Changes to esbuild and adds initial creation of creaps
This commit is contained in:
57
src/main.ts
57
src/main.ts
@@ -1,7 +1,7 @@
|
||||
import SpawnHandler from "spawnHandler";
|
||||
|
||||
declare global {
|
||||
/*
|
||||
/*
|
||||
Example types, expand on these or remove them and add your own.
|
||||
Note: Values, properties defined here do no fully *exist* by this type definiton alone.
|
||||
You must also give them an implemention if you would like to use them. (ex. actually setting a `role` property in a Creeps memory)
|
||||
@@ -9,24 +9,25 @@ 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.
|
||||
*/
|
||||
// Memory extension samples
|
||||
interface Memory {
|
||||
uuid: number;
|
||||
log: any;
|
||||
}
|
||||
|
||||
interface CreepMemory {
|
||||
role: string;
|
||||
room: string;
|
||||
working: boolean;
|
||||
}
|
||||
|
||||
// Syntax for adding proprties to `global` (ex "global.log")
|
||||
namespace NodeJS {
|
||||
interface Global {
|
||||
log: any;
|
||||
// Memory extension samples
|
||||
interface Memory {
|
||||
uuid: number;
|
||||
log: any;
|
||||
spawnHandlers: { [name: string]: SpawnHandler };
|
||||
}
|
||||
|
||||
interface CreepMemory {
|
||||
role: string;
|
||||
room: string;
|
||||
working: boolean;
|
||||
}
|
||||
|
||||
// Syntax for adding proprties to `global` (ex "global.log")
|
||||
namespace NodeJS {
|
||||
interface Global {
|
||||
log: any;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// When compiling TS to JS and bundling with rollup, the line numbers and file names in error messages change
|
||||
@@ -42,10 +43,18 @@ declare global {
|
||||
// }
|
||||
// });
|
||||
export const loop = () => {
|
||||
for (const spawn of Object.values(Game.spawns)) {
|
||||
// Create a handler for each spawn
|
||||
const spawnHandler = new SpawnHandler(spawn);
|
||||
// Run the handler
|
||||
spawnHandler.run();
|
||||
}
|
||||
Memory.spawnHandlers = Memory.spawnHandlers || {};
|
||||
|
||||
console.log(`Current game tick is ${Game.time}`);
|
||||
|
||||
// Check if spawn still exists
|
||||
|
||||
for (const spawn of Object.values(Game.spawns)) {
|
||||
// Create a handler for each spawn
|
||||
if (spawn.name in Memory.spawnHandlers) {
|
||||
Memory.spawnHandlers[spawn.name] = new SpawnHandler(spawn);
|
||||
}
|
||||
// Run the handler
|
||||
Memory.spawnHandlers[spawn.name].run();
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user