[Orxonox-commit 6932] r11553 - code/branches/AsteroidMining_HS17/src/modules/asteroidmining
remartin at orxonox.net
remartin at orxonox.net
Thu Nov 9 18:13:50 CET 2017
Author: remartin
Date: 2017-11-09 18:13:50 +0100 (Thu, 09 Nov 2017)
New Revision: 11553
Modified:
code/branches/AsteroidMining_HS17/src/modules/asteroidmining/AsteroidMinable.cc
Log:
That pickup stuff is a bloody mess. Protected methods and weird interaction.
Modified: code/branches/AsteroidMining_HS17/src/modules/asteroidmining/AsteroidMinable.cc
===================================================================
--- code/branches/AsteroidMining_HS17/src/modules/asteroidmining/AsteroidMinable.cc 2017-11-07 18:26:12 UTC (rev 11552)
+++ code/branches/AsteroidMining_HS17/src/modules/asteroidmining/AsteroidMinable.cc 2017-11-09 17:13:50 UTC (rev 11553)
@@ -49,10 +49,21 @@
- Neue Asteroiden generieren -> Absturz
- Pickup spawning -> Absturz
+
+o hat's mit den Context-Eingenschaften zu tun? Je einen Neuen/Aktuellen besorgen?
+
+Nicht Pointer uebergeben?
- Manchmal: Absturz bei Zerstoerung eines Asteroiden
+- Was tut 'Register Variables'?
+o Error messages: change context::pickups to something else
+OFFEN:
+o Add custom pickup 'resources'
+
+
+
Erlegt:
o Rand() geht bis zu riesigen Nummern!
*/
@@ -84,6 +95,7 @@
#include "../pickup/items/HealthPickup.h"
#include "../pickup/PickupSpawner.h"
#include "../pickup/Pickup.h"
+//#include "../pickup/pickup ..... pickupable
#include "../objects/collisionshapes/SphereCollisionShape.h"
#include "../../orxonox/graphics/Model.h"
@@ -118,6 +130,13 @@
//this->roll = rand()*5; //etwas Drehung. richtige Variable
+
+
+
+
+
+
+
// DELETE if other stuff works! (wrong size etc.)
SphereCollisionShape* cs = new SphereCollisionShape(this->context);
cs->setRadius((this->size)*2); //OFFEN: Feinabstimmung der Radien
@@ -126,6 +145,8 @@
+
+
// Old from Pawn
this->registerVariables();
@@ -153,11 +174,10 @@
// Collision shape
SphereCollisionShape* cs = new SphereCollisionShape(this->context);
- cs->setRadius((this->size)*2); //OFFEN: Feinabstimmung der Radien
+ cs->setRadius((this->size)*2); //OFFEN: Feinabstimmung der Radien. 2.5 in AsteroidField.lua
this->attachCollisionShape(cs);
-
this->initialised=true;
}
@@ -185,6 +205,16 @@
registerVariable(this->size, VariableDirection::ToClient);
registerVariable(this->generateSmaller, VariableDirection::ToClient);
+
+ registerVariable(this->initialised, VariableDirection::ToClient);
+ //registerVariable(this->context, VariableDirection::ToClient); // can't link that since it's a context
+
+
+ // float size;
+ // bool generateSmaller;
+ // bool initialised;
+
+ // Context* context;
}
void AsteroidMinable::tick(float dt)
@@ -210,22 +240,47 @@
{
+ //Spawn Pickup // Create at start already? ( Hidden in CollisionShape)
+ HealthPickup* hP = new HealthPickup(this->context);
+ if(hP == nullptr){
+ orxout(internal_error, context::pickups) << "Weird, can't create new HealthPickup." << endl;
+ }
+ // hP->setPosition(this->getPosition()); // Does not have a member named 'setPosition' (Inherits from Pickup//BAse Object)
-
- //Spawn Pickup
- HealthPickup* hP = new HealthPickup(this->context);
+ // invoke spawnPickup on the pikcup itself? (returns bool, creates the hideous thing)
+ // HealthPickup inherits from Pickup.
+ // createSpawner is protected ->can be used as well in inheriting classes, but not here!
+ // bool unnecessary = hP->createSpawner();
+ // hP->setPosition(this->getPosition());
//OFFEN: Add custom pickup 'resources'
- PickupSpawner* thingy = new PickupSpawner(this->context);
- thingy->setPosition(this->getPosition());
- thingy->createDroppedPickup(this->context, hP, nullptr, 10);
+ // createPickup is private, hP is of type Pickup!
+ // CreateDroppedPickup returns a PickupSpawner!
+ // PickupSpawner don't have public set methods, just that ugly 'factory method' which returns another PickupSpawner
+ // PickupSpawner* thingy = new PickupSpawner(this->context);
+ // What is Pickupable? says: Interface, no way to set type. Why do I even need the spawner? Trigger Distance?
+
+
+ // Plan: Solve the Pickupable mystery, try to adapt the spawner somehow. Ask to modify it if that fails. (Change method types)
+
+
+ // PickupSpawner* thingy = (new PickupSpawner(this->context))->createDroppedPickup(this->context, hP, nullptr, 10);
// /*static*/ PickupSpawner* PickupSpawner::createDroppedPickup(Context* context, Pickupable* pickup, PickupCarrier* carrier, float triggerDistance)
+
+
+
+ // if(thingy == nullptr){
+ // orxout(internal_error, context::pickups) << "Weird, can't create new PickupSpawner." << endl;
+ // }
+ // thingy->setPosition(this->getPosition());
+ // thingy->setMaxSpawnedItems(1);//Default is 1 already, private anyways
+
- // Smaller Parts
- if(this->generateSmaller){
- this->spawnChildren();
- }
+ // // Smaller Parts
+ // if(this->generateSmaller){
+ // this->spawnChildren();
+ // }
// OFFEN: Sauber kapputten
@@ -270,15 +325,25 @@
//Spawn this child Game crashes!
AsteroidMinable* child = new AsteroidMinable(this->context);
- child->setSize(extra + 1);
-
- //OFFEN:Kollision der Kinder verhindern
- //Relativ zu Elternteil automatisch?
- //Typ position:rand()*Vektoriwas?
- //pawn->getWorldPosition() + Vector3(30,0,-30);
- child->setPosition(this->getPosition() + Vector3(num*5, 0, 0));
+ // if(!(child == nullptr)){//Errorgebastel
+
+ if(child == nullptr){
+ orxout(internal_error, context::pickups) << "Weird, can't create new AsteroidMinable." << endl;
+ }
+
+ child->setSize(extra + 1);
+
+ //OFFEN:Kollision der Kinder verhindern
+ //Relativ zu Elternteil automatisch?
+ //Typ position:rand()*Vektoriwas?
+ //pawn->getWorldPosition() + Vector3(30,0,-30);
+ child->setPosition(this->getPosition() + Vector3(num*5, 0, 0));
+
+ // }
+
+
// Pawn* pawn = this->carrierToPawnHelper();
// if(pawn == nullptr) // If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.
// this->Pickupable::destroy();
More information about the Orxonox-commit
mailing list