74 lines
2.7 KiB
C#
74 lines
2.7 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace Golems
|
|
{
|
|
/// <summary>
|
|
/// 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.
|
|
/// </summary>
|
|
public class GhostObjectCollection
|
|
{
|
|
/// <summary>
|
|
/// The active singleton of GhostObjectCollection
|
|
/// </summary>
|
|
private static GhostObjectCollection m_Instance;
|
|
|
|
public static GhostObjectCollection Instance
|
|
{
|
|
get
|
|
{
|
|
if (m_Instance == null) new GhostObjectCollection();
|
|
return m_Instance;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Collection of all the Ghost Object Behaviours which require rendering
|
|
/// </summary>
|
|
public List<GhostObjectBehaviour> GhostObjectBehaviours { get; private set; }
|
|
|
|
/// <summary>
|
|
/// Flag if there's anything Ghost Object Behaviours which require rendering
|
|
/// </summary>
|
|
public bool HasSomethingToRender()=> GhostObjectBehaviours != null && GhostObjectBehaviours.Count > 0;
|
|
|
|
/// <summary>
|
|
/// 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...
|
|
/// </summary>
|
|
public int NumberOfObjectsRendered = 0;
|
|
|
|
private GhostObjectCollection()
|
|
{
|
|
m_Instance = this;
|
|
GhostObjectBehaviours = new List<GhostObjectBehaviour>();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Add the passed Ghost Object Behaviour to Albert Ghost Memory pass
|
|
/// </summary>
|
|
public void AddGhostObjectBehaviour(GhostObjectBehaviour ghostObjectBehaviour)
|
|
{
|
|
if (ghostObjectBehaviour == null) return;
|
|
GhostObjectBehaviours.Add(ghostObjectBehaviour);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Remove the passed Ghost Object Behaviour to Albert Ghost Memory pass
|
|
/// </summary>
|
|
public void RemoveGhostObjectBehaviour(GhostObjectBehaviour ghostObjectBehaviour)
|
|
{
|
|
if (ghostObjectBehaviour == null) return;
|
|
GhostObjectBehaviours.Remove(ghostObjectBehaviour);
|
|
}
|
|
}
|
|
}
|
|
|