- Timestamp:
- Dec 16, 2008, 6:01:13 PM (16 years ago)
- Location:
- code/branches/presentation
- Files:
-
- 6 edited
- 6 copied
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation
-
code/branches/presentation/src/orxonox/objects/controllers/CMakeLists.txt
r2131 r2485 2 2 Controller.cc 3 3 HumanController.cc 4 ArtificialController.cc 5 AIController.cc 6 ScriptController.cc 4 7 ) 5 8 -
code/branches/presentation/src/orxonox/objects/controllers/Controller.cc
r2087 r2485 31 31 32 32 #include "core/CoreIncludes.h" 33 #include "overlays/OverlayGroup.h" 33 34 34 35 namespace orxonox … … 42 43 this->player_ = 0; 43 44 this->controllableEntity_ = 0; 45 this->hud_ = 0; 46 this->bUpdateHUD_ = false; 44 47 } 45 48 46 49 Controller::~Controller() 47 50 { 51 if (this->isInitialized() && this->hud_) 52 delete this->hud_; 53 } 54 55 void Controller::changedControllableEntity() 56 { 57 if (this->bUpdateHUD_) 58 { 59 this->updateHUD(); 60 this->bUpdateHUD_ = false; 61 } 62 63 if (this->hud_) 64 this->hud_->setOwner(this->getControllableEntity()); 65 } 66 67 void Controller::updateHUD() 68 { 69 if (this->hud_) 70 { 71 delete this->hud_; 72 this->hud_ = 0; 73 } 74 75 if (this->hudtemplate_ != "") 76 { 77 this->hud_ = new OverlayGroup(this); 78 this->hud_->addTemplate(this->hudtemplate_); 79 this->hud_->setOwner(this->getControllableEntity()); 80 } 48 81 } 49 82 } -
code/branches/presentation/src/orxonox/objects/controllers/Controller.h
r2087 r2485 47 47 { return this->player_; } 48 48 49 virtual inline void setControllableEntity(ControllableEntity* entity) 50 { this->controllableEntity_ = entity; } 51 virtual inline ControllableEntity* getControllableEntity() const 49 inline void setControllableEntity(ControllableEntity* entity) 50 { 51 if (entity != this->controllableEntity_) 52 { 53 this->controllableEntity_ = entity; 54 this->changedControllableEntity(); 55 } 56 } 57 inline ControllableEntity* getControllableEntity() const 52 58 { return this->controllableEntity_; } 59 virtual void changedControllableEntity(); 60 61 inline void setHUDTemplate(const std::string& name) 62 { 63 if (name != this->hudtemplate_) 64 { 65 this->hudtemplate_ = name; 66 if (this->controllableEntity_) 67 this->updateHUD(); 68 else 69 this->bUpdateHUD_ = true; 70 } 71 } 72 inline const std::string& getHUDTemplate() const 73 { return this->hudtemplate_; } 74 75 inline OverlayGroup* getHUD() const 76 { return this->hud_; } 53 77 54 78 protected: 79 void updateHUD(); 80 55 81 PlayerInfo* player_; 56 82 ControllableEntity* controllableEntity_; 83 std::string hudtemplate_; 84 OverlayGroup* hud_; 85 bool bUpdateHUD_; 57 86 }; 58 87 } -
code/branches/presentation/src/orxonox/objects/controllers/HumanController.cc
r2087 r2485 33 33 #include "core/ConsoleCommand.h" 34 34 #include "objects/worldentities/ControllableEntity.h" 35 #include "objects/worldentities/pawns/Pawn.h" 36 #include "objects/gametypes/Gametype.h" 35 37 36 38 namespace orxonox … … 44 46 SetConsoleCommand(HumanController, fire, true).keybindMode(KeybindMode::OnHold); 45 47 SetConsoleCommand(HumanController, altFire, true).keybindMode(KeybindMode::OnHold); 48 SetConsoleCommand(HumanController, boost, true).keybindMode(KeybindMode::OnHold); 46 49 SetConsoleCommand(HumanController, greet, true); 47 50 SetConsoleCommand(HumanController, use, true); 48 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); 49 56 50 57 CreateUnloadableFactory(HumanController); … … 112 119 } 113 120 121 void HumanController::boost() 122 { 123 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 124 HumanController::localController_s->controllableEntity_->boost(); 125 } 126 114 127 void HumanController::greet() 115 128 { … … 129 142 HumanController::localController_s->controllableEntity_->switchCamera(); 130 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 } 131 172 } -
code/branches/presentation/src/orxonox/objects/controllers/HumanController.h
r2087 r2485 54 54 static void altFire(); 55 55 56 static void boost(); 56 57 static void greet(); 57 58 static void use(); 58 59 static void switchCamera(); 60 static void mouseLook(); 61 62 static void suicide(); 63 64 static void addBots(unsigned int amount); 65 static void killBots(unsigned int amount = 0); 59 66 60 67 private:
Note: See TracChangeset
for help on using the changeset viewer.