Fix pulling HandleComponentState (#4773)

This commit is contained in:
20kdc
2021-10-05 22:51:34 +01:00
committed by GitHub
parent eb5f447e7a
commit 021f281dfc

View File

@@ -28,7 +28,7 @@ namespace Content.Shared.Pulling.Components
/// <summary> /// <summary>
/// The current entity pulling this component. /// The current entity pulling this component.
/// Ideally, alter using TryStartPull and TryStopPull. /// SharedPullingStateManagementSystem should be writing this. This means definitely not you.
/// </summary> /// </summary>
public IEntity? Puller { get; set; } public IEntity? Puller { get; set; }
/// <summary> /// <summary>
@@ -57,7 +57,7 @@ namespace Content.Shared.Pulling.Components
if (state.Puller == null) if (state.Puller == null)
{ {
Puller = null; EntitySystem.Get<SharedPullingStateManagementSystem>().ForceDisconnectPullable(this);
return; return;
} }
@@ -67,7 +67,21 @@ namespace Content.Shared.Pulling.Components
return; return;
} }
Puller = entity; if (Puller == entity)
{
// don't disconnect and reconnect a puller for no reason
return;
}
if (!entity.TryGetComponent<SharedPullerComponent>(out var comp))
{
Logger.Error($"Entity {state.Puller.Value} for pulling had no Puller component");
// ensure it disconnects from any different puller, still
EntitySystem.Get<SharedPullingStateManagementSystem>().ForceDisconnectPullable(this);
return;
}
EntitySystem.Get<SharedPullingStateManagementSystem>().ForceRelationship(comp, this);
} }
protected override void Shutdown() protected override void Shutdown()