[Orxonox-commit 3571] r8257 - in code/branches/dockingsystem2: data/levels src/modules/docking
sven at orxonox.net
sven at orxonox.net
Mon Apr 18 16:35:01 CEST 2011
Author: sven
Date: 2011-04-18 16:35:01 +0200 (Mon, 18 Apr 2011)
New Revision: 8257
Added:
code/branches/dockingsystem2/src/modules/docking/DockingTarget.cc
code/branches/dockingsystem2/src/modules/docking/DockingTarget.h
Modified:
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/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
Log:
First working dock example..
Modified: code/branches/dockingsystem2/data/levels/docking.oxw
===================================================================
--- code/branches/dockingsystem2/data/levels/docking.oxw 2011-04-18 14:18:31 UTC (rev 8256)
+++ code/branches/dockingsystem2/data/levels/docking.oxw 2011-04-18 14:35:01 UTC (rev 8257)
@@ -29,22 +29,10 @@
<?lua for i = 1, 10, 1 do ?>
<SpawnPoint position="<?lua print(math.random() * 500 - 250) ?>,<?lua print(math.random() * 500 - 250) ?>,<?lua print(math.random() * 500 - 250) ?>" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
<?lua end ?>
-
- <Destroyer
- position = "100,150,0"
- collisionType = dynamic
- mass = 100000
- velocity = "0,0,0"
- angularDamping = 0.9999999
- health = 10000
- maxhealth = 10000
- initialhealth = 10000
- >
- <attached>
- <Dock>
+ <Dock position="-50,-100,50">
<effects>
- <DockToShip />
+ <DockToShip target="asdf" />
</effects>
<events>
<execute>
@@ -56,8 +44,69 @@
<Billboard material="Examples/Flare" colour="1.0, 0, 0" />
</attached>
</Dock>
+
+
+ <SpaceShip
+ hudtemplate = spaceshiphud
+ camerapositiontemplate = spaceshipassffcameras
+ engine = spaceshipassffengine
+ spawnparticlesource = "Orxonox/fairytwirl"
+ spawnparticleduration = 3
+ explosionchunks = 6
+
+ health = 100
+ maxhealth = 200
+ initialhealth = 100
+
+ primaryThrust = 100;
+ auxilaryThrust = 30;
+ rotationThrust = 25;
+
+ collisionType = "dynamic"
+ mass = 100
+ linearDamping = 0.7
+ angularDamping = 0.9999999
+ >
+ <attached>
<DistanceTriggerBeacon name="beacon1" />
-
+ <DockingTarget name="asdf" />
+
+ <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 />
+ <BlinkingBillboard position="-17,-1.5,0" material="Examples/Flare" colour="0.5, 1.0, 0.3" amplitude=0.1 frequency=0.5 phase=180 quadratic=1 />
+ <DistanceTriggerBeacon name="PlayerDistanceTrigger" /> <!--added DistanceTrigger-->
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="0,0,0" halfExtents="10, 3, 5" />
+ <BoxCollisionShape position="13,-1.3,0" halfExtents="3, 1, 2" />
+ <BoxCollisionShape position="-13,-1.3,0" halfExtents="3, 1, 2" />
+ <BoxCollisionShape position="0,0,7" halfExtents="3, 2, 2" />
+ <BoxCollisionShape position="0,0.1,-11" halfExtents="2.2, 1.8, 6" />
+ <BoxCollisionShape position="0,0.1,-19" halfExtents="1.4, 1, 2" />
+ </collisionShapes>
+<?lua
+ include("includes/weaponSettingsAssff.oxi")
+?>
+ </SpaceShip>
+
+
+ <!-- <Destroyer
+ position = "100,150,0"
+ collisionType = dynamic
+ mass = 100000
+ velocity = "0,0,0"
+ angularDamping = 0.9999999
+ health = 10000
+ maxhealth = 10000
+ initialhealth = 10000
+ >
+
+ <attached>
+
+ <DistanceTriggerBeacon name="beacon1" />
+ <DockingTarget name="asdf" />
+
+
<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 />
@@ -144,7 +193,7 @@
<BoxCollisionShape position="167,0,70" halfExtents="17, 20, 20" />
</collisionShapes>
</Destroyer>
-
+ //-->
</Scene>
</Level>
Modified: code/branches/dockingsystem2/src/modules/docking/CMakeLists.txt
===================================================================
--- code/branches/dockingsystem2/src/modules/docking/CMakeLists.txt 2011-04-18 14:18:31 UTC (rev 8256)
+++ code/branches/dockingsystem2/src/modules/docking/CMakeLists.txt 2011-04-18 14:35:01 UTC (rev 8257)
@@ -1,4 +1,5 @@
SET_SOURCE_FILES(DOCKING_SRC_FILES
+ DockingTarget.cc
DockingEffect.cc
DockToShip.cc
Dock.cc
Modified: code/branches/dockingsystem2/src/modules/docking/Dock.cc
===================================================================
--- code/branches/dockingsystem2/src/modules/docking/Dock.cc 2011-04-18 14:18:31 UTC (rev 8256)
+++ code/branches/dockingsystem2/src/modules/docking/Dock.cc 2011-04-18 14:35:01 UTC (rev 8257)
@@ -72,8 +72,6 @@
bool Dock::execute(bool bTriggered, BaseObject* trigger)
{
- //TODO: Handle DistanceMultiTrigger
-
PlayerTrigger* pTrigger = orxonox_cast<PlayerTrigger*>(trigger);
Pawn* pawn = NULL;
@@ -103,21 +101,11 @@
return false;
}
- // Try to get HumanPlayer
- if(!player->isHumanPlayer()) {
- COUT(0) << "Docking::execute Not triggered by a human." << std::endl;
- return false;
- }
- HumanPlayer* human = orxonox_cast<HumanPlayer*>(player);
- if(human == NULL) {
- COUT(0) << "Docking::execute Player was not as human as expected.." << std::endl;
- }
- COUT(0) << "Dock triggered by player: " << human->getName() << ".." << std::endl;
+ COUT(0) << "Dock triggered by player: " << player->getName() << ".." << std::endl;
- //TODO: This is waaay too oversimplified
if(bTriggered) {
DockingEffect::invokeEffect(docking::DOCKING, player, effects_);
- //DockingEffect::invokeEffect(docking::ATTACH, player, effects_);
+ DockingEffect::invokeEffect(docking::ATTACH, player, effects_);
} else {
DockingEffect::invokeEffect(docking::RELEASE, player, effects_);
}
Modified: code/branches/dockingsystem2/src/modules/docking/DockToShip.cc
===================================================================
--- code/branches/dockingsystem2/src/modules/docking/DockToShip.cc 2011-04-18 14:18:31 UTC (rev 8256)
+++ code/branches/dockingsystem2/src/modules/docking/DockToShip.cc 2011-04-18 14:35:01 UTC (rev 8257)
@@ -50,6 +50,22 @@
}
+
+ void DockToShip::XMLPort(Element& xmlelement, XMLPort::Mode mode) {
+ SUPER(DockToShip, XMLPort, xmlelement, mode);
+
+ XMLPortParam(DockToShip, "target", setTargetId, getTargetId, xmlelement, mode);
+ }
+
+ void DockToShip::setTargetId(std::string str) {
+ this->target = str;
+ }
+
+ std::string DockToShip::getTargetId() {
+ return this->target;
+ }
+
+
bool DockToShip::docking(PlayerInfo* player)
{
COUT(0) << "DockToShip::docking" << endl;
@@ -59,6 +75,21 @@
bool DockToShip::attach(PlayerInfo* player)
{
COUT(0) << "DockToShip::attach" << endl;
+
+ DockingTarget *target = DockingEffect::findTarget(this->target);
+ if (target == NULL) {
+ COUT(0) << "Can't retrieve target for '" << this->target << "'.." << std::endl;
+ return false;
+ }
+
+ ControllableEntity *dockTo = (ControllableEntity*) target->getParent();
+ if (dockTo == NULL) {
+ COUT(0) << "Parent is not a ControllableEntity.." << std::endl;
+ return false;
+ }
+
+ player->startTemporaryControl(dockTo);
+
return true;
}
Modified: code/branches/dockingsystem2/src/modules/docking/DockToShip.h
===================================================================
--- code/branches/dockingsystem2/src/modules/docking/DockToShip.h 2011-04-18 14:18:31 UTC (rev 8256)
+++ code/branches/dockingsystem2/src/modules/docking/DockToShip.h 2011-04-18 14:35:01 UTC (rev 8257)
@@ -38,7 +38,9 @@
#include "DockingPrereqs.h"
#include "DockToShip.h"
+#include "worldentities/ControllableEntity.h"
+
namespace orxonox
{
@@ -57,9 +59,16 @@
DockToShip(BaseObject* creator);
virtual ~DockToShip();
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+ virtual void setTargetId(std::string str);
+ virtual 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;
};
}
Modified: code/branches/dockingsystem2/src/modules/docking/DockingEffect.cc
===================================================================
--- code/branches/dockingsystem2/src/modules/docking/DockingEffect.cc 2011-04-18 14:18:31 UTC (rev 8256)
+++ code/branches/dockingsystem2/src/modules/docking/DockingEffect.cc 2011-04-18 14:35:01 UTC (rev 8257)
@@ -32,7 +32,6 @@
*/
#include "DockingEffect.h"
-#include "core/CoreIncludes.h"
namespace orxonox
{
@@ -70,4 +69,14 @@
return check;
}
+
+ DockingTarget *DockingEffect::findTarget(std::string name) {
+ for (ObjectList<DockingTarget>::iterator it = ObjectList<DockingTarget>::begin();
+ it != ObjectList<DockingTarget>::end(); ++it)
+ {
+ if ((*it)->getName().compare(name) == 0)
+ return (*it);
+ }
+ return NULL;
+ }
}
Modified: code/branches/dockingsystem2/src/modules/docking/DockingEffect.h
===================================================================
--- code/branches/dockingsystem2/src/modules/docking/DockingEffect.h 2011-04-18 14:18:31 UTC (rev 8256)
+++ code/branches/dockingsystem2/src/modules/docking/DockingEffect.h 2011-04-18 14:35:01 UTC (rev 8257)
@@ -35,7 +35,13 @@
#ifndef _DockingEffect_H__
#define _DockingEffect_H__
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+
+#include "infos/PlayerInfo.h"
+
#include "DockingPrereqs.h"
+#include "DockingTarget.h"
#include <list>
#include "core/BaseObject.h"
@@ -67,9 +73,10 @@
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 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 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-04-18 14:18:31 UTC (rev 8256)
+++ code/branches/dockingsystem2/src/modules/docking/DockingPrereqs.h 2011-04-18 14:35:01 UTC (rev 8257)
@@ -65,6 +65,7 @@
namespace orxonox
{
class Dock;
+ class DockingTarget;
class DockingEffect;
class DockToShip;
}
Added: code/branches/dockingsystem2/src/modules/docking/DockingTarget.cc
===================================================================
--- code/branches/dockingsystem2/src/modules/docking/DockingTarget.cc (rev 0)
+++ code/branches/dockingsystem2/src/modules/docking/DockingTarget.cc 2011-04-18 14:35:01 UTC (rev 8257)
@@ -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 DockingTarget.cc
+ @brief Docking system main class
+*/
+
+#include "DockingTarget.h"
+#include "core/XMLPort.h"
+
+
+namespace orxonox
+{
+ CreateFactory(DockingTarget);
+
+ DockingTarget::DockingTarget(BaseObject* creator) : StaticEntity(creator)
+ {
+ RegisterObject(DockingTarget);
+ }
+
+ DockingTarget::~DockingTarget()
+ {
+ }
+
+
+ void DockingTarget::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(DockingTarget, XMLPort, xmlelement, mode);
+ XMLPortParam(DockingTarget, "name", setName, getName, xmlelement, mode);
+
+ COUT(0) << "DockingTarget with name '" << this->getName() << "' created.." << std::endl;
+ }
+
+
+ void DockingTarget::setName(std::string str) {
+ this->name = str;
+ }
+
+ std::string DockingTarget::getName() {
+ return this->name;
+ }
+}
Added: code/branches/dockingsystem2/src/modules/docking/DockingTarget.h
===================================================================
--- code/branches/dockingsystem2/src/modules/docking/DockingTarget.h (rev 0)
+++ code/branches/dockingsystem2/src/modules/docking/DockingTarget.h 2011-04-18 14:35:01 UTC (rev 8257)
@@ -0,0 +1,71 @@
+/*
+ * 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 DockingTarget.h
+ @brief Definition of the DockingTarget class.
+ @ingroup Docking
+*/
+
+#ifndef _DockingTarget_H__
+#define _DockingTarget_H__
+
+#include "DockingPrereqs.h"
+
+#include "core/BaseObject.h"
+#include "worldentities/StaticEntity.h"
+
+namespace orxonox
+{
+ /**
+ @brief
+ DockingTargets for @ref orxonox::Docking "Docks".
+
+ @author
+ Sven Stucki
+
+ @ingroup Docking
+ */
+ class _DockingExport DockingTarget : public StaticEntity
+ {
+ private:
+ std::string name;
+
+ public:
+ DockingTarget(BaseObject* creator);
+ virtual ~DockingTarget();
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+ virtual void setName(std::string str);
+ virtual std::string getName();
+ };
+
+}
+
+#endif /* _DockingTarget_H__ */
More information about the Orxonox-commit
mailing list