summary refs log tree commit diff stats
path: root/src/systems/pondering.h
blob: adc0cdaf83697ca2d876469672ea4332945cd5f9 (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 PONDERING_H_F2530E0E
#define PONDERING_H_F2530E0E

#include "system.h"
#include "components/ponderable.h"
#include "direction.h"

class PonderingSystem : public System {
public:

  PonderingSystem(Game& game) : System(game)
  {
  }

  void tick(double dt);

  void initializeBody(id_type entity, PonderableComponent::Type type);

  /**
   * Initializes a ponderable map object from its prototype data.
   *
   * @requires entity is ponderable
   * @requires entity is a map object
   */
  void initPrototype(id_type prototype);

  /**
   * Unferries an entity if it is a passenger of another entity. Use before
   * moving a ponderable entity outside the PonderingSystem.
   *
   * @requires entity is ponderable
   */
  void unferry(id_type entity);

private:

  struct CollisionResult
  {
    double newX;
    double newY;
    bool stopProcessing = false;
    bool touchedWall = false;
    bool adjacentlyWarping = false;
    Direction adjWarpDir;
    size_t adjWarpMapId;
    id_type groundEntity;
  };

  void processCollision(
    id_type entity,
    id_type collider,
    Direction dir,
    PonderableComponent::Collision type,
    double axis,
    double lower,
    double upper,
    CollisionResult& result);

};

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