Game.Prefabs.AreasConfigurationPrefab
Assembly: Assembly-CSharp.dll
Namespace: Game.Prefabs
Type: class
Base: PrefabBase
Summary:
Prefab that provides area/district-related configuration for the game. It exposes a default district prefab reference and a bounds value that controls how slope is considered buildable for map selection UI. During LateInitialize it writes an AreasConfigurationData component to the provided entity, converting the AreaPrefab reference into an ECS entity and copying the slope bounds.
Fields
-
public AreaPrefab m_DefaultDistrictPrefab
Reference to the default district (area) prefab. Marked [NotNull] in source; this prefab is added as a dependency in GetDependencies and converted to an entity in LateInitialize. -
public Bounds1 m_BuildableLandMaxSlope
Bounds (min/max) describing the maximum slope considered buildable for map selection. Default value in code: new Bounds1(0.1f, 0.3f). This value is stored onto the AreasConfigurationData component in LateInitialize.
Properties
- None (this class does not declare any public properties).
Constructors
public AreasConfigurationPrefab()
Implicit default constructor (no explicit constructor is defined in source). Initialization of fields uses their inline initializers (m_BuildableLandMaxSlope default provided).
Methods
-
public override void GetDependencies(List<PrefabBase> prefabs)
Adds dependent prefabs to the provided list. This implementation calls base.GetDependencies(prefabs) and then adds m_DefaultDistrictPrefab so the default district prefab is included in dependency resolution. -
public override void GetPrefabComponents(HashSet<ComponentType> components)
Adds ECS component types that this prefab will use to the provided set. Calls base.GetPrefabComponents(components) and then adds ComponentType.ReadWrite() so that the entity created for this prefab will have an AreasConfigurationData component. -
public override void LateInitialize(EntityManager entityManager, Entity entity)
Finalizes initialization on the ECS entity. It: - Calls base.LateInitialize(entityManager, entity).
- Obtains the PrefabSystem from the world: entityManager.World.GetExistingSystemManaged
(). - Converts the referenced AreaPrefab to an entity via existingSystemManaged.GetEntity(m_DefaultDistrictPrefab).
- Writes an AreasConfigurationData struct to the entity with the resolved m_DefaultDistrictPrefab entity and the m_BuildableLandMaxSlope value.
Usage Example
// The prefab itself already performs necessary setup in LateInitialize.
// Example of how another system might read the configured data from the entity:
void SomeSystemMethod(EntityManager entityManager, Entity areasConfigEntity)
{
if (entityManager.HasComponent<AreasConfigurationData>(areasConfigEntity))
{
var data = entityManager.GetComponentData<AreasConfigurationData>(areasConfigEntity);
Entity defaultDistrictEntity = data.m_DefaultDistrictPrefab;
Bounds1 slopeBounds = data.m_BuildableLandMaxSlope;
// Use defaultDistrictEntity and slopeBounds for initialization or UI display...
}
}
// Example: a Prefab that depends on the default district prefab
public override void GetDependencies(List<PrefabBase> prefabs)
{
base.GetDependencies(prefabs);
// ensure the AreasConfigurationPrefab's default district is available (if you hold a reference)
// prefabs.Add(myAreasConfigurationPrefab.m_DefaultDistrictPrefab);
}