git-svn-id: https://scorched3d.svn.sourceforge.net/svnroot/scorched3d/trunk/scorched...
[scorched3d/parasti.git] / src / common / target / Target.h
blobae9044eff9d934cd9e2725e5149193e7e17a2ace
1 ////////////////////////////////////////////////////////////////////////////////
2 // Scorched3D (c) 2000-2009
3 //
4 // This file is part of Scorched3D.
5 //
6 // Scorched3D is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
11 // Scorched3D is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with Scorched3D; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 ////////////////////////////////////////////////////////////////////////////////
21 #if !defined(AFX_TARGET_H__52F37177_46EA_49C8_9B58_E6C57ABDB78A__INCLUDED_)
22 #define AFX_TARGET_H__52F37177_46EA_49C8_9B58_E6C57ABDB78A__INCLUDED_
24 #include <engine/ScorchedContext.h>
25 #include <common/FixedVector.h>
26 #include <lang/LangString.h>
28 namespace TargetID
30 const int MIN_TANK_ID = 1;
31 const int START_TRANSIENT_TANK_ID = 9000000;
32 const int SPEC_TANK_ID = START_TRANSIENT_TANK_ID - 1;
33 const int MAX_TANK_ID = 10000000;
34 const int MIN_TARGET_ID = 20000000;
35 const int MIN_TARGET_TRANSIENT_ID = 39000000;
36 const int MAX_TARGET_ID = 40000000;
39 class NetBuffer;
40 class NetBufferReader;
41 class TargetState;
42 class TargetLife;
43 class TargetShield;
44 class TargetGroup;
45 class TargetParachute;
46 class TargetRenderer;
47 class Weapon;
48 class Target
50 public:
51 Target(unsigned int playerId,
52 const LangString &name,
53 ScorchedContext &context);
54 virtual ~Target();
56 virtual void newGame();
58 virtual bool getAlive();
59 virtual bool isTarget() { return true; }
60 virtual bool isTemp();
61 unsigned int getPlayerId() { return playerId_; }
63 // Weapons
64 TargetLife &getLife() { return *life_; }
65 TargetShield &getShield() { return *shield_; }
66 TargetParachute &getParachute() { return *parachute_; }
67 TargetGroup &getGroup() { return *group_; }
68 TargetState &getTargetState() { return *targetState_; }
70 // Actions
71 void setDeathAction(Weapon *deathAction) { deathAction_ = deathAction; }
72 void setBurnAction(Weapon *burnAction) { burnAction_ = burnAction; }
73 virtual Weapon *getDeathAction() { return deathAction_; }
74 virtual Weapon *getBurnAction() { return burnAction_; }
76 // Renderer
77 fixed getBorder() { return border_; }
78 void setBorder(fixed b) { border_ = b; }
79 TargetRenderer *getRenderer() { return renderer_; }
80 void setRenderer(TargetRenderer *renderer) { renderer_ = renderer; }
82 // Name
83 const LangString &getTargetName() { return name_; }
84 const std::string &getCStrName();
85 void setName(const LangString &name);
86 unsigned int getNameLen() { return name_.size(); }
88 // Serialize the target
89 virtual bool writeMessage(NetBuffer &buffer);
90 virtual bool readMessage(NetBufferReader &reader);
92 protected:
93 unsigned int playerId_;
94 fixed border_;
95 ScorchedContext &context_;
96 TargetLife *life_;
97 TargetShield *shield_;
98 TargetParachute *parachute_;
99 TargetRenderer *renderer_;
100 TargetState *targetState_;
101 TargetGroup *group_;
102 LangString name_;
103 std::string cStrName_;
104 Weapon *deathAction_, *burnAction_;
108 #endif // !defined(AFX_TARGET_H__52F37177_46EA_49C8_9B58_E6C57ABDB78A__INCLUDED_)