- add: TelefragSystem. (#333)

This commit is contained in:
Aviu00
2024-06-06 10:23:00 +00:00
committed by GitHub
parent ad65bd1e58
commit 152c9546a4
4 changed files with 45 additions and 12 deletions

View File

@@ -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);

View File

@@ -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);
}
}

View File

@@ -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);

View File

@@ -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<Entity<StandingStateComponent>>();
_lookup.GetEntitiesInRange(coords, range, ents);
foreach (var ent in ents.Where(ent => ent.Owner != user))
{
_standingState.TryLieDown(ent, ent, true);
}
}
}