Skip to content

Commit

Permalink
Update Assign<T>
Browse files Browse the repository at this point in the history
  • Loading branch information
nilpunch committed Aug 25, 2024
1 parent 590be30 commit dae9209
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 13.0.0 - August 25, 2024

- Changed: Divided `Assign<T>()` 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<Include, Exclude, Owned>`.

## 12.0.0 - August 10, 2024

Devirtualize usages for better inlining and performance.
Expand Down
17 changes: 16 additions & 1 deletion Runtime/Registry/RegistryExtensions/RegistryEntityExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static bool IsAlive(this Registry registry, Entity entity)
/// <param name="data"> Initial data for the assigned component. </param>
/// <remarks> If the entity is not alive, nothing happens. </remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Assign<T>(this Registry registry, Entity entity, T data = default)
public static void Assign<T>(this Registry registry, Entity entity, T data)
{
if (!registry.Entities.IsAlive(entity))
{
Expand All @@ -85,6 +85,21 @@ public static void Assign<T>(this Registry registry, Entity entity, T data = def
registry.Assign(entity.Id, data);
}

/// <summary>
/// Assigns a component to an entity, without data initialization.
/// </summary>
/// <remarks> If the entity is not alive, nothing happens. </remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Assign<T>(this Registry registry, Entity entity)
{
if (!registry.Entities.IsAlive(entity))
{
return;
}

registry.Assign<T>(entity.Id);
}

/// <summary>
/// Unassigns a component from an entity.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions Runtime/Registry/RegistryExtensions/RegistryIdExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ public static void Assign<T>(this Registry registry, int id, T data)
dataSet.Get(id) = data;
}
}

/// <summary>
/// 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.
/// </summary>
/// <remarks>
/// Assigning a component to an entity that is being destroyed can lead to undefined behavior.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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.",
Expand Down

0 comments on commit dae9209

Please sign in to comment.