Game.Buildings.BuildingEfficiency
Assembly: Assembly-CSharp
Namespace: Game.Buildings
Type: struct
Base: IComponentData, IQueryTypeParameter, ISerializable
Summary: A marker component used by the game's ECS to represent that a building participates in "efficiency" related systems. The struct contains no runtime data and implements the ISerializable interface with a minimal serialization footprint (a single byte), allowing it to be saved/loaded by Colossal's serialization system. The StructLayout attribute forces the native size to 1 byte so the type is not zero-sized in native layouts.
Fields
None
This struct declares no instance fields. The layout attribute [StructLayout(LayoutKind.Sequential, Size = 1)] ensures a native size of 1 byte despite the lack of fields.
{{ The component is effectively a marker/tag component. The fixed size is intentional for stable native memory layout and compatibility with serialization and job systems. }}
Properties
None
No properties are exposed by this type.
{{ As a pure marker component, BuildingEfficiency does not hold runtime properties — presence/absence on an entity is used by systems to change behavior. }}
Constructors
public BuildingEfficiency()
The default parameterless constructor is used. Since the struct has no instance fields, construction is trivial. The explicit StructLayout guarantees the struct occupies 1 byte in native layout.
{{ When adding this component to an entity you typically use the default value: EntityManager.AddComponentData(entity, new BuildingEfficiency()); The component's value carries no payload. }}
Methods
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
This writes a single byte (value 0) to the provided writer. The written value is not semantically significant beyond keeping a fixed-size footprint for serialization.
{{ Purpose: satisfy the ISerializable contract so the component can be saved. Keeping a fixed-size write keeps saved data stable even though the component has no state. }}
public void Deserialize<TReader>(TReader reader) where TReader : IReader
This reads a single byte from the reader and discards it.
{{ Purpose: restore compatibility with the serialized format. Since the component has no internal state, the read byte is ignored. This ensures forward/backward compatibility with the serializer expecting a byte for this type. }}
Usage Example
// Add the marker component to an entity (ECS)
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity myEntity = entityManager.CreateEntity();
entityManager.AddComponentData(myEntity, new Game.Buildings.BuildingEfficiency());
// Serialization is handled by the game's serializer; the component implements ISerializable.
// Example pseudocode of what the serializer will effectively do:
writer.Write((byte)0); // Serialize
reader.Read(out byte _); // Deserialize (value ignored)
{{ Notes: - This component is intended as a tag/marker (presence == true). Systems should query for the component to include/exclude entities in building efficiency logic. - The IQueryTypeParameter implementation enables use in query-building APIs that accept query type parameters. - The fixed 1-byte layout ensures consistent behavior when interop/native layout or low-level memory is required by engine code. }}