Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/objects/controllers/HumanController.cc @ 2255

Last change on this file since 2255 was 2087, checked in by landauf, 16 years ago

merged objecthierarchy branch back to trunk

  • Property svn:eol-style set to native
File size: 5.1 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
36namespace orxonox
37{
38    SetConsoleCommand(HumanController, moveFrontBack, true).setAsInputCommand();
39    SetConsoleCommand(HumanController, moveRightLeft, true).setAsInputCommand();
40    SetConsoleCommand(HumanController, moveUpDown,    true).setAsInputCommand();
41    SetConsoleCommand(HumanController, rotateYaw,     true).setAsInputCommand();
42    SetConsoleCommand(HumanController, rotatePitch,   true).setAsInputCommand();
43    SetConsoleCommand(HumanController, rotateRoll,    true).setAsInputCommand();
44    SetConsoleCommand(HumanController, fire,          true).keybindMode(KeybindMode::OnHold);
45    SetConsoleCommand(HumanController, altFire,       true).keybindMode(KeybindMode::OnHold);
46    SetConsoleCommand(HumanController, greet,         true);
47    SetConsoleCommand(HumanController, use,           true);
48    SetConsoleCommand(HumanController, switchCamera,  true);
49
50    CreateUnloadableFactory(HumanController);
51
52    HumanController* HumanController::localController_s = 0;
53
54    HumanController::HumanController(BaseObject* creator) : Controller(creator)
55    {
56        RegisterObject(HumanController);
57
58        HumanController::localController_s = this;
59    }
60
61    HumanController::~HumanController()
62    {
63        HumanController::localController_s = 0;
64    }
65
66    void HumanController::moveFrontBack(const Vector2& value)
67    {
68        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
69            HumanController::localController_s->controllableEntity_->moveFrontBack(value);
70    }
71
72    void HumanController::moveRightLeft(const Vector2& value)
73    {
74        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
75            HumanController::localController_s->controllableEntity_->moveRightLeft(value);
76    }
77
78    void HumanController::moveUpDown(const Vector2& value)
79    {
80        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
81            HumanController::localController_s->controllableEntity_->moveUpDown(value);
82    }
83
84    void HumanController::rotateYaw(const Vector2& value)
85    {
86        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
87            HumanController::localController_s->controllableEntity_->rotateYaw(value);
88    }
89
90    void HumanController::rotatePitch(const Vector2& value)
91    {
92        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
93            HumanController::localController_s->controllableEntity_->rotatePitch(value);
94    }
95
96    void HumanController::rotateRoll(const Vector2& value)
97    {
98        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
99            HumanController::localController_s->controllableEntity_->rotateRoll(value);
100    }
101
102    void HumanController::fire()
103    {
104        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
105            HumanController::localController_s->controllableEntity_->fire();
106    }
107
108    void HumanController::altFire()
109    {
110        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
111            HumanController::localController_s->controllableEntity_->altFire();
112    }
113
114    void HumanController::greet()
115    {
116        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
117            HumanController::localController_s->controllableEntity_->greet();
118    }
119
120    void HumanController::use()
121    {
122        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
123            HumanController::localController_s->controllableEntity_->use();
124    }
125
126    void HumanController::switchCamera()
127    {
128        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
129            HumanController::localController_s->controllableEntity_->switchCamera();
130    }
131}
Note: See TracBrowser for help on using the repository browser.