From 81f5a52869a8b19a83258bf85c5ff41c42a8b87d Mon Sep 17 00:00:00 2001 From: Ullrich Praetz Date: Sun, 1 Dec 2024 15:35:09 +0100 Subject: [PATCH] rename: EntityRelation<> -> EntityRelations<> --- .../{EntityRelation.cs => EntityRelations.cs} | 6 +++--- src/ECS/Relations/RelationExtensions.cs | 18 +++++++++--------- src/Tests/ECS/Relations/Test_Relations.cs | 2 +- .../ECS/Relations/Test_Relations_Delete.cs | 4 ++-- .../ECS/Relations/Test_Relations_Query.cs | 4 ++-- 5 files changed, 17 insertions(+), 17 deletions(-) rename src/ECS/Relations/{EntityRelation.cs => EntityRelations.cs} (86%) diff --git a/src/ECS/Relations/EntityRelation.cs b/src/ECS/Relations/EntityRelations.cs similarity index 86% rename from src/ECS/Relations/EntityRelation.cs rename to src/ECS/Relations/EntityRelations.cs index a82f5ffe..7f8f0021 100644 --- a/src/ECS/Relations/EntityRelation.cs +++ b/src/ECS/Relations/EntityRelations.cs @@ -3,12 +3,12 @@ // ReSharper disable once CheckNamespace namespace Friflo.Engine.ECS; -public readonly struct EntityRelation +public readonly struct EntityRelations where TRelation : struct, IRelation { private readonly AbstractEntityRelations relations; - internal EntityRelation(AbstractEntityRelations relations) { + internal EntityRelations(AbstractEntityRelations relations) { this.relations = relations; } @@ -23,7 +23,7 @@ internal EntityRelation(AbstractEntityRelations relations) { /// /// /// To get all entities including their relations (the cartesian product aka CROSS JOIN) use
- /// + /// ///
/// /// diff --git a/src/ECS/Relations/RelationExtensions.cs b/src/ECS/Relations/RelationExtensions.cs index c9ea3bc4..0293cf93 100644 --- a/src/ECS/Relations/RelationExtensions.cs +++ b/src/ECS/Relations/RelationExtensions.cs @@ -102,15 +102,15 @@ public static EntityLinks GetIncomingLinks(this Entity tar #endregion #region EntityStore - public static EntityRelation EntityRelation(this EntityStore store) + public static EntityRelations EntityRelations(this EntityStore store) where TRelation : struct, IRelation { var relations = AbstractEntityRelations.GetEntityRelations(store, StructInfo.Index); - return new EntityRelation(relations); + return new EntityRelations(relations); } /// - /// Obsolete: Use
+ /// Obsolete: Use
/// Returns a collection of entities having one or more relations of the specified type.
/// Executes in O(1). ///
@@ -121,11 +121,11 @@ public static EntityRelation EntityRelation(this EntitySto /// /// /// To get all entities including their relations (the cartesian product aka CROSS JOIN) use
- /// + /// ///
/// /// - [Obsolete("replace with property: EntityRelation().Entities")] + [Obsolete("replace with property: EntityRelations().Entities")] public static EntityReadOnlyCollection GetAllEntitiesWithRelations(this EntityStore store) where TRelation : struct, IRelation { @@ -134,11 +134,11 @@ public static EntityReadOnlyCollection GetAllEntitiesWithRelations(th } /// - /// Obsolete: Use
+ /// Obsolete: Use
/// Iterates all entity relations of the specified type.
/// Executes in O(N) N: number of all entity relations. ///
- [Obsolete("replace with method: EntityRelation().For()")] + [Obsolete("replace with method: EntityRelations().For()")] public static void ForAllEntityRelations(this EntityStore store, ForEachEntity lambda) where TRelation : struct, IRelation { @@ -147,11 +147,11 @@ public static void ForAllEntityRelations(this EntityStore store, ForE } /// - /// Obsolete: Use
+ /// Obsolete: Use
/// Return all entity relations of the specified type.
/// Executes in O(1). Most efficient way to iterate all entity relations. ///
- [Obsolete("replace with property: EntityRelation().Pairs")] + [Obsolete("replace with property: EntityRelations().Pairs")] public static (Entities entities, Chunk relations) GetAllEntityRelations(this EntityStore store) where TRelation : struct, IRelation { diff --git a/src/Tests/ECS/Relations/Test_Relations.cs b/src/Tests/ECS/Relations/Test_Relations.cs index 24815d84..a8fd2a02 100644 --- a/src/Tests/ECS/Relations/Test_Relations.cs +++ b/src/Tests/ECS/Relations/Test_Relations.cs @@ -227,7 +227,7 @@ public static void Test_Relations_Enumerator() public static void Test_Relations_EntityReadOnlyCollection() { var store = new EntityStore(); - var entities = store.EntityRelation().Entities; + var entities = store.EntityRelations().Entities; var entity1 = store.CreateEntity(1); var entity2 = store.CreateEntity(2); diff --git a/src/Tests/ECS/Relations/Test_Relations_Delete.cs b/src/Tests/ECS/Relations/Test_Relations_Delete.cs index 90582417..d3f571bb 100644 --- a/src/Tests/ECS/Relations/Test_Relations_Delete.cs +++ b/src/Tests/ECS/Relations/Test_Relations_Delete.cs @@ -12,7 +12,7 @@ public static class Test_Relations_Delete public static void Test_Relations_Delete_int_relations() { var store = new EntityStore(); - var intRelations = store.EntityRelation(); + var intRelations = store.EntityRelations(); var allEntities = intRelations.Entities; AreEqual("{ }", allEntities.Debug()); @@ -55,7 +55,7 @@ public static void Test_Relations_Delete_int_relations() public static void Test_Relations_Delete_Entity_relations() { var store = new EntityStore(); - var attackRelations = store.EntityRelation(); + var attackRelations = store.EntityRelations(); var sourceNodes = attackRelations.Entities; AreEqual("{ }", sourceNodes.Debug()); diff --git a/src/Tests/ECS/Relations/Test_Relations_Query.cs b/src/Tests/ECS/Relations/Test_Relations_Query.cs index 730a02d5..b221795e 100644 --- a/src/Tests/ECS/Relations/Test_Relations_Query.cs +++ b/src/Tests/ECS/Relations/Test_Relations_Query.cs @@ -197,7 +197,7 @@ public static void Test_Relations_ForAllEntityRelations_Perf() int count = 0; var sw = new Stopwatch(); sw.Start(); - store.EntityRelation().For((ref IntRelation relation, Entity entity) => { + store.EntityRelations().For((ref IntRelation relation, Entity entity) => { count++; }); AreEqual(entityCount * relationsPerEntity, count); @@ -222,7 +222,7 @@ public static void Test_Relations_GetAllEntityRelations_Perf() int count = 0; var sw = new Stopwatch(); sw.Start(); - var (entities, relations) = store.EntityRelation().Pairs; + var (entities, relations) = store.EntityRelations().Pairs; int length = entities.Count; for (int n = 0; n < length; n++) { count++;