Changeset 2369 for code/branches/objecthierarchy2/src/orxonox/objects
- Timestamp:
- Dec 10, 2008, 3:37:48 AM (16 years ago)
- Location:
- code/branches/objecthierarchy2/src/orxonox/objects
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy2/src/orxonox/objects/EventTarget.cc
r2087 r2369 48 48 void EventTarget::changedName() 49 49 { 50 SUPER(EventTarget, changedName); 51 50 52 for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it) 51 53 if (it->getName() == this->getName()) -
code/branches/objecthierarchy2/src/orxonox/objects/gametypes/Gametype.cc
r2361 r2369 169 169 for (std::map<PlayerInfo*, PlayerState::Enum>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) 170 170 { 171 if (!it->first->getControllableEntity() && (!it->first->isReadyToSpawn() || !this->bStarted_)) 172 { 173 SpawnPoint* spawn = this->getBestSpawnPoint(it->first); 174 if (spawn) 175 { 176 // force spawn at spawnpoint with default pawn 177 ControllableEntity* entity = this->defaultControllableEntity_.fabricate(spawn); 178 spawn->spawn(entity); 179 it->first->startControl(entity); 180 it->second = PlayerState::Dead; 181 } 182 else 183 { 184 COUT(1) << "Error: No SpawnPoints in current Gametype" << std::endl; 185 abort(); 171 if (!it->first->getControllableEntity()) 172 { 173 it->second = PlayerState::Dead; 174 175 if (!it->first->isReadyToSpawn() || !this->bStarted_) 176 { 177 SpawnPoint* spawn = this->getBestSpawnPoint(it->first); 178 if (spawn) 179 { 180 // force spawn at spawnpoint with default pawn 181 ControllableEntity* entity = this->defaultControllableEntity_.fabricate(spawn); 182 spawn->spawn(entity); 183 it->first->startControl(entity); 184 it->second = PlayerState::Dead; 185 } 186 else 187 { 188 COUT(1) << "Error: No SpawnPoints in current Gametype" << std::endl; 189 abort(); 190 } 186 191 } 187 192 } … … 211 216 { 212 217 bool allplayersready = true; 218 bool hashumanplayers = false; 213 219 for (std::map<PlayerInfo*, PlayerState::Enum>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) 214 220 { 215 221 if (!it->first->isReadyToSpawn()) 216 222 allplayersready = false; 217 } 218 if (allplayersready) 223 if (it->first->isHumanPlayer()) 224 hashumanplayers = true; 225 } 226 if (allplayersready && hashumanplayers) 219 227 { 220 228 this->startCountdown_ = this->initialStartCountdown_; -
code/branches/objecthierarchy2/src/orxonox/objects/infos/PlayerInfo.cc
r2362 r2369 77 77 void PlayerInfo::changedName() 78 78 { 79 SUPER(PlayerInfo, changedName); 80 79 81 if (this->isInitialized() && this->getGametype()) 80 82 this->getGametype()->playerChangedName(this); -
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/Camera.cc
r2361 r2369 54 54 { 55 55 RegisterObject(Camera); 56 56 COUT(0) << this << ": created camera" << std::endl; 57 57 if (!this->getScene() || !this->getScene()->getSceneManager()) 58 58 ThrowException(AbortLoading, "Can't create Camera, no scene or no scene manager given."); … … 70 70 this->configvaluecallback_changedNearClipDistance(); 71 71 72 this->requestFocus(); // ! HACK ! REMOVE THIS !72 // this->requestFocus(); // ! HACK ! REMOVE THIS ! 73 73 } 74 74 … … 80 80 this->getScene()->getSceneManager()->destroyCamera(this->camera_); 81 81 } 82 COUT(0) << this << ": destroyed camera" << std::endl; 82 83 } 83 84 … … 122 123 void Camera::removeFocus() 123 124 { 125 COUT(0) << this << ": remove focus" << std::endl; 124 126 this->bHasFocus_ = false; 125 127 } … … 142 144 this->bHasFocus_ = true; 143 145 viewport->setCamera(this->camera_); 146 COUT(0) << this << ": set focus" << std::endl; 144 147 145 148 // reactivate all visible compositors -
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/pawns/Pawn.cc
r2256 r2369 33 33 #include "core/XMLPort.h" 34 34 #include "util/Math.h" 35 #include "PawnManager.h" 35 36 #include "objects/infos/PlayerInfo.h" 36 37 #include "objects/gametypes/Gametype.h" … … 45 46 RegisterObject(Pawn); 46 47 47 this->bAlive_ = false; 48 PawnManager::touch(); 49 50 this->bAlive_ = true; 48 51 49 52 this->health_ = 0; … … 70 73 Pawn::~Pawn() 71 74 { 75 if (this->isInitialized()) 76 { 77 for (ObjectList<PawnListener>::iterator it = ObjectList<PawnListener>::begin(); it != ObjectList<PawnListener>::end(); ++it) 78 it->destroyedPawn(this); 79 } 72 80 } 73 81 … … 76 84 SUPER(Pawn, XMLPort, xmlelement, mode); 77 85 78 XMLPortParam(Pawn, "health", setHealth, getHeal ht, xmlelement, mode).defaultValues(100);86 XMLPortParam(Pawn, "health", setHealth, getHealth, xmlelement, mode).defaultValues(100); 79 87 XMLPortParam(Pawn, "maxhealth", setMaxHealth, getMaxHealth, xmlelement, mode).defaultValues(200); 80 88 XMLPortParam(Pawn, "initialhealth", setInitialHealth, getInitialHealth, xmlelement, mode).defaultValues(100); … … 85 93 REGISTERDATA(this->bAlive_, direction::toclient); 86 94 REGISTERDATA(this->health_, direction::toclient); 95 REGISTERDATA(this->initialHealth_, direction::toclient); 87 96 } 88 97 … … 90 99 { 91 100 SUPER(Pawn, tick, dt); 101 102 this->health_ -= 15 * dt * rnd(); 92 103 93 104 if (this->health_ <= 0) … … 129 140 void Pawn::death() 130 141 { 142 // Set bAlive_ to false and wait for PawnManager to do the destruction 131 143 this->bAlive_ = false; 144 132 145 if (this->getGametype()) 133 146 this->getGametype()->pawnKilled(this, this->lastHitOriginator_); 147 148 this->setDestroyWhenPlayerLeft(false); 149 134 150 if (this->getPlayer()) 135 151 this->getPlayer()->stopControl(this); 136 137 delete this;138 152 139 153 // play death effect … … 151 165 this->spawn(); 152 166 } 167 168 /////////////////// 169 // Pawn Listener // 170 /////////////////// 171 PawnListener::PawnListener() 172 { 173 RegisterRootObject(PawnListener); 174 } 153 175 } -
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/pawns/Pawn.h
r2256 r2369 55 55 inline void removeHealth(float health) 56 56 { this->setHealth(this->health_ - health); } 57 inline float getHeal ht() const57 inline float getHealth() const 58 58 { return this->health_; } 59 59 … … 96 96 WeaponSystem* weaponSystem_; 97 97 }; 98 99 class _OrxonoxExport PawnListener : public OrxonoxClass 100 { 101 friend class Pawn; 102 103 public: 104 PawnListener(); 105 virtual ~PawnListener() {} 106 107 protected: 108 virtual void destroyedPawn(Pawn* pawn) = 0; 109 }; 98 110 } 99 111
Note: See TracChangeset
for help on using the changeset viewer.