Skip to content

Game.Prefabs.BuildingStatusInfomodePrefab

Assembly:
Assembly-CSharp

Namespace:
Game.Prefabs

Type:
class

Base:
GradientInfomodeBasePrefab

Summary:
Prefab class that defines a building-status "infomode" (visual overlay) configuration. This prefab exposes a BuildingStatusType and a Bounds1 range which are written into the ECS component InfoviewBuildingStatusData when the prefab is initialized. It also provides the infomode localization key ("BuildingColor") used by the UI/infomode system. The class is decorated with a ComponentMenu attribute so it can be created/selected in the editor under Tools/Infomode/.


Fields

  • public BuildingStatusType m_Type
    The kind of building status this infomode represents (an enum or identifier that categorizes the status overlay). This value is copied into the InfoviewBuildingStatusData component on the entity during Initialize.

  • public Bounds1 m_Range
    A Bounds1 structure (from Colossal.Mathematics) that specifies the numeric range or thresholds used by this gradient infomode. This value is copied into the InfoviewBuildingStatusData component on the entity during Initialize.

Properties

  • public override string infomodeTypeLocaleKey { get; }
    Returns the localization key for this infomode type. For this prefab it always returns "BuildingColor". This key is used by the UI/localization system to show the name of the infomode.

Constructors

  • public BuildingStatusInfomodePrefab()
    Implicit default constructor. Typical Unity/MonoBehaviour/prefab types rely on the default constructor and the Unity editor/serialization to instantiate and populate public fields (m_Type, m_Range).

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Calls the base implementation and then adds the ECS component type InfoviewBuildingStatusData as ReadWrite to the provided set. This tells the prefab building system that entities instantiated from this prefab must include InfoviewBuildingStatusData.

  • public override void Initialize(EntityManager entityManager, Entity entity)
    Calls the base Initialize and then sets the InfoviewBuildingStatusData component on the created entity with the prefab's m_Type and m_Range values:

  • entityManager.SetComponentData(entity, new InfoviewBuildingStatusData { m_Type = m_Type, m_Range = m_Range });

This transfers the prefab configuration into the ECS world so runtime systems can read it.

Usage Example

// Example: reading the InfoviewBuildingStatusData that this prefab writes during initialization.
Entity entity = /* the entity created from the BuildingStatusInfomodePrefab */;
var data = entityManager.GetComponentData<InfoviewBuildingStatusData>(entity);
Debug.Log($"Building infomode type: {data.m_Type}, range: {data.m_Range}");

Notes and tips: - The prefab is intended to be used in the editor side (as part of the game's prefab/infomode system). Set m_Type and m_Range in the prefab asset or via code before the prefab is serialized/instantiated. - The class requires the InfoviewBuildingStatusData component definition to exist; that component contains fields named m_Type and m_Range matching the prefab's data. - The ComponentMenu attribute ("Tools/Infomode/") places this prefab type into the editor menu for easier creation.