diff --git a/CHANGELOG.md b/CHANGELOG.md index fb1e4e4..a87b553 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 13.0.0 - August 25, 2024 + +- Changed: Divided `Assign()` into two distinct overloads - with data initialization and without it. + This will allow the sets to be used as objects pools. +- Changed: Order of groups to more common pattern `Group`. + ## 12.0.0 - August 10, 2024 Devirtualize usages for better inlining and performance. diff --git a/Runtime/Registry/RegistryExtensions/RegistryEntityExtensions.cs b/Runtime/Registry/RegistryExtensions/RegistryEntityExtensions.cs index 4633a0a..197b5b9 100644 --- a/Runtime/Registry/RegistryExtensions/RegistryEntityExtensions.cs +++ b/Runtime/Registry/RegistryExtensions/RegistryEntityExtensions.cs @@ -75,7 +75,7 @@ public static bool IsAlive(this Registry registry, Entity entity) /// Initial data for the assigned component. /// If the entity is not alive, nothing happens. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void Assign(this Registry registry, Entity entity, T data = default) + public static void Assign(this Registry registry, Entity entity, T data) { if (!registry.Entities.IsAlive(entity)) { @@ -85,6 +85,21 @@ public static void Assign(this Registry registry, Entity entity, T data = def registry.Assign(entity.Id, data); } + /// + /// Assigns a component to an entity, without data initialization. + /// + /// If the entity is not alive, nothing happens. + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static void Assign(this Registry registry, Entity entity) + { + if (!registry.Entities.IsAlive(entity)) + { + return; + } + + registry.Assign(entity.Id); + } + /// /// Unassigns a component from an entity. /// diff --git a/Runtime/Registry/RegistryExtensions/RegistryIdExtensions.cs b/Runtime/Registry/RegistryExtensions/RegistryIdExtensions.cs index 3a06cda..2b06e03 100644 --- a/Runtime/Registry/RegistryExtensions/RegistryIdExtensions.cs +++ b/Runtime/Registry/RegistryExtensions/RegistryIdExtensions.cs @@ -94,9 +94,9 @@ public static void Assign(this Registry registry, int id, T data) dataSet.Get(id) = data; } } - + /// - /// Assigns a component to an entity with this ID, regardless of generation. + /// Assigns a component to an entity with this ID, regardless of generation, without data initialization. /// /// /// Assigning a component to an entity that is being destroyed can lead to undefined behavior. diff --git a/package.json b/package.json index 2d83b64..f8d791a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "massive-ecs", - "version": "12.0.0", + "version": "13.0.0", "displayName": "Massive ECS", "unity": "2021.2", "description": "Sparse set ECS library made for prediction-rollback netcode.",