Skip to content

Game.Prefabs.ElectricityParametersPrefab

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: class

Base: PrefabBase

Summary:
Holds editable electricity-related configuration and prefab references used by the electricity simulation. Exposes inspector-visible parameters (initial battery charge, temperature→consumption curve, cloudiness penalty) and many notification/service prefab references. On initialization it converts those prefab references into ECS entities and writes an ElectricityParameterData component to the prefab entity so runtime systems can read the configuration. The temperature curve is wrapped into an AnimationCurve1 for use in component data.


Fields

  • public float m_InitialBatteryCharge
    Initial battery charge as a fraction (0.0–1.0). Has [Tooltip("Initial charge of batteries")] and [Range(0f, 1f)] attributes. Default value: 0.1f.

  • public AnimationCurve m_TemperatureConsumptionMultiplier
    AnimationCurve mapping temperature (°C) to a consumption multiplier. Used to modify electricity consumption with temperature. Has a tooltip describing its purpose. Converted to AnimationCurve1 when stored in component data.

  • public float m_CloudinessSolarPenalty
    Fractional penalty applied to solar plant output when cloudy. Range 0.0–1.0 with Tooltip. Default value: 0.25f.

  • public ServicePrefab m_ElectricityServicePrefab
    Reference to the ServicePrefab representing the electricity service. Converted to an Entity in LateInitialize.

  • public NotificationIconPrefab m_ElectricityNotificationPrefab
    Notification prefab used for general electricity notifications. Converted to an Entity in LateInitialize.

  • public NotificationIconPrefab m_LowVoltageNotConnectedPrefab
    Notification prefab for low-voltage not-connected warnings. Converted to an Entity in LateInitialize.

  • public NotificationIconPrefab m_HighVoltageNotConnectedPrefab
    Notification prefab for high-voltage not-connected warnings. Converted to an Entity in LateInitialize.

  • public NotificationIconPrefab m_BottleneckNotificationPrefab
    Notification prefab for generic electricity bottlenecks. Converted to an Entity in LateInitialize.

  • public NotificationIconPrefab m_BuildingBottleneckNotificationPrefab
    Notification prefab for building-specific electricity bottlenecks. Converted to an Entity in LateInitialize.

  • public NotificationIconPrefab m_NotEnoughProductionNotificationPrefab
    Notification prefab shown when production is insufficient. Converted to an Entity in LateInitialize.

  • public NotificationIconPrefab m_TransformerNotificationPrefab
    Notification prefab related to transformers. Converted to an Entity in LateInitialize.

  • public NotificationIconPrefab m_NotEnoughConnectedNotificationPrefab
    Notification prefab for insufficient connected supply. Converted to an Entity in LateInitialize.

  • public NotificationIconPrefab m_BatteryEmptyNotificationPrefab
    Notification prefab fired when batteries are depleted. Converted to an Entity in LateInitialize.

Properties

  • None declared on the MonoBehaviour/prefab class. (Runtime data is provided via the ElectricityParameterData component written in LateInitialize.)

Constructors

  • public ElectricityParametersPrefab()
    No explicit constructor is defined in the source; the default parameterless constructor is used. Initialization of default field values happens via field initializers in the class (for example m_InitialBatteryCharge = 0.1f).

Methods

  • public override void GetDependencies(List<PrefabBase> prefabs)
    Adds all referenced prefabs (service and notification prefabs) to the provided dependency list so those prefabs are ensured to be loaded before this prefab. Calls base.GetDependencies(prefabs) and then Add(...) for each referenced PrefabBase field.

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Registers the component types that this prefab will attach on the ECS entity. This implementation adds ComponentType.ReadWrite() and calls base.GetPrefabComponents(components).

  • public override void LateInitialize(EntityManager entityManager, Entity entity)
    Called during prefab->entity conversion. Creates or gets the PrefabSystem, converts each referenced PrefabBase into an Entity (using PrefabSystem.GetEntity), wraps the temperature AnimationCurve into an AnimationCurve1, and writes an ElectricityParameterData component to the provided entity with all parameter values and entity references. Calls base.LateInitialize(entityManager, entity) first.

Notes: - AnimationCurve1 is used as a serializable/struct wrapper for AnimationCurve to store it in component data. - The written component is ElectricityParameterData (must be available in the game types); runtime systems should read that component from the prefab entity to obtain settings.

Usage Example

// In a runtime System or other initialization code you can read the data written by the prefab:
var prefabSystem = entityManager.World.GetOrCreateSystemManaged<PrefabSystem>();
Entity prefabEntity = prefabSystem.GetEntity(myElectricityParametersPrefab); // myElectricityParametersPrefab is a reference to the prefab asset
ElectricityParameterData data = entityManager.GetComponentData<ElectricityParameterData>(prefabEntity);

float initialBattery = data.m_InitialBatteryCharge;
AnimationCurve1 tempCurve = data.m_TemperatureConsumptionMultiplier;
Entity electricityServiceEntity = data.m_ElectricityServicePrefab;
// Use these values/entities in simulation systems...