Game.Prefabs.ElectricityParameterData
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: struct
Base: IComponentData, IQueryTypeParameter
Summary:
Holds configuration parameters and prefab references used by the game's electricity system. This component encapsulates tuning values (initial battery charge, temperature-based consumption multiplier, solar penalty from cloudiness) and Entity references to prefabs used for service objects and various electricity-related notifications. Attach this component to an entity that represents electricity system parameters so systems can read behavior and spawn the appropriate prefabs/notifications.
Fields
-
public float m_InitialBatteryCharge
Initial battery charge used by the electricity system when creating or resetting battery state. Represents the starting stored energy level for battery systems (use units appropriate to the electricity simulation). Can be left at a default if not used. -
public AnimationCurve1 m_TemperatureConsumptionMultiplier
Curve that maps temperature to a consumption multiplier. Systems use this to scale building energy consumption based on ambient temperature. Configure the curve with keyframes to represent how consumption increases/decreases with temperature. -
public float m_CloudinessSolarPenalty
Scalar penalty applied to solar production based on cloudiness (typically between 0 and 1). Higher values reduce solar output proportionally. -
public Entity m_ElectricityServicePrefab
Entity reference to the electricity service prefab. Used when the electricity service needs to be instantiated (for service-level visuals or logic). -
public Entity m_ElectricityNotificationPrefab
Entity reference to the generic electricity notification prefab. Spawned to present notifications related to electricity issues. -
public Entity m_LowVoltageNotConnectedPrefab
Prefab reference used for low-voltage "not connected" notifications or visuals. -
public Entity m_HighVoltageNotConnectedPrefab
Prefab reference used for high-voltage "not connected" notifications or visuals. -
public Entity m_BottleneckNotificationPrefab
Prefab reference used to represent network bottlenecks in the electricity grid. -
public Entity m_BuildingBottleneckNotificationPrefab
Prefab reference used to indicate a building-specific electricity bottleneck. -
public Entity m_NotEnoughProductionNotificationPrefab
Prefab reference used when there is insufficient electricity production to meet demand. -
public Entity m_TransformerNotificationPrefab
Prefab reference for transformer-related notifications (e.g., faults, overloads). -
public Entity m_NotEnoughConnectedNotificationPrefab
Prefab reference used when not enough consumers are connected where expected. -
public Entity m_BatteryEmptyNotificationPrefab
Prefab reference used when a battery or stored-power device is depleted.
Notes: - All prefab fields are Unity.Entities.Entity references. Use Entity.Null to indicate "no prefab" if you want to disable spawning for a specific notification. - AnimationCurve1 is a lightweight curve type used in the game's data; configure it with keys appropriate for your tuning.
Properties
- This struct defines no properties. It exposes plain public fields for data/configuration.
Constructors
public ElectricityParameterData()
Structs have an implicit default constructor that zero-initializes numeric fields, sets Entity fields to Entity.Null, and constructs reference types to their default (e.g., a default AnimationCurve1). Initialize explicit values via object initializer when adding the component.
Methods
- This struct defines no methods. It is a pure data container (IComponentData) and is intended to be read by systems.
Usage Example
// Example: Create and attach electricity parameters to a dedicated entity
using Unity.Entities;
using UnityEngine; // for curve construction if necessary
var em = World.DefaultGameObjectInjectionWorld.EntityManager;
var paramEntity = em.CreateEntity();
// Prepare a temperature multiplier curve (example - API may differ)
var tempCurve = new AnimationCurve1();
// Configure keys on tempCurve as appropriate for your game data
// tempCurve.AddKey(...);
// Obtain prefab Entities from your prefab manager / conversion process
Entity electricityServicePrefab = /* retrieve prefab entity */;
Entity notEnoughProductionPrefab = /* retrieve prefab entity */;
var electricityParams = new ElectricityParameterData
{
m_InitialBatteryCharge = 0.5f,
m_TemperatureConsumptionMultiplier = tempCurve,
m_CloudinessSolarPenalty = 0.3f,
m_ElectricityServicePrefab = electricityServicePrefab,
m_ElectricityNotificationPrefab = notEnoughProductionPrefab,
// set other prefab references as needed
};
em.AddComponentData(paramEntity, electricityParams);
If you need finer control or dynamic updates, systems may read this component and spawn the referenced prefabs (instantiating Entities) or adjust energy calculations based on the curve and scalar values.