From 152c9546a47f3cbe118df53f73e2a9d4df6be6ca Mon Sep 17 00:00:00 2001 From: Aviu00 <93730715+Aviu00@users.noreply.github.com> Date: Thu, 6 Jun 2024 10:23:00 +0000 Subject: [PATCH] - add: TelefragSystem. (#333) --- .../ExperimentalSyndicateTeleporter.cs | 28 +++++++++++-------- .../_White/Other/BlinkSystem/BlinkSystem.cs | 2 ++ .../Ninja/Systems/DashAbilitySystem.cs | 3 ++ .../_White/BetrayalDagger/TelefragSystem.cs | 24 ++++++++++++++++ 4 files changed, 45 insertions(+), 12 deletions(-) create mode 100644 Content.Shared/_White/BetrayalDagger/TelefragSystem.cs diff --git a/Content.Server/_White/ExperimentalSyndicateTeleporter/ExperimentalSyndicateTeleporter.cs b/Content.Server/_White/ExperimentalSyndicateTeleporter/ExperimentalSyndicateTeleporter.cs index 60a55c9dbb..b9d805850e 100644 --- a/Content.Server/_White/ExperimentalSyndicateTeleporter/ExperimentalSyndicateTeleporter.cs +++ b/Content.Server/_White/ExperimentalSyndicateTeleporter/ExperimentalSyndicateTeleporter.cs @@ -3,6 +3,7 @@ using System.Numerics; using Content.Server._White.Other; using Content.Server.Body.Systems; using Content.Server.Popups; +using Content.Shared._White.BetrayalDagger; using Content.Shared.Coordinates.Helpers; using Content.Shared.Examine; using Content.Shared.Interaction.Events; @@ -31,6 +32,7 @@ public sealed class ExperimentalSyndicateTeleporter : EntitySystem [Dependency] private readonly PullingSystem _pullingSystem = default!; [Dependency] private readonly ContainerSystem _containerSystem = default!; [Dependency] private readonly IRobustRandom _random = default!; + [Dependency] private readonly TelefragSystem _telefrag = default!; public override void Initialize() { @@ -113,12 +115,7 @@ public sealed class ExperimentalSyndicateTeleporter : EntitySystem return; } - SoundAndEffects(component, coords, oldCoords); - - _transform.SetCoordinates(args.User, coords); - - component.Uses--; - component.NextUse = _timing.CurTime + component.Cooldown; + Teleport(args.User, component, coords, oldCoords); } private void OnExamine(EntityUid uid, ExperimentalSyndicateTeleporterComponent component, ExaminedEvent args) @@ -132,12 +129,7 @@ public sealed class ExperimentalSyndicateTeleporter : EntitySystem var coords = xform.Coordinates.Offset(newOffset).SnapToGrid(EntityManager); - SoundAndEffects(component, coords, oldCoords); - - _transform.SetCoordinates(uid, coords); - - component.Uses--; - component.NextUse = _timing.CurTime + component.Cooldown; + Teleport(uid, component, coords, oldCoords); if (TryCheckWall(coords)) { @@ -145,6 +137,18 @@ public sealed class ExperimentalSyndicateTeleporter : EntitySystem } } + private void Teleport(EntityUid uid, ExperimentalSyndicateTeleporterComponent component, EntityCoordinates coords, + EntityCoordinates oldCoords) + { + SoundAndEffects(component, coords, oldCoords); + + _telefrag.Telefrag(coords, uid); + _transform.SetCoordinates(uid, coords); + + component.Uses--; + component.NextUse = _timing.CurTime + component.Cooldown; + } + private void SoundAndEffects(ExperimentalSyndicateTeleporterComponent component, EntityCoordinates coords, EntityCoordinates oldCoords) { _audio.PlayPvs(component.TeleportSound, coords); diff --git a/Content.Server/_White/Other/BlinkSystem/BlinkSystem.cs b/Content.Server/_White/Other/BlinkSystem/BlinkSystem.cs index 7bf73c0f1d..b2d37c633b 100644 --- a/Content.Server/_White/Other/BlinkSystem/BlinkSystem.cs +++ b/Content.Server/_White/Other/BlinkSystem/BlinkSystem.cs @@ -15,6 +15,7 @@ public sealed class BlinkSystem : EntitySystem [Dependency] private readonly AudioSystem _audio = default!; [Dependency] private readonly TransformSystem _transform = default!; [Dependency] private readonly PhysicsSystem _physics = default!; + [Dependency] private readonly TelefragSystem _telefrag = default!; public override void Initialize() { @@ -61,6 +62,7 @@ public sealed class BlinkSystem : EntitySystem } _transform.SetWorldPosition(user, targetPos); + _telefrag.Telefrag(xform.Coordinates, user); _audio.PlayPvs(blink.BlinkSound, user); } } diff --git a/Content.Shared/Ninja/Systems/DashAbilitySystem.cs b/Content.Shared/Ninja/Systems/DashAbilitySystem.cs index f9e5d4a1f6..011b6f9f66 100644 --- a/Content.Shared/Ninja/Systems/DashAbilitySystem.cs +++ b/Content.Shared/Ninja/Systems/DashAbilitySystem.cs @@ -1,3 +1,4 @@ +using Content.Shared._White.BetrayalDagger; using Content.Shared.Actions; using Content.Shared.Charges.Components; using Content.Shared.Charges.Systems; @@ -24,6 +25,7 @@ public sealed class DashAbilitySystem : EntitySystem [Dependency] private readonly SharedPopupSystem _popup = default!; [Dependency] private readonly SharedTransformSystem _transform = default!; [Dependency] private readonly ActionContainerSystem _actionContainer = default!; + [Dependency] private readonly TelefragSystem _telefrag = default!; // WD public override void Initialize() { @@ -90,6 +92,7 @@ public sealed class DashAbilitySystem : EntitySystem return; } + _telefrag.Telefrag(args.Target, user); _transform.SetCoordinates(user, args.Target); _transform.AttachToGridOrMap(user); _audio.PlayPredicted(comp.BlinkSound, user, user); diff --git a/Content.Shared/_White/BetrayalDagger/TelefragSystem.cs b/Content.Shared/_White/BetrayalDagger/TelefragSystem.cs new file mode 100644 index 0000000000..2892e16b26 --- /dev/null +++ b/Content.Shared/_White/BetrayalDagger/TelefragSystem.cs @@ -0,0 +1,24 @@ +using System.Linq; +using Content.Shared.Standing; +using Content.Shared.Standing.Systems; +using Content.Shared.StatusEffect; +using Robust.Shared.Map; + +namespace Content.Shared._White.BetrayalDagger; + +public sealed class TelefragSystem : EntitySystem +{ + [Dependency] private readonly EntityLookupSystem _lookup = default!; + [Dependency] private readonly SharedStandingStateSystem _standingState = default!; + + public void Telefrag(EntityCoordinates coords, EntityUid user, float range = 0.2f) + { + var ents = new HashSet>(); + _lookup.GetEntitiesInRange(coords, range, ents); + + foreach (var ent in ents.Where(ent => ent.Owner != user)) + { + _standingState.TryLieDown(ent, ent, true); + } + } +}