Skip to content

Game.Prefabs.BuildingConfigurationPrefab

Assembly: Game
Namespace: Game.Prefabs

Type: class

Base: PrefabBase

Summary:
Prefab container that exposes building-related settings and references (notifications, visual/particle effects, connection lanes, construction/collapse objects, etc.) in the editor and converts them into ECS data. During prefab initialization this class writes a BuildingConfigurationData component to the entity, resolving referenced prefabs into entities via the PrefabSystem. The increments/decrements for building condition are applied 16 times per game day (per the inspector tooltips).


Fields

  • public int m_BuildingConditionIncrement = 30
    Controls how much the building condition increases when upkeep is paid. Changes occur 16 times per game day. Default: 30.

  • public int m_BuildingConditionDecrement = 1
    Controls how much the building condition decreases when upkeep is not paid. Changes occur 16 times per game day. Default: 1.

  • public NotificationIconPrefab m_AbandonedCollapsedNotification
    Prefab reference for the notification shown when a building is abandoned and collapsed.

  • public NotificationIconPrefab m_AbandonedNotification
    Prefab reference for the notification shown when a building is abandoned.

  • public NotificationIconPrefab m_CondemnedNotification
    Prefab reference for the notification shown when a building is condemned.

  • public NotificationIconPrefab m_LevelUpNotification
    Prefab reference for the level-up notification for buildings.

  • public NotificationIconPrefab m_TurnedOffNotification
    Prefab reference for the notification shown when a building is turned off (e.g., power off).

  • public NetLanePrefab m_ElectricityConnectionLane
    Lane prefab used to visualize/represent electricity connection on the building.

  • public NetLanePrefab m_SewageConnectionLane
    Lane prefab used to visualize/represent sewage connection on the building.

  • public NetLanePrefab m_WaterConnectionLane
    Lane prefab used to visualize/represent water connection on the building.

  • public uint m_AbandonedDestroyDelay
    Delay (in game ticks/units used by the game) before an abandoned building is destroyed/removed.

  • public NotificationIconPrefab m_HighRentNotification
    Prefab reference for the notification that triggers when rent is too high.

  • public BrandPrefab m_DefaultRenterBrand
    Default brand prefab used for renters of the building.

  • public AreaPrefab m_ConstructionSurface
    Area prefab used while the building is under construction.

  • public NetLanePrefab m_ConstructionBorder
    Net lane prefab used to mark the construction border.

  • public ObjectPrefab m_ConstructionObject
    Object prefab used for the building while it is under construction.

  • public ObjectPrefab m_CollapsedObject
    Object prefab used to represent a collapsed building.

  • public EffectPrefab m_CollapseVFX
    Visual effect prefab played when a building collapses.

  • public EffectPrefab m_CollapseSFX
    Sound effect prefab played when a building collapses.

  • public float m_CollapseSFXDensity = 0.1f
    Density parameter for collapse SFX (how frequently sound events are spawned). Default: 0.1.

  • public AreaPrefab m_CollapsedSurface
    Area prefab used to mark the collapsed building area.

  • public EffectPrefab m_FireLoopSFX
    Sound effect prefab for continuous fire loop for burning buildings.

  • public EffectPrefab m_FireSpotSFX
    Sound effect prefab for fire spot sounds.

Properties

  • None declared on this class.
    Note: This prefab adds the BuildingConfigurationData component to the prefab entity during GetPrefabComponents so runtime code should read configuration through that ECS component.

Constructors

  • public BuildingConfigurationPrefab()
    Implicit default constructor. Instances of this prefab are typically created/edited in the Unity editor; runtime initialization is done by the Prefab system and LateInitialize override.

Methods

  • public override void GetDependencies(List<PrefabBase> prefabs)
    Adds all referenced prefabs (notifications, lanes, objects, effects, etc.) to the provided list so they can be loaded/processed before this prefab. Ensure referenced fields are assigned in the inspector; otherwise null entries may be added.

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds ComponentType.ReadWrite() to the given set so the entity created from this prefab will have the BuildingConfigurationData ECS component.

  • public override void LateInitialize(EntityManager entityManager, Entity entity)
    Populates the BuildingConfigurationData component on the freshly created entity. Uses PrefabSystem (obtained via entityManager.World.GetOrCreateSystemManaged()) to translate referenced Prefab objects into entities and copies scalar values (increments, delay, density, etc.). After this runs, systems can read BuildingConfigurationData from the entity to get all configured values and entity references.

Usage Example

// Example: reading the configured ECS data after the prefab has been initialized
EntityManager em = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity configEntity = /* entity created from BuildingConfigurationPrefab by the prefab system */;

if (em.HasComponent<BuildingConfigurationData>(configEntity))
{
    BuildingConfigurationData cfg = em.GetComponentData<BuildingConfigurationData>(configEntity);
    int inc = cfg.m_BuildingConditionIncrement;
    int dec = cfg.m_BuildingConditionDecrement;
    Entity collapseVfxEntity = cfg.m_CollapseVFX;
    // Use these values/entities in your system logic...
}

Notes: - Assign all referenced prefab fields in the inspector to avoid null references being added to dependencies. - The BuildingConfigurationPrefab exists to bridge editor-exposed references to an ECS-friendly BuildingConfigurationData component used at runtime.