Changeset 8257 for code/branches/dockingsystem2
- Timestamp:
- Apr 18, 2011, 4:35:01 PM (14 years ago)
- Location:
- code/branches/dockingsystem2
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/dockingsystem2/data/levels/docking.oxw
r8206 r8257 30 30 <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 /> 31 31 <?lua end ?> 32 33 <Destroyer 32 33 <Dock position="-50,-100,50"> 34 <effects> 35 <DockToShip target="asdf" /> 36 </effects> 37 <events> 38 <execute> 39 <EventListener event="dockMe" /> 40 </execute> 41 </events> 42 <attached> 43 <DistanceTrigger position="0,0,0" distance="20" target="Pawn" beaconMode="exclude" targetname="beacon1" name="dockMe" /> 44 <Billboard material="Examples/Flare" colour="1.0, 0, 0" /> 45 </attached> 46 </Dock> 47 48 49 <SpaceShip 50 hudtemplate = spaceshiphud 51 camerapositiontemplate = spaceshipassffcameras 52 engine = spaceshipassffengine 53 spawnparticlesource = "Orxonox/fairytwirl" 54 spawnparticleduration = 3 55 explosionchunks = 6 56 57 health = 100 58 maxhealth = 200 59 initialhealth = 100 60 61 primaryThrust = 100; 62 auxilaryThrust = 30; 63 rotationThrust = 25; 64 65 collisionType = "dynamic" 66 mass = 100 67 linearDamping = 0.7 68 angularDamping = 0.9999999 69 > 70 <attached> 71 <DistanceTriggerBeacon name="beacon1" /> 72 <DockingTarget name="asdf" /> 73 74 <Model position="0,0,0" yaw=90 pitch=-90 roll=0 scale=4 mesh="assff.mesh" /> 75 <BlinkingBillboard position="17,-1.5,0" material="Examples/Flare" colour="1.0, 0.5, 0.3" amplitude=0.1 frequency=0.5 quadratic=1 /> 76 <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 /> 77 <DistanceTriggerBeacon name="PlayerDistanceTrigger" /> <!--added DistanceTrigger--> 78 </attached> 79 <collisionShapes> 80 <BoxCollisionShape position="0,0,0" halfExtents="10, 3, 5" /> 81 <BoxCollisionShape position="13,-1.3,0" halfExtents="3, 1, 2" /> 82 <BoxCollisionShape position="-13,-1.3,0" halfExtents="3, 1, 2" /> 83 <BoxCollisionShape position="0,0,7" halfExtents="3, 2, 2" /> 84 <BoxCollisionShape position="0,0.1,-11" halfExtents="2.2, 1.8, 6" /> 85 <BoxCollisionShape position="0,0.1,-19" halfExtents="1.4, 1, 2" /> 86 </collisionShapes> 87 <?lua 88 include("includes/weaponSettingsAssff.oxi") 89 ?> 90 </SpaceShip> 91 92 93 <!-- <Destroyer 34 94 position = "100,150,0" 35 95 collisionType = dynamic … … 43 103 44 104 <attached> 45 <Dock> 46 <effects> 47 <DockToShip /> 48 </effects> 49 <events> 50 <execute> 51 <EventListener event="dockMe" /> 52 </execute> 53 </events> 54 <attached> 55 <DistanceTrigger position="0,0,0" distance="20" target="Pawn" beaconMode="exclude" targetname="beacon1" name="dockMe" /> 56 <Billboard material="Examples/Flare" colour="1.0, 0, 0" /> 57 </attached> 58 </Dock> 105 59 106 <DistanceTriggerBeacon name="beacon1" /> 60 107 <DockingTarget name="asdf" /> 108 109 61 110 <TeamSpawnPoint team=1 position="150,0,7" direction="-1,0,0" roll=90 yaw=0 spawnclass=SpaceShip pawndesign=spaceshipassff /> 62 111 <TeamSpawnPoint team=1 position="0,0,7" lookat="-1,0,0" roll="90" yaw=0 spawnclass=SpaceShip pawndesign=spaceshipassff /> … … 145 194 </collisionShapes> 146 195 </Destroyer> 147 196 //--> 148 197 149 198 </Scene> -
code/branches/dockingsystem2/src/modules/docking/CMakeLists.txt
r8196 r8257 1 1 SET_SOURCE_FILES(DOCKING_SRC_FILES 2 DockingTarget.cc 2 3 DockingEffect.cc 3 4 DockToShip.cc -
code/branches/dockingsystem2/src/modules/docking/Dock.cc
r8197 r8257 73 73 bool Dock::execute(bool bTriggered, BaseObject* trigger) 74 74 { 75 //TODO: Handle DistanceMultiTrigger76 77 75 PlayerTrigger* pTrigger = orxonox_cast<PlayerTrigger*>(trigger); 78 76 Pawn* pawn = NULL; … … 104 102 } 105 103 106 // Try to get HumanPlayer 107 if(!player->isHumanPlayer()) { 108 COUT(0) << "Docking::execute Not triggered by a human." << std::endl; 109 return false; 110 } 111 HumanPlayer* human = orxonox_cast<HumanPlayer*>(player); 112 if(human == NULL) { 113 COUT(0) << "Docking::execute Player was not as human as expected.." << std::endl; 114 } 115 COUT(0) << "Dock triggered by player: " << human->getName() << ".." << std::endl; 104 COUT(0) << "Dock triggered by player: " << player->getName() << ".." << std::endl; 116 105 117 //TODO: This is waaay too oversimplified118 106 if(bTriggered) { 119 107 DockingEffect::invokeEffect(docking::DOCKING, player, effects_); 120 //DockingEffect::invokeEffect(docking::ATTACH, player, effects_);108 DockingEffect::invokeEffect(docking::ATTACH, player, effects_); 121 109 } else { 122 110 DockingEffect::invokeEffect(docking::RELEASE, player, effects_); -
code/branches/dockingsystem2/src/modules/docking/DockToShip.cc
r8196 r8257 51 51 } 52 52 53 54 void DockToShip::XMLPort(Element& xmlelement, XMLPort::Mode mode) { 55 SUPER(DockToShip, XMLPort, xmlelement, mode); 56 57 XMLPortParam(DockToShip, "target", setTargetId, getTargetId, xmlelement, mode); 58 } 59 60 void DockToShip::setTargetId(std::string str) { 61 this->target = str; 62 } 63 64 std::string DockToShip::getTargetId() { 65 return this->target; 66 } 67 68 53 69 bool DockToShip::docking(PlayerInfo* player) 54 70 { … … 60 76 { 61 77 COUT(0) << "DockToShip::attach" << endl; 78 79 DockingTarget *target = DockingEffect::findTarget(this->target); 80 if (target == NULL) { 81 COUT(0) << "Can't retrieve target for '" << this->target << "'.." << std::endl; 82 return false; 83 } 84 85 ControllableEntity *dockTo = (ControllableEntity*) target->getParent(); 86 if (dockTo == NULL) { 87 COUT(0) << "Parent is not a ControllableEntity.." << std::endl; 88 return false; 89 } 90 91 player->startTemporaryControl(dockTo); 92 62 93 return true; 63 94 } -
code/branches/dockingsystem2/src/modules/docking/DockToShip.h
r8196 r8257 39 39 #include "DockToShip.h" 40 40 41 #include "worldentities/ControllableEntity.h" 42 41 43 42 44 namespace orxonox … … 58 60 virtual ~DockToShip(); 59 61 62 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 63 virtual void setTargetId(std::string str); 64 virtual std::string getTargetId(); 65 60 66 virtual bool docking(PlayerInfo* player); //!< Called when docking starts 61 67 virtual bool attach(PlayerInfo* player); //!< Called after docking animation 62 68 virtual bool release(PlayerInfo* player); //!< Called when player wants undock 69 70 private: 71 std::string target; 63 72 }; 64 73 -
code/branches/dockingsystem2/src/modules/docking/DockingEffect.cc
r8196 r8257 33 33 34 34 #include "DockingEffect.h" 35 #include "core/CoreIncludes.h"36 35 37 36 namespace orxonox … … 71 70 return check; 72 71 } 72 73 DockingTarget *DockingEffect::findTarget(std::string name) { 74 for (ObjectList<DockingTarget>::iterator it = ObjectList<DockingTarget>::begin(); 75 it != ObjectList<DockingTarget>::end(); ++it) 76 { 77 if ((*it)->getName().compare(name) == 0) 78 return (*it); 79 } 80 return NULL; 81 } 73 82 } -
code/branches/dockingsystem2/src/modules/docking/DockingEffect.h
r8196 r8257 36 36 #define _DockingEffect_H__ 37 37 38 #include "core/CoreIncludes.h" 39 #include "core/XMLPort.h" 40 41 #include "infos/PlayerInfo.h" 42 38 43 #include "DockingPrereqs.h" 44 #include "DockingTarget.h" 39 45 40 46 #include <list> … … 68 74 virtual bool docking(PlayerInfo* player) = 0; //!< Called when docking starts 69 75 virtual bool attach(PlayerInfo* player) = 0; //!< Called after docking animation 70 virtual bool release(PlayerInfo* player) = 0; //!< Called when player wants undock76 virtual bool release(PlayerInfo* player) = 0; //!< Called when player wants to undock 71 77 72 78 static bool invokeEffect(docking::event event, PlayerInfo* player, std::list<DockingEffect*> & effects); //!< Invokes the event specific method of all DockingEffects in the list 79 static DockingTarget *findTarget(std::string name); //!< Iterates through all DockingTarget objects to find the one with name=target 73 80 }; 74 81 -
code/branches/dockingsystem2/src/modules/docking/DockingPrereqs.h
r8196 r8257 66 66 { 67 67 class Dock; 68 class DockingTarget; 68 69 class DockingEffect; 69 70 class DockToShip;
Note: See TracChangeset
for help on using the changeset viewer.