Created a base engine class and let it handle all creeps.
This commit is contained in:
19
src/loop.cpp
19
src/loop.cpp
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user