[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: |
---|
[10885] | 23 | * Gani Aliguzhinov |
---|
[10678] | 24 | * Co-authors: |
---|
[10885] | 25 | * ... |
---|
[10678] | 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 |
---|
[10886] | 38 | DivisionController::DivisionController(Context* context) : ActionpointController(context) |
---|
[10678] | 39 | { |
---|
| 40 | RegisterObject(DivisionController); |
---|
[10759] | 41 | this->setFormationMode(FormationMode::DIAMOND); |
---|
[10763] | 42 | this->target_ = 0; |
---|
[10725] | 43 | this->myFollower_ = 0; |
---|
| 44 | this->myWingman_ = 0; |
---|
[10909] | 45 | //this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&DivisionController::action, this))); |
---|
[10678] | 46 | } |
---|
| 47 | |
---|
| 48 | DivisionController::~DivisionController() |
---|
| 49 | { |
---|
[10854] | 50 | for (size_t i = 0; i < this->actionpoints_.size(); ++i) |
---|
| 51 | { |
---|
| 52 | if(this->actionpoints_[i]) |
---|
| 53 | this->actionpoints_[i]->destroy(); |
---|
| 54 | } |
---|
| 55 | this->parsedActionpoints_.clear(); |
---|
| 56 | this->actionpoints_.clear(); |
---|
[10725] | 57 | } |
---|
[10731] | 58 | |
---|
[10826] | 59 | void DivisionController::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
---|
| 60 | { |
---|
| 61 | SUPER(DivisionController, XMLPort, xmlelement, mode); |
---|
[10912] | 62 | |
---|
[10826] | 63 | //XMLPortParam(DivisionController, "target_", setTarget, getTarget, xmlelement, mode).defaultValues(100.0f); |
---|
| 64 | } |
---|
[10725] | 65 | void DivisionController::tick(float dt) |
---|
[10803] | 66 | { |
---|
| 67 | if (!this->isActive()) |
---|
[10861] | 68 | return; |
---|
[10722] | 69 | SUPER(DivisionController, tick, dt); |
---|
[10923] | 70 | /*if (this->timeOffset_ >= 0.0f && this->timeOffset_ <= 0.8f && !this->bActionCalled_) |
---|
[10909] | 71 | { |
---|
| 72 | this->action(); |
---|
| 73 | this->bActionCalled_ = true; |
---|
| 74 | } |
---|
[10915] | 75 | if (this->timeOffset_ > 1.6f) |
---|
[10909] | 76 | { |
---|
| 77 | this->bActionCalled_ = false; |
---|
[10923] | 78 | }*/ |
---|
[10909] | 79 | |
---|
| 80 | |
---|
[10678] | 81 | } |
---|
[10725] | 82 | void DivisionController::action() |
---|
[10854] | 83 | { |
---|
[10859] | 84 | if (!this || !this->getControllableEntity()) |
---|
| 85 | return; |
---|
[10861] | 86 | |
---|
[10864] | 87 | ActionpointController::action(); |
---|
[10861] | 88 | if (!this || !this->getControllableEntity()) |
---|
| 89 | return; |
---|
| 90 | if (!(this->parsedActionpoints_.empty() && this->loopActionpoints_.empty())) |
---|
| 91 | { |
---|
| 92 | if (this->myFollower_) |
---|
| 93 | { |
---|
| 94 | this->myFollower_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_); |
---|
| 95 | } |
---|
| 96 | else if (this->myWingman_) |
---|
| 97 | { |
---|
| 98 | this->myWingman_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_); |
---|
| 99 | } |
---|
| 100 | } |
---|
[10915] | 101 | |
---|
[10859] | 102 | |
---|
[10709] | 103 | } |
---|
[10869] | 104 | //I wanted to do it different here, but at this point I think nothing will change if I delete that method |
---|
[10854] | 105 | void DivisionController::stayNearProtect() |
---|
| 106 | { |
---|
[10864] | 107 | ActionpointController::stayNearProtect(); |
---|
[10854] | 108 | } |
---|
| 109 | |
---|
[10885] | 110 | bool DivisionController::setWingman(ActionpointController* newWingman) |
---|
[10731] | 111 | { |
---|
| 112 | if (!this->myWingman_) |
---|
| 113 | { |
---|
[10877] | 114 | this->myWingman_ = newWingman; |
---|
[10885] | 115 | if (!this->hasFollower()) |
---|
| 116 | newWingman->takeActionpoints (this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_); |
---|
[10731] | 117 | return true; |
---|
| 118 | } |
---|
| 119 | else |
---|
| 120 | { |
---|
| 121 | return false; |
---|
| 122 | } |
---|
| 123 | } |
---|
[10885] | 124 | bool DivisionController::setFollower(ActionpointController* newFollower) |
---|
[10731] | 125 | { |
---|
[10877] | 126 | if (!this->myFollower_) |
---|
[10731] | 127 | { |
---|
[10877] | 128 | this->myFollower_ = newFollower; |
---|
[10882] | 129 | if (this->hasWingman()) |
---|
| 130 | { |
---|
| 131 | this->myWingman_->takeActionpoints (std::vector<Point>(), std::vector<Point>(), false); |
---|
| 132 | } |
---|
[10885] | 133 | |
---|
| 134 | newFollower->takeActionpoints (this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_); |
---|
| 135 | |
---|
[10731] | 136 | return true; |
---|
| 137 | } |
---|
| 138 | else |
---|
| 139 | { |
---|
| 140 | return false; |
---|
| 141 | } |
---|
| 142 | } |
---|
| 143 | bool DivisionController::hasWingman() |
---|
| 144 | { |
---|
| 145 | if (this->myWingman_) |
---|
| 146 | return true; |
---|
| 147 | else |
---|
| 148 | return false; |
---|
| 149 | } |
---|
| 150 | bool DivisionController::hasFollower() |
---|
| 151 | { |
---|
| 152 | if (this->myFollower_) |
---|
| 153 | return true; |
---|
[10882] | 154 | |
---|
| 155 | return false; |
---|
[10731] | 156 | } |
---|
[10915] | 157 | |
---|
[10678] | 158 | } |
---|