/* * ORXONOX - the hottest 3D action shooter ever to exist * > www.orxonox.net < * * * License notice: * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * Author: * Fabian 'x3n' Landau * Co-authors: * ... * */ #ifndef _CommonController_H__ #define _CommonController_H__ #include "controllers/Controller.h" #include "worldentities/ControllableEntity.h" #include "worldentities/pawns/Pawn.h" #include "core/ClassTreeMask.h" namespace orxonox { namespace FormationMode { enum Value { VEE, FINGER4, DIAMOND, WALL }; } namespace Rank { enum Value { NONE, SECTIONLEADER, DIVISIONLEADER, WINGMAN }; } //none for a formation flight without attacking, neutral when opponent and this have no //advantage over each other, offensive when this spotted opponent first, //defensive otherwise namespace ManeuverType { enum Value { NONE, NEUTRAL, OFFENSIVE, DEFENCIVE }; } //none for a formation flight namespace Maneuver { enum Value { NONE, GUNSD, SCISSORS, COMBATSPREAD, DEFENSIVESPLIT, BREAK, BARRELROLL, SWOOP, IMMELMANN, WINGOVER, LOWYOYO, HIGHYOYO, LAGDISPLACEMENTROLL }; } class _OrxonoxExport CommonController : public Controller { public: static const float ACTION_INTERVAL = 1.0f; CommonController(Context* context); virtual ~CommonController(); virtual void setFormationMode(FormationMode::Value val) { this->formationMode_ = val; } inline FormationMode::Value getFormationMode() const { return this->formationMode_; } virtual void setFormationModeXML(std::string val); virtual std::string getFormationModeXML(); virtual void setRank(Rank::Value val) { this->rank_ = val; } inline Rank::Value getRank() const { return this->rank_; } virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); virtual bool setWingman(CommonController* wingman); virtual bool hasWingman(); void setTarget(ControllableEntity* target); void setTargetOrientation(const Quaternion& orient); void setTargetOrientation(ControllableEntity* target); void setTargetPosition(const Vector3& target); /*void spin(); void turn180();*/ protected: void moveToPosition(const Vector3& target); void moveToTargetPosition(); //enum Mode {ROCKET, ATTACK, MOVE, HOLD};//TODO; implement DEFENCE, MOVING modes //Mode mode_; void copyOrientation(const Quaternion& orient); void copyTargetOrientation(); bool isCloseAtTarget(float distance) const; void doFire(); void aimAtTarget(); bool isLookingAtTarget(float angle) const; //checks if spaceship points at enemy and if there are allies inbetween bool canFire(); std::map weaponModes_; // projectiles_; // target_; bool bShooting_; WeakPtr objectiveTarget_; FormationMode::Value formationMode_; Rank::Value rank_; ManeuverType::Value maneuverType_; Maneuver::Value maneuver_; ClassTreeMask targetMask_; private: }; } #endif /* _CommonController_H__ */