void UpdateReaction(ParticleMap partMap, TemperatureMap tempMap) { bool pass; if (!stable) { pass = stable; } else { // even if stable check for reactions regularly (tanks performance) pass = !(stableTime % 10 == 0); } ElementID result = Element.elements[ID].UpdateReaction(pos, lifeTime, pass, partMap, tempMap); if (result != this.ID) { SetStable(false); partMap.UnstableSurroundingParticles(this.pos); unstableTimeout = 0; if (result == ElementID.VOID) // void == deleted { partMap.DeleteLater(this.pos, 0); SetStable(true); //dont update pos after deleting } else if (result == ElementID.EXPLOSION) { partMap.DeleteLater(this.pos, 0); partMap.SpawnLater(ElementID.FIRE, this.pos, Element.elements[ID].ExplosivePwr); SetStable(true); //dont update pos after deleting } else { this.ID = result; this.lifeTime = 0; } } }
void UpdatePosition(ParticleMap partMap) { Point result = Element.elements[ID].UpdatePosition(pos, partMap); if (result != this.pos) { partMap.UnstableSurroundingParticles(this.pos); partMap.Swap(this.pos, result); unstableTimeout = 0; } else { if (unstableTimeout < 50) // wait for a while before making it stable { unstableTimeout++; } else { SetStable(true); this.stableTime = 0; } } }