#if HAVE_SLATE
using System;
using UnityEngine;
using Slate;
using Slate.ActionClips;
namespace Framework.Actors {
/// Switches an actor presenter to a different state
[Category("Actors")]
[Description("Change the animation state of an actor presenter")]
public class SetPresenterStateAction : ActorActionClip {
/// State to which the actor presenter will be switched
public int State;
/// Summary of what this action does
public override string info {
get { return "Set State " + this.State.ToString(); }
}
/// Called before the event is played back for the first time
protected override void OnEnter() {
this.actorPresenter = actor.GetComponent();
if(this.actorPresenter == null) {
Debug.LogWarning(
"SetPresenterStateAction used on '" + actor.name + "' could not " +
"find an ActorPresenter component to set the state on"
);
return;
}
this.previousState = this.actorPresenter.State;
this.actorPresenter.State = this.State;
}
/// Called when the action's effects should be reversed
///
/// Called either after the event has been scrubbed/played in reverse
/// or when the stop button is hit after the event was played.
///
protected override void OnReverse() {
if(this.actorPresenter != null) {
this.actorPresenter.State = this.previousState;
}
}
/// Actor presenter on which the state was set
private ActorPresenter actorPresenter;
/// Previous state the actor presenter had been holding
private int previousState;
}
} // namespace Framework.Cinematics
#endif // HAVE_SLATE