Skip to content

Commit

Permalink
Engine - ECS: add TreeNode docs
Browse files Browse the repository at this point in the history
  • Loading branch information
friflo committed Jul 21, 2024
1 parent fa97d9f commit f11f449
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Engine/src/ECS/Collections/IdArray/IdArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private string GetString()

internal static class IdArrayExtensions {

internal static ReadOnlySpan<int> GetSpan(this ref IdArray array, IdArrayHeap heap, EntityStoreBase store)
internal static ReadOnlySpan<int> GetSpan(this IdArray array, IdArrayHeap heap, EntityStoreBase store)
{
int count = array.count;
int start = array.start;
Expand Down
12 changes: 10 additions & 2 deletions Engine/src/ECS/Components/TreeNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public struct TreeNode : IComponent
/// <summary> returns the number of <see cref="Entity.ChildEntities"/>.</summary>
public int ChildCount => childIds.count;

/// <summary> Property is obsolete. Use <see cref="GetChildIds"/> instead. </summary>
/// <summary>Property is obsolete. Use <see cref="GetChildIds"/> instead. </summary>
[Obsolete($"Use {nameof(GetChildIds)}()")]
public ReadOnlySpan<int> ChildIds => throw new InvalidOperationException($"ChildIds is obsolete. Use {nameof(GetChildIds)}()");

Expand All @@ -38,9 +38,17 @@ public struct TreeNode : IComponent
internal IdArray childIds; // 8
#endregion

/// <summary>
/// Returns the child entities.<br/>
/// Executes in O(1).
/// </summary>
public ChildEntities GetChildEntities(EntityStore store) => new ChildEntities(store, this);

/// same as <see cref="IdArrayExtensions.GetSpan"/>
// same as <see cref="IdArrayExtensions.GetSpan"/>
/// <summary>
/// Returns the child entity ids.<br/>
/// Executes in O(1).
/// </summary>
public ReadOnlySpan<int> GetChildIds(EntityStore store)
{
var count = childIds.count;
Expand Down
4 changes: 2 additions & 2 deletions Engine/src/ECS/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ public bool RemoveTags(in Tags tags) {
/// See <a href="https://github.com/friflo/Friflo.Json.Fliox/wiki/Examples-~-General#child-entities">Example.</a>
/// </summary>
/// <remarks>
/// Executes in O(1).<br/>
/// Executes in O(1) in case the child has no parent.<br/>
/// The subtree structure of the added entity remains unchanged<br/>
/// </remarks>
/// <returns>
Expand All @@ -483,7 +483,7 @@ public int AddChild(Entity child) {
}
/// <summary>Insert the given <paramref name="child"/> as a child to the entity at the passed <paramref name="index"/>.</summary>
/// <remarks>
/// Executes in O(1) in case <paramref name="index"/> == <see cref="ChildCount"/>.<br/>
/// Executes in O(1) in case the child has no paren and <paramref name="index"/> == <see cref="ChildCount"/>.<br/>
/// Otherwise, O(N). N = <see cref="ChildCount"/> - <paramref name="index"/><br/>
/// The subtree structure of the added entity remains unchanged<br/>
/// </remarks>
Expand Down

0 comments on commit f11f449

Please sign in to comment.