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:
118
Ghost.Entities/Template/Helpers.ttinclude
Normal file
118
Ghost.Entities/Template/Helpers.ttinclude
Normal file
@@ -0,0 +1,118 @@
|
||||
<#@ import namespace="System.Text" #>
|
||||
<#@ import namespace="System.Collections.Generic" #>
|
||||
<#+
|
||||
|
||||
public int Amount = 25;
|
||||
|
||||
|
||||
public string Indent(StringBuilder sb, int spaces)
|
||||
{
|
||||
var indent = new string(' ', spaces);
|
||||
return sb.ToString().Replace("\n", "\n" + indent);
|
||||
}
|
||||
|
||||
string AppendGenerics(int amount)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
for (var i = 0; i < amount; i++)
|
||||
{
|
||||
if (i > 0) sb.Append(", ");
|
||||
sb.Append($"T{i}");
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public StringBuilder AppendGenericRefParameters(int amount)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
for (var localIndex = 0; localIndex < amount; localIndex++)
|
||||
{
|
||||
sb.Append($"ref T{localIndex} t{localIndex}Component,");
|
||||
}
|
||||
|
||||
sb.Length--;
|
||||
return sb;
|
||||
}
|
||||
|
||||
public StringBuilder AppendRefParameters(int amount)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
for (var localIndex = 0; localIndex < amount; localIndex++)
|
||||
{
|
||||
sb.Append($"ref component{localIndex},");
|
||||
}
|
||||
|
||||
sb.Length--;
|
||||
return sb;
|
||||
}
|
||||
|
||||
public StringBuilder AppendGenericRestrictions(int amount, string template)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
for (var localIndex = 0; localIndex < amount; localIndex++)
|
||||
{
|
||||
sb.Append($"where T{localIndex} : {template}");
|
||||
if (localIndex < amount - 1)
|
||||
{
|
||||
sb.Append(' ');
|
||||
}
|
||||
}
|
||||
return sb;
|
||||
}
|
||||
|
||||
public StringBuilder TryGetComponentPools(int amount)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
for (var localIndex = 0; localIndex < amount; localIndex++)
|
||||
{
|
||||
sb.Append($"TryGetPool<T{localIndex}>(out var pool{localIndex})");
|
||||
if (localIndex < amount - 1)
|
||||
{
|
||||
sb.Append(" && ");
|
||||
}
|
||||
}
|
||||
return sb;
|
||||
}
|
||||
|
||||
public StringBuilder HasEntity(int amount)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
for (var localIndex = 1; localIndex < amount; localIndex++)
|
||||
{
|
||||
sb.Append($"pool{localIndex}.Has(entity)");
|
||||
if (localIndex < amount - 1)
|
||||
{
|
||||
sb.Append(" && ");
|
||||
}
|
||||
}
|
||||
return sb;
|
||||
}
|
||||
|
||||
public StringBuilder GetComponent(int amount)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
for (var localIndex = 0; localIndex < amount; localIndex++)
|
||||
{
|
||||
sb.Append($"pool{localIndex}.GetRef(entity)");
|
||||
if (localIndex < amount - 1)
|
||||
{
|
||||
sb.Append(", ");
|
||||
}
|
||||
}
|
||||
return sb;
|
||||
}
|
||||
|
||||
public StringBuilder GetComponentRef(int amount)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
for (var localIndex = 0; localIndex < amount; localIndex++)
|
||||
{
|
||||
sb.Append($"ref pool{localIndex}.GetRef(entity)");
|
||||
if (localIndex < amount - 1)
|
||||
{
|
||||
sb.Append(", ");
|
||||
}
|
||||
}
|
||||
return sb;
|
||||
}
|
||||
#>
|
||||
Reference in New Issue
Block a user