using System.Collections.Generic; namespace OM.TimelineCreator.Runtime { /// /// Interface defining the contract for a timeline playback engine. /// Implementors are responsible for managing clips, controlling playback state (Play, Pause, Stop), /// evaluating clips over time, and providing essential properties and events for editor integration /// and runtime interaction. /// /// The specific type of OM_ClipBase managed by this player (e.g., AnimoraClip). public interface IOM_TimelinePlayer where T : OM_ClipBase { // --- Events --- /// /// Event triggered frequently during playback, providing the current elapsed time. /// Useful for updating UI elements or synchronizing other systems. /// Parameter: float (elapsedTime) /// public event System.Action OnElapsedTimeChangedCallback; /// /// Event triggered when internal data relevant to editor validation might have changed. /// Signals the editor or custom drawers to re-validate the player's state. /// public event System.Action OnPlayerValidateCallback; /// /// Event triggered whenever the playback state (Playing, Paused, Stopped) changes. /// Parameter: OM_PlayState (newState) /// public event System.Action OnPlayStateChanged; /// /// Event triggered to signal the editor UI that it should refresh its display. /// Typically invoked after significant changes like loading data or structural modifications. /// public event System.Action OnTriggerEditorRefresh; /// /// Event triggered whenever a clip is added to or removed from the player's clip manager. /// Useful for editor UI updates. /// public event System.Action OnClipAddedOrRemoved; /// /// Event triggered specifically when a clip is added. /// Parameter: T (clipAdded) - The clip that was added. /// public event System.Action OnClipAdded; /// /// Event triggered specifically when a clip is removed. /// Parameter: T (clipRemoved) - The clip that was removed. /// public event System.Action OnClipRemoved; // --- Properties --- /// /// Gets the clip manager instance responsible for storing and managing the clips associated with this player. /// public OM_ClipsManager ClipsManager { get; } /// /// Gets the current elapsed time within the timeline's duration (in seconds). /// This value typically progresses from 0 to GetTimelineDuration() (or vice-versa if playing backward). /// public float ElapsedTime { get; } /// /// Gets the index of the currently selected clip in the editor UI context. /// Returns -1 if no clip is selected. /// public int SelectedClipIndex { get; } // --- Methods --- /// /// Performs initialization steps required specifically for the editor environment. /// This might include setting up editor-only data structures or validating initial state. /// public void InitPlayerForEditor(); /// /// Gets the total duration of the timeline (in seconds). /// Playback typically loops or stops when ElapsedTime reaches this value (or 0 if playing backward). /// /// The total duration in seconds. public float GetTimelineDuration(); /// /// Sets the total duration of the timeline (in seconds). /// /// The new total duration. public void SetTimelineDuration(float newDuration); /// /// Sets the current elapsed time of the player. Clamps the value between 0 and the timeline duration. /// This is used for scrubbing or seeking within the timeline. /// /// The desired elapsed time (in seconds). public void SetElapsedTime(float newElapsedTime); /// /// Adds a new clip to the timeline via the ClipsManager. /// /// The clip instance to add. public void AddClip(T clipToAdd); /// /// Removes a clip from the timeline via the ClipsManager. /// /// The clip instance to remove. public void RemoveClip(T clipToRemove); /// /// Duplicates an existing clip and adds the copy to the timeline, typically adjacent to the original. /// /// The clip instance to duplicate. public void DuplicateClip(T clipToDuplicate); /// /// Gets an enumerable collection of all clips currently managed by the player. /// The order might depend on the implementation (e.g., insertion order or sorted by OrderIndex). /// /// An IEnumerable containing all clips. public IEnumerable GetClips(); /// /// Records an action for the Unity Undo system. Essential for making editor changes undoable. /// /// The name displayed in the Undo history (e.g., "Move Clip"). public void RecordUndo(string undoName); /// /// Called when the player's data might need validation, often triggered by changes in the editor. /// Implementors should perform necessary checks and potentially update internal state or editor UI. /// public void OnValidate(); /// /// Sets the index of the currently selected clip in the editor context. /// Used by the editor UI to inform the player about the selection state. /// /// The index of the selected clip, or -1 for no selection. public void SetSelectedClipIndex(int index); /// /// Gets the index of the currently selected clip. /// Used by the editor UI or other systems to query the selection state. /// /// The index of the selected clip, or -1 if none. public int GetSelectedClipIndex(); } }