using System; using System.Threading.Tasks; using Babushka.scripts.CSharp.Common.Util; using Godot; namespace Babushka.scripts.CSharp.Common.Fight; public abstract class FighterAction { public class TargetSelection { // ReSharper disable once MemberHidesStaticFromOuterClass public static readonly TargetSelection Skip = new() { skipTargetSelection = () => true }; public Func skipTargetSelection = () => false; } public abstract class FighterActionDetail { public abstract bool DetailComplete(); } private bool _abort = false; #region Shortcuts protected static FightWorld.FightHappeningData HappeningData => FightWorld.Instance.fightHappeningData ?? throw new NoFightHappeningException(); #endregion /// /// Executes the data modification for the action. This must happen instantly and not via a coroutines or callbacks. /// To get a multiple hit effect for one action, use appropriate Visual Manipulation functions in AnimateAction. /// public virtual void ExecuteAction() { } /// /// Returns a way to determine, when an action animation is done /// /// /// A variant that can be float or Func<bool>.
/// When the return type is float, the animation will take the return value amount of seconds.
/// When the return type is Func<bool>, the animation will be done, when the function returns true. ///
public abstract Variant> GetAnimationEnd(); /// /// Animates the action. /// public virtual async Task AnimateAction() { } public void MarkAbort() { _abort = true; } public bool MarkedForAbort() { return _abort; } public abstract FighterActionDetail? NeededDetail(); public class Skip : FighterAction { public override Variant> GetAnimationEnd() { return 0f; } public override FighterActionDetail? NeededDetail() { return null; } } }