Skip to content

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 the GarbageParameterData 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 the GarbageParameterData 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 via entityManager.GetComponentData<GarbageParameterData>(entity).

  • public override JobHandle ApplyModeData(EntityManager entityManager, EntityQuery requestedQuery, JobHandle deps)
    Applies the prefab's field values to the singleton GarbageParameterData component found via requestedQuery.GetSingletonEntity(). The method copies each public field into the corresponding fields of the GarbageParameterData struct and writes it back with entityManager.SetComponentData(...). It returns the incoming JobHandle deps unchanged (no additional jobs scheduled here).

  • public override void RestoreDefaultData(EntityManager entityManager, ref NativeArray<Entity> entities, PrefabSystem prefabSystem)
    Restores garbage parameter values from the original GarbagePrefab defaults. It looks up the GarbagePrefab for the provided entity via prefabSystem.GetPrefab<GarbagePrefab>(entity) and copies those prefab default values into the entity's GarbageParameterData component, then writes the component back with entityManager.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);