-
Notifications
You must be signed in to change notification settings - Fork 1
/
entity.h
151 lines (129 loc) · 3.8 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#ifndef __ENTITY_H__
#define __ENTITY_H__
#include "detectable.h"
#include "resourcemgr.h"
#include <string>
#include <vector>
//Keeps track of number of entity types we have
// mostly useful for the entity container but
// easier to edit here since this is where they're
// added.
#define ENTITY_TYPE_NUM 5
using namespace std;
class EntityContainer;
enum EntityType
{
BALL = 0,
BUTTON = 1,
DOOR = 2,
MAGNET = 3,
WALL = 4,
BUMPER = 5,
GENERAL = 6
};
enum Stimulus
{
ONTOUCH = 0,
ONUNTOUCH = 1
};
enum Response
{
OPEN = 0,
CLOSE = 1
};
class StimResp
{
public:
Stimulus stimulus;
string targetName;
Response response;
StimResp( Stimulus stim, const string& targetName, Response resp )
:stimulus( stim ), targetName( targetName ), response( resp )
{}
};
struct TouchedInfo
{
string name;
Point loc1, loc2;
double xAmount;
double yAmount;
double mass;
TouchedInfo(string n, double x, double y)
{
name = n;
xAmount = x;
yAmount = y;
}
TouchedInfo(string n, Point p1, Point p2, double x, double y)
{
name = n;
loc1 = p1;
loc2 = p2;
xAmount = x;
yAmount = y;
}
TouchedInfo(string n, Point p1, Point p2, double x, double y, double m)
{
name = n;
loc1 = p1;
loc2 = p2;
xAmount = x;
yAmount = y;
mass = m;
}
};
class Entity
:public Detectable
{
protected:
EntityContainer* entityContainer;
protected:
EntityType eType;
int health;
bool destructible;
string name;
ResourceMgr* resourceMgr;
vector<string> touchedBy;
vector<struct TouchedInfo> touchedInfo;
vector<string> unTouchedBy;
vector<StimResp> StimulusResponseList;
public:
Entity();
Entity( EntityType type, string name, int health, bool destructible, Point upperLeft, Point lowerRight, Substance substance, DetectableType type, bool fixed, bool moves );
Entity( EntityType type, string name, int health, bool destructible, Point upperLeft, double width, double height, Substance substance, DetectableType type, bool fixed, bool moves );
Entity( EntityType type, string name, int health, bool destructible, Point center, double radius, Substance substance, DetectableType type, bool fixed, bool moves );
string getName();
virtual ~Entity();
void insertStimResp( Stimulus stim, const string& targetName, Response resp );
//STIMULUS FUNCTIONS
//Will be called in handle flags functions.
virtual void onTouch();
virtual void onUnTouch();
//Response
virtual void open();
virtual void close();
//Misc
virtual void onAlways();
virtual void onFrameEnd();
void touch( const string& name );
void handleFlags();
void callFunction( const string& entityName, Response funcName );
void callFunction( const vector<StimResp>& srList, Stimulus stim );
virtual void draw();
virtual void wasTouchedBy(Detectable* d, Point loc1, Point loc2, double xAmount, double yAmount);
void printSR();
bool touched(const string name) const;
//Organize later
EntityType getEntityType();
Entity* getEntity( const string& entityName );
const vector< Entity* >& getEntitiesOfType( EntityType eType ) const;
const vector< Entity* >& getAllEntities() const;
void insertStimResp( const StimResp & stimResp );
//////////////////////////////////////////////////////////
/////////DESCRIBE YOUR FUNCTIONS HERE ILL PROTOTYPE AND
/////////DEFINE THEM LATER JEW BASTARDS
//////////////////////////////////////////////////////////
/*
*/
};
#endif