Skip to content

Game.Buildings.CityEffectProvider

Assembly:
Assembly-CSharp (typical for game mods; actual assembly may vary)

Namespace:
Game.Buildings

Type:
struct (value type)

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

Summary:
CityEffectProvider is an empty/tag component used by the game's ECS to mark entities (typically building entities) that provide city-wide effects. It is a 1-byte sized struct (see StructLayout attribute) and is intended to be used purely as a marker (no data). The IEmptySerializable interface and explicit StructLayout(Size = 1) ensure the struct can be serialized/deserialized by the game's custom serialization system and avoids zero-sized-struct pitfalls.


Fields

  • This struct declares no managed fields.
    Additional implementation detail: it is annotated with [StructLayout(LayoutKind.Sequential, Size = 1)] to enforce a minimum size of 1 byte for serialization compatibility.

Properties

  • This struct exposes no properties. It functions as a tag component only.

Constructors

  • public CityEffectProvider()
    Structs in C# have an implicit default parameterless constructor which will initialize the single-byte instance. No explicit constructor is defined in the source.

Methods

  • This struct declares no methods. Behavior is provided by systems that query for this component type.

Usage Example

using Unity.Entities;
using Game.Buildings;

// Add the tag component to an entity (e.g., a building entity)
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity buildingEntity = /* obtain entity for a building */;

// Add the CityEffectProvider tag to mark this building as a provider of city effects
if (!entityManager.HasComponent<CityEffectProvider>(buildingEntity))
{
    entityManager.AddComponentData(buildingEntity, new CityEffectProvider());
}

// Querying for all entities that provide city effects
var query = entityManager.CreateEntityQuery(typeof(CityEffectProvider));
using (var entities = query.ToEntityArray(Unity.Collections.Allocator.TempJob))
{
    foreach (var e in entities)
    {
        // handle effect-providing building entity `e`
    }
}

{{ Additional notes: - Use this type when you need a lightweight marker for systems that should run on or collect entities that "provide" city effects. - Because the struct carries no data, adding/removing the component is how you toggle the semantic meaning on an entity. - Ensure systems that depend on this tag check for the presence of the component rather than expecting any data fields. }}