Skip to content

Commit

Permalink
disallow teleporting out of entity storage
Browse files Browse the repository at this point in the history
  • Loading branch information
DEATHB4DEFEAT committed Oct 14, 2023
1 parent 383c38e commit 3fa32e8
Showing 1 changed file with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Content.Shared.Damage.Systems;
using Content.Shared.Pulling.Components;
using Content.Shared.SimpleStation14.Species.Shadowkin.Components;
using Content.Shared.Storage.Components;
using Robust.Shared.Audio;
using Robust.Shared.Prototypes;

Expand Down Expand Up @@ -49,16 +50,15 @@ private void Shutdown(EntityUid uid, ShadowkinTeleportPowerComponent component,

private void Teleport(EntityUid uid, ShadowkinTeleportPowerComponent component, ShadowkinTeleportEvent args)
{
// Need power to drain power
if (!_entity.TryGetComponent<ShadowkinComponent>(args.Performer, out var comp))
return;

// Don't activate abilities if specially handcuffed
if (_entity.TryGetComponent<HandcuffComponent>(args.Performer, out var cuffs) && cuffs.AntiShadowkin)
// Don't activate abilities if...
if (!_entity.TryGetComponent<ShadowkinComponent>(args.Performer, out var comp) || // Not a Shadowkin
_entity.TryGetComponent<HandcuffComponent>(args.Performer, out var cuffs) && cuffs.AntiShadowkin || // Specially handcuffed
_entity.HasComponent<InsideEntityStorageComponent>(args.Performer)) // Inside an entity storage
return;


var transform = Transform(args.Performer);
// Must be on the same map
if (transform.MapID != args.Target.GetMapId(EntityManager))
return;

Expand All @@ -67,14 +67,12 @@ private void Teleport(EntityUid uid, ShadowkinTeleportPowerComponent component,
puller.Pulling != null &&
_entity.TryGetComponent<SharedPullableComponent>(puller.Pulling, out pullable) &&
pullable.BeingPulled)
{
// Temporarily stop pulling to avoid not teleporting to the target
// Temporarily stop pulling to avoid not teleporting fully to the target
_pulling.TryStopPull(pullable);
}

// Teleport the performer to the target
_transform.SetCoordinates(args.Performer, args.Target);
transform.AttachToGridOrMap();
_transform.AttachToGridOrMap(args.Performer, transform);

if (pullable != null && puller != null)
{
Expand All @@ -84,7 +82,7 @@ private void Teleport(EntityUid uid, ShadowkinTeleportPowerComponent component,
// Teleport the pulled entity to the target
// TODO: Relative position to the performer
_transform.SetCoordinates(pullable.Owner, args.Target);
pulledTransform.AttachToGridOrMap();
_transform.AttachToGridOrMap(args.Performer, transform);

// Resume pulling
// TODO: This does nothing? // This does things sometimes, but the client never knows
Expand Down

0 comments on commit 3fa32e8

Please sign in to comment.