Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11031


Ignore:
Timestamp:
Jan 3, 2016, 9:46:11 PM (9 years ago)
Author:
landauf
Message:

bugfix: due to a limitation of the framework, timers are not automatically destroyed at the end of a level. every timer must be controlled (and destroyed) by a BaseObject (or a descendant). this was not the case for the timer in IceGunProjectile, causing errors when a level ended while a timer was still active.
I fixed this by using a ParticleSpawner (instead of a ParticleEmitter) which is designed to destroy an emitter after a given time, thus perfectly suited for our needs.

Location:
code/branches/presentationHS15/src/modules/weapons/projectiles
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentationHS15/src/modules/weapons/projectiles/IceGunProjectile.cc

    r11026 r11031  
    6666
    6767        // Add effect.
    68         emitter_ = new ParticleEmitter(this->getContext());
    69         this->attach(emitter_);
    70         emitter_->setOrientation(this->getOrientation());
    71         emitter_->setSource("Orxonox/ice");   
    72         emitter_->setDeleteWithParent(false);     
     68        spawner_ = new ParticleSpawner(this->getContext());
     69        this->attach(spawner_);
     70        spawner_->setOrientation(this->getOrientation());
     71        spawner_->setSource("Orxonox/ice");
     72        spawner_->setDeleteWithParent(false);
     73        spawner_->setDestroydelay(particleDestructionDelay_);
    7374    }
    7475
     
    7778        if (this->isInitialized())
    7879        {
    79             const Vector3& pos = emitter_->getWorldPosition();
    80             const Quaternion& rot = emitter_->getWorldOrientation();
    81             this->detach(emitter_);
    82             emitter_->setPosition(pos);
    83             emitter_->setOrientation(rot);
    84             emitter_->getParticleInterface()->setEnabled(false);
    85             this->getScene()->getRootSceneNode()->addChild(const_cast<Ogre::SceneNode*>(emitter_->getNode()));
    86 
    87             const ExecutorPtr& executor = createExecutor(createFunctor(&ParticleEmitter::destroy, emitter_));
    88             new Timer(particleDestructionDelay_, false, executor, true);
     80            const Vector3& pos = spawner_->getWorldPosition();
     81            const Quaternion& rot = spawner_->getWorldOrientation();
     82            this->detach(spawner_);
     83            spawner_->setPosition(pos);
     84            spawner_->setOrientation(rot);
     85            this->getScene()->getRootSceneNode()->addChild(const_cast<Ogre::SceneNode*>(spawner_->getNode()));
     86            this->spawner_->stop(true);
    8987        }
    9088    }
  • code/branches/presentationHS15/src/modules/weapons/projectiles/IceGunProjectile.h

    r11026 r11031  
    6565            static const float particleDestructionDelay_;
    6666        private:
    67             ParticleEmitter* emitter_;
     67            ParticleSpawner* spawner_;
    6868            float freezeTime_; //The duration of the freezing effect on a target
    6969            float freezeFactor_; //The strength of the freezing effect
Note: See TracChangeset for help on using the changeset viewer.