Game.Prefabs.Modes.GarbageParametersMode
Assembly: Assembly-CSharp
Namespace: Game.Prefabs.Modes
Type: class
Base: EntityQueryModePrefab
Summary:
A prefab mode class that exposes configurable garbage system parameters (production, limits and balance factors) to the ECS world. When applied, it writes these values into the singleton GarbageParameterData component so the garbage simulation systems use the configured settings. It also supports restoring values from the corresponding GarbagePrefab defaults.
Fields
-
public int m_HomelessGarbageProduce = 25
This value configures how much garbage a homeless population produces. Default: 25. -
public int m_CollectionGarbageLimit = 20
Amount used as a threshold/limit related to garbage collection behaviour. Default: 20. -
public int m_RequestGarbageLimit = 100
Threshold at which the system requests additional garbage collection resources. Default: 100. -
public int m_WarningGarbageLimit = 500
Warning threshold for garbage accumulation used by UI or systems to signal issues. Default: 500. -
public int m_MaxGarbageAccumulation = 2000
Maximum amount of garbage that can accumulate before more severe measures are taken. Default: 2000. -
public float m_BuildingLevelBalance = 1.25f
Multiplies or biases garbage-related calculations by building level (used to scale production/impact). Default: 1.25. -
public float m_EducationBalance = 2.5f
A factor representing how education affects garbage production/handling. Default: 2.5. -
public int m_HappinessEffectBaseline = 100
Baseline value for happiness impact related to garbage (used in happiness calculations). Default: 100. -
public int m_HappinessEffectStep = 65
Step value used when computing happiness effects from garbage thresholds. Default: 65.
Properties
- None (this prefab exposes its settings as public fields rather than properties)
Constructors
public GarbageParametersMode()
Default constructor. Instances are generally created/instantiated by the prefab system (e.g., added to a prefab in the editor). Initializes fields to their default literal values listed above.
Methods
-
public override EntityQueryDesc GetEntityQueryDesc()
Returns an EntityQueryDesc that matches entities containing theGarbageParameterData
component (read-only). This query is used by the mode framework to find the singleton garbage parameter entity to update. -
protected override void RecordChanges(EntityManager entityManager, Entity entity)
Reads theGarbageParameterData
component from the provided entity to record its current state. The method is used by the prefab/mode system to capture previous values (for undo/restore or change tracking) — it performs a read viaentityManager.GetComponentData<GarbageParameterData>(entity)
. -
public override JobHandle ApplyModeData(EntityManager entityManager, EntityQuery requestedQuery, JobHandle deps)
Applies the prefab's field values to the singletonGarbageParameterData
component found viarequestedQuery.GetSingletonEntity()
. The method copies each public field into the corresponding fields of theGarbageParameterData
struct and writes it back withentityManager.SetComponentData(...)
. It returns the incoming JobHandledeps
unchanged (no additional jobs scheduled here). -
public override void RestoreDefaultData(EntityManager entityManager, ref NativeArray<Entity> entities, PrefabSystem prefabSystem)
Restores garbage parameter values from the originalGarbagePrefab
defaults. It looks up theGarbagePrefab
for the provided entity viaprefabSystem.GetPrefab<GarbagePrefab>(entity)
and copies those prefab default values into the entity'sGarbageParameterData
component, then writes the component back withentityManager.SetComponentData(...)
.
Usage Example
// Example usage pattern: configure the prefab instance (e.g. in editor or at runtime)
// and let the prefab/mode system call ApplyModeData to write values to the ECS singleton.
// In editor: attach GarbageParametersMode to a prefab and tweak fields via the inspector.
// Programmatically:
GarbageParametersMode mode = new GarbageParametersMode();
mode.m_HomelessGarbageProduce = 30;
mode.m_CollectionGarbageLimit = 25;
// ...adjust other fields as needed
// When the mode system applies this mode it will call:
// mode.ApplyModeData(entityManager, requestedQuery, deps);