mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
Don't raise contact events for qdel ents (#4126)
This commit is contained in:
@@ -77,6 +77,11 @@ namespace Robust.Shared.GameObjects
|
||||
public event Action<EntityUid>? EntityInitialized;
|
||||
public event Action<EntityUid>? EntityStarted;
|
||||
public event Action<EntityUid>? EntityDeleted;
|
||||
|
||||
/// <summary>
|
||||
/// Raised when an entity is queued for deletion. Not raised if an entity is deleted.
|
||||
/// </summary>
|
||||
public event Action<EntityUid>? EntityQueueDeleted;
|
||||
public event Action<EntityUid>? EntityDirtied; // only raised after initialization
|
||||
|
||||
private string _xformName = string.Empty;
|
||||
@@ -637,8 +642,11 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
public virtual void QueueDeleteEntity(EntityUid uid)
|
||||
{
|
||||
if(QueuedDeletionsSet.Add(uid))
|
||||
QueuedDeletions.Enqueue(uid);
|
||||
if (!QueuedDeletionsSet.Add(uid))
|
||||
return;
|
||||
|
||||
QueuedDeletions.Enqueue(uid);
|
||||
EntityQueueDeleted?.Invoke(uid);
|
||||
}
|
||||
|
||||
public bool IsQueuedForDeletion(EntityUid uid) => QueuedDeletionsSet.Contains(uid);
|
||||
|
||||
@@ -164,6 +164,21 @@ public abstract partial class SharedPhysicsSystem
|
||||
4096);
|
||||
|
||||
InitializePool();
|
||||
EntityManager.EntityQueueDeleted += OnContactEntityQueueDel;
|
||||
}
|
||||
|
||||
private void ShutdownContacts()
|
||||
{
|
||||
EntityManager.EntityQueueDeleted -= OnContactEntityQueueDel;
|
||||
}
|
||||
|
||||
private void OnContactEntityQueueDel(EntityUid obj)
|
||||
{
|
||||
// If an entity is queuedeleted then we want to purge its contacts before SimulateWorld runs in the same tick.
|
||||
if (!TryComp<PhysicsComponent>(obj, out var physicsComp))
|
||||
return;
|
||||
|
||||
DestroyContacts(physicsComp);
|
||||
}
|
||||
|
||||
private void InitializePool()
|
||||
|
||||
@@ -250,6 +250,7 @@ namespace Robust.Shared.Physics.Systems
|
||||
{
|
||||
base.Shutdown();
|
||||
|
||||
ShutdownContacts();
|
||||
ShutdownIsland();
|
||||
_configManager.UnsubValueChanged(CVars.AutoClearForces, OnAutoClearChange);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user