/// <summary> /// Copies the state from another <see cref="ActorAction"/>. /// </summary> /// <param name="other">An <see cref="ActorAction"/> to copy state from.</param> public void CopyFrom(ActorAction other) { this.Value = other.Value; this.LastValue = other.LastValue; this.Tolerance = other.Tolerance; this.HeldTime = other.HeldTime; this.Icon = other.Icon; }
/// <summary> /// Activates an action by copying values from another. /// </summary> /// <param name="name">The name of the action to activate.</param> /// <param name="other">The source action.</param> public void Activate(string name, ActorAction other) { ActorAction action = this.GetOrCreateAction(name); if (action != null) { action.CopyFrom(other); } }
/// <summary> /// Deactives an action. /// </summary> /// <param name="name">The name of the action.</param> public void Deactivate(string name) { ActorAction action = this.GetOrCreateAction(name); if (action != null) { action.Value = Vector2.zero; } }
/// <summary> /// Actives an action. /// </summary> /// <param name="name">The name of the action.</param> /// <param name="value">The value to activate with.</param> public void Activate(string name, Vector2 value) { ActorAction action = this.GetOrCreateAction(name); if (action != null) { action.Value = value; } }
/// <summary> /// Determines if an action was active in the last frame. /// </summary> /// <param name="name">The name of the action.</param> /// <returns>True if the action was active last frame.</returns> public bool WasActive(string name) { ActorAction action = this.GetOrCreateAction(name); return(action != null && action.WasActive); }
/// <summary> /// Gets the icon assigned to an action. /// </summary> /// <param name="name">The name of the action.</param> /// <returns>The icon assigned to an action.</returns> public Sprite GetIcon(string name) { ActorAction action = this.GetOrCreateAction(name); return(action != null ? action.Icon : null); }
/// <summary> /// Gets the non-normalized value of an action. If you are looking for /// the normalized value use <see cref="IActorController.GetDirection"/>. /// </summary> /// <param name="name">The name of the action.</param> /// <returns>The value of an action.</returns> public Vector2 GetVector(string name) { ActorAction action = this.GetOrCreateAction(name); return(action != null ? action.Value : Vector2.zero); }
/// <summary> /// Clears an action's hold time and value. /// </summary> /// <param name="name">The name of the action.</param> public void Flush(string name) { ActorAction action = this.GetOrCreateAction(name); action.Flush(); }
/// <summary> /// Is not active this frame but was active last frame. /// </summary> /// <param name="name"></param> /// <returns></returns> public bool IsReleased(string name) { ActorAction action = this.GetOrCreateAction(name); return(action != null && !action.IsActive && action.WasActive); }
/// <summary> /// Returns true if the action has been active for the given duration. /// </summary> /// <param name="name">The name of the action.</param> /// <param name="duration">A duration in seconds.</param> /// <returns>True if the action has been active for the given duration.</returns> public bool IsHeldFor(string name, float duration) { ActorAction action = this.GetOrCreateAction(name); return(action != null && action.HeldTime > duration); }
public Vector2 GetVector(string actionName) { ActorAction action = this.GetOrCreateAction(actionName); return(action?.Value ?? Vector2.zero); }
public bool IsTriggered(string actionName) { ActorAction action = this.GetOrCreateAction(actionName); return(action != null && action.IsActive && !action.WasActive); }
public bool IsActive(string actionName) { ActorAction action = this.GetOrCreateAction(actionName); return(action != null && action.IsActive); }
public void Activate(string actionName, ActorAction other) { ActorAction action = this.GetOrCreateAction(actionName); action?.CopyFrom(other); }
public Sprite GetIcon(string actionName) { ActorAction action = this.GetOrCreateAction(actionName); return(action?.Icon); }