diff --git a/Content.Server/GameObjects/Components/Mobs/BuckleComponent.cs b/Content.Server/GameObjects/Components/Mobs/BuckleComponent.cs index 8b5eae4c9c..98f9da38f2 100644 --- a/Content.Server/GameObjects/Components/Mobs/BuckleComponent.cs +++ b/Content.Server/GameObjects/Components/Mobs/BuckleComponent.cs @@ -29,8 +29,10 @@ namespace Content.Server.GameObjects.Components.Mobs [Dependency] private readonly IServerNotifyManager _notifyManager = default!; #pragma warning restore 649 - private StrapComponent? _buckledTo; private int _size; + private float _range; + + private StrapComponent? _buckledTo; [ViewVariables] public StrapComponent? BuckledTo @@ -74,10 +76,18 @@ namespace Content.Server.GameObjects.Components.Mobs return false; } - var strapPosition = Owner.Transform.MapPosition; - var range = SharedInteractionSystem.InteractionRange / 2; + if (!to.TryGetComponent(out StrapComponent strap)) + { + _notifyManager.PopupMessage(Owner, user, + Loc.GetString(Owner == user + ? "You can't buckle yourself there!" + : "You can't buckle {0:them} there!", Owner)); + return false; + } - if (!InteractionChecks.InRangeUnobstructed(user, strapPosition, range) || + var strapPosition = strap.Owner.Transform.MapPosition; + + if (!InteractionChecks.InRangeUnobstructed(user, strapPosition, _range) || ContainerHelpers.IsInContainer(Owner)) { _notifyManager.PopupMessage(user, user, @@ -101,15 +111,6 @@ namespace Content.Server.GameObjects.Components.Mobs return false; } - if (!to.TryGetComponent(out StrapComponent strap)) - { - _notifyManager.PopupMessage(Owner, user, - Loc.GetString(Owner == user - ? "You can't buckle yourself there!" - : "You can't buckle {0:them} there!", Owner)); - return false; - } - var parent = to.Transform.Parent; while (parent != null) { @@ -195,9 +196,8 @@ namespace Content.Server.GameObjects.Components.Mobs } var strapPosition = Owner.Transform.MapPosition; - var range = SharedInteractionSystem.InteractionRange / 2; - if (!InteractionChecks.InRangeUnobstructed(user, strapPosition, range)) + if (!InteractionChecks.InRangeUnobstructed(user, strapPosition, _range)) { _notifyManager.PopupMessage(user, user, Loc.GetString("You can't reach there!")); @@ -265,6 +265,7 @@ namespace Content.Server.GameObjects.Components.Mobs base.ExposeData(serializer); serializer.DataField(ref _size, "size", 100); + serializer.DataField(ref _range, "range", SharedInteractionSystem.InteractionRange / 2); } protected override void Startup()