-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add LinkComponentIndex<> - made IndexExtensions.GetAllLinkedEntities(…
…) obsolete
- Loading branch information
Showing
5 changed files
with
59 additions
and
24 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System.Collections.Generic; | ||
using Friflo.Engine.ECS.Index; | ||
|
||
// ReSharper disable once CheckNamespace | ||
namespace Friflo.Engine.ECS; | ||
|
||
public readonly struct LinkComponentIndex <TLinkComponent> | ||
where TLinkComponent: struct, ILinkComponent | ||
{ | ||
private readonly AbstractComponentIndex<Entity> index; | ||
|
||
internal LinkComponentIndex(AbstractComponentIndex<Entity> index) { | ||
this.index = index; | ||
} | ||
|
||
/// <summary> | ||
/// Return the entities having a link component with the passed component value.<br/> | ||
/// Executes in O(1) with default index. | ||
/// </summary> | ||
public Entities this[Entity value] => index.GetHasValueEntities(value); | ||
|
||
/// <summary> | ||
/// Returns all indexed link component values of the passed<see cref="Entity"/> type.<br/> | ||
/// Executes in O(1). Each value in the returned list is unique. See remarks for additional infos. | ||
/// </summary> | ||
/// <remarks> | ||
/// <list type="bullet"> | ||
/// <item> | ||
/// The returned collection changes when indexed component values are updated, removed or added. | ||
/// </item> | ||
/// <item> | ||
/// To get the entities having a specific component value use <see cref="this[Entity]"/>. | ||
/// </item> | ||
/// </list> | ||
/// </remarks> | ||
public IReadOnlyCollection<Entity> Values => index.IndexedComponentValues; | ||
|
||
public override string ToString() => $"Count: {Values.Count}"; | ||
} |
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