From 769f77dcdb561f848678abe033bf853f1445c40f Mon Sep 17 00:00:00 2001 From: Ullrich Praetz Date: Wed, 31 Jul 2024 08:22:42 +0200 Subject: [PATCH] ECS - change EntityState to ref readonly struct --- src/ECS/Entity/EntityState.cs | 2 +- src/Tests/ECS/Entity/Test_EntityState.cs | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/ECS/Entity/EntityState.cs b/src/ECS/Entity/EntityState.cs index c7e3a9b0..92ae5541 100644 --- a/src/ECS/Entity/EntityState.cs +++ b/src/ECS/Entity/EntityState.cs @@ -4,7 +4,7 @@ // ReSharper disable once CheckNamespace namespace Friflo.Engine.ECS; -public readonly struct EntityState +public readonly ref struct EntityState { #region entity getter public bool IsNull => archetype == null; diff --git a/src/Tests/ECS/Entity/Test_EntityState.cs b/src/Tests/ECS/Entity/Test_EntityState.cs index 942c79ad..f9d407f2 100644 --- a/src/Tests/ECS/Entity/Test_EntityState.cs +++ b/src/Tests/ECS/Entity/Test_EntityState.cs @@ -31,12 +31,22 @@ public static void Test_EntityState_getter() state = entity.State; IsTrue(state.IsNull); Throws(() => { - _ = state.Tags; + GetTags(entity); }); Throws(() => { - _ = state.Get(); + GetComponent(entity); }); } + + private static void GetTags(Entity entity) { + var state = entity.State; + _ = state.Tags; + } + + private static void GetComponent(Entity entity) { + var state = entity.State; + _ = state.Get(); + } } }