Fixes Game Source Pos

Fixes Game Source Pos
This commit is contained in:
2025-07-07 08:41:47 -03:00
parent bb3f797fc3
commit 4f28d240e0
6 changed files with 104 additions and 20 deletions

View File

@@ -9,11 +9,22 @@ declare global {
Types added in this `global` block are in an ambient, global context. This is needed because `main.ts` is a module file (uses import or export).
Interfaces matching on name from @types/screeps will be merged. This is how you can extend the 'built-in' interfaces from @types/screeps.
*/
interface SourceState {
id: string;
pos: RoomPosition;
maxHarvesters: number|null;
currentHarvesters: number;
}
interface GameState {
sourcesStates: { [sourceId: string]: SourceState };
}
// Memory extension samples
interface Memory {
uuid: number;
log: any;
spawnHandlers: { [name: string]: string };
spawnStates: { [name: string]: GameState };
}
interface CreepMemory {
@@ -32,8 +43,13 @@ declare global {
export const loop = () => {
Memory.spawnStates = Memory.spawnStates || {};
for (const spawnName of Object.keys(Game.spawns)) {
// Run the handler
new SpawnHandler(Game.spawns[spawnName]).run();
const spawnState = Memory.spawnStates[spawnName] || {};
const spawnHandler = new SpawnHandler(Game.spawns[spawnName]);
Memory.spawnStates[spawnName] = spawnHandler.run(spawnState);
}
};