Created a base engine class and let it handle all creeps.

This commit is contained in:
douwe
2025-08-21 14:13:32 +02:00
parent c9ce09ba1a
commit 1e9e696b1e
16 changed files with 221 additions and 91 deletions

View File

@@ -7,30 +7,25 @@
#include <emscripten/val.h>
#include "Constants.hpp"
#include "creeps/harvester.hpp"
#include "structures/spawn.hpp"
#include "Engine.hpp"
#include "Structures/Spawn.hpp"
EMSCRIPTEN_KEEPALIVE
extern "C" void loop()
{
Screeps::Context::update();
EM_ASM({console.log('Starting loop: ')});
// Structures
for (auto& spawn_entry : Screeps::Game.spawns())
{
auto spawn = DouwcoHivemind::Spawn(&spawn_entry.second);
spawn.process();
}
DouwcoHivemind::Engine engine;
engine.loop();
// Creeps
auto creeps = Screeps::Game.creeps();
for (auto& creep : creeps){
if (creep.second.memory()["role"] == DouwcoHivemind::ROLE_HARVESTER)
{
auto harvester = DouwcoHivemind::HarvesterRole(&creep.second);
harvester.process();
}
}
EM_ASM({console.log('\n\n\n')});
}
EMSCRIPTEN_BINDINGS(loop)