Changeset 10602 in orxonox.OLD for branches/cleanup/src
- Timestamp:
- Mar 26, 2007, 12:31:58 AM (18 years ago)
- Location:
- branches/cleanup/src/world_entities
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/cleanup/src/world_entities/spectator.cc
r10601 r10602 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 ( !regularPlayable ) 152 { 153 if ( !State::getPlayer() || !State::getPlayer()->getPlayable() ) 154 return; 155 156 regularPlayable = State::getPlayer()->getPlayable(); 157 158 ghost->setAbsCoor( regularPlayable->getAbsCoor() ); 159 ghost->setAbsDir( regularPlayable->getAbsDir() ); 160 161 State::getPlayer()->setPlayable( ghost ); 162 } 163 else 164 { 165 if ( !State::getPlayer() || !State::getPlayer()->getPlayable() ) 166 return; 167 168 State::getPlayer()->setPlayable( regularPlayable ); 169 regularPlayable = NULL; 170 } 116 171 } 117 172 … … 264 319 265 320 321 -
branches/cleanup/src/world_entities/spectator.h
r9869 r10602 30 30 31 31 virtual void process(const Event &event); 32 33 void allowGhost( bool flag ); 34 35 static void enableGhost(); 32 36 33 37 private: … … 45 49 float angleX; 46 50 float angleY; 51 52 static Spectator* ghost; 53 static Playable* regularPlayable; 47 54 48 55 };
Note: See TracChangeset
for help on using the changeset viewer.