Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 13, 2008, 10:54:26 PM (15 years ago)
Author:
landauf
Message:
  • Moved some variables from Gametype to GametypeInfo (Gametype exists only on the Server while GametypeInfo is synchronized)
  • Created a new HUD-element, GametypeStatus, based on GametypeInfo (the same effect was formerly achieved by using a hack in Spectator and a TextOverlay)
  • HumanController creates a HUD (additionally to the SpaceShips HUD) which includes GametypeStatus and ChatOverlay and even more in the future
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy2/src/orxonox/objects/worldentities/ControllableEntity.cc

    r2361 r2428  
    3838#include "objects/worldentities/Camera.h"
    3939#include "objects/worldentities/CameraPosition.h"
     40#include "objects/gametypes/Gametype.h"
    4041#include "overlays/OverlayGroup.h"
    4142
     
    5960        this->bDestroyWhenPlayerLeft_ = false;
    6061
     62        this->gtinfo_ = 0;
     63        this->gtinfoID_ = OBJECTID_UNKNOWN;
     64        this->changedGametype();
     65
    6166        this->velocity_ = Vector3::ZERO;
    6267        this->acceleration_ = Vector3::ZERO;
     
    98103
    99104        XMLPortObject(ControllableEntity, CameraPosition, "camerapositions", addCameraPosition, getCameraPosition, xmlelement, mode);
     105    }
     106
     107    void ControllableEntity::changedGametype()
     108    {
     109        SUPER(ControllableEntity, changedGametype);
     110
     111        this->gtinfo_ = 0;
     112        this->gtinfoID_ = OBJECTID_UNKNOWN;
     113
     114        if (this->getGametype() && this->getGametype()->getGametypeInfo())
     115        {
     116            this->gtinfo_ = this->getGametype()->getGametypeInfo();
     117            this->gtinfoID_ = this->gtinfo_->getObjectID();
     118        }
    100119    }
    101120
     
    199218    }
    200219
     220    void ControllableEntity::networkcallback_changedgtinfoID()
     221    {
     222        if (this->gtinfoID_ != OBJECTID_UNKNOWN)
     223        {
     224            this->gtinfo_ = dynamic_cast<GametypeInfo*>(Synchronisable::getSynchronisable(this->gtinfoID_));
     225
     226            if (!this->gtinfo_)
     227                this->gtinfoID_ = OBJECTID_UNKNOWN;
     228        }
     229    }
     230
    201231    void ControllableEntity::startLocalHumanControl()
    202232    {
     
    268298
    269299        REGISTERDATA(this->playerID_, direction::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedplayerID));
     300        REGISTERDATA(this->gtinfoID_, direction::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedgtinfoID));
    270301    }
    271302
Note: See TracChangeset for help on using the changeset viewer.