Game.Prefabs.LimitSettingPrefab
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: class
Base: PrefabBase
Summary:
Prefab class that exposes a configurable "max chirps" limit and ensures that a LimitSettingData ECS component is added to the prefab/entity. During LateInitialize the prefab writes the configured value into the entity's LimitSettingData component so it is available at runtime (ECS side). The default m_MaxChirpsLimit is 100.
Fields
public int m_MaxChirpsLimit = 100
Public integer that defines the maximum chirps limit to be written into the LimitSettingData component during LateInitialize. Default value is 100. Set this value on the prefab (in code or inspector) to change the limit that will be placed on the spawned entity.
Properties
- None declared in this class.
Constructors
public LimitSettingPrefab()
Default parameterless constructor. The field m_MaxChirpsLimit is initialized to 100 by default.
Methods
-
public override void GetPrefabComponents(HashSet<ComponentType> components)
Adds the ECS components that this prefab requires. This override calls the base implementation and then adds a read/write LimitSettingData component (ComponentType.ReadWrite()) so the created entity will include that component. -
public override void GetArchetypeComponents(HashSet<ComponentType> components)
Overrides the base method. In the current implementation it just calls the base implementation and does not add additional archetype components itself. The method exists to allow adding archetype-level component types if needed. -
public override void LateInitialize(EntityManager entityManager, Entity entity)
Called after the entity is created from the prefab. This override calls the base implementation and then writes the configured m_MaxChirpsLimit into the entity's LimitSettingData component using entityManager.SetComponentData(entity, new LimitSettingData { m_MaxChirpsLimit = m_MaxChirpsLimit });. This ensures the ECS component has the intended initial value.
Usage Example
// Configure a prefab instance in code (or set m_MaxChirpsLimit in the inspector)
var limitPrefab = new LimitSettingPrefab
{
m_MaxChirpsLimit = 250 // set desired limit
};
// When the prefab is instantiated, the prefab system will call GetPrefabComponents()
// and LateInitialize. LateInitialize will write the value into the entity's LimitSettingData:
// entityManager.SetComponentData(entity, new LimitSettingData { m_MaxChirpsLimit = 250 });
Additional notes: - LimitSettingData is expected to be an ECS IComponentData/struct with a field named m_MaxChirpsLimit. Ensure that type exists and matches the expected layout. - This class relies on PrefabBase to integrate with the prefab/instantiation system used by the game. If you need to add other ECS components to the prefab, add them in GetPrefabComponents or GetArchetypeComponents as appropriate.