Game.Objects.ElectricityOutsideConnection
Assembly:
Game (Assembly-CSharp)
Namespace:
Game.Objects
Type:
struct
Base:
Implements: Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter, Colossal.Serialization.Entities.IEmptySerializable
Summary:
A lightweight tag (marker) component used by the game's ECS to mark entities that represent an "electricity outside connection" (i.e., a connection point to external/utility power). The struct is intentionally empty and annotated with StructLayout(Size = 1) so it has a non-zero size for deterministic serialization and interop with the game's custom serializer (IEmptySerializable). As a tag component it carries no data and is used purely for querying and conditional logic in systems.
Fields
This type declares no instance fields. The struct is intentionally empty and used as a tag component.
Properties
This type declares no properties.
Constructors
public ElectricityOutsideConnection()
Default parameterless constructor (implicit for C# structs). Instances are normally created withnew ElectricityOutsideConnection()
when adding the tag component to an entity.
Methods
This type declares no methods.
Additional Notes
- Attribute:
[StructLayout(LayoutKind.Sequential, Size = 1)]
ensures the struct occupies 1 byte. This avoids a 0-sized type which can cause issues in some serialization/interop scenarios and ensures compatibility with the game's Colossal.Serialization system. - Interfaces:
IComponentData
makes this usable as a component in Unity DOTS (ECS).IQueryTypeParameter
allows this type to be used in queries (e.g., WithAll/WithAny).IEmptySerializable
(Colossal.Serialization.Entities) marks it so the custom serializer recognizes it as an empty/marker component and handles it accordingly.- Typical use: as a tag on entities that need to be recognized as external electricity connection points by systems handling power distribution, outside connections, or import/export of utilities.
Usage Example
// Add the tag to an entity (EntityManager example)
var connection = new ElectricityOutsideConnection();
entityManager.AddComponentData(entity, connection);
// Query entities that have the outside electricity connection tag
Entities
.WithAll<ElectricityOutsideConnection>()
.ForEach((Entity e, ref SomeOtherComponent comp) =>
{
// handle entities that are marked as an outside electricity connection
}).ScheduleParallel();