From d7467f53980c896ea118b405b1e4cd87d4f98484 Mon Sep 17 00:00:00 2001 From: MilenVolf Date: Wed, 19 Jun 2024 12:57:39 +0300 Subject: [PATCH 1/5] cleanup prototypes with `PryingComponent` & fix jaws of life prying speed --- .../Entities/Debugging/spanisharmyknife.yml | 2 -- Resources/Prototypes/Entities/Mobs/NPCs/animals.yml | 13 +++---------- Resources/Prototypes/Entities/Mobs/NPCs/xeno.yml | 11 +++-------- .../Prototypes/Entities/Objects/Tools/cowtools.yml | 4 +--- .../Entities/Objects/Tools/jaws_of_life.yml | 10 ++-------- .../Entities/Objects/Weapons/Melee/armblade.yml | 3 --- .../Entities/Objects/Weapons/Melee/mining.yml | 3 --- 7 files changed, 9 insertions(+), 37 deletions(-) diff --git a/Resources/Prototypes/Entities/Debugging/spanisharmyknife.yml b/Resources/Prototypes/Entities/Debugging/spanisharmyknife.yml index b7fb1188ccd6d8..023ba8c08a811c 100644 --- a/Resources/Prototypes/Entities/Debugging/spanisharmyknife.yml +++ b/Resources/Prototypes/Entities/Debugging/spanisharmyknife.yml @@ -22,8 +22,6 @@ Slash: 10 - type: ToolTileCompatible - type: Tool - qualities: - - Prying - type: Prying - type: MultipleTool statusShowBehavior: true diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml b/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml index 93d24be5af8f5f..fc9e5151e91bea 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml @@ -2265,17 +2265,10 @@ tags: - DoorBumpOpener - FootstepSound - - type: Tool # Open door from xeno.yml. + - type: Prying # Open door from xeno.yml. + pryPowered: true + force: true speedModifier: 1.5 - qualities: - - Prying - useSound: - path: /Audio/Items/crowbar.ogg - - type: Prying - pryPowered: !type:Bool - true - force: !type:Bool - true useSound: path: /Audio/Items/crowbar.ogg - type: PassiveDamage # Slight passive regen. Assuming one damage type, comes out to about 4 damage a minute from base.yml. diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/xeno.yml b/Resources/Prototypes/Entities/Mobs/NPCs/xeno.yml index 8c262d23da65cd..9fb0be02aec9a5 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/xeno.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/xeno.yml @@ -21,15 +21,10 @@ true NavSmash: !type:Bool true - - type: Tool - speedModifier: 1.5 - qualities: - - Prying - type: Prying - pryPowered: !type:Bool - true - force: !type:Bool - true + pryPowered: true + force: true + speedModifier: 1.5 useSound: path: /Audio/Items/crowbar.ogg - type: Reactive diff --git a/Resources/Prototypes/Entities/Objects/Tools/cowtools.yml b/Resources/Prototypes/Entities/Objects/Tools/cowtools.yml index c9b37b8b1aed70..075e9b5a099b17 100644 --- a/Resources/Prototypes/Entities/Objects/Tools/cowtools.yml +++ b/Resources/Prototypes/Entities/Objects/Tools/cowtools.yml @@ -91,11 +91,9 @@ - type: Tool qualities: - Prying - useSound: - path: /Audio/Items/crowbar.ogg - speedModifier: 0.05 - type: ToolTileCompatible - type: Prying + speedModifier: 0.05 - type: entity name: mooltitool diff --git a/Resources/Prototypes/Entities/Objects/Tools/jaws_of_life.yml b/Resources/Prototypes/Entities/Objects/Tools/jaws_of_life.yml index c80e53870e583d..4d1b7d3313a6f7 100644 --- a/Resources/Prototypes/Entities/Objects/Tools/jaws_of_life.yml +++ b/Resources/Prototypes/Entities/Objects/Tools/jaws_of_life.yml @@ -19,14 +19,10 @@ - Belt - type: ToolTileCompatible - type: Tool - qualities: - - Prying - speedModifier: 1.5 - useSound: /Audio/Items/jaws_pry.ogg - type: Prying + speedModifier: 1.5 pryPowered: true useSound: /Audio/Items/jaws_pry.ogg - - type: ToolForcePowered - type: MultipleTool statusShowBehavior: true entries: @@ -66,9 +62,7 @@ right: - state: syn_inhand-right size: Normal - - type: Tool - qualities: - - Prying + - type: Prying speedModifier: 3.0 - type: MultipleTool entries: diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Melee/armblade.yml b/Resources/Prototypes/Entities/Objects/Weapons/Melee/armblade.yml index 9e1134195d5820..49b22c000d595a 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Melee/armblade.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Melee/armblade.yml @@ -18,7 +18,4 @@ - type: Item size: Normal sprite: Objects/Weapons/Melee/armblade.rsi - - type: Tool - qualities: - - Prying - type: Prying diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Melee/mining.yml b/Resources/Prototypes/Entities/Objects/Weapons/Melee/mining.yml index ccf45bf59aa92c..4eec90584c812d 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Melee/mining.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Melee/mining.yml @@ -62,9 +62,6 @@ - type: Item size: Ginormous - type: DisarmMalus - - type: Tool - qualities: - - Prying - type: Prying - type: entity From 7ac9cdeaab9d65e4c8593f2408b1fff332a2673c Mon Sep 17 00:00:00 2001 From: MilenVolf Date: Wed, 19 Jun 2024 12:59:44 +0300 Subject: [PATCH 2/5] Minor cleanup for tools and prying systems Remove some obsolete methods. --- .../Prying/Components/PryingComponent.cs | 14 +++++++------- Content.Shared/Prying/Systems/PryingSystem.cs | 12 +++++------- .../Tools/Components/ToolForcePoweredComponent.cs | 10 ---------- .../Tools/Systems/SharedToolSystem.MultipleTool.cs | 11 ++--------- .../Tools/Systems/SharedToolSystem.Tile.cs | 10 ++++++---- 5 files changed, 20 insertions(+), 37 deletions(-) delete mode 100644 Content.Shared/Tools/Components/ToolForcePoweredComponent.cs diff --git a/Content.Shared/Prying/Components/PryingComponent.cs b/Content.Shared/Prying/Components/PryingComponent.cs index 7a7f304d8f8340..6651e2b5744d39 100644 --- a/Content.Shared/Prying/Components/PryingComponent.cs +++ b/Content.Shared/Prying/Components/PryingComponent.cs @@ -9,32 +9,32 @@ public sealed partial class PryingComponent : Component /// /// Whether the entity can pry open powered doors /// - [DataField("pryPowered")] - public bool PryPowered = false; + [DataField] + public bool PryPowered; /// /// Whether the tool can bypass certain restrictions when prying. /// For example door bolts. /// - [DataField("force")] - public bool Force = false; + [DataField] + public bool Force; /// /// Modifier on the prying time. /// Lower values result in more time. /// - [DataField("speedModifier")] + [DataField] public float SpeedModifier = 1.0f; /// /// What sound to play when prying is finished. /// - [DataField("useSound")] + [DataField] public SoundSpecifier UseSound = new SoundPathSpecifier("/Audio/Items/crowbar.ogg"); /// /// Whether the entity can currently pry things. /// - [DataField("enabled")] + [DataField] public bool Enabled = true; } diff --git a/Content.Shared/Prying/Systems/PryingSystem.cs b/Content.Shared/Prying/Systems/PryingSystem.cs index 372c89c9ae090e..43563e79d01d6d 100644 --- a/Content.Shared/Prying/Systems/PryingSystem.cs +++ b/Content.Shared/Prying/Systems/PryingSystem.cs @@ -21,7 +21,7 @@ public sealed class PryingSystem : EntitySystem [Dependency] private readonly ISharedAdminLogManager _adminLog = default!; [Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!; [Dependency] private readonly SharedAudioSystem _audioSystem = default!; - [Dependency] private readonly SharedPopupSystem Popup = default!; + [Dependency] private readonly SharedPopupSystem _popup = default!; public override void Initialize() { @@ -46,7 +46,7 @@ private void OnDoorAltVerb(EntityUid uid, DoorComponent component, GetVerbsEvent if (!args.CanInteract || !args.CanAccess) return; - if (!TryComp(args.User, out var tool)) + if (!TryComp(args.User, out _)) return; args.Verbs.Add(new AlternativeVerb() @@ -74,7 +74,7 @@ public bool TryPry(EntityUid target, EntityUid user, out DoAfterId? id, EntityUi if (!CanPry(target, user, out var message, comp)) { if (!string.IsNullOrWhiteSpace(message)) - Popup.PopupClient(Loc.GetString(message), target, user); + _popup.PopupClient(Loc.GetString(message), target, user); // If we have reached this point we want the event that caused this // to be marked as handled. return true; @@ -163,7 +163,7 @@ private void OnDoAfter(EntityUid uid, DoorComponent door, DoorPryDoAfterEvent ar if (!CanPry(uid, args.User, out var message, comp)) { if (!string.IsNullOrWhiteSpace(message)) - Popup.PopupClient(Loc.GetString(message), uid, args.User); + _popup.PopupClient(Loc.GetString(message), uid, args.User); return; } @@ -178,6 +178,4 @@ private void OnDoAfter(EntityUid uid, DoorComponent door, DoorPryDoAfterEvent ar } [Serializable, NetSerializable] -public sealed partial class DoorPryDoAfterEvent : SimpleDoAfterEvent -{ -} +public sealed partial class DoorPryDoAfterEvent : SimpleDoAfterEvent; diff --git a/Content.Shared/Tools/Components/ToolForcePoweredComponent.cs b/Content.Shared/Tools/Components/ToolForcePoweredComponent.cs deleted file mode 100644 index d38034c754076d..00000000000000 --- a/Content.Shared/Tools/Components/ToolForcePoweredComponent.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Content.Shared.Tools.Components -{ - /// - /// Tag component to let a tool ignore restrictions on whether devices are powered - /// or not to work. - /// - [RegisterComponent] - public sealed partial class ToolForcePoweredComponent : Component - {} -} diff --git a/Content.Shared/Tools/Systems/SharedToolSystem.MultipleTool.cs b/Content.Shared/Tools/Systems/SharedToolSystem.MultipleTool.cs index d69f01d762f62c..595ef8a9252c64 100644 --- a/Content.Shared/Tools/Systems/SharedToolSystem.MultipleTool.cs +++ b/Content.Shared/Tools/Systems/SharedToolSystem.MultipleTool.cs @@ -70,16 +70,9 @@ public virtual void SetMultipleTool(EntityUid uid, tool.Qualities = current.Behavior; // TODO: Replace this with a better solution later - if (TryComp(uid, out var pcomp)) + if (TryComp(uid, out var pryComp)) { - if (current.Behavior.Contains("Prying")) - { - pcomp.Enabled = true; - } - else - { - pcomp.Enabled = false; - } + pryComp.Enabled = current.Behavior.Contains("Prying"); } if (playSound && current.ChangeSound != null) diff --git a/Content.Shared/Tools/Systems/SharedToolSystem.Tile.cs b/Content.Shared/Tools/Systems/SharedToolSystem.Tile.cs index 4ccdb2ef4941a3..cfc0a0c368c321 100644 --- a/Content.Shared/Tools/Systems/SharedToolSystem.Tile.cs +++ b/Content.Shared/Tools/Systems/SharedToolSystem.Tile.cs @@ -39,7 +39,7 @@ private void OnToolTileComplete(Entity ent, ref Til return; var coordinates = GetCoordinates(args.Coordinates); - var gridUid = coordinates.GetGridUid(EntityManager); + var gridUid = _transformSystem.GetGrid(coordinates.EntityId); if (!TryComp(gridUid, out var grid)) { Log.Error("Attempted use tool on a non-existent grid?"); @@ -53,8 +53,10 @@ private void OnToolTileComplete(Entity ent, ref Til 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}"); + AdminLogger.Add( + LogType.LatticeCut, + LogImpact.Medium, + $"{ToPrettyString(args.User):player} used {ToPrettyString(ent)} to edit the tile at {args.Coordinates}"); args.Handled = true; } @@ -66,7 +68,7 @@ private bool UseToolOnTile(Entity 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); From fa86d8bd50ec3bd9cef9d2a1a0480b62f949372e Mon Sep 17 00:00:00 2001 From: MilenVolf Date: Wed, 19 Jun 2024 17:56:01 +0300 Subject: [PATCH 3/5] Fix doafter continues when not held & log --- Content.Shared/Prying/Systems/PryingSystem.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Content.Shared/Prying/Systems/PryingSystem.cs b/Content.Shared/Prying/Systems/PryingSystem.cs index 43563e79d01d6d..52459c4f744cad 100644 --- a/Content.Shared/Prying/Systems/PryingSystem.cs +++ b/Content.Shared/Prying/Systems/PryingSystem.cs @@ -138,9 +138,10 @@ private bool StartPry(EntityUid target, EntityUid user, EntityUid? tool, float t { BreakOnDamage = true, BreakOnMove = true, + NeedHand = tool != user, }; - if (tool != null) + if (tool != user && tool != null) { _adminLog.Add(LogType.Action, LogImpact.Low, $"{ToPrettyString(user)} is using {ToPrettyString(tool.Value)} to pry {ToPrettyString(target)}"); } From 8257a9d5c62fb9460b584d491e1e98f2c90f025d Mon Sep 17 00:00:00 2001 From: MilenVolf Date: Wed, 19 Jun 2024 19:20:37 +0300 Subject: [PATCH 4/5] Modifiy delays for floor prying --- Resources/Prototypes/Entities/Objects/Tools/cowtools.yml | 1 + Resources/Prototypes/Entities/Objects/Tools/jaws_of_life.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/Resources/Prototypes/Entities/Objects/Tools/cowtools.yml b/Resources/Prototypes/Entities/Objects/Tools/cowtools.yml index 075e9b5a099b17..2d584bd233c9e8 100644 --- a/Resources/Prototypes/Entities/Objects/Tools/cowtools.yml +++ b/Resources/Prototypes/Entities/Objects/Tools/cowtools.yml @@ -92,6 +92,7 @@ qualities: - Prying - type: ToolTileCompatible + delay: 10 - type: Prying speedModifier: 0.05 diff --git a/Resources/Prototypes/Entities/Objects/Tools/jaws_of_life.yml b/Resources/Prototypes/Entities/Objects/Tools/jaws_of_life.yml index 4d1b7d3313a6f7..98f3cf96377ee8 100644 --- a/Resources/Prototypes/Entities/Objects/Tools/jaws_of_life.yml +++ b/Resources/Prototypes/Entities/Objects/Tools/jaws_of_life.yml @@ -18,6 +18,7 @@ slots: - Belt - type: ToolTileCompatible + delay: 0.5 - type: Tool - type: Prying speedModifier: 1.5 From cccc48436260d9c8c5e49d51a2724acc795dfa3b Mon Sep 17 00:00:00 2001 From: MilenVolf Date: Wed, 19 Jun 2024 20:38:33 +0300 Subject: [PATCH 5/5] Fix test fail --- Resources/Prototypes/Entities/Objects/Tools/jaws_of_life.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Resources/Prototypes/Entities/Objects/Tools/jaws_of_life.yml b/Resources/Prototypes/Entities/Objects/Tools/jaws_of_life.yml index 98f3cf96377ee8..bd4c7aa7b5dad9 100644 --- a/Resources/Prototypes/Entities/Objects/Tools/jaws_of_life.yml +++ b/Resources/Prototypes/Entities/Objects/Tools/jaws_of_life.yml @@ -20,6 +20,9 @@ - type: ToolTileCompatible delay: 0.5 - type: Tool + qualities: + - Prying + useSound: /Audio/Items/jaws_pry.ogg - type: Prying speedModifier: 1.5 pryPowered: true