Fix error when pulling a buckled entity (#1510)

* Fix error when pulling a buckled entity

* Cache BuckledTo earlier in the code
This commit is contained in:
DrSmugleaf
2020-07-28 08:34:42 +02:00
committed by GitHub
parent 5e0ca8a85a
commit 264062cd15

View File

@@ -292,11 +292,13 @@ namespace Content.Server.GameObjects.Components.Buckle
/// </returns> /// </returns>
public bool TryUnbuckle(IEntity user, bool force = false) public bool TryUnbuckle(IEntity user, bool force = false)
{ {
if (BuckledTo == null) if (!Buckled)
{ {
return false; return false;
} }
StrapComponent oldBuckledTo = BuckledTo!;
if (!force) if (!force)
{ {
if (_gameTiming.CurTime < _buckleTime + _unbuckleDelay) if (_gameTiming.CurTime < _buckleTime + _unbuckleDelay)
@@ -319,15 +321,14 @@ namespace Content.Server.GameObjects.Components.Buckle
} }
} }
if (Owner.Transform.Parent == BuckledTo.Owner.Transform) BuckledTo = null;
if (Owner.Transform.Parent == oldBuckledTo.Owner.Transform)
{ {
ContainerHelpers.AttachParentToContainerOrGrid(Owner.Transform); ContainerHelpers.AttachParentToContainerOrGrid(Owner.Transform);
Owner.Transform.WorldRotation = BuckledTo.Owner.Transform.WorldRotation; Owner.Transform.WorldRotation = oldBuckledTo.Owner.Transform.WorldRotation;
} }
var oldBuckledTo = BuckledTo;
BuckledTo = null;
if (Owner.TryGetComponent(out AppearanceComponent appearance)) if (Owner.TryGetComponent(out AppearanceComponent appearance))
{ {
appearance.SetData(BuckleVisuals.Buckled, false); appearance.SetData(BuckleVisuals.Buckled, false);