Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
blob: 6bbcdfd26312c42bb0fc28c4b45b8abd3356807a (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
/*
   core/entityprojectile.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_CORE_PROJECTILE_H__
#define __INCLUDED_CORE_PROJECTILE_H__

#include "core/entity.h"

namespace core
{

class EntityProjectile : public core::EntityDynamic
{
public:
	EntityProjectile();
	EntityProjectile(std::istream & is);	
	
	virtual ~EntityProjectile();

	virtual void upkeep(const unsigned long timestamp);

	virtual void collision(Entity *other);
	
	virtual void frame(const unsigned long elapsed);

	/* --- inspectors ------------------------------------------ */
	
	/**
	 * @brief  core type id
	 * */
	virtual inline const unsigned int type() const {
		return Projectile;
	}
	
	inline const unsigned long timestamp() const
	{
		return projectile_timestamp;
	}
	
	/**
	 * @brief the lifespan of this projectile, in milliseconds
	 * */
	inline const unsigned long lifespan() const
	{
		return projectile_lifespan;
	}
	
	/**
	 * @brief the amount of damage this projectile inflicts
	 * */
	inline const float damage() const
	{
		return projectile_damage;
	}
	
	/**
	 * @brief id of the player who fired the projectile
	 * */
	inline const unsigned int ownerid() const
	{
		return projectile_ownerid;
	}
	
	/**
	 * @brief return the projectile modelname
	 * */
	inline const std::string & projectile_modelname() const
	{
		return projectile_modelname_str;
	}
	
	/*----- serializers ----------------------------------------------- */

	/**
	 * @brief serialize the entity to a stream
	 * */
	virtual void serialize_server_create(std::ostream & os) const;

	/*----- mutators -------------------------------------------------- */

	/**
	 * @brief  receive a server-to-client create from a stream
	 * */
	virtual void receive_server_create(std::istream &is);
	
	/**
	 * @brief reset physics state
	 * */
	virtual void reset();
	
	/**
	 * @brief set the amount of damage this projectile inflicts
	 * */
	inline void set_damage(const float damage)
	{
		projectile_damage = damage;
	}
	
	/**
	 * @brief set the lifespan of the projectile
	 * */
	inline void set_lifespan(const unsigned long lifespan)
	{
		projectile_lifespan = lifespan;
	}

	/**
	 * @brief set the id of the player who fired the projectile
	 * */
	inline void set_ownerid(const unsigned int ownerid)
	{
		projectile_ownerid = ownerid;
	}
	
	/**
	 * @brief set the projectile timestamp
	 * */
	inline void set_timestamp(const unsigned int timestamp)
	{
		projectile_timestamp = timestamp;
	}
	
	/**
	 * @brief set the projectile modelname
	 * */
	void set_projectile_modelname(const std::string modelname);
	
private:
	unsigned long projectile_timestamp;
	
	unsigned long projectile_lifespan;
	
	std::string projectile_modelname_str;
	
	float projectile_damage;
	
	unsigned int projectile_ownerid;
};

} // namespace game

#endif // __INCLUDED_CORE_PROJECTILE_H__