Created
December 10, 2016 09:37
-
-
Save SLIB53/3d9174591eaa24a1191e2767f43c071d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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