attack_task.hpp 1.17 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
#ifndef ATTACK_TASK_HPP_INCLUDED
#define ATTACK_TASK_HPP_INCLUDED

#include <world/task.hpp>

#include <memory>

class Location;

class AttackTask: public Task
{
public:
13 14
  AttackTask(Entity* entity, std::weak_ptr<Entity> target, const std::size_t fs,
             const std::size_t bs, const bool ranged);
15 16 17 18
  ~AttackTask() = default;
  bool tick(World* world) override final;
  TaskType get_type() const override final
  { return TaskType::Attack; }
louiz’'s avatar
louiz’ committed
19 20 21 22 23
  /**
   * in ticks
   */
  std::size_t get_remaining_frontswing_duration() const;
  std::size_t get_remaining_backswing_duration() const;
24 25

private:
26
  void do_attack(World* world);
27 28 29 30 31 32
  /**
   * If the target becomes unavailable before the attack point is reached,
   * this task is over.
   */
  std::weak_ptr<Entity> target;
  Location* location;
33 34 35
  /**
   * Number of ticks needed to complete the front and backswings
   */
36 37 38
  std::size_t frontswing;
  std::size_t backswing;
  bool attack_point_reached;
39
  const bool ranged;
40 41 42 43 44 45 46 47 48

  AttackTask(const AttackTask&) = delete;
  AttackTask(AttackTask&&) = delete;
  AttackTask& operator=(const AttackTask&) = delete;
  AttackTask& operator=(AttackTask&&) = delete;
};


#endif /* ATTACK_TASK_HPP_INCLUDED */