Fix buckling range and north facing buckle visual bug (#1421)

* Fix being able to buckle others from farther away than intended

* Make buckling range slightly bigger

* Fix north facing buckles looking strange
This commit is contained in:
DrSmugleaf
2020-07-19 21:34:35 +02:00
committed by GitHub
parent 935e3b56df
commit 2facb57826

View File

@@ -16,6 +16,7 @@ using Robust.Server.GameObjects.EntitySystemMessages;
using Robust.Server.GameObjects.EntitySystems; using Robust.Server.GameObjects.EntitySystems;
using Robust.Shared.Containers; using Robust.Shared.Containers;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Timing; using Robust.Shared.Interfaces.Timing;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -85,7 +86,8 @@ namespace Content.Server.GameObjects.Components.Buckle
private bool ContainerChanged { get; set; } private bool ContainerChanged { get; set; }
/// <summary> /// <summary>
/// The amount of space that this entity occupies in a <see cref="StrapComponent"/>. /// The amount of space that this entity occupies in a
/// <see cref="StrapComponent"/>.
/// </summary> /// </summary>
[ViewVariables] [ViewVariables]
public int Size => _size; public int Size => _size;
@@ -106,9 +108,9 @@ namespace Content.Server.GameObjects.Components.Buckle
} }
/// <summary> /// <summary>
/// Reattaches this entity to the strap, modifying its position and rotation /// Reattaches this entity to the strap, modifying its position and rotation.
/// </summary> /// </summary>
/// <param name="strap">The strap to reattach to</param> /// <param name="strap">The strap to reattach to.</param>
private void ReAttach(StrapComponent strap) private void ReAttach(StrapComponent strap)
{ {
var ownTransform = Owner.Transform; var ownTransform = Owner.Transform;
@@ -131,6 +133,11 @@ namespace Content.Server.GameObjects.Components.Buckle
ownTransform.WorldRotation = Angle.South; ownTransform.WorldRotation = Angle.South;
break; break;
} }
if (strapTransform.WorldRotation.GetCardinalDir() == Direction.North)
{
ownTransform.WorldPosition += (0, 0.15f);
}
} }
/// <summary> /// <summary>
@@ -167,10 +174,16 @@ namespace Content.Server.GameObjects.Components.Buckle
return false; return false;
} }
var ownerPosition = Owner.Transform.MapPosition;
var strapPosition = strap.Owner.Transform.MapPosition; var strapPosition = strap.Owner.Transform.MapPosition;
var interaction = EntitySystem.Get<SharedInteractionSystem>();
bool Ignored(IEntity entity) => entity == Owner || entity == user || entity == strap.Owner;
if (!InteractionChecks.InRangeUnobstructed(user, strapPosition, _range)) if (!interaction.InRangeUnobstructed(ownerPosition, strapPosition, _range, predicate: Ignored))
{ {
_notifyManager.PopupMessage(strap.Owner, user,
Loc.GetString("You can't reach there!"));
return false; return false;
} }
@@ -408,7 +421,7 @@ namespace Content.Server.GameObjects.Components.Buckle
base.ExposeData(serializer); base.ExposeData(serializer);
serializer.DataField(ref _size, "size", 100); serializer.DataField(ref _size, "size", 100);
serializer.DataField(ref _range, "range", SharedInteractionSystem.InteractionRange / 2); serializer.DataField(ref _range, "range", SharedInteractionSystem.InteractionRange / 1.4f);
var seconds = 0.25f; var seconds = 0.25f;
serializer.DataField(ref seconds, "cooldown", 0.25f); serializer.DataField(ref seconds, "cooldown", 0.25f);