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
@@ -33,6 +33,7 @@ import { SleeveWorkType } from "../Sleeve/Work/Work";
import { calculateSkillProgress as calculateSkillProgressF, ISkillProgress } from "../formulas/skill";
import { AddToAllServers, createUniqueRandomIp } from "../../Server/AllServers";
import { safelyCreateUniqueServer } from "../../Server/ServerHelpers";
import { Location } from "../../Locations/Location";
import { SpecialServers } from "../../Server/data/SpecialServers";
import { applySourceFile } from "../../SourceFile/applySourceFile";
@@ -55,6 +56,7 @@ import { Augmentations } from "../../Augmentation/Augmentations";
import { PlayerEventType, PlayerEvents } from "./PlayerEvents";
import { Result } from "../../types";
import type { AchievementId } from "../../Achievements/Types";
import { Infiltration } from "../../Infiltration/Infiltration";
export function init(this: PlayerObject): void {
/* Initialize Player's home computer */
@@ -599,3 +601,10 @@ export function focusPenalty(this: PlayerObject): number {
}
return focus;
}
/** This doesn't change the current page; that is up to the caller. */
export function startInfiltration(this: PlayerObject, location: Location): void {
if (!location.infiltrationData)
throw new Error(`trying to start infiltration at ${location.name} but the infiltrationData is null`);
this.infiltration = new Infiltration(location);
}