Game.ExtractorParametersMode
Assembly:
Assembly-CSharp (inferred)
Namespace: Game.Prefabs.Modes
Type:
class
Base:
EntityQueryModePrefab
Summary:
ExtractorParametersMode is a Mode prefab that synchronizes extractor-related configuration values (consumption and "full" thresholds for different resource types) into the ECS world by writing them into the ExtractorParameterData component on the singleton extractor-parameter entity. It provides an EntityQuery that looks for the ExtractorParameterData component, can record changes, apply the mode values to the ECS component, and restore default values from the corresponding prefab data.
This class is decorated with the ComponentMenu attribute: [ComponentMenu("Modes/Mode Parameters/", new Type[] { })]
Fields
-
public float m_FertilityConsumption
Value used to set ExtractorParameterData.m_FertilityConsumption. Represents how much fertility is consumed per unit (configured by the mode/prefab). -
public float m_OreConsumption
Value used to set ExtractorParameterData.m_OreConsumption. Represents ore consumption. -
public float m_ForestConsumption
Value used to set ExtractorParameterData.m_ForestConsumption. Represents forest resource consumption. -
public float m_OilConsumption
Value used to set ExtractorParameterData.m_OilConsumption. Represents oil consumption. -
public float m_FullFertility
Value used to set ExtractorParameterData.m_FullFertility. Threshold representing a "full" fertility level for extraction logic. -
public float m_FullOre
Value used to set ExtractorParameterData.m_FullOre. Threshold for ore. -
public float m_FullOil
Value used to set ExtractorParameterData.m_FullOil. Threshold for oil.
Notes: - These fields are intended to be set on the prefab (in the editor or via code) and then pushed into the ECS ExtractorParameterData component by ApplyModeData. - Field names map 1:1 to the ExtractorParameterData component's fields.
Properties
- (none)
This class defines no C# properties. It relies on public fields and overrides of base class methods.
Constructors
public ExtractorParametersMode()
Default parameterless constructor (implicitly provided). No special initialization is performed in the class source.
Methods
-
public override EntityQueryDesc GetEntityQueryDesc()
Returns an EntityQueryDesc that matches entities having the ExtractorParameterData component (read-only). This query is used to find the singleton extractor-parameter entity where values will be written. -
protected override void RecordChanges(EntityManager entityManager, Entity entity)
Reads ExtractorParameterData from the provided entity via entityManager.GetComponentData(entity). The call ensures the system records the component's state for change-tracking (or to ensure the component is accessed/validated). It does not modify the component. -
public override JobHandle ApplyModeData(EntityManager entityManager, EntityQuery requestedQuery, JobHandle deps)
Applies the mode's configured float values into the ExtractorParameterData component on the singleton entity found by requestedQuery.GetSingletonEntity(). It sets m_FertilityConsumption, m_OreConsumption, m_ForestConsumption, m_OilConsumption, m_FullFertility, m_FullOre and m_FullOil, then writes the updated component back with entityManager.SetComponentData(...). Returns the incoming JobHandle (deps) unchanged — no jobs are scheduled here. -
public override void RestoreDefaultData(EntityManager entityManager, ref NativeArray<Entity> entities, PrefabSystem prefabSystem)
Restores the ExtractorParameterData for the first entity in the provided entities array by reading default values from the corresponding ExtractorParameterPrefab (via prefabSystem.GetPrefab(entity)). It copies the prefab's fields into the component and writes it back using entityManager.SetComponentData(...). This is used to reset prefab instances to their default parameter values.
Implementation notes: - The class operates synchronously on the main thread via EntityManager component reads/writes. It does not schedule or depend on jobs (ApplyModeData returns deps without modification). - It assumes requestedQuery contains a singleton entity with ExtractorParameterData; calling GetSingletonEntity() will throw if not satisfied. - RestoreDefaultData expects entities[0] to be the correct prefab entity to fetch the corresponding ExtractorParameterPrefab.
Usage Example
// Example: programmatically set mode values and apply them to ECS
// (Assumes you have an EntityManager and a query that returns the ExtractorParameterData singleton.)
ExtractorParametersMode mode = /* obtain mode prefab instance (from scene or prefab system) */;
mode.m_FertilityConsumption = 0.75f;
mode.m_OreConsumption = 1.2f;
mode.m_ForestConsumption = 0.5f;
mode.m_OilConsumption = 0.9f;
mode.m_FullFertility = 100f;
mode.m_FullOre = 200f;
mode.m_FullOil = 150f;
JobHandle deps = default;
EntityQuery query = entityManager.CreateEntityQuery(typeof(ExtractorParameterData));
deps = mode.ApplyModeData(entityManager, query, deps);
// deps is unchanged; values have been written to the ExtractorParameterData singleton.