[10678] | 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: |
---|
| 23 | * Fabian 'x3n' Landau |
---|
| 24 | * Co-authors: |
---|
| 25 | * Dominik Solenicki |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | #include "DivisionController.h" |
---|
[10849] | 30 | #include "infos/PlayerInfo.h" |
---|
[10678] | 31 | |
---|
| 32 | namespace orxonox |
---|
| 33 | { |
---|
| 34 | |
---|
| 35 | RegisterClass(DivisionController); |
---|
| 36 | |
---|
[10826] | 37 | //Leaders share the fact that they have Wingmans |
---|
[10709] | 38 | DivisionController::DivisionController(Context* context) : LeaderController(context) |
---|
[10678] | 39 | { |
---|
| 40 | RegisterObject(DivisionController); |
---|
[10759] | 41 | |
---|
| 42 | this->setFormationMode(FormationMode::DIAMOND); |
---|
[10763] | 43 | this->target_ = 0; |
---|
[10725] | 44 | this->myFollower_ = 0; |
---|
| 45 | this->myWingman_ = 0; |
---|
| 46 | this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&DivisionController::action, this))); |
---|
[10759] | 47 | this->rank_ = Rank::DIVISIONLEADER; |
---|
[10678] | 48 | } |
---|
| 49 | |
---|
| 50 | DivisionController::~DivisionController() |
---|
| 51 | { |
---|
[10854] | 52 | if (this->myFollower_) |
---|
| 53 | { |
---|
[10856] | 54 | this->myFollower_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_); |
---|
[10858] | 55 | if (this->myWingman_) |
---|
| 56 | { |
---|
| 57 | this->myWingman_->setAction(Action::FIGHTALL); |
---|
| 58 | } |
---|
[10854] | 59 | } |
---|
[10856] | 60 | else if (this->myWingman_) |
---|
| 61 | { |
---|
| 62 | this->myWingman_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_); |
---|
| 63 | } |
---|
[10854] | 64 | for (size_t i = 0; i < this->actionpoints_.size(); ++i) |
---|
| 65 | { |
---|
| 66 | if(this->actionpoints_[i]) |
---|
| 67 | this->actionpoints_[i]->destroy(); |
---|
| 68 | } |
---|
| 69 | this->parsedActionpoints_.clear(); |
---|
| 70 | this->actionpoints_.clear(); |
---|
[10725] | 71 | } |
---|
[10731] | 72 | |
---|
[10826] | 73 | void DivisionController::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
---|
| 74 | { |
---|
| 75 | SUPER(DivisionController, XMLPort, xmlelement, mode); |
---|
| 76 | |
---|
| 77 | //XMLPortParam(DivisionController, "target_", setTarget, getTarget, xmlelement, mode).defaultValues(100.0f); |
---|
| 78 | } |
---|
[10725] | 79 | void DivisionController::tick(float dt) |
---|
[10803] | 80 | { |
---|
| 81 | if (!this->isActive()) |
---|
| 82 | return; |
---|
[10722] | 83 | SUPER(DivisionController, tick, dt); |
---|
[10678] | 84 | } |
---|
[10725] | 85 | void DivisionController::action() |
---|
[10854] | 86 | { |
---|
| 87 | CommonController::action(); |
---|
[10709] | 88 | } |
---|
[10854] | 89 | void DivisionController::stayNearProtect() |
---|
| 90 | { |
---|
| 91 | CommonController::stayNearProtect(); |
---|
| 92 | } |
---|
| 93 | |
---|
[10731] | 94 | bool DivisionController::setWingman(CommonController* cwingman) |
---|
| 95 | { |
---|
| 96 | |
---|
| 97 | WeakPtr<WingmanController> wingman = orxonox_cast<WingmanController*>(cwingman); |
---|
| 98 | if (!this->myWingman_) |
---|
| 99 | { |
---|
| 100 | this->myWingman_ = wingman; |
---|
| 101 | return true; |
---|
| 102 | } |
---|
| 103 | else |
---|
| 104 | { |
---|
| 105 | return false; |
---|
| 106 | } |
---|
| 107 | } |
---|
| 108 | bool DivisionController::setFollower(LeaderController* myFollower) |
---|
| 109 | { |
---|
| 110 | if (!this->myFollower_) |
---|
| 111 | { |
---|
| 112 | this->myFollower_ = myFollower; |
---|
| 113 | return true; |
---|
| 114 | } |
---|
| 115 | else |
---|
| 116 | { |
---|
| 117 | return false; |
---|
| 118 | } |
---|
| 119 | } |
---|
| 120 | bool DivisionController::hasWingman() |
---|
| 121 | { |
---|
| 122 | if (this->myWingman_) |
---|
| 123 | return true; |
---|
| 124 | else |
---|
| 125 | return false; |
---|
| 126 | } |
---|
| 127 | bool DivisionController::hasFollower() |
---|
| 128 | { |
---|
| 129 | if (this->myFollower_) |
---|
| 130 | return true; |
---|
| 131 | else |
---|
| 132 | return false; |
---|
| 133 | } |
---|
[10678] | 134 | } |
---|