mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-06 17:58:05 +02:00
Making possible to QueueDeleteEntity on EndCollideEvent (#4883)
* made possible to destroy entity on EndCollideEvent * figured queue delete issue * review --------- Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -186,17 +186,25 @@ public partial class SharedPhysicsSystem
|
||||
{
|
||||
if (body.Contacts.Count == 0) return;
|
||||
|
||||
// This variable is only used in edge-case scenario when contact flagged Deleting raises
|
||||
// EndCollideEvent which will QueueDelete contact's entity
|
||||
ushort contactsFlaggedDeleting = 0;
|
||||
var node = body.Contacts.First;
|
||||
|
||||
while (node != null)
|
||||
{
|
||||
var contact = node.Value;
|
||||
node = node.Next;
|
||||
|
||||
// Destroy last so the linked-list doesn't get touched.
|
||||
DestroyContact(contact);
|
||||
if (!DestroyContact(contact))
|
||||
{
|
||||
contactsFlaggedDeleting++;
|
||||
}
|
||||
}
|
||||
|
||||
DebugTools.Assert(body.Contacts.Count == 0);
|
||||
// This contact will be deleted before SimulateWorld runs since it is already set to be Deleted
|
||||
DebugTools.Assert(body.Contacts.Count == contactsFlaggedDeleting);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user