Changeset 6412 for code/branches/pickup2/src/orxonox/controllers
- Timestamp:
- Dec 25, 2009, 1:18:03 PM (15 years ago)
- Location:
- code/branches/pickup2
- Files:
-
- 8 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pickup2
- Property svn:mergeinfo changed
-
code/branches/pickup2/src/orxonox/controllers/ArtificialController.cc
r5929 r6412 46 46 this->bHasTargetPosition_ = false; 47 47 this->targetPosition_ = Vector3::ZERO; 48 48 49 49 this->target_.setCallback(createFunctor(&ArtificialController::targetDied, this)); 50 50 } … … 143 143 this->targetPosition_ = getPredictedPosition(this->getControllableEntity()->getPosition(), hardcoded_projectile_speed, this->target_->getPosition(), this->target_->getVelocity()); 144 144 this->bHasTargetPosition_ = (this->targetPosition_ != Vector3::ZERO); 145 146 Pawn* pawn = dynamic_cast<Pawn*>(this->getControllableEntity()); 147 if (pawn) 148 pawn->setAimPosition(this->targetPosition_); 145 149 } 146 150 -
code/branches/pickup2/src/orxonox/controllers/ArtificialController.h
r5929 r6412 42 42 ArtificialController(BaseObject* creator); 43 43 virtual ~ArtificialController(); 44 44 45 45 void abandonTarget(Pawn* target); 46 46 -
code/branches/pickup2/src/orxonox/controllers/CMakeLists.txt
r5781 r6412 2 2 Controller.cc 3 3 HumanController.cc 4 NewHumanController.cc 4 5 ArtificialController.cc 5 6 AIController.cc -
code/branches/pickup2/src/orxonox/controllers/Controller.cc
r5781 r6412 29 29 #include "Controller.h" 30 30 #include "core/CoreIncludes.h" 31 #include "worldentities/ControllableEntity.h" 31 32 32 33 namespace orxonox … … 40 41 this->player_ = 0; 41 42 this->controllableEntity_ = 0; 43 this->bGodMode_ = false; 42 44 } 43 45 -
code/branches/pickup2/src/orxonox/controllers/Controller.h
r5781 r6412 37 37 class _OrxonoxExport Controller : public BaseObject 38 38 { 39 // set friend classes to access setControllableEntity 40 friend class PlayerInfo; 41 friend class ControllableEntity; 42 39 43 public: 40 44 Controller(BaseObject* creator); … … 46 50 { return this->player_; } 47 51 52 virtual inline void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage) {}; 53 54 void setGodMode( bool mode ){ this->bGodMode_ = mode; } 55 bool getGodMode(){ return this->bGodMode_; } 56 57 inline ControllableEntity* getControllableEntity() const 58 { return this->controllableEntity_; } 59 virtual void changedControllableEntity() {} 60 61 protected: 62 // don't use this directly, use getPlayer()->startControl(entity) (unless you know exactly what you do) 48 63 inline void setControllableEntity(ControllableEntity* entity) 49 64 { … … 54 69 } 55 70 } 56 inline ControllableEntity* getControllableEntity() const57 { return this->controllableEntity_; }58 virtual void changedControllableEntity() {}59 71 60 72 protected: 61 73 PlayerInfo* player_; 62 74 ControllableEntity* controllableEntity_; 75 private: 76 bool bGodMode_; 63 77 }; 64 78 } -
code/branches/pickup2/src/orxonox/controllers/HumanController.cc
r5929 r6412 36 36 #include "infos/PlayerInfo.h" 37 37 #include "overlays/Map.h" 38 #include "graphics/Camera.h"39 #include "sound/SoundManager.h"40 38 #include "Radar.h" 41 39 #include "Scene.h" … … 56 54 SetConsoleCommand(HumanController, mouseLook, true); 57 55 SetConsoleCommand(HumanController, suicide, true); 56 SetConsoleCommand(HumanController, toggleGodMode, true); 58 57 SetConsoleCommand(HumanController, addBots, true).defaultValues(1); 59 58 SetConsoleCommand(HumanController, killBots, true).defaultValues(0); … … 71 70 RegisterObject(HumanController); 72 71 72 controlPaused_ = false; 73 73 74 HumanController::localController_s = this; 74 75 } … … 83 84 if (GameMode::playsSound() && HumanController::localController_s && HumanController::localController_s->controllableEntity_) 84 85 { 85 // Update sound listener86 86 Camera* camera = HumanController::localController_s->controllableEntity_->getCamera(); 87 if (camera) 88 { 89 SoundManager::getInstance().setListenerPosition(camera->getWorldPosition()); 90 SoundManager::getInstance().setListenerOrientation(camera->getWorldOrientation()); 91 } 92 else 87 if (!camera) 93 88 COUT(3) << "HumanController, Warning: Using a ControllableEntity without Camera" << std::endl; 94 89 } … … 97 92 void HumanController::moveFrontBack(const Vector2& value) 98 93 { 94 if (HumanController::localController_s) 95 HumanController::localController_s->frontback(value); 96 } 97 98 void HumanController::frontback(const Vector2& value) 99 { 99 100 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 100 101 HumanController::localController_s->controllableEntity_->moveFrontBack(value); … … 113 114 } 114 115 115 void HumanController:: rotateYaw(const Vector2& value)116 void HumanController::yaw(const Vector2& value) 116 117 { 117 118 //Hack to enable mouselook in map … … 125 126 } 126 127 127 void HumanController:: rotatePitch(const Vector2& value)128 void HumanController::pitch(const Vector2& value) 128 129 { 129 130 //Hack to enable mouselook in map … … 137 138 } 138 139 140 void HumanController::rotateYaw(const Vector2& value) 141 { 142 if (HumanController::localController_s) 143 HumanController::localController_s->yaw(value); 144 } 145 146 void HumanController::rotatePitch(const Vector2& value) 147 { 148 if (HumanController::localController_s) 149 HumanController::localController_s->pitch(value); 150 } 151 139 152 void HumanController::rotateRoll(const Vector2& value) 140 153 { … … 144 157 145 158 void HumanController::fire(unsigned int firemode) 159 { 160 if (HumanController::localController_s) 161 HumanController::localController_s->doFire(firemode); 162 } 163 164 void HumanController::doFire(unsigned int firemode) 146 165 { 147 166 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) … … 191 210 } 192 211 212 void HumanController::toggleGodMode() 213 { 214 HumanController::getLocalControllerSingleton()->setGodMode( !HumanController::getLocalControllerSingleton()->getGodMode() ); 215 } 216 193 217 void HumanController::useItem() 194 218 { … … 234 258 HumanController::localController_s->controllableEntity_->getScene()->getRadar()->releaseFocus(); 235 259 } 260 261 void HumanController::pauseControl() 262 { 263 if (HumanController::localController_s) 264 HumanController::localController_s->doPauseControl(); 265 } 266 267 void HumanController::resumeControl() 268 { 269 if (HumanController::localController_s) 270 HumanController::localController_s->doResumeControl(); 271 } 236 272 } -
code/branches/pickup2/src/orxonox/controllers/HumanController.h
r5929 r6412 35 35 #include "Controller.h" 36 36 37 // tolua_begin 37 38 namespace orxonox 38 39 { 39 class _OrxonoxExport HumanController : public Controller, public Tickable 40 { 40 class _OrxonoxExport HumanController 41 // tolua_end 42 : public Controller, public Tickable 43 { // tolua_export 41 44 public: 42 45 HumanController(BaseObject* creator); … … 53 56 static void rotateRoll(const Vector2& value); 54 57 58 virtual void frontback(const Vector2& value); 59 virtual void yaw(const Vector2& value); 60 virtual void pitch(const Vector2& value); 61 55 62 static void fire(unsigned int firemode); 63 virtual void doFire(unsigned int firemode); 56 64 static void reload(); 57 65 … … 66 74 67 75 static void suicide(); 76 static void toggleGodMode(); 68 77 69 78 static void addBots(unsigned int amount); 70 79 static void killBots(unsigned int amount = 0); 80 81 static void pauseControl(); // tolua_export 82 static void resumeControl(); // tolua_export 83 virtual void doPauseControl() {}; 84 virtual void doResumeControl() {}; 71 85 72 86 static inline HumanController* getLocalControllerSingleton() … … 76 90 friend class Map; 77 91 78 pr ivate:92 protected: 79 93 static HumanController* localController_s; 80 }; 81 } 94 bool controlPaused_; 95 }; // tolua_export 96 } // tolua_export 82 97 83 98 #endif /* _HumanController_H__ */
Note: See TracChangeset
for help on using the changeset viewer.