Skip to content

Instantly share code, notes, and snippets.

@SLIB53
Created December 10, 2016 09:37
Show Gist options
  • Save SLIB53/3d9174591eaa24a1191e2767f43c071d to your computer and use it in GitHub Desktop.
Save SLIB53/3d9174591eaa24a1191e2767f43c071d to your computer and use it in GitHub Desktop.
using UnityEngine;
namespace SS.Aspects
{
public enum AspectStatus
{
Foreground, Background, Frozen, Off
}
public abstract class AspectCore : MonoBehaviour
{
public abstract void ProcessCommands();
}
public abstract class Aspect
{
public AspectStatus Status { get; set; }
}
public abstract class AspectCommand<TCore>
where TCore : AspectCore
{
public void Run(TCore core)
{
Process(core);
Post(core);
}
abstract protected void Process(TCore core);
abstract protected void Post(TCore core);
}
public class AspectTraitPublisher<T>
{
public delegate void TraitUpdateHandler(T newTraitValue);
public T LastPublishedValue { get; private set; }
public event TraitUpdateHandler OnUpdate;
public void PublishUpdate(T newTraitValue)
{
LastPublishedValue = newTraitValue;
if (OnUpdate != null)
OnUpdate(newTraitValue);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment