[Orxonox-commit 3465] r8151 - in code/branches/dockingsystem: data/levels src/modules/docking
sven at orxonox.net
sven at orxonox.net
Mon Mar 28 16:39:32 CEST 2011
Author: sven
Date: 2011-03-28 16:39:32 +0200 (Mon, 28 Mar 2011)
New Revision: 8151
Added:
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
Modified:
code/branches/dockingsystem/data/levels/docking.oxw
code/branches/dockingsystem/src/modules/docking/CMakeLists.txt
code/branches/dockingsystem/src/modules/docking/Dock.cc
code/branches/dockingsystem/src/modules/docking/Dock.h
code/branches/dockingsystem/src/modules/docking/DockingPrereqs.h
Log:
XML support for different DockingEffects added, DockingEffect base class created
Modified: code/branches/dockingsystem/data/levels/docking.oxw
===================================================================
--- code/branches/dockingsystem/data/levels/docking.oxw 2011-03-28 14:27:06 UTC (rev 8150)
+++ code/branches/dockingsystem/data/levels/docking.oxw 2011-03-28 14:39:32 UTC (rev 8151)
@@ -1,6 +1,6 @@
<LevelInfo
name = "Transporter"
- description = "Level with moving Transporter."
+ description = "Level with a Transporter. Demostrates the docking system."
tags = ""
/>
@@ -13,7 +13,7 @@
<Level
name = "Transporter"
- description = "Level with Transporter :)"
+ description = "Docking example level"
>
<templates>
<Template link=lodtemplate_default />
@@ -47,13 +47,16 @@
<attached>
<Dock>
+ <effects>
+ <DockToShip />
+ </effects>
<events>
<execute>
<EventListener event="dockMe" />
</execute>
</events>
<attached>
- <PlayerTrigger name="dockMe" /> //A PlayerTrigger triggering the execution of the QuestEffectBeacon.
+ <DistanceTrigger position="0,0,0" distance=2 target="ControllableEntity" name="dockMe" />
</attached>
</Dock>
Modified: code/branches/dockingsystem/src/modules/docking/CMakeLists.txt
===================================================================
--- code/branches/dockingsystem/src/modules/docking/CMakeLists.txt 2011-03-28 14:27:06 UTC (rev 8150)
+++ code/branches/dockingsystem/src/modules/docking/CMakeLists.txt 2011-03-28 14:39:32 UTC (rev 8151)
@@ -1,4 +1,6 @@
SET_SOURCE_FILES(DOCKING_SRC_FILES
+ DockingEffect.cc
+ DockToShip.cc
Dock.cc
)
Modified: code/branches/dockingsystem/src/modules/docking/Dock.cc
===================================================================
--- code/branches/dockingsystem/src/modules/docking/Dock.cc 2011-03-28 14:27:06 UTC (rev 8150)
+++ code/branches/dockingsystem/src/modules/docking/Dock.cc 2011-03-28 14:39:32 UTC (rev 8151)
@@ -37,7 +37,6 @@
namespace orxonox
{
-
CreateFactory(Dock);
Dock::Dock(BaseObject* creator) : StaticEntity(creator)
@@ -55,7 +54,7 @@
{
SUPER(Dock, XMLPort, xmlelement, mode);
- // TODO: Something similar to XMLPortObject(Dock, QuestEffect, "effects", addEffect, getEffect, xmlelement, mode);
+ XMLPortObject(Dock, DockingEffect, "effects", addEffect, getEffect, xmlelement, mode);
XMLPortEventSink(Dock, BaseObject, "execute", execute, xmlelement, mode);
COUT(0) << "Dock created.." << std::endl;
@@ -76,4 +75,22 @@
}
+ 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)
+ return *effect;
+
+ i--;
+ }
+ return NULL;
+ }
+
}
Modified: code/branches/dockingsystem/src/modules/docking/Dock.h
===================================================================
--- code/branches/dockingsystem/src/modules/docking/Dock.h 2011-03-28 14:27:06 UTC (rev 8150)
+++ code/branches/dockingsystem/src/modules/docking/Dock.h 2011-03-28 14:39:32 UTC (rev 8151)
@@ -40,6 +40,7 @@
#include "core/EventIncludes.h"
#include "worldentities/StaticEntity.h"
+#include "DockingEffect.h"
#include "DockingPrereqs.h"
namespace orxonox {
@@ -54,6 +55,12 @@
virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
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.
};
Added: code/branches/dockingsystem/src/modules/docking/DockToShip.cc
===================================================================
Added: code/branches/dockingsystem/src/modules/docking/DockToShip.h
===================================================================
Added: code/branches/dockingsystem/src/modules/docking/DockingEffect.cc
===================================================================
--- code/branches/dockingsystem/src/modules/docking/DockingEffect.cc (rev 0)
+++ code/branches/dockingsystem/src/modules/docking/DockingEffect.cc 2011-03-28 14:39:32 UTC (rev 8151)
@@ -0,0 +1,60 @@
+/*
+ * 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 DockingEffect.cc
+ @brief Implementation of the DockingEffect class.
+*/
+
+#include "DockingEffect.h"
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+ DockingEffect::DockingEffect(BaseObject* creator) : BaseObject(creator)
+ {
+ RegisterObject(DockingEffect);
+ }
+
+ DockingEffect::~DockingEffect()
+ {
+
+ }
+
+ bool DockingEffect::invokeEffects(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);
+
+ return check;
+ }
+}
Added: code/branches/dockingsystem/src/modules/docking/DockingEffect.h
===================================================================
--- code/branches/dockingsystem/src/modules/docking/DockingEffect.h (rev 0)
+++ code/branches/dockingsystem/src/modules/docking/DockingEffect.h 2011-03-28 14:39:32 UTC (rev 8151)
@@ -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:
+ * Sven Stucki
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file DockingEffect.h
+ @brief Definition of the DockingEffect class.
+ @ingroup Docking
+*/
+
+#ifndef _DockingEffect_H__
+#define _DockingEffect_H__
+
+#include "DockingPrereqs.h"
+
+#include <list>
+#include "core/BaseObject.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ Handles DockingEffects for @ref orxonox::Docking "Docks".
+
+ @author
+ Sven Stucki
+
+ @ingroup Docking
+ */
+ class _DockingExport DockingEffect : public BaseObject
+ {
+ public:
+ DockingEffect(BaseObject* creator);
+ 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
+
+ static bool invokeEffects(PlayerInfo* player, std::list<DockingEffect*> & effects); //!< Invokes all DockingEffects in the list.
+ };
+
+}
+
+#endif /* _DockingEffect_H__ */
Modified: code/branches/dockingsystem/src/modules/docking/DockingPrereqs.h
===================================================================
--- code/branches/dockingsystem/src/modules/docking/DockingPrereqs.h 2011-03-28 14:27:06 UTC (rev 8150)
+++ code/branches/dockingsystem/src/modules/docking/DockingPrereqs.h 2011-03-28 14:39:32 UTC (rev 8151)
@@ -65,6 +65,7 @@
namespace orxonox
{
class Dock;
+ class DockingEffect;
}
#endif /* _DockingPrereqs_H__ */
More information about the Orxonox-commit
mailing list