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_WEAPON_H__65439E20_84A6_406A_8FD0_045A3E7555D3__INCLUDED_) 22 #define AFX_WEAPON_H__65439E20_84A6_406A_8FD0_045A3E7555D3__INCLUDED_ 23 24 #include <weapons/AccessoryPart.h> 25 #include <net/NetBuffer.h> 26 #include <common/FixedVector.h> 27 #include <engine/ScorchedContext.h> 28 #include <engine/ObjectGroups.h> 29 30 class WeaponFireContextInternal 31 { 32 public: 33 WeaponFireContextInternal(unsigned int selectPositionX, unsigned int selectPositionY, 34 const FixedVector &velocityVectory, 35 bool referenced, bool updateStats); 36 virtual ~WeaponFireContextInternal(); 37 getKillCount()38 int getKillCount() { return killCount_; } setKillCount(int killCount)39 void setKillCount(int killCount) { killCount_ = killCount; } 40 getUpdateStats()41 bool getUpdateStats() { return updateStats_; } getReferenced()42 bool getReferenced() { return referenced_; } 43 getSelectPositionX()44 unsigned int getSelectPositionX() { return selectPositionX_; } getSelectPositionY()45 unsigned int getSelectPositionY() { return selectPositionY_; } getVelocityVector()46 FixedVector &getVelocityVector() { return velocityVector_; } 47 getLocalGroups()48 ObjectGroups &getLocalGroups() { return localGroups_; } 49 50 int getIncLabelCount(unsigned int label); 51 52 void incrementReference(); 53 void decrementReference(); 54 55 protected: 56 int killCount_; 57 bool referenced_, updateStats_; 58 unsigned int referenceCount_; 59 ObjectGroups localGroups_; 60 unsigned int selectPositionX_; 61 unsigned int selectPositionY_; 62 FixedVector velocityVector_; 63 std::map<unsigned int, int> *labelCount_; 64 65 private: 66 WeaponFireContextInternal(WeaponFireContextInternal &other); 67 WeaponFireContextInternal &operator=(WeaponFireContextInternal &other); 68 }; 69 70 class WeaponFireContext 71 { 72 public: 73 WeaponFireContext(unsigned int playerId, 74 unsigned int selectPositionX, unsigned int selectPositionY, 75 const FixedVector &velocityVector, 76 bool referenced, bool updateStats); 77 WeaponFireContext(WeaponFireContext &other); 78 virtual ~WeaponFireContext(); 79 getPlayerId()80 unsigned int getPlayerId() { return playerId_; } setPlayerId(unsigned int playerId)81 void setPlayerId(unsigned int playerId) { playerId_ = playerId; } 82 getInternalContext()83 WeaponFireContextInternal &getInternalContext() { return *internalContext_; } 84 85 protected: 86 unsigned int playerId_; 87 WeaponFireContextInternal *internalContext_; 88 89 private: 90 WeaponFireContext &operator=(WeaponFireContext &other); 91 92 }; 93 94 class Action; 95 class Weapon : public AccessoryPart 96 { 97 public: 98 Weapon(); 99 virtual ~Weapon(); 100 101 virtual bool parseXML(AccessoryCreateContext &context, 102 XMLNode *accessoryNode); 103 104 virtual void fire(ScorchedContext &context, 105 WeaponFireContext &weaponContext, 106 FixedVector &position, FixedVector &velocity); 107 108 int getArmsLevel(); 109 110 protected: 111 int armsLevel_; 112 113 virtual void addWeaponSyncCheck(ScorchedContext &context, 114 WeaponFireContext &weaponContext, 115 FixedVector &position, FixedVector &velocity); 116 virtual void fireWeapon(ScorchedContext &context, 117 WeaponFireContext &weaponContext, 118 FixedVector &position, FixedVector &velocity) = 0; 119 }; 120 121 #endif // !defined(AFX_WEAPON_H__65439E20_84A6_406A_8FD0_045A3E7555D3__INCLUDED_) 122