misc optimization (#6436)

This commit is contained in:
Leon Friedrich
2022-02-03 18:40:22 +13:00
committed by GitHub
parent 19ceda04b5
commit 0da74b1bfb
7 changed files with 138 additions and 15 deletions

View File

@@ -29,7 +29,7 @@ namespace Content.Shared.Pulling.Components
/// </summary>
public DistanceJoint? PullJoint { get; set; }
public bool BeingPulled => Puller != default;
public bool BeingPulled => Puller != null;
public EntityCoordinates? MovingTo { get; set; }
@@ -76,15 +76,9 @@ namespace Content.Shared.Pulling.Components
EntitySystem.Get<SharedPullingStateManagementSystem>().ForceRelationship(comp, this);
}
protected override void Shutdown()
{
EntitySystem.Get<SharedPullingStateManagementSystem>().ForceDisconnectPullable(this);
base.Shutdown();
}
protected override void OnRemove()
{
if (Puller != default)
if (Puller != null)
{
// This is absolute paranoia but it's also absolutely necessary. Too many puller state bugs. - 20kdc
Logger.ErrorS("c.go.c.pulling", "PULLING STATE CORRUPTION IMMINENT IN PULLABLE {0} - OnRemove called when Puller is set!", Owner);

View File

@@ -31,6 +31,19 @@ namespace Content.Shared.Pulling
{
[Dependency] private readonly SharedJointSystem _jointSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<SharedPullableComponent, ComponentShutdown>(OnShutdown);
}
private void OnShutdown(EntityUid uid, SharedPullableComponent component, ComponentShutdown args)
{
if (component.Puller != null)
ForceRelationship(null, component);
}
// A WARNING:
// The following 2 functions are the most internal part of the pulling system's relationship management.
// They do not expect to be cancellable.