Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/objecthierarchy/src/orxonox/objects/controllers/HumanController.cc @ 2041

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

bugs—
network++
endurance—
tiredness++

but it still doesn't work properly
(commit because oli is very impatient)

File size: 5.3 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        COUT(0) << "HumanController created" << std::endl;
61    }
62
63    HumanController::~HumanController()
64    {
65        HumanController::localController_s = 0;
66    }
67
68    void HumanController::moveFrontBack(const Vector2& value)
69    {
70        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
71            HumanController::localController_s->controllableEntity_->moveFrontBack(value);
72    }
73
74    void HumanController::moveRightLeft(const Vector2& value)
75    {
76        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
77            HumanController::localController_s->controllableEntity_->moveRightLeft(value);
78    }
79
80    void HumanController::moveUpDown(const Vector2& value)
81    {
82        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
83            HumanController::localController_s->controllableEntity_->moveUpDown(value);
84    }
85
86    void HumanController::rotateYaw(const Vector2& value)
87    {
88        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
89            HumanController::localController_s->controllableEntity_->rotateYaw(value);
90    }
91
92    void HumanController::rotatePitch(const Vector2& value)
93    {
94        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
95            HumanController::localController_s->controllableEntity_->rotatePitch(value);
96    }
97
98    void HumanController::rotateRoll(const Vector2& value)
99    {
100        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
101            HumanController::localController_s->controllableEntity_->rotateRoll(value);
102    }
103
104    void HumanController::fire()
105    {
106        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
107            HumanController::localController_s->controllableEntity_->fire();
108    }
109
110    void HumanController::altFire()
111    {
112        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
113            HumanController::localController_s->controllableEntity_->altFire();
114    }
115
116    void HumanController::greet()
117    {
118        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
119            HumanController::localController_s->controllableEntity_->greet();
120    }
121
122    void HumanController::use()
123    {
124        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
125            HumanController::localController_s->controllableEntity_->use();
126    }
127
128    void HumanController::switchCamera()
129    {
130        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
131            HumanController::localController_s->controllableEntity_->switchCamera();
132    }
133}
Note: See TracBrowser for help on using the repository browser.