Skip to content

Commit

Permalink
better count
Browse files Browse the repository at this point in the history
  • Loading branch information
metalgearsloth committed Sep 2, 2024
1 parent 13e860e commit 89731b4
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions Robust.Shared/GameObjects/EntityManager.Components.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,13 @@ private void RegisterComponents(IEnumerable<ComponentRegistration> components)
/// <inheritdoc />
public int Count<T>() where T : IComponent
{
return _world.CountEntities(new QueryDescription().WithAll<T>());
return _entTraitArray[CompIdx.ArrayIndex<T>()].Count;
}

/// <inheritdoc />
public int Count(Type component)
{
var query = new QueryDescription([component]);
return _world.CountEntities(in query);
return _entTraitArray[_componentFactory.GetArrayIndex(component)].Count;
}

[Obsolete("Use InitializeEntity")]
Expand Down

0 comments on commit 89731b4

Please sign in to comment.