Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/controllers/DivisionController.cc @ 12012

Last change on this file since 12012 was 11083, checked in by muemart, 9 years ago

Fix some clang-tidy warnings.
Also, Serialise.h was doing some C-style casts that ended up being const casts. I moved those const casts as close to the source as possible and changed the loadAndIncrease functions to not do that.

  • Property svn:eol-style set to native
File size: 3.9 KB
RevLine 
[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
32namespace 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);
[11071]42        this->target_ = nullptr;
43        this->myFollower_ = nullptr;
44        this->myWingman_ = nullptr;
[10678]45    }
46
47    DivisionController::~DivisionController()
48    {
[11071]49        for (WorldEntity* actionpoint : this->actionpoints_)
[10854]50        {
[11071]51            if (actionpoint)
52                actionpoint->destroy();
[10854]53        }
54        this->parsedActionpoints_.clear();
55        this->actionpoints_.clear();
[10725]56    } 
57    void DivisionController::action()
[10854]58    {   
[11083]59        if (!this->getControllableEntity() || !this->isActive())
[10859]60            return;
[10861]61       
[10864]62        ActionpointController::action();
[10861]63        if (!(this->parsedActionpoints_.empty() && this->loopActionpoints_.empty()))
64        {
[10974]65            //when this dies, its follower will execute all its actionpoints, if follower dies before this, wingman will do this
[10861]66            if (this->myFollower_)
67            {
68                this->myFollower_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_);
69            }
70            else if (this->myWingman_)
71            {
72                this->myWingman_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_);
73            }   
74        }
[10915]75
[10859]76       
[10709]77    }
[10869]78    //I wanted to do it different here, but at this point I think nothing will change if I delete that method
[10854]79    void DivisionController::stayNearProtect()
80    {
[10864]81        ActionpointController::stayNearProtect();
[10854]82    }
83   
[10885]84    bool DivisionController::setWingman(ActionpointController* newWingman)
[10731]85    {
86        if (!this->myWingman_)
87        {
[10877]88            this->myWingman_ = newWingman;
[10885]89            if (!this->hasFollower())
90                newWingman->takeActionpoints (this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_);
[10731]91            return true;
92        }
93        else
94        {
95            return false;
96        }
97    }
[10885]98    bool DivisionController::setFollower(ActionpointController* newFollower)
[10731]99    {
[10877]100        if (!this->myFollower_)
[10731]101        {
[10877]102            this->myFollower_ = newFollower;
[10882]103            if (this->hasWingman())
104            {
105                this->myWingman_->takeActionpoints (std::vector<Point>(), std::vector<Point>(), false);
106            }
[10885]107
108            newFollower->takeActionpoints (this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_);
109           
[10731]110            return true;
111        }
112        else
113        {
114            return false;
115        }
116    }
117    bool DivisionController::hasWingman()
118    {
119        if (this->myWingman_)
120            return true;
121        else
122            return false;
123    }
124    bool DivisionController::hasFollower()
125    {
126        if (this->myFollower_)
127            return true;
[10882]128       
129        return false;
[10731]130    }
[10915]131
[10678]132}
Note: See TracBrowser for help on using the repository browser.