Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
blob: 5cfeb3eebfa8fe6185207edc44e2e14646a43024 (plain)
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
/*
   core/slot.h
   This file is part of the Osirion project and is distributed under
   the terms of the GNU General Public License version 2.
*/

#ifndef __INCLUDED_CORE_SLOT_H__
#define __INCLUDED_CORE_SLOT_H__

#include "math/vector3f.h"
#include "math/axis.h"

#include "core/item.h"

#include <string>

namespace core
{
	
/**
 * @brief A mount point for a weapon or a piece of equipment
 * */
class Slot {
public:
	enum Flags {Mounted = 1, Active = 2};
	
	/**
	 * @brief default constructor
	 * Creates an empty slot
	 * */
	Slot();

	/**
	 * @brief default destructor
	 * */
	~Slot();
	
	/**
	 * @brief location of the slot within the parent model
	 * */
	inline const math::Vector3f & location() const
	{
		return slot_location;
	}

	/**
	 * @brief axis indication the slot's orientation
	 * */
	inline const math::Axis & axis() const
	{
		return slot_axis;
	}

	/**
	 * @brief slot flags
	 * */
	inline const unsigned int flags() const
	{
		return slot_flags;
	}
	
	/**
	 * @brief return true if a specified flag is set
	 * */
	inline const bool has_flag(const Flags flag)
	{
		return ( (slot_flags & flag) == flag );
	}
	
	/**
	 * @brief the item this slot is holding
	 * */
	inline core::Item *item()
	{
		return slot_item;
	}
	
	/**
	 * @brief timestamp indicating when the slot was last fired,server-side
	 * This is a server-side property
	 * */
	inline unsigned long last_fired() const
	{
		return slot_last_fired;
	}
	
	/**
	 * @brief timestamp indicating when the slot was last fire, client-side
	 * This is a client-side property
	 * */
	inline unsigned long last_ejected() const
	{
		return slot_last_ejected;
	}
	
	/**
	 * @brief interval between two consequtive shots by this slot, in milliseconds
	 * */
	inline unsigned long projectile_interval() const
	{
		return slot_projectile_interval;
	}
	
	/**
	 * @brief lifespan of a projectile generated by this slot, in milliseconds
	 * */
	inline unsigned long projectile_lifespan() const 
	{
		return slot_projectile_lifespan;
	}
	
	/**
	 * @brief speed of a projectile generated by this slot, in game units per second
	 * */
	inline  float projectile_speed() const
	{
		return slot_projectile_speed;
	}
	
	/**
	 * @brief damage done by a projectile generated by this slot
	 * */
	inline float projectile_damage() const
	{
		return slot_projectile_damage;
	}
	
	/**
	 * @brief model name used to draw projectiles generated by this slot
	 * */
	inline const std::string & projectile_modelname() const
	{
		return slot_projectile_modelname;
	}
		
	/* --- mutators -------------------------------------------- */

	/**
	 * @brief set the slot's location
	 * */
	inline void set_location(const math::Vector3f &location)
	{
		slot_location.assign(location);
	}
	
	/**
	 * @brief set the slot's orientation
	 */
	inline void set_axis(const math::Axis & axis)
	{
		slot_axis.assign(axis);
	}
	
	/**
	 * @brief set a specified flags
	 * */
	void set_flag(const Flags flag);

	/**
	 * @brief unset a specified flags
	 * */
	void unset_flag(const Flags flag);
		
	/**
	 * @brief set the slot's timestamp
	 * The timestamp indicates when the slot's configuration was last changed.
	 * */
	inline void set_timestamp(unsigned long timestamp)
	{
		slot_timestamp = timestamp;
	}

	/**
	 * @brief set the timestamp when the slot last ejected a projectile, server-side
	 * This is a server-side property, to be set by the game module
	 * */
	inline void set_last_fired(unsigned long last_fired)
	{
		slot_last_fired = last_fired;
	}
	
	/**
	 * @brief set the timestamp when the slat last ejected a projectile, client-side
	 * This is a client-side property, to be set by the client
	 * */
	inline void set_last_ejected(unsigned long last_ejected)
	{
		slot_last_ejected = last_ejected;
	}
	
	/**
	 * @brief set the interval between two shots, in milliseconds
	 * */
	void set_projectile_interval(unsigned long projectile_interval);
	
	/**
	 * @brief set the lifespan of ejected projectiles, in milliseconds
	 * */
	void set_projectile_lifespan(unsigned long projectile_lifespan);
	
	/**
	 * @brief set the speed of ejected projectiles, in game units per second
	 * */
	void set_projectile_speed(float projectile_speed);
	
	/**
	 * @brief set the amount of damage done by a projectile generated by this slot
	 * */
	void set_projectile_damage(float projectile_damage);
	/**
	 * @brief set the name of model used to draw projectiles generated by this slot
	 * */
	void set_projectile_modelname(const std::string & projectile_modelname);
	
	/**
	 * @brief set the item this slot is holding
	 * */
	void set_item(Item *item);
	
private:
	math::Vector3f		slot_location;
	
	math::Axis		slot_axis;

	// slot flags
	unsigned int		slot_flags;
	
	// timestamp indicating when the slot configuration was last changed
	unsigned long		slot_timestamp;
	
	// timestamp indicating when the slot last generated a projectile, server-side
	unsigned long		slot_last_fired;
	
	// timestamp indicating when the slot last generated a projectile, client-side
	unsigned long		slot_last_ejected;
	
	// interval between two shots, in milliseconds
	unsigned long		slot_projectile_interval;
	
	// projectile lifespan
	unsigned long		slot_projectile_lifespan;
	
	// projectile speed, in game units per second
	float 			slot_projectile_speed;
	
	// projectile damage
	float			slot_projectile_damage;
	
	// name of the model used to draw projectiles generated by this slot
	std::string		slot_projectile_modelname;
	
	// item mounted in this slot
	Item			*slot_item;
};

} // namespace core

#endif // __INCLUDED_CORE_SLOTS_H__