Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 9, 2017, 6:13:50 PM (7 years ago)
Author:
remartin
Message:

That pickup stuff is a bloody mess. Protected methods and weird interaction.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/AsteroidMining_HS17/src/modules/asteroidmining/AsteroidMinable.cc

    r11551 r11553  
    5050- Neue Asteroiden generieren -> Absturz
    5151- Pickup spawning -> Absturz
     52
     53o hat's mit den Context-Eingenschaften zu tun? Je einen Neuen/Aktuellen besorgen?
     54
     55Nicht Pointer uebergeben?
    5256- Manchmal: Absturz bei Zerstoerung eines Asteroiden
     57- Was tut 'Register Variables'?
     58
     59o Error messages: change context::pickups to something else
     60
     61
     62OFFEN:
     63o Add custom pickup 'resources'
    5364
    5465
     
    8596#include "../pickup/PickupSpawner.h"
    8697#include "../pickup/Pickup.h"
     98//#include "../pickup/pickup ..... pickupable
    8799#include "../objects/collisionshapes/SphereCollisionShape.h"
    88100#include "../../orxonox/graphics/Model.h"
     
    119131
    120132
     133
     134
     135
     136
     137
     138
     139
    121140        // DELETE if other stuff works! (wrong size etc.)
    122141        SphereCollisionShape* cs = new SphereCollisionShape(this->context);
    123142        cs->setRadius((this->size)*2); //OFFEN: Feinabstimmung der Radien
    124143        this->attachCollisionShape(cs);
     144
     145
    125146
    126147
     
    154175        // Collision shape
    155176        SphereCollisionShape* cs = new SphereCollisionShape(this->context);
    156         cs->setRadius((this->size)*2); //OFFEN: Feinabstimmung der Radien 
     177        cs->setRadius((this->size)*2); //OFFEN: Feinabstimmung der Radien. 2.5 in AsteroidField.lua
    157178        this->attachCollisionShape(cs);
    158 
    159179
    160180
     
    186206        registerVariable(this->size, VariableDirection::ToClient);
    187207        registerVariable(this->generateSmaller, VariableDirection::ToClient);
     208
     209        registerVariable(this->initialised, VariableDirection::ToClient);
     210        //registerVariable(this->context, VariableDirection::ToClient); // can't link that since it's a context
     211
     212
     213            //         float size;
     214            // bool generateSmaller;
     215            // bool initialised;
     216
     217            // Context* context;
    188218    }
    189219
     
    211241
    212242
    213 
    214 
    215         //Spawn Pickup
     243        //Spawn Pickup // Create at start already? ( Hidden in CollisionShape)
    216244        HealthPickup* hP = new HealthPickup(this->context);
     245        if(hP == nullptr){
     246            orxout(internal_error, context::pickups) << "Weird, can't create new HealthPickup." << endl;
     247        }
     248        // hP->setPosition(this->getPosition()); // Does not have a member named 'setPosition' (Inherits from Pickup//BAse Object)
     249
     250        // invoke spawnPickup on the pikcup itself? (returns bool, creates the hideous thing)
     251        // HealthPickup inherits from Pickup.
     252        // createSpawner is protected ->can be used as well in inheriting classes, but not here!
     253        // bool unnecessary = hP->createSpawner();
     254        // hP->setPosition(this->getPosition());
    217255        //OFFEN: Add custom pickup 'resources'
    218         PickupSpawner* thingy = new PickupSpawner(this->context);
    219         thingy->setPosition(this->getPosition());
    220         thingy->createDroppedPickup(this->context, hP, nullptr, 10);
    221 
     256
     257        // createPickup is private, hP is of type Pickup!
     258        // CreateDroppedPickup returns a PickupSpawner!
     259        // PickupSpawner don't have public set methods, just that ugly 'factory method' which returns another PickupSpawner
     260        // PickupSpawner* thingy = new PickupSpawner(this->context);
     261        // What is Pickupable? says: Interface, no way to set type. Why do I even need the spawner? Trigger Distance?
     262       
     263
     264        // Plan: Solve the Pickupable mystery, try to adapt the spawner somehow. Ask to modify it if that fails. (Change method types)
     265
     266
     267        // PickupSpawner* thingy = (new PickupSpawner(this->context))->createDroppedPickup(this->context, hP, nullptr, 10);
    222268//    /*static*/ PickupSpawner* PickupSpawner::createDroppedPickup(Context* context, Pickupable* pickup, PickupCarrier* carrier, float triggerDistance)
     269
     270
     271
     272        // if(thingy == nullptr){
     273        //     orxout(internal_error, context::pickups) << "Weird, can't create new PickupSpawner." << endl;
     274        // }
     275        // thingy->setPosition(this->getPosition());
     276        // thingy->setMaxSpawnedItems(1);//Default is 1 already, private anyways
     277       
    223278   
    224279
    225         // Smaller Parts
    226         if(this->generateSmaller){
    227             this->spawnChildren();
    228         }
     280        // // Smaller Parts
     281        // if(this->generateSmaller){
     282        //     this->spawnChildren();
     283        // }
    229284
    230285
     
    271326        //Spawn this child  Game crashes!
    272327        AsteroidMinable* child = new AsteroidMinable(this->context);
    273         child->setSize(extra + 1);
    274            
    275         //OFFEN:Kollision der Kinder verhindern
    276         //Relativ zu Elternteil automatisch?
    277         //Typ position:rand()*Vektoriwas?
    278         //pawn->getWorldPosition() + Vector3(30,0,-30);
    279         child->setPosition(this->getPosition() + Vector3(num*5, 0, 0));
     328        // if(!(child == nullptr)){//Errorgebastel
     329
     330
     331
     332            if(child == nullptr){
     333                orxout(internal_error, context::pickups) << "Weird, can't create new AsteroidMinable." << endl;
     334            }
     335
     336            child->setSize(extra + 1);
     337               
     338            //OFFEN:Kollision der Kinder verhindern
     339            //Relativ zu Elternteil automatisch?
     340            //Typ position:rand()*Vektoriwas?
     341            //pawn->getWorldPosition() + Vector3(30,0,-30);
     342            child->setPosition(this->getPosition() + Vector3(num*5, 0, 0));
     343
     344        // }
    280345
    281346
Note: See TracChangeset for help on using the changeset viewer.