using System.Threading; using Content.Shared.FixedPoint; namespace Content.Server.DoAfter { public sealed class DoAfterEventArgs { /// /// The entity invoking do_after /// public EntityUid User { get; } /// /// How long does the do_after require to complete /// public float Delay { get; } /// /// Applicable target (if relevant) /// public EntityUid? Target { get; } /// /// Entity used by the User on the Target. /// public EntityUid? Used { get; set; } /// /// Manually cancel the do_after so it no longer runs /// public CancellationToken CancelToken { get; } // Break the chains /// /// Whether we need to keep our active hand as is (i.e. can't change hand or change item). /// This also covers requiring the hand to be free (if applicable). /// public bool NeedHand { get; set; } /// /// If do_after stops when the user moves /// public bool BreakOnUserMove { get; set; } /// /// If do_after stops when the target moves (if there is a target) /// public bool BreakOnTargetMove { get; set; } /// /// Threshold for user and target movement /// public float MovementThreshold { get; set; } public bool BreakOnDamage { get; set; } /// /// Threshold for user damage /// public FixedPoint2 DamageThreshold { get; set; } public bool BreakOnStun { get; set; } /// /// Threshold for distance user from the used OR target entities. /// public float? DistanceThreshold { get; set; } /// /// Requires a function call once at the end (like InRangeUnobstructed). /// /// /// Anything that needs a pre-check should do it itself so no DoAfterState is ever sent to the client. /// public Func? PostCheck { get; set; } = null; /// /// Additional conditions that need to be met. Return false to cancel. /// public Func? ExtraCheck { get; set; } /// /// Event to be raised directed to the entity when the DoAfter is cancelled. /// public object? UserCancelledEvent { get; set; } /// /// Event to be raised directed to the entity when the DoAfter is finished successfully. /// public object? UserFinishedEvent { get; set; } /// /// Event to be raised directed to the entity when the DoAfter is cancelled. /// public object? TargetCancelledEvent { get; set; } /// /// Event to be raised directed to the entity when the DoAfter is finished successfully. /// public object? TargetFinishedEvent { get; set; } /// /// Event to be broadcast when the DoAfter is cancelled. /// public object? BroadcastCancelledEvent { get; set; } /// /// Event to be broadcast when the DoAfter is finished successfully. /// public object? BroadcastFinishedEvent { get; set; } public DoAfterEventArgs( EntityUid user, float delay, CancellationToken cancelToken = default, EntityUid? target = null, EntityUid? used = null) { User = user; Delay = delay; CancelToken = cancelToken; Target = target; Used = used; MovementThreshold = 0.1f; DamageThreshold = 1.0; if (Target == null) { BreakOnTargetMove = false; } } } }