[Orxonox-commit 3702] r8382 - in code/branches/dockingsystem2: data/levels src/modules/docking src/orxonox/infos
sven at orxonox.net
sven at orxonox.net
Mon May 2 16:16:27 CEST 2011
Author: sven
Date: 2011-05-02 16:16:27 +0200 (Mon, 02 May 2011)
New Revision: 8382
Modified:
code/branches/dockingsystem2/data/levels/docking.oxw
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/orxonox/infos/PlayerInfo.cc
Log:
Added dock/undock console commands.
Modified: code/branches/dockingsystem2/data/levels/docking.oxw
===================================================================
--- code/branches/dockingsystem2/data/levels/docking.oxw 2011-05-02 13:58:10 UTC (rev 8381)
+++ code/branches/dockingsystem2/data/levels/docking.oxw 2011-05-02 14:16:27 UTC (rev 8382)
@@ -16,7 +16,7 @@
description = "Docking example level"
>
<templates>
- <Template link=lodtemplate_default />
+ <Template link="lodtemplate_default" />
</templates>
<Scene
@@ -24,15 +24,15 @@
skybox = "Orxonox/skypanoramagen1"
>
- <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0" />
+ <Light type="directional" position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0" />
<?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 />
+ <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 ?>
<Dock position="-50,-100,50">
<effects>
- <DockToShip target="asdf" />
+ <DockToShip target="theDestroyer" />
</effects>
<events>
<execute>
@@ -40,41 +40,43 @@
</execute>
</events>
<attached>
- <DistanceTrigger position="0,0,0" distance="20" target="Pawn" beaconMode="exclude" targetname="beacon1" name="dockMe" />
+ <DistanceTrigger position="0,0,0" distance="20" target="Pawn" beaconMode="exclude" targetname="destroyerBeacon" name="dockMe" />
<Billboard material="Examples/Flare" colour="1.0, 0, 0" />
</attached>
</Dock>
+
+
<SpaceShip
- hudtemplate = spaceshiphud
- camerapositiontemplate = spaceshipassffcameras
- engine = spaceshipassffengine
+ hudtemplate = "spaceshiphud"
+ camerapositiontemplate = "spaceshipassffcameras"
+ engine = "spaceshipassffengine"
spawnparticlesource = "Orxonox/fairytwirl"
- spawnparticleduration = 3
- explosionchunks = 6
+ spawnparticleduration = "3"
+ explosionchunks = "6"
- health = 100
- maxhealth = 200
- initialhealth = 100
+ health = "100"
+ maxhealth = "200"
+ initialhealth = "100"
- primaryThrust = 100;
- auxilaryThrust = 30;
- rotationThrust = 25;
+ primaryThrust = "100;"
+ auxilaryThrust = "30;"
+ rotationThrust = "25;"
collisionType = "dynamic"
- mass = 100
- linearDamping = 0.7
- angularDamping = 0.9999999
+ 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-->
+ <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" />
</attached>
<collisionShapes>
<BoxCollisionShape position="0,0,0" halfExtents="10, 3, 5" />
@@ -89,65 +91,89 @@
?>
</SpaceShip>
+
- <!-- <Destroyer
+
+ <Destroyer
position = "100,150,0"
- collisionType = dynamic
- mass = 100000
+ collisionType = "dynamic"
+ mass = "100000"
velocity = "0,0,0"
- angularDamping = 0.9999999
- health = 10000
- maxhealth = 10000
- initialhealth = 10000
+ angularDamping = "0.9999999"
+ health = "10000"
+ maxhealth = "10000"
+ initialhealth = "10000"
>
<attached>
-
- <DistanceTriggerBeacon name="beacon1" />
- <DockingTarget name="asdf" />
+ <DistanceTriggerBeacon name="destroyerBeacon" />
+ <DockingTarget name="theDestroyer" />
- <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 />
- <TeamSpawnPoint team=1 position="100,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 />
+
+ <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" />
+ <TeamSpawnPoint team="1" position="100,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" />
<?lua for i = 1, 100, 1 do ?>
<TeamSpawnPoint
- team=0
+ team="0"
position="<?lua print((math.random() * 500 + 500) * (math.floor(math.random() + 0.5) * 2 - 1)) ?>,<?lua print((math.random() * 500 + 500) * (math.floor(math.random() + 0.5) * 2 - 1)) ?>,<?lua print((math.random() * 500 + 500) * (math.floor(math.random() + 0.5) * 2 - 1)) ?>"
lookat="0,0,0"
- spawnclass=SpaceShip
- pawndesign=spaceshipassff
+ spawnclass="SpaceShip"
+ pawndesign="spaceshipassff"
/>
<?lua end ?>
<Model mesh="Carrier.mesh" scale="5" />
<Backlight
- mainstate=activity
- active=false
- scale=0.4
- name=bltest
+ mainstate="activity"
+ active="false"
+ scale="0.4"
+ name="bltest"
position=" 7.6, 0, 6"
colour="0.2, 0.65, 1.0, 1.0"
- width=15
- length=1500
- lifetime=2
- elements=50
+ width="15"
+ length="1500"
+ lifetime="2"
+ elements="50"
trailmaterial="Trail/backlighttrail"
- turnontime=1
- turnofftime=1
+ turnontime="1"
+ turnofftime="1"
material="Flares/ThrusterFlare1"
/>
+ <Backlight
+ scale="1"
+ position=" 169, 75, -15"
+ colour="1, 0.85, 0.5, 0.5"
+ width="40"
+ length="1000"
+ lifetime="5"
+ elements="15"
+ trailmaterial="Trail/backlighttrail"
+ material="Examples/Flare"
+ />
+ <Backlight
+ scale="1"
+ position=" 169, -75, -15"
+ colour="1, 0.85, 0.5, 0.5"
+ width="40"
+ length="1000"
+ lifetime="5"
+ elements="15"
+ trailmaterial="Trail/backlighttrail"
+ material="Examples/Flare"
+ />
<?lua for i=0,8,1 do ?>
<BlinkingBillboard
position="<?lua print(200-270/8*i)?> ,15,2"
material="Examples/Flare"
colour="1.0, 0.5, 0.3"
phase="<?lua print(-360/8*i)?>"
- amplitude=0.1
- frequency=0.5
- quadratic=1
+ amplitude="0.1"
+ frequency="0.5"
+ quadratic="1"
/>
<BlinkingBillboard
@@ -155,33 +181,12 @@
material="Examples/Flare"
colour="1.0, 0.5, 0.3"
phase="<?lua print(-360/8*i)?>"
- amplitude=0.1
- frequency=0.5
- quadratic=1
+ amplitude="0.1"
+ frequency="0.5"
+ quadratic="1"
/>
<?lua end ?>
- <Backlight
- scale=1
- position=" 169, 75, -15"
- colour="1, 0.85, 0.5, 0.5"
- width=40
- length=1000
- lifetime=5
- elements=15
- trailmaterial="Trail/backlighttrail"
- material="Examples/Flare"
- />
- <Backlight
- scale=1
- position=" 169, -75, -15"
- colour="1, 0.85, 0.5, 0.5"
- width=40
- length=1000
- lifetime=5
- elements=15
- trailmaterial="Trail/backlighttrail"
- material="Examples/Flare" />
</attached>
<collisionShapes>
<BoxCollisionShape position="70,0,-25" halfExtents="150, 50, 25" />
@@ -192,8 +197,8 @@
<BoxCollisionShape position="77,0,50" halfExtents="110, 45, 6" />
<BoxCollisionShape position="167,0,70" halfExtents="17, 20, 20" />
</collisionShapes>
+
</Destroyer>
- //-->
</Scene>
</Level>
Modified: code/branches/dockingsystem2/src/modules/docking/Dock.cc
===================================================================
--- code/branches/dockingsystem2/src/modules/docking/Dock.cc 2011-05-02 13:58:10 UTC (rev 8381)
+++ code/branches/dockingsystem2/src/modules/docking/Dock.cc 2011-05-02 14:16:27 UTC (rev 8382)
@@ -32,15 +32,22 @@
*/
#include "Dock.h"
+
#include "infos/HumanPlayer.h"
#include "worldentities/pawns/Pawn.h"
#include "interfaces/PlayerTrigger.h"
+#include "controllers/HumanController.h"
+#include "core/command/ConsoleCommand.h"
+
namespace orxonox
{
CreateFactory(Dock);
+ SetConsoleCommand("Dock", "dock", &Dock::cmdDock).addShortcut().setAsInputCommand();
+ SetConsoleCommand("Dock", "undock", &Dock::cmdUndock).addShortcut().setAsInputCommand();
+
Dock::Dock(BaseObject* creator) : StaticEntity(creator)
{
RegisterObject(Dock);
@@ -79,17 +86,17 @@
if(pTrigger != NULL)
{
if(!pTrigger->isForPlayer()) { // The PlayerTrigger is not exclusively for Pawns which means we cannot extract one.
- COUT(0) << "Docking:execute PlayerTrigger was not triggered by a player.." << std::endl;
+ COUT(2) << "Docking:execute PlayerTrigger was not triggered by a player.." << std::endl;
return false;
}
pawn = pTrigger->getTriggeringPlayer();
} else {
- COUT(0) << "Docking::execute Not a player trigger, can't extract pawn from it.." << std::endl;
+ COUT(2) << "Docking::execute Not a player trigger, can't extract pawn from it.." << std::endl;
return false;
}
if(pawn == NULL)
{
- COUT(0) << "Docking::execute Can't retrieve Pawn from Trigger. (" << trigger->getIdentifier()->getName() << ")" << std::endl;
+ COUT(2) << "Docking::execute Can't retrieve Pawn from Trigger. (" << trigger->getIdentifier()->getName() << ")" << std::endl;
return false;
}
@@ -97,36 +104,85 @@
PlayerInfo* player = pawn->getPlayer();
if(player == NULL)
{
- COUT(0) << "The PlayerInfo* is NULL." << std::endl;
+ COUT(2) << "The PlayerInfo* is NULL." << std::endl;
return false;
}
COUT(0) << "Dock triggered by player: " << player->getName() << ".." << std::endl;
if(bTriggered) {
- DockingEffect::invokeEffect(docking::DOCKING, player, effects_);
- DockingEffect::invokeEffect(docking::ATTACH, player, effects_);
+ // Add player to this Docks candidates
+ candidates.insert(player);
+
+ //DockingEffect::invokeEffect(docking::DOCKING, player, effects_);
} else {
- DockingEffect::invokeEffect(docking::RELEASE, player, effects_);
+ // Remove player from candidates list
+ candidates.erase(player);
+
+ //DockingEffect::invokeEffect(docking::RELEASE, player, effects_);
}
return true;
}
+ void Dock::cmdDock() {
+ PlayerInfo* player = HumanController::getLocalControllerSingleton()->getPlayer();
+ for(ObjectList<Dock>::iterator it = ObjectList<Dock>::begin(); it != ObjectList<Dock>::end(); ++it) {
+ if(it->dock(player))
+ break;
+ }
+ }
+
+ void Dock::cmdUndock() {
+ PlayerInfo* player = HumanController::getLocalControllerSingleton()->getPlayer();
+ for(ObjectList<Dock>::iterator it = ObjectList<Dock>::begin(); it != ObjectList<Dock>::end(); ++it) {
+ if(it->undock(player))
+ break;
+ }
+ }
+
+
+ bool Dock::dock(PlayerInfo* player) {
+ // Check if player is a candidate
+ if(candidates.find(player) == candidates.end()) {
+ COUT(0) << "Player is not a candidate!";
+ 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);
+ 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;
+ return false;
+ }
+
+ // Remove player from docked, add to candidates and reverse DockingEffect
+ docked.erase(player);
+ candidates.insert(player);
+ DockingEffect::invokeEffect(docking::RELEASE, player, effects);
+ return true;
+ }
+
+
bool Dock::addEffect(DockingEffect* effect) {
assert(effect);
- effects_.push_back(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)
- {
+ 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/dockingsystem2/src/modules/docking/Dock.h
===================================================================
--- code/branches/dockingsystem2/src/modules/docking/Dock.h 2011-05-02 13:58:10 UTC (rev 8381)
+++ code/branches/dockingsystem2/src/modules/docking/Dock.h 2011-05-02 14:16:27 UTC (rev 8382)
@@ -35,17 +35,20 @@
#ifndef _Dock_H__
#define _Dock_H__
+#include <map>
+
#include "core/CoreIncludes.h"
#include "core/XMLPort.h"
#include "core/EventIncludes.h"
#include "worldentities/StaticEntity.h"
+#include "notifications/NotificationManager.h"
+
#include "DockingEffect.h"
#include "DockingPrereqs.h"
-namespace orxonox {
+namespace orxonox {
-
class _DockingExport Dock : public StaticEntity {
public:
Dock(BaseObject* creator);
@@ -59,8 +62,16 @@
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 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)
+
+ static void cmdDock();
+ static void cmdUndock();
+
private:
- std::list<DockingEffect*> effects_; //!< The list of DockingEffects to be executed when a player docks.
+ 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.
};
Modified: code/branches/dockingsystem2/src/modules/docking/DockToShip.cc
===================================================================
--- code/branches/dockingsystem2/src/modules/docking/DockToShip.cc 2011-05-02 13:58:10 UTC (rev 8381)
+++ code/branches/dockingsystem2/src/modules/docking/DockToShip.cc 2011-05-02 14:16:27 UTC (rev 8382)
@@ -88,6 +88,8 @@
return false;
}
+ // Make sure target isn't removed when undocking
+ dockTo->setDestroyWhenPlayerLeft(false);
player->startTemporaryControl(dockTo);
return true;
@@ -96,6 +98,9 @@
bool DockToShip::release(PlayerInfo* player)
{
COUT(0) << "DockToShip::release" << endl;
+
+ player->stopTemporaryControl();
+
return true;
}
}
Modified: code/branches/dockingsystem2/src/orxonox/infos/PlayerInfo.cc
===================================================================
--- code/branches/dockingsystem2/src/orxonox/infos/PlayerInfo.cc 2011-05-02 13:58:10 UTC (rev 8381)
+++ code/branches/dockingsystem2/src/orxonox/infos/PlayerInfo.cc 2011-05-02 14:16:27 UTC (rev 8382)
@@ -222,7 +222,7 @@
this->controllableEntity_->setController(0);
- this->controllableEntity_ = this->previousControllableEntity_.back();
+// this->controllableEntity_ = this->previousControllableEntity_.back();
do {
this->controllableEntity_ = this->previousControllableEntity_.back();
} while(this->controllableEntity_ == NULL && this->previousControllableEntity_.size() > 0);
More information about the Orxonox-commit
mailing list