Game.Prefabs.GroundWaterPowered
Assembly: Assembly-CSharp.dll
Namespace: Game.Prefabs
Type: class
Base: ComponentBase, IServiceUpgrade
Summary:
GroundWaterPowered is a prefab component used for ground-water powered power plants (city service building). It exposes configurable inspector fields for production and maximum groundwater, registers the runtime ECS component GroundWaterPoweredData on the prefab entity, and conditionally adds archetype components (Efficiency and RenewableElectricityProduction) for entities that are not using a ServiceUpgrade. This ties the GameObject prefab into the game's ECS systems for electricity production and efficiency/upgrade handling.
Fields
-
public int m_Production
Production output (integer) configured on the prefab. At Initialize time this value is stored into the GroundWaterPoweredData component so the ECS systems can read the plant's production amount. -
public int m_MaximumGroundWater
Maximum groundwater capacity (integer) configured on the prefab. This value is written into GroundWaterPoweredData during initialization and used by gameplay/ECS logic that governs groundwater-based production limits.
Properties
- None
This prefab class does not declare any C# properties. It exposes public fields for inspector configuration and implements methods that add ECS components.
Constructors
public GroundWaterPowered()
Implicit default constructor. No explicit construction logic is defined in the class source; Unity creates instances as components attached to GameObjects (prefabs).
Methods
-
public override void GetPrefabComponents(HashSet<ComponentType> components)
Adds the runtime ECS component type GroundWaterPoweredData (ReadWrite) to the prefab's component set. This ensures entities spawned from this prefab include the GroundWaterPoweredData component. -
public override void GetArchetypeComponents(HashSet<ComponentType> components)
If the GameObject does not have a ServiceUpgrade component, this method adds Efficiency and RenewableElectricityProduction (both ReadWrite) to the prefab's archetype components. This enables non-upgrade variants to participate in efficiency and renewable electricity production systems. -
public void GetUpgradeComponents(HashSet<ComponentType> components)
When used in an upgrade context, this method adds the Efficiency component (ReadWrite) to the upgrade archetype so upgrade entities maintain an efficiency component. -
public override void Initialize(EntityManager entityManager, Entity entity)
Writes the configured m_Production and m_MaximumGroundWater values into the GroundWaterPoweredData component on the created entity: - Sets GroundWaterPoweredData.m_Production = m_Production
- Sets GroundWaterPoweredData.m_MaximumGroundWater = m_MaximumGroundWater This bridges the MonoBehaviour prefab data to the ECS entity data at spawn/initialization time.
Additional notes: - The class is annotated with [RequireComponent(typeof(PowerPlant))], so GameObjects using this component must also have a PowerPlant component. - The [ComponentMenu] attribute places the prefab under Buildings/CityServices/ in the editor component menu.
Usage Example
// Configure the prefab in the Unity inspector:
// - Set m_Production (e.g. 500)
// - Set m_MaximumGroundWater (e.g. 10000)
// Attach GroundWaterPowered to a GameObject that also has a PowerPlant component.
// During entity initialization the prefab will write the values into ECS:
public override void Initialize(EntityManager entityManager, Entity entity)
{
// base.Initialize not defined here (this method overrides ComponentBase.Initialize),
// but this class writes GroundWaterPoweredData based on inspector fields.
entityManager.SetComponentData(entity, new GroundWaterPoweredData
{
m_Production = m_Production,
m_MaximumGroundWater = m_MaximumGroundWater
});
}