Changeset 5895 in orxonox.OLD for branches/spaceshipcontrol/src
- Timestamp:
- Dec 3, 2005, 5:18:37 PM (19 years ago)
- Location:
- branches/spaceshipcontrol/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/spaceshipcontrol/src/story_entities/world.cc
r5894 r5895 363 363 { 364 364 playable = dynamic_cast<Playable*>(playableList->front()); 365 if (playable != NULL) 366 this->localPlayer->setControllable(playable); 365 this->localPlayer->setControllable(playable); 367 366 } 368 367 -
branches/spaceshipcontrol/src/world_entities/playable.cc
r5889 r5895 14 14 */ 15 15 16 #include "weapons/weapon_manager.h"17 16 18 17 #include "playable.h" 18 19 #include "weapons/weapon_manager.h" 19 20 #include "event_handler.h" 20 21 #include "player.h" … … 29 30 { 30 31 delete this->weaponMan; 32 33 if (this->currentPlayer) 34 { 35 PRINTF(2)("There is Still a Player subscribed to this Playable (%s::%s)\n", this->getClassName(), this->getName()); 36 37 } 31 38 } 32 39 … … 36 43 PRINTF(4)("PLAYABLE INIT\n"); 37 44 this->weaponMan = new WeaponManager(this); 45 46 this->currentPlayer = NULL; 38 47 } 39 48 … … 41 50 * subscribe to all events the controllable needs 42 51 */ 43 void Playable::subscribeEvents(Player* player)52 bool Playable::subscribePlayer(Player* player) 44 53 { 45 /*EventHandler*/ 46 EventHandler* evh = EventHandler::getInstance(); 47 std::list<int>::iterator ev; 48 for (ev = this->events.begin(); ev != events.end(); ev++) 54 if (this->currentPlayer != NULL) 49 55 { 50 evh->subscribe(player, ES_GAME, (*ev)); 56 PRINTF(1)("Already registered Player:%s to this Playable (%s:%s)\n", this->currentPlayer->getName(), this->getClassName(), this->getName()); 57 return false; 51 58 } 59 else 60 { 61 this->currentPlayer = player; 62 /*EventHandler*/ 63 EventHandler* evh = EventHandler::getInstance(); 64 std::list<int>::iterator ev; 65 for (ev = this->events.begin(); ev != events.end(); ev++) 66 evh->subscribe(player, ES_GAME, (*ev)); 52 67 68 return true; 69 } 53 70 } 54 71 -
branches/spaceshipcontrol/src/world_entities/playable.h
r5888 r5895 31 31 inline WeaponManager* getWeaponManager() const { return this->weaponMan; }; 32 32 33 void subscribeEvents(Player* player); 33 bool subscribePlayer(Player* player); 34 34 35 virtual void process(const Event &event) {} //= 0; 35 36 inline const std::list<int>& getEventList() { return this->events; }; … … 37 38 protected: 38 39 void registerEvent(int eventType); 40 void unregisterEvent(int eventType); 39 41 40 42 private: -
branches/spaceshipcontrol/src/world_entities/player.cc
r5883 r5895 61 61 62 62 63 void Player::setControllable(Playable* controllalble)63 bool Player::setControllable(Playable* controllable) 64 64 { 65 66 this->controllable = controllalble; 67 this->controllable->subscribeEvents(this); 68 65 if(controllable != NULL && controllable->subscribePlayer(this)) 66 { 67 this->controllable = controllable; 68 return true; 69 } 70 else 71 return false; 69 72 } 70 73 71 74 72 73 Playable* Player::getControllable()74 {75 return controllable;76 }77 -
branches/spaceshipcontrol/src/world_entities/player.h
r5872 r5895 31 31 virtual void process(const Event &event); 32 32 33 voidsetControllable(Playable* controllalble);33 bool setControllable(Playable* controllalble); 34 34 void disconnectControllable(); 35 Playable* getControllable() ;35 Playable* getControllable() { return this->controllable; }; 36 36 37 37 38 38 private: 39 Playable* controllable;39 Playable* controllable; 40 40 41 41
Note: See TracChangeset
for help on using the changeset viewer.