Skip to content

Game.Prefabs.BuildingStateInfomodePrefab

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: class

Base: ColorInfomodeBasePrefab

Summary:
Prefab component that configures an infomode visualization for buildings. This prefab adds and initializes the runtime ECS components required to display building status colors in the infoview. It exposes a public field m_Type (BuildingStatusType) to control which building status is represented. If m_Type == BuildingStatusType.LeisureProvider, the prefab also adds and initializes a corresponding network-status component so leisure-providing buildings can show net-based status overlays.


Fields

  • public BuildingStatusType m_Type
    Determines which building status this infomode prefab represents. This value is typically set in the prefab/inspector and drives which ECS components are added to the Entity: always InfoviewBuildingStatusData, and additionally InfoviewNetStatusData when m_Type == BuildingStatusType.LeisureProvider.

Properties

  • public override string infomodeTypeLocaleKey { get; }
    Returns the localization key used for this infomode type. For this class it returns "BuildingColor" which should map to the localized label shown in the UI for building infomode.

Constructors

  • public BuildingStateInfomodePrefab()
    Implicit parameterless constructor (no explicit constructor defined in source). Instances are normally created as Unity prefab instances rather than directly instantiated in code.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds the ECS component types that the prefab requires to the provided set. Implementation behavior:
  • Calls base.GetPrefabComponents(components) to include base-class component requirements.
  • Adds ComponentType.ReadWrite() unconditionally.
  • If m_Type == BuildingStatusType.LeisureProvider, adds ComponentType.ReadWrite() as well.

  • public override void Initialize(EntityManager entityManager, Entity entity)
    Sets initial component data on the created Entity. Implementation behavior:

  • Calls base.Initialize(entityManager, entity).
  • Sets InfoviewBuildingStatusData on the entity with m_Type = this.m_Type.
  • If m_Type == BuildingStatusType.LeisureProvider, also sets InfoviewNetStatusData with m_Type = NetStatusType.LeisureProvider. This wires the entity so both building-status and net-status infoview systems can read the correct status type.

Usage Example

// Example: programmatically configuring and initializing the prefab for an entity.
// Note: in normal Unity workflow this prefab is configured in the editor and Unity's prefab system
// calls Initialize during entity creation. This snippet demonstrates the same operations manually.

var prefab = new BuildingStateInfomodePrefab();
prefab.m_Type = BuildingStatusType.LeisureProvider; // set via inspector in regular use

// When the prefab is instantiated into an ECS Entity (pseudo-code):
prefab.Initialize(entityManager, entity);

// After Initialize:
// - Entity has InfoviewBuildingStatusData with m_Type == BuildingStatusType.LeisureProvider
// - Entity also has InfoviewNetStatusData with m_Type == NetStatusType.LeisureProvider