ToolTileCompatibleComponent.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using Content.Shared.DoAfter;
  2. using Content.Shared.Tools.Systems;
  3. using Robust.Shared.GameStates;
  4. using Robust.Shared.Map;
  5. using Robust.Shared.Serialization;
  6. namespace Content.Shared.Tools.Components;
  7. /// <summary>
  8. /// This is used for entities with <see cref="ToolComponent"/> that are additionally
  9. /// able to modify tiles.
  10. /// </summary>
  11. [RegisterComponent, NetworkedComponent]
  12. [Access(typeof(SharedToolSystem))]
  13. public sealed partial class ToolTileCompatibleComponent : Component
  14. {
  15. /// <summary>
  16. /// The time it takes to modify the tile.
  17. /// </summary>
  18. [DataField, ViewVariables(VVAccess.ReadWrite)]
  19. public TimeSpan Delay = TimeSpan.FromSeconds(1);
  20. /// <summary>
  21. /// Whether or not the tile being modified must be unobstructed
  22. /// </summary>
  23. [DataField, ViewVariables(VVAccess.ReadWrite)]
  24. public bool RequiresUnobstructed = true;
  25. }
  26. [Serializable, NetSerializable]
  27. public sealed partial class TileToolDoAfterEvent : DoAfterEvent
  28. {
  29. public NetEntity Grid;
  30. public Vector2i GridTile;
  31. public TileToolDoAfterEvent(NetEntity grid, Vector2i gridTile)
  32. {
  33. Grid = grid;
  34. GridTile = gridTile;
  35. }
  36. public override DoAfterEvent Clone()
  37. {
  38. return this;
  39. }
  40. public override bool IsDuplicate(DoAfterEvent other)
  41. {
  42. return other is TileToolDoAfterEvent otherTile
  43. && Grid == otherTile.Grid
  44. && GridTile == otherTile.GridTile;
  45. }
  46. }