Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 21, 2008, 4:56:41 PM (16 years ago)
Author:
landauf
Message:
  • added ControllableEntity, the baseclass of all players, vehicles and ships.
  • moved Template to core
  • some changes in Camera
  • added 6 constants to WorldEntity to identify relative directions
  • changed vom Radian to Degree as default angle unit
Location:
code/branches/objecthierarchy/src/orxonox/objects/infos
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy/src/orxonox/objects/infos/PlayerInfo.cc

    r1953 r1989  
    4141#include "GraphicsEngine.h"
    4242#include "objects/gametypes/Gametype.h"
     43#include "objects/worldentities/ControllableEntity.h"
    4344
    4445namespace orxonox
     
    5657        this->bHumanPlayer_ = false;
    5758        this->bFinishedSetup_ = false;
     59
     60        this->pawn_ = 0;
     61        this->pawnID_ = network::OBJECTID_UNKNOWN;
    5862
    5963        this->setConfigValues();
     
    103107        REGISTERDATA(ping_,           network::direction::toclient);
    104108        REGISTERDATA(bHumanPlayer_,   network::direction::toclient);
     109        REGISTERDATA(pawnID_,         network::direction::toclient, new network::NetworkCallback<PlayerInfo>(this, &PlayerInfo::updatePawn));
    105110        REGISTERDATA(bFinishedSetup_, network::direction::bidirectional, new network::NetworkCallback<PlayerInfo>(this, &PlayerInfo::finishedSetup));
    106111    }
     
    160165        }
    161166    }
     167
     168    void PlayerInfo::startControl(ControllableEntity* pawn)
     169    {
     170        pawn->setPlayer(this);
     171        this->pawn_ = pawn;
     172        this->pawnID_ = pawn->getObjectID();
     173    }
     174
     175    void PlayerInfo::stopControl()
     176    {
     177        this->pawn_->removePlayer();
     178        this->pawn_ = 0;
     179        this->pawnID_ = network::OBJECTID_UNKNOWN;
     180    }
     181
     182    void PlayerInfo::updatePawn()
     183    {
     184        this->pawn_ = dynamic_cast<ControllableEntity*>(network::Synchronisable::getSynchronisable(this->pawnID_));
     185        if (this->pawn_ && (this->pawn_->getPlayer() != this))
     186            this->pawn_->setPlayer(this);
     187    }
    162188}
  • code/branches/objecthierarchy/src/orxonox/objects/infos/PlayerInfo.h

    r1953 r1989  
    5252                { return this->clientID_; }
    5353
    54             inline void setHumanPlayer(bool bHumanPlayer)
    55                 { this->bHumanPlayer_ = bHumanPlayer; }
    5654            inline bool isHumanPlayer() const
    5755                { return this->bHumanPlayer_; }
     56
     57            inline bool isLocalPlayer() const
     58                { return this->bLocalPlayer_; }
     59
     60            void startControl(ControllableEntity* pawn);
     61            void stopControl();
     62
     63            inline ControllableEntity* getPawn() const
     64                { return this->pawn_; }
    5865
    5966        private:
     
    6269            void checkNick();
    6370            void clientChangedName();
     71            void updatePawn();
    6472
    6573            unsigned int clientID_;
     
    7179            std::string playerName_;
    7280            std::string nick_;
     81
     82            ControllableEntity* pawn_;
     83            unsigned int pawnID_;
    7384    };
    7485}
Note: See TracChangeset for help on using the changeset viewer.