Changeset 8257 for code/branches/dockingsystem2/src/modules/docking
- Timestamp:
- Apr 18, 2011, 4:35:01 PM (14 years ago)
- Location:
- code/branches/dockingsystem2/src/modules/docking
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
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.