Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 14, 2009, 10:17:35 PM (15 years ago)
Author:
rgrieder
Message:

Merged presentation branch back to trunk.

Location:
code/trunk
Files:
6 edited
6 copied

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/objects/controllers/CMakeLists.txt

    r2131 r2662  
    22  Controller.cc
    33  HumanController.cc
     4  ArtificialController.cc
     5  AIController.cc
     6  ScriptController.cc
    47)
    58
  • code/trunk/src/orxonox/objects/controllers/Controller.cc

    r2087 r2662  
    3131
    3232#include "core/CoreIncludes.h"
     33#include "overlays/OverlayGroup.h"
    3334
    3435namespace orxonox
     
    4243        this->player_ = 0;
    4344        this->controllableEntity_ = 0;
     45        this->hud_ = 0;
     46        this->bUpdateHUD_ = false;
    4447    }
    4548
    4649    Controller::~Controller()
    4750    {
     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        }
    4881    }
    4982}
  • code/trunk/src/orxonox/objects/controllers/Controller.h

    r2087 r2662  
    4747                { return this->player_; }
    4848
    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
    5258                { 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_; }
    5377
    5478        protected:
     79            void updateHUD();
     80
    5581            PlayerInfo* player_;
    5682            ControllableEntity* controllableEntity_;
     83            std::string hudtemplate_;
     84            OverlayGroup* hud_;
     85            bool bUpdateHUD_;
    5786    };
    5887}
  • code/trunk/src/orxonox/objects/controllers/HumanController.cc

    r2087 r2662  
    3333#include "core/ConsoleCommand.h"
    3434#include "objects/worldentities/ControllableEntity.h"
     35#include "objects/worldentities/pawns/Pawn.h"
     36#include "objects/gametypes/Gametype.h"
    3537
    3638namespace orxonox
     
    4446    SetConsoleCommand(HumanController, fire,          true).keybindMode(KeybindMode::OnHold);
    4547    SetConsoleCommand(HumanController, altFire,       true).keybindMode(KeybindMode::OnHold);
     48    SetConsoleCommand(HumanController, boost,         true).keybindMode(KeybindMode::OnHold);
    4649    SetConsoleCommand(HumanController, greet,         true);
    4750    SetConsoleCommand(HumanController, use,           true);
    4851    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);
     56    SetConsoleCommand(HumanController, dropItems,     true);
    4957
    5058    CreateUnloadableFactory(HumanController);
     
    103111    {
    104112        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
    105             HumanController::localController_s->controllableEntity_->fire();
     113            HumanController::localController_s->controllableEntity_->fire(WeaponMode::fire);
    106114    }
    107115
     
    109117    {
    110118        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
    111             HumanController::localController_s->controllableEntity_->altFire();
     119            HumanController::localController_s->controllableEntity_->fire(WeaponMode::altFire);
     120    }
     121
     122    void HumanController::boost()
     123    {
     124        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
     125            HumanController::localController_s->controllableEntity_->boost();
    112126    }
    113127
     
    129143            HumanController::localController_s->controllableEntity_->switchCamera();
    130144    }
     145
     146    void HumanController::mouseLook()
     147    {
     148        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
     149            HumanController::localController_s->controllableEntity_->mouseLook();
     150    }
     151
     152    void HumanController::suicide()
     153    {
     154        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
     155        {
     156            Pawn* pawn = dynamic_cast<Pawn*>(HumanController::localController_s->controllableEntity_);
     157            if (pawn)
     158                pawn->kill();
     159        }
     160    }
     161
     162    void HumanController::addBots(unsigned int amount)
     163    {
     164        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && HumanController::localController_s->controllableEntity_->getGametype())
     165            HumanController::localController_s->controllableEntity_->getGametype()->addBots(amount);
     166    }
     167
     168    void HumanController::killBots(unsigned int amount)
     169    {
     170        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && HumanController::localController_s->controllableEntity_->getGametype())
     171            HumanController::localController_s->controllableEntity_->getGametype()->killBots(amount);
     172    }
     173
     174    void HumanController::dropItems()
     175    {
     176        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
     177            HumanController::localController_s->controllableEntity_->dropItems();
     178    }
    131179}
  • code/trunk/src/orxonox/objects/controllers/HumanController.h

    r2087 r2662  
    5454            static void altFire();
    5555
     56            static void boost();
    5657            static void greet();
    5758            static void use();
    5859            static void switchCamera();
     60            static void mouseLook();
     61            static void dropItems();
     62
     63            static void suicide();
     64
     65            static void addBots(unsigned int amount);
     66            static void killBots(unsigned int amount = 0);
    5967
    6068        private:
Note: See TracChangeset for help on using the changeset viewer.