Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/objecthierarchy2/src/orxonox/objects/controllers/HumanController.cc @ 2518

Last change on this file since 2518 was 2478, checked in by landauf, 16 years ago
  • Readded smooth camera movement (configurable through CameraPosition), works also with camera-position-changes
  • Added free mouse look (press left control key)
  • Made strength of boost-blur configurable
  • Property svn:eol-style set to native
File size: 7.0 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 *      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"
35#include "objects/worldentities/pawns/Pawn.h"
36#include "objects/gametypes/Gametype.h"
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);
48    SetConsoleCommand(HumanController, boost,         true).keybindMode(KeybindMode::OnHold);
49    SetConsoleCommand(HumanController, greet,         true);
50    SetConsoleCommand(HumanController, use,           true);
51    SetConsoleCommand(HumanController, switchCamera,  true);
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
57    CreateUnloadableFactory(HumanController);
58
59    HumanController* HumanController::localController_s = 0;
60
61    HumanController::HumanController(BaseObject* creator) : Controller(creator)
62    {
63        RegisterObject(HumanController);
64
65        HumanController::localController_s = this;
66    }
67
68    HumanController::~HumanController()
69    {
70        HumanController::localController_s = 0;
71    }
72
73    void HumanController::moveFrontBack(const Vector2& value)
74    {
75        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
76            HumanController::localController_s->controllableEntity_->moveFrontBack(value);
77    }
78
79    void HumanController::moveRightLeft(const Vector2& value)
80    {
81        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
82            HumanController::localController_s->controllableEntity_->moveRightLeft(value);
83    }
84
85    void HumanController::moveUpDown(const Vector2& value)
86    {
87        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
88            HumanController::localController_s->controllableEntity_->moveUpDown(value);
89    }
90
91    void HumanController::rotateYaw(const Vector2& value)
92    {
93        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
94            HumanController::localController_s->controllableEntity_->rotateYaw(value);
95    }
96
97    void HumanController::rotatePitch(const Vector2& value)
98    {
99        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
100            HumanController::localController_s->controllableEntity_->rotatePitch(value);
101    }
102
103    void HumanController::rotateRoll(const Vector2& value)
104    {
105        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
106            HumanController::localController_s->controllableEntity_->rotateRoll(value);
107    }
108
109    void HumanController::fire()
110    {
111        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
112            HumanController::localController_s->controllableEntity_->fire();
113    }
114
115    void HumanController::altFire()
116    {
117        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
118            HumanController::localController_s->controllableEntity_->altFire();
119    }
120
121    void HumanController::boost()
122    {
123        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
124            HumanController::localController_s->controllableEntity_->boost();
125    }
126
127    void HumanController::greet()
128    {
129        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
130            HumanController::localController_s->controllableEntity_->greet();
131    }
132
133    void HumanController::use()
134    {
135        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
136            HumanController::localController_s->controllableEntity_->use();
137    }
138
139    void HumanController::switchCamera()
140    {
141        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
142            HumanController::localController_s->controllableEntity_->switchCamera();
143    }
144
145    void HumanController::mouseLook()
146    {
147        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
148            HumanController::localController_s->controllableEntity_->mouseLook();
149    }
150
151    void HumanController::suicide()
152    {
153        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
154        {
155            Pawn* pawn = dynamic_cast<Pawn*>(HumanController::localController_s->controllableEntity_);
156            if (pawn)
157                pawn->kill();
158        }
159    }
160
161    void HumanController::addBots(unsigned int amount)
162    {
163        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && HumanController::localController_s->controllableEntity_->getGametype())
164            HumanController::localController_s->controllableEntity_->getGametype()->addBots(amount);
165    }
166
167    void HumanController::killBots(unsigned int amount)
168    {
169        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && HumanController::localController_s->controllableEntity_->getGametype())
170            HumanController::localController_s->controllableEntity_->getGametype()->killBots(amount);
171    }
172}
Note: See TracBrowser for help on using the repository browser.