Skip to content

Game.Simulation.BatteryDischargeNode

Assembly:
Namespace: Game.Simulation

Type: struct

Base: IComponentData, IQueryTypeParameter, IEmptySerializable

Summary:
BatteryDischargeNode is an empty marker component used by the game's ECS to mark entities that participate in battery discharge logic. It has no instance data and exists purely as a tag/query parameter. The struct is decorated with StructLayout(LayoutKind.Sequential, Size = 1) so it has a stable non-zero size for native/serialization systems and is compatible with Colossal's serialization via IEmptySerializable. Being an IQueryTypeParameter makes it convenient to use in entity queries (e.g., WithAll).


Fields

  • This struct defines no instance fields.
    BatteryDischargeNode is intentionally empty (marker/tag component). The StructLayout attribute forces the size to 1 byte to avoid zero-sized-type corner cases in native containers and serialization.

Properties

  • This struct exposes no properties.
    It is intended only as a component tag and does not carry state.

Constructors

  • public BatteryDischargeNode()
    Value types get a default parameterless constructor provided by the runtime. No initialization is required or performed.

Methods

  • This struct implements no methods.
    Behavior associated with this tag is implemented in systems that query for the presence of BatteryDischargeNode on entities.

Usage Example

// Add the tag to an entity
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
entityManager.AddComponentData(entity, new BatteryDischargeNode());

// Query in a SystemBase to process all entities tagged for battery discharge
protected override void OnUpdate()
{
    Entities
        .WithAll<BatteryDischargeNode>()
        .ForEach((ref BatteryComponent battery, in Entity entity) =>
        {
            // discharge logic here, e.g. reduce battery charge and handle state changes
            // battery.charge -= dischargeAmount;
        })
        .ScheduleParallel();
}

Additional notes: - The [StructLayout(LayoutKind.Sequential, Size = 1)] attribute ensures the component occupies a stable size for interop/serialization and avoids complications with zero-sized types in native arrays or serialization systems. - IEmptySerializable indicates compatibility with the project's serialization (Colossal serialization). The component remains suitable for saving/loading as an empty marker.