Changeset 11581 for code/branches/AsteroidMining_HS17/src/modules
- Timestamp:
- Nov 20, 2017, 4:21:26 PM (7 years ago)
- Location:
- code/branches/AsteroidMining_HS17/src/modules/asteroidmining
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/AsteroidMining_HS17/src/modules/asteroidmining/AsteroidMinable.cc
r11561 r11581 44 44 45 45 KNACKPUNKTE: 46 o Collision Shape-Problem (Funktioniert nur, wenn im Konstruktor) 46 o Collision Shape-Problem (Funktioniert nur, wenn im Konstruktor) -> Mit Factory-Methode oder so basteln. 47 47 o Maximale Hitpunkte = 200? 48 48 49 49 o Neue Asteroiden generieren -> Absturz 50 -- -> Weil Elterndings zerstoert wird?51 -- -> Nicht moeglich, zur Laufzeit zu generieren?52 53 o Pickups: setMaxSpawned funktioniert nicht 50 --> Kollidiert sofort mit irgendetwas, death() wird mehrfach aufgerufen. 51 --> Funktioniert der Test in den hit()-Methoden? 52 --> Welcher Aufruf loest die death()-Methode auf? 53 54 54 55 55 … … 72 72 o Dynamische Definition -> putStuff-Methode, Werte noch nicht durchgesickert. 73 73 o Error-Nachricht: Einfach Argumente leer lassen. 74 o Pickups: setMaxSpawned funktioniert nicht -> Bastelloesung: Auf 2 statt eins setzen, erstes wird wohl direkt zerstoert. 74 75 */ 75 76 … … 123 124 this->setCollisionType(WorldEntity::CollisionType::Dynamic); 124 125 this->bAlive_ = true; 126 125 127 this->bVulnerable_ = true; 128 this->enableCollisionCallback(); 126 129 127 130 // Default Values 128 this->generateSmaller = true; 131 this->generateSmaller = true; 132 //this->setHealth(50); 129 133 this->size = 10; // customSize 130 134 this->context = context; 131 135 this->initialised = false; 132 136 //this->roll = rand()*5; //etwas Drehung. richtige Variable 133 137 //this = new AsteroidMinable() 134 138 135 139 … … 145 149 // Old from Pawn 146 150 this->registerVariables(); 151 152 orxout() << "AsteroidMining:: Konstruktor passiert!" << endl; 147 153 148 154 } … … 171 177 172 178 173 this->initialised=true; 179 this->initialised=true; 180 181 orxout() << "AsteroidMining:: Initialisierung abgeschlosssssen." << endl; 182 174 183 } 175 184 … … 232 241 { 233 242 234 // Stuff that can be harvested. 235 PickupSpawner* thingy = new PickupSpawner(this->context); 236 237 // OFFEN: more precise size relation in custom resource pickup. 238 char tname[] = ""; // can-t overwrite strings easily in C (strcat etc.) 239 if(this->size <= 5){ 240 strcat(tname, "smallmunitionpickup"); 241 }else if(this->size <= 20){ 242 strcat(tname, "mediummunitionpickup"); 243 }else{ 244 strcat(tname, "hugemunitionpickup"); 245 } 246 //orxout() << "Zeugsname:" << tname << endl; 247 thingy->setPickupTemplateName(tname); 248 thingy->setPosition(this->getPosition()); 249 //thingy->setMaxSpawnedItems(1); // Somehow doesn-t work yet. 250 thingy->setRespawnTime(0.1f);// instantly 251 252 orxout() << "AsteroidMining::Death(): Passed Pickup stuff!" << endl; 253 254 255 243 orxout() << "AsteroidMinable::Death() aufgerufen." << endl; 244 245 // OFFEN: Sauber kapputten 246 // just copied other stuff: 247 // this->setHealth(1); 248 this->bAlive_ = false; 249 this->destroyLater(); 250 this->setDestroyWhenPlayerLeft(false); 251 // pawn -> addExplosionPart 252 // this->goWithStyle(); 253 254 255 // // Stuff that can be harvested. 256 // PickupSpawner* thingy = new PickupSpawner(this->context); 257 258 // // OFFEN: more precise size relation in custom resource pickup. 259 // char tname[] = ""; // can-t overwrite strings easily in C (strcat etc.) 260 // if(this->size <= 5){ 261 // strcat(tname, "smallmunitionpickup"); 262 // }else if(this->size <= 20){ 263 // strcat(tname, "mediummunitionpickup"); 264 // }else{ 265 // strcat(tname, "hugemunitionpickup"); 266 // } 267 // thingy->setPickupTemplateName(tname); 268 // thingy->setPosition(this->getPosition()); 269 // thingy->setMaxSpawnedItems(2); // The first somehow gets destroyed immediately. 270 // thingy->setRespawnTime(0.5f); 271 272 // orxout() << "AsteroidMining::Death(): Passed Pickup stuff!" << endl; 256 273 257 274 … … 265 282 266 283 267 // OFFEN: Sauber kapputten 268 // just copied other stuff: 269 this->setHealth(1); 270 this->bAlive_ = false; 271 this->destroyLater(); 272 this->setDestroyWhenPlayerLeft(false); 273 274 275 // pawn -> addExplosionPart 276 // this->goWithStyle(); 284 285 286 277 287 orxout() << "Wieder retour in death() geschafft. " << endl; 278 288 … … 291 301 void AsteroidMinable::spawnChildren(){ 292 302 303 if (this->size <=1){return;} // Absicherung trivialer Fall 304 305 306 293 307 // Spawn smaller Children 294 308 int massRem = this->size-1; //some mass is lost … … 300 314 301 315 302 orxout() << "Number of Children: " << num << endl;303 304 305 for(int fisch=num; fisch>=1; fisch--){316 //orxout() << "Number of Children: " << num << endl; 317 318 319 for(int fisch=num; fisch>=1; --fisch){ 306 320 // to distribute remaining mass 321 322 //orxout() << "AsteroidMining::spawnChildren(): Fisch-Variable: " << fisch << endl; 323 307 324 if(fisch==1){ 308 325 extra = massRem; … … 313 330 } 314 331 315 orxout() << "Mass chosen: " << extra+1 << endl;316 317 orxout() << "AsteroidMining::spawnChildren(): Inside for-loop." << endl;332 //orxout() << "Mass chosen: " << extra+1 << endl; 333 334 //orxout() << "AsteroidMining::spawnChildren(): Inside for-loop." << endl; 318 335 319 336 //Spawn this child Game crashes! … … 323 340 // Position zu spaet gesetzt? Tick nicht atomar -> falsche Groesse evtl? 324 341 325 326 327 328 329 342 if(child == nullptr){ 343 orxout(internal_error, context::pickups) << "Weird, can't create new AsteroidMinable." << endl; 344 } 345 346 child->setSize(extra + 1); 330 347 331 348 //OFFEN:Kollision der Kinder verhindern … … 333 350 //Typ position:rand()*Vektoriwas? 334 351 //pawn->getWorldPosition() + Vector3(30,0,-30); 335 336 337 338 orxout() << "Done: Creating new Asteroid" << endl;352 child->setPosition(this->getPosition() + Vector3(num*5, 0, 0)); 353 //child->setPosition(Vector3(0,0,0)); 354 355 //orxout() << "Done: Creating new Asteroid" << endl; 339 356 340 357 // } … … 355 372 356 373 374 void AsteroidMinable::hit(Pawn* originator, const Vector3& force, const btCollisionShape* cs, float damage, float healthdamage, float shielddamage){ 375 376 orxout() << "AsteroidMining::Hit(Variante 1) Dings aufgerufen. " << endl; 377 378 // Kollision mit anderem Asteroid oder Pickup (OFFEN: evtl. Spawner oder irgendwas?) verhindern. In diesem Fall einfach nichts tun. 379 // Wird staending aufgerufen -> Rechenleistung? 380 if(orxonox_cast<AsteroidMinable*>(originator) || orxonox_cast<Pickup*>(originator)){return;} 381 this->damage(damage, healthdamage, shielddamage, originator, cs); 382 this->setVelocity(this->getVelocity() + force); 383 384 385 386 // if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator))// && (!this->getController() || !this->getController()->getGodMode()) ) 387 // { 388 // this->damage(damage, healthdamage, shielddamage, originator, cs); 389 // this->setVelocity(this->getVelocity() + force); 390 // } 391 } 392 393 void AsteroidMinable::hit(Pawn* originator, btManifoldPoint& contactpoint, const btCollisionShape* cs, float damage, float healthdamage, float shielddamage){ 394 395 orxout() << "AsteroidMining::Hit(Variante 2) Dings aufgerufen. " << endl; 396 // Kollision mit anderem Asteroid oder Pickup (OFFEN: evtl. Spawner oder irgendwas?) verhindern. In diesem Fall einfach nichts tun. 397 // Wird staending aufgerufen -> Rechenleistung? 398 if(orxonox_cast<AsteroidMinable*>(originator) || orxonox_cast<Pickup*>(originator)){return;} 399 400 401 402 this->damage(damage, healthdamage, shielddamage, originator, cs); 403 404 405 406 407 // if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator))// && (!this->getController() || !this->getController()->getGodMode()) ) 408 // { 409 // this->damage(damage, healthdamage, shielddamage, originator, cs); 410 411 // //if ( this->getController() ) 412 // // this->getController()->hit(originator, contactpoint, damage); // changed to damage, why shielddamage? 413 // } 414 } 415 416 417 418 419 // Cast-Test aus movableEntity(): 420 // Pawn* victim = orxonox_cast<Pawn*>(otherObject); 421 // if (victim) 422 423 424 425 426 //Pawn: 427 // void Pawn::hit(Pawn* originator, const Vector3& force, const btCollisionShape* cs, float damage, float healthdamage, float shielddamage) 428 // { 429 // if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) ) 430 // { 431 // this->damage(damage, healthdamage, shielddamage, originator, cs); 432 // this->setVelocity(this->getVelocity() + force); 433 // } 434 // } 435 436 // void Pawn::hit(Pawn* originator, btManifoldPoint& contactpoint, const btCollisionShape* cs, float damage, float healthdamage, float shielddamage) 437 // { 438 // if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) ) 439 // { 440 // this->damage(damage, healthdamage, shielddamage, originator, cs); 441 442 // if ( this->getController() ) 443 // this->getController()->hit(originator, contactpoint, damage); // changed to damage, why shielddamage? 444 // } 445 // } 446 447 448 449 450 // /** 451 // @brief 452 // Virtual function that gets called when this object collides with another. 453 // @param otherObject 454 // The object this one has collided into. 455 // @param ownCollisionShape 456 // The collision shape of the other object 457 // @param contactPoint 458 // Contact point provided by Bullet. Holds more information and can me modified. See return value. 459 // @return 460 // Returning false means that no modification to the contactPoint has been made. Return true otherwise! 461 // @note 462 // Condition is that enableCollisionCallback() was called. 463 // */ 464 // virtual inline bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) 465 // { return false; } /* With false, Bullet assumes no modification to the collision objects. */ 466 467 // //! Enables the collidesAgainst(.) function. The object doesn't respond to collision otherwise! 468 // inline void enableCollisionCallback() 469 // { this->bCollisionCallbackActive_ = true; this->collisionCallbackActivityChanged(); } 470 471 472 473 // //! Disables the collidesAgainst(.) function. @see enableCollisionCallback() 474 // inline void disableCollisionCallback() 475 // { this->bCollisionCallbackActive_ = false; this->collisionCallbackActivityChanged(); } 476 477 478 // //! Tells whether there could be a collision callback via collidesAgainst(.) 479 // inline bool isCollisionCallbackActive() const 480 // { return this->bCollisionCallbackActive_; } 481 482 // //! Enables or disables collision response (default is of course on) 483 // inline void setCollisionResponse(bool value) 484 // { this->bCollisionResponseActive_ = value; this->collisionResponseActivityChanged(); } 485 486 487 // //! Tells whether there could be a collision response 488 // inline bool hasCollisionResponse() 489 // { return this->bCollisionResponseActive_; } 357 490 358 491 -
code/branches/AsteroidMining_HS17/src/modules/asteroidmining/AsteroidMinable.h
r11551 r11581 56 56 virtual void tick(float dt) override; 57 57 58 // Overwrite to prevet 'self-collision' of generated stuff 59 virtual void hit(Pawn* originator, const Vector3& force, const btCollisionShape* cs, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f); 60 virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, const btCollisionShape* cs, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f); 61 62 63 58 64 virtual void setSize(float f); 59 65 virtual float getSize(); 66 67 68 60 69 61 70
Note: See TracChangeset
for help on using the changeset viewer.