MISC: Expose internal data in dev build (#1611)

This commit is contained in:
catloversg 2024-08-22 07:50:11 +07:00 committed by GitHub
parent 8d9f63f49f
commit 4a3dcf8a26
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -22,7 +22,7 @@ import { checkForMessagesToSend } from "./Message/MessageHelpers";
import { loadAllRunningScripts, updateOnlineScriptTimes } from "./NetscriptWorker"; import { loadAllRunningScripts, updateOnlineScriptTimes } from "./NetscriptWorker";
import { Player } from "@player"; import { Player } from "@player";
import { saveObject, loadGame } from "./SaveObject"; import { saveObject, loadGame } from "./SaveObject";
import { initForeignServers } from "./Server/AllServers"; import { GetAllServers, initForeignServers } from "./Server/AllServers";
import { Settings } from "./Settings/Settings"; import { Settings } from "./Settings/Settings";
import { FormatsNeedToChange } from "./ui/formatNumber"; import { FormatsNeedToChange } from "./ui/formatNumber";
import { initSymbolToStockMap, processStockPrices } from "./StockMarket/StockMarket"; import { initSymbolToStockMap, processStockPrices } from "./StockMarket/StockMarket";
@ -46,6 +46,22 @@ import { SnackbarEvents } from "./ui/React/Snackbar";
import { SaveData } from "./types"; import { SaveData } from "./types";
import { Go } from "./Go/Go"; import { Go } from "./Go/Go";
import { EventEmitter } from "./utils/EventEmitter"; import { EventEmitter } from "./utils/EventEmitter";
import { Companies } from "./Company/Companies";
declare global {
// This property is only available in the dev build
// eslint-disable-next-line no-var
var Bitburner: {
Player: typeof Player;
GetAllServers: typeof GetAllServers;
Factions: typeof Factions;
Companies: typeof Companies;
SaveObject: {
saveObject: typeof saveObject;
loadGame: typeof loadGame;
};
};
}
// Only show warning if the time diff is greater than this value. // Only show warning if the time diff is greater than this value.
const thresholdOfTimeDiffForShowingWarningAboutSystemClock = CONSTANTS.MillisecondsPerFiveMinutes; const thresholdOfTimeDiffForShowingWarningAboutSystemClock = CONSTANTS.MillisecondsPerFiveMinutes;
@ -408,6 +424,24 @@ const Engine: {
// Start interactive tutorial // Start interactive tutorial
iTutorialStart(); iTutorialStart();
} }
// Expose internal objects/functions in the dev build
if (process.env.NODE_ENV === "development") {
globalThis.Bitburner = {
// Most data is in this object
Player: Player,
// Manipulate data of servers
GetAllServers: GetAllServers,
// Manipulate data of Factions and Companies
Factions: Factions,
Companies: Companies,
// saveObject and loadGame can be used to create a custom save/load tool
SaveObject: {
saveObject: saveObject,
loadGame: loadGame,
},
};
}
}, },
start: function () { start: function () {