Refactor doAfterEventArgs
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Robust.Shared.Interfaces.GameObjects;
|
using Robust.Shared.Interfaces.GameObjects;
|
||||||
|
// ReSharper disable UnassignedReadonlyField
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.EntitySystems
|
namespace Content.Server.GameObjects.EntitySystems
|
||||||
{
|
{
|
||||||
@@ -11,7 +12,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
/// The entity invoking do_after
|
/// The entity invoking do_after
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IEntity User { get; }
|
public IEntity User { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// How long does the do_after require to complete
|
/// How long does the do_after require to complete
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -21,64 +22,52 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
/// Applicable target (if relevant)
|
/// Applicable target (if relevant)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IEntity? Target { get; }
|
public IEntity? Target { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Manually cancel the do_after so it no longer runs
|
/// Manually cancel the do_after so it no longer runs
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public CancellationToken CancelToken { get; }
|
public CancellationToken CancelToken { get; }
|
||||||
|
|
||||||
// Break the chains
|
// Break the chains
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether we need to keep our active hand as is (i.e. can't change hand or change item).
|
/// 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).
|
/// This also covers requiring the hand to be free (if applicable).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool NeedHand { get; }
|
public readonly bool NeedHand;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// If do_after stops when the user moves
|
/// If do_after stops when the user moves
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool BreakOnUserMove { get; }
|
public readonly bool BreakOnUserMove;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// If do_after stops when the target moves (if there is a target)
|
/// If do_after stops when the target moves (if there is a target)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool BreakOnTargetMove { get; }
|
public readonly bool BreakOnTargetMove;
|
||||||
public bool BreakOnDamage { get; }
|
|
||||||
public bool BreakOnStun { get; }
|
public readonly bool BreakOnDamage;
|
||||||
|
public readonly bool BreakOnStun;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Additional conditions that need to be met. Return false to cancel.
|
/// Additional conditions that need to be met. Return false to cancel.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Func<bool>? ExtraCheck { get; }
|
public readonly Func<bool>? ExtraCheck;
|
||||||
|
|
||||||
public DoAfterEventArgs(
|
public DoAfterEventArgs(
|
||||||
IEntity user,
|
IEntity user,
|
||||||
float delay,
|
float delay,
|
||||||
CancellationToken cancelToken,
|
CancellationToken cancelToken = default,
|
||||||
IEntity? target = null,
|
IEntity? target = null)
|
||||||
bool needHand = true,
|
|
||||||
bool breakOnUserMove = true,
|
|
||||||
bool breakOnTargetMove = true,
|
|
||||||
bool breakOnDamage = true,
|
|
||||||
bool breakOnStun = true,
|
|
||||||
Func<bool>? extraCheck = null
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
User = user;
|
User = user;
|
||||||
Delay = delay;
|
Delay = delay;
|
||||||
CancelToken = cancelToken;
|
CancelToken = cancelToken;
|
||||||
Target = target;
|
Target = target;
|
||||||
NeedHand = needHand;
|
|
||||||
BreakOnUserMove = breakOnUserMove;
|
|
||||||
BreakOnTargetMove = breakOnTargetMove;
|
|
||||||
BreakOnDamage = breakOnDamage;
|
|
||||||
BreakOnStun = breakOnStun;
|
|
||||||
ExtraCheck = extraCheck;
|
|
||||||
|
|
||||||
if (Target == null)
|
if (Target == null)
|
||||||
{
|
{
|
||||||
BreakOnTargetMove = false;
|
BreakOnTargetMove = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user