mirror of
https://github.com/wega-team/ss14-wega.git
synced 2026-02-14 19:30:01 +01:00
Fix delete
This commit is contained in:
31
Content.Server/_Wega/Sharpening/Systems/SharpeningSystem.cs
Normal file
31
Content.Server/_Wega/Sharpening/Systems/SharpeningSystem.cs
Normal file
@@ -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<SharpenerComponent, SharpeningFinishedEvent>(OnSharpeningFinished);
|
||||
}
|
||||
|
||||
private void OnSharpeningFinished(Entity<SharpenerComponent> 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);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
17
Content.Shared/_Wega/Sharpening/Events/SharpeningEvents.cs
Normal file
17
Content.Shared/_Wega/Sharpening/Events/SharpeningEvents.cs
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user