Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10414 for code/branches


Ignore:
Timestamp:
May 3, 2015, 11:47:50 AM (10 years ago)
Author:
landauf
Message:

destroy all remaining ship parts if ModularSpaceShip is destroyed.
separate ship part death effects from object deletion. ShipPart.death() creates effects, ShipPartManager destroys the instance.

Location:
code/branches/core7/src/orxonox
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core7/src/orxonox/ShipPartManager.cc

    r10413 r10414  
    4646    ShipPartManager::~ShipPartManager()
    4747    {
    48         // Be sure to delete all the pawns
     48        // Be sure to delete all the ship parts
    4949        for (ObjectList<ShipPart>::iterator it = ObjectList<ShipPart>::begin(); it != ObjectList<ShipPart>::end(); )
    50             (it++)->death();
     50            (it++)->destroy();
    5151    }
    5252
     
    5656        {
    5757            if (!it->isAlive())
    58                 (it++)->death();
     58                (it++)->destroy();
    5959            else
    6060                ++it;
  • code/branches/core7/src/orxonox/items/ShipPart.cc

    r10262 r10414  
    5050
    5151    ShipPart::ShipPart(Context* context)
    52         : Item(context)
     52        : Item(context), parent_(NULL)
    5353    {
    5454        RegisterObject(ShipPart);
    55         this->setAlive(true);
    56         this->setEventExecution(true);
     55        this->alive_ = true;
     56        this->eventExecution_ = true;
    5757        this->healthMem_ = 100;
    5858    }
     
    6060    ShipPart::~ShipPart()
    6161    {
    62 
     62        if (this->parent_)
     63        {
     64            // Remove this ShipPart from the parent.
     65            this->parent_->removeShipPart(this);
     66        }
    6367    }
    6468
     
    100104            }
    101105        }
    102 
    103         // Remove this ShipPart from the parent.
    104         this->parent_->removeShipPart(this);
    105         delete this;
    106106    }
    107107
     
    240240        }
    241241        if (this->health_ < 0)
    242             this->alive_ = false;
    243             //this->death();
     242            this->death();
    244243
    245244        // (Ugly) Chatoutput of health, until a GUI for modularspaceships-shipparts is implemented.
  • code/branches/core7/src/orxonox/worldentities/pawns/ModularSpaceShip.cc

    r10347 r10414  
    6969        if (this->isInitialized())
    7070        {
    71 
     71            while (!this->partList_.empty())
     72                this->partList_[0]->destroy();
    7273        }
    7374    }
     
    177178            if (it->second->getName() == name)
    178179            {
    179                 it->second->setAlive(false);
     180                it->second->death();
    180181                return;
    181182            }
     
    196197            if (it->second->getName() == name)
    197198            {
    198                 it->second->setAlive(false);
     199                it->second->death();
    199200                return;
    200201            }
Note: See TracChangeset for help on using the changeset viewer.