Game.Prefabs.Modes.AttractivenessParametersMode
Assembly: Assembly-CSharp
Namespace: Game.Prefabs.Modes
Type: class
Base: EntityQueryModePrefab
Summary:
A Mode prefab component that provides a set of attractiveness-related tuning parameters and applies them to the game's AttractivenessParameterData (typically a singleton ECS component). This prefab is exposed in the Unity editor under "Modes/Mode Parameters/" (via the ComponentMenu attribute) and is used by the Prefab/System workflow to set or restore attractiveness defaults for the world (forest/shore effects, temperature ranges, rain/snow effects, height bonuses, etc.).
Fields
-
public float m_ForestEffect
Strength of the attractiveness effect applied by nearby forest tiles. -
public float m_ForestDistance
Distance over which the forest effect attenuates. -
public float m_ShoreEffect
Strength of the attractiveness effect applied by nearby shore (water) tiles. -
public float m_ShoreDistance
Distance over which the shore effect attenuates. -
public float3 m_HeightBonus
Additional attractiveness bonus depending on terrain height. Represented as a float3 (likely mapping tiers or axes used by the game). -
public float2 m_AttractiveTemperature
Temperature range considered "attractive" (min, max). -
public float2 m_ExtremeTemperature
Temperature range considered "extreme" (min, max). -
public float2 m_TemperatureAffect
How much temperature (within the ranges) affects attractiveness (likely separate coefficients for warm/cold). -
public float2 m_RainEffectRange
Range (min, max) describing how rain intensity affects attractiveness. -
public float2 m_SnowEffectRange
Range (min, max) describing how snow intensity affects attractiveness. -
public float3 m_SnowRainExtremeAffect
Extra attractiveness modifier for extreme precipitation conditions (snow/rain), represented as float3.
Properties
- None (this prefab stores its tunables as public fields and does not expose additional properties).
Constructors
public AttractivenessParametersMode()
Default parameterless constructor (implicit). The behavior is driven by the public fields set on the prefab instance in the editor or at runtime.
Methods
-
public override EntityQueryDesc GetEntityQueryDesc()
Returns an EntityQueryDesc that targets entities containing AttractivenessParameterData (read-only specified in the query). Used by the prefab/system to find the singleton attractiveness data entity. -
protected override void RecordChanges(EntityManager entityManager, Entity entity)
Reads the AttractivenessParameterData for the given entity. This method is called by the prefab recording system to ensure changes are registered for this entity/prefab instance (it gets the component data, triggering the recording logic). -
public override void RestoreDefaultData(EntityManager entityManager, ref NativeArray<Entity> entities, PrefabSystem prefabSystem)
Restores component data on the provided entity array from the AttractivenessParametersPrefab stored in the PrefabSystem. It reads default values from the prefab (AttractivenessParametersPrefab) and writes them into the entity's AttractivenessParameterData via EntityManager.SetComponentData. -
public override JobHandle ApplyModeData(EntityManager entityManager, EntityQuery requestedQuery, JobHandle deps)
Applies the values currently set on this Mode prefab instance to the singleton AttractivenessParameterData found by the requestedQuery. It copies all the fields (forest/shore, height bonus, temperature/rain/snow settings) into the component on the singleton entity and returns the incoming deps JobHandle. No jobs are scheduled by this method (it performs immediate SetComponentData calls).
Usage Example
// Example usage from a management script or system.
// This assumes the AttractivenessParametersMode component is available (e.g., on a prefab)
// and that entityManager & a query for AttractivenessParameterData are available.
AttractivenessParametersMode mode = /* obtain your prefab/component instance (e.g., GetComponent) */;
mode.m_ForestEffect = 0.6f;
mode.m_ForestDistance = 30f;
mode.m_ShoreEffect = 0.4f;
mode.m_ShoreDistance = 20f;
// ... set other fields as needed ...
EntityQuery query = entityManager.CreateEntityQuery(typeof(AttractivenessParameterData));
JobHandle deps = default;
// Apply the prefab values to the singleton AttractivenessParameterData
mode.ApplyModeData(entityManager, query, deps);
Notes: - This class is intended to be used as a prefab-driven tuning container. Values are typically set in the Unity editor on the prefab and then applied at runtime via the PrefabSystem / mode application flow. - RestoreDefaultData reads defaults from AttractivenessParametersPrefab (from the PrefabSystem) and writes them to the entity; ApplyModeData writes current instance values directly to the singleton component.