- Timestamp:
- May 16, 2019, 4:53:45 PM (6 years ago)
- Location:
- code/branches/Boxhead_FS19/src/orxonox/scriptablecontroller
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/Boxhead_FS19/src/orxonox/scriptablecontroller/scriptable_controller_api.cc
r12006 r12390 10 10 #include "graphics/Model.h" 11 11 #include "worldentities/pawns/ScriptableControllerDrone.h" 12 #include "worldentities/pawns/SpaceShip.h" 13 12 14 13 15 … … 42 44 43 45 LuaTB<ScriptableControllerAPI, decltype(&ScriptableControllerAPI::spawnTest)>::registerFunction<&ScriptableControllerAPI::spawnTest>(this, lua, "spawnTest"); 44 46 LuaTB<ScriptableControllerAPI, decltype(&ScriptableControllerAPI::spawnZombie)>::registerFunction<&ScriptableControllerAPI::spawnZombie>(this, lua, "spawnZombie"); 45 47 46 48 … … 289 291 } 290 292 291 292 293 void ScriptableControllerAPI::spawnZombie(std::string id) 294 { 295 Identifier *identifier = ClassByString("SpaceShip"); 296 297 if(!identifier) 298 { 299 orxout(user_error) << "Script tried to spawn unknown object" << std::endl; 300 return; 301 } 302 303 if(!identifier->isLoadable()) 304 { 305 orxout(user_error) << "Script tried to spawn unloadable object" << std::endl; 306 return; 307 } 308 309 310 WorldEntity *entity; 311 Identifiable *obj = identifier->fabricate(this->controller_->getWorldEntityByID("Player")->getContext()); 312 313 314 315 orxout(user_status) << "First hit!" << std::endl; 316 317 if(obj->isA(ClassIdentifier<WorldEntity>::getIdentifier())) 318 { 319 orxout(user_status) << "Is WorldEntity!" << std::endl; 320 entity = orxonox_cast<WorldEntity*>(obj); 321 } 322 else if(obj->isA(ClassIdentifier<PlayerInfo>::getIdentifier())) 323 { 324 // TODO This does not work yet because somehow the controllable entity is not set 325 // yet at this stage. 326 // entity = orxonox_cast<PlayerInfo*>(obj)->getControllableEntity(); 327 328 orxout(user_status) << "Is PlayerInfo!" << std::endl; 329 330 //use TEMPLATES in the map to define objects that are not present on the map yet 331 return; 332 } 333 else 334 { 335 orxout(user_warning) << "Script tried to spawn an object that is neither a WorldEntity, nor a PlayerInfo" << std::endl; 336 337 return; 338 } 339 340 if(entity->isA(ClassIdentifier<MobileEntity>::getIdentifier())) { 341 orxout(user_status) << "Is MobileEntity!" << std::endl; 342 this->controller_->registerMobileEntity(id, orxonox_cast<MobileEntity*>(entity)); 343 } 344 345 346 347 if(entity->isA(ClassIdentifier<Pawn>::getIdentifier())) { 348 orxout(user_status) << "Is Pawn!" << std::endl; 349 this->controller_->registerPawn(id, orxonox_cast<Pawn*>(entity)); 350 } 351 352 this->controller_->registerWorldEntity(id, orxonox_cast<WorldEntity*>(entity)); 353 354 355 ///////////////GOLD!!!!!!!!!!!!!!!//////////////////////// 356 Pawn* pawn = this->controller_->getPawnByID(id); 357 358 //Attach to pawn 359 SpaceShip* drone = new SpaceShip(pawn->getContext()); // this is neccessary because the projectiles fired need a valid creator for the particlespawner (when colliding against something) 360 361 drone->addTemplate("spaceshipzombie"); //ScriptableControllerDroneTemplate spaceshipescort 362 363 Vector3 spawnPosition = pawn->getWorldPosition() + Vector3(500,20,500); 364 drone->setPosition(spawnPosition); 365 } 293 366 294 367 -
code/branches/Boxhead_FS19/src/orxonox/scriptablecontroller/scriptable_controller_api.h
r11974 r12390 161 161 * @param z The position on the z-axis 162 162 */ 163 164 void spawnZombie(std::string id); 165 166 /** 167 * @brief Set the position of an object 168 * @param id The ID of the object 169 * @param x The position on the x-axis 170 * @param y The position on the y-axis 171 * @param z The position on the z-axis 172 */ 173 174 163 175 void setPosition(std::string id, double x, double y, double z); 164 176
Note: See TracChangeset
for help on using the changeset viewer.