summary refs log tree commit diff stats
path: root/src/behaviour_system.h
blob: d338c791d272a987f6dad47af09c3c4ffe21891f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef BEHAVIOUR_SYSTEM_H_FC908ABE
#define BEHAVIOUR_SYSTEM_H_FC908ABE

#include "system.h"
#include "timer.h"
#include "vector.h"

enum class PathfindingOptions {
  None                    = 0,
  CardinalDirectionsOnly  = 1 << 0,
  Moonwalking             = 1 << 1
};

class Game;

class BehaviourSystem : public System {
public:

  static constexpr SystemKey Key = SystemKey::Behaviour;

  explicit BehaviourSystem(Game& game) : game_(game) {}

  void tick(double dt) override;

  void directSpriteToLocation(int spriteId, vec2i pos, PathfindingOptions options = PathfindingOptions::None);

  bool isFollowingPath(int spriteId);

private:

  void createPath(int spriteId);

  Game& game_;
  Timer timer_ { 500 };
  Timer overcorrectionTimer_ { 1000/60 };
};

#endif /* end of include guard: BEHAVIOUR_SYSTEM_H_FC908ABE */