-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGameEntity.h
80 lines (59 loc) · 2.5 KB
/
GameEntity.h
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//
// Created by Paul on 29.04.2017.
//
#ifndef PAXENGINE3_GAMEENTITY_H
#define PAXENGINE3_GAMEENTITY_H
#include <polypropylene/property/Entity.h>
#include <polypropylene/prefab/Prefab.h>
#include <polypropylene/property/EntityManagerView.h>
#include "polypropylene/event/EventHandler.h"
#include "polypropylene/event/EventService.h"
#include <paxutil/math/Transformation.h>
#include "MotionType.h"
#include "Tag.h"
#include "event/GameEntityParentChangedEvent.h"
#include "GameEntityProperty.h"
#include "property/AbilityIdentifier.h"
namespace PAX {
class World;
using GameEntityPrefab = Prefab<GameEntity>;
class GameEntity final : public Entity<GameEntity, GameEntityProperty> {
friend class World;
private:
Transformation transform;
// The motionType should actually be const, but it made problems with prefabs.
MotionType motionType = MotionType::Static;
std::vector<Tag> tags;
GameEntity * parent = nullptr;
std::vector<GameEntity*> children;
World *world = nullptr;
protected:
void onPropertyAdded(GameEntityProperty *property) override;
void onPropertyRemoved(GameEntityProperty *property) override;
public:
EventHandler<GameEntityParentChangedEvent&> OnParentChanged;
GameEntity();
~GameEntity() override;
PAX_NODISCARD Transformation& getTransformation();
PAX_NODISCARD const Transformation& getTransformation() const;
void setParent(GameEntity *parent);
PAX_NODISCARD GameEntity* getParent() const;
PAX_NODISCARD const std::vector<GameEntity*>& getChildren() const;
PAX_NODISCARD World* getWorld() const;
// TODO: This should not be changeable later. Add some sort of finalisation or so.
void i_setMotionType(MotionType motionType);
PAX_NODISCARD MotionType getMotionType() const;
void addTag(const Tag & tag);
bool removeTag(const Tag & tag);
PAX_NODISCARD bool hasTag(const Tag & tag) const;
PAX_NODISCARD const std::vector<Tag> & getTags() const;
AbilityResult startPerforming(const AbilityIdentifier & abilityName) const;
AbilityResult endPerforming(const AbilityIdentifier & abilityName) const;
void spawned();
void despawned();
};
using GameEntityManager = EntityManager<GameEntity>;
template<typename... RequiredProperties>
using GameEntityManagerView = EntityManagerView<GameEntity, RequiredProperties...>;
}
#endif //PAXENGINE3_GAMEENTITY_H