Implement core entity management features
Added `Archetype` struct with chunk management and disposal. Added `BitSet` class for managing collections of bits. Added `Class1.cs` as a placeholder for graphics functionality. Added `ComponentData` struct and `ComponentPool` class for component management. Added `ComponentRegistry` for efficient component registration. Added `EntityChangeQueue` as a placeholder for future changes. Added `Helpers.ttinclude` and `QueryRefComponent.tt` for code generation. Added `Signature` struct for managing component signatures. Added `World` struct to manage the game world and entities. Added `QueryRefComponent` delegates for querying entities. Changed `Archetype.cs` to implement `IDisposable`. Changed `AssemblyInfo.cs` to update global using directives. Changed `Chunk.cs` to introduce `ChunkCollection` for chunk management. Changed `Component.cs` to refine component management methods. Changed `Entity.cs` to improve properties and methods. Changed `Ghost.Entities.csproj` to update project properties. Changed `Program.cs` to demonstrate entity creation and querying. Changed `World.Query.cs` to facilitate querying with components.
This commit is contained in:
48
Ghost.Entities/Template/World.Query.tt
Normal file
48
Ghost.Entities/Template/World.Query.tt
Normal file
@@ -0,0 +1,48 @@
|
||||
<#@ template language="C#" #>
|
||||
<#@ output extension=".cs" #>
|
||||
<#@ import namespace="System.Text" #>
|
||||
<#@ include file="Helpers.ttinclude" #>
|
||||
|
||||
namespace Ghost.Entities;
|
||||
|
||||
public partial struct World
|
||||
{
|
||||
<#
|
||||
for (var index = 1; index <= Amount; index++)
|
||||
{
|
||||
var generics = AppendGenerics(index);
|
||||
var restrictions = AppendGenericRestrictions(index, "struct, IComponent");
|
||||
var getPools = TryGetComponentPools(index);
|
||||
var hasEntity = HasEntity(index);
|
||||
#>
|
||||
public readonly void Query<<#= generics #>>(QueryRefComponent<<#= generics #>> callback)
|
||||
<#= restrictions.ToString() #>
|
||||
{
|
||||
if (!(<#=getPools.ToString()#>))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < pool0.Count; i++)
|
||||
{
|
||||
var entity = _entities[i];
|
||||
<#
|
||||
if (index > 1)
|
||||
{
|
||||
#>
|
||||
if (!(<#=hasEntity.ToString()#>))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
<#
|
||||
}
|
||||
#>
|
||||
callback(entity, <#= GetComponentRef(index).ToString() #>);
|
||||
}
|
||||
}
|
||||
|
||||
<#
|
||||
}
|
||||
#>
|
||||
}
|
||||
Reference in New Issue
Block a user