NETSCRIPT: Expose more enums for player use (#198)

* Add support for enums at other ns layers
* APIWrapper: simplified wrapping algorithm and modified to just use cloneDeep to copy enums instead of recursively wrapping enums as if they were new API layers
* Improve APIWrapper typing
* Changed some typings at RamCostGenerator to allow for enums at different levels without enums needing a ram cost
* Added enums to ns.corporation, removed getter functions that were being used instead.
* Add FactionWorkType for player use
* Add ClassType and CompanyWorkPos enums
* Change netscriptDefinitions to expect members of these new enums where appropriate.
This commit is contained in:
Snarling
2022-11-09 13:46:21 -05:00
committed by GitHub
parent 8e0e0eaa88
commit b275f88053
13 changed files with 355 additions and 285 deletions
+2 -1
View File
@@ -16,6 +16,7 @@ import { BaseServer } from "../Server/BaseServer";
import { NS } from "../ScriptEditor/NetscriptDefinitions";
import { ScriptDeath } from "./ScriptDeath";
import { ScriptArg } from "./ScriptArg";
import { ExternalAPI } from "./APIWrapper";
export class WorkerScript {
/** Script's arguments */
@@ -82,7 +83,7 @@ export class WorkerScript {
/** Function called when the script ends. */
atExit?: () => void;
constructor(runningScriptObj: RunningScript, pid: number, nsFuncsGenerator?: (ws: WorkerScript) => NS) {
constructor(runningScriptObj: RunningScript, pid: number, nsFuncsGenerator?: (ws: WorkerScript) => ExternalAPI<NS>) {
this.name = runningScriptObj.filename;
this.hostname = runningScriptObj.server;