Skip to content

Game.Buildings.Transformer

Assembly:
Assembly-CSharp

Namespace:
Game.Buildings

Type:
struct

Base:
Implements: Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter, Colossal.Serialization.Entities.IEmptySerializable

Summary:
Transformer is an empty/tag ECS component used to mark entities that represent transformer buildings in the game's entity-component system. The struct is laid out with a fixed size via [StructLayout(LayoutKind.Sequential, Size = 1)] so it has a non-zero footprint for native/serialization systems. Implementing IEmptySerializable means the presence of this component can be preserved by the game's custom serialization (Colossal.Serialization) even though it carries no payload. Implementing IQueryTypeParameter makes it usable in ECS query type parameters (e.g., to select/filter transformer entities).


Fields

  • None. This is an empty/tag component; it contains no managed fields or stored data.

Notes: - The [StructLayout(LayoutKind.Sequential, Size = 1)] attribute gives the empty struct a size of 1 byte, which avoids issues with zero-sized types in native code/serialization. - Because there are no fields, state is represented solely by the presence or absence of this component on an Entity.

Properties

  • None.

Notes: - As a pure marker component there are no runtime properties to read or set beyond adding/removing the component on an entity.

Constructors

  • Implicit default constructor (provided by the C# language/runtime)

Notes: - There is no user-defined constructor. The default value is used when adding the component to an entity (e.g., new Transformer() or simply AddComponent).

Methods

  • None.

Notes: - The type exposes no methods. Behavior is implemented by systems that query for Entities that have the Transformer component.

Usage Example

using Unity.Entities;
using Game.Buildings;

public partial class TransformerExampleSystem : SystemBase
{
    protected override void OnCreate()
    {
        base.OnCreate();

        // Example: create an entity and add Transformer as a tag component
        var em = World.DefaultGameObjectInjectionWorld.EntityManager;
        Entity e = em.CreateEntity();
        em.AddComponent<Transformer>(e); // or: em.AddComponentData(e, new Transformer());
    }

    protected override void OnUpdate()
    {
        // Query and process entities that are marked as transformers
        Entities
            .WithAll<Transformer>()
            .ForEach((Entity entity) =>
            {
                // Do transformer-specific processing here
            })
            .WithoutBurst() // adjust scheduling as needed
            .Run();
    }
}

Additional notes: - To test whether an entity is a transformer: EntityManager.HasComponent(entity). - To remove the tag: EntityManager.RemoveComponent(entity). - Because Transformer implements IEmptySerializable, the presence of the component can be included in save/load operations handled by the game's serialization system; it will not carry payload data, only presence information.