Skip to content

Game.Prefabs.WindPowered

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: class

Base: ComponentBase, IServiceUpgrade

Summary:
WindPowered is a MonoBehaviour prefab component used for wind power plant buildings. It requires a PowerPlant component and is listed under the Buildings/CityServices component menu for BuildingPrefab and BuildingExtensionPrefab. The component exposes simple configuration fields (maximum wind and production) and integrates with the game's ECS layer by adding or initializing entity components (WindPoweredData and, depending on context, Efficiency, RenewableElectricityProduction and PointOfInterest). It also provides upgrade-related component information through the IServiceUpgrade interface.


Fields

  • public float m_MaximumWind
    The maximum wind speed (or wind factor) used by the wind power building. This value is copied into the entity component (WindPoweredData) during Initialize and is used by simulation systems to determine generation efficiency/availability.

  • public int m_Production
    Nominal production value (e.g., base electricity output) for the wind-powered plant. This is stored in WindPoweredData via Initialize and used by electricity-production systems to compute generated power.

Properties

  • This class does not declare any public properties.

Constructors

  • public WindPowered()
    Default MonoBehaviour constructor (implicit). The class does not define an explicit constructor; fields are expected to be set in the inspector or via script before the prefab is initialized.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds the WindPoweredData component type to the given component set so the prefab entity will carry WindPoweredData. Called during prefab conversion to ECS.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    When the GameObject does not have a ServiceUpgrade component, this method adds Efficiency, RenewableElectricityProduction, and PointOfInterest component types to the archetype. This controls which components the archetype/entity will include for runtime systems.

  • public void GetUpgradeComponents(HashSet<ComponentType> components)
    Part of IServiceUpgrade: adds the Efficiency component type to the set of components required for upgrades.

  • public override void Initialize(EntityManager entityManager, Entity entity)
    Initializes the entity's WindPoweredData using the MonoBehaviour field values (m_MaximumWind and m_Production). Called during prefab-to-entity conversion to write the runtime data into the ECS entity.

Usage Example

// Example: configure in code before conversion or show what Initialize writes to ECS
public class WindPoweredConfigurator : MonoBehaviour
{
    public WindPowered windPrefab;

    void Start()
    {
        // Configure defaults (can be set in Inspector as well)
        windPrefab.m_MaximumWind = 14.5f;
        windPrefab.m_Production = 120;

        // During conversion, WindPowered.Initialize will be called and will set:
        // WindPoweredData { m_MaximumWind = 14.5f, m_Production = 120 }
    }
}

// Alternatively, manually write WindPoweredData to an entity:
EntityManager em = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity myEntity = /* obtain/create prefab entity */;
em.SetComponentData(myEntity, new WindPoweredData
{
    m_MaximumWind = 14.5f,
    m_Production = 120
});