From b93beed5ec3f43195f375060c1c60eb177e790d3 Mon Sep 17 00:00:00 2001 From: copygirl Date: Sat, 6 May 2023 13:52:20 +0200 Subject: [PATCH] Fix CreateLookup throwing on same lookup creation --- src/gaemstone.ECS/Entity.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gaemstone.ECS/Entity.cs b/src/gaemstone.ECS/Entity.cs index be1abc9..2d96b3e 100644 --- a/src/gaemstone.ECS/Entity.cs +++ b/src/gaemstone.ECS/Entity.cs @@ -50,7 +50,8 @@ public unsafe readonly partial struct Entity public Entity CreateLookup() { ref var lookup = ref Lookup.Entity.Value; - if (lookup.IsSome) throw new InvalidOperationException( + if (lookup == this) { /* Don't throw if lookup already has the same entity set. */ } + else if (lookup.IsSome) throw new InvalidOperationException( $"The lookup for type {typeof(T)} in context {typeof(TContext)} is already in use by {lookup}"); lookup = this; return this;