Changeset 8434 for code/branches/dockingsystem2/src/modules/docking
- Timestamp:
- May 9, 2011, 4:26:37 PM (14 years ago)
- Location:
- code/branches/dockingsystem2/src/modules/docking
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/dockingsystem2/src/modules/docking/CMakeLists.txt
r8257 r8434 10 10 FIND_HEADER_FILES 11 11 TOLUA_FILES 12 Dock.h 12 13 PCH_FILE 13 14 DockingPrecompiledHeaders.h -
code/branches/dockingsystem2/src/modules/docking/Dock.cc
r8382 r8434 34 34 #include "Dock.h" 35 35 36 #include "core/CoreIncludes.h" 37 #include "core/LuaState.h" 38 #include "core/GUIManager.h" 36 39 #include "infos/HumanPlayer.h" 37 40 #include "worldentities/pawns/Pawn.h" 38 41 #include "interfaces/PlayerTrigger.h" 39 #include "controllers/HumanController.h"40 42 #include "core/command/ConsoleCommand.h" 41 43 42 44 #include "ToluaBindDocking.h" 43 45 44 46 namespace orxonox 45 47 { 48 // Register tolua_open function when loading the library 49 DeclareToluaInterface(Docking); 50 46 51 CreateFactory(Dock); 47 52 … … 111 116 COUT(0) << "Dock triggered by player: " << player->getName() << ".." << std::endl; 112 117 113 if(bTriggered) { 118 if(bTriggered) 119 { 114 120 // Add player to this Docks candidates 115 121 candidates.insert(player); 116 122 123 // Show docking dialog 124 GUIManager::showGUI("DockingDialog"); 117 125 //DockingEffect::invokeEffect(docking::DOCKING, player, effects_); 118 } else { 126 } 127 else 128 { 119 129 // Remove player from candidates list 120 130 candidates.erase(player); … … 127 137 128 138 129 void Dock::cmdDock() { 130 PlayerInfo* player = HumanController::getLocalControllerSingleton()->getPlayer(); 131 for(ObjectList<Dock>::iterator it = ObjectList<Dock>::begin(); it != ObjectList<Dock>::end(); ++it) { 139 void Dock::cmdDock() 140 { 141 PlayerInfo* player = HumanController::getLocalControllerSingleton()->getPlayer(); 142 for(ObjectList<Dock>::iterator it = ObjectList<Dock>::begin(); it != ObjectList<Dock>::end(); ++it) 143 { 132 144 if(it->dock(player)) 133 145 break; … … 135 147 } 136 148 137 void Dock::cmdUndock() { 138 PlayerInfo* player = HumanController::getLocalControllerSingleton()->getPlayer(); 139 for(ObjectList<Dock>::iterator it = ObjectList<Dock>::begin(); it != ObjectList<Dock>::end(); ++it) { 149 void Dock::cmdUndock() 150 { 151 PlayerInfo* player = HumanController::getLocalControllerSingleton()->getPlayer(); 152 for(ObjectList<Dock>::iterator it = ObjectList<Dock>::begin(); it != ObjectList<Dock>::end(); ++it) 153 { 140 154 if(it->undock(player)) 141 155 break; … … 144 158 145 159 146 bool Dock::dock(PlayerInfo* player) { 160 bool Dock::dock(PlayerInfo* player) 161 { 147 162 // Check if player is a candidate 148 if(candidates.find(player) == candidates.end()) { 149 COUT(0) << "Player is not a candidate!"; 163 if(candidates.find(player) == candidates.end()) 164 { 165 COUT(0) << "Player is not a candidate!" << std::endl; 150 166 return false; 151 167 } … … 158 174 } 159 175 160 bool Dock::undock(PlayerInfo* player) { 176 bool Dock::undock(PlayerInfo* player) 177 { 161 178 // Check if player is docked to this Dock 162 if(docked.find(player) == docked.end()) { 179 if(docked.find(player) == docked.end()) 180 { 163 181 COUT(0) << "Player is not docked to this Dock." << std::endl; 164 182 return false; … … 173 191 174 192 175 bool Dock::addEffect(DockingEffect* effect) { 193 unsigned int Dock::getNumberOfActiveDocks() 194 { 195 int i = 0; 196 PlayerInfo* player = HumanController::getLocalControllerSingleton()->getPlayer(); 197 for(ObjectList<Dock>::iterator it = ObjectList<Dock>::begin(); it != ObjectList<Dock>::end(); ++it) 198 { 199 if(it->candidates.find(player) != it->candidates.end()) 200 i++; 201 } 202 return i; 203 } 204 205 Dock* Dock::getActiveDockAtIndex(unsigned int index) 206 { 207 PlayerInfo* player = HumanController::getLocalControllerSingleton()->getPlayer(); 208 for(ObjectList<Dock>::iterator it = ObjectList<Dock>::begin(); it != ObjectList<Dock>::end(); ++it) 209 { 210 if(it->candidates.find(player) != it->candidates.end()) 211 { 212 if(index == 0) 213 return *it; 214 index--; 215 } 216 } 217 return NULL; 218 } 219 220 221 bool Dock::addEffect(DockingEffect* effect) 222 { 176 223 assert(effect); 177 224 effects.push_back(effect); … … 179 226 } 180 227 181 const DockingEffect* Dock::getEffect(unsigned int index) const { 228 const DockingEffect* Dock::getEffect(unsigned int index) const 229 { 182 230 int i = index; 183 for (std::list<DockingEffect*>::const_iterator effect = this->effects.begin(); effect != this->effects.end(); ++effect) { 231 for (std::list<DockingEffect*>::const_iterator effect = this->effects.begin(); effect != this->effects.end(); ++effect) 232 { 184 233 if(i == 0) 185 234 return *effect; -
code/branches/dockingsystem2/src/modules/docking/Dock.h
r8383 r8434 43 43 44 44 #include "worldentities/StaticEntity.h" 45 #include " notifications/NotificationManager.h"45 #include "controllers/HumanController.h" 46 46 47 47 #include "DockingEffect.h" 48 48 #include "DockingPrereqs.h" 49 49 50 namespace orxonox { 50 namespace orxonox // tolua_export 51 { // tolua_export 51 52 52 class _DockingExport Dock : public StaticEntity { 53 class _DockingExport Dock // tolua_export 54 : public StaticEntity 55 { // tolua_export 53 56 public: 54 57 Dock(BaseObject* creator); … … 66 69 bool undock(PlayerInfo* player); //!< Undocks a player (player must be docked) 67 70 71 void dock() { this->dock(HumanController::getLocalControllerSingleton()->getPlayer()); } // tolua_export 72 static unsigned int getNumberOfActiveDocks(); // tolua_export 73 static Dock* getActiveDockAtIndex(unsigned int index); // tolua_export 74 68 75 static void cmdDock(); 69 76 static void cmdUndock(); … … 73 80 std::set<PlayerInfo*> docked; //!< A set of all docked players 74 81 std::list<DockingEffect*> effects; //!< The list of DockingEffects to be executed when a player docks. 75 }; 76 77 78 } 82 }; // tolua_export 83 } // tolua_export 79 84 80 85 #endif /* _Dock_H__ */
Note: See TracChangeset
for help on using the changeset viewer.