forked from Misaki/GhostEngine
Per-component versioning and change tracking for ECS
Introduce per-component versioning in chunks and world for efficient change detection. - Add version arrays to chunks and global version to world. - Update queries and ForEach to mark written components as changed. - Extend QueryBuilder with WithAllRW/WithPresentRW for write access. - Expose change tracking API in ChunkView. - Improve thread safety and debug code. - Update tests and examples to demonstrate new features.
This commit is contained in:
@@ -18,6 +18,20 @@ public ref partial struct QueryBuilder
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified component type(s) to the 'All' filter of the query and requires read-write access.
|
||||
/// Targets entities that have all of the specified component types and those component(s) must be enabled.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public QueryBuilder WithAllRW<T0>()
|
||||
where T0 : unmanaged, IComponent
|
||||
{
|
||||
_all.Add(ComponentTypeID<T0>.value);
|
||||
_rw.Add(ComponentTypeID<T0>.value);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified component type(s) to the 'Any' filter of the query.
|
||||
/// Targets entities that have at least one of the specified component types and those component(s) must be enabled.
|
||||
@@ -83,6 +97,20 @@ public ref partial struct QueryBuilder
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified component type(s) to the 'Present' filter of the query and requires read-write access.
|
||||
/// Targets entities that have all of the specified component types, regardless of whether those component(s) are enabled or disabled.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public QueryBuilder WithPresentRW<T0>()
|
||||
where T0 : unmanaged, IComponent
|
||||
{
|
||||
_present.Add(ComponentTypeID<T0>.value);
|
||||
_rw.Add(ComponentTypeID<T0>.value);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified component type(s) to the 'All' filter of the query.
|
||||
/// Targets entities that have all of the specified component types and those component(s) must be enabled.
|
||||
@@ -98,6 +126,23 @@ public ref partial struct QueryBuilder
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified component type(s) to the 'All' filter of the query and requires read-write access.
|
||||
/// Targets entities that have all of the specified component types and those component(s) must be enabled.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public QueryBuilder WithAllRW<T0, T1>()
|
||||
where T0 : unmanaged, IComponent
|
||||
where T1 : unmanaged, IComponent
|
||||
{
|
||||
_all.Add(ComponentTypeID<T0>.value);
|
||||
_rw.Add(ComponentTypeID<T0>.value);
|
||||
_all.Add(ComponentTypeID<T1>.value);
|
||||
_rw.Add(ComponentTypeID<T1>.value);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified component type(s) to the 'Any' filter of the query.
|
||||
/// Targets entities that have at least one of the specified component types and those component(s) must be enabled.
|
||||
@@ -173,6 +218,23 @@ public ref partial struct QueryBuilder
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified component type(s) to the 'Present' filter of the query and requires read-write access.
|
||||
/// Targets entities that have all of the specified component types, regardless of whether those component(s) are enabled or disabled.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public QueryBuilder WithPresentRW<T0, T1>()
|
||||
where T0 : unmanaged, IComponent
|
||||
where T1 : unmanaged, IComponent
|
||||
{
|
||||
_present.Add(ComponentTypeID<T0>.value);
|
||||
_rw.Add(ComponentTypeID<T0>.value);
|
||||
_present.Add(ComponentTypeID<T1>.value);
|
||||
_rw.Add(ComponentTypeID<T1>.value);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified component type(s) to the 'All' filter of the query.
|
||||
/// Targets entities that have all of the specified component types and those component(s) must be enabled.
|
||||
@@ -190,6 +252,26 @@ public ref partial struct QueryBuilder
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified component type(s) to the 'All' filter of the query and requires read-write access.
|
||||
/// Targets entities that have all of the specified component types and those component(s) must be enabled.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public QueryBuilder WithAllRW<T0, T1, T2>()
|
||||
where T0 : unmanaged, IComponent
|
||||
where T1 : unmanaged, IComponent
|
||||
where T2 : unmanaged, IComponent
|
||||
{
|
||||
_all.Add(ComponentTypeID<T0>.value);
|
||||
_rw.Add(ComponentTypeID<T0>.value);
|
||||
_all.Add(ComponentTypeID<T1>.value);
|
||||
_rw.Add(ComponentTypeID<T1>.value);
|
||||
_all.Add(ComponentTypeID<T2>.value);
|
||||
_rw.Add(ComponentTypeID<T2>.value);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified component type(s) to the 'Any' filter of the query.
|
||||
/// Targets entities that have at least one of the specified component types and those component(s) must be enabled.
|
||||
@@ -275,4 +357,24 @@ public ref partial struct QueryBuilder
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified component type(s) to the 'Present' filter of the query and requires read-write access.
|
||||
/// Targets entities that have all of the specified component types, regardless of whether those component(s) are enabled or disabled.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public QueryBuilder WithPresentRW<T0, T1, T2>()
|
||||
where T0 : unmanaged, IComponent
|
||||
where T1 : unmanaged, IComponent
|
||||
where T2 : unmanaged, IComponent
|
||||
{
|
||||
_present.Add(ComponentTypeID<T0>.value);
|
||||
_rw.Add(ComponentTypeID<T0>.value);
|
||||
_present.Add(ComponentTypeID<T1>.value);
|
||||
_rw.Add(ComponentTypeID<T1>.value);
|
||||
_present.Add(ComponentTypeID<T2>.value);
|
||||
_rw.Add(ComponentTypeID<T2>.value);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user