Game.Prefabs.Modes.BuildingEfficiencyParametersMode
Assembly:
Assembly-CSharp (game code / modding assembly)
Namespace:
Game.Prefabs.Modes
Type:
class
Base:
EntityQueryModePrefab
Summary:
Defines a prefab-mode component that exposes global building-efficiency tuning parameters (penalties, thresholds and fee curves) in the Unity inspector and applies them into the ECS singleton BuildingEfficiencyParameterData
. This prefab is used by the game's mode/prefab system to write runtime values (or restore defaults from a corresponding prefab) into the ECS component used by building systems to compute efficiency related effects (electricity, water, sewage, garbage, mail, staffing, etc).
Fields
-
public AnimationCurve m_ServiceBudgetEfficiencyFactor
AnimationCurve used to map service budget to an efficiency factor. Converted to an internalAnimationCurve1
when applied to ECS component. -
public float m_LowEfficiencyThreshold = 0.15f
Threshold below which a building is considered low-efficiency. Has a[Range(0f, 1f)]
inspector attribute; default shown in field initializer. -
public float m_ElectricityPenalty = 0.5f
Electricity-related efficiency penalty applied when electricity is missing/outage.[Range(0f, 1f)]
. -
public short m_ElectricityPenaltyDelay = 32
Delay (in simulation ticks) before electricity penalty is applied. Marked[Min(1f)]
. -
public AnimationCurve m_ElectricityFeeFactor
AnimationCurve mapping electricity fees to an efficiency factor. Converted toAnimationCurve1
for ECS. -
public float m_WaterPenalty = 0.5f
Water service penalty when water is insufficient.[Range(0f, 1f)]
. -
public byte m_WaterPenaltyDelay = 32
Delay (in ticks) before water penalty is applied.[Min(1f)]
. Cast toint
when stored in ECS. -
public float m_WaterPollutionPenalty = 0.5f
Penalty for water pollution.[Range(0f, 1f)]
. -
public float m_SewagePenalty = 0.5f
Sewage service penalty.[Range(0f, 1f)]
. -
public byte m_SewagePenaltyDelay = 32
Delay before sewage penalty is applied.[Min(1f)]
. Cast toint
when stored in ECS. -
public AnimationCurve m_WaterFeeFactor
AnimationCurve mapping water fees to an efficiency factor. Converted toAnimationCurve1
for ECS. -
public float m_GarbagePenalty = 0.5f
Garbage collection related efficiency penalty.[Range(0f, 1f)]
. -
public int m_NegligibleMail = 20
Mail threshold considered negligible.[Min(0f)]
. -
public float m_MailEfficiencyPenalty = 0.1f
Efficiency penalty applied when mail is insufficient.[Range(0f, 1f)]
. -
public float m_TelecomBaseline = 0.3f
Baseline telecom efficiency used in calculations.[Range(0f, 1f)]
. -
public float m_MissingEmployeesEfficiencyPenalty = 0.9f
Penalty applied when a workplace is missing employees.[Range(0f, 1f)]
. -
public short m_MissingEmployeesEfficiencyDelay = 16
Delay (ticks) before missing-employees penalty takes effect.[Min(1f)]
. -
public short m_ServiceBuildingEfficiencyGracePeriod = 16
Grace period (ticks) for service buildings before efficiency penalties apply.[Min(0f)]
. -
public float m_SickEmployeesEfficiencyPenalty = 0.9f
Penalty applied when employees are sick.[Range(0f, 1f)]
.
Properties
- This class does not declare any public properties of its own. It exposes data via public fields and uses override methods to write into ECS component data.
Constructors
public BuildingEfficiencyParametersMode()
Implicit default constructor. The prefab component is intended to be configured in the Unity inspector; no special construction logic is defined in this class.
Methods
-
public override EntityQueryDesc GetEntityQueryDesc()
Returns an EntityQueryDesc that selects entities having theBuildingEfficiencyParameterData
component (read-only). Used by the mode system to find the singleton ECS entity to write into. -
protected override void RecordChanges(EntityManager entityManager, Entity entity)
Records changes — this implementation callsentityManager.GetComponentData<BuildingEfficiencyParameterData>(entity)
to ensure the component is referenced/recorded by the prefab system. -
public override JobHandle ApplyModeData(EntityManager entityManager, EntityQuery requestedQuery, JobHandle deps)
Reads the singleton entity fromrequestedQuery
, fetches itsBuildingEfficiencyParameterData
, and writes all values from this prefab instance into that component. Conversions performed: AnimationCurve
fields are converted toAnimationCurve1
.-
byte
/short
delay fields are cast toint
as required by the component fields. Returns the incomingdeps
JobHandle (no asynchronous jobs are scheduled here). -
public override void RestoreDefaultData(EntityManager entityManager, ref NativeArray<Entity> entities, PrefabSystem prefabSystem)
Restores default values from the correspondingBuildingEfficiencyParametersPrefab
pulled fromPrefabSystem
. It reads the prefab data and writes it into the ECS component on the entity passed inentities[0]
. Also performs the sameAnimationCurve
→AnimationCurve1
conversions and integer casts.
Usage Example
// Example: change a value in the prefab component at runtime and apply it to the ECS singleton.
// (This is a simplified example: in-game the mode/prefab system normally calls ApplyModeData.)
var mode = myGameObject.GetComponent<Game.Prefabs.Modes.BuildingEfficiencyParametersMode>();
mode.m_ElectricityPenalty = 0.6f;
// Assuming you already have an EntityManager and an EntityQuery that matches the singleton:
JobHandle deps = default;
deps = mode.ApplyModeData(entityManager, myEntityQuery, deps);
Notes and implementation details:
- This component is a bridge between Unity inspector-configured values (and prefab defaults) and the ECS BuildingEfficiencyParameterData
used by simulation systems.
- All curves are converted to the game's internal AnimationCurve1
type before being written to the component.
- Delay fields declared as byte
/short
in the prefab are stored as int
in the component — casts are performed in ApplyModeData
/ RestoreDefaultData
.
- GetEntityQueryDesc
makes this class operate on the singleton BuildingEfficiencyParameterData
entity.