[Orxonox-commit 3499] r8185 - in code/branches/dockingsystem: data/levels src/modules/docking src/orxonox/infos
sven at orxonox.net
sven at orxonox.net
Mon Apr 4 15:12:49 CEST 2011
Author: sven
Date: 2011-04-04 15:12:49 +0200 (Mon, 04 Apr 2011)
New Revision: 8185
Modified:
code/branches/dockingsystem/data/levels/docking.oxw
code/branches/dockingsystem/src/modules/docking/Dock.cc
code/branches/dockingsystem/src/modules/docking/Dock.h
code/branches/dockingsystem/src/modules/docking/DockToShip.cc
code/branches/dockingsystem/src/modules/docking/DockToShip.h
code/branches/dockingsystem/src/modules/docking/DockingEffect.cc
code/branches/dockingsystem/src/modules/docking/DockingEffect.h
code/branches/dockingsystem/src/modules/docking/DockingPrereqs.h
code/branches/dockingsystem/src/orxonox/infos/PlayerInfo.cc
Log:
DockToShip and some fixes
Modified: code/branches/dockingsystem/data/levels/docking.oxw
===================================================================
--- code/branches/dockingsystem/data/levels/docking.oxw 2011-04-04 12:53:53 UTC (rev 8184)
+++ code/branches/dockingsystem/data/levels/docking.oxw 2011-04-04 13:12:49 UTC (rev 8185)
@@ -31,8 +31,23 @@
<?lua end ?>
- <!-- stolen from underAttack.oxw -->
+ <Dock>
+ <effects>
+ <DockToShip />
+ </effects>
+ <events>
+ <execute>
+ <EventListener event="dockMe" />
+ </execute>
+ </events>
+ <attached>
+ <DistanceTrigger position="0,0,0" distance="20" target="ControllableEntity" name="dockMe" />
+ <Billboard material="Examples/Flare" colour="1.0, 0, 0" />
+ </attached>
+ </Dock>
+
+ <!--
<Destroyer
position = "100,150,0"
collisionType = dynamic
@@ -45,21 +60,6 @@
>
<attached>
-
- <Dock>
- <effects>
- <DockToShip />
- </effects>
- <events>
- <execute>
- <EventListener event="dockMe" />
- </execute>
- </events>
- <attached>
- <DistanceTrigger position="0,0,0" distance=2 target="ControllableEntity" name="dockMe" />
- </attached>
- </Dock>
-
<TeamSpawnPoint team=1 position="150,0,7" direction="-1,0,0" roll=90 yaw=0 spawnclass=SpaceShip pawndesign=spaceshipassff />
<TeamSpawnPoint team=1 position="0,0,7" lookat="-1,0,0" roll="90" yaw=0 spawnclass=SpaceShip pawndesign=spaceshipassff />
<TeamSpawnPoint team=1 position="-50,0,7" lookat="-1,0,0" roll="90" yaw=0 spawnclass=SpaceShip pawndesign=spaceshipassff />
@@ -146,7 +146,7 @@
<BoxCollisionShape position="167,0,70" halfExtents="17, 20, 20" />
</collisionShapes>
</Destroyer>
+ //-->
-
</Scene>
</Level>
Modified: code/branches/dockingsystem/src/modules/docking/Dock.cc
===================================================================
--- code/branches/dockingsystem/src/modules/docking/Dock.cc 2011-04-04 12:53:53 UTC (rev 8184)
+++ code/branches/dockingsystem/src/modules/docking/Dock.cc 2011-04-04 13:12:49 UTC (rev 8185)
@@ -36,13 +36,12 @@
namespace orxonox
{
+ CreateFactory(Dock);
- CreateFactory(Dock);
-
Dock::Dock(BaseObject* creator) : StaticEntity(creator)
{
RegisterObject(Dock);
- COUT(0) << "Registering dock..." << std::endl;
+ COUT(0) << "Registering dock..." << std::endl;
}
Dock::~Dock()
@@ -69,20 +68,32 @@
bool Dock::execute(bool bTriggered, BaseObject* trigger)
- {
- COUT(0) << "Dock executed (bTriggered = " << (bTriggered? "true":"false") << ").." << std::endl;
- return true;
- }
+ {
+ COUT(0) << "Dock executed (bTriggered = " << (bTriggered? "true":"false") << ").." << std::endl;
+ //TODO: Handle MultiDistanceTrigger
- bool Dock::addEffect(DockingEffect* effect) {
- assert(effect);
- effects_.push_back(effect);
- return true;
- }
-
- const DockingEffect* Dock::getEffect(unsigned int index) const {
- int i = index;
+ //TODO: This way too oversimplified
+ if(bTriggered) {
+ DockingEffect::invokeEffect(docking::DOCKING, NULL, effects_);
+ DockingEffect::invokeEffect(docking::ATTACH, NULL, effects_);
+ } else {
+ DockingEffect::invokeEffect(docking::RELEASE, NULL, effects_);
+ }
+
+
+ return true;
+ }
+
+
+ bool Dock::addEffect(DockingEffect* effect) {
+ assert(effect);
+ effects_.push_back(effect);
+ return true;
+ }
+
+ const DockingEffect* Dock::getEffect(unsigned int index) const {
+ int i = index;
for (std::list<DockingEffect*>::const_iterator effect = this->effects_.begin(); effect != this->effects_.end(); ++effect)
{
if(i == 0)
@@ -91,6 +102,5 @@
i--;
}
return NULL;
- }
-
+ }
}
Modified: code/branches/dockingsystem/src/modules/docking/Dock.h
===================================================================
--- code/branches/dockingsystem/src/modules/docking/Dock.h 2011-04-04 12:53:53 UTC (rev 8184)
+++ code/branches/dockingsystem/src/modules/docking/Dock.h 2011-04-04 13:12:49 UTC (rev 8185)
@@ -46,9 +46,9 @@
namespace orxonox {
- class _DockingExport Dock : public StaticEntity {
- public:
- Dock(BaseObject* creator);
+ class _DockingExport Dock : public StaticEntity {
+ public:
+ Dock(BaseObject* creator);
virtual ~Dock();
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
@@ -56,14 +56,14 @@
bool execute(bool bTriggered, BaseObject* trigger);
- private:
- std::list<DockingEffect*> effects_; //!< The list of DockingEffects to be executed when a player docks.
-
bool addEffect(DockingEffect* effect); //!< Add a DockingEffect to the Dock.
const DockingEffect* getEffect(unsigned int index) const; //!< Get the DockingEffect at a given index.
- };
+ private:
+ std::list<DockingEffect*> effects_; //!< The list of DockingEffects to be executed when a player docks.
+ };
+
}
#endif /* _Dock_H__ */
Modified: code/branches/dockingsystem/src/modules/docking/DockToShip.cc
===================================================================
--- code/branches/dockingsystem/src/modules/docking/DockToShip.cc 2011-04-04 12:53:53 UTC (rev 8184)
+++ code/branches/dockingsystem/src/modules/docking/DockToShip.cc 2011-04-04 13:12:49 UTC (rev 8185)
@@ -0,0 +1,70 @@
+/*
+ * 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:
+ * Damian 'Mozork' Frick
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file DockToShip.cc
+ @brief Implementation of the DockToShip class.
+*/
+
+#include "DockingEffect.h"
+#include "DockToShip.h"
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+ CreateFactory(DockToShip);
+
+ DockToShip::DockToShip(BaseObject* creator) : DockingEffect(creator)
+ {
+ RegisterObject(DockToShip);
+ COUT(0) << "DockToShip instance created.." << endl;
+ }
+
+ DockToShip::~DockToShip()
+ {
+
+ }
+
+ bool DockToShip::docking(PlayerInfo* player)
+ {
+ COUT(0) << "DockToShip::docking" << endl;
+ return true;
+ }
+
+ bool DockToShip::attach(PlayerInfo* player)
+ {
+ COUT(0) << "DockToShip::attach" << endl;
+ return true;
+ }
+
+ bool DockToShip::release(PlayerInfo* player)
+ {
+ COUT(0) << "DockToShip::release" << endl;
+ return true;
+ }
+}
Modified: code/branches/dockingsystem/src/modules/docking/DockToShip.h
===================================================================
--- code/branches/dockingsystem/src/modules/docking/DockToShip.h 2011-04-04 12:53:53 UTC (rev 8184)
+++ code/branches/dockingsystem/src/modules/docking/DockToShip.h 2011-04-04 13:12:49 UTC (rev 8185)
@@ -0,0 +1,67 @@
+/*
+ * 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 DockToShip.h
+ @brief DockingEffect which transfers control from spaceship to docked ship ASDF
+ @ingroup Docking
+*/
+
+#ifndef _DockToShip_H__
+#define _DockToShip_H__
+
+#include "DockingPrereqs.h"
+#include "DockToShip.h"
+
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ Allows players to dock onto a ship
+
+ @author
+ Sven Stucki
+
+ @ingroup Docking
+ */
+ class _DockingExport DockToShip : public DockingEffect
+ {
+ public:
+ DockToShip(BaseObject* creator);
+ virtual ~DockToShip();
+
+ 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
+ };
+
+}
+
+#endif /* _DockToShip_H__ */
Modified: code/branches/dockingsystem/src/modules/docking/DockingEffect.cc
===================================================================
--- code/branches/dockingsystem/src/modules/docking/DockingEffect.cc 2011-04-04 12:53:53 UTC (rev 8184)
+++ code/branches/dockingsystem/src/modules/docking/DockingEffect.cc 2011-04-04 13:12:49 UTC (rev 8185)
@@ -46,14 +46,27 @@
}
- bool DockingEffect::invokeEffects(PlayerInfo* player, std::list<DockingEffect*> & effects)
+ bool DockingEffect::invokeEffect(docking::event event, 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++)
- check = check ;// && (*effect)->invoke(player); TODO
+ for (std::list<DockingEffect*>::iterator effect = effects.begin(); effect != effects.end(); effect++) {
+ switch(event) {
+ case docking::DOCKING:
+ check &= (*effect)->docking(player);
+ break;
+ case docking::ATTACH:
+ check &= (*effect)->attach(player);
+ break;
+ case docking::RELEASE:
+ check &= (*effect)->release(player);
+ break;
+ default:
+ assert(0);
+ }
+ }
return check;
}
Modified: code/branches/dockingsystem/src/modules/docking/DockingEffect.h
===================================================================
--- code/branches/dockingsystem/src/modules/docking/DockingEffect.h 2011-04-04 12:53:53 UTC (rev 8184)
+++ code/branches/dockingsystem/src/modules/docking/DockingEffect.h 2011-04-04 13:12:49 UTC (rev 8185)
@@ -42,6 +42,13 @@
namespace orxonox
{
+ namespace docking {
+ enum event {
+ DOCKING,
+ ATTACH,
+ RELEASE
+ };
+ }
/**
@brief
@@ -59,10 +66,10 @@
virtual ~DockingEffect();
virtual bool docking(PlayerInfo* player) = 0; //!< Called when docking starts
- virtual bool attach(PlayerInfo* player) = 0; //!< Called after docking animation
- virtual bool release(PlayerInfo* player) = 0; //!< Called when player wants undock
+ virtual bool attach(PlayerInfo* player) = 0; //!< Called after docking animation
+ virtual bool release(PlayerInfo* player) = 0; //!< Called when player wants undock
- static bool invokeEffects(PlayerInfo* player, std::list<DockingEffect*> & effects); //!< Invokes all DockingEffects in the list.
+ static bool invokeEffect(docking::event event, PlayerInfo* player, std::list<DockingEffect*> & effects); //!< Invokes the event specific method of all DockingEffects in the list
};
}
Modified: code/branches/dockingsystem/src/modules/docking/DockingPrereqs.h
===================================================================
--- code/branches/dockingsystem/src/modules/docking/DockingPrereqs.h 2011-04-04 12:53:53 UTC (rev 8184)
+++ code/branches/dockingsystem/src/modules/docking/DockingPrereqs.h 2011-04-04 13:12:49 UTC (rev 8185)
@@ -65,7 +65,8 @@
namespace orxonox
{
class Dock;
- class DockingEffect;
+ class DockingEffect;
+ class DockToShip;
}
#endif /* _DockingPrereqs_H__ */
Modified: code/branches/dockingsystem/src/orxonox/infos/PlayerInfo.cc
===================================================================
--- code/branches/dockingsystem/src/orxonox/infos/PlayerInfo.cc 2011-04-04 12:53:53 UTC (rev 8184)
+++ code/branches/dockingsystem/src/orxonox/infos/PlayerInfo.cc 2011-04-04 13:12:49 UTC (rev 8185)
@@ -223,7 +223,7 @@
return;
this->controllableEntity_->setController(0);
-
+
this->controllableEntity_ = this->oldControllableEntity_;
this->controllableEntityID_ = this->controllableEntity_->getObjectID();
this->oldControllableEntity_ = 0;
More information about the Orxonox-commit
mailing list