From 8f1605a30e71fd5ad6f3e100a9d08077d0cb8ffa Mon Sep 17 00:00:00 2001 From: Mike Goslin Date: Wed, 29 Aug 2001 00:00:29 +0000 Subject: [PATCH] *** empty log message *** --- direct/src/interval/IntervalGlobal.py | 1 + direct/src/interval/ParticleInterval.py | 56 +++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 direct/src/interval/ParticleInterval.py diff --git a/direct/src/interval/IntervalGlobal.py b/direct/src/interval/IntervalGlobal.py index 2d3745095f..a1c7690d01 100644 --- a/direct/src/interval/IntervalGlobal.py +++ b/direct/src/interval/IntervalGlobal.py @@ -6,6 +6,7 @@ from ActorInterval import * from FunctionInterval import * from LerpInterval import * from MopathInterval import * +from ParticleInterval import * from SoundInterval import * from WaitInterval import * diff --git a/direct/src/interval/ParticleInterval.py b/direct/src/interval/ParticleInterval.py new file mode 100644 index 0000000000..2dc885519c --- /dev/null +++ b/direct/src/interval/ParticleInterval.py @@ -0,0 +1,56 @@ +"""ParticleInterval module: contains the ParticleInterval class""" + +from PandaModules import * +from Interval import * + +import BattleParticles + +class ParticleInterval(Interval): + # Name counter + particleNum = 1 + # create ParticleInterval DirectNotify category + notify = directNotify.newCategory('ParticleInterval') + # Class methods + def __init__(self, particleEffect, parent, worldRelative=1, loop=0, + duration=0.0, name=None): + """__init__(particleEffect, parent, worldRelative, loop, duration, name) + """ + # Generate unique name + id = 'Particle-%d' % ParticleInterval.particleNum + ParticleInterval.particleNum += 1 + if (name == None): + name = id + # Record instance variables + self.particleEffect = particleEffect + self.parent = parent + self.worldRelative = worldRelative + self.loop = loop + assert(duration > 0.0 or loop == 1) + # Initialize superclass + Interval.__init__(self, name, duration) + # Update stopEvent + self.stopEvent = id + '_stopEvent' + self.stopEventList = [self.stopEvent] + + def updateFunc(self, t, event=IVAL_NONE): + """ updateFunc(t, event) + Go to time t + """ + # Update particle effect based on current time + if (t >= self.getDuration()): + # If duration reached or stop event received, stop particle effect + BattleParticles.cleanupParticleEffect(self.particleEffect) + self.ignore(self.stopEvent) + elif (event == IVAL_INIT): + # IVAL_INIT event, start new particle effect + BattleParticles.startParticleEffect(self.particleEffect, + self.parent, self.worldRelative) + # Accept event to kill particle effect + self.acceptOnce(self.stopEvent, + lambda s = self: + BattleParticles.cleanupParticleEffect(s.particleEffect)) + # Print debug information + self.notify.debug('updateFunc() - %s: t = %f' % (self.name, t)) + + +