Commit d6d87dcd authored by louiz’'s avatar louiz’

Minor fixes

parent 0c3a673f
......@@ -36,4 +36,3 @@ ser::game::Occupant Occupant::serialize() const
srlzed.set_team(this->team);
return srlzed;
}
......@@ -39,9 +39,9 @@ public:
void on_modified() const;
template <typename InputIt>
void assign(InputIt first, InputIt last)
{
this->entities.assign(first, last);
}
{
this->entities.assign(first, last);
}
std::vector<t_selection_changed_callback> on_modified_callbacks;
......
......@@ -50,6 +50,17 @@ public:
Work* get_current_work();
const Work* get_current_work() const;
template <typename WorkType>
WorkType* get_current_work()
{
return dynamic_cast<WorkType*>(this->get_current_work());
}
template <typename WorkType>
const WorkType* get_current_work() const
{
return dynamic_cast<const WorkType*>(this->get_current_work());
}
template <typename ComponentClass>
ComponentClass* get() const
{
......@@ -172,6 +183,7 @@ public:
* The list of Status that currently affect this entity.
*/
std::vector<std::unique_ptr<Status>> status;
std::unique_ptr<Brain> brain;
};
#endif // __ENTITY_HPP__
......@@ -7,6 +7,8 @@
#include <world/entity.hpp>
class World;
static constexpr std::size_t MaxEntityModels = 32;
class EntityFactory
......@@ -14,7 +16,7 @@ class EntityFactory
public:
EntityFactory();
~EntityFactory();
std::unique_ptr<Entity> make_entity(const EntityType type);
std::unique_ptr<Entity> make_entity(World* world, const EntityType type);
private:
std::vector<Entity> entity_models;
......
......@@ -18,6 +18,8 @@ public:
bool tick(World* world) override final;
TaskType get_type() const override final
{ return TaskType::Path; }
const Path& get_path() const
{ return this->path; }
private:
/**
......
......@@ -9,10 +9,6 @@ class World;
class Entity;
/**
* The function to call at each tick of the entity owning that work. It
* returns true if that work is complete and must be removed from the queue,
* false otherwise.
*
* A work is composed of one or more Task. Each Work::tick(), we call
* task.tick(). We may also change the value of the current work, depending
* on some world condition, or if the current task finished (tick() returned
......@@ -27,6 +23,10 @@ public:
world(world) {}
virtual ~Work();
/**
* The function to call at each tick of the entity owning that work. It
* returns true if that work is complete and must be removed from the queue,
* false otherwise.
*
* May set/change the current task. Then call tick() on that Task.
*/
virtual bool tick() = 0;
......@@ -44,6 +44,17 @@ public:
Task* get_task();
const Task* get_task() const;
template <typename TaskType>
TaskType* get_task()
{
return dynamic_cast<TaskType*>(this->get_task());
}
template <typename TaskType>
const TaskType* get_task() const
{
return dynamic_cast<const TaskType*>(this->get_task());
}
protected:
/**
* Set the current Task of this work. Also call
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment