Game.Net.ElectricityConnection
Assembly: Assembly-CSharp
Namespace: Game.Net
Type: struct
Base: System.ValueType
Implements: Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter, Colossal.Serialization.Entities.IEmptySerializable
Summary: ElectricityConnection is an empty/marker ECS component used to tag entities that participate in the game's electricity network. The struct is intentionally empty and marked with a fixed size via StructLayout (Size = 1) so it can be serialized and stored as a non-zero sized component by the game's serialization and ECS systems. Mods can use it to mark, query, or filter entities that have an electricity connection.
Fields
This struct declares no instance fields. It is an intentionally empty marker component.
The attribute [StructLayout(LayoutKind.Sequential, Size = 1)] forces the compiled size to 1 byte so the component has a non-zero layout for serialization and interop.
Properties
This type defines no properties. It only serves as a tag component for queries and serialization.
Constructors
public ElectricityConnection()
This type has no explicit constructors in source; it uses the default value-initialized struct semantics. You can create or apply it using default(ElectricityConnection) or new ElectricityConnection() when adding it to an entity.
Methods
There are no methods defined on this struct. Behavior and serialization are provided by the implemented interfaces and the game's ECS/serialization systems (IComponentData, IQueryTypeParameter, IEmptySerializable).
Usage Example
// Add the marker to an entity using the EntityManager
if (!EntityManager.HasComponent<ElectricityConnection>(entity))
{
EntityManager.AddComponentData(entity, new ElectricityConnection());
}
// Remove the marker when an entity loses its electricity connection
if (EntityManager.HasComponent<ElectricityConnection>(entity))
{
EntityManager.RemoveComponent<ElectricityConnection>(entity);
}
// Querying for entities that have an electricity connection inside a SystemBase
public partial class PowerProcessingSystem : SystemBase
{
protected override void OnUpdate()
{
// Process all entities tagged with ElectricityConnection
Entities
.WithAll<ElectricityConnection>()
.ForEach((Entity e) =>
{
// handle powered entity...
})
.Schedule();
}
}
Additional notes: - Because this is an empty marker component, use HasComponent/WithAll to check/filter entities rather than relying on component data values. - The IEmptySerializable implementation allows the game/mod framework to include this marker in savegame serialization without custom serializer code.