1 #ifndef BTANKS_TROOPER_H_
2 #define BTANKS_TROOPER_H_
3 
4 /* Battle Tanks Game
5  * Copyright (C) 2006-2009 Battle Tanks team
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20  */
21 
22 /*
23  * Additional rights can be granted beyond the GNU General Public License
24  * on the terms provided in the Exception. If you modify this file,
25  * you may extend this exception to your version of the file,
26  * but you are not obligated to do so. If you do not wish to provide this
27  * exception without modification, you must delete this exception statement
28  * from your version and license this file solely under the GPL without exception.
29 */
30 
31 
32 #include "object.h"
33 #include "alarm.h"
34 
35 class Trooper : public Object {
36 public:
Trooper(const std::string & classname,const std::string & object)37 	Trooper(const std::string &classname, const std::string &object) :
38 		Object(classname), _object(object), _fire(false), _alt_fire(false) {}
39 
40 	virtual void tick(const float dt);
41 
42 	virtual Object * clone() const;
43 	virtual void on_spawn();
44 	virtual void emit(const std::string &event, Object * emitter = NULL);
45 	virtual const bool validateFire(const int idx);
46 
serialize(mrt::Serializator & s)47 	virtual void serialize(mrt::Serializator &s) const {
48 		Object::serialize(s);
49 		s.add(_object);
50 		s.add(_fire);
51 		s.add(_alt_fire);
52 		s.add(_pose);
53 	}
deserialize(const mrt::Serializator & s)54 	virtual void deserialize(const mrt::Serializator &s) {
55 		Object::deserialize(s);
56 		s.get(_object);
57 		s.get(_fire);
58 		s.get(_alt_fire);
59 		s.get(_pose);
60 	}
61 
62 	void get_impassability_penalty(const float impassability, float &base, float &base_value, float &penalty) const;
63 	virtual const bool take(const BaseObject *obj, const std::string &type);
64 
65 protected:
66 	bool can_attach(Object *vehicle) const;
67 
68 	std::string _object;
69 	Alarm _fire, _alt_fire;
70 
71 	std::string _pose; //run by default
72 };
73 
74 #endif
75