using CinemaDirector.Helpers; using System.Collections.Generic; using UnityEngine; namespace CinemaDirector { /// /// An Actor event for disabling the Actor /// [CutsceneItemAttribute("Game Object", "Disable", CutsceneItemGenre.ActorItem)] public class DisableGameObject : CinemaActorEvent, IRevertable { // Options for reverting in editor. [SerializeField] private RevertMode editorRevertMode = RevertMode.Revert; // Options for reverting during runtime. [SerializeField] private RevertMode runtimeRevertMode = RevertMode.Revert; /// /// Cache the state of all actors related to this event. /// /// public RevertInfo[] CacheState() { List actors = new List(GetActors()); List reverts = new List(); foreach (Transform go in actors) { if (go != null) { reverts.Add(new RevertInfo(this, go.gameObject, "SetActive", go.gameObject.activeSelf)); } } return reverts.ToArray(); } /// /// Trigger this event and disable the given actor. /// /// The actor to be disabled. public override void Trigger(GameObject actor) { if (actor != null) { actor.SetActive(false); } } /// /// Reverse the event by settings the game object to the previous state. /// /// The actor whose active state will be reversed. public override void Reverse(GameObject actor) { if (actor != null) { actor.SetActive(true); // ToDo: Implement reversing with cacheing previous state. } } /// /// Option for choosing when this Event will Revert to initial state in Editor. /// public RevertMode EditorRevertMode { get { return editorRevertMode; } set { editorRevertMode = value; } } /// /// Option for choosing when this Event will Revert to initial state in Runtime. /// public RevertMode RuntimeRevertMode { get { return runtimeRevertMode; } set { runtimeRevertMode = value; } } } }