Game.Prefabs.Modes.DeathcareFacilityMode
Assembly: Assembly-CSharp
Namespace: Game.Prefabs.Modes
Type: class
Base: LocalModePrefab
Summary:
Prefab component that defines mode-specific adjustments for deathcare facilities. It contains a list of ModeData entries that reference target prefabs and specify multipliers for storage capacity and processing rate. The component can record dependencies (marking the ECS component as used), apply multipliers to the runtime ECS component data (DeathcareFacilityData), and restore the original defaults from the prefab's DeathcareFacility component.
Fields
-
public ModeData[] m_ModeDatas
Array of ModeData entries. Each entry targets a prefab and contains multipliers used to modify the corresponding DeathcareFacilityData on the entity created from that prefab. -
public class ModeData
public PrefabBase m_Prefab
Reference to the prefab this mode entry applies to.public float m_StorageCapacityMultifier
Multiplier applied to the facility's storage capacity. (Note: the field name uses the spelling "Multifier" as in the source.)public float m_ProcessingRateMultifier
Multiplier applied to the facility's processing rate.
Properties
- None
Constructors
public DeathcareFacilityMode()
Default constructor (compiler-generated). No special runtime initialization is performed by the component beyond default field values.
Methods
-
public override void RecordChanges(EntityManager entityManager, PrefabSystem prefabSystem)
Iterates m_ModeDatas and, for each entry, resolves the referenced DeathcareFacility MonoBehaviour from the PrefabBase. If the component is missing, a critical log is emitted and that entry is skipped. For valid targets it obtains the ECS Entity for the prefab via prefabSystem.GetEntity(component.prefab) and calls entityManager.GetComponentData(entity). This call ensures the DeathcareFacilityData component is accessed (likely to register a dependency/change), but note that GetComponentData will throw if the component does not exist on the entity. -
public override void ApplyModeData(EntityManager entityManager, PrefabSystem prefabSystem)
Applies the configured multipliers to the entity's DeathcareFacilityData. For each ModeData entry: - Resolves the DeathcareFacility component on the referenced prefab; logs and skips if missing.
- Gets the entity corresponding to that prefab.
- Reads the existing DeathcareFacilityData from the entity.
- Scales m_StorageCapacity by m_StorageCapacityMultifier (the result is cast to int).
- Multiplies m_ProcessingRate by m_ProcessingRateMultifier.
-
Writes the modified DeathcareFacilityData back to the entity via entityManager.SetComponentData. Be aware that casting the scaled storage capacity to int truncates fractional values.
-
public override void RestoreDefaultData(EntityManager entityManager, PrefabSystem prefabSystem)
Restores the original values from the prefab's DeathcareFacility component to the runtime DeathcareFacilityData on the entity. For each ModeData entry: - Resolves the DeathcareFacility component on the referenced prefab; logs and skips if missing.
- Gets the entity for that prefab.
- Reads the DeathcareFacilityData from the entity.
- Sets m_StorageCapacity to the prefab's component.m_StorageCapacity and m_ProcessingRate to component.m_ProcessingRate.
- Writes the restored DeathcareFacilityData back to the entity. This ensures runtime modifications made by ApplyModeData can be reverted to the prefab defaults.
Usage Example
// Example: configure a single ModeData entry in code and apply it.
// Typically m_ModeDatas is set in the prefab/inspector, but this shows runtime usage.
var mode = someGameObject.GetComponent<Game.Prefabs.Modes.DeathcareFacilityMode>();
mode.m_ModeDatas = new[]
{
new Game.Prefabs.Modes.DeathcareFacilityMode.ModeData
{
m_Prefab = somePrefabBase,
m_StorageCapacityMultifier = 1.5f,
m_ProcessingRateMultifier = 0.9f
}
};
// Apply multipliers to the runtime ECS data
mode.ApplyModeData(entityManager, prefabSystem);
// Later, to restore original values:
mode.RestoreDefaultData(entityManager, prefabSystem);
Notes and tips: - The component expects the referenced prefab to contain a DeathcareFacility MonoBehaviour and the instantiated entity to contain a DeathcareFacilityData ECS component. Missing components are logged as critical and entries are skipped. - The storage multiplier is applied and then cast to int — consider rounding if truncation is undesirable. - Field name typo: "m_StorageCapacityMultifier" / "m_ProcessingRateMultifier" (uses "Multifier" instead of "Multiplier") — keep this spelling when referencing fields in code.