[5979] | 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 "NewHumanController.h" |
---|
| 30 | |
---|
| 31 | #include "core/CoreIncludes.h" |
---|
| 32 | #include "core/ConsoleCommand.h" |
---|
| 33 | #include "worldentities/ControllableEntity.h" |
---|
| 34 | #include "worldentities/pawns/Pawn.h" |
---|
| 35 | #include "gametypes/Gametype.h" |
---|
| 36 | #include "infos/PlayerInfo.h" |
---|
| 37 | #include "overlays/Map.h" |
---|
| 38 | #include "graphics/Camera.h" |
---|
| 39 | #include "sound/SoundManager.h" |
---|
| 40 | #include "Radar.h" |
---|
| 41 | #include "Scene.h" |
---|
| 42 | |
---|
| 43 | namespace orxonox |
---|
| 44 | { |
---|
| 45 | SetConsoleCommand(NewHumanController, moveFrontBack, true).setAsInputCommand(); |
---|
| 46 | SetConsoleCommand(NewHumanController, moveRightLeft, true).setAsInputCommand(); |
---|
| 47 | SetConsoleCommand(NewHumanController, moveUpDown, true).setAsInputCommand(); |
---|
| 48 | SetConsoleCommand(NewHumanController, rotateYaw, true).setAsInputCommand(); |
---|
| 49 | SetConsoleCommand(NewHumanController, rotatePitch, true).setAsInputCommand(); |
---|
| 50 | SetConsoleCommand(NewHumanController, rotateRoll, true).setAsInputCommand(); |
---|
| 51 | SetConsoleCommand(NewHumanController, fire, true).keybindMode(KeybindMode::OnHold); |
---|
| 52 | SetConsoleCommand(NewHumanController, reload, true); |
---|
| 53 | SetConsoleCommand(NewHumanController, boost, true).keybindMode(KeybindMode::OnHold); |
---|
| 54 | SetConsoleCommand(NewHumanController, greet, true); |
---|
| 55 | SetConsoleCommand(NewHumanController, switchCamera, true); |
---|
| 56 | SetConsoleCommand(NewHumanController, mouseLook, true); |
---|
| 57 | SetConsoleCommand(NewHumanController, suicide, true); |
---|
| 58 | SetConsoleCommand(NewHumanController, addBots, true).defaultValues(1); |
---|
| 59 | SetConsoleCommand(NewHumanController, killBots, true).defaultValues(0); |
---|
| 60 | SetConsoleCommand(NewHumanController, dropItems, true); |
---|
| 61 | SetConsoleCommand(NewHumanController, useItem, true); |
---|
| 62 | SetConsoleCommand(NewHumanController, cycleNavigationFocus, true); |
---|
| 63 | SetConsoleCommand(NewHumanController, releaseNavigationFocus, true); |
---|
| 64 | |
---|
| 65 | CreateUnloadableFactory(NewHumanController); |
---|
| 66 | |
---|
| 67 | NewHumanController* NewHumanController::localController_s = 0; |
---|
| 68 | |
---|
| 69 | NewHumanController::NewHumanController(BaseObject* creator) : HumanController(creator) |
---|
| 70 | { |
---|
| 71 | RegisterObject(NewHumanController); |
---|
| 72 | |
---|
| 73 | NewHumanController::localController_s = this; |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | NewHumanController::~NewHumanController() |
---|
| 77 | { |
---|
| 78 | NewHumanController::localController_s = 0; |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | void NewHumanController::tick(float dt) |
---|
| 82 | { |
---|
| 83 | if (GameMode::playsSound() && NewHumanController::localController_s && NewHumanController::localController_s->controllableEntity_) |
---|
| 84 | { |
---|
| 85 | // Update sound listener |
---|
| 86 | Camera* camera = NewHumanController::localController_s->controllableEntity_->getCamera(); |
---|
| 87 | if (camera) |
---|
| 88 | { |
---|
| 89 | SoundManager::getInstance().setListenerPosition(camera->getWorldPosition()); |
---|
| 90 | SoundManager::getInstance().setListenerOrientation(camera->getWorldOrientation()); |
---|
| 91 | } |
---|
| 92 | else |
---|
| 93 | COUT(3) << "NewHumanController, Warning: Using a ControllableEntity without Camera" << std::endl; |
---|
| 94 | } |
---|
| 95 | } |
---|
| 96 | |
---|
| 97 | } |
---|