Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/cpp11_v3/src/orxonox/controllers/DivisionController.cc @ 11057

Last change on this file since 11057 was 11057, checked in by landauf, 8 years ago

removed empty XMLPort functions

  • Property svn:eol-style set to native
File size: 4.2 KB
Line 
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 *      Gani Aliguzhinov
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#include "DivisionController.h"
30#include "infos/PlayerInfo.h"
31
32namespace orxonox
33{
34
35    RegisterClass(DivisionController);
36
37    //Leaders share the fact that they have Wingmans
38    DivisionController::DivisionController(Context* context) : ActionpointController(context)
39    {
40        RegisterObject(DivisionController);
41        this->setFormationMode(FormationMode::DIAMOND);
42        this->target_ = 0;
43        this->myFollower_ = 0;
44        this->myWingman_ = 0;
45    }
46
47    DivisionController::~DivisionController()
48    {
49        for (size_t i = 0; i < this->actionpoints_.size(); ++i)
50        {
51            if(this->actionpoints_[i])
52                this->actionpoints_[i]->destroy();
53        }
54        this->parsedActionpoints_.clear();
55        this->actionpoints_.clear();
56    } 
57    void DivisionController::tick(float dt)
58    {   
59        if (!this->isActive())
60            return;   
61       
62        SUPER(DivisionController, tick, dt);
63       
64    }
65    void DivisionController::action()
66    {   
67        if (!this || !this->getControllableEntity() || !this->isActive())
68            return;
69       
70        ActionpointController::action();
71        if (!this || !this->getControllableEntity())
72            return;
73        if (!(this->parsedActionpoints_.empty() && this->loopActionpoints_.empty()))
74        {
75            //when this dies, its follower will execute all its actionpoints, if follower dies before this, wingman will do this
76            if (this->myFollower_)
77            {
78                this->myFollower_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_);
79            }
80            else if (this->myWingman_)
81            {
82                this->myWingman_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_);
83            }   
84        }
85
86       
87    }
88    //I wanted to do it different here, but at this point I think nothing will change if I delete that method
89    void DivisionController::stayNearProtect()
90    {
91        ActionpointController::stayNearProtect();
92    }
93   
94    bool DivisionController::setWingman(ActionpointController* newWingman)
95    {
96        if (!this->myWingman_)
97        {
98            this->myWingman_ = newWingman;
99            if (!this->hasFollower())
100                newWingman->takeActionpoints (this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_);
101            return true;
102        }
103        else
104        {
105            return false;
106        }
107    }
108    bool DivisionController::setFollower(ActionpointController* newFollower)
109    {
110        if (!this->myFollower_)
111        {
112            this->myFollower_ = newFollower;
113            if (this->hasWingman())
114            {
115                this->myWingman_->takeActionpoints (std::vector<Point>(), std::vector<Point>(), false);
116            }
117
118            newFollower->takeActionpoints (this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_);
119           
120            return true;
121        }
122        else
123        {
124            return false;
125        }
126    }
127    bool DivisionController::hasWingman()
128    {
129        if (this->myWingman_)
130            return true;
131        else
132            return false;
133    }
134    bool DivisionController::hasFollower()
135    {
136        if (this->myFollower_)
137            return true;
138       
139        return false;
140    }
141
142}
Note: See TracBrowser for help on using the repository browser.