Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/questsystem5/src/orxonox/objects/controllers/HumanController.cc @ 2908

Last change on this file since 2908 was 2908, checked in by dafrick, 16 years ago

Reverted to revision 2906 (because I'm too stupid to merge correctly, 2nd try will follow shortly. ;))

  • Property svn:eol-style set to native
File size: 7.3 KB
RevLine 
[2072]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 *      ...
26 *
27 */
28
29#include "OrxonoxStableHeaders.h"
30#include "HumanController.h"
31
32#include "core/CoreIncludes.h"
33#include "core/ConsoleCommand.h"
34#include "objects/worldentities/ControllableEntity.h"
[2662]35#include "objects/worldentities/pawns/Pawn.h"
36#include "objects/gametypes/Gametype.h"
[2072]37
38namespace orxonox
39{
40    SetConsoleCommand(HumanController, moveFrontBack, true).setAsInputCommand();
41    SetConsoleCommand(HumanController, moveRightLeft, true).setAsInputCommand();
42    SetConsoleCommand(HumanController, moveUpDown,    true).setAsInputCommand();
43    SetConsoleCommand(HumanController, rotateYaw,     true).setAsInputCommand();
44    SetConsoleCommand(HumanController, rotatePitch,   true).setAsInputCommand();
45    SetConsoleCommand(HumanController, rotateRoll,    true).setAsInputCommand();
46    SetConsoleCommand(HumanController, fire,          true).keybindMode(KeybindMode::OnHold);
47    SetConsoleCommand(HumanController, altFire,       true).keybindMode(KeybindMode::OnHold);
[2662]48    SetConsoleCommand(HumanController, boost,         true).keybindMode(KeybindMode::OnHold);
[2072]49    SetConsoleCommand(HumanController, greet,         true);
50    SetConsoleCommand(HumanController, use,           true);
51    SetConsoleCommand(HumanController, switchCamera,  true);
[2662]52    SetConsoleCommand(HumanController, mouseLook,     true);
53    SetConsoleCommand(HumanController, suicide,       true);
54    SetConsoleCommand(HumanController, addBots,       true).defaultValues(1);
55    SetConsoleCommand(HumanController, killBots,      true).defaultValues(0);
56    SetConsoleCommand(HumanController, dropItems,     true);
[2072]57
58    CreateUnloadableFactory(HumanController);
59
60    HumanController* HumanController::localController_s = 0;
61
62    HumanController::HumanController(BaseObject* creator) : Controller(creator)
63    {
64        RegisterObject(HumanController);
65
66        HumanController::localController_s = this;
67    }
68
69    HumanController::~HumanController()
70    {
71        HumanController::localController_s = 0;
72    }
73
74    void HumanController::moveFrontBack(const Vector2& value)
75    {
76        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
77            HumanController::localController_s->controllableEntity_->moveFrontBack(value);
78    }
79
80    void HumanController::moveRightLeft(const Vector2& value)
81    {
82        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
83            HumanController::localController_s->controllableEntity_->moveRightLeft(value);
84    }
85
86    void HumanController::moveUpDown(const Vector2& value)
87    {
88        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
89            HumanController::localController_s->controllableEntity_->moveUpDown(value);
90    }
91
92    void HumanController::rotateYaw(const Vector2& value)
93    {
94        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
95            HumanController::localController_s->controllableEntity_->rotateYaw(value);
96    }
97
98    void HumanController::rotatePitch(const Vector2& value)
99    {
100        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
101            HumanController::localController_s->controllableEntity_->rotatePitch(value);
102    }
103
104    void HumanController::rotateRoll(const Vector2& value)
105    {
106        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
107            HumanController::localController_s->controllableEntity_->rotateRoll(value);
108    }
109
110    void HumanController::fire()
111    {
112        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
[2662]113            HumanController::localController_s->controllableEntity_->fire(WeaponMode::fire);
[2072]114    }
115
116    void HumanController::altFire()
117    {
118        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
[2662]119            HumanController::localController_s->controllableEntity_->fire(WeaponMode::altFire);
[2072]120    }
121
[2662]122    void HumanController::boost()
123    {
124        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
125            HumanController::localController_s->controllableEntity_->boost();
126    }
127
[2072]128    void HumanController::greet()
129    {
130        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
131            HumanController::localController_s->controllableEntity_->greet();
132    }
133
134    void HumanController::use()
135    {
136        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
137            HumanController::localController_s->controllableEntity_->use();
138    }
139
140    void HumanController::switchCamera()
141    {
142        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
143            HumanController::localController_s->controllableEntity_->switchCamera();
144    }
[2662]145
146    void HumanController::mouseLook()
147    {
148        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
149            HumanController::localController_s->controllableEntity_->mouseLook();
150    }
151
152    void HumanController::suicide()
153    {
154        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
155        {
156            Pawn* pawn = dynamic_cast<Pawn*>(HumanController::localController_s->controllableEntity_);
157            if (pawn)
158                pawn->kill();
159        }
160    }
161
162    void HumanController::addBots(unsigned int amount)
163    {
164        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && HumanController::localController_s->controllableEntity_->getGametype())
165            HumanController::localController_s->controllableEntity_->getGametype()->addBots(amount);
166    }
167
168    void HumanController::killBots(unsigned int amount)
169    {
170        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && HumanController::localController_s->controllableEntity_->getGametype())
171            HumanController::localController_s->controllableEntity_->getGametype()->killBots(amount);
172    }
173
174    void HumanController::dropItems()
175    {
176        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
177            HumanController::localController_s->controllableEntity_->dropItems();
178    }
[2072]179}
Note: See TracBrowser for help on using the repository browser.