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:
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user