summary refs log tree commit diff stats
path: root/src/character_system.h
blob: dff2a7f79602964ce9d49301e54fec5d9f3a8cb5 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef PARTY_H_826F91BA
#define PARTY_H_826F91BA

#include "system.h"
#include "direction.h"
#include "timer.h"
#include "sprite.h"

class Mixer;
class Game;
class Input;

class CharacterSystem : public System {
public:

  static constexpr SystemKey Key = SystemKey::Character;

  CharacterSystem(Game& game) : game_(game) {}

  void initSprite(int spriteId, int movementSpeed);

  void tick(double dt) override;

  void addSpriteToParty(int leaderId, int followerId);

  void transplantParty(int leaderId, vec2i pos, Direction dir);

  void breakUpParty(int leaderId);

  void moveInDirection(int spriteId, Direction dir);

  void stopDirecting(int spriteId);

  void beginCrouch(int spriteId);

  void endCrouch(int spriteId);

  void startRunning(int spriteId);

  void halt(int spriteId);

  void destroySprite(int spriteId) override;

private:

  void stopRunning(int spriteId);

  void setPartyState(int spriteId, CharacterState state);

  void stopRunningSound(Sprite& sprite);

  // state should be the party leader's state
  void setAnimationFor(int spriteId, CharacterState state);

  void adjustPartyTrails(int spriteId);

  Game& game_;
  Timer inputTimer_ {33};
};

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