Commit 07b3ce2e authored by louiz’'s avatar louiz’

Convert PathWork into a SingleTaskWork<PathTask>

parent 9de13489
#include <world/works/path_work.hpp>
#include <world/tasks/path_task.hpp>
#include <world/world.hpp>
#include <world/entity.hpp>
PathWork::PathWork(Entity* entity, const Position& destination):
Work(entity),
destination(destination)
{
}
bool PathWork::tick(World* world)
{
if (!this->task)
this->set_task(world,
std::make_unique<PathTask>(this->entity, this->destination));
return this->task->tick(world);
}
#ifndef PATH_WORK_HPP_INCLUDED
#define PATH_WORK_HPP_INCLUDED
#include <world/work.hpp>
#include <world/position.hpp>
#include <world/works/single_task_work.hpp>
#include <world/tasks/path_task.hpp>
class Entity;
class PathWork: public Work
{
public:
PathWork(Entity* entity, const Position& destination);
~PathWork() = default;
bool tick(World* world) override final;
private:
const Position destination;
PathWork(const PathWork&);
PathWork& operator=(const PathWork&);
};
using PathWork = SingleTaskWork<PathTask>;
#endif /* PATH_WORK_HPP_INCLUDED */
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