///<summary> Finds all Effects in the inputList matching the given Output. If there are none, the Effect will be added to inputList, otherwise the matching Effects are refreshed. </summary> public void Add(EnvironOutput effect, EnvironObject targetEO, EnvironObject lastSourceEO) { List <EnvironOutput> effectList = inputList.FindAll(e => e == effect); if (effectList.Count > 0) { foreach (EnvironOutput eOut in effectList) { eOut.Refresh(); } return; } EnvironOutput newEffect = UnityEngine.Object.Instantiate(effect); newEffect.Setup(targetEO, lastSourceEO); if (newEffect.appearanceI) { if (inputList.Count == 0 || IsPriority(newEffect.appearanceI)) //If the given Effect has a valid material Appearance that takes priority { newEffect.appearanceI.SetRendererMaterial(); //The material will be added to the Effect's set AppearanceI MeshRenderer. } } inputList.Add(newEffect); }
///<summary> Stops and destroys the particles of Effects in the cullList, then removes them from inputList and sets targetEO's appearance. </summary> public void CullInputList(EnvironObject targetEO) { if (cullList.Count == 0) { return; } var setToRemove = new HashSet <EnvironOutput>(cullList); foreach (EnvironOutput eOut in setToRemove) { if (eOut.appearanceI) { eOut.appearanceI.StopAndDestroy(); } } inputList.RemoveAll(x => setToRemove.Contains(x)); cullList.Clear(); SetMaterialAppearance(targetEO); }
///<summary> Determines the priority material AppearanceInfo in the inputList and applies it to the target MeshRenderer. </summary> private void SetMaterialAppearance(EnvironObject targetEO) { if (inputList.Count > 0) { EnvironOutput output = inputList.Find(eOut => eOut.appearanceI && eOut.appearanceI.canUseMaterial); if (output.appearanceI) //Sets the meshRenderer material of targetEO to: { output.appearanceI.SetRendererMaterial(); //apInfo material (from Effect in inputList) } else { targetEO.appearance.SetRendererMaterial(); //TargetEO's appearance material (reset) } } else { targetEO.appearance.SetRendererMaterial(); } }