Game.Prefabs.Modes.LeisureParametersMode
Assembly: Assembly-CSharp.dll
Namespace: Game.Prefabs.Modes
Type: class
Base: EntityQueryModePrefab
Summary:
LeisureParametersMode is a MonoBehaviour prefab component that bridges designer-configured leisure/tourist parameters (exposed as public fields on the prefab) into the DOTS/ECS world by writing values into the singleton LeisureParametersData component. It is used by the prefab system / mode system to apply or restore leisure-related configuration for the game mode (tourist consumption, lodging, and random factor).
Fields
-
public int m_LeisureRandomFactor
Controls a randomization factor affecting leisure behavior. This integer value is written into LeisureParametersData.m_LeisureRandomFactor when ApplyModeData runs. -
public int m_TouristLodgingConsumePerDay
Configured number of lodging units a tourist consumes per day. Written to LeisureParametersData.m_TouristLodgingConsumePerDay. -
public int m_TouristServiceConsumePerDay
Configured number of service units a tourist consumes per day. Written to LeisureParametersData.m_TouristServiceConsumePerDay.
Properties
- This class does not declare any C# properties.
Constructors
public LeisureParametersMode()
Default constructor (generated). This component is typically configured in the Unity editor on a prefab; no special construction logic is implemented in the class.
Methods
-
public override EntityQueryDesc GetEntityQueryDesc()
Returns an EntityQueryDesc that targets entities containing the LeisureParametersData component. Implementation creates a new EntityQueryDesc with All = [ReadOnly()]. This describes the singleton ECS component that this mode will operate on. -
protected override void RecordChanges(EntityManager entityManager, Entity entity)
Invokes entityManager.GetComponentData(entity). The call ensures the component is accessed so that the prefab/system can record or detect changes (versioning) for the specified entity. No mutation is performed here. -
public override JobHandle ApplyModeData(EntityManager entityManager, EntityQuery requestedQuery, JobHandle deps)
Applies the MonoBehaviour's configured field values into the ECS singleton component. It: - Obtains the singleton entity via requestedQuery.GetSingletonEntity().
- Reads LeisureParametersData from that entity, updates its fields (m_LeisureRandomFactor, m_TouristLodgingConsumePerDay, m_TouristServiceConsumePerDay) from this prefab's public fields.
- Writes the modified LeisureParametersData back with entityManager.SetComponentData.
-
Returns the input JobHandle (deps). This method runs synchronously on the main thread (no new jobs scheduled).
-
public override void RestoreDefaultData(EntityManager entityManager, ref NativeArray<Entity> entities, PrefabSystem prefabSystem)
Restores default values from the prefab data into the ECS component for the provided entity. It: - Uses entities[0] as the target entity.
- Retrieves the LeisureParametersPrefab via prefabSystem.GetPrefab
(entity). - Reads current LeisureParametersData, overwrites its fields with values from the prefab (leisureParametersPrefab.*), and sets the component data back on the entity.
- Used when resetting mode/prefab values to defaults defined by the prefab asset.
Usage Example
// Example: Configure the prefab component in code (typically done in editor).
GameObject modePrefab = new GameObject("LeisureModePrefab");
var leisureMode = modePrefab.AddComponent<Game.Prefabs.Modes.LeisureParametersMode>();
leisureMode.m_LeisureRandomFactor = 10;
leisureMode.m_TouristLodgingConsumePerDay = 2;
leisureMode.m_TouristServiceConsumePerDay = 3;
// At runtime the prefab system will call GetEntityQueryDesc/ApplyModeData to copy these
// values into the ECS LeisureParametersData singleton so game systems use the configured values.