Game.Prefabs.Modes.WorkProviderParameterMode
Assembly: Assembly-CSharp (game / mod assembly)
Namespace: Game.Prefabs.Modes
Type: class
Base: EntityQueryModePrefab
Summary:
WorkProviderParameterMode is a mode prefab component used to transfer configurable work-provider parameters from a prefab (or inspector-exposed values) into the game ECS singleton WorkProviderParameterData. It exposes notification delay and limit fields for educated and uneducated workers, plus a senior employee level. When the mode is applied, the component copies its public field values to the WorkProviderParameterData component on the singleton entity. It also supports restoring values from the original prefab via RestoreDefaultData.
Fields
-
public short m_UneducatedNotificationDelay
Minimum value enforced via [Min(1f)]. Delay (in game ticks/units expected by the system) used for uneducated worker notifications. Exposed in the Inspector. -
public short m_EducatedNotificationDelay
Minimum value enforced via [Min(1f)]. Delay used for educated worker notifications. Exposed in the Inspector. -
public float m_UneducatedNotificationLimit
Clamped to [0f, 1f] via [Range(0f, 1f)]. Fraction threshold for uneducated worker notification activation. Exposed in the Inspector. -
public float m_EducatedNotificationLimit
Clamped to [0f, 1f] via [Range(0f, 1f)]. Fraction threshold for educated worker notification activation. Exposed in the Inspector. -
public int m_SeniorEmployeeLevel
Integer value specifying the senior employee level used by work provider logic. Exposed in the Inspector.
(These fields are public and intended to be configured on the prefab or in the Unity Inspector. Validation attributes enforce minimum and range constraints at edit time.)
Properties
- This class does not declare public properties. It exposes configuration via the public fields listed above and provides behavior via overridden methods from EntityQueryModePrefab.
Constructors
public WorkProviderParameterMode()
Implicit default constructor provided by Unity/MonoBehaviour. Instances of this component are created and managed by the Unity editor/runtime when the prefab is used.
Methods
public override EntityQueryDesc GetEntityQueryDesc()
: EntityQueryDesc
Returns an EntityQueryDesc that matches entities containing a read-only WorkProviderParameterData component. This is used by the mode system to find the singleton (or entities) to which this mode will apply data.
Behavior detail:
- Builds an EntityQueryDesc with All = [ ComponentType.ReadOnly
-
protected override void RecordChanges(EntityManager entityManager, Entity entity)
: void
Intended to record any changes needed for undo/redo or change-tracking in the prefab/mode system. In this implementation it performs a GetComponentData(entity) (reads the component), which ensures change tracking hooks that depend on reading the component run as necessary. -
public override JobHandle ApplyModeData(EntityManager entityManager, EntityQuery requestedQuery, JobHandle deps)
: JobHandle
Copies the mode's configured fields into the WorkProviderParameterData component on the singleton entity matched by requestedQuery. Steps performed: - Gets the singleton entity via requestedQuery.GetSingletonEntity().
- Reads WorkProviderParameterData from the entity.
- Sets the component fields:
- m_UneducatedNotificationDelay
- m_EducatedNotificationDelay
- m_UneducatedNotificationLimit
- m_EducatedNotificationLimit
- m_SeniorEmployeeLevel
- Writes the component back with entityManager.SetComponentData.
- Returns the incoming JobHandle unchanged (no additional jobs scheduled in this override).
Notes: - This method runs on the main thread as it uses EntityManager.Get/SetComponentData directly. - Because it returns deps without scheduling, it should be safe to call in contexts where synchronous application is intended.
public override void RestoreDefaultData(EntityManager entityManager, ref NativeArray<Entity> entities, PrefabSystem prefabSystem)
: void
Restores component values on the provided entity to the values stored in the prefab asset (WorkProviderParameterPrefab). Steps:- Fetches the entity from the entities array (entities[0]).
- Gets the WorkProviderParameterPrefab for that entity from PrefabSystem.
- Reads WorkProviderParameterData from the entity.
- Copies values from the prefab into the component data fields:
- m_UneducatedNotificationDelay
- m_EducatedNotificationDelay
- m_UneducatedNotificationLimit
- m_EducatedNotificationLimit
- m_SeniorEmployeeLevel
- Writes the component data back to the entity with entityManager.SetComponentData.
Usage notes: - Typically called by the prefab/mode system to reset runtime changes back to the original prefab defaults.
Usage Example
Basic example showing how values are stored on the prefab component and applied by the mode system. In practice the mode system calls ApplyModeData; here is an example snippet illustrating how the inspector fields on this component are the source for the WorkProviderParameterData singleton.
// Example: configuring in script or via Inspector
// (In the editor, attach WorkProviderParameterMode to a Mode prefab and edit fields.)
WorkProviderParameterMode mode = /* obtained from prefab or created in editor */;
mode.m_UneducatedNotificationDelay = 10;
mode.m_EducatedNotificationDelay = 5;
mode.m_UneducatedNotificationLimit = 0.2f;
mode.m_EducatedNotificationLimit = 0.35f;
mode.m_SeniorEmployeeLevel = 3;
// The mode system will call ApplyModeData(...), which will copy these values into
// the WorkProviderParameterData singleton used by the game systems.
Additional information: - Related types: WorkProviderParameterData, WorkProviderParameterPrefab, PrefabSystem, EntityManager, EntityQuery, JobHandle. - This class relies on Unity.Entities ECS APIs and is intended to be used by the game's prefab/mode application system rather than invoked directly in most mod code.