-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- replaced RelationExtensions.GetAllEntitiesWithRelations() -> EntityRelations<TRelation>().Entities - replaced RelationExtensions.ForAllEntityRelations() -> EntityRelations<TRelation>().For()
- Loading branch information
Showing
5 changed files
with
54 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using Friflo.Engine.ECS.Relations; | ||
|
||
// ReSharper disable once CheckNamespace | ||
namespace Friflo.Engine.ECS; | ||
|
||
public readonly struct EntityRelations <TRelation> | ||
where TRelation : struct, IRelation | ||
{ | ||
private readonly AbstractEntityRelations relations; | ||
|
||
internal EntityRelations(AbstractEntityRelations relations) { | ||
this.relations = relations; | ||
} | ||
|
||
/// <summary> | ||
/// Returns a collection of entities having one or more relations of the specified <typeparamref name="TRelation"/> type.<br/> | ||
/// Executes in O(1). | ||
/// </summary> | ||
/// <remarks> | ||
/// <list type="bullet"> | ||
/// <item> | ||
/// The returned collection changes when relations are updated, removed or added. | ||
/// </item> | ||
/// <item> | ||
/// To get all entities including their relations (the cartesian product aka CROSS JOIN) use<br/> | ||
/// <see cref="RelationExtensions.GetAllEntityRelations{TRelation}"/> | ||
/// </item> | ||
/// </list> | ||
/// </remarks> | ||
public EntityReadOnlyCollection Entities => new EntityReadOnlyCollection(relations.store, relations.positionMap.Keys); | ||
|
||
/// <summary> | ||
/// Iterates all entity relations of the specified <typeparamref name="TRelation"/> type.<br/> | ||
/// Executes in O(N) N: number of all entity relations. | ||
/// </summary> | ||
public void For(ForEachEntity<TRelation> lambda) => relations.ForAllEntityRelations(lambda); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters