Skip to content

Commit

Permalink
Fixed #11
Browse files Browse the repository at this point in the history
  • Loading branch information
genaray committed Nov 20, 2022
1 parent b1f4dfb commit e47d24e
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 23 deletions.
28 changes: 14 additions & 14 deletions Arch.Benchmark/Arch.Benchmark.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,29 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Arch\Arch.csproj"/>
<ProjectReference Include="..\Arch\Arch.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.1"/>
<PackageReference Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.13.1"/>
<PackageReference Include="Microsoft.Extensions.ObjectPool" Version="7.0.0"/>
<PackageReference Include="ZeroAllocJobScheduler" Version="1.0.2"/>
<PackageReference Include="BenchmarkDotNet" Version="0.13.2" />
<PackageReference Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.13.1" />
<PackageReference Include="Microsoft.Extensions.ObjectPool" Version="7.0.0" />
<PackageReference Include="ZeroAllocJobScheduler" Version="1.0.2" />
</ItemGroup>

<ItemGroup>
<Content Include="obj\Arch.Benchmark.csproj.nuget.dgspec.json"/>
<Content Include="obj\project.assets.json"/>
<Content Include="obj\project.nuget.cache"/>
<Content Include="obj\project.packagespec.json"/>
<Content Include="obj\Release\net7.0\Arch.Benchmark.AssemblyInfoInputs.cache"/>
<Content Include="obj\Release\net7.0\Arch.Benchmark.assets.cache"/>
<Content Include="obj\Release\net7.0\Arch.Benchmark.csproj.AssemblyReference.cache"/>
<Content Include="obj\rider.project.restore.info"/>
<Content Include="obj\Arch.Benchmark.csproj.nuget.dgspec.json" />
<Content Include="obj\project.assets.json" />
<Content Include="obj\project.nuget.cache" />
<Content Include="obj\project.packagespec.json" />
<Content Include="obj\Release\net7.0\Arch.Benchmark.AssemblyInfoInputs.cache" />
<Content Include="obj\Release\net7.0\Arch.Benchmark.assets.cache" />
<Content Include="obj\Release\net7.0\Arch.Benchmark.csproj.AssemblyReference.cache" />
<Content Include="obj\rider.project.restore.info" />
</ItemGroup>

<ItemGroup>
<Compile Include="obj\Release\net7.0\.NETCoreApp,Version=v7.0.AssemblyAttributes.cs"/>
<Compile Include="obj\Release\net7.0\.NETCoreApp,Version=v7.0.AssemblyAttributes.cs" />
</ItemGroup>

</Project>
23 changes: 23 additions & 0 deletions Arch.Test/WorldTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,27 @@ public void MultipleArchetypesTest()

Assert.AreEqual(entity1.GetArchetype(), entity2.GetArchetype());
}

[Test]
public void GetEntitesTest()
{
var world = World.Create();

var archTypes = new[] { typeof(Transform) };
var query = new QueryDescription { All = archTypes };

var entity = world.Create(archTypes);

var entites = new List<Entity>();
world.GetEntities(query, entites);

Assert.That(entites.Count, Is.EqualTo(1));

entites.Clear();
world.Destroy(entity);
world.GetEntities(query, entites);

Assert.That(entites.Count, Is.EqualTo(0));
World.Destroy(world);
}
}
4 changes: 2 additions & 2 deletions Arch/Arch.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

<PackageId>Arch</PackageId>
<Title>Arch</Title>
<Version>1.0.11</Version>
<Version>1.0.12</Version>
<Authors>genaray</Authors>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<Description>A high performance c# net.6 and net.7 archetype based ECS ( Entity component system ).</Description>
<PackageReleaseNotes>
Fixed a bug where multiple same structured archetypes and querydescriptions could exist next to each other.
Fixed a bug where queries would produce a null reference exception if there no target entities for it.
</PackageReleaseNotes>
<PackageTags>c#;.net;.net6;.net7;ecs;game;entity;gamedev; game-development; game-engine; entity-component-system;</PackageTags>

Expand Down
2 changes: 1 addition & 1 deletion Arch/Core/Enumerators.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public bool MoveNext()
while (++_index < _size)
{
ref var archetype = ref Current;
if (_query.Valid(archetype.BitSet))
if (archetype.Size > 0 && _query.Valid(archetype.BitSet))
return true;
}

Expand Down
6 changes: 0 additions & 6 deletions Arch/Core/World.cs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@ public Query Query(in QueryDescription queryDescription)
public void GetEntities(in QueryDescription queryDescription, IList<Entity> list)
{
var query = Query(in queryDescription);

foreach (ref var chunk in query.GetChunkIterator())
{
var chunkSize = chunk.Size;
Expand Down Expand Up @@ -380,7 +379,6 @@ public partial class World
public void Query(in QueryDescription queryDescription, ForEach forEntity)
{
var query = Query(in queryDescription);

foreach (ref var chunk in query.GetChunkIterator())
{
var chunkSize = chunk.Size;
Expand All @@ -404,7 +402,6 @@ public void Query<T>(in QueryDescription queryDescription) where T : struct, IFo
var t = new T();

var query = Query(in queryDescription);

foreach (ref var chunk in query.GetChunkIterator())
{
var chunkSize = chunk.Size;
Expand All @@ -427,7 +424,6 @@ public void Query<T>(in QueryDescription queryDescription) where T : struct, IFo
public void Query<T>(in QueryDescription queryDescription, ref T iForEach) where T : struct, IForEach
{
var query = Query(in queryDescription);

foreach (ref var chunk in query.GetChunkIterator())
{
var chunkSize = chunk.Size;
Expand Down Expand Up @@ -470,7 +466,6 @@ public partial class World
public T GetJob<T>() where T : class, new()
{
var type = typeof(T);

if (!JobPools.TryGetValue(type, out var obj))
{
obj = new DefaultObjectPool<T>(new DefaultObjectPolicy<T>());
Expand Down Expand Up @@ -501,7 +496,6 @@ public void ReturnJob<T>(T instance) where T : class
public List<T> GetListCache<T>() where T : class, new()
{
var type = typeof(T);

if (!ParallelJobsListCache.TryGetValue(type, out var obj))
{
obj = new List<T>(64);
Expand Down

0 comments on commit e47d24e

Please sign in to comment.