CatStation/Content.Shared/Trigger/Systems/SwapLocationOnTriggerSystem.cs
Pieter-Jan Briers 5168b5f3d4
IoC source gen compatibility (#43863)
* IoC source gen compatibility

Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter.

* Missed a spot
2026-05-09 03:29:58 +00:00

30 lines
938 B
C#

using Content.Shared.Trigger.Components.Effects;
using Robust.Shared.Network;
namespace Content.Shared.Trigger.Systems;
public sealed partial class SwapLocationOnTriggerSystem : EntitySystem
{
[Dependency] private SharedTransformSystem _transform = default!;
[Dependency] private 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;
}
}