DoAfterSystem uses EntityUid internally, adds EntityUid constructor for DoAfterEventArgs.

This commit is contained in:
Vera Aguilera Puerto
2021-09-28 11:33:33 +02:00
parent 35067b3a3e
commit 4e6d602784
4 changed files with 37 additions and 41 deletions

View File

@@ -10,22 +10,10 @@ namespace Content.Server.DoAfter
{
public sealed class DoAfterEventArgs
{
// Premade checks
public Func<bool> GetInRangeUnobstructed(CollisionGroup collisionMask = CollisionGroup.MobMask)
{
if (Target == null)
{
throw new InvalidOperationException("Can't supply a null target to DoAfterEventArgs.GetInRangeUnobstructed");
}
bool Ignored(IEntity entity) => entity == User || entity == Target;
return () => User.InRangeUnobstructed(Target, collisionMask: collisionMask, predicate: Ignored);
}
/// <summary>
/// The entity invoking do_after
/// </summary>
public IEntity User { get; }
public EntityUid User { get; }
/// <summary>
/// How long does the do_after require to complete
@@ -35,7 +23,7 @@ namespace Content.Server.DoAfter
/// <summary>
/// Applicable target (if relevant)
/// </summary>
public IEntity? Target { get; }
public EntityUid? Target { get; }
/// <summary>
/// Manually cancel the do_after so it no longer runs
@@ -114,7 +102,15 @@ namespace Content.Server.DoAfter
IEntity user,
float delay,
CancellationToken cancelToken = default,
IEntity? target = null)
IEntity? target = null) : this(user.Uid, delay, cancelToken, target?.Uid ?? null)
{
}
public DoAfterEventArgs(
EntityUid user,
float delay,
CancellationToken cancelToken = default,
EntityUid? target = null)
{
User = user;
Delay = delay;