Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 16, 2008, 6:01:13 PM (17 years ago)
Author:
landauf
Message:

Merged objecthierarchy2 into presentation branch

Couln't merge 2 lines in Gamestate.cc and a whole block of code in GSDedicated.cc (it seems like oli implemented in both branches something like a network-tick-limiter but with different approaches)

Not yet tested in network mode and with bots
The SpaceShips movement is also not yet fully adopted to the new physics (see Engine class)

Location:
code/branches/presentation
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation

  • code/branches/presentation/src/orxonox/objects/worldentities/pawns/Pawn.cc

    r2371 r2485  
    3030#include "Pawn.h"
    3131
     32#include "core/Core.h"
    3233#include "core/CoreIncludes.h"
    3334#include "core/XMLPort.h"
    3435#include "util/Math.h"
     36#include "PawnManager.h"
    3537#include "objects/infos/PlayerInfo.h"
    3638#include "objects/gametypes/Gametype.h"
    3739#include "objects/weaponSystem/WeaponSystem.h"
     40#include "objects/worldentities/ParticleSpawner.h"
     41#include "objects/worldentities/ExplosionChunk.h"
    3842
    3943namespace orxonox
     
    4549        RegisterObject(Pawn);
    4650
    47         this->bAlive_ = false;
     51        PawnManager::touch();
     52
     53        this->bAlive_ = true;
    4854
    4955        this->health_ = 0;
     
    5359        this->lastHitOriginator_ = 0;
    5460        this->weaponSystem_ = 0;
     61
     62        this->spawnparticleduration_ = 3.0f;
    5563
    5664        /*
     
    6270        */
    6371
     72        this->setRadarObjectColour(ColourValue::Red);
     73        this->setRadarObjectShape(RadarViewable::Dot);
     74
    6475        this->registerVariables();
    6576    }
     
    6778    Pawn::~Pawn()
    6879    {
     80        if (this->isInitialized())
     81        {
     82            for (ObjectList<PawnListener>::iterator it = ObjectList<PawnListener>::begin(); it != ObjectList<PawnListener>::end(); ++it)
     83                it->destroyedPawn(this);
     84        }
    6985    }
    7086
     
    7389        SUPER(Pawn, XMLPort, xmlelement, mode);
    7490
    75         XMLPortParam(Pawn, "health", setHealth, getHealht, xmlelement, mode).defaultValues(100);
     91        XMLPortParam(Pawn, "health", setHealth, getHealth, xmlelement, mode).defaultValues(100);
    7692        XMLPortParam(Pawn, "maxhealth", setMaxHealth, getMaxHealth, xmlelement, mode).defaultValues(200);
    7793        XMLPortParam(Pawn, "initialhealth", setInitialHealth, getInitialHealth, xmlelement, mode).defaultValues(100);
     94        XMLPortParam(Pawn, "spawnparticlesource", setSpawnParticleSource, getSpawnParticleSource, xmlelement, mode);
     95        XMLPortParam(Pawn, "spawnparticleduration", setSpawnParticleDuration, getSpawnParticleDuration, xmlelement, mode).defaultValues(3.0f);
     96        XMLPortParam(Pawn, "explosionchunks", setExplosionChunks, getExplosionChunks, xmlelement, mode).defaultValues(7);
    7897    }
    7998
    8099    void Pawn::registerVariables()
    81100    {
    82         registerVariable(this->bAlive_, variableDirection::toclient);
    83         registerVariable(this->health_, variableDirection::toclient);
     101        registerVariable(this->bAlive_,        variableDirection::toclient);
     102        registerVariable(this->health_,        variableDirection::toclient);
     103        registerVariable(this->initialHealth_, variableDirection::toclient);
    84104    }
    85105
     
    119139    }
    120140
    121     void Pawn::spawn()
     141    void Pawn::spawneffect()
    122142    {
    123143        // play spawn effect
     144        if (this->spawnparticlesource_ != "")
     145        {
     146            ParticleSpawner* effect = new ParticleSpawner(this->getCreator());
     147            effect->setPosition(this->getPosition());
     148            effect->setOrientation(this->getOrientation());
     149            effect->setDestroyAfterLife(true);
     150            effect->setSource(this->spawnparticlesource_);
     151            effect->setLifetime(this->spawnparticleduration_);
     152        }
    124153    }
    125154
    126155    void Pawn::death()
    127156    {
     157        // Set bAlive_ to false and wait for PawnManager to do the destruction
    128158        this->bAlive_ = false;
     159
     160        this->setDestroyWhenPlayerLeft(false);
     161
    129162        if (this->getGametype())
    130163            this->getGametype()->pawnKilled(this, this->lastHitOriginator_);
     164
    131165        if (this->getPlayer())
    132166            this->getPlayer()->stopControl(this);
    133167
    134         delete this;
    135 
     168        if (Core::isMaster())
     169            this->deatheffect();
     170    }
     171
     172    void Pawn::deatheffect()
     173    {
    136174        // play death effect
     175        {
     176            ParticleSpawner* effect = new ParticleSpawner(this->getCreator());
     177            effect->setPosition(this->getPosition());
     178            effect->setOrientation(this->getOrientation());
     179            effect->setDestroyAfterLife(true);
     180            effect->setSource("Orxonox/explosion2b");
     181            effect->setLifetime(4.0f);
     182        }
     183        {
     184            ParticleSpawner* effect = new ParticleSpawner(this->getCreator());
     185            effect->setPosition(this->getPosition());
     186            effect->setOrientation(this->getOrientation());
     187            effect->setDestroyAfterLife(true);
     188            effect->setSource("Orxonox/smoke6");
     189            effect->setLifetime(4.0f);
     190        }
     191        {
     192            ParticleSpawner* effect = new ParticleSpawner(this->getCreator());
     193            effect->setPosition(this->getPosition());
     194            effect->setOrientation(this->getOrientation());
     195            effect->setDestroyAfterLife(true);
     196            effect->setSource("Orxonox/sparks");
     197            effect->setLifetime(4.0f);
     198        }
     199        for (unsigned int i = 0; i < this->numexplosionchunks_; ++i)
     200        {
     201            ExplosionChunk* chunk = new ExplosionChunk(this->getCreator());
     202            chunk->setPosition(this->getPosition());
     203
     204        }
    137205    }
    138206
     
    146214    {
    147215        this->setHealth(this->initialHealth_);
    148         this->spawn();
     216        if (Core::isMaster())
     217            this->spawneffect();
     218    }
     219
     220    ///////////////////
     221    // Pawn Listener //
     222    ///////////////////
     223    PawnListener::PawnListener()
     224    {
     225        RegisterRootObject(PawnListener);
    149226    }
    150227}
Note: See TracChangeset for help on using the changeset viewer.