From ca3d5d5fb7d8411cdf665aee54e67cfc33e5870a Mon Sep 17 00:00:00 2001 From: HappyRoach Date: Fri, 9 Jan 2026 20:16:11 +0300 Subject: [PATCH] Fix delete --- .../Sharpening/Systems/SharpeningSystem.cs | 31 +++++++++++++++++++ .../Components/SharpenerComponent.cs | 4 +++ .../Sharpening/Events/SharpeningEvents.cs | 17 ++++++++++ .../Systems/SharedSharpeningSystem.cs | 10 +++--- 4 files changed, 56 insertions(+), 6 deletions(-) create mode 100644 Content.Server/_Wega/Sharpening/Systems/SharpeningSystem.cs create mode 100644 Content.Shared/_Wega/Sharpening/Events/SharpeningEvents.cs diff --git a/Content.Server/_Wega/Sharpening/Systems/SharpeningSystem.cs b/Content.Server/_Wega/Sharpening/Systems/SharpeningSystem.cs new file mode 100644 index 0000000000..c8d814f2fd --- /dev/null +++ b/Content.Server/_Wega/Sharpening/Systems/SharpeningSystem.cs @@ -0,0 +1,31 @@ +using Content.Shared.Sharpening.Components; +using Content.Shared.Sharpening.Systems; +using Content.Shared.Sharpening.Events; +using Robust.Shared.Audio.Systems; +using Robust.Shared.Audio; + +namespace Content.Server.Sharpening.Systems; + +public sealed class SharpeningSystem : SharedSharpeningSystem +{ + [Dependency] private readonly SharedAudioSystem _audio = default!; + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnSharpeningFinished); + } + + private void OnSharpeningFinished(Entity ent, ref SharpeningFinishedEvent args) + { + _audio.PlayPvs(ent.Comp.SharpeningSound, GetEntity(args.Sharpening), AudioParams.Default.WithMaxDistance(2f)); + + if (!ent.Comp.DeleteOnSharpening) + return; + + if (ent.Comp.Prototype != string.Empty && TryComp(ent, out TransformComponent? xform)) + Spawn(ent.Comp.Prototype, xform.Coordinates); + + Del(ent); + } +} diff --git a/Content.Shared/_Wega/Sharpening/Components/SharpenerComponent.cs b/Content.Shared/_Wega/Sharpening/Components/SharpenerComponent.cs index 887d64bc42..67c07ef7da 100644 --- a/Content.Shared/_Wega/Sharpening/Components/SharpenerComponent.cs +++ b/Content.Shared/_Wega/Sharpening/Components/SharpenerComponent.cs @@ -1,5 +1,6 @@ using Robust.Shared.GameStates; using Robust.Shared.Audio; +using Robust.Shared.Prototypes; namespace Content.Shared.Sharpening.Components; @@ -17,4 +18,7 @@ public sealed partial class SharpenerComponent : Component [DataField("DeleteOnSharpening"), AutoNetworkedField] public bool DeleteOnSharpening = false; + + [DataField("SpawnOnDelete"), AutoNetworkedField] + public EntProtoId Prototype = string.Empty; } diff --git a/Content.Shared/_Wega/Sharpening/Events/SharpeningEvents.cs b/Content.Shared/_Wega/Sharpening/Events/SharpeningEvents.cs new file mode 100644 index 0000000000..6cd86a22ff --- /dev/null +++ b/Content.Shared/_Wega/Sharpening/Events/SharpeningEvents.cs @@ -0,0 +1,17 @@ +using Robust.Shared.GameStates; +using Robust.Shared.Serialization; + +namespace Content.Shared.Sharpening.Events; + +[Serializable, NetSerializable] +public sealed class SharpeningFinishedEvent : EntityEventArgs +{ + public NetEntity Sharpener; + public NetEntity Sharpening; + + public SharpeningFinishedEvent(NetEntity sharpener, NetEntity sharpening) + { + Sharpener = sharpener; + Sharpening = sharpening; + } +} diff --git a/Content.Shared/_Wega/Sharpening/Systems/SharedSharpeningSystem.cs b/Content.Shared/_Wega/Sharpening/Systems/SharedSharpeningSystem.cs index 00fd916101..56a6ee1423 100644 --- a/Content.Shared/_Wega/Sharpening/Systems/SharedSharpeningSystem.cs +++ b/Content.Shared/_Wega/Sharpening/Systems/SharedSharpeningSystem.cs @@ -4,11 +4,11 @@ using Content.Shared.Interaction; using Content.Shared.Weapons.Melee; using Robust.Shared.Audio.Systems; using Content.Shared.Weapons.Melee.Events; +using Content.Shared.Sharpening.Events; namespace Content.Shared.Sharpening.Systems; - -public sealed partial class SharedSharpeningSystem : EntitySystem +public abstract class SharedSharpeningSystem : EntitySystem { [Dependency] private readonly SharedAudioSystem _audio = default!; @@ -53,10 +53,8 @@ public sealed partial class SharedSharpeningSystem : EntitySystem ent.Comp.PreviousDamage = weapon.Damage; weapon.Damage = ent.Comp.Damage; - _audio.PlayPredicted(sharpener.SharpeningSound, args.Target.Value, args.User); - - if (sharpener.DeleteOnSharpening) - QueueDel(args.Target); + var ev = new SharpeningFinishedEvent(GetNetEntity(args.Target.Value), GetNetEntity(ent.Owner)); + RaiseLocalEvent(args.Target.Value, ev); args.Handled = true; }