Skip to content

Commit

Permalink
rename: EntityRelation<> -> EntityRelations<>
Browse files Browse the repository at this point in the history
  • Loading branch information
friflo committed Dec 1, 2024
1 parent fda08ca commit 81f5a52
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
// ReSharper disable once CheckNamespace
namespace Friflo.Engine.ECS;

public readonly struct EntityRelation <TRelation>
public readonly struct EntityRelations <TRelation>
where TRelation : struct, IRelation
{
private readonly AbstractEntityRelations relations;

internal EntityRelation(AbstractEntityRelations relations) {
internal EntityRelations(AbstractEntityRelations relations) {
this.relations = relations;
}

Expand All @@ -23,7 +23,7 @@ internal EntityRelation(AbstractEntityRelations relations) {
/// </item>
/// <item>
/// To get all entities including their relations (the cartesian product aka CROSS JOIN) use<br/>
/// <see cref="EntityRelation{TRelation}.Pairs"/>
/// <see cref="EntityRelations{TRelation}.Pairs"/>
/// </item>
/// </list>
/// </remarks>
Expand Down
18 changes: 9 additions & 9 deletions src/ECS/Relations/RelationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@ public static EntityLinks<TRelation> GetIncomingLinks<TRelation>(this Entity tar
#endregion

#region EntityStore
public static EntityRelation<TRelation> EntityRelation<TRelation>(this EntityStore store)
public static EntityRelations<TRelation> EntityRelations<TRelation>(this EntityStore store)
where TRelation : struct, IRelation
{
var relations = AbstractEntityRelations.GetEntityRelations(store, StructInfo<TRelation>.Index);
return new EntityRelation<TRelation>(relations);
return new EntityRelations<TRelation>(relations);
}

/// <summary>
/// Obsolete: Use <see cref="EntityRelation{TRelation}.Entities"/><br/>
/// Obsolete: Use <see cref="ECS.EntityRelations{TRelation}.Entities"/><br/>
/// Returns a collection of entities having one or more relations of the specified <typeparamref name="TRelation"/> type.<br/>
/// Executes in O(1).
/// </summary>
Expand All @@ -121,11 +121,11 @@ public static EntityRelation<TRelation> EntityRelation<TRelation>(this EntitySto
/// </item>
/// <item>
/// To get all entities including their relations (the cartesian product aka CROSS JOIN) use<br/>
/// <see cref="EntityRelation{TRelation}.Pairs"/>
/// <see cref="ECS.EntityRelations{TRelation}.Pairs"/>
/// </item>
/// </list>
/// </remarks>
[Obsolete("replace with property: EntityRelation<TRelation>().Entities")]
[Obsolete("replace with property: EntityRelations<TRelation>().Entities")]
public static EntityReadOnlyCollection GetAllEntitiesWithRelations<TRelation>(this EntityStore store)
where TRelation : struct, IRelation
{
Expand All @@ -134,11 +134,11 @@ public static EntityReadOnlyCollection GetAllEntitiesWithRelations<TRelation>(th
}

/// <summary>
/// Obsolete: Use <see cref="EntityRelation{TRelation}.For"/><br/>
/// Obsolete: Use <see cref="ECS.EntityRelations{TRelation}.For"/><br/>
/// Iterates all entity relations of the specified <typeparamref name="TRelation"/> type.<br/>
/// Executes in O(N) N: number of all entity relations.
/// </summary>
[Obsolete("replace with method: EntityRelation<TRelation>().For()")]
[Obsolete("replace with method: EntityRelations<TRelation>().For()")]
public static void ForAllEntityRelations<TRelation>(this EntityStore store, ForEachEntity<TRelation> lambda)
where TRelation : struct, IRelation
{
Expand All @@ -147,11 +147,11 @@ public static void ForAllEntityRelations<TRelation>(this EntityStore store, ForE
}

/// <summary>
/// Obsolete: Use <see cref="EntityRelation{TRelation}.Pairs"/><br/>
/// Obsolete: Use <see cref="ECS.EntityRelations{TRelation}.Pairs"/><br/>
/// Return all entity relations of the specified <typeparamref name="TRelation"/> type.<br/>
/// Executes in O(1). Most efficient way to iterate all entity relations.
/// </summary>
[Obsolete("replace with property: EntityRelation<TRelation>().Pairs")]
[Obsolete("replace with property: EntityRelations<TRelation>().Pairs")]
public static (Entities entities, Chunk<TRelation> relations) GetAllEntityRelations<TRelation>(this EntityStore store)
where TRelation : struct, IRelation
{
Expand Down
2 changes: 1 addition & 1 deletion src/Tests/ECS/Relations/Test_Relations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public static void Test_Relations_Enumerator()
public static void Test_Relations_EntityReadOnlyCollection()
{
var store = new EntityStore();
var entities = store.EntityRelation<IntRelation>().Entities;
var entities = store.EntityRelations<IntRelation>().Entities;

var entity1 = store.CreateEntity(1);
var entity2 = store.CreateEntity(2);
Expand Down
4 changes: 2 additions & 2 deletions src/Tests/ECS/Relations/Test_Relations_Delete.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<IntRelation>();
var intRelations = store.EntityRelations<IntRelation>();
var allEntities = intRelations.Entities;
AreEqual("{ }", allEntities.Debug());

Expand Down Expand Up @@ -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<AttackRelation>();
var attackRelations = store.EntityRelations<AttackRelation>();
var sourceNodes = attackRelations.Entities;
AreEqual("{ }", sourceNodes.Debug());

Expand Down
4 changes: 2 additions & 2 deletions src/Tests/ECS/Relations/Test_Relations_Query.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public static void Test_Relations_ForAllEntityRelations_Perf()
int count = 0;
var sw = new Stopwatch();
sw.Start();
store.EntityRelation<IntRelation>().For((ref IntRelation relation, Entity entity) => {
store.EntityRelations<IntRelation>().For((ref IntRelation relation, Entity entity) => {
count++;
});
AreEqual(entityCount * relationsPerEntity, count);
Expand All @@ -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<IntRelation>().Pairs;
var (entities, relations) = store.EntityRelations<IntRelation>().Pairs;
int length = entities.Count;
for (int n = 0; n < length; n++) {
count++;
Expand Down

0 comments on commit 81f5a52

Please sign in to comment.