Creeps extract memory completly

This commit is contained in:
douwe
2025-08-22 03:11:44 +02:00
parent cd1464cc94
commit 6ee67eac47
9 changed files with 55 additions and 31 deletions

View File

@@ -9,9 +9,25 @@ namespace DouwcoHivemind
{
class HarvesterRole : public Creep
{
private:
bool harvesting;
std::string target_id;
int taskCounter;
public:
HarvesterRole(Screeps::Creep crp) : Creep(crp) {}
~HarvesterRole() {}
HarvesterRole(Screeps::Creep crp) : Creep(crp)
{
harvesting = memory.contains("harvesting") ? static_cast<bool>(memory["harvesting"]) : false;
target_id = memory.contains("target_id") ? static_cast<std::string>(memory["target_id"]) : std::string();
taskCounter = memory.contains("taskCounter") ? static_cast<int>(memory["taskCounter"]) : 0;
}
~HarvesterRole() override
{
memory["harvesting"] = harvesting;
memory["target_id"] = target_id;
memory["taskCounter"] = taskCounter;
}
void loop() override;