REFACTOR: Rewrite infiltration to pull state out of React (#2316)

* REFACTOR: Rewrite infiltration to pull state out of React

Upcoming projects (auto-infil, the possibility of making infil a work
task, etc.) require infiltration state to transition with predictable
timing and be under our control, instead of inside React. This refactor
accomplishes this by pulling the state out into accompanying model
classes.

After this, infiltration can theoretically run headless (without UI),
although it doesn't actually, and you would quickly be
hospitalized due to failing all the minigames.

There should be no user-visible changes, aside from the progress-bars
scrolling much more smoothly.

* Fix console warning in InfiltrationRoot

It turns out true isn't actually a safe value to use in JSX, only false works.

* Fix up some comments
This commit is contained in:
David Walker
2025-11-16 22:55:06 -08:00
committed by GitHub
parent 57ca5ffeaf
commit 4d230c3121
39 changed files with 1620 additions and 1496 deletions

View File

@@ -2,6 +2,7 @@ import type { BitNodeOptions, Player as IPlayer } from "@nsdefs";
import type { PlayerAchievement } from "../../Achievements/Achievements";
import type { Bladeburner } from "../../Bladeburner/Bladeburner";
import type { Corporation } from "../../Corporation/Corporation";
import type { Infiltration } from "../../Infiltration/Infiltration";
import type { Exploit } from "../../Exploits/Exploit";
import type { Gang } from "../../Gang/Gang";
import type { HacknetNode } from "../../Hacknet/HacknetNode";
@@ -24,6 +25,7 @@ import { constructorsForReviver, Generic_toJSON, Generic_fromJSON, IReviverValue
import { JSONMap, JSONSet } from "../../Types/Jsonable";
import { cyrb53 } from "../../utils/HashUtils";
import { getRandomIntInclusive } from "../../utils/helpers/getRandomIntInclusive";
import { getKeyList } from "../../utils/helpers/getKeyList";
import { CONSTANTS } from "../../Constants";
import { Person } from "../Person";
import { isMember } from "../../utils/EnumHelper";
@@ -36,6 +38,7 @@ export class PlayerObject extends Person implements IPlayer {
corporation: Corporation | null = null;
gang: Gang | null = null;
bladeburner: Bladeburner | null = null;
infiltration: Infiltration | null = null;
currentServer = "";
factions: FactionName[] = [];
factionInvitations: FactionName[] = [];
@@ -149,6 +152,7 @@ export class PlayerObject extends Person implements IPlayer {
activeSourceFileLvl = generalMethods.activeSourceFileLvl;
applyEntropy = augmentationMethods.applyEntropy;
focusPenalty = generalMethods.focusPenalty;
startInfiltration = generalMethods.startInfiltration;
constructor() {
super();
@@ -178,7 +182,8 @@ export class PlayerObject extends Person implements IPlayer {
/** Serialize the current object to a JSON save state. */
toJSON(): IReviverValue {
return Generic_toJSON("PlayerObject", this);
// For the time being, infiltration is not part of the save.
return Generic_toJSON("PlayerObject", this, getKeyList(PlayerObject, { removedKeys: ["infiltration"] }));
}
/** Initializes a PlayerObject object from a JSON save state. */