mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Add TryQueueDeleteEntity (#5281)
Having to check deleted by hand up front is annoying.
This commit is contained in:
@@ -33,10 +33,7 @@ public class EntityPrototypeView : SpriteView
|
||||
|
||||
_currentPrototype = entProto;
|
||||
SetEntity(null);
|
||||
if (_ourEntity != null)
|
||||
{
|
||||
EntMan.DeleteEntity(_ourEntity);
|
||||
}
|
||||
EntMan.DeleteEntity(_ourEntity);
|
||||
|
||||
if (_currentPrototype != null)
|
||||
{
|
||||
@@ -57,8 +54,6 @@ public class EntityPrototypeView : SpriteView
|
||||
protected override void ExitedTree()
|
||||
{
|
||||
base.ExitedTree();
|
||||
|
||||
if (!EntMan.Deleted(_ourEntity))
|
||||
EntMan.QueueDeleteEntity(_ourEntity);
|
||||
EntMan.TryQueueDeleteEntity(_ourEntity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -468,6 +468,21 @@ namespace Robust.Shared.GameObjects
|
||||
ent.Comp4.LastModifiedTick = CurrentTick;
|
||||
}
|
||||
|
||||
public bool TryQueueDeleteEntity(EntityUid? uid)
|
||||
{
|
||||
if (uid == null)
|
||||
return false;
|
||||
|
||||
if (Deleted(uid.Value))
|
||||
return false;
|
||||
|
||||
if (!QueuedDeletionsSet.Add(uid.Value))
|
||||
return false;
|
||||
|
||||
QueueDeleteEntity(uid);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shuts-down and removes given Entity. This is also broadcast to all clients.
|
||||
/// </summary>
|
||||
|
||||
@@ -705,6 +705,13 @@ public partial class EntitySystem
|
||||
EntityManager.QueueDeleteEntity(uid);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IEntityManager.TryQueueDeleteEntity(EntityUid?)" />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected bool TryQueueDel(EntityUid? uid)
|
||||
{
|
||||
return EntityManager.TryQueueDeleteEntity(uid);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Entity Spawning
|
||||
|
||||
@@ -153,6 +153,11 @@ namespace Robust.Shared.GameObjects
|
||||
where T3 : IComponent
|
||||
where T4 : IComponent;
|
||||
|
||||
/// <summary>
|
||||
/// Tries to QueueDeleteEntity if the entity is not already deleted.
|
||||
/// </summary>
|
||||
public bool TryQueueDeleteEntity(EntityUid? uid);
|
||||
|
||||
public void QueueDeleteEntity(EntityUid? uid);
|
||||
|
||||
public bool IsQueuedForDeletion(EntityUid uid);
|
||||
|
||||
Reference in New Issue
Block a user