Changeset 10618 in orxonox.OLD for trunk/src/world_entities/spectator.cc
- Timestamp:
- Apr 4, 2007, 12:13:53 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:ignore
-
old new 16 16 OrxonoxPlayability.kdevses 17 17 OrxonoxPlayability.kdevelop.pcs 18 orxonox.backtrace 19 orxonox.kdevses 20 orxonox.kdevelop.pcs
-
- Property svn:ignore
-
trunk/src/world_entities/spectator.cc
r10401 r10618 25 25 #include "src/world_entities/npcs/generic_npc.h" 26 26 27 #include "src/lib/util/loading/load_param.h" 28 29 #include "player.h" 30 27 31 28 32 ObjectListDefinition(Spectator); 29 33 CREATE_FACTORY(Spectator); 30 34 31 35 Spectator* Spectator::ghost = NULL; 36 Playable* Spectator::regularPlayable = NULL; 32 37 33 38 #include "state.h" 39 #include "shell_command.h" 40 41 SHELL_COMMAND( enableGhost, Spectator, enableGhost ) 42 ->describe("fly around") 43 ->setAlias("ghost"); 34 44 35 45 … … 109 119 /** 110 120 * loads the Settings of a Spectator from an XML-element. 111 * @param root the XML-element to load the Sp aceship's properties from121 * @param root the XML-element to load the Spectator's properties from 112 122 */ 113 123 void Spectator::loadParams(const TiXmlElement* root) 114 124 { 115 125 Playable::loadParams(root); 126 127 LoadParam(root, "allowGhost", this, Spectator, allowGhost) 128 .describe("Allows the Player to fly around"); 129 } 130 131 132 133 void 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 149 void 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 } 116 177 } 117 178 … … 242 303 this->yMouse += event.yRel; 243 304 } 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 ); 246 308 // FPSPlayer * fps = new FPSPlayer(); 247 309 // //GenericNPC* fps = new GenericNPC(); … … 263 325 264 326 327
Note: See TracChangeset
for help on using the changeset viewer.