Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 22, 2008, 5:25:01 AM (16 years ago)
Author:
landauf
Message:

added several new classes

File:
1 edited

Legend:

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

    r1989 r1993  
    5353        this->hud_ = 0;
    5454        this->camera_ = 0;
    55 
     55        this->bDestroyWhenPlayerLeft_ = false;
    5656
    5757        this->velocity_ = Vector3::ZERO;
     
    9494
    9595        if (this->bControlled_)
     96        {
    9697            this->startLocalControl();
     98            this->setObjectMode(network::direction::bidirectional);
     99        }
    97100    }
    98101
     
    105108        this->playerID_ = network::OBJECTID_UNKNOWN;
    106109        this->bControlled_ = false;
     110        this->setObjectMode(network::direction::toclient);
     111
     112        if (this->bDestroyWhenPlayerLeft_)
     113            delete this;
    107114    }
    108115
    109116    void ControllableEntity::updatePlayer()
    110117    {
    111         this->player_ = dynamic_cast<PlayerInfo*>(network::Synchronisable::getSynchronisable(this->playerID_));
    112         if (this->player_ && (this->player_->getPawn() != this))
    113             this->player_->startControl(this);
     118        if (this->playerID_ != network::OBJECTID_UNKNOWN)
     119        {
     120            this->player_ = dynamic_cast<PlayerInfo*>(network::Synchronisable::getSynchronisable(this->playerID_));
     121            if (this->player_ && (this->player_->getPawn() != this))
     122                this->player_->startControl(this);
     123        }
    114124    }
    115125
    116126    void ControllableEntity::startLocalControl()
    117127    {
     128        std::cout << "###### start local control" << std::endl;
    118129        this->camera_ = new Camera();
    119130        this->camera_->requestFocus();
    120 
    121         this->hud_ = new OverlayGroup();
    122         this->hud_->addTemplate(this->hudtemplate_);
     131        this->attach(this->camera_);
     132
     133        if (this->hudtemplate_ != "")
     134        {
     135            this->hud_ = new OverlayGroup();
     136            this->hud_->addTemplate(this->hudtemplate_);
     137        }
    123138    }
    124139
    125140    void ControllableEntity::stopLocalControl()
    126141    {
     142        std::cout << "###### stop local control" << std::endl;
     143        this->detach(this->camera_);
    127144        delete this->camera_;
    128145        this->camera_ = 0;
     
    137154        {
    138155            this->velocity_ += (dt * this->acceleration_);
    139             this->node_->translate(dt * this->velocity_);
     156            this->node_->translate(dt * this->velocity_, Ogre::Node::TS_PARENT);
    140157
    141158            if (Core::isMaster())
     
    150167            }
    151168        }
    152 
    153 //        std::cout << this->getPosition() << std::endl;
    154169    }
    155170
Note: See TracChangeset for help on using the changeset viewer.