|
|
@@ -28,13 +28,12 @@ class ParticleEffect(NodePath):
|
|
|
def cleanup(self):
|
|
|
self.removeNode()
|
|
|
self.disable()
|
|
|
- if hasattr(self, 'forceGroupDict'):
|
|
|
+ if self.__isValid():
|
|
|
for f in self.forceGroupDict.values():
|
|
|
f.cleanup()
|
|
|
- del self.forceGroupDict
|
|
|
- if hasattr(self, 'particlesDict'):
|
|
|
for p in self.particlesDict.values():
|
|
|
p.cleanup()
|
|
|
+ del self.forceGroupDict
|
|
|
del self.particlesDict
|
|
|
del self.renderParent
|
|
|
|
|
|
@@ -53,7 +52,7 @@ class ParticleEffect(NodePath):
|
|
|
|
|
|
def enable(self):
|
|
|
# band-aid added for client crash - grw
|
|
|
- if hasattr(self, 'forceGroupDict') and hasattr(self, 'particlesDict'):
|
|
|
+ if self.__isValid():
|
|
|
if (self.renderParent != None):
|
|
|
for p in self.particlesDict.values():
|
|
|
p.setRenderParent(self.renderParent.node())
|
|
|
@@ -66,7 +65,7 @@ class ParticleEffect(NodePath):
|
|
|
def disable(self):
|
|
|
self.detachNode()
|
|
|
# band-aid added for client crash - grw
|
|
|
- if hasattr(self, 'forceGroupDict') and hasattr(self, 'particlesDict'):
|
|
|
+ if self.__isValid():
|
|
|
for p in self.particlesDict.values():
|
|
|
p.setRenderParent(p.node)
|
|
|
for f in self.forceGroupDict.values():
|
|
|
@@ -101,7 +100,7 @@ class ParticleEffect(NodePath):
|
|
|
|
|
|
forceGroup.nodePath.removeNode()
|
|
|
forceGroup.particleEffect = None
|
|
|
- del self.forceGroupDict[forceGroup.getName()]
|
|
|
+ self.forceGroupDict.pop(forceGroup.getName(), None)
|
|
|
|
|
|
def removeForce(self, force):
|
|
|
for p in self.particlesDict.values():
|
|
|
@@ -125,7 +124,7 @@ class ParticleEffect(NodePath):
|
|
|
self.notify.warning('removeParticles() - particles == None!')
|
|
|
return
|
|
|
particles.nodePath.detachNode()
|
|
|
- del self.particlesDict[particles.getName()]
|
|
|
+ self.particlesDict.pop(particles.getName(), None)
|
|
|
|
|
|
# Remove all forces from the particles
|
|
|
for fg in self.forceGroupDict.values():
|
|
|
@@ -216,5 +215,14 @@ class ParticleEffect(NodePath):
|
|
|
particles.softStop()
|
|
|
|
|
|
def softStart(self):
|
|
|
- for particles in self.getParticlesList():
|
|
|
- particles.softStart()
|
|
|
+ if self.__isValid():
|
|
|
+ for particles in self.getParticlesList():
|
|
|
+ particles.softStart()
|
|
|
+ else:
|
|
|
+ # Not asserting here since we want to crash live clients for more expedient bugfix
|
|
|
+ # (Sorry, live clients)
|
|
|
+ self.notify.error('Trying to start effect(%s) after cleanup.' % (self.getName(),))
|
|
|
+
|
|
|
+ def __isValid(self):
|
|
|
+ return hasattr(self, 'forceGroupDict') and \
|
|
|
+ hasattr(self, 'particlesDict')
|