Improved walking system.
This commit is contained in:
@@ -2,9 +2,12 @@
|
||||
#define DOUWCO_HIVEMIND_CREEP_HPP
|
||||
|
||||
#include <Screeps/Creep.hpp>
|
||||
#include <Screeps/ReturnTypes.hpp>
|
||||
#include "Tools/JsonTool.hpp"
|
||||
#include "Tools/PathTool.hpp"
|
||||
|
||||
namespace Screeps{
|
||||
class RoomPosition;
|
||||
class RoomObject;
|
||||
class PathStep;
|
||||
}
|
||||
|
||||
namespace DouwcoHivemind
|
||||
{
|
||||
@@ -13,39 +16,26 @@ namespace DouwcoHivemind
|
||||
UNEMPLOYED,
|
||||
HARVESTER
|
||||
};
|
||||
|
||||
class Creep
|
||||
{
|
||||
public:
|
||||
CreepRole role;
|
||||
std::string target_id;
|
||||
std::vector<Screeps::PathStep> path;
|
||||
|
||||
protected:
|
||||
Screeps::Creep creep;
|
||||
JSON memory;
|
||||
|
||||
public:
|
||||
Creep(Screeps::Creep crp) : creep(crp),
|
||||
memory(crp.memory())
|
||||
{
|
||||
role = memory.contains("role") ? static_cast<CreepRole>(memory["role"]) : CreepRole::UNEMPLOYED;
|
||||
target_id = memory.contains("target_id") ? static_cast<std::string>(memory["target_id"]) : std::string();
|
||||
path = memory.contains("path") ? unflattenPathSteps(jsonToVector<int>(memory["path"])) : std::vector<Screeps::PathStep>();
|
||||
}
|
||||
virtual ~Creep()
|
||||
{
|
||||
memory["target_id"] = target_id;
|
||||
memory["path"] = vectorToJson(flattenPathSteps(path));
|
||||
creep.setMemory(memory);
|
||||
}
|
||||
|
||||
Creep(Screeps::Creep crp);
|
||||
virtual ~Creep();
|
||||
virtual void loop() {}
|
||||
bool isNearTo(const Screeps::RoomPosition &pos, int dist);
|
||||
|
||||
protected:
|
||||
void moveToTarget(int dist = 1);
|
||||
std::unique_ptr<Screeps::RoomObject> getRoomObjectTarget();
|
||||
bool isNearTo(const Screeps::RoomPosition &pos1, const Screeps::RoomPosition &pos2, int dist);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user