[Orxonox-commit 3816] r8493 - in code/branches/dockingsystem2: data/gui/scripts data/levels src/modules/docking src/orxonox/controllers
sven at orxonox.net
sven at orxonox.net
Mon May 16 18:21:05 CEST 2011
Author: sven
Date: 2011-05-16 18:21:05 +0200 (Mon, 16 May 2011)
New Revision: 8493
Added:
code/branches/dockingsystem2/src/modules/docking/DockingAnimation.cc
code/branches/dockingsystem2/src/modules/docking/DockingAnimation.h
code/branches/dockingsystem2/src/modules/docking/DockingController.cc
code/branches/dockingsystem2/src/modules/docking/DockingController.h
code/branches/dockingsystem2/src/modules/docking/MoveToDockingTarget.cc
code/branches/dockingsystem2/src/modules/docking/MoveToDockingTarget.h
Modified:
code/branches/dockingsystem2/data/gui/scripts/DockingDialog.lua
code/branches/dockingsystem2/data/levels/docking.oxw
code/branches/dockingsystem2/src/modules/docking/CMakeLists.txt
code/branches/dockingsystem2/src/modules/docking/Dock.cc
code/branches/dockingsystem2/src/modules/docking/Dock.h
code/branches/dockingsystem2/src/modules/docking/DockToShip.cc
code/branches/dockingsystem2/src/modules/docking/DockToShip.h
code/branches/dockingsystem2/src/modules/docking/DockingEffect.cc
code/branches/dockingsystem2/src/modules/docking/DockingEffect.h
code/branches/dockingsystem2/src/modules/docking/DockingPrereqs.h
code/branches/dockingsystem2/src/orxonox/controllers/ArtificialController.cc
code/branches/dockingsystem2/src/orxonox/controllers/ArtificialController.h
Log:
Added docking animations, skeletton for DockingController..
Modified: code/branches/dockingsystem2/data/gui/scripts/DockingDialog.lua
===================================================================
--- code/branches/dockingsystem2/data/gui/scripts/DockingDialog.lua 2011-05-16 15:25:00 UTC (rev 8492)
+++ code/branches/dockingsystem2/data/gui/scripts/DockingDialog.lua 2011-05-16 16:21:05 UTC (rev 8493)
@@ -9,12 +9,12 @@
end
function P.onShow()
- orxonox.CommandExecutor:execute("pause")
+ orxonox.execute("setPause 1")
P.update()
end
function P.onHide()
- orxonox.CommandExecutor:execute("pause")
+ orxonox.execute("setPause 0")
end
function P.update()
@@ -41,9 +41,7 @@
if choice ~= nil then
local index = listbox:getItemIndex(choice)
local dock = P.docks[index+1]
- cout(0, index )--.. ": " .. P.docks[index])
if dock ~= nil then
- cout(0, "LUA>Docking")
dock:dock()
end
end
@@ -51,7 +49,6 @@
end
function P.cancelButton_clicked(e)
- --P.hideMe()
hideMenuSheet(P.name)
end
Modified: code/branches/dockingsystem2/data/levels/docking.oxw
===================================================================
--- code/branches/dockingsystem2/data/levels/docking.oxw 2011-05-16 15:25:00 UTC (rev 8492)
+++ code/branches/dockingsystem2/data/levels/docking.oxw 2011-05-16 16:21:05 UTC (rev 8493)
@@ -34,13 +34,12 @@
-
<Dock>
- <animation>
+ <animations>
<MoveToDockingTarget target="destroyer" position="10,150,40" />
- </animation>
+ </animations>
<effects>
- <DockToShip target="destroyer" />
+ <DockToShip target="spaceShip" />
</effects>
<events>
<execute>
@@ -48,7 +47,7 @@
</execute>
</events>
<attached>
- <DistanceTrigger position="0,0,0" distance="30" target="Pawn" beaconMode="exclude" targetname="destroyerBeacon" name="dockMe" />
+ <DistanceTrigger position="0,0,0" distance="30" target="Pawn" beaconMode="exclude" targetname="bcnSpaceShip" name="dockMe" />
<Billboard material="Examples/Flare" colour="1.0, 0, 0" />
</attached>
</Dock>
@@ -78,8 +77,8 @@
angularDamping = "0.9999999"
>
<attached>
- <DistanceTriggerBeacon name="bcnSpaceShip1" />
- <DockingTarget name="spaceShip1" />
+ <DistanceTriggerBeacon name="bcnSpaceShip" />
+ <DockingTarget name="spaceShip" />
<Model position="0,0,0" yaw="90" pitch="-90" roll="0" scale="4" mesh="assff.mesh" />
<BlinkingBillboard position="17,-1.5,0" material="Examples/Flare" colour="1.0, 0.5, 0.3" amplitude="0.1" frequency="0.5" quadratic="1" />
Modified: code/branches/dockingsystem2/src/modules/docking/CMakeLists.txt
===================================================================
--- code/branches/dockingsystem2/src/modules/docking/CMakeLists.txt 2011-05-16 15:25:00 UTC (rev 8492)
+++ code/branches/dockingsystem2/src/modules/docking/CMakeLists.txt 2011-05-16 16:21:05 UTC (rev 8493)
@@ -1,7 +1,10 @@
SET_SOURCE_FILES(DOCKING_SRC_FILES
DockingTarget.cc
DockingEffect.cc
+ DockingAnimation.cc
DockToShip.cc
+ MoveToDockingTarget.cc
+ DockingController.cc
Dock.cc
)
Modified: code/branches/dockingsystem2/src/modules/docking/Dock.cc
===================================================================
--- code/branches/dockingsystem2/src/modules/docking/Dock.cc 2011-05-16 15:25:00 UTC (rev 8492)
+++ code/branches/dockingsystem2/src/modules/docking/Dock.cc 2011-05-16 16:21:05 UTC (rev 8493)
@@ -56,7 +56,6 @@
Dock::Dock(BaseObject* creator) : StaticEntity(creator)
{
RegisterObject(Dock);
- COUT(0) << "Registering dock..." << std::endl;
}
Dock::~Dock()
@@ -69,9 +68,8 @@
SUPER(Dock, XMLPort, xmlelement, mode);
XMLPortObject(Dock, DockingEffect, "effects", addEffect, getEffect, xmlelement, mode);
+ XMLPortObject(Dock, DockingAnimation, "animations", addAnimation, getAnimation, xmlelement, mode);
XMLPortEventSink(Dock, BaseObject, "execute", execute, xmlelement, mode);
-
- COUT(0) << "Dock created.." << std::endl;
}
void Dock::XMLEventPort(Element& xmlelement, XMLPort::Mode mode)
@@ -95,7 +93,9 @@
return false;
}
pawn = pTrigger->getTriggeringPlayer();
- } else {
+ }
+ else
+ {
COUT(2) << "Docking::execute Not a player trigger, can't extract pawn from it.." << std::endl;
return false;
}
@@ -109,12 +109,10 @@
PlayerInfo* player = pawn->getPlayer();
if(player == NULL)
{
- COUT(2) << "The PlayerInfo* is NULL." << std::endl;
+ COUT(2) << "Docking::execute The PlayerInfo* is NULL." << std::endl;
return false;
}
- COUT(0) << "Dock triggered by player: " << player->getName() << ".." << std::endl;
-
if(bTriggered)
{
// Add player to this Docks candidates
@@ -122,14 +120,11 @@
// Show docking dialog
GUIManager::showGUI("DockingDialog");
- //DockingEffect::invokeEffect(docking::DOCKING, player, effects_);
}
else
{
// Remove player from candidates list
candidates.erase(player);
-
- //DockingEffect::invokeEffect(docking::RELEASE, player, effects_);
}
return true;
@@ -162,34 +157,61 @@
// Check if player is a candidate
if(candidates.find(player) == candidates.end())
{
- COUT(0) << "Player is not a candidate!" << std::endl;
+ COUT(0) << "Dock::dock Player is not a candidate!" << std::endl;
return false;
}
- // Remove player from candidates, add to docked players and invoke docking effect
candidates.erase(player);
docked.insert(player);
- DockingEffect::invokeEffect(docking::ATTACH, player, effects);
+
+ if (animations.empty())
+ return dockingAnimationFinished(player);
+ else
+ DockingAnimation::invokeAnimation(true, player, animations);
+
return true;
}
+ bool Dock::dockingAnimationFinished(PlayerInfo* player)
+ {
+ if(docked.find(player) == docked.end())
+ {
+ COUT(0) << "Dock::dockingAnimationFinished Player is not currently docked." << std::endl;
+ return false;
+ }
+
+ DockingEffect::invokeEffect(true, player, effects);
+ return true;
+ }
+
bool Dock::undock(PlayerInfo* player)
{
// Check if player is docked to this Dock
if(docked.find(player) == docked.end())
{
- COUT(0) << "Player is not docked to this Dock." << std::endl;
+ COUT(0) << "Dock::undock Player is not docked to this Dock." << std::endl;
return false;
}
- // Remove player from docked, add to candidates and reverse DockingEffect
docked.erase(player);
candidates.insert(player);
- DockingEffect::invokeEffect(docking::RELEASE, player, effects);
+
+ DockingEffect::invokeEffect(false, player, effects);
+
+ if (animations.empty())
+ return undockingAnimationFinished(player);
+ else
+ DockingAnimation::invokeAnimation(false, player, animations);
+
return true;
}
+ bool Dock::undockingAnimationFinished(PlayerInfo* player) {
+ COUT(0) << "Dock::undockingAnimationFinished executed" << std::endl;
+ return true;
+ }
+
unsigned int Dock::getNumberOfActiveDocks()
{
int i = 0;
@@ -225,9 +247,8 @@
return true;
}
- const DockingEffect* Dock::getEffect(unsigned int index) const
+ const DockingEffect* Dock::getEffect(unsigned int i) const
{
- int i = index;
for (std::list<DockingEffect*>::const_iterator effect = this->effects.begin(); effect != this->effects.end(); ++effect)
{
if(i == 0)
@@ -236,4 +257,23 @@
}
return NULL;
}
+
+ bool Dock::addAnimation(DockingAnimation* animation)
+ {
+ assert(animation);
+ animation->setParent(this);
+ animations.push_back(animation);
+ return true;
+ }
+
+ const DockingAnimation* Dock::getAnimation(unsigned int i) const
+ {
+ for (std::list<DockingAnimation*>::const_iterator animation = this->animations.begin(); animation != this->animations.end(); ++animation)
+ {
+ if(i == 0)
+ return *animation;
+ i--;
+ }
+ return NULL;
+ }
}
Modified: code/branches/dockingsystem2/src/modules/docking/Dock.h
===================================================================
--- code/branches/dockingsystem2/src/modules/docking/Dock.h 2011-05-16 15:25:00 UTC (rev 8492)
+++ code/branches/dockingsystem2/src/modules/docking/Dock.h 2011-05-16 16:21:05 UTC (rev 8493)
@@ -45,6 +45,7 @@
#include "controllers/HumanController.h"
#include "DockingEffect.h"
+#include "DockingAnimation.h"
#include "DockingPrereqs.h"
namespace orxonox // tolua_export
@@ -57,28 +58,42 @@
Dock(BaseObject* creator);
virtual ~Dock();
+ // Trigger interface
+ bool execute(bool bTriggered, BaseObject* trigger);
+
+ // XML interface
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
- bool execute(bool bTriggered, BaseObject* trigger);
-
+ // XML functions
bool addEffect(DockingEffect* effect); //!< Add a DockingEffect to the Dock.
const DockingEffect* getEffect(unsigned int index) const; //!< Get the DockingEffect at a given index.
+ bool addAnimation(DockingAnimation* animation); //!< Add a DockingAnimation to the Dock.
+ const DockingAnimation* getAnimation(unsigned int index) const; //!< Get the DockingAnimation at a given index.
+ // Docking/undocking logic, checks conditions and invokes the DockingAnimations
bool dock(PlayerInfo* player); //!< Returns true if given player docked successfully (player must be a candidate)
bool undock(PlayerInfo* player); //!< Undocks a player (player must be docked)
+ // Animation logic
+ bool dockingAnimationFinished(PlayerInfo* player); //!< Called when a docking animation finished
+ bool undockingAnimationFinished(PlayerInfo* player); //!< Called when a undocking animation finished
+
+ // LUA interface
void dock() { this->dock(HumanController::getLocalControllerSingleton()->getPlayer()); } // tolua_export
static unsigned int getNumberOfActiveDocks(); // tolua_export
static Dock* getActiveDockAtIndex(unsigned int index); // tolua_export
+ // Console commands
static void cmdDock();
static void cmdUndock();
private:
std::set<PlayerInfo*> candidates; //!< A set of all players which are allowed to dock using the console command.
std::set<PlayerInfo*> docked; //!< A set of all docked players
+
std::list<DockingEffect*> effects; //!< The list of DockingEffects to be executed when a player docks.
+ std::list<DockingAnimation*> animations; //!< The list of DockingAnimations to be executed before a player docks
}; // tolua_export
} // tolua_export
Modified: code/branches/dockingsystem2/src/modules/docking/DockToShip.cc
===================================================================
--- code/branches/dockingsystem2/src/modules/docking/DockToShip.cc 2011-05-16 15:25:00 UTC (rev 8492)
+++ code/branches/dockingsystem2/src/modules/docking/DockToShip.cc 2011-05-16 16:21:05 UTC (rev 8493)
@@ -20,7 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Author:
- * Damian 'Mozork' Frick
+ * Sven Stucki
* Co-authors:
* ...
*
@@ -68,12 +68,6 @@
bool DockToShip::docking(PlayerInfo* player)
{
- COUT(0) << "DockToShip::docking" << endl;
- return true;
- }
-
- bool DockToShip::attach(PlayerInfo* player)
- {
COUT(0) << "DockToShip::attach" << endl;
DockingTarget *target = DockingEffect::findTarget(this->target);
Modified: code/branches/dockingsystem2/src/modules/docking/DockToShip.h
===================================================================
--- code/branches/dockingsystem2/src/modules/docking/DockToShip.h 2011-05-16 15:25:00 UTC (rev 8492)
+++ code/branches/dockingsystem2/src/modules/docking/DockToShip.h 2011-05-16 16:21:05 UTC (rev 8493)
@@ -60,13 +60,11 @@
virtual ~DockToShip();
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
- virtual void setTargetId(std::string str);
- virtual std::string getTargetId();
+ void setTargetId(std::string str);
+ std::string getTargetId();
virtual bool docking(PlayerInfo* player); //!< Called when docking starts
- virtual bool attach(PlayerInfo* player); //!< Called after docking animation
virtual bool release(PlayerInfo* player); //!< Called when player wants undock
-
private:
std::string target;
};
Added: code/branches/dockingsystem2/src/modules/docking/DockingAnimation.cc
===================================================================
--- code/branches/dockingsystem2/src/modules/docking/DockingAnimation.cc (rev 0)
+++ code/branches/dockingsystem2/src/modules/docking/DockingAnimation.cc 2011-05-16 16:21:05 UTC (rev 8493)
@@ -0,0 +1,68 @@
+/*
+ * 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:
+ * Sven Stucki
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file DockingAnimation.cc
+ @brief Implementation of the DockingAnimation class.
+*/
+
+#include "DockingAnimation.h"
+
+#include "DockingEffect.h" // For DockingEffect::findTarget
+
+namespace orxonox
+{
+ DockingAnimation::DockingAnimation(BaseObject* creator) : BaseObject(creator)
+ {
+ RegisterObject(DockingAnimation);
+ }
+
+ DockingAnimation::~DockingAnimation()
+ {
+
+ }
+
+ bool DockingAnimation::invokeAnimation(bool dock, PlayerInfo* player, std::list<DockingAnimation*> &animations)
+ {
+ bool check = true;
+
+ for (std::list<DockingAnimation*>::iterator animation = animations.begin(); animation != animations.end(); animation++)
+ {
+ if(dock)
+ check &= (*animation)->docking(player);
+ else
+ check &= (*animation)->release(player);
+ }
+
+ return check;
+ }
+
+ DockingTarget *DockingAnimation::findTarget(std::string name) {
+ return DockingEffect::findTarget(name);
+ }
+}
Added: code/branches/dockingsystem2/src/modules/docking/DockingAnimation.h
===================================================================
--- code/branches/dockingsystem2/src/modules/docking/DockingAnimation.h (rev 0)
+++ code/branches/dockingsystem2/src/modules/docking/DockingAnimation.h 2011-05-16 16:21:05 UTC (rev 8493)
@@ -0,0 +1,84 @@
+/*
+ * 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:
+ * Sven Stucki
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file DockingAnimation.h
+ @brief Definition of the DockingAnimation class.
+ @ingroup Docking
+*/
+
+#ifndef _DockingAnimation_H__
+#define _DockingAnimation_H__
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+
+#include "infos/PlayerInfo.h"
+
+#include "DockingPrereqs.h"
+#include "DockingTarget.h"
+#include "Dock.h"
+
+
+#include <list>
+#include "core/BaseObject.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ Base class for docking animations used by @ref orxonox::Docking "Docks".
+
+ @author
+ Sven Stucki
+
+ @ingroup Docking
+ */
+ class _DockingExport DockingAnimation : public BaseObject
+ {
+ public:
+ DockingAnimation(BaseObject* creator);
+ virtual ~DockingAnimation();
+
+ virtual bool docking(PlayerInfo* player) = 0; //!< Called when a player starts docking
+ virtual bool release(PlayerInfo* player) = 0; //!< Called when player wants to undock
+
+ static bool invokeAnimation(bool dock, PlayerInfo* player, std::list<DockingAnimation*> &animations); //!< Invokes calls the docking or release method of all list entries
+ static DockingTarget *findTarget(std::string name); //!< Iterates through all DockingTarget objects to find the one with name=target
+
+ void setParent(Dock *parent) { this->parent = parent; }
+
+ protected:
+ Dock *parent;
+ std::set<PlayerInfo*> animations; //!< Contains a list of currently running animations
+ };
+
+}
+
+#endif /* _DockingAnimation_H__ */
Added: code/branches/dockingsystem2/src/modules/docking/DockingController.cc
===================================================================
--- code/branches/dockingsystem2/src/modules/docking/DockingController.cc (rev 0)
+++ code/branches/dockingsystem2/src/modules/docking/DockingController.cc 2011-05-16 16:21:05 UTC (rev 8493)
@@ -0,0 +1,64 @@
+/*
+ * 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:
+ * Sven Stucki
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "DockingController.h"
+
+#include "Dock.h"
+
+
+namespace orxonox
+{
+ CreateFactory(DockingController);
+
+ DockingController::DockingController(BaseObject* creator) : ArtificialController(creator)
+ {
+ RegisterObject(DockingController);
+ }
+
+ DockingController::~DockingController()
+ {
+
+ }
+
+ void DockingController::tick(float dt)
+ {
+ this->moveToTargetPosition();
+
+ SUPER(DockingController, tick, dt);
+ }
+
+ void DockingController::positionReached()
+ {
+ // TODO; Give control back to player
+
+ if (docking)
+ dock->dockingAnimationFinished(player);
+ else
+ dock->undockingAnimationFinished(player);
+ }
+}
Added: code/branches/dockingsystem2/src/modules/docking/DockingController.h
===================================================================
--- code/branches/dockingsystem2/src/modules/docking/DockingController.h (rev 0)
+++ code/branches/dockingsystem2/src/modules/docking/DockingController.h 2011-05-16 16:21:05 UTC (rev 8493)
@@ -0,0 +1,64 @@
+/*
+ * 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:
+ * Sven Stucki
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _DockingController_H__
+#define _DockingController_H__
+
+#include "DockingPrereqs.h"
+
+#include "infos/PlayerInfo.h"
+#include "controllers/ArtificialController.h"
+#include "tools/interfaces/Tickable.h"
+#include "DockingController.h"
+
+namespace orxonox
+{
+ class _OrxonoxExport DockingController : public ArtificialController, public Tickable
+ {
+ public:
+ DockingController(BaseObject* creator);
+ virtual ~DockingController();
+
+ virtual void tick(float dt);
+
+ void takeControl(bool docking);
+
+ void setDock(Dock* dock) { this->dock = dock; }
+ void setEntity(ControllableEntity* entity) { this->entity = entity; }
+
+ protected:
+ virtual void positionReached();
+
+ private:
+ Dock* dock;
+ bool docking;
+ ControllableEntity* entity;
+ };
+}
+
+#endif /* _DockingController_H__ */
Modified: code/branches/dockingsystem2/src/modules/docking/DockingEffect.cc
===================================================================
--- code/branches/dockingsystem2/src/modules/docking/DockingEffect.cc 2011-05-16 15:25:00 UTC (rev 8492)
+++ code/branches/dockingsystem2/src/modules/docking/DockingEffect.cc 2011-05-16 16:21:05 UTC (rev 8493)
@@ -20,7 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Author:
- * Damian 'Mozork' Frick
+ * Sven Stucki
* Co-authors:
* ...
*
@@ -45,25 +45,16 @@
}
- bool DockingEffect::invokeEffect(docking::event event, PlayerInfo* player, std::list<DockingEffect*> & effects)
+ bool DockingEffect::invokeEffect(bool dock, PlayerInfo* player, std::list<DockingEffect*> & effects)
{
bool check = true;
- COUT(4) << "Invoking DockingEffects on player: " << player << " ." << std::endl;
-
for (std::list<DockingEffect*>::iterator effect = effects.begin(); effect != effects.end(); effect++)
{
- switch(event)
- {
- case docking::DOCKING:
- check &= (*effect)->docking(player);
- break;
- case docking::RELEASE:
- check &= (*effect)->release(player);
- break;
- default:
- assert(0);
- }
+ if (dock)
+ check &= (*effect)->docking(player);
+ else
+ check &= (*effect)->release(player);
}
return check;
Modified: code/branches/dockingsystem2/src/modules/docking/DockingEffect.h
===================================================================
--- code/branches/dockingsystem2/src/modules/docking/DockingEffect.h 2011-05-16 15:25:00 UTC (rev 8492)
+++ code/branches/dockingsystem2/src/modules/docking/DockingEffect.h 2011-05-16 16:21:05 UTC (rev 8493)
@@ -48,12 +48,6 @@
namespace orxonox
{
- namespace docking {
- enum event {
- DOCKING,
- RELEASE
- };
- }
/**
@brief
@@ -73,7 +67,7 @@
virtual bool docking(PlayerInfo* player) = 0; //!< Called when player docked
virtual bool release(PlayerInfo* player) = 0; //!< Called when player wants to undock
- static bool invokeEffect(docking::event event, PlayerInfo* player, std::list<DockingEffect*> & effects); //!< Invokes the event specific method of all DockingEffects in the list
+ static bool invokeEffect(bool dock, PlayerInfo* player, std::list<DockingEffect*> & effects); //!< Invokes the event specific method of all DockingEffects in the list
static DockingTarget *findTarget(std::string name); //!< Iterates through all DockingTarget objects to find the one with name=target
};
Modified: code/branches/dockingsystem2/src/modules/docking/DockingPrereqs.h
===================================================================
--- code/branches/dockingsystem2/src/modules/docking/DockingPrereqs.h 2011-05-16 15:25:00 UTC (rev 8492)
+++ code/branches/dockingsystem2/src/modules/docking/DockingPrereqs.h 2011-05-16 16:21:05 UTC (rev 8493)
@@ -65,9 +65,11 @@
namespace orxonox
{
class Dock;
+ class DockingAnimation;
class DockingTarget;
class DockingEffect;
class DockToShip;
+ class MoveToDockingTarget;
}
#endif /* _DockingPrereqs_H__ */
Added: code/branches/dockingsystem2/src/modules/docking/MoveToDockingTarget.cc
===================================================================
--- code/branches/dockingsystem2/src/modules/docking/MoveToDockingTarget.cc (rev 0)
+++ code/branches/dockingsystem2/src/modules/docking/MoveToDockingTarget.cc 2011-05-16 16:21:05 UTC (rev 8493)
@@ -0,0 +1,66 @@
+/*
+ * 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:
+ * Sven Stucki
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file MoveToDockingTarget.h
+ @brief Definition of the MoveToDockingTarget class.
+ @ingroup Docking
+*/
+
+#include "MoveToDockingTarget.h"
+
+#include "core/XMLPort.h"
+
+namespace orxonox
+{
+ CreateFactory(MoveToDockingTarget);
+
+ MoveToDockingTarget::MoveToDockingTarget(BaseObject *creator) : DockingAnimation(creator)
+ {
+ RegisterObject(MoveToDockingTarget);
+ }
+
+ MoveToDockingTarget::~MoveToDockingTarget() {
+
+ }
+
+ bool MoveToDockingTarget::docking(PlayerInfo *player)
+ {
+ assert(parent);
+ parent->dockingAnimationFinished(player);
+ return true;
+ }
+
+ bool MoveToDockingTarget::release(PlayerInfo *player)
+ {
+ assert(parent);
+ parent->undockingAnimationFinished(player);
+ return true;
+ }
+
+}
Added: code/branches/dockingsystem2/src/modules/docking/MoveToDockingTarget.h
===================================================================
--- code/branches/dockingsystem2/src/modules/docking/MoveToDockingTarget.h (rev 0)
+++ code/branches/dockingsystem2/src/modules/docking/MoveToDockingTarget.h 2011-05-16 16:21:05 UTC (rev 8493)
@@ -0,0 +1,66 @@
+/*
+ * 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:
+ * Sven Stucki
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file MoveToDockingTarget.h
+ @brief Definition of the MoveToDockingTarget class.
+ @ingroup Docking
+*/
+
+#ifndef _MoveToDockingTarget_H__
+#define _MoveToDockingTarget_H__
+
+#include "DockingPrereqs.h"
+#include "DockingAnimation.h"
+#include "Dock.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ Base class for docking animations used by @ref orxonox::Docking "Docks".
+
+ @author
+ Sven Stucki
+
+ @ingroup Docking
+ */
+ class _DockingExport MoveToDockingTarget : public DockingAnimation
+ {
+ public:
+ MoveToDockingTarget(BaseObject* creator);
+ virtual ~MoveToDockingTarget();
+
+ virtual bool docking(PlayerInfo* player); //!< Called when a player starts docking
+ virtual bool release(PlayerInfo* player); //!< Called when player wants to undock
+ };
+
+}
+
+#endif /* _MoveToDockingTarget_H__ */
Modified: code/branches/dockingsystem2/src/orxonox/controllers/ArtificialController.cc
===================================================================
--- code/branches/dockingsystem2/src/orxonox/controllers/ArtificialController.cc 2011-05-16 15:25:00 UTC (rev 8492)
+++ code/branches/dockingsystem2/src/orxonox/controllers/ArtificialController.cc 2011-05-16 16:21:05 UTC (rev 8493)
@@ -380,6 +380,11 @@
this->getControllableEntity()->moveFrontBack(1.2f*SPEED_MASTER + distance/300.0f);
}
}
+
+ if (distance < 10)
+ {
+ this->positionReached();
+ }
}
void ArtificialController::moveToTargetPosition()
@@ -387,7 +392,12 @@
this->moveToPosition(this->targetPosition_);
}
+ void ArtificialController::positionReached()
+ {
+ // Override me !
+ }
+
/**
@brief Unregisters a slave from its master. Initiated by a slave.
*/
Modified: code/branches/dockingsystem2/src/orxonox/controllers/ArtificialController.h
===================================================================
--- code/branches/dockingsystem2/src/orxonox/controllers/ArtificialController.h 2011-05-16 15:25:00 UTC (rev 8492)
+++ code/branches/dockingsystem2/src/orxonox/controllers/ArtificialController.h 2011-05-16 16:21:05 UTC (rev 8493)
@@ -96,6 +96,8 @@
void moveToPosition(const Vector3& target);
void moveToTargetPosition();
+ virtual void positionReached();
+
void removeFromFormation();
void unregisterSlave();
void searchNewMaster();
More information about the Orxonox-commit
mailing list