Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2818


Ignore:
Timestamp:
Mar 22, 2009, 9:40:35 PM (16 years ago)
Author:
landauf
Message:

added two new functions to Gametype

Location:
code/branches/miniprojects/src/orxonox/objects
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/miniprojects/src/orxonox/objects/gametypes/Gametype.cc

    r2768 r2818  
    176176    }
    177177
     178    void Gametype::playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn)
     179    {
     180    }
     181
     182    void Gametype::playerStopsControllingPawn(PlayerInfo* player, Pawn* pawn)
     183    {
     184    }
     185
    178186    bool Gametype::allowPawnHit(Pawn* victim, Pawn* originator)
    179187    {
  • code/branches/miniprojects/src/orxonox/objects/gametypes/Gametype.h

    r2789 r2818  
    101101            virtual void playerPostSpawn(PlayerInfo* player);
    102102
     103            virtual void playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn);
     104            virtual void playerStopsControllingPawn(PlayerInfo* player, Pawn* pawn);
     105
    103106            inline const std::map<PlayerInfo*, Player>& getPlayers() const
    104107                { return this->players_; }
  • code/branches/miniprojects/src/orxonox/objects/gametypes/TeamGametype.cc

    r2768 r2818  
    3434#include "objects/Teamcolourable.h"
    3535#include "objects/worldentities/TeamSpawnPoint.h"
    36 #include "objects/infos/PlayerInfo.h" // remove this
    3736
    3837namespace orxonox
     
    151150    }
    152151
    153     void TeamGametype::playerPostSpawn(PlayerInfo* player)
     152    void TeamGametype::playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn)
    154153    {
    155154        if (!player)
     
    160159        if (it_player != this->teamnumbers_.end() && it_player->second >= 0 && it_player->second < this->teamcolours_.size())
    161160        {
    162             if (player->getControllableEntity())
     161            if (pawn)
    163162            {
    164                 std::set<WorldEntity*> pawnAttachments = player->getControllableEntity()->getAttachedObjects();
     163                std::set<WorldEntity*> pawnAttachments = pawn->getAttachedObjects();
    165164                for (std::set<WorldEntity*>::iterator it = pawnAttachments.begin(); it != pawnAttachments.end(); ++it)
    166165                {
  • code/branches/miniprojects/src/orxonox/objects/gametypes/TeamGametype.h

    r2768 r2818  
    5353            virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0);
    5454
    55             virtual void playerPostSpawn(PlayerInfo* player);
     55            virtual void playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn);
    5656
    5757        protected:
  • code/branches/miniprojects/src/orxonox/objects/worldentities/pawns/Pawn.cc

    r2768 r2818  
    133133    }
    134134
     135    void Pawn::setPlayer(PlayerInfo* player)
     136    {
     137        ControllableEntity::setPlayer(player);
     138
     139        if (this->getGametype())
     140            this->getGametype()->playerStartsControllingPawn(player, this);
     141    }
     142
     143    void Pawn::removePlayer()
     144    {
     145        if (this->getGametype())
     146            this->getGametype()->playerStopsControllingPawn(this->getPlayer(), this);
     147
     148        ControllableEntity::removePlayer();
     149    }
     150
    135151    void Pawn::setHealth(float health)
    136152    {
  • code/branches/miniprojects/src/orxonox/objects/worldentities/pawns/Pawn.h

    r2662 r2818  
    4747            virtual void tick(float dt);
    4848            void registerVariables();
     49
     50            virtual void setPlayer(PlayerInfo* player);
     51            virtual void removePlayer();
    4952
    5053            inline bool isAlive() const
Note: See TracChangeset for help on using the changeset viewer.