Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
blob: 64244fc9e39e6b7f68ef099236834066741baa1f (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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
/*
   base/shipmodel.h
   This file is part of the Osirion project and is distributed under
   the terms and conditions of the GNU General Public License version 2
*/

#ifndef __INCLUDED_BASE_SHIPMODEL_H__
#define __INCLUDED_BASE_SHIPMODEL_H__

#include <string>

#include "core/info.h"
#include "core/entity.h"
#include "base/template.h"

namespace game
{

class Ship;

/// ship model specification
class ShipModel : public core::Info
{
public:
	/// default constructor
	ShipModel();

	/// default destructor
	virtual ~ShipModel();

	/* ---- inspectors ------------------------------------------------ */
	
	/// indicates if this model can be equiped with a jump drive
	inline const bool jumpdrive() const
	{
		return shipmodel_jumpdrive;
	}
	
	/// indicates if players can dock this ship model
	inline const bool dockable() const
	{
		return shipmodel_dockable;
	}
	
	/// default mass
	inline const float mass() const
	{
		return shipmodel_mass;
	}
	
	/// default impulse drive force
	inline const float impulse_force() const
	{
		return shipmodel_impulse_force;
	}
		
	/// default thruster force
	inline const float thrust_force() const
	{
		return shipmodel_thrust_force;
	}
	
	/// default strafe force 
	inline const float strafe_force() const
	{
		return shipmodel_strafe_force;
	}
	
	/// default turn force
	inline const float turn_force() const
	{
		return shipmodel_turn_force;
	}
	
	/// default turn force
	inline const float roll_force() const
	{
		return shipmodel_roll_force;
	}

	/// linear damping factor
	inline const float linear_damping() const
	{
		return shipmodel_linear_damping;
	}
	
	/// angular damping factor
	inline const float angular_damping() const
	{
		return shipmodel_angular_damping;
	}
	
// 	/// maximum thrust speed
// 	inline const float maxspeed() const
// 	{
// 		return shipmodel_maxspeed;
// 	}
	
	/// size of the cargo hold, in cubic meters
	inline const float maxcargo() const
	{
		return shipmodel_maxcargo;
	}
	
	/// maximum armor amount
	inline const float maxarmor() const
	{
		return shipmodel_maxarmor;
	}
	
	/// ship radius
	inline const float radius() const
	{
		return shipmodel_radius;
	}
	
	/// entity template
	inline const Template *model_template() const
	{
		return shipmodel_template;
	}
	
	/* ---- actors ---------------------------------------------------- */
	
	/**
	 * @brief apply ship type settings to an entity
	 */
	void apply(core::Entity *entity) const;
	
	/**
	 * @brief apply ship type settings to a ship
	 */
	void apply(Ship *ship) const;

protected:

	/* ---- mutators -------------------------------------------------- */
	
	/// set mass
	inline void set_mass(const float mass)
	{
		shipmodel_mass = mass;
	}
	
	/// set impulse drive force
	inline void set_impulse_force(const float impulse)
	{
		shipmodel_impulse_force = impulse;
		
	}
		
	/// set thruster force
	inline void set_thrust_force(const float thrust)
	{
		shipmodel_thrust_force = thrust;
	}
	
	/// set strafe force
	inline void set_strafe_force(const float strafe)
	{
		shipmodel_strafe_force = strafe;
	}
	
	/// set turn forceshipmodel_lineardamping
	inline void set_turn_force(const float turn)
	{
		shipmodel_turn_force = turn;
	}

	/// set roll force
	inline void set_roll_force(const float roll)
	{
		shipmodel_roll_force = roll;
	}
	
// 	/// set maximum speed
// 	inline void set_maxspeed(const float maxspeed)
// 	{
// 		shipmodel_maxspeed = maxspeed;
// 	}
	
	/// set maximum armor amount
	inline void set_maxarmor(const float maxarmor)
	{
		shipmodel_maxarmor = maxarmor;
	}
	
	/// set size of the cargo hold
	inline void set_maxcargo(const float maxcargo)
	{
		shipmodel_maxcargo = maxcargo;
	}

	/// set jumpdrive capability
	inline void set_jumpdrive(const bool jumpdrive)
	{
		shipmodel_jumpdrive = jumpdrive;
	}
	
	/// set dock capability
	inline void set_dockable(const bool dockable)
	{
		shipmodel_dockable = dockable;
	}
	
	/// set radius
	inline void set_radius(const float radius)
	{
		shipmodel_radius = radius;
	}
	
	/// set entity template
	inline void set_template(const Template *model_template)
	{
		shipmodel_template = model_template;
	}

	/**
	 * @brief set physics linear damping factor
	 */
	inline void set_linear_damping(const float linear_damping)
	{
		shipmodel_linear_damping = linear_damping;
	}
	
	/**
	 * @brief set physics linear damping factor
	 */
	inline void set_angular_damping(const float angular_damping)
	{
		shipmodel_angular_damping = angular_damping;
	}
		
public:
	/**
	 * @brief generate specifications info.
	 * */
	void generate_info();
	
	void buy(core::EntityControlable *buyer, core::Entity *seller, bool confirm = false);
		
	/* --- static registry functions ---------------------------------- */
	
	static ShipModel *find(const std::string & label);

	static ShipModel *search(const std::string & searchstr);	
	
	static bool init();
	
	static void done();
	
	static void list();
	
	static inline const core::InfoType *infotype() {
		return shipmodel_infotype;
	}

private:
	/* --- attributes ------------------------------------------------- */
	
	float 			shipmodel_radius;
	float 			shipmodel_mass;
	float			shipmodel_linear_damping;
	float			shipmodel_angular_damping;
	
	float			shipmodel_impulse_force;
	float			shipmodel_thrust_force;
	float			shipmodel_strafe_force;
	float			shipmodel_turn_force;
	float			shipmodel_roll_force;
	
	float			shipmodel_maxcargo;	
	float			shipmodel_maxarmor;
	float			shipmodel_maxshield;
	
	bool			shipmodel_jumpdrive;
	bool			shipmodel_dockable;	
	
	const Template		*shipmodel_template;
	
	/* --- static ----------------------------------------------------- */
	
	static core::InfoType *shipmodel_infotype;
};

}

#endif // __INCLUDED_BASE_SHIPMODEL_H__