1 //////////////////////////////////////////////////////////////////////////////// 2 // Scorched3D (c) 2000-2011 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. 10 // 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. 15 // 16 // You should have received a copy of the GNU General Public License along 17 // with this program; if not, write to the Free Software Foundation, Inc., 18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 //////////////////////////////////////////////////////////////////////////////// 20 21 #if !defined(AFX_TARGET_H__52F37177_46EA_49C8_9B58_E6C57ABDB78A__INCLUDED_) 22 #define AFX_TARGET_H__52F37177_46EA_49C8_9B58_E6C57ABDB78A__INCLUDED_ 23 24 #include <engine/ScorchedContext.h> 25 #include <common/FixedVector.h> 26 #include <lang/LangString.h> 27 28 namespace TargetID 29 { 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; 37 }; 38 39 class NamedNetBuffer; 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 49 { 50 public: 51 enum TargetType 52 { 53 TypeTarget = 1, 54 TypeTank = 2, 55 TypeTanket = 3 56 }; 57 58 Target(unsigned int playerId, 59 const LangString &name, 60 ScorchedContext &context); 61 virtual ~Target(); 62 63 virtual void loaded(); 64 virtual void newGame(); 65 66 virtual bool getAlive(); 67 virtual bool getPlaying(); 68 virtual bool getVisible(); getType()69 virtual TargetType getType() { return Target::TypeTarget; } getPlayerId()70 unsigned int getPlayerId() { return playerId_; } 71 72 // Weapons getLife()73 TargetLife &getLife() { return *life_; } getShield()74 TargetShield &getShield() { return *shield_; } getParachute()75 TargetParachute &getParachute() { return *parachute_; } getGroup()76 TargetGroup &getGroup() { return *group_; } getTargetState()77 TargetState &getTargetState() { return *targetState_; } 78 79 // Actions setDeathAction(Weapon * deathAction)80 void setDeathAction(Weapon *deathAction) { deathAction_ = deathAction; } setBurnAction(Weapon * burnAction)81 void setBurnAction(Weapon *burnAction) { burnAction_ = burnAction; } setCollisionAction(Weapon * collisionAction)82 void setCollisionAction(Weapon *collisionAction) { collisionAction_ = collisionAction; } getDeathAction()83 virtual Weapon *getDeathAction() { return deathAction_; } getBurnAction()84 virtual Weapon *getBurnAction() { return burnAction_; } getCollisionAction()85 virtual Weapon *getCollisionAction() { return collisionAction_; } 86 87 // Renderer getBorder()88 fixed getBorder() { return border_; } setBorder(fixed b)89 void setBorder(fixed b) { border_ = b; } getRenderer()90 TargetRenderer *getRenderer() { return renderer_; } setRenderer(TargetRenderer * renderer)91 void setRenderer(TargetRenderer *renderer) { renderer_ = renderer; } 92 93 // Name getTargetName()94 const LangString &getTargetName() { return name_; } 95 const std::string &getCStrName(); 96 void setName(const LangString &name); getNameLen()97 unsigned int getNameLen() { return (unsigned int) name_.size(); } 98 99 virtual void toString(std::string &str); 100 101 // Serialize the target 102 virtual bool writeMessage(NamedNetBuffer &buffer); 103 virtual bool readMessage(NetBufferReader &reader); 104 105 protected: 106 unsigned int playerId_; 107 fixed border_; 108 ScorchedContext &context_; 109 TargetLife *life_; 110 TargetShield *shield_; 111 TargetParachute *parachute_; 112 TargetRenderer *renderer_; 113 TargetState *targetState_; 114 TargetGroup *group_; 115 LangString name_; 116 std::string cStrName_; 117 Weapon *deathAction_, *burnAction_, *collisionAction_; 118 119 }; 120 121 #endif // !defined(AFX_TARGET_H__52F37177_46EA_49C8_9B58_E6C57ABDB78A__INCLUDED_) 122