Rev | Line | |
---|
[12296] | 1 | #include "mousegametype.h" |
---|
| 2 | |
---|
| 3 | namespace orxonox |
---|
| 4 | { |
---|
| 5 | RegisterUnloadableClass(MouseGametype); |
---|
| 6 | MouseGametype::MouseGametype(Context* context):Gametype(context) |
---|
| 7 | { |
---|
| 8 | RegisterObject(MouseGametype); |
---|
| 9 | player_ =nullptr; |
---|
| 10 | |
---|
| 11 | } |
---|
| 12 | void MouseGametype::start(){ |
---|
| 13 | |
---|
| 14 | bool temp = this->bForceSpawn_; |
---|
| 15 | this->bForceSpawn_ = true; |
---|
| 16 | |
---|
| 17 | // Call start for the parent class. |
---|
| 18 | Gametype::start(); |
---|
| 19 | |
---|
| 20 | // Reset the variable. |
---|
| 21 | this->bForceSpawn_ = temp; |
---|
| 22 | |
---|
| 23 | } |
---|
| 24 | |
---|
| 25 | void MouseGametype::spawnPlayersIfRequested() |
---|
| 26 | { |
---|
| 27 | // Spawn a human player. |
---|
| 28 | for (const auto& mapEntry : this->players_) |
---|
| 29 | if (mapEntry.first->isHumanPlayer() && (mapEntry.first->isReadyToSpawn() || this->bForceSpawn_)) |
---|
| 30 | this->spawnPlayer(mapEntry.first); |
---|
| 31 | } |
---|
| 32 | |
---|
| 33 | |
---|
| 34 | void MouseGametype::spawnPlayer(PlayerInfo* player) |
---|
| 35 | { |
---|
| 36 | assert(player); |
---|
| 37 | |
---|
| 38 | if(this->player_ == nullptr) |
---|
| 39 | { |
---|
| 40 | this->player_ = player; |
---|
| 41 | this->players_[player].state_ = PlayerState::Alive; |
---|
| 42 | |
---|
| 43 | } |
---|
| 44 | } |
---|
| 45 | |
---|
| 46 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.