Skip to content

Commit

Permalink
Carried Entities Interact Fix (#114)
Browse files Browse the repository at this point in the history
# Description

Brings over mnemo's carrying interact fix so you can pet/hug/smooch
people who are carried!
Fansana/floofstation1#393

---

# Changelog

:cl:
- fix: can now interact with carried entities!
  • Loading branch information
sleepyyapril authored Dec 31, 2024
2 parents a38830e + c3e1413 commit 34de3a7
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions Content.Server/Carrying/CarryingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,17 @@ private void OnMobStateChanged(EntityUid uid, CarryingComponent component, MobSt
/// </summary>
private void OnInteractionAttempt(EntityUid uid, BeingCarriedComponent component, InteractionAttemptEvent args)
{
if (args.Target == null)
// Floofstation - function body reviewed
Predicate<TransformComponent> isChildOfCarrier = null!; // C# doesn't have local functions eugh
isChildOfCarrier = (childXForm) => childXForm.ParentUid == component.Carrier
|| (childXForm.ParentUid is { Valid: true } parent && isChildOfCarrier(Transform(parent)));

if (args.Target == null // Allow self-interacts
|| isChildOfCarrier(Transform(args.Target.Value))) // Allow interacting with everything on the carriee
return;

// Also check if the interacted-with entity is on the carrier and cancel the event if not
var targetParent = Transform(args.Target.Value).ParentUid;

if (args.Target.Value != component.Carrier && targetParent != component.Carrier && targetParent != uid)
args.Cancel();
}
Expand Down Expand Up @@ -201,8 +207,9 @@ private void OnStandAttempt(EntityUid uid, BeingCarriedComponent component, Stan

private void OnInteractedWith(EntityUid uid, BeingCarriedComponent component, GettingInteractedWithAttemptEvent args)
{
if (args.Uid != component.Carrier)
args.Cancel();
// Floofstation - why.
// if (args.Uid != component.Carrier)
// args.Cancel();
}

private void OnPullAttempt(EntityUid uid, BeingCarriedComponent component, PullAttemptEvent args)
Expand Down

0 comments on commit 34de3a7

Please sign in to comment.