#nullable enable
using System;
using System.Threading;
using Robust.Shared.Interfaces.GameObjects;
namespace Content.Server.GameObjects.EntitySystems
{
public sealed class DoAfterEventArgs
{
///
/// The entity invoking do_after
///
public IEntity User { get; }
///
/// How long does the do_after require to complete
///
public float Delay { get; }
///
/// Applicable target (if relevant)
///
public IEntity? Target { get; }
///
/// 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; }
///
/// If do_after stops when the user moves
///
public bool BreakOnUserMove { get; }
///
/// If do_after stops when the target moves (if there is a target)
///
public bool BreakOnTargetMove { get; }
public bool BreakOnDamage { get; }
public bool BreakOnStun { get; }
///
/// Additional conditions that need to be met. Return false to cancel.
///
public Func? ExtraCheck { get; }
public DoAfterEventArgs(
IEntity user,
float delay,
CancellationToken cancelToken,
IEntity? target = null,
bool needHand = true,
bool breakOnUserMove = true,
bool breakOnTargetMove = true,
bool breakOnDamage = true,
bool breakOnStun = true,
Func? extraCheck = null
)
{
User = user;
Delay = delay;
CancelToken = cancelToken;
Target = target;
NeedHand = needHand;
BreakOnUserMove = breakOnUserMove;
BreakOnTargetMove = breakOnTargetMove;
BreakOnDamage = breakOnDamage;
BreakOnStun = breakOnStun;
ExtraCheck = extraCheck;
if (Target == null)
{
BreakOnTargetMove = false;
}
}
}
}