Skip to content

Game.Prefabs.ZoneSuitabilityInfomodePrefab

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: class

Base: GradientInfomodeBasePrefab

Summary:
Prefab component that configures a zone-suitability infomode. It exposes which AreaType the infomode targets and whether the suitability should consider office zoning. When the prefab is instantiated into the ECS world it adds and initializes an InfoviewAvailabilityData component on the created entity so the infomode system knows which area type and office flag to display.


Fields

  • public AreaType m_AreaType
    This field selects the AreaType (from Game.Zones) that the infomode will report on (for example residential, commercial, industrial, etc.). It is used to populate the InfoviewAvailabilityData component during Initialize.

  • public bool m_Office
    When true, indicates the suitability infomode targets office zoning (a specific sub-type/flag relevant to commercial zoning). This value is copied into the InfoviewAvailabilityData on the entity.

  • The prefab also causes the addition of an ECS component:

  • InfoviewAvailabilityData (added via GetPrefabComponents)
    This ECS component is added as ReadWrite so runtime systems can read the configured area/office availability state.

Properties

  • public override string infomodeTypeLocaleKey => "NetworkColor"
    This override returns the locale key used to label the infomode in UI. The prefab uses the string "NetworkColor" (likely reusing an existing localization entry) as the infomode type label.

Constructors

  • public ZoneSuitabilityInfomodePrefab()
    The default parameterless constructor is used by Unity when creating the prefab/Component. No custom construction logic is defined in this class; configuration is expected via the public fields (set in the editor or by code).

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds prefab-required ECS component types into the provided set. Implementation:
  • Calls base.GetPrefabComponents(components) to include base-class components.
  • Adds ComponentType.ReadWrite() so entities instantiated from this prefab will include that component (writable by systems).

  • public override void Initialize(EntityManager entityManager, Entity entity)
    Sets up the entity's InfoviewAvailabilityData using the prefab's public fields. Implementation:

  • Calls base.Initialize(entityManager, entity).
  • Uses entityManager.SetComponentData(entity, new InfoviewAvailabilityData { m_AreaType = m_AreaType, m_Office = m_Office }) to copy the prefab configuration into the ECS component.

Usage Example

// Example: prefab fields are normally set in the Unity inspector. If you create/configure in code:
var prefab = new ZoneSuitabilityInfomodePrefab
{
    m_AreaType = AreaType.Commercial,
    m_Office = true
};

// During entity creation, the prefab's Initialize will run and write:
// InfoviewAvailabilityData { m_AreaType = AreaType.Commercial, m_Office = true }
// onto the created entity so infomode systems can use it.

[Preserve]
public override void Initialize(EntityManager entityManager, Entity entity)
{
    base.Initialize(entityManager, entity);
    entityManager.SetComponentData(entity, new InfoviewAvailabilityData
    {
        m_AreaType = this.m_AreaType,
        m_Office = this.m_Office
    });
}

Notes: - This prefab relies on the InfoviewAvailabilityData ECS type and the AreaType enum from Game.Zones. - Configure m_AreaType and m_Office on the prefab asset (or set them in code before instantiation) to control what the infomode displays.