Skip to content

Commit

Permalink
Moved pulled container check to CanOpen
Browse files Browse the repository at this point in the history
Also added a line to check if the user is inside the container. With the previous commit, the user could leave using the movement keys, since that method bypassed ToggleOpen. This now allows trapped users to leave both with movement keys and interact.
  • Loading branch information
TGRCdev committed Nov 25, 2024
1 parent 67a8de4 commit c08ca6c
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,6 @@ public void ToggleOpen(EntityUid user, EntityUid target, SharedEntityStorageComp
if (!ResolveStorage(target, ref component))
return;

// impstation edit
// prevent dumbasses from opening crates that are being dragged
if (
TryComp<PullableComponent>(target, out var pull) &&
pull.BeingPulled &&
pull.Puller != user
)
return;

if (component.Open)
{
TryCloseStorage(target);
Expand Down Expand Up @@ -381,6 +372,15 @@ public bool CanOpen(EntityUid user, EntityUid target, bool silent = false, Share
}
}

// impstation edit: prevent opening containers being pulled by others
if (
TryComp<PullableComponent>(target, out var pullable) && // Can be pulled
pullable.BeingPulled && // Someone is pulling it
pullable.Puller != user && // It is not the user
!component.Contents.Contains(user) // The user is not inside of it
)
return false;

//Checks to see if the opening position, if offset, is inside of a wall.
if (component.EnteringOffset != new Vector2(0, 0) && !HasComp<WallMountComponent>(target)) //if the entering position is offset
{
Expand Down

0 comments on commit c08ca6c

Please sign in to comment.