[10678] | 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 | * Dominik Solenicki |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | #ifndef _DivisionController_H__ |
---|
| 30 | #define _DivisionController_H__ |
---|
| 31 | |
---|
| 32 | #include "controllers/FleetController.h" |
---|
| 33 | |
---|
| 34 | |
---|
| 35 | namespace orxonox |
---|
| 36 | { |
---|
| 37 | class _OrxonoxExport DivisionController : public FleetController |
---|
| 38 | { |
---|
| 39 | public: |
---|
[10681] | 40 | DivisionController(Context* context); |
---|
| 41 | virtual ~DivisionController(); |
---|
[10678] | 42 | |
---|
[10681] | 43 | //virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); |
---|
[10678] | 44 | |
---|
[10681] | 45 | //Using british military aircraft formations |
---|
| 46 | enum FormationMode {VEE,FINGER4,DIAMOND, WALL}; |
---|
| 47 | void setFormationMode(FormationMode val); |
---|
| 48 | inline FormationMode getFormationMode() const |
---|
| 49 | { return this->formationMode_; } |
---|
| 50 | |
---|
| 51 | virtual void doFire(); |
---|
[10678] | 52 | |
---|
[10681] | 53 | //WAYPOINT FUNCTIONS` |
---|
| 54 | void addWaypoint(WorldEntity* waypoint); |
---|
| 55 | WorldEntity* getWaypoint(unsigned int index) const; |
---|
[10678] | 56 | |
---|
[10681] | 57 | inline void setAccuracy(float accuracy) |
---|
| 58 | { this->squaredaccuracy_ = accuracy*accuracy; } |
---|
| 59 | inline float getAccuracy() const |
---|
| 60 | { return sqrt(this->squaredaccuracy_); } |
---|
| 61 | void updatePointsOfInterest(std::string name, float distance); |
---|
| 62 | void manageWaypoints(); |
---|
[10678] | 63 | |
---|
| 64 | protected: |
---|
| 65 | |
---|
[10681] | 66 | //Target enemy, set by fleet controller. |
---|
| 67 | WeakPtr<Pawn> target_; |
---|
| 68 | bool bHasTargetPosition_; |
---|
| 69 | Vector3 targetPosition_; |
---|
| 70 | bool bHasTargetOrientation_; |
---|
| 71 | Quaternion targetOrientation_; |
---|
| 72 | void setTargetPosition(const Vector3& target); |
---|
| 73 | void searchRandomTargetPosition(); |
---|
| 74 | |
---|
| 75 | void setTargetOrientation(const Quaternion& orient); |
---|
| 76 | void setTargetOrientation(Pawn* target); |
---|
| 77 | |
---|
| 78 | virtual void positionReached() {} |
---|
| 79 | |
---|
| 80 | static bool sameTeam(ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gametype); // hack |
---|
| 81 | |
---|
| 82 | |
---|
| 83 | void setTarget(Pawn* target); |
---|
| 84 | |
---|
| 85 | void searchNewTarget(); |
---|
| 86 | void forgetTarget(); |
---|
| 87 | |
---|
| 88 | void targetDied(); |
---|
| 89 | bool bShooting_; |
---|
| 90 | void aimAtTarget(); |
---|
| 91 | |
---|
| 92 | bool isCloseAtTarget(float distance) const; |
---|
| 93 | bool isLookingAtTarget(float angle) const; |
---|
| 94 | |
---|
| 95 | //Has nothing to do with desiredRelativePosition_, |
---|
| 96 | //is set by fleet controller. |
---|
| 97 | Vector3* desiredAbsolutePosition_; |
---|
| 98 | |
---|
| 99 | enum Maneuver {NONE, SPIN, TURN180}; |
---|
| 100 | Maneuver maneuver_; |
---|
| 101 | |
---|
| 102 | void moveToPosition(const Vector3& target); |
---|
| 103 | void moveToTargetPosition(); |
---|
| 104 | void absoluteMoveToPosition(const Vector3& target); |
---|
| 105 | void copyOrientation(const Quaternion& orient); |
---|
| 106 | void copyTargetOrientation(); |
---|
| 107 | |
---|
| 108 | void turn180Init(); |
---|
| 109 | void spinInit(); |
---|
| 110 | void spin(); |
---|
| 111 | void turn180(); |
---|
| 112 | |
---|
| 113 | //WAYPOINT DATA |
---|
| 114 | std::vector<WeakPtr<WorldEntity> > waypoints_; |
---|
| 115 | size_t currentWaypoint_; |
---|
| 116 | float squaredaccuracy_; |
---|
| 117 | WorldEntity* defaultWaypoint_; |
---|
| 118 | |
---|
[10678] | 119 | private: |
---|
| 120 | }; |
---|
| 121 | } |
---|
| 122 | |
---|
| 123 | #endif /* _DivisionController_H__ */ |
---|