From ea92e23d99570f91e6099103ac3ab05bfa114c0b Mon Sep 17 00:00:00 2001 From: Ullrich Praetz Date: Tue, 2 Apr 2024 18:10:52 +0200 Subject: [PATCH] Engine - ECS: moved EntityStoreExtensions.CreateEntity() overload to Extension folder --- Engine/src/ECS/Entity/Store/Entities.cs | 34 ++++++++++++++++++ .../Store/{ => Extensions}/CreateEntity.cs | 36 ------------------- 2 files changed, 34 insertions(+), 36 deletions(-) rename Engine/src/ECS/Entity/Store/{ => Extensions}/CreateEntity.cs (89%) diff --git a/Engine/src/ECS/Entity/Store/Entities.cs b/Engine/src/ECS/Entity/Store/Entities.cs index 8eb4cf6ef3..ce9386677f 100644 --- a/Engine/src/ECS/Entity/Store/Entities.cs +++ b/Engine/src/ECS/Entity/Store/Entities.cs @@ -6,6 +6,8 @@ using System.Diagnostics.CodeAnalysis; using Friflo.Engine.ECS.Serialize; using static Friflo.Engine.ECS.NodeFlags; +using static Friflo.Engine.ECS.StoreOwnership; +using static Friflo.Engine.ECS.TreeMembership; // ReSharper disable UseNullPropagation // ReSharper disable ForeachCanBeConvertedToQueryUsingAnotherGetEnumerator @@ -23,6 +25,38 @@ public partial class EntityStore /// public static EntitySchema GetEntitySchema()=> Static.EntitySchema; + /// + /// Create and return a new in the entity store.
+ /// See Example. + ///
+ /// An and entity + public Entity CreateEntity() + { + var id = NewId(); + CreateEntityInternal(defaultArchetype, id); + var entity = new Entity(this, id); + + // Send event. See: SEND_EVENT notes + CreateEntityEvent(entity); + return entity; + } + + /// + /// Create and return a new with the passed in the entity store. + /// + /// an and entity + public Entity CreateEntity(int id) + { + CheckEntityId(id); + CreateEntityInternal(defaultArchetype, id); + var entity = new Entity(this, id); + + // Send event. See: SEND_EVENT notes + CreateEntityEvent(entity); + return entity; + } + + internal void CheckEntityId(int id) { if (id < Static.MinNodeId) { diff --git a/Engine/src/ECS/Entity/Store/CreateEntity.cs b/Engine/src/ECS/Entity/Store/Extensions/CreateEntity.cs similarity index 89% rename from Engine/src/ECS/Entity/Store/CreateEntity.cs rename to Engine/src/ECS/Entity/Store/Extensions/CreateEntity.cs index 7915a6ee84..447aaef486 100644 --- a/Engine/src/ECS/Entity/Store/CreateEntity.cs +++ b/Engine/src/ECS/Entity/Store/Extensions/CreateEntity.cs @@ -2,46 +2,10 @@ // See LICENSE file in the project root for full license information. -using static Friflo.Engine.ECS.StoreOwnership; -using static Friflo.Engine.ECS.TreeMembership; - // ReSharper disable UseNullPropagation // ReSharper disable once CheckNamespace namespace Friflo.Engine.ECS; -public partial class EntityStore -{ - /// - /// Create and return a new in the entity store.
- /// See Example. - ///
- /// An and entity - public Entity CreateEntity() - { - var id = NewId(); - CreateEntityInternal(defaultArchetype, id); - var entity = new Entity(this, id); - - // Send event. See: SEND_EVENT notes - CreateEntityEvent(entity); - return entity; - } - - /// - /// Create and return a new with the passed in the entity store. - /// - /// an and entity - public Entity CreateEntity(int id) - { - CheckEntityId(id); - CreateEntityInternal(defaultArchetype, id); - var entity = new Entity(this, id); - - // Send event. See: SEND_EVENT notes - CreateEntityEvent(entity); - return entity; - } -} /// /// Provide generic CreateEntity() overloads to create entities with passed components without any structural change.