Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
blob: f7052313ef6c14fc199b726ab0c5a030a271b046 (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
/*
   base/ship.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_SHIP_H__
#define __INCLUDED_BASE_SHIP_H__

#include "core/player.h"
#include "core/entity.h"
#include "base/shipmodel.h"
#include "base/jumppoint.h"
#include "math/vector3f.h"

namespace game
{

/// A ship in the game, controled by a player
class Ship : public core::EntityControlable
{
public:
	Ship(core::Player *owner, const ShipModel *shipmodel);
	~Ship();

	/* -- inspectors ------------------------------------------- */
	
	/// shipmodel
	inline const ShipModel *shipmodel() const {
		return ship_shipmodel;
	}
	
	/// impulse drive force
	inline const float impulse_force() const {
		return ship_impulse_force;
	}
		
	/// thruster force
	inline const float thrust_force() const {
		return ship_thrust_force;
	}
	
	/// strafe force 
	inline const float strafe_force() const {
		return ship_strafe_force;
	}
	
	/// turn force
	inline const float turn_force() const {
		return ship_turn_force;
	}
	
	/// roll force
	inline const float roll_force() const {
		return ship_roll_force;
	}
	
	/// entity the ship is currently docked at
	inline core::Entity *dock() {
		return ship_dock;
	}
	
	/// (dockable) entity where the ship will respawn if destroyed
	core::Entity *spawn() {
		return ship_spawn;
	}

	/* -- mutators --------------------------------------------- */
	
	/// physics frame
	virtual void action (btScalar seconds);

	/// game frame
	virtual void frame(const unsigned long elapsed);

	/// move the ship to a different zone
	virtual void set_zone(core::Zone *zone);

	/// true if the ship is equiped with a jumpdrive
	inline bool jumpdrive() const {
		return ship_jumpdrive;
	}
	
	/// set jumpdrive capability
	inline void set_jumpdrive(const bool jumpdrive) {
		ship_jumpdrive = jumpdrive;
	}
	
	/// set impulse drive force
	inline void set_impulse_force(const float impulse) {
		ship_impulse_force = impulse;
		
	}
		
	/// set thruster force
	inline void set_thrust_force(const float thrust) {
		ship_thrust_force = thrust;
	}
	
	/// set strafe force
	inline void set_strafe_force(const float strafe) {
		ship_strafe_force = strafe;
	}
	
	/// set turn force
	inline void set_turn_force(const float turn) {
		ship_turn_force = turn;
	}
	
	/// set roll force
	inline void set_roll_force(const float roll) {
		ship_roll_force = roll;
	}
	
	/// Initiate jump, departing from a jump point
	void initiate_jump(JumpPoint *depart);

	/// void reset drive controls
	virtual void reset();

	/// explode the ship
	void explode();

	/// toggle impulse drive activation
	void func_impulse();

	/// toggle jump drive activation
	void func_jump(std::string const & args);
	
	virtual void set_state(int state);
	/**
	 * @brief dock the ship at a station, planet or another player's ship_dock
	 * This will set the ship's state to Entity::Docked and reset spawn if required
	 */
	void set_dock(core::Entity *dock);
	
	void launch();
	
	void set_spawn(core::Entity *spawn);

private:
	JumpPoint *find_closest_jumppoint();

	const ShipModel		*ship_shipmodel;

	float 			current_target_direction;
	float 			current_target_pitch;
	float 			current_target_roll;
	float			current_target_strafe;
	float			current_target_vstrafe;
	float			current_target_afterburner;
	bool			current_impulse;

	bool			ship_jumpdrive;
	float			ship_jumpdrive_timer;

	float			ship_impulsedrive_timer;

	JumpPoint		*ship_jumpdepart;
	
	float			ship_impulse_force;
	float			ship_thrust_force;
	float			ship_strafe_force;
	float			ship_turn_force;
	float			ship_roll_force;
	
	core::Entity 		*ship_dock;
	
	core::Entity		*ship_spawn;
};

}

#endif // __INCLUDED_BASE_SHIP_H__