TankAccessories.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_TANKACCESSORIES_H__60850A18_DED2_4BB0_B104_CB0941EF6D1D__INCLUDED_)
00022 #define AFX_TANKACCESSORIES_H__60850A18_DED2_4BB0_B104_CB0941EF6D1D__INCLUDED_
00023 
00024 #include <weapons/AccessoryPart.h>
00025 #include <tank/TankWeapon.h>
00026 #include <tank/TankAutoDefense.h>
00027 #include <tank/TankBatteries.h>
00028 #include <lang/LangString.h>
00029 
00030 class ScorchedContext;
00031 class TankAccessories  
00032 {
00033 public:
00034         TankAccessories(ScorchedContext &context);
00035         virtual ~TankAccessories();
00036 
00037         void setTank(Tank *tank);
00038 
00039         void newMatch();
00040         void add(Accessory *accessory, int count, bool check = true);
00041         void rm(Accessory *accessory, int count);
00042         void clearAccessories();
00043 
00044         bool canUse(Accessory *accessory);
00045 
00046         void activate(Accessory *accessory);
00047 
00048         bool accessoryAllowed(Accessory *accessory, int count);
00049         int getAccessoryCount(Accessory *accessory);
00050         void getAllAccessories(std::list<Accessory *> &result);
00051         std::list<Accessory *> &getAllAccessoriesByType(
00052                 AccessoryPart::AccessoryType type);
00053         std::list<Accessory *> &getAllAccessoriesByGroup(
00054                 const char *groupName);
00055 
00056         TankWeapon &getWeapons() { return tankWeapon_; }
00057         TankAutoDefense &getAutoDefense() { return tankAuto_; }
00058         TankBatteries &getBatteries() { return tankBatteries_; }
00059 
00060         LangString getAccessoryCountString(Accessory *accessory);
00061         LangString getAccessoryAndCountString(Accessory *accessory);
00062 
00063         // Serialize the tank accessories
00064         bool writeMessage(NetBuffer &buffer, bool writeAccessories);
00065         bool readMessage(NetBufferReader &reader);
00066 
00067 protected:
00068         ScorchedContext &context_;
00069         TankWeapon tankWeapon_;
00070         TankAutoDefense tankAuto_;
00071         TankBatteries tankBatteries_;
00072         Tank *tank_;
00073 
00074         typedef std::list<Accessory *> AccessoryList;
00075         std::map<Accessory *, int> accessories_;
00076         std::map<std::string, AccessoryList*> accessoryGroups_;
00077         std::map<AccessoryPart::AccessoryType, AccessoryList*> accessoryTypes_;
00078 
00079         void changed();
00080         void add_(Accessory *accessory, int count, bool check);
00081 };
00082 
00083 #endif // !defined(AFX_TANKACCESSORIES_H__60850A18_DED2_4BB0_B104_CB0941EF6D1D__INCLUDED_)

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