void SetEmitState(FluidParticleSystem F, bool state) { GameObject Ps = ParticleSystemPool[F.index]; if (Ps == null) { return; } VisualEffect Effect = Ps.GetComponent <VisualEffect>(); if (Effect != null) { if (state) { Effect.Play(); } else { Effect.Stop(); } } else { Debug.Log("Prefab Missing VFX"); } }
bool FindAndUpdatePS(FluidParticleSystem f) { for (int i = 0; i < CurrentSystems.Count; i++) { if (CurrentSystems[i].Pos == f.Pos) { CurrentSystems[i].TimeLeft = SystemLength; return(true); } } return(false); }
void ReleaseBackToPool(FluidParticleSystem F) { if (F.index == -2) { Debug.LogError("ReleaseBackToPool called twice"); return; } GameObject Ps = ParticleSystemPool[F.index]; Ps.SetActive(false); FreeIndex.Add(F.index); F.index = -2; }
public void NotifyFluidInteraction(Vector3 pos, float amt) { FluidParticleSystem FPS = new FluidParticleSystem(); FPS.Pos = pos; FPS.Amount = amt; FPS.TimeLeft = SystemLength; FPS.index = -1; if (FindAndUpdatePS(FPS)) { return; } CurrentSystems.Add(FPS); }
GameObject GetFromPool(FluidParticleSystem F) { if (FreeIndex.Count == 0) { AddToPool(); if (FreeIndex.Count == 0) { Debug.Log("Pool full"); return(null); } } int index = FreeIndex[0]; F.index = index; FreeIndex.RemoveAt(0); return(ParticleSystemPool[index]); }
// Use this for initialization void Start() { parSys = this.GetComponent <FluidParticleSystem> (); numParticles = parSys.GetParticleSystem().main.maxParticles; if (baseParticle != null) { smokeParticles = new GameObject[numParticles]; smokeParticles [0] = baseParticle; for (int i = 1; i < numParticles; i++) { smokeParticles [i] = GameObject.Instantiate(baseParticle); smokeParticles [i].SetActive(false); } smokeParticles [0].SetActive(false); } }
void PlaceSystem(FluidParticleSystem F) { GameObject Ps = GetFromPool(F); if (Ps == null) { return; } Ps.SetActive(true); F.Pos.y = YHeight; Ps.transform.position = F.Pos; VisualEffect Effect = Ps.GetComponent <VisualEffect>(); if (Effect != null) { Effect.Stop(); Effect.Reinit(); Effect.Play(); } else { Debug.Log("Prefab Missing VFX"); } }