Game.Prefabs.DistrictData
Assembly: Game
Namespace: Game.Prefabs
Type: struct
Base: System.ValueType, Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter, Colossal.Serialization.Entities.IEmptySerializable
Summary:
DistrictData is an empty (marker) component type used by the game's ECS to mark or identify entities that represent district-related data. It is laid out with a fixed size of 1 byte via StructLayout to ensure a non-zero size for serialization and interoperability with the game's custom serializer (IEmptySerializable). Being an IComponentData makes it usable in ECS queries; implementing IQueryTypeParameter allows it to be used in query expressions or as a query parameter type.
Fields
- This struct declares no instance fields.
The StructLayout attribute (LayoutKind.Sequential, Size = 1) forces a one-byte size for the type, which is important for serialization and storage even though the component carries no payload.
Properties
- This type does not expose any properties. It functions purely as a tag/marker component.
Constructors
public DistrictData()
(implicit default)
As a value type, DistrictData has the implicit parameterless constructor. No custom initialization is required or provided.
Methods
- This type declares no methods. Behavior is provided by systems that query for this component presence.
Usage Example
using Unity.Entities;
using Game.Prefabs;
public partial class DistrictTaggingSystem : SystemBase
{
protected override void OnCreate()
{
base.OnCreate();
// Example: create an entity and tag it as a district-related entity
var entity = EntityManager.CreateEntity();
EntityManager.AddComponentData(entity, new DistrictData());
}
protected override void OnUpdate()
{
// Example: process all entities tagged with DistrictData
Entities
.WithAll<DistrictData>()
.ForEach((Entity e) =>
{
// Do district-related processing for entity e
})
.Schedule();
}
}
Notes: - Use this component when you need a lightweight way to mark or filter entities related to districts without storing additional payload. - The IEmptySerializable interface and fixed size ensure compatibility with the game's serialization pipeline.