Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc @ 10879

Last change on this file since 10879 was 10877, checked in by gania, 9 years ago

CommonController now has static methods only. Replace with a namespace?

File size: 4.2 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:
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
32namespace 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)));
[10678]47    }
48
49    DivisionController::~DivisionController()
50    {
[10854]51        for (size_t i = 0; i < this->actionpoints_.size(); ++i)
52        {
53            if(this->actionpoints_[i])
54                this->actionpoints_[i]->destroy();
55        }
56        this->parsedActionpoints_.clear();
57        this->actionpoints_.clear();
[10725]58    } 
[10731]59
[10826]60    void DivisionController::XMLPort(Element& xmlelement, XMLPort::Mode mode)
61    {
62        SUPER(DivisionController, XMLPort, xmlelement, mode);
63
64        //XMLPortParam(DivisionController, "target_", setTarget, getTarget, xmlelement, mode).defaultValues(100.0f);
65    }
[10725]66    void DivisionController::tick(float dt)
[10803]67    {   
68        if (!this->isActive())
[10861]69            return;   
[10722]70        SUPER(DivisionController, tick, dt);
[10678]71    }
[10725]72    void DivisionController::action()
[10854]73    {   
[10859]74        if (!this || !this->getControllableEntity())
75            return;
[10861]76       
[10864]77        ActionpointController::action();
[10861]78        if (!this || !this->getControllableEntity())
79            return;
80        if (!(this->parsedActionpoints_.empty() && this->loopActionpoints_.empty()))
81        {
82            if (this->myFollower_)
83            {
84                this->myFollower_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_);
85            }
86            else if (this->myWingman_)
87            {
88                this->myWingman_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_);
89            }   
90        }
[10859]91       
[10709]92    }
[10869]93    //I wanted to do it different here, but at this point I think nothing will change if I delete that method
[10854]94    void DivisionController::stayNearProtect()
95    {
[10864]96        ActionpointController::stayNearProtect();
[10854]97    }
98   
[10877]99    bool DivisionController::setWingman(ActionpointController* wingman)
[10731]100    {
101
[10877]102        WingmanController* newWingman = orxonox_cast<WingmanController*>(wingman);
[10731]103        if (!this->myWingman_)
104        {
[10877]105            this->myWingman_ = newWingman;
[10731]106            return true;
107        }
108        else
109        {
110            return false;
111        }
112    }
[10877]113    bool DivisionController::setFollower(ActionpointController* myFollower)
[10731]114    {
[10877]115        LeaderController* newFollower = orxonox_cast<LeaderController*> (myFollower);
116        if (!this->myFollower_)
[10731]117        {
[10877]118            this->myFollower_ = newFollower;
[10731]119            return true;
120        }
121        else
122        {
123            return false;
124        }
125    }
126    bool DivisionController::hasWingman()
127    {
128        if (this->myWingman_)
129            return true;
130        else
131            return false;
132    }
133    bool DivisionController::hasFollower()
134    {
135        if (this->myFollower_)
136            return true;
137        else
138            return false;
139    }
[10678]140}
Note: See TracBrowser for help on using the repository browser.