Game.Prefabs.Modes.HappinessFactorParameterMode
Assembly:
Assembly-CSharp (Unity game assembly; inferred)
Namespace:
Game.Prefabs.Modes
Type:
class
Base:
EntityQueryModePrefab
Summary:
A mode prefab component that modifies the HappinessFactorParameterData buffer for a targeted prefab/entity. This mode sets the m_BaseLevel field of a specific index (taxIndex = 17) in the HappinessFactorParameterData dynamic buffer to the value stored in m_TaxBaseLevel. It also supports restoring that value from the corresponding HappinessFactorParameterPrefab default values.
Fields
public int m_TaxBaseLevel
An integer value representing the base happiness/tax level to apply to the targeted parameter at the configured index (taxIndex). This field is exposed on the prefab/mode and is used by ApplyModeData to write into the HappinessFactorParameterData buffer.
Properties
public int taxIndex { get }
Returns the buffer index used by this mode. Hard-coded to 17 in this implementation. This index identifies which entry in the HappinessFactorParameterData dynamic buffer will be modified.
Constructors
public HappinessFactorParameterMode()
Default parameterless constructor (inherited/default). Instances of this prefab are normally created/managed by the prefab system or via Unity editor serialization.
Methods
-
public override EntityQueryDesc GetEntityQueryDesc()
Returns an EntityQueryDesc that matches entities having a read-only HappinessFactorParameterData buffer. This describes which entities/prefabs the mode will target. -
protected override void RecordChanges(EntityManager entityManager, Entity entity)
Called to record the components/buffers that this mode changes. This implementation calls entityManager.GetBuffer(entity) to ensure changes to that buffer are recorded by the prefab mode system. -
public override JobHandle ApplyModeData(EntityManager entityManager, EntityQuery requestedQuery, JobHandle deps)
Applies the m_TaxBaseLevel value to the target entity's HappinessFactorParameterData buffer at taxIndex. Steps: - Obtain the singleton entity from the requestedQuery.
- Get the DynamicBuffer
for that entity. - Read the element at taxIndex, set its m_BaseLevel to m_TaxBaseLevel, and write it back.
-
Returns the incoming JobHandle (this method does not schedule or chain jobs itself).
-
public override void RestoreDefaultData(EntityManager entityManager, ref NativeArray<Entity> entities, PrefabSystem prefabSystem)
Restores the default m_BaseLevel for the same taxIndex from the HappinessFactorParameterPrefab defaults. It: - Gets the prefab for the provided entity via prefabSystem.GetPrefab
(entity). - Reads the corresponding value from the prefab's m_BaseLevels array and writes it into the entity's DynamicBuffer
at taxIndex.
Usage Example
// Example (conceptual): set the desired base level on a mode instance and apply it.
// In the actual game this component is a prefab-mode and typically configured via the editor/prefab system.
HappinessFactorParameterMode mode = /* obtained from prefab/component */;
mode.m_TaxBaseLevel = 4;
// When the prefab system or mode-application code runs:
JobHandle deps = default;
deps = mode.ApplyModeData(entityManager, requestedQuery, deps);
// The happiness parameter at index 17 will now have its m_BaseLevel set to 4.