debug mode check use after destroy

pull/2/head
cosmonaut 2022-04-06 20:07:18 -07:00
parent da35e99266
commit 21891da116
1 changed files with 7 additions and 5 deletions

View File

@ -16,11 +16,6 @@ public abstract class System : EntityComponentReader
public abstract void Update(TimeSpan delta);
public virtual void InitializeFilters()
{
}
protected Entity CreateEntity()
{
return EntityStorage.Create();
@ -28,6 +23,13 @@ public abstract class System : EntityComponentReader
protected void Set<TComponent>(in Entity entity, in TComponent component) where TComponent : struct
{
#if DEBUG
// check for use after destroy
if (!Exists(entity))
{
throw new ArgumentException("This entity is not valid!");
}
#endif
ComponentDepot.Set<TComponent>(entity.ID, component);
}