-
Notifications
You must be signed in to change notification settings - Fork 1
/
Entity.h
92 lines (77 loc) · 2.72 KB
/
Entity.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
81
82
83
84
85
86
87
88
89
90
91
92
#ifndef _ENTITY_H_
#define _ENTITY_H_
#include <memory>
#include "Vector.h"
#include "BBox.h"
namespace typing
{
class BBox;
class Entity
{
public:
virtual const juzutil::Vector3& GetOrigin() const = 0;
virtual bool IsSolid() const = 0;
virtual char GetStartChar() const = 0;
virtual bool StartsWith(const char c) const = 0;
virtual bool IsPhraseSingle() const = 0;
virtual float GetTypingSpeed() const = 0;
virtual bool Unlink() const = 0;
virtual void OnType(char c,
bool *hit,
bool *phraseFinished) = 0;
virtual const BBox GetBounds() const
{
return BBox();
}
virtual void OnCollide()
{
}
// OnPlayerDie
// Called when the player loses a life. Used eg. to ensure all enemies
// are removed when the player dies.
virtual void OnPlayerDie()
{
}
// Draw2D
// Called once a frame to render the 2D aspects of the entity's appearance.
// This is mainly used for drawing the phrase associated with an entity.
// Orthographic projection will already have been set up before this is
// called.
virtual void Draw2D()
{
}
// Draw3D
// Called once a frame to render the 3D aspects of the entity's appearance.
virtual void Draw3D()
{
}
// OnSpawn
// Called when an entity is added to the game's list of entities. The
// entity should perform any actions it needs to before updating, such
// as setting firing timers etc.
virtual void OnSpawn()
{
}
// Update
// Called once a frame. The entity should perform any actions needed to update
// the state of the entity, such as moving or firing.
virtual void Update()
{
}
// SuppressAwardDisplay
// Called when the award for an entity's phrase is displayed,
// to determine whether the award display should be suppressed,
// for example if the entity will add its own award.
virtual bool SuppressAwardDisplay()
{
return false;
}
virtual unsigned int GetScore() const
{
return 0;
}
};
typedef std::shared_ptr<Entity> EntityPtr;
typedef std::weak_ptr<Entity> EntityWeakPtr;
}
#endif // _ENTITY_H_