/// <summary> /// Dispose this particle system, unloading resources created by it's processor and storage children /// </summary> public void Dispose() { if (disposed) return; disposed = true; this.threadWaitCallback.WaitForCompletion(); this.timeStep = 0; this.renderStepCount = 0; this.systemData = null; this.systemLogic = null; for (int i = 0; i < this.particleStore.Length; i++) { this.particleStore[i].Dispose(); this.particleStore[i] = null; } for (int i = 0; i < this.triggers.Length; i++) { this.triggers[i] = null; } for (int i = 0; i < this.toggles.Length; i++) { this.toggles[i] = null; } for (int i = 0; i < particleStoreSortedDrawOrder.Length; i++) { if (particleStoreSortedDrawOrder[i] != null) particleStoreSortedDrawOrder[i].Clear(); } particleStoreSortedDrawOrder = null; }
//creates the particle system storage classes (store all particle life data) private void Initalise(ParticleSystemData systemData, Type processorType) { if (systemData == null) throw new ArgumentNullException(); this.systemData = systemData; this.enabled = true; //build the triggers this.triggers = new ParticleSystemTrigger[systemData.SystemLogicData.Triggers.Length]; for (int i = 0; i < this.triggers.Length; i++) this.triggers[i] = new ParticleSystemTrigger(this, i); this.toggles = new ParticleSystemToggleTrigger[systemData.SystemLogicData.ToggleTriggers.Length]; for (int i = 0; i < this.toggles.Length; i++) this.toggles[i] = new ParticleSystemToggleTrigger(this, i); this.systemLogic = systemData.SystemLogicData; //create the storage for the particle instances if (processorType == null) this.particleStore = systemData.CreateParticleProfilerStore(); else this.particleStore = systemData.CreateParticleStore(processorType); this.particleStoreSortedDrawOrder = new List<ParticleStore>[4]; //fill with a few empty entires for (int i = 0; i < particleStoreSortedDrawOrder.Length; i++) particleStoreSortedDrawOrder[i] = new List<ParticleStore>(particleStore.Length); typeDependancyList = new int[this.particleStore.Length * 2]; activeSpawnDetails = this.userSpawnDetails; //run the 'once' emitter if (this.systemLogic.OnceEmitter != null) this.systemLogic.OnceEmitter.Run(this, 0); }