[Orxonox-commit 6206] r10864 - code/branches/campaignHS15/src/orxonox/controllers
gania at orxonox.net
gania at orxonox.net
Thu Nov 26 09:08:11 CET 2015
Author: gania
Date: 2015-11-26 09:08:11 +0100 (Thu, 26 Nov 2015)
New Revision: 10864
Added:
code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc
code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.h
Modified:
code/branches/campaignHS15/src/orxonox/controllers/CMakeLists.txt
code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc
code/branches/campaignHS15/src/orxonox/controllers/CommonController.h
code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc
code/branches/campaignHS15/src/orxonox/controllers/DivisionController.h
code/branches/campaignHS15/src/orxonox/controllers/LeaderController.cc
code/branches/campaignHS15/src/orxonox/controllers/LeaderController.h
code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc
code/branches/campaignHS15/src/orxonox/controllers/SectionController.h
code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc
code/branches/campaignHS15/src/orxonox/controllers/WingmanController.h
Log:
split up some code
Added: code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc (rev 0)
+++ code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc 2015-11-26 08:08:11 UTC (rev 10864)
@@ -0,0 +1,667 @@
+/*
+ * 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:
+ * Dominik Solenicki
+ *
+ */
+
+#include "ActionpointController.h"
+
+#include "core/XMLPort.h"
+
+#include "controllers/NewHumanController.h"
+
+namespace orxonox
+{
+
+ RegisterClass(ActionpointController);
+
+ //CommonController contains all common functionality of AI Controllers
+ ActionpointController::ActionpointController(Context* context) : CommonController(context)
+ {
+ this->bInLoop_ = false;
+ this->bLoop_ = false;
+ this->bEndLoop_ = false;
+ this->parsedActionpoints_.clear();
+ this->bTakenOver_ = false;
+ this->action_ = Action::NONE;
+ this->squaredaccuracy_ = 2500;
+
+
+ RegisterObject(ActionpointController);
+
+ }
+ void ActionpointController::XMLPort( Element& xmlelement, XMLPort::Mode mode )
+ {
+ SUPER( ActionpointController, XMLPort, xmlelement, mode );
+ XMLPortObject(ActionpointController, WorldEntity, "actionpoints", addActionpoint, getActionpoint, xmlelement, mode);
+ }
+ void ActionpointController::tick(float dt)
+ {
+ if (this->bHasTargetPosition_)
+ {
+ this->moveToTargetPosition(dt);
+ }
+ else if (this->bLookAtTarget_)
+ {
+ this->lookAtTarget(dt);
+ }
+ if (bShooting_)
+ {
+ this->doFire();
+ }
+ if (this->bFirstTick_)
+ {
+ std::reverse(parsedActionpoints_.begin(), parsedActionpoints_.end());
+ std::reverse(actionpoints_.begin(), actionpoints_.end());
+ if (this->parsedActionpoints_.empty())
+ {
+ this->action_ = Action::FIGHTALL;
+ }
+ }
+ if (this->bFirstTick_)
+ this->bFirstTick_ = false;
+ SUPER(ActionpointController, tick, dt);
+ }
+ ActionpointController::~ActionpointController()
+ {
+ parsedActionpoints_.clear();
+ actionpoints_.clear();
+ }
+ void ActionpointController::setProtect (ControllableEntity* protect)
+ {
+ this->protect_ = protect;
+ }
+ ControllableEntity* ActionpointController::getProtect ()
+ {
+ return this->protect_;
+ }
+ void ActionpointController::addActionpoint(WorldEntity* actionpoint)
+ {
+ std::string actionName;
+ Vector3 position;
+ std::string targetName;
+ bool inLoop = false;
+ Point p;
+ if (static_cast<Actionpoint*> (actionpoint))
+ {
+ Actionpoint* ap = static_cast<Actionpoint*> (actionpoint);
+ actionName = ap->getActionXML();
+ targetName = ap->getName();
+ position = ap->getWorldPosition();
+
+ if (this->bEndLoop_)
+ {
+ this->bInLoop_ = false;
+ }
+ if (!this->bInLoop_ && ap->getLoopStart())
+ {
+ this->bInLoop_ = true;
+ }
+ if (this->bInLoop_ && ap->getLoopEnd())
+ {
+ this->bEndLoop_ = true;
+ }
+ inLoop = this->bInLoop_;
+
+ Action::Value value;
+
+ if ( actionName == "FIGHT" )
+ { value = Action::FIGHT; }
+ else if ( actionName == "FLY" )
+ { value = Action::FLY; }
+ else if ( actionName == "PROTECT" )
+ { value = Action::PROTECT; }
+ else if ( actionName == "NONE" )
+ { value = Action::NONE; }
+ else if ( actionName == "FIGHTALL" )
+ { value = Action::FIGHTALL; }
+ else if ( actionName == "ATTACK" )
+ { value = Action::ATTACK; }
+ else
+ ThrowException( ParseError, std::string( "Attempting to set an unknown Action: '" )+ actionName + "'." );
+ p.action = value; p.name = targetName; p.position = position; p.inLoop = inLoop;
+ }
+ else
+ {
+ p.action = Action::FLY; p.name = ""; p.position = actionpoint->getWorldPosition(); p.inLoop = inLoop;
+ }
+ parsedActionpoints_.push_back(p);
+ this->actionpoints_.push_back(actionpoint);
+ }
+ WorldEntity* ActionpointController::getActionpoint(unsigned int index) const
+ {
+ if (index < this->actionpoints_.size())
+ return this->actionpoints_[index];
+ else
+ return 0;
+ }
+
+ Action::Value ActionpointController::getAction ()
+ {
+ return this->action_;
+ }
+ std::string ActionpointController::getActionName()
+ {
+ switch ( this->action_ )
+ {
+ case Action::FIGHT:
+ { return "FIGHT"; break; }
+ case Action::FLY:
+ { return "FLY"; break; }
+ case Action::PROTECT:
+ { return "PROTECT"; break; }
+ case Action::NONE:
+ { return "NONE"; break; }
+ case Action::FIGHTALL:
+ { return "FIGHTALL"; break; }
+ case Action::ATTACK:
+ { return "ATTACK"; break; }
+ default:
+ return "NONE";
+ break;
+ }
+ }
+ void ActionpointController::setAction (Action::Value action)
+ {
+ this->action_ = action;
+ }
+ void ActionpointController::setAction (Action::Value action, ControllableEntity* target)
+ {
+ this->action_ = action;
+ if (action == Action::FIGHT || action == Action::FIGHTALL || action == Action::ATTACK)
+ {
+ if (target)
+ this->setTarget (target);
+ }
+ else if (action == Action::PROTECT)
+ {
+ if (target)
+ this->setProtect (target);
+ }
+ }
+ void ActionpointController::setAction (Action::Value action, const Vector3& target)
+ {
+ this->action_ = action;
+ if (action == Action::FLY)
+ {
+ this->setTargetPosition (target);
+ }
+ }
+ void ActionpointController::setAction (Action::Value action, const Vector3& target, const Quaternion& orient )
+ {
+ this->action_ = action;
+ if (action == Action::FLY)
+ {
+ this->setTargetPosition (target);
+ this->setTargetOrientation (orient);
+ }
+ }
+
+ //------------------------------------------------------------------------------
+ //------------------------------Actionpoint methods-----------------------------
+ //------------------------------------------------------------------------------
+
+ //POST: this starts doing what was asked by the last element of parsedActionpoints_,
+ //if last element was failed to be parsed, next element will be executed.
+ void ActionpointController::executeActionpoint()
+ {
+ if (this->bLoop_)
+ {
+ if (!this->loopActionpoints_.empty())
+ {
+ this->action_ = this->loopActionpoints_.back().action;
+ switch ( this->action_ )
+ {
+ case Action::FIGHT:
+ {
+ std::string targetName = this->loopActionpoints_.back().name;
+ if (targetName == "")
+ {
+ break;
+ }
+ for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
+ {
+ if (CommonController::getName(*itP) == targetName)
+ {
+ this->setTarget (static_cast<ControllableEntity*>(*itP));
+ }
+ }
+ break;
+ }
+ case Action::FLY:
+ {
+ this->setTargetPosition( this->loopActionpoints_.back().position );
+ if (this->squaredDistanceToTarget() <= this->squaredaccuracy_)
+ {
+ this->nextActionpoint();
+ this->executeActionpoint();
+ }
+ break;
+ }
+ case Action::PROTECT:
+ {
+ std::string protectName = this->loopActionpoints_.back().name;
+ if (protectName == "reservedKeyword:human")
+ {
+ for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
+ {
+ if (orxonox_cast<ControllableEntity*>(*itP) && ((*itP)->getController()) && orxonox_cast <NewHumanController*> ((*itP)->getController()))
+ {
+ this->setProtect (static_cast<ControllableEntity*>(*itP));
+ }
+ }
+ }
+ else
+ {
+ for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
+ {
+ if (CommonController::getName(*itP) == protectName)
+ {
+ this->setProtect (static_cast<ControllableEntity*>(*itP));
+ }
+ }
+ }
+ if (!this->getProtect())
+ {
+ this->nextActionpoint();
+ this->executeActionpoint();
+ }
+ break;
+ }
+ case Action::NONE:
+ {
+ break;
+ }
+ case Action::FIGHTALL:
+ {
+ break;
+ }
+ case Action::ATTACK:
+ {
+ std::string targetName = this->loopActionpoints_.back().name;
+
+ for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
+ {
+ if (CommonController::getName(*itP) == targetName)
+ {
+ this->setTarget (static_cast<ControllableEntity*>(*itP));
+ }
+ }
+ if (!this->hasTarget())
+ {
+ this->nextActionpoint();
+ this->executeActionpoint();
+ }
+ break;
+ }
+ default:
+ {
+ break;
+ }
+
+ }
+ }
+ else
+ {
+ this->bLoop_ = false;
+ }
+ }
+ else
+ {
+ if (!this->parsedActionpoints_.empty())
+ {
+ if (this->parsedActionpoints_.back().inLoop)
+ {
+ //MOVES all points that are in loop to a loop vector
+ this->fillLoop();
+ this->bLoop_ = true;
+ executeActionpoint();
+ return;
+ }
+ this->action_ = this->parsedActionpoints_.back().action;
+ switch ( this->action_ )
+ {
+ case Action::FIGHT:
+ {
+ std::string targetName = this->parsedActionpoints_.back().name;
+ if (targetName == "")
+ {
+ break;
+ }
+ for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
+ {
+ if (CommonController::getName(*itP) == targetName)
+ {
+ this->setTarget (static_cast<ControllableEntity*>(*itP));
+ }
+ }
+ break;
+ }
+ case Action::FLY:
+ {
+ this->setTargetPosition( this->parsedActionpoints_.back().position );
+ if (this->squaredDistanceToTarget() <= this->squaredaccuracy_)
+ {
+ this->nextActionpoint();
+ this->executeActionpoint();
+ }
+ break;
+ }
+ case Action::PROTECT:
+ {
+
+ std::string protectName = this->parsedActionpoints_.back().name;
+ if (protectName == "reservedKeyword:human")
+ {
+ for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
+ {
+ if (orxonox_cast<ControllableEntity*>(*itP) && ((*itP)->getController()) && orxonox_cast <NewHumanController*> ((*itP)->getController()))
+ {
+ this->setProtect (static_cast<ControllableEntity*>(*itP));
+ }
+ }
+ }
+ else
+ {
+ for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
+ {
+ if (CommonController::getName(*itP) == protectName)
+ {
+ this->setProtect (static_cast<ControllableEntity*>(*itP));
+ }
+ }
+ }
+ if (!this->getProtect())
+ {
+ this->nextActionpoint();
+ this->executeActionpoint();
+ }
+ break;
+ }
+ case Action::NONE:
+ {
+ break;
+ }
+ case Action::FIGHTALL:
+ {
+ break;
+ }
+ case Action::ATTACK:
+ {
+ std::string targetName = this->parsedActionpoints_.back().name;
+
+ for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
+ {
+ if (CommonController::getName(*itP) == targetName)
+ {
+ this->setTarget (static_cast<ControllableEntity*>(*itP));
+ }
+ }
+ if (!this->hasTarget())
+ {
+ this->nextActionpoint();
+ this->executeActionpoint();
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ }
+
+ else
+ {
+ this->setTarget(0);
+ this->setTargetPosition(this->getControllableEntity()->getWorldPosition());
+ this->action_ = Action::NONE;
+ }
+ }
+ }
+
+
+ void ActionpointController::stayNearProtect()
+ {
+ Vector3* targetRelativePosition;
+ targetRelativePosition = new Vector3 (0, 300, 300);
+ Vector3 targetAbsolutePosition = ((this->getProtect()->getWorldPosition()) +
+ (this->getProtect()->getWorldOrientation()* (*targetRelativePosition)));
+ this->setTargetPosition(targetAbsolutePosition);
+ }
+ void ActionpointController::nextActionpoint()
+ {
+ if (!this || !this->getControllableEntity())
+ return;
+ if (this->bLoop_)
+ {
+ if (!this->loopActionpoints_.empty())
+ {
+ this->moveBackToTop();
+ }
+ }
+ else
+ {
+ if (!this->parsedActionpoints_.empty())
+ {
+ this->parsedActionpoints_.pop_back();
+ }
+ }
+ this->setAction(Action::NONE);
+ }
+ void ActionpointController::moveBackToTop()
+ {
+ Point temp = loopActionpoints_.back();
+ loopActionpoints_.pop_back();
+ std::reverse (loopActionpoints_.begin(), loopActionpoints_.end());
+ loopActionpoints_.push_back(temp);
+ std::reverse (loopActionpoints_.begin(), loopActionpoints_.end());
+ }
+ void ActionpointController::fillLoop()
+ {
+ loopActionpoints_.clear();
+ fillLoopReversed();
+ std::reverse (loopActionpoints_.begin(), loopActionpoints_.end());
+ }
+ void ActionpointController::fillLoopReversed()
+ {
+ if (parsedActionpoints_.back().inLoop)
+ {
+ loopActionpoints_.push_back(parsedActionpoints_.back());
+ parsedActionpoints_.pop_back();
+ }
+ if (parsedActionpoints_.back().inLoop)
+ {
+ fillLoopReversed();
+ }
+ }
+ void ActionpointController::action()
+ {
+ if (!this || !this->getControllableEntity())
+ return;
+ // orxout (internal_error) << "Size of actions is " << this->parsedActionpoints_.size() << endl;
+ this->startAttackingEnemiesThatAreClose();
+ //No action -> pop one from stack
+ if (this->action_ == Action::NONE || this->bTakenOver_)
+ {
+ if (this->parsedActionpoints_.empty() && this->loopActionpoints_.empty())
+ {
+ Point p = { Action::FIGHTALL, "", Vector3::ZERO, false };
+ this->parsedActionpoints_.push_back (p);
+ }
+ this->executeActionpoint();
+ this->bTakenOver_ = false;
+ }
+ //Action fightall -> fight till nobody alive
+ if (this->action_ == Action::FIGHTALL)
+ {
+ if (!this->hasTarget())
+ {
+ //----find a target----
+ ControllableEntity* newTarget = this->closestTarget();
+ if (newTarget)
+ {
+ this->setAction (Action::FIGHTALL, newTarget);
+ }
+ else
+ {
+ this->nextActionpoint();
+ return;
+ }
+ }
+ else if (this->hasTarget())
+ {
+
+ }
+ }
+ //Action fight -> fight as long as enemies in range
+ else if (this->action_ == Action::FIGHT)
+ {
+ if (!this->hasTarget())
+ {
+ //----find a target----
+ ControllableEntity* newTarget = this->closestTarget();
+ if (newTarget &&
+ CommonController::distance (this->getControllableEntity(), newTarget) < this->attackRange_)
+ {
+ this->setAction (Action::FIGHT, newTarget);
+ }
+ else
+ {
+ this->nextActionpoint();
+ return;
+ }
+ }
+ else if (this->hasTarget())
+ {
+ //----fly in formation if far enough----
+ Vector3 diffVector = this->positionOfTarget_ - this->getControllableEntity()->getWorldPosition();
+
+ if (diffVector.length() > this->attackRange_)
+ {
+ ControllableEntity* newTarget = this->closestTarget();
+
+ if (newTarget &&
+ CommonController::distance (this->getControllableEntity(), newTarget) < this->attackRange_)
+ {
+ this->setAction (Action::FIGHT, newTarget);
+ }
+ else
+ {
+ this->nextActionpoint();
+ return;
+ }
+ }
+ }
+ }
+ else if (this->action_ == Action::FLY)
+ {
+ if (this->squaredDistanceToTarget() <= this->squaredaccuracy_)
+ {
+ this->nextActionpoint();
+ return;
+ }
+ }
+ else if (this->action_ == Action::PROTECT)
+ {
+ if (!this->getProtect())
+ {
+ this->nextActionpoint();
+ return;
+ }
+ this->stayNearProtect();
+ }
+ else if (this->action_ == Action::ATTACK)
+ {
+ if (!this->hasTarget())
+ {
+ this->nextActionpoint();
+ return;
+ }
+ }
+ if (this->hasTarget())
+ {
+ //----choose where to go----
+ this->maneuver();
+ //----fire if you can----
+ this->bShooting_ = this->canFire();
+ }
+ }
+ void ActionpointController::takeActionpoints (std::vector<Point > vector, std::vector<Point > loop, bool b)
+ {
+ this->parsedActionpoints_ = vector;
+ this->loopActionpoints_ = loop;
+ this->bLoop_ = this->bLoop_;
+ this->bTakenOver_ = true;
+ // orxout(internal_error) << "Top action is " << this->parsedActionpoints_.back().action << endl;
+ }
+ void ActionpointController::setClosestTarget()
+ {
+ this->setTarget (static_cast<ControllableEntity*>( closestTarget() ) );
+ }
+ Pawn* ActionpointController::closestTarget()
+ {
+ if (!this->getControllableEntity())
+ return 0;
+
+ Pawn* closestTarget = 0;
+ float minDistance = std::numeric_limits<float>::infinity();
+ Gametype* gt = this->getGametype();
+ for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
+ {
+ if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>(*itP), gt) )
+ continue;
+
+ float distance = CommonController::distance (*itP, this->getControllableEntity());
+ if (distance < minDistance)
+ {
+ closestTarget = *itP;
+ minDistance = distance;
+ }
+ }
+ if (closestTarget)
+ {
+ return closestTarget;
+ }
+ return 0;
+ }
+ void ActionpointController::startAttackingEnemiesThatAreClose()
+ {
+ if (this->action_ != Action::FIGHT && this->action_ != Action::FIGHTALL)
+ {
+ if ( (this->target_ && this->distance (this->getControllableEntity(), this->target_) > this->attackRange_)
+ || !this->target_ )
+ {
+ Pawn* newTarget = this->closestTarget();
+ if ( newTarget &&
+ this->distance (this->getControllableEntity(), static_cast<ControllableEntity*>(newTarget))
+ <= this->attackRange_ )
+ {
+ Point p = { Action::FIGHT, this->getName(newTarget), Vector3::ZERO, false };
+ this->parsedActionpoints_.push_back(p);
+ this->executeActionpoint();
+ }
+ }
+ }
+ }
+}
Added: code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.h
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.h (rev 0)
+++ code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.h 2015-11-26 08:08:11 UTC (rev 10864)
@@ -0,0 +1,112 @@
+/*
+ * 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 _ActionpointController_H__
+#define _ActionpointController_H__
+
+#include "controllers/CommonController.h"
+
+
+namespace orxonox
+{
+ namespace Action
+ {
+ enum Value
+ {
+ NONE, FLY, FIGHT, PROTECT, FIGHTALL, ATTACK
+ };
+
+ }
+
+ struct Point {
+ Action::Value action;
+ std::string name;
+ Vector3 position;
+ bool inLoop;
+ } ;
+
+ class _OrxonoxExport ActionpointController : public CommonController
+ {
+ public:
+ //----[language demanded functions]----
+ ActionpointController(Context* context);
+ virtual ~ActionpointController();
+ //----[language demanded functions]----
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+ virtual void tick(float dt);
+ void addActionpoint(WorldEntity* waypoint);
+ WorldEntity* getActionpoint(unsigned int index) const;
+ virtual void stayNearProtect();
+ virtual void action(); //<! action() is called in regular intervals managing the bot's behaviour.
+ virtual void takeActionpoints (std::vector<Point > vector, std::vector<Point > loop, bool b);
+ Action::Value getAction ();
+ std::string getActionName();
+
+ void setAction (Action::Value action);
+ void setAction (Action::Value action, ControllableEntity* target);
+ void setAction (Action::Value action, const Vector3& target);
+ void setAction (Action::Value action, const Vector3& target, const Quaternion& orient );
+
+
+
+
+ protected:
+ void startAttackingEnemiesThatAreClose();
+
+ //----[Actionpoint information]----
+ Action::Value action_;
+ std::string protectName_;
+ std::string targetName_;
+ std::vector<WeakPtr<WorldEntity> > actionpoints_;
+ float squaredaccuracy_;
+ std::vector<Point > parsedActionpoints_;
+ std::vector<Point > loopActionpoints_;
+ bool bInLoop_;
+ bool bLoop_;
+ bool bEndLoop_;
+ bool bTakenOver_;
+ //----[/Actionpoint information]----
+ void setProtect (ControllableEntity* protect);
+ ControllableEntity* getProtect ();
+ void setClosestTarget();
+ Pawn* closestTarget();
+ //----[Actionpoint methods]----
+ void executeActionpoint();
+ void nextActionpoint();
+ void fillLoop();
+ void fillLoopReversed();
+ void moveBackToTop();
+ //----[Actionpoint methods]----
+
+ private:
+
+ };
+}
+
+#endif /* _ActionpointController_H__ */
Modified: code/branches/campaignHS15/src/orxonox/controllers/CMakeLists.txt
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/CMakeLists.txt 2015-11-25 21:07:48 UTC (rev 10863)
+++ code/branches/campaignHS15/src/orxonox/controllers/CMakeLists.txt 2015-11-26 08:08:11 UTC (rev 10864)
@@ -15,4 +15,5 @@
WingmanController.cc
SectionController.cc
CommonController.cc
+ ActionpointController.cc
)
Modified: code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc 2015-11-25 21:07:48 UTC (rev 10863)
+++ code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc 2015-11-26 08:08:11 UTC (rev 10864)
@@ -67,49 +67,20 @@
CommonController::CommonController( Context* context ): Controller( context )
{
- this->squaredaccuracy_ = 2500;
this->bFirstTick_ = true;
this->tolerance_ = 50;
- this->action_ = Action::NONE;
this->stopLookingAtTarget();
this->attackRange_ = 2500;
- this->bInLoop_ = false;
- this->bLoop_ = false;
- this->bEndLoop_ = false;
- this->parsedActionpoints_.clear();
RegisterObject( CommonController );
- this->bTakenOver_ = false;
+
}
CommonController::~CommonController()
{
- parsedActionpoints_.clear();
- actionpoints_.clear();
+
}
void CommonController::tick(float dt)
{
- if (this->bHasTargetPosition_)
- {
- this->moveToTargetPosition(dt);
- }
- else if (this->bLookAtTarget_)
- {
- this->lookAtTarget(dt);
- }
- if (bShooting_)
- {
- this->doFire();
- }
- if (this->bFirstTick_)
- {
- std::reverse(parsedActionpoints_.begin(), parsedActionpoints_.end());
- std::reverse(actionpoints_.begin(), actionpoints_.end());
- if (this->parsedActionpoints_.empty())
- {
- this->action_ = Action::FIGHTALL;
- }
- }
- if (this->bFirstTick_)
- this->bFirstTick_ = false;
+
SUPER(CommonController, tick, dt);
}
@@ -121,7 +92,6 @@
{
SUPER( CommonController, XMLPort, xmlelement, mode );
XMLPortParam( CommonController, "formationMode", setFormationModeXML, getFormationModeXML, xmlelement, mode );
- XMLPortObject(CommonController, WorldEntity, "actionpoints", addActionpoint, getActionpoint, xmlelement, mode);
}
void CommonController::setFormationModeXML( std::string val )
{
@@ -168,67 +138,7 @@
{
return this->rank_;
}
- void CommonController::addActionpoint(WorldEntity* actionpoint)
- {
- std::string actionName;
- Vector3 position;
- std::string targetName;
- bool inLoop = false;
- Point p;
- if (static_cast<Actionpoint*> (actionpoint))
- {
- Actionpoint* ap = static_cast<Actionpoint*> (actionpoint);
- actionName = ap->getActionXML();
- targetName = ap->getName();
- position = ap->getWorldPosition();
-
- if (this->bEndLoop_)
- {
- this->bInLoop_ = false;
- }
- if (!this->bInLoop_ && ap->getLoopStart())
- {
- this->bInLoop_ = true;
- }
- if (this->bInLoop_ && ap->getLoopEnd())
- {
- this->bEndLoop_ = true;
- }
- inLoop = this->bInLoop_;
-
- Action::Value value;
-
- if ( actionName == "FIGHT" )
- { value = Action::FIGHT; }
- else if ( actionName == "FLY" )
- { value = Action::FLY; }
- else if ( actionName == "PROTECT" )
- { value = Action::PROTECT; }
- else if ( actionName == "NONE" )
- { value = Action::NONE; }
- else if ( actionName == "FIGHTALL" )
- { value = Action::FIGHTALL; }
- else if ( actionName == "ATTACK" )
- { value = Action::ATTACK; }
- else
- ThrowException( ParseError, std::string( "Attempting to set an unknown Action: '" )+ actionName + "'." );
- p.action = value; p.name = targetName; p.position = position; p.inLoop = inLoop;
- }
- else
- {
- p.action = Action::FLY; p.name = ""; p.position = actionpoint->getWorldPosition(); p.inLoop = inLoop;
- }
- parsedActionpoints_.push_back(p);
- this->actionpoints_.push_back(actionpoint);
- }
- WorldEntity* CommonController::getActionpoint(unsigned int index) const
- {
- if (index < this->actionpoints_.size())
- return this->actionpoints_[index];
- else
- return 0;
- }
-
+
//------------------------------------------------------------------------------
//-------------------------------World interaction------------------------------
//------------------------------------------------------------------------------
@@ -248,66 +158,7 @@
{
return this->target_;
}
- Action::Value CommonController::getAction ()
- {
- return this->action_;
- }
- std::string CommonController::getActionName()
- {
- switch ( this->action_ )
- {
- case Action::FIGHT:
- { return "FIGHT"; break; }
- case Action::FLY:
- { return "FLY"; break; }
- case Action::PROTECT:
- { return "PROTECT"; break; }
- case Action::NONE:
- { return "NONE"; break; }
- case Action::FIGHTALL:
- { return "FIGHTALL"; break; }
- case Action::ATTACK:
- { return "ATTACK"; break; }
- default:
- return "NONE";
- break;
- }
- }
- void CommonController::setAction (Action::Value action)
- {
- this->action_ = action;
- }
- void CommonController::setAction (Action::Value action, ControllableEntity* target)
- {
- this->action_ = action;
- if (action == Action::FIGHT || action == Action::FIGHTALL || action == Action::ATTACK)
- {
- if (target)
- this->setTarget (target);
- }
- else if (action == Action::PROTECT)
- {
- if (target)
- this->setProtect (target);
- }
- }
- void CommonController::setAction (Action::Value action, const Vector3& target)
- {
- this->action_ = action;
- if (action == Action::FLY)
- {
- this->setTargetPosition (target);
- }
- }
- void CommonController::setAction (Action::Value action, const Vector3& target, const Quaternion& orient )
- {
- this->action_ = action;
- if (action == Action::FLY)
- {
- this->setTargetPosition (target);
- this->setTargetOrientation (orient);
- }
- }
+
//------------------------------------------------------------------------------
//--------------------------------Helper methods--------------------------------
@@ -602,14 +453,7 @@
this->orientationOfTarget_=orient;
this->bHasOrientationOfTarget_=true;
}
- void CommonController::setProtect (ControllableEntity* protect)
- {
- this->protect_ = protect;
- }
- ControllableEntity* CommonController::getProtect ()
- {
- return this->protect_;
- }
+
void CommonController::maneuver()
{
maneuverCounter_++;
@@ -738,447 +582,9 @@
pawn->setAimPosition( this->positionOfTarget_ );
this->getControllableEntity() ->fire( 0 );
}
- void CommonController::setClosestTarget()
- {
- this->setTarget (static_cast<ControllableEntity*>( closestTarget() ) );
- }
- Pawn* CommonController::closestTarget()
- {
- if (!this->getControllableEntity())
- return 0;
- Pawn* closestTarget = 0;
- float minDistance = std::numeric_limits<float>::infinity();
- Gametype* gt = this->getGametype();
- for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
- {
- if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>(*itP), gt) )
- continue;
- float distance = CommonController::distance (*itP, this->getControllableEntity());
- if (distance < minDistance)
- {
- closestTarget = *itP;
- minDistance = distance;
- }
- }
- if (closestTarget)
- {
- return closestTarget;
- }
- return 0;
- }
- void CommonController::startAttackingEnemiesThatAreClose()
- {
- if (this->action_ != Action::FIGHT && this->action_ != Action::FIGHTALL)
- {
- if ( (this->target_ && this->distance (this->getControllableEntity(), this->target_) > this->attackRange_)
- || !this->target_ )
- {
- Pawn* newTarget = this->closestTarget();
- if ( newTarget &&
- this->distance (this->getControllableEntity(), static_cast<ControllableEntity*>(newTarget))
- <= this->attackRange_ )
- {
- Point p = { Action::FIGHT, this->getName(newTarget), Vector3::ZERO, false };
- this->parsedActionpoints_.push_back(p);
- this->executeActionpoint();
- }
- }
- }
- }
-
- //------------------------------------------------------------------------------
- //------------------------------Actionpoint methods-----------------------------
- //------------------------------------------------------------------------------
-
- //POST: this starts doing what was asked by the last element of parsedActionpoints_,
- //if last element was failed to be parsed, next element will be executed.
- void CommonController::executeActionpoint()
- {
- if (this->bLoop_)
- {
- if (!this->loopActionpoints_.empty())
- {
- this->action_ = this->loopActionpoints_.back().action;
- switch ( this->action_ )
- {
- case Action::FIGHT:
- {
- std::string targetName = this->loopActionpoints_.back().name;
- if (targetName == "")
- {
- break;
- }
- for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
- {
- if (CommonController::getName(*itP) == targetName)
- {
- this->setTarget (static_cast<ControllableEntity*>(*itP));
- }
- }
- break;
- }
- case Action::FLY:
- {
- this->setTargetPosition( this->loopActionpoints_.back().position );
- if (this->squaredDistanceToTarget() <= this->squaredaccuracy_)
- {
- this->nextActionpoint();
- this->executeActionpoint();
- }
- break;
- }
- case Action::PROTECT:
- {
- std::string protectName = this->loopActionpoints_.back().name;
- if (protectName == "reservedKeyword:human")
- {
- for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
- {
- if (orxonox_cast<ControllableEntity*>(*itP) && ((*itP)->getController()) && orxonox_cast <NewHumanController*> ((*itP)->getController()))
- {
- this->setProtect (static_cast<ControllableEntity*>(*itP));
- }
- }
- }
- else
- {
- for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
- {
- if (CommonController::getName(*itP) == protectName)
- {
- this->setProtect (static_cast<ControllableEntity*>(*itP));
- }
- }
- }
- if (!this->getProtect())
- {
- this->nextActionpoint();
- this->executeActionpoint();
- }
- break;
- }
- case Action::NONE:
- {
- break;
- }
- case Action::FIGHTALL:
- {
- break;
- }
- case Action::ATTACK:
- {
- std::string targetName = this->loopActionpoints_.back().name;
-
- for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
- {
- if (CommonController::getName(*itP) == targetName)
- {
- this->setTarget (static_cast<ControllableEntity*>(*itP));
- }
- }
- if (!this->hasTarget())
- {
- this->nextActionpoint();
- this->executeActionpoint();
- }
- break;
- }
- default:
- break;
- }
- }
- else
- {
- this->bLoop_ = false;
- }
- }
- else
- {
- if (!this->parsedActionpoints_.empty())
- {
- if (this->parsedActionpoints_.back().inLoop)
- {
- //MOVES all points that are in loop to a loop vector
- this->fillLoop();
- this->bLoop_ = true;
- executeActionpoint();
- return;
- }
- this->action_ = this->parsedActionpoints_.back().action;
- switch ( this->action_ )
- {
- case Action::FIGHT:
- {
- std::string targetName = this->parsedActionpoints_.back().name;
- if (targetName == "")
- {
- break;
- }
- for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
- {
- if (CommonController::getName(*itP) == targetName)
- {
- this->setTarget (static_cast<ControllableEntity*>(*itP));
- }
- }
- break;
- }
- case Action::FLY:
- {
- this->setTargetPosition( this->parsedActionpoints_.back().position );
- if (this->squaredDistanceToTarget() <= this->squaredaccuracy_)
- {
- this->nextActionpoint();
- this->executeActionpoint();
- }
- break;
- }
- case Action::PROTECT:
- {
-
- std::string protectName = this->parsedActionpoints_.back().name;
- if (protectName == "reservedKeyword:human")
- {
- for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
- {
- if (orxonox_cast<ControllableEntity*>(*itP) && ((*itP)->getController()) && orxonox_cast <NewHumanController*> ((*itP)->getController()))
- {
- this->setProtect (static_cast<ControllableEntity*>(*itP));
- }
- }
- }
- else
- {
- for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
- {
- if (CommonController::getName(*itP) == protectName)
- {
- this->setProtect (static_cast<ControllableEntity*>(*itP));
- }
- }
- }
- if (!this->getProtect())
- {
- this->nextActionpoint();
- this->executeActionpoint();
- }
- break;
- }
- case Action::NONE:
- {
- break;
- }
- case Action::FIGHTALL:
- {
- break;
- }
- case Action::ATTACK:
- {
- std::string targetName = this->parsedActionpoints_.back().name;
-
- for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
- {
- if (CommonController::getName(*itP) == targetName)
- {
- this->setTarget (static_cast<ControllableEntity*>(*itP));
- }
- }
- if (!this->hasTarget())
- {
- this->nextActionpoint();
- this->executeActionpoint();
- }
- break;
- }
- default:
- break;
- }
- }
- else
- {
- this->setTarget(0);
- this->setTargetPosition(this->getControllableEntity()->getWorldPosition());
- this->action_ = Action::NONE;
- }
- }
-
- }
- void CommonController::stayNearProtect()
- {
- Vector3* targetRelativePosition;
- targetRelativePosition = new Vector3 (0, 300, 300);
- Vector3 targetAbsolutePosition = ((this->getProtect()->getWorldPosition()) +
- (this->getProtect()->getWorldOrientation()* (*targetRelativePosition)));
- this->setTargetPosition(targetAbsolutePosition);
- }
- void CommonController::nextActionpoint()
- {
- if (!this || !this->getControllableEntity())
- return;
- if (this->bLoop_)
- {
- if (!this->loopActionpoints_.empty())
- {
- this->moveBackToTop();
- }
- }
- else
- {
- if (!this->parsedActionpoints_.empty())
- {
- this->parsedActionpoints_.pop_back();
- }
- }
- this->setAction(Action::NONE);
- }
- void CommonController::moveBackToTop()
- {
- Point temp = loopActionpoints_.back();
- loopActionpoints_.pop_back();
- std::reverse (loopActionpoints_.begin(), loopActionpoints_.end());
- loopActionpoints_.push_back(temp);
- std::reverse (loopActionpoints_.begin(), loopActionpoints_.end());
- }
- void CommonController::fillLoop()
- {
- loopActionpoints_.clear();
- fillLoopReversed();
- std::reverse (loopActionpoints_.begin(), loopActionpoints_.end());
- }
- void CommonController::fillLoopReversed()
- {
- if (parsedActionpoints_.back().inLoop)
- {
- loopActionpoints_.push_back(parsedActionpoints_.back());
- parsedActionpoints_.pop_back();
- }
- if (parsedActionpoints_.back().inLoop)
- {
- fillLoopReversed();
- }
- }
- void CommonController::action()
- {
- if (!this || !this->getControllableEntity())
- return;
- // orxout (internal_error) << "Size of actions is " << this->parsedActionpoints_.size() << endl;
- this->startAttackingEnemiesThatAreClose();
- //No action -> pop one from stack
- if (this->action_ == Action::NONE || this->bTakenOver_)
- {
- if (this->parsedActionpoints_.empty() && this->loopActionpoints_.empty())
- {
- Point p = { Action::FIGHTALL, "", Vector3::ZERO, false };
- this->parsedActionpoints_.push_back (p);
- }
- this->executeActionpoint();
- this->bTakenOver_ = false;
- }
- //Action fightall -> fight till nobody alive
- if (this->action_ == Action::FIGHTALL)
- {
- if (!this->hasTarget())
- {
- //----find a target----
- ControllableEntity* newTarget = this->closestTarget();
- if (newTarget)
- {
- this->setAction (Action::FIGHTALL, newTarget);
- }
- else
- {
- this->nextActionpoint();
- return;
- }
- }
- else if (this->hasTarget())
- {
-
- }
- }
- //Action fight -> fight as long as enemies in range
- else if (this->action_ == Action::FIGHT)
- {
- if (!this->hasTarget())
- {
- //----find a target----
- ControllableEntity* newTarget = this->closestTarget();
- if (newTarget &&
- CommonController::distance (this->getControllableEntity(), newTarget) < this->attackRange_)
- {
- this->setAction (Action::FIGHT, newTarget);
- }
- else
- {
- this->nextActionpoint();
- return;
- }
- }
- else if (this->hasTarget())
- {
- //----fly in formation if far enough----
- Vector3 diffVector = this->positionOfTarget_ - this->getControllableEntity()->getWorldPosition();
-
- if (diffVector.length() > this->attackRange_)
- {
- ControllableEntity* newTarget = this->closestTarget();
-
- if (newTarget &&
- CommonController::distance (this->getControllableEntity(), newTarget) < this->attackRange_)
- {
- this->setAction (Action::FIGHT, newTarget);
- }
- else
- {
- this->nextActionpoint();
- return;
- }
- }
- }
- }
- else if (this->action_ == Action::FLY)
- {
- if (this->squaredDistanceToTarget() <= this->squaredaccuracy_)
- {
- this->nextActionpoint();
- return;
- }
- }
- else if (this->action_ == Action::PROTECT)
- {
- if (!this->getProtect())
- {
- this->nextActionpoint();
- return;
- }
- this->stayNearProtect();
- }
- else if (this->action_ == Action::ATTACK)
- {
- if (!this->hasTarget())
- {
- this->nextActionpoint();
- return;
- }
- }
- if (this->hasTarget())
- {
- //----choose where to go----
- this->maneuver();
- //----fire if you can----
- this->bShooting_ = this->canFire();
- }
- }
- void CommonController::takeActionpoints (std::vector<Point > vector, std::vector<Point > loop, bool b)
- {
- this->parsedActionpoints_ = vector;
- this->loopActionpoints_ = loop;
- this->bLoop_ = this->bLoop_;
- this->bTakenOver_ = true;
- // orxout(internal_error) << "Top action is " << this->parsedActionpoints_.back().action << endl;
- }
+
void CommonController::boostControl()
{
SpaceShip* ship = orxonox_cast<SpaceShip*>(this->getControllableEntity());
Modified: code/branches/campaignHS15/src/orxonox/controllers/CommonController.h
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/CommonController.h 2015-11-25 21:07:48 UTC (rev 10863)
+++ code/branches/campaignHS15/src/orxonox/controllers/CommonController.h 2015-11-26 08:08:11 UTC (rev 10864)
@@ -60,23 +60,8 @@
};
}
- namespace Action
- {
- enum Value
- {
- NONE, FLY, FIGHT, PROTECT, FIGHTALL, ATTACK
- };
-
- }
-
- struct Point {
- Action::Value action;
- std::string name;
- Vector3 position;
- bool inLoop;
- } ;
+
-
@@ -95,16 +80,15 @@
//----[XML methods]----
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
- void setFormationModeXML(std::string val);
- std::string getFormationModeXML();
- void setFormationMode(FormationMode::Value val);
- FormationMode::Value getFormationMode() const;
+ void setFormationModeXML(std::string val);
+ std::string getFormationModeXML();
+ void setFormationMode(FormationMode::Value val);
+ FormationMode::Value getFormationMode() const;
- void setRank(Rank::Value val);
- Rank::Value getRank() const;
-
- void addActionpoint(WorldEntity* waypoint);
- WorldEntity* getActionpoint(unsigned int index) const;
+ void setRank(Rank::Value val);
+ Rank::Value getRank() const;
+
+
//----[/XML methods]----
//----[Interaction with other Controllers]----
@@ -114,15 +98,8 @@
bool hasTarget();
ControllableEntity* getTarget();
- Action::Value getAction ();
- std::string getActionName();
+ //----[/Interaction with other Controllers]----
- void setAction (Action::Value action);
- void setAction (Action::Value action, ControllableEntity* target);
- void setAction (Action::Value action, const Vector3& target);
- void setAction (Action::Value action, const Vector3& target, const Quaternion& orient );
- //----[/Interaction with other Controllers]----
-
//----[Helper methods]----
float randomInRange(float a, float b);
static float distance(ControllableEntity* entity1, ControllableEntity* entity2);
@@ -134,11 +111,7 @@
bool isLookingAtTarget(float angle);
//----[/Helper methods]----
-
- virtual void stayNearProtect();
- virtual void action(); //<! action() is called in regular intervals managing the bot's behaviour.
- virtual void takeActionpoints (std::vector<Point > vector, std::vector<Point > loop, bool b);
-
+
protected:
//----[Flying methods]----
void stopMoving();
@@ -167,16 +140,12 @@
void setPositionOfTarget(const Vector3& target);
void setOrientationOfTarget(const Quaternion& orient);
- void setProtect (ControllableEntity* protect);
- ControllableEntity* getProtect ();
void maneuver();
void dodge(Vector3& thisPosition, Vector3& diffUnit);
bool canFire();
void doFire();
- void setClosestTarget();
- Pawn* closestTarget();
- void startAttackingEnemiesThatAreClose();
+
//----[/Fighting methods]----
//----[where-to-fly information]----
@@ -199,37 +168,18 @@
Quaternion orientationOfTarget_;
//----[/who-to-kill information]----
- //----[Actionpoint information]----
- std::vector<WeakPtr<WorldEntity> > actionpoints_;
- float squaredaccuracy_;
- std::vector<Point > parsedActionpoints_;
- std::vector<Point > loopActionpoints_;
-
- //----[/Actionpoint information]----
- //----[Actionpoint methods]----
- void executeActionpoint();
- void nextActionpoint();
- void fillLoop();
- void fillLoopReversed();
- void moveBackToTop();
- //----[Actionpoint methods]----
//----["Private" variables]----
FormationMode::Value formationMode_;
Rank::Value rank_;
- std::string protectName_;
- std::string targetName_;
- Action::Value action_;
+
int attackRange_;
bool bLookAtTarget_;
bool bShooting_;
int maneuverCounter_;
int tolerance_;
bool bFirstTick_;
- bool bInLoop_;
- bool bLoop_;
- bool bEndLoop_;
- bool bTakenOver_;
+
//----[/"Private" variables]----
};
Modified: code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc 2015-11-25 21:07:48 UTC (rev 10863)
+++ code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc 2015-11-26 08:08:11 UTC (rev 10864)
@@ -90,7 +90,7 @@
if (!this || !this->getControllableEntity())
return;
- CommonController::action();
+ ActionpointController::action();
if (!this || !this->getControllableEntity())
return;
if (!(this->parsedActionpoints_.empty() && this->loopActionpoints_.empty()))
@@ -108,10 +108,10 @@
}
void DivisionController::stayNearProtect()
{
- CommonController::stayNearProtect();
+ ActionpointController::stayNearProtect();
}
- bool DivisionController::setWingman(CommonController* cwingman)
+ bool DivisionController::setWingman(ActionpointController* cwingman)
{
WeakPtr<WingmanController> wingman = orxonox_cast<WingmanController*>(cwingman);
Modified: code/branches/campaignHS15/src/orxonox/controllers/DivisionController.h
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/DivisionController.h 2015-11-25 21:07:48 UTC (rev 10863)
+++ code/branches/campaignHS15/src/orxonox/controllers/DivisionController.h 2015-11-26 08:08:11 UTC (rev 10864)
@@ -52,7 +52,7 @@
//----[own functions]----
virtual bool setFollower(LeaderController* myFollower);
- virtual bool setWingman(CommonController* cwingman);
+ virtual bool setWingman(ActionpointController* cwingman);
virtual bool hasWingman();
virtual bool hasFollower();
Modified: code/branches/campaignHS15/src/orxonox/controllers/LeaderController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/LeaderController.cc 2015-11-25 21:07:48 UTC (rev 10863)
+++ code/branches/campaignHS15/src/orxonox/controllers/LeaderController.cc 2015-11-26 08:08:11 UTC (rev 10864)
@@ -35,7 +35,7 @@
RegisterClass(LeaderController);
//CommonController contains all common functionality of AI Controllers
- LeaderController::LeaderController(Context* context) : CommonController(context)
+ LeaderController::LeaderController(Context* context) : ActionpointController(context)
{
RegisterObject(LeaderController);
Modified: code/branches/campaignHS15/src/orxonox/controllers/LeaderController.h
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/LeaderController.h 2015-11-25 21:07:48 UTC (rev 10863)
+++ code/branches/campaignHS15/src/orxonox/controllers/LeaderController.h 2015-11-26 08:08:11 UTC (rev 10864)
@@ -29,7 +29,7 @@
#ifndef _LeaderController_H__
#define _LeaderController_H__
-#include "controllers/CommonController.h"
+#include "controllers/ActionpointController.h"
#include "controllers/WingmanController.h"
@@ -37,7 +37,7 @@
namespace orxonox
{
- class _OrxonoxExport LeaderController : public CommonController
+ class _OrxonoxExport LeaderController : public ActionpointController
{
public:
//----[language demanded functions]----
Modified: code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc 2015-11-25 21:07:48 UTC (rev 10863)
+++ code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc 2015-11-26 08:08:11 UTC (rev 10864)
@@ -98,7 +98,7 @@
if (!myDivisionLeader_)
{
- CommonController::action();
+ ActionpointController::action();
if (!this || !this->getControllableEntity())
return;
if (!(this->parsedActionpoints_.empty() && this->loopActionpoints_.empty()))
@@ -306,7 +306,7 @@
}
return 0;
}
- bool SectionController::setWingman(CommonController* cwingman)
+ bool SectionController::setWingman(ActionpointController* cwingman)
{
WeakPtr<WingmanController> wingman = orxonox_cast<WingmanController*>(cwingman);
Modified: code/branches/campaignHS15/src/orxonox/controllers/SectionController.h
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/SectionController.h 2015-11-25 21:07:48 UTC (rev 10863)
+++ code/branches/campaignHS15/src/orxonox/controllers/SectionController.h 2015-11-26 08:08:11 UTC (rev 10864)
@@ -52,7 +52,7 @@
//----[own functions]----
LeaderController* findNewDivisionLeader();
- virtual bool setWingman(CommonController* cwingman);
+ virtual bool setWingman(ActionpointController* cwingman);
virtual bool hasWingman();
void chooseTarget();
Modified: code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc 2015-11-25 21:07:48 UTC (rev 10863)
+++ code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc 2015-11-26 08:08:11 UTC (rev 10864)
@@ -34,8 +34,8 @@
RegisterClass(WingmanController);
- //CommonController contains all common functionality of AI Controllers
- WingmanController::WingmanController(Context* context) : CommonController(context)
+ //ActionpointController contains all common functionality of AI Controllers
+ WingmanController::WingmanController(Context* context) : ActionpointController(context)
{
RegisterObject(WingmanController);
this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&WingmanController::action, this)));
@@ -80,7 +80,7 @@
//----If no leader, find one----
if (!this->myLeader_)
{
- CommonController* newLeader = findNewLeader();
+ ActionpointController* newLeader = findNewLeader();
this->myLeader_ = newLeader;
}
@@ -91,7 +91,7 @@
}
if (!this->myLeader_)
{
- CommonController::action();
+ ActionpointController::action();
}
else if (this->myLeader_)
{
@@ -216,17 +216,17 @@
return *targetRelativePosition;
}
//----POST: closest leader that is ready to take a new wingman is returned----
- CommonController* WingmanController::findNewLeader()
+ ActionpointController* WingmanController::findNewLeader()
{
if (!this->getControllableEntity())
return 0;
//----vars for finding the closest leader----
- CommonController* closestLeader = 0;
+ ActionpointController* closestLeader = 0;
float minDistance = std::numeric_limits<float>::infinity();
Gametype* gt = this->getGametype();
- for (ObjectList<CommonController>::iterator it = ObjectList<CommonController>::begin(); it; ++it)
+ for (ObjectList<ActionpointController>::iterator it = ObjectList<ActionpointController>::begin(); it; ++it)
{
//----0ptr or not a leader or dead?----
if (!it ||
Modified: code/branches/campaignHS15/src/orxonox/controllers/WingmanController.h
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/WingmanController.h 2015-11-25 21:07:48 UTC (rev 10863)
+++ code/branches/campaignHS15/src/orxonox/controllers/WingmanController.h 2015-11-26 08:08:11 UTC (rev 10864)
@@ -30,12 +30,12 @@
#define _WingmanController_H__
-#include "controllers/CommonController.h"
+#include "controllers/ActionpointController.h"
namespace orxonox
{
- class _OrxonoxExport WingmanController : public CommonController
+ class _OrxonoxExport WingmanController : public ActionpointController
{
public:
//----[language demanded functions]----
@@ -51,7 +51,7 @@
//----[/orxonox demanded functions]----
//----[own functions]----
- CommonController* findNewLeader();
+ ActionpointController* findNewLeader();
//----[/own functions]----
protected:
@@ -61,7 +61,7 @@
private:
//----private variables-----
- WeakPtr<CommonController> myLeader_;
+ WeakPtr<ActionpointController> myLeader_;
Timer actionTimer_; //<! Regularly calls action().
bool bFirstAction_;
More information about the Orxonox-commit
mailing list