mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Cleanup relays on joint deletion (#4497)
This commit is contained in:
@@ -51,7 +51,7 @@ public abstract partial class SharedJointSystem
|
||||
{
|
||||
foreach (var relay in component.Relayed)
|
||||
{
|
||||
if (Deleted(relay) || !_jointsQuery.TryGetComponent(relay, out var joint))
|
||||
if (TerminatingOrDeleted(relay) || !_jointsQuery.TryGetComponent(relay, out var joint))
|
||||
continue;
|
||||
|
||||
RefreshRelay(relay, component: joint);
|
||||
@@ -73,13 +73,13 @@ public abstract partial class SharedJointSystem
|
||||
relay = container.Owner;
|
||||
}
|
||||
|
||||
RefreshRelay(uid, relay, component);
|
||||
SetRelay(uid, relay, component);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Refreshes the joint relay for this entity.
|
||||
/// </summary>
|
||||
public void RefreshRelay(EntityUid uid, EntityUid? relay, JointComponent? component = null)
|
||||
public void SetRelay(EntityUid uid, EntityUid? relay, JointComponent? component = null)
|
||||
{
|
||||
if (!Resolve(uid, ref component, false))
|
||||
return;
|
||||
@@ -91,7 +91,11 @@ public abstract partial class SharedJointSystem
|
||||
{
|
||||
if (relayTarget.Relayed.Remove(uid))
|
||||
{
|
||||
// TODO: Comp cleanup.
|
||||
if (relayTarget.Relayed.Count == 0)
|
||||
{
|
||||
RemCompDeferred<JointRelayTargetComponent>(component.Relay.Value);
|
||||
}
|
||||
|
||||
Dirty(component.Relay.Value, relayTarget);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,6 +90,10 @@ public abstract partial class SharedJointSystem : EntitySystem
|
||||
{
|
||||
RemoveJoint(joint);
|
||||
}
|
||||
|
||||
// If we're relaying elsewhere then cleanup our old data.
|
||||
if (component.Relay != null && !TerminatingOrDeleted(component.Relay.Value))
|
||||
SetRelay(uid, null, component);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user