Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalize tile prying to any tool quality #24432

Merged
merged 2 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions Content.Server/Interaction/TilePryCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@

namespace Content.Server.Interaction
{
/// <summary>
/// <see cref="Shared.Tools.Components.TilePryingComponent.TryPryTile"/>
/// </summary>
[AdminCommand(AdminFlags.Debug)]
sealed class TilePryCommand : IConsoleCommand
{
Expand Down
17 changes: 0 additions & 17 deletions Content.Server/Tools/Components/LatticeCuttingComponent.cs

This file was deleted.

81 changes: 0 additions & 81 deletions Content.Server/Tools/ToolSystem.LatticeCutting.cs

This file was deleted.

4 changes: 2 additions & 2 deletions Content.Server/Tools/ToolSystem.Welder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void TryTurnOn(Entity<WelderComponent> entity, ref ItemToggleActivateAtte
_solutionContainer.RemoveReagent(entity.Comp.FuelSolution.Value, entity.Comp.FuelReagent, entity.Comp.FuelLitCost);

// Logging
_adminLogger.Add(LogType.InteractActivate, LogImpact.Low, $"{ToPrettyString(args.User):user} toggled {ToPrettyString(entity.Owner):welder} on");
AdminLogger.Add(LogType.InteractActivate, LogImpact.Low, $"{ToPrettyString(args.User):user} toggled {ToPrettyString(entity.Owner):welder} on");

_ignitionSource.SetIgnited(entity.Owner);

Expand All @@ -88,7 +88,7 @@ public void TryTurnOn(Entity<WelderComponent> entity, ref ItemToggleActivateAtte
public void TurnOff(Entity<WelderComponent> entity, ref ItemToggleDeactivateAttemptEvent args)
{
// Logging
_adminLogger.Add(LogType.InteractActivate, LogImpact.Low, $"{ToPrettyString(args.User):user} toggled {ToPrettyString(entity.Owner):welder} off");
AdminLogger.Add(LogType.InteractActivate, LogImpact.Low, $"{ToPrettyString(args.User):user} toggled {ToPrettyString(entity.Owner):welder} off");

_ignitionSource.SetIgnited(entity.Owner, false);

Expand Down
6 changes: 0 additions & 6 deletions Content.Server/Tools/ToolSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Content.Server.Tools.Components;
using Robust.Server.GameObjects;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Map;

using SharedToolSystem = Content.Shared.Tools.Systems.SharedToolSystem;

Expand All @@ -13,21 +12,16 @@ namespace Content.Server.Tools
// TODO move tool system to shared, and make it a friend of Tool Component.
public sealed partial class ToolSystem : SharedToolSystem
{
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!;
[Dependency] private readonly AppearanceSystem _appearanceSystem = default!;
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
[Dependency] private readonly PopupSystem _popup = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedPointLightSystem _light = default!;
[Dependency] private readonly SolutionContainerSystem _solutionContainer = default!;
[Dependency] private readonly TransformSystem _transformSystem = default!;

public override void Initialize()
{
base.Initialize();

InitializeLatticeCutting();
InitializeWelders();
}

Expand Down
17 changes: 10 additions & 7 deletions Content.Shared/Maps/ContentTileDefinition.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Content.Shared.Atmos;
using Content.Shared.Movement.Systems;
using Content.Shared.Tools;
using Robust.Shared.Audio;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
Expand All @@ -12,6 +13,9 @@ namespace Content.Shared.Maps
[Prototype("tile")]
public sealed partial class ContentTileDefinition : IPrototype, IInheritingPrototype, ITileDefinition
{
[ValidatePrototypeId<ToolQualityPrototype>]
public const string PryingToolQuality = "Prying";

public const string SpaceID = "Space";

[ParentDataFieldAttribute(typeof(AbstractPrototypeIdArraySerializer<ContentTileDefinition>))]
Expand All @@ -38,14 +42,13 @@ public sealed partial class ContentTileDefinition : IPrototype, IInheritingProto
[DataField("baseTurf")]
public string BaseTurf { get; private set; } = string.Empty;

[DataField("canCrowbar")] public bool CanCrowbar { get; private set; }

/// <summary>
/// Whether this tile can be pried by an advanced prying tool if not pryable otherwise.
/// </summary>
[DataField("canAxe")] public bool CanAxe { get; private set; }
[DataField]
public PrototypeFlags<ToolQualityPrototype> DeconstructTools { get; set; } = new();

[DataField("canWirecutter")] public bool CanWirecutter { get; private set; }
/// <remarks>
/// Legacy AF but nice to have.
/// </remarks>
public bool CanCrowbar => DeconstructTools.Contains(PryingToolQuality);

/// <summary>
/// These play when the mob has shoes on.
Expand Down
19 changes: 2 additions & 17 deletions Content.Shared/Maps/TileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,7 @@ public bool PryTile(TileRef tileRef, bool pryPlating)

var tileDef = (ContentTileDefinition) _tileDefinitionManager[tile.TypeId];

if (!tileDef.CanCrowbar && !(pryPlating && tileDef.CanAxe))
return false;

return DeconstructTile(tileRef);
}

public bool CutTile(TileRef tileRef)
{
var tile = tileRef.Tile;

if (tile.IsEmpty)
return false;

var tileDef = (ContentTileDefinition) _tileDefinitionManager[tile.TypeId];

if (!tileDef.CanWirecutter)
if (!tileDef.CanCrowbar)
return false;

return DeconstructTile(tileRef);
Expand Down Expand Up @@ -112,7 +97,7 @@ public bool ReplaceTile(TileRef tileref, ContentTileDefinition replacementTile,
return true;
}

private bool DeconstructTile(TileRef tileRef)
public bool DeconstructTile(TileRef tileRef)
{
if (tileRef.Tile.IsEmpty)
return false;
Expand Down
26 changes: 0 additions & 26 deletions Content.Shared/Tools/Components/TilePryingComponent.cs

This file was deleted.

44 changes: 44 additions & 0 deletions Content.Shared/Tools/Components/ToolTileCompatibleComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using Content.Shared.DoAfter;
using Content.Shared.Tools.Systems;
using Robust.Shared.GameStates;
using Robust.Shared.Map;
using Robust.Shared.Serialization;

namespace Content.Shared.Tools.Components;

/// <summary>
/// This is used for entities with <see cref="ToolComponent"/> that are additionally
/// able to modify tiles.
/// </summary>
[RegisterComponent, NetworkedComponent]
[Access(typeof(SharedToolSystem))]
public sealed partial class ToolTileCompatibleComponent : Component
{
/// <summary>
/// The time it takes to modify the tile.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public TimeSpan Delay = TimeSpan.FromSeconds(1);

/// <summary>
/// Whether or not the tile being modified must be unobstructed
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public bool RequiresUnobstructed = true;
}

[Serializable, NetSerializable]
public sealed partial class TileToolDoAfterEvent : DoAfterEvent
{
public NetCoordinates Coordinates;

public TileToolDoAfterEvent(NetCoordinates coordinates)
{
Coordinates = coordinates;
}

public override DoAfterEvent Clone()
{
return this;
}
}
4 changes: 2 additions & 2 deletions Content.Shared/Tools/Systems/SharedToolSystem.MultipleTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Content.Shared.Tools.Systems;

public abstract partial class SharedToolSystem : EntitySystem
public abstract partial class SharedToolSystem
{
public void InitializeMultipleTool()
{
Expand Down Expand Up @@ -57,7 +57,7 @@ public virtual void SetMultipleTool(EntityUid uid,
if (!Resolve(uid, ref multiple, ref tool))
return;

Dirty(multiple);
Dirty(uid, multiple);

if (multiple.Entries.Length <= multiple.CurrentEntry)
{
Expand Down
Loading
Loading