Game.Events.Destruction
Assembly: Game
Namespace: Game.Events
Type: struct
Base: IComponentData, IQueryTypeParameter, IEmptySerializable
Summary:
Destruction is an empty ECS tag component used to mark entities that are to be destroyed or processed by destruction-related systems. The type is annotated with [StructLayout(LayoutKind.Sequential, Size = 1)] to ensure it has a non-zero size for serialization and interop. Implementing IComponentData makes it usable as an ECS component; IQueryTypeParameter allows it to be used directly in queries; IEmptySerializable indicates it participates in the game's custom serialization pipeline as an empty/marker type.
Fields
- This struct declares no instance fields.
The StructLayout attribute with Size = 1 ensures the type occupies at least one byte in memory/serialization even though it contains no data.
Properties
- This type exposes no properties. It is a pure marker/tag component.
Constructors
- The type uses the implicit parameterless constructor provided by C#. No explicit constructors are declared.
Methods
- The type declares no methods. Behavior is provided by systems that query for this component.
Usage Example
// Mark an entity for destruction using an EntityManager:
EntityManager.AddComponent<Destruction>(entity);
// Or using an EntityCommandBuffer (safe from jobs or deferred changes):
ecb.AddComponent<Destruction>(entity);
// Querying entities that are marked for destruction in a system:
Entities
.WithAll<Destruction>()
.ForEach((Entity e, in SomeOtherData data) =>
{
// perform destruction logic, e.g., enqueue deletion, spawn effects, etc.
}).Schedule(); // or .Run()
// Removing the tag after processing:
EntityManager.RemoveComponent<Destruction>(entity);
// Alternatively, remove and destroy:
if (EntityManager.HasComponent<Destruction>(entity))
{
EntityManager.DestroyEntity(entity);
}
Notes:
- Because Destruction is an empty marker, systems should use queries like WithAll