00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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
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_)