Target.h

Go to the documentation of this file.
00001 ////////////////////////////////////////////////////////////////////////////////
00002 //    Scorched3D (c) 2000-2009
00003 //
00004 //    This file is part of Scorched3D.
00005 //
00006 //    Scorched3D is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    Scorched3D is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with Scorched3D; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 ////////////////////////////////////////////////////////////////////////////////
00020 
00021 #if !defined(AFX_TARGET_H__52F37177_46EA_49C8_9B58_E6C57ABDB78A__INCLUDED_)
00022 #define AFX_TARGET_H__52F37177_46EA_49C8_9B58_E6C57ABDB78A__INCLUDED_
00023 
00024 #include <engine/ScorchedContext.h>
00025 #include <common/FixedVector.h>
00026 #include <lang/LangString.h>
00027 
00028 namespace TargetID
00029 {
00030         const int MIN_TANK_ID = 1;
00031         const int START_TRANSIENT_TANK_ID = 9000000;
00032         const int SPEC_TANK_ID = START_TRANSIENT_TANK_ID - 1;
00033         const int MAX_TANK_ID = 10000000;
00034         const int MIN_TARGET_ID = 20000000;
00035         const int MIN_TARGET_TRANSIENT_ID = 39000000;
00036         const int MAX_TARGET_ID = 40000000;
00037 };
00038 
00039 class NetBuffer;
00040 class NetBufferReader;
00041 class TargetState;
00042 class TargetLife;
00043 class TargetShield;
00044 class TargetGroup;
00045 class TargetParachute;
00046 class TargetRenderer;
00047 class Weapon;
00048 class Target  
00049 {
00050 public:
00051         Target(unsigned int playerId, 
00052                 const LangString &name, 
00053                 ScorchedContext &context);
00054         virtual ~Target();
00055 
00056         virtual void newGame();
00057 
00058         virtual bool getAlive();
00059         virtual bool isTarget() { return true; }
00060         virtual bool isTemp();
00061         unsigned int getPlayerId() { return playerId_; }
00062 
00063         // Weapons
00064         TargetLife &getLife() { return *life_; }
00065         TargetShield &getShield() { return *shield_; }
00066         TargetParachute &getParachute() { return *parachute_; }
00067         TargetGroup &getGroup() { return *group_; }
00068         TargetState &getTargetState() { return *targetState_; }
00069 
00070         // Actions
00071         void setDeathAction(Weapon *deathAction) { deathAction_ = deathAction; }
00072         void setBurnAction(Weapon *burnAction) { burnAction_ = burnAction; }
00073         virtual Weapon *getDeathAction() { return deathAction_; }
00074         virtual Weapon *getBurnAction() { return burnAction_; }
00075 
00076         // Renderer
00077         fixed getBorder() { return border_; }
00078         void setBorder(fixed b) { border_ = b; }
00079         TargetRenderer *getRenderer() { return renderer_; }
00080         void setRenderer(TargetRenderer *renderer) { renderer_ = renderer; }
00081 
00082         // Name
00083         const LangString &getTargetName() { return name_; }
00084         const std::string &getCStrName();
00085         void setName(const LangString &name);
00086         unsigned int getNameLen() { return name_.size(); }
00087 
00088         // Serialize the target
00089         virtual bool writeMessage(NetBuffer &buffer);
00090         virtual bool readMessage(NetBufferReader &reader);
00091 
00092 protected:
00093         unsigned int playerId_;
00094         fixed border_;
00095         ScorchedContext &context_;
00096         TargetLife *life_;
00097         TargetShield *shield_;
00098         TargetParachute *parachute_;
00099         TargetRenderer *renderer_;
00100         TargetState *targetState_;
00101         TargetGroup *group_;
00102         LangString name_;
00103         std::string cStrName_;
00104         Weapon *deathAction_, *burnAction_;
00105 
00106 };
00107 
00108 #endif // !defined(AFX_TARGET_H__52F37177_46EA_49C8_9B58_E6C57ABDB78A__INCLUDED_)

Generated on Mon Feb 16 15:14:52 2009 for Scorched3D by  doxygen 1.5.3