Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10618 in orxonox.OLD for trunk/src/world_entities/spectator.cc


Ignore:
Timestamp:
Apr 4, 2007, 12:13:53 PM (17 years ago)
Author:
bknecht
Message:

merged cleanup into trunk (only improvements)

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

        old new  
        1616OrxonoxPlayability.kdevses
        1717OrxonoxPlayability.kdevelop.pcs
         18orxonox.backtrace
         19orxonox.kdevses
         20orxonox.kdevelop.pcs
  • trunk/src/world_entities/spectator.cc

    r10401 r10618  
    2525#include "src/world_entities/npcs/generic_npc.h"
    2626
     27#include "src/lib/util/loading/load_param.h"
     28
     29#include "player.h"
     30
    2731
    2832ObjectListDefinition(Spectator);
    2933CREATE_FACTORY(Spectator);
    3034
    31 
     35Spectator* Spectator::ghost = NULL;
     36Playable* Spectator::regularPlayable = NULL;
    3237
    3338#include "state.h"
     39#include "shell_command.h"
     40             
     41SHELL_COMMAND( enableGhost, Spectator, enableGhost )
     42             ->describe("fly around")
     43             ->setAlias("ghost");
    3444
    3545
     
    109119/**
    110120 * loads the Settings of a Spectator from an XML-element.
    111  * @param root the XML-element to load the Spaceship's properties from
     121 * @param root the XML-element to load the Spectator's properties from
    112122 */
    113123void Spectator::loadParams(const TiXmlElement* root)
    114124{
    115125  Playable::loadParams(root);
     126 
     127  LoadParam(root, "allowGhost", this, Spectator, allowGhost)
     128    .describe("Allows the Player to fly around");
     129}
     130
     131
     132
     133void Spectator::allowGhost( bool flag )
     134{
     135  PRINTF(0)( "SPECTATOR ALLOWGHOST: %d\n", flag );
     136  if ( flag )
     137  {
     138    assert( ghost == NULL && "only one flySpectator allowed" );
     139   
     140    ghost = this;
     141  }
     142  else
     143  {
     144    ghost = NULL;
     145  }
     146}
     147
     148
     149void Spectator::enableGhost( )
     150{
     151  if ( !ghost )
     152  {
     153    Spectator* spec = new Spectator();
     154    spec->allowGhost( true );
     155  }
     156 
     157  if ( !regularPlayable )
     158  {
     159    if ( !State::getPlayer() || !State::getPlayer()->getPlayable() )
     160      return;
     161   
     162    regularPlayable = State::getPlayer()->getPlayable();
     163   
     164    ghost->setAbsCoor( regularPlayable->getAbsCoor() );
     165    ghost->setAbsDir( regularPlayable->getAbsDir() );
     166   
     167    State::getPlayer()->setPlayable( ghost );
     168  }
     169  else
     170  {
     171    if ( !State::getPlayer() || !State::getPlayer()->getPlayable() )
     172      return;
     173   
     174    State::getPlayer()->setPlayable( regularPlayable );
     175    regularPlayable = NULL;
     176  }
    116177}
    117178
     
    242303    this->yMouse += event.yRel;
    243304  }
    244   else if( event.type == KeyMapper::PEV_JUMP)
    245   {
     305  else if( event.type == KeyMapper::PEV_FIRE1 )
     306  {
     307    PRINTF(0)( "CURRENT POS: (%f, %f, %f) ROT (%f, (%f, %f, %f))\n", this->getAbsCoorX(), this->getAbsCoorY(), this->getAbsCoorZ(), this->getAbsDir().w, this->getAbsDir().v.x, this->getAbsDir().v.y, this->getAbsDir().v.z );
    246308//     FPSPlayer * fps = new FPSPlayer();
    247309//     //GenericNPC* fps = new GenericNPC();
     
    263325
    264326
     327
Note: See TracChangeset for help on using the changeset viewer.