Files
screeps/include/Creeps/Harvester.hpp
2025-08-22 03:11:44 +02:00

47 lines
1.3 KiB
C++

#ifndef DOUWCO_HIVEMIND_HARVESTER_HPP
#define DOUWCO_HIVEMIND_HARVESTER_HPP
#include <Screeps/Creep.hpp>
#include "Creeps/Creep.hpp"
namespace DouwcoHivemind
{
class HarvesterRole : public Creep
{
private:
bool harvesting;
std::string target_id;
int taskCounter;
public:
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;
private:
void harvestSource();
std::unique_ptr<Screeps::Source> getSourceTarget();
void searchSource();
void depositEnergy();
std::unique_ptr<Screeps::Structure> getDepositTarget();
void searchDeposit();
std::unique_ptr<Screeps::RoomObject> getRoomObjectTarget();
};
}
#endif // DOUWCO_HIVEMIND_HARVESTER_HPP