using System.Collections.Generic; using UnityEngine; namespace Golems { /// /// A gross singleton collection of all the Ghost Object Behaviours /// which require rendering via Albert Ghost Memory This is purely /// convenience for the AlbertGhostMemory to access Ghost Object Behaviours /// and for Ghost Object Behaviours to register/unregister themselves. /// public class GhostObjectCollection { /// /// The active singleton of GhostObjectCollection /// private static GhostObjectCollection m_Instance; public static GhostObjectCollection Instance { get { if (m_Instance == null) new GhostObjectCollection(); return m_Instance; } } /// /// Collection of all the Ghost Object Behaviours which require rendering /// public List GhostObjectBehaviours { get; private set; } /// /// Flag if there's anything Ghost Object Behaviours which require rendering /// public bool HasSomethingToRender()=> GhostObjectBehaviours != null && GhostObjectBehaviours.Count > 0; /// /// The number of objects rendered in AlbertGhostMemoryPass. /// This is reset in AlbertGhostMemoryPass.Execute() and incremented in /// DrawObjectsDefault(). /// ComposeOutlinePass uses this in AddRenderPasses, if it's zero screen copy Blit is avoided. /// /// N.B This is a sketchy place to do this sort of thing, full acknowledged but it's quick, easy and works... /// public int NumberOfObjectsRendered = 0; private GhostObjectCollection() { m_Instance = this; GhostObjectBehaviours = new List(); } /// /// Add the passed Ghost Object Behaviour to Albert Ghost Memory pass /// public void AddGhostObjectBehaviour(GhostObjectBehaviour ghostObjectBehaviour) { if (ghostObjectBehaviour == null) return; GhostObjectBehaviours.Add(ghostObjectBehaviour); } /// /// Remove the passed Ghost Object Behaviour to Albert Ghost Memory pass /// public void RemoveGhostObjectBehaviour(GhostObjectBehaviour ghostObjectBehaviour) { if (ghostObjectBehaviour == null) return; GhostObjectBehaviours.Remove(ghostObjectBehaviour); } } }