From 264062cd1572553d0d799abde7ad6a654d0cfc54 Mon Sep 17 00:00:00 2001 From: DrSmugleaf Date: Tue, 28 Jul 2020 08:34:42 +0200 Subject: [PATCH] Fix error when pulling a buckled entity (#1510) * Fix error when pulling a buckled entity * Cache BuckledTo earlier in the code --- .../Components/Buckle/BuckleComponent.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Content.Server/GameObjects/Components/Buckle/BuckleComponent.cs b/Content.Server/GameObjects/Components/Buckle/BuckleComponent.cs index 46eb6d3b65..4914e7f9a9 100644 --- a/Content.Server/GameObjects/Components/Buckle/BuckleComponent.cs +++ b/Content.Server/GameObjects/Components/Buckle/BuckleComponent.cs @@ -292,11 +292,13 @@ namespace Content.Server.GameObjects.Components.Buckle /// public bool TryUnbuckle(IEntity user, bool force = false) { - if (BuckledTo == null) + if (!Buckled) { return false; } + StrapComponent oldBuckledTo = BuckledTo!; + if (!force) { 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); - 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)) { appearance.SetData(BuckleVisuals.Buckled, false);