diff --git a/Content.Shared/DoAfter/DoAfterEvent.cs b/Content.Shared/DoAfter/DoAfterEvent.cs
index bc9abdab87..5affbe7485 100644
--- a/Content.Shared/DoAfter/DoAfterEvent.cs
+++ b/Content.Shared/DoAfter/DoAfterEvent.cs
@@ -34,6 +34,14 @@ public abstract partial class DoAfterEvent : HandledEntityEventArgs
public EntityUid? Used => DoAfter.Args.Used;
public DoAfterArgs Args => DoAfter.Args;
#endregion
+
+ ///
+ /// Check whether this event is "the same" as another event for duplicate checking.
+ ///
+ public virtual bool IsDuplicate(DoAfterEvent other)
+ {
+ return GetType() == other.GetType();
+ }
}
///
diff --git a/Content.Shared/DoAfter/SharedDoAfterSystem.cs b/Content.Shared/DoAfter/SharedDoAfterSystem.cs
index 9ad649683d..77b4741533 100644
--- a/Content.Shared/DoAfter/SharedDoAfterSystem.cs
+++ b/Content.Shared/DoAfter/SharedDoAfterSystem.cs
@@ -310,7 +310,7 @@ public abstract partial class SharedDoAfterSystem : EntitySystem
}
if ((conditions & DuplicateConditions.SameEvent) != 0
- && args.Event.GetType() != otherArgs.Event.GetType())
+ && !args.Event.IsDuplicate(otherArgs.Event))
{
return false;
}
diff --git a/Content.Shared/Tools/Components/ToolTileCompatibleComponent.cs b/Content.Shared/Tools/Components/ToolTileCompatibleComponent.cs
index caac41a3de..57058a5781 100644
--- a/Content.Shared/Tools/Components/ToolTileCompatibleComponent.cs
+++ b/Content.Shared/Tools/Components/ToolTileCompatibleComponent.cs
@@ -30,15 +30,24 @@ public sealed partial class ToolTileCompatibleComponent : Component
[Serializable, NetSerializable]
public sealed partial class TileToolDoAfterEvent : DoAfterEvent
{
- public NetCoordinates Coordinates;
+ public NetEntity Grid;
+ public Vector2i GridTile;
- public TileToolDoAfterEvent(NetCoordinates coordinates)
+ public TileToolDoAfterEvent(NetEntity grid, Vector2i gridTile)
{
- Coordinates = coordinates;
+ Grid = grid;
+ GridTile = gridTile;
}
public override DoAfterEvent Clone()
{
return this;
}
+
+ public override bool IsDuplicate(DoAfterEvent other)
+ {
+ return other is TileToolDoAfterEvent otherTile
+ && Grid == otherTile.Grid
+ && GridTile == otherTile.GridTile;
+ }
}
diff --git a/Content.Shared/Tools/Systems/SharedToolSystem.Tile.cs b/Content.Shared/Tools/Systems/SharedToolSystem.Tile.cs
index 4ccdb2ef49..f392b31740 100644
--- a/Content.Shared/Tools/Systems/SharedToolSystem.Tile.cs
+++ b/Content.Shared/Tools/Systems/SharedToolSystem.Tile.cs
@@ -37,24 +37,24 @@ public abstract partial class SharedToolSystem
if (!TryComp(ent, out var tool))
return;
- var coordinates = GetCoordinates(args.Coordinates);
- var gridUid = coordinates.GetGridUid(EntityManager);
+ var gridUid = GetEntity(args.Grid);
if (!TryComp(gridUid, out var grid))
{
Log.Error("Attempted use tool on a non-existent grid?");
return;
}
- var tileRef = _maps.GetTileRef(gridUid.Value, grid, coordinates);
- if (comp.RequiresUnobstructed && _turfs.IsTileBlocked(gridUid.Value, tileRef.GridIndices, CollisionGroup.MobMask))
+ var tileRef = _maps.GetTileRef(gridUid, grid, args.GridTile);
+ var coords = _maps.ToCoordinates(tileRef, grid);
+ if (comp.RequiresUnobstructed && _turfs.IsTileBlocked(gridUid, tileRef.GridIndices, CollisionGroup.MobMask))
return;
if (!TryDeconstructWithToolQualities(tileRef, tool.Qualities))
return;
AdminLogger.Add(LogType.LatticeCut, LogImpact.Medium,
- $"{ToPrettyString(args.User):player} used {ToPrettyString(ent)} to edit the tile at {args.Coordinates}");
+ $"{ToPrettyString(args.User):player} used {ToPrettyString(ent)} to edit the tile at {coords}");
args.Handled = true;
}
@@ -66,7 +66,7 @@ public abstract partial class SharedToolSystem
var comp = ent.Comp1!;
var tool = ent.Comp2!;
- if (!_mapManager.TryFindGridAt(clickLocation.ToMap(EntityManager, _transformSystem), out var gridUid, out var mapGrid))
+ if (!_mapManager.TryFindGridAt(_transformSystem.ToMapCoordinates(clickLocation), out var gridUid, out var mapGrid))
return false;
var tileRef = _maps.GetTileRef(gridUid, mapGrid, clickLocation);
@@ -85,7 +85,7 @@ public abstract partial class SharedToolSystem
if (!InteractionSystem.InRangeUnobstructed(user, coordinates, popup: false))
return false;
- var args = new TileToolDoAfterEvent(GetNetCoordinates(coordinates));
+ var args = new TileToolDoAfterEvent(GetNetEntity(gridUid), tileRef.GridIndices);
UseTool(ent, user, ent, comp.Delay, tool.Qualities, args, out _, toolComponent: tool);
return true;
}
diff --git a/Content.Shared/Tools/Systems/SharedToolSystem.cs b/Content.Shared/Tools/Systems/SharedToolSystem.cs
index 72e984fd82..56ce81413f 100644
--- a/Content.Shared/Tools/Systems/SharedToolSystem.cs
+++ b/Content.Shared/Tools/Systems/SharedToolSystem.cs
@@ -271,6 +271,11 @@ public abstract partial class SharedToolSystem : EntitySystem
return new ToolDoAfterEvent(Fuel, evClone, OriginalTarget);
}
+
+ public override bool IsDuplicate(DoAfterEvent other)
+ {
+ return other is ToolDoAfterEvent toolDoAfter && WrappedEvent.IsDuplicate(toolDoAfter.WrappedEvent);
+ }
}
[Serializable, NetSerializable]