[10719] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
| 3 | * > www.orxonox.net < |
---|
| 4 | * |
---|
| 5 | * |
---|
| 6 | * License notice: |
---|
| 7 | * |
---|
| 8 | * This program is free software; you can redistribute it and/or |
---|
| 9 | * modify it under the terms of the GNU General Public License |
---|
| 10 | * as published by the Free Software Foundation; either version 2 |
---|
| 11 | * of the License, or (at your option) any later version. |
---|
| 12 | * |
---|
| 13 | * This program is distributed in the hope that it will be useful, |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | * GNU General Public License for more details. |
---|
| 17 | * |
---|
| 18 | * You should have received a copy of the GNU General Public License |
---|
| 19 | * along with this program; if not, write to the Free Software |
---|
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 21 | * |
---|
| 22 | * Author: |
---|
| 23 | * Fabian 'x3n' Landau |
---|
| 24 | * Co-authors: |
---|
| 25 | * ... |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | #ifndef _CommonController_H__ |
---|
| 30 | #define _CommonController_H__ |
---|
| 31 | |
---|
| 32 | |
---|
| 33 | #include "controllers/Controller.h" |
---|
| 34 | #include "worldentities/ControllableEntity.h" |
---|
[10759] | 35 | #include "worldentities/pawns/Pawn.h" |
---|
[10719] | 36 | |
---|
[10759] | 37 | |
---|
[10719] | 38 | namespace orxonox |
---|
| 39 | { |
---|
[10759] | 40 | |
---|
| 41 | namespace FormationMode |
---|
| 42 | { |
---|
| 43 | enum Value |
---|
| 44 | { |
---|
| 45 | VEE, FINGER4, DIAMOND, WALL |
---|
| 46 | }; |
---|
| 47 | } |
---|
| 48 | namespace Rank |
---|
| 49 | { |
---|
| 50 | enum Value |
---|
| 51 | { |
---|
| 52 | NONE, SECTIONLEADER, DIVISIONLEADER, WINGMAN |
---|
| 53 | }; |
---|
| 54 | |
---|
| 55 | } |
---|
| 56 | |
---|
[10719] | 57 | class _OrxonoxExport CommonController : public Controller |
---|
| 58 | { |
---|
| 59 | public: |
---|
[10731] | 60 | |
---|
[10729] | 61 | static const float ACTION_INTERVAL = 1.0f; |
---|
| 62 | |
---|
[10731] | 63 | |
---|
| 64 | CommonController(Context* context); |
---|
| 65 | virtual ~CommonController(); |
---|
| 66 | |
---|
| 67 | |
---|
| 68 | |
---|
[10759] | 69 | |
---|
| 70 | |
---|
| 71 | virtual void setFormationMode(FormationMode::Value val) |
---|
[10725] | 72 | { this->formationMode_ = val; } |
---|
[10759] | 73 | inline FormationMode::Value getFormationMode() const |
---|
[10725] | 74 | { return this->formationMode_; } |
---|
[10759] | 75 | virtual void setFormationModeXML(std::string val); |
---|
| 76 | virtual std::string getFormationModeXML(); |
---|
[10725] | 77 | |
---|
[10759] | 78 | virtual void setRank(Rank::Value val) |
---|
[10731] | 79 | { this->rank_ = val; } |
---|
[10759] | 80 | inline Rank::Value getRank() const |
---|
[10731] | 81 | { return this->rank_; } |
---|
| 82 | |
---|
[10759] | 83 | virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); |
---|
[10731] | 84 | |
---|
| 85 | |
---|
| 86 | |
---|
[10719] | 87 | virtual bool setWingman(CommonController* wingman); |
---|
[10722] | 88 | virtual bool hasWingman(); |
---|
[10719] | 89 | |
---|
[10759] | 90 | void setTarget(ControllableEntity* target); |
---|
[10719] | 91 | |
---|
[10729] | 92 | void setTargetOrientation(const Quaternion& orient); |
---|
| 93 | void setTargetOrientation(ControllableEntity* target); |
---|
| 94 | void setTargetPosition(const Vector3& target); |
---|
| 95 | |
---|
[10731] | 96 | /*void spin(); |
---|
| 97 | void turn180();*/ |
---|
| 98 | |
---|
| 99 | |
---|
[10719] | 100 | protected: |
---|
[10731] | 101 | |
---|
[10725] | 102 | void moveToPosition(const Vector3& target); |
---|
[10731] | 103 | void moveToTargetPosition(); |
---|
[10737] | 104 | //enum Mode {ROCKET, ATTACK, MOVE, HOLD};//TODO; implement DEFENCE, MOVING modes |
---|
[10719] | 105 | |
---|
[10737] | 106 | //Mode mode_; |
---|
[10725] | 107 | void copyOrientation(const Quaternion& orient); |
---|
| 108 | void copyTargetOrientation(); |
---|
| 109 | |
---|
[10759] | 110 | bool isCloseAtTarget(float distance) const; |
---|
[10731] | 111 | void doFire(); |
---|
| 112 | void aimAtTarget(); |
---|
| 113 | bool isLookingAtTarget(float angle) const; |
---|
[10725] | 114 | |
---|
[10737] | 115 | |
---|
| 116 | std::map<std::string, int> weaponModes_; //<! Links each "weapon" to it's weaponmode - managed by setupWeapons() |
---|
| 117 | //std::vector<int> projectiles_; //<! Displays amount of projectiles of each weapon. - managed by setupWeapons() |
---|
| 118 | float timeout_; //<! Timeout for rocket usage. (If a rocket misses, a bot should stop using it.) |
---|
| 119 | void setupWeapons(); //<! Defines which weapons are available for a bot. Is recalled whenever a bot was killed. |
---|
| 120 | bool bSetupWorked; //<! If false, setupWeapons() is called. |
---|
| 121 | int getFiremode(std::string name); |
---|
| 122 | |
---|
[10759] | 123 | |
---|
[10725] | 124 | bool bHasTargetPosition_; |
---|
| 125 | Vector3 targetPosition_; |
---|
| 126 | bool bHasTargetOrientation_; |
---|
| 127 | Quaternion targetOrientation_; |
---|
| 128 | |
---|
[10731] | 129 | |
---|
[10725] | 130 | WeakPtr<ControllableEntity> target_; |
---|
| 131 | bool bShooting_; |
---|
| 132 | |
---|
[10731] | 133 | |
---|
[10759] | 134 | FormationMode::Value formationMode_; |
---|
| 135 | Rank::Value rank_; |
---|
[10725] | 136 | |
---|
| 137 | |
---|
[10719] | 138 | |
---|
| 139 | private: |
---|
| 140 | |
---|
| 141 | |
---|
| 142 | }; |
---|
| 143 | } |
---|
| 144 | |
---|
| 145 | #endif /* _CommonController_H__ */ |
---|