[2934] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
| 3 | * > www.orxonox.net < |
---|
| 4 | * |
---|
| 5 | * |
---|
| 6 | * License notice: |
---|
| 7 | * |
---|
| 8 | * This program is free software; you can redistribute it and/or |
---|
| 9 | * modify it under the terms of the GNU General Public License |
---|
| 10 | * as published by the Free Software Foundation; either version 2 |
---|
| 11 | * of the License, or (at your option) any later version. |
---|
| 12 | * |
---|
| 13 | * This program is distributed in the hope that it will be useful, |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | * GNU General Public License for more details. |
---|
| 17 | * |
---|
| 18 | * You should have received a copy of the GNU General Public License |
---|
| 19 | * along with this program; if not, write to the Free Software |
---|
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 21 | * |
---|
| 22 | * Author: |
---|
[3020] | 23 | * Val Mikos |
---|
[2934] | 24 | * Co-authors: |
---|
[3020] | 25 | * ... |
---|
[2934] | 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | |
---|
| 30 | #include "TeamBaseMatchBase.h" |
---|
| 31 | #include "core/CoreIncludes.h" |
---|
| 32 | #include "objects/gametypes/TeamBaseMatch.h" |
---|
[3183] | 33 | #include "interfaces/TeamColourable.h" |
---|
[3177] | 34 | #include "interfaces/PawnListener.h" |
---|
[2934] | 35 | |
---|
| 36 | namespace orxonox |
---|
| 37 | { |
---|
| 38 | CreateFactory(TeamBaseMatchBase); |
---|
| 39 | |
---|
| 40 | TeamBaseMatchBase::TeamBaseMatchBase(BaseObject* creator) : Pawn(creator) |
---|
| 41 | { |
---|
| 42 | RegisterObject(TeamBaseMatchBase); |
---|
| 43 | |
---|
| 44 | this->state_ = BaseState::uncontrolled; |
---|
| 45 | |
---|
| 46 | TeamBaseMatch* gametype = dynamic_cast<TeamBaseMatch*>(this->getGametype()); |
---|
| 47 | if (gametype) |
---|
| 48 | { |
---|
| 49 | gametype->addBase(this); |
---|
| 50 | } |
---|
[3086] | 51 | |
---|
| 52 | this->setRadarObjectShape(RadarViewable::Triangle); |
---|
[2934] | 53 | } |
---|
[2985] | 54 | |
---|
| 55 | void TeamBaseMatchBase::changeTeamColour() |
---|
| 56 | { |
---|
| 57 | this->fireEvent(); |
---|
| 58 | |
---|
| 59 | TeamDeathmatch* gametype = dynamic_cast<TeamDeathmatch*>(this->getGametype()); |
---|
| 60 | if (!gametype) |
---|
| 61 | return; |
---|
| 62 | |
---|
| 63 | ColourValue colour; |
---|
| 64 | |
---|
| 65 | switch (this->state_) |
---|
| 66 | { |
---|
| 67 | case BaseState::controlTeam1: |
---|
| 68 | colour = gametype->getTeamColour(0); |
---|
| 69 | break; |
---|
| 70 | case BaseState::controlTeam2: |
---|
| 71 | colour = gametype->getTeamColour(1); |
---|
| 72 | break; |
---|
| 73 | case BaseState::uncontrolled: |
---|
| 74 | default: |
---|
[3086] | 75 | colour = ColourValue(0.5, 0.5, 0.5, 1.0); |
---|
[2985] | 76 | break; |
---|
| 77 | } |
---|
| 78 | |
---|
[3020] | 79 | |
---|
[2985] | 80 | std::set<WorldEntity*> attachments = this->getAttachedObjects(); |
---|
| 81 | for (std::set<WorldEntity*>::iterator it = attachments.begin(); it != attachments.end(); ++it) |
---|
| 82 | { |
---|
[3183] | 83 | if ((*it)->isA(Class(TeamColourable))) |
---|
[2985] | 84 | { |
---|
[3183] | 85 | TeamColourable* tc = dynamic_cast<TeamColourable*>(*it); |
---|
[2985] | 86 | tc->setTeamColour(colour); |
---|
| 87 | } |
---|
| 88 | } |
---|
[3086] | 89 | |
---|
| 90 | this->setRadarObjectColour(colour); |
---|
| 91 | |
---|
| 92 | // Call this so bots stop shooting at the base after they converted it |
---|
| 93 | for (ObjectList<PawnListener>::iterator it = ObjectList<PawnListener>::begin(); it != ObjectList<PawnListener>::end(); ++it) |
---|
| 94 | it->destroyedPawn(this); |
---|
[2985] | 95 | } |
---|
[2934] | 96 | } |
---|
| 97 | |
---|