Files
tbd-station-14/Content.Shared/Trigger/Systems/SwapLocationOnTriggerSystem.cs
slarticodefast 414817e38a AddTagOnTrigger, RemoveTagOnTrigger, SwapPositionOnTrigger, JitterOnTrigger (#41476)
* more triggers

* comment

---------

Co-authored-by: iaada <iaada@users.noreply.github.com>
2025-11-19 01:58:50 +00:00

31 lines
948 B
C#

using Content.Shared.Trigger.Components.Effects;
using Robust.Shared.Network;
namespace Content.Shared.Trigger.Systems;
public sealed class SwapLocationOnTriggerSystem : EntitySystem
{
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly INetManager _net = default!;
public override void Initialize()
{
SubscribeLocalEvent<SwapLocationOnTriggerComponent, TriggerEvent>(OnTrigger);
}
private void OnTrigger(Entity<SwapLocationOnTriggerComponent> ent, ref TriggerEvent args)
{
if (args.Key != null && !ent.Comp.KeysIn.Contains(args.Key))
return;
if (args.User == null)
return;
// SwapPositions mispredicts at the moment.
// TODO: Fix this and remove the IsServer check.
if (_net.IsServer)
_transform.SwapPositions(ent.Owner, args.User.Value);
args.Handled = true;
}
}