First Commit
This commit is contained in:
73
Assets/Scripts/RenderPasses/GhostObjectCollection.cs
Normal file
73
Assets/Scripts/RenderPasses/GhostObjectCollection.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user