Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 12, 2009, 9:24:58 PM (16 years ago)
Author:
landauf
Message:

changed type of gametype-HUD and default-HUD to PlayerInfo (instead of Gametype and ControllableEntity respectively). The owner of the Pawn-HUD remains Pawn.

Location:
code/trunk/src/orxonox/objects
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/objects/infos/HumanPlayer.cc

    r2896 r2973  
    167167    }
    168168
    169     void HumanPlayer::changedControllableEntity()
    170     {
    171         PlayerInfo::changedControllableEntity();
    172 
    173         if (this->humanHud_)
    174             this->humanHud_->setOwner(this->getControllableEntity());
    175     }
    176 
    177169    void HumanPlayer::updateHumanHUD()
    178170    {
     
    187179            this->humanHud_ = new OverlayGroup(this);
    188180            this->humanHud_->addTemplate(this->humanHudTemplate_);
    189             this->humanHud_->setOwner(this->getControllableEntity());
     181            this->humanHud_->setOwner(this);
    190182        }
    191183    }
     
    203195            this->gametypeHud_ = new OverlayGroup(this);
    204196            this->gametypeHud_->addTemplate(this->gametypeHudTemplate_);
    205             this->gametypeHud_->setOwner(this->getGametype());
     197            this->gametypeHud_->setOwner(this);
    206198        }
    207199    }
  • code/trunk/src/orxonox/objects/infos/HumanPlayer.h

    r2826 r2973  
    5252
    5353            virtual void changedGametype();
    54             virtual void changedControllableEntity();
    5554
    5655            inline void setHumanHUDTemplate(const std::string& name)
  • code/trunk/src/orxonox/objects/infos/PlayerInfo.cc

    r2839 r2973  
    5151        this->controllableEntityID_ = CLIENTID_UNKNOWN;
    5252
     53        this->gtinfo_ = 0;
     54        this->gtinfoID_ = OBJECTID_UNKNOWN;
     55        this->updateGametypeInfo();
     56
    5357        this->registerVariables();
    5458    }
     
    7680        registerVariable(this->controllableEntityID_, variableDirection::toclient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedcontrollableentityID));
    7781        registerVariable(this->bReadyToSpawn_,        variableDirection::toserver);
     82        registerVariable(this->gtinfoID_,             variableDirection::toclient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedgtinfoID));
    7883    }
    7984
     
    8893    void PlayerInfo::changedGametype()
    8994    {
     95        this->updateGametypeInfo();
     96
    9097        if (this->isInitialized())
    9198        {
     
    108115    }
    109116
     117    void PlayerInfo::updateGametypeInfo()
     118    {
     119        this->gtinfo_ = 0;
     120        this->gtinfoID_ = OBJECTID_UNKNOWN;
     121
     122        if (this->getGametype() && this->getGametype()->getGametypeInfo())
     123        {
     124            this->gtinfo_ = this->getGametype()->getGametypeInfo();
     125            this->gtinfoID_ = this->gtinfo_->getObjectID();
     126        }
     127    }
     128
    110129    void PlayerInfo::createController()
    111130    {
     
    181200        }
    182201    }
     202
     203    void PlayerInfo::networkcallback_changedgtinfoID()
     204    {
     205        if (this->gtinfoID_ != OBJECTID_UNKNOWN)
     206        {
     207            this->gtinfo_ = dynamic_cast<GametypeInfo*>(Synchronisable::getSynchronisable(this->gtinfoID_));
     208
     209            if (!this->gtinfo_)
     210                this->gtinfoID_ = OBJECTID_UNKNOWN;
     211        }
     212    }
    183213}
  • code/trunk/src/orxonox/objects/infos/PlayerInfo.h

    r2826 r2973  
    7777                { return this->controller_; }
    7878
     79            inline const GametypeInfo* getGametypeInfo() const
     80                { return this->gtinfo_; }
     81
    7982        protected:
    8083            void createController();
     
    8891        private:
    8992            void networkcallback_changedcontrollableentityID();
     93            void networkcallback_changedgtinfoID();
     94            void updateGametypeInfo();
    9095
    9196            bool bReadyToSpawn_;
     
    9398            ControllableEntity* controllableEntity_;
    9499            unsigned int controllableEntityID_;
     100
     101            const GametypeInfo* gtinfo_;
     102            unsigned int gtinfoID_;
    95103    };
    96104}
  • code/trunk/src/orxonox/objects/worldentities/ControllableEntity.cc

    r2896 r2973  
    4242#include "objects/worldentities/Camera.h"
    4343#include "objects/worldentities/CameraPosition.h"
    44 #include "objects/gametypes/Gametype.h"
    4544#include "overlays/OverlayGroup.h"
    4645
     
    6766        this->mouseLookSpeed_ = 200;
    6867
    69         this->gtinfo_ = 0;
    70         this->gtinfoID_ = OBJECTID_UNKNOWN;
    71         this->changedGametype();
    72 
    7368        this->server_position_         = Vector3::ZERO;
    7469        this->client_position_         = Vector3::ZERO;
     
    125120    {
    126121        SetConfigValue(mouseLookSpeed_, 3.0f);
    127     }
    128 
    129     void ControllableEntity::changedGametype()
    130     {
    131         //SUPER(ControllableEntity, changedGametype);
    132         WorldEntity::changedGametype();
    133 
    134         this->gtinfo_ = 0;
    135         this->gtinfoID_ = OBJECTID_UNKNOWN;
    136 
    137         if (this->getGametype() && this->getGametype()->getGametypeInfo())
    138         {
    139             this->gtinfo_ = this->getGametype()->getGametypeInfo();
    140             this->gtinfoID_ = this->gtinfo_->getObjectID();
    141         }
    142122    }
    143123
     
    283263    }
    284264
    285     void ControllableEntity::networkcallback_changedgtinfoID()
    286     {
    287         if (this->gtinfoID_ != OBJECTID_UNKNOWN)
    288         {
    289             this->gtinfo_ = dynamic_cast<GametypeInfo*>(Synchronisable::getSynchronisable(this->gtinfoID_));
    290 
    291             if (!this->gtinfo_)
    292                 this->gtinfoID_ = OBJECTID_UNKNOWN;
    293         }
    294     }
    295 
    296265    void ControllableEntity::startLocalHumanControl()
    297266    {
     
    394363
    395364        registerVariable(this->playerID_,                variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedplayerID));
    396         registerVariable(this->gtinfoID_,                variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedgtinfoID));
    397365    }
    398366
  • code/trunk/src/orxonox/objects/worldentities/ControllableEntity.h

    r2851 r2973  
    4848            void setConfigValues();
    4949
    50             virtual void changedGametype();
    5150            virtual void changedPlayer() {}
    5251
     
    126125                { return this->bHasHumanController_; }
    127126
    128             inline const GametypeInfo* getGametypeInfo() const
    129                 { return this->gtinfo_; }
    130 
    131127            inline bool isInMouseLook() const
    132128                { return this->bMouseLook_; }
     
    157153
    158154            void networkcallback_changedplayerID();
    159             void networkcallback_changedgtinfoID();
    160155
    161156            // Bullet btMotionState related
     
    190185            std::list<CameraPosition*> cameraPositions_;
    191186            std::string cameraPositionTemplate_;
    192 
    193             const GametypeInfo* gtinfo_;
    194             unsigned int gtinfoID_;
    195187    };
    196188}
Note: See TracChangeset for help on using the changeset viewer.