Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 30, 2012, 11:08:17 PM (12 years ago)
Author:
landauf
Message:

merged branch presentation2012merge back to trunk

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/modules/pickup/PickupRepresentation.cc

    r8858 r9348  
    5252        This is primarily for use of the PickupManager in creating a default PickupRepresentation.
    5353    */
    54     PickupRepresentation::PickupRepresentation() : BaseObject(NULL), Synchronisable(NULL), spawnerRepresentation_(NULL), pickup_(NULL)
     54    PickupRepresentation::PickupRepresentation() : BaseObject(NULL), Synchronisable(NULL), spawnerRepresentation_(NULL)
    5555    {
    5656        RegisterObject(PickupRepresentation);
     
    6464        Default Constructor. Registers the object and initializes its member variables.
    6565    */
    66     PickupRepresentation::PickupRepresentation(BaseObject* creator) : BaseObject(creator), Synchronisable(creator), spawnerRepresentation_(NULL), pickup_(NULL)
     66    PickupRepresentation::PickupRepresentation(BaseObject* creator) : BaseObject(creator), Synchronisable(creator), spawnerRepresentation_(NULL)
    6767    {
    6868        RegisterObject(PickupRepresentation);
     
    7070        this->initialize();
    7171        this->registerVariables();
    72 
    73         PickupManager::getInstance().registerRepresentation(this); // Registers the PickupRepresentation with the PickupManager.
    7472    }
    7573
     
    8482
    8583        if(this->isInitialized())
    86         {
    87             if(GameMode::isMaster() && this->pickup_ != NULL)
    88             {
    89                 PickupManager::getInstance().unregisterRepresentation(this->pickup_->getPickupIdentifier(), this);
    90             }
    91             PickupManager::getInstance().unregisterRepresentation(this);
    92         }
     84            PickupManager::getInstance().unregisterRepresentation(this->getName());
    9385    }
    9486
     
    128120        XMLPortParam(PickupRepresentation, "spawnerTemplate", setSpawnerTemplate, getSpawnerTemplate, xmlelement, mode);
    129121        XMLPortParam(PickupRepresentation, "inventoryRepresentation", setInventoryRepresentation, getInventoryRepresentation, xmlelement, mode);
    130         XMLPortObject(PickupRepresentation, Pickupable, "pickup", setPickup, getPickup, xmlelement, mode);
    131122        XMLPortObject(PickupRepresentation, StaticEntity, "spawner-representation", setSpawnerRepresentation, getSpawnerRepresentationIndex, xmlelement, mode);
    132 
    133         if(GameMode::isMaster())
    134         {
    135             // Registers the PickupRepresentation with the PickupManager through the PickupIdentifier of the Pickupable it represents.
    136             PickupManager::getInstance().registerRepresentation(this->pickup_->getPickupIdentifier(), this);
    137         }
    138 
    139         if(this->spawnerRepresentation_ != NULL)
    140             this->spawnerRepresentation_->setVisible(false);
    141123
    142124        orxout(verbose, context::pickups) << "PickupRepresentation created: name: '" << this->name_ << "', description: '" << this->description_ << "', spawnerTemplate: '" << this->spawnerTemplate_ << "'." << endl;
     
    151133        Returns a pointer to the StaticEntity.
    152134    */
    153     StaticEntity* PickupRepresentation::getSpawnerRepresentation(PickupSpawner* spawner)
     135    StaticEntity* PickupRepresentation::createSpawnerRepresentation(PickupSpawner* spawner)
    154136    {
    155137        if(this->spawnerRepresentation_ == NULL)
     
    158140            if(this->spawnerTemplate_ == "")
    159141            {
    160                 orxout(verbose, context::pickups) << "PickupRepresentation: Spawner template is empty." << endl;
     142                orxout(internal_warning, context::pickups) << "PickupRepresentation: Spawner template is empty." << endl;
    161143                // If neither spawnerRepresentation nor spawnerTemplate was specified
    162144                return this->getDefaultSpawnerRepresentation(spawner);
     
    165147        }
    166148
    167         StaticEntity* representation = this->spawnerRepresentation_;
    168         representation->setVisible(true);
     149        this->spawnerRepresentation_->setVisible(true);
     150        StaticEntity* temp = this->spawnerRepresentation_;
     151        this->spawnerRepresentation_ = NULL;
    169152
    170         this->addTemplate(this->spawnerTemplate_);
    171         this->spawnerRepresentation_->setVisible(false);
     153        return temp;
     154    }
    172155
    173         return representation;
     156    void PickupRepresentation::changedName()
     157    {
     158        // Registers the PickupRepresentation with the PickupManager.
     159        PickupManager::getInstance().unregisterRepresentation(this->getOldName());
     160        PickupManager::getInstance().registerRepresentation(this->getName(), this);
     161    }
     162
     163    void PickupRepresentation::setSpawnerRepresentation(StaticEntity* representation)
     164    {
     165        this->spawnerRepresentation_ = representation;
     166        if(this->spawnerRepresentation_ != NULL)
     167            this->spawnerRepresentation_->setVisible(false);
    174168    }
    175169
Note: See TracChangeset for help on using the changeset viewer.