From 21891da11695493c57aede26f3575c783161fc9b Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Wed, 6 Apr 2022 20:07:18 -0700 Subject: [PATCH] debug mode check use after destroy --- src/System.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/System.cs b/src/System.cs index 3cb11cd..e76706e 100644 --- a/src/System.cs +++ b/src/System.cs @@ -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(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(entity.ID, component); }