Game.Prefabs.ZoneBuiltRequirementPrefab
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: Class
Base: UnlockRequirementPrefab
Summary:
This Prefab type defines an "unlock requirement" that checks if a particular zone/area/theme has been built to satisfy an unlock condition. At initialization it adds an UnlockRequirement entry to the entity's buffer and writes a ZoneBuiltRequirementData component with the configured requirement parameters (required theme/zone/type, minimum squares, count and level). This prefab is used by the game's prefab system to turn editor-set values into ECS component data consumed by game logic that evaluates unlock requirements.
Fields
-
public ThemePrefab m_RequiredTheme
Optional reference to a ThemePrefab. If set, the requirement will target zones with this theme. -
public ZonePrefab m_RequiredZone
Optional reference to a specific ZonePrefab. If set, the requirement will target that zone type. -
public AreaType m_RequiredType
AreaType enum indicating the required area type to count toward the requirement (e.g., residential/commercial/industrial/etc). -
public int m_MinimumSquares = 2500
Minimum number of squares (total area) required. Default value is 2500. -
public int m_MinimumCount
Minimum number of zone instances required. -
public int m_MinimumLevel = 1
Minimum zone level required. When written to the component this value is stored as a byte.
Properties
- None (this prefab exposes configuration via public fields and converts them to component data in LateInitialize).
{{ This class does not declare C# properties; it exposes public fields that are transferred to ECS components during LateInitialize. }}
Constructors
public ZoneBuiltRequirementPrefab()
{{ There is no explicit constructor in the source — the default parameterless constructor provided by C# is used. Initialization of runtime data happens during LateInitialize when the prefab is converted to an entity. }}
Methods
-
public override void GetDependencies(List<PrefabBase> prefabs)
{{ Adds referenced prefabs (m_RequiredTheme and m_RequiredZone) to the provided dependencies list so the prefab system knows to load them first. Calls base.GetDependencies(prefabs) then conditionally appends the referenced ThemePrefab and ZonePrefab. }} -
public override void GetPrefabComponents(HashSet<ComponentType> components)
{{ Declares which ECS component types this prefab will add to the entity. Calls base then adds ComponentType.ReadWrite() so the entity will have the ZoneBuiltRequirementData component. }} -
public override void LateInitialize(EntityManager entityManager, Entity entity)
{{ Core conversion method: called by the prefab system to initialize the entity. It: - Calls base.LateInitialize.
- Gets the PrefabSystem to resolve referenced prefab assets to entities.
- Adds an UnlockRequirement entry to the entity's UnlockRequirement buffer.
- Fills a ZoneBuiltRequirementData struct with the prefab field values (resolving theme/zone to entity references when present).
- Writes the ZoneBuiltRequirementData to the entity via entityManager.SetComponentData. Note: m_MinimumLevel is cast to a byte when stored into the component. }}
Usage Example
// Example showing how to read the ZoneBuiltRequirementData after the prefab has been converted.
EntityManager em = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity requirementEntity = /* entity created from ZoneBuiltRequirementPrefab by PrefabSystem */;
// After prefab conversion (LateInitialize) you can read the component:
if (em.HasComponent<ZoneBuiltRequirementData>(requirementEntity))
{
ZoneBuiltRequirementData data = em.GetComponentData<ZoneBuiltRequirementData>(requirementEntity);
Debug.Log($"Required type: {data.m_RequiredType}, min squares: {data.m_MinimumSquares}, min level: {data.m_MinimumLevel}");
}
{{Notes for modders: Create and configure ZoneBuiltRequirementPrefab assets in the editor (inspector) to define unlock conditions. The prefab system will turn the public fields into an ECS component (ZoneBuiltRequirementData) and register an UnlockRequirement buffer element on the generated entity so game logic can evaluate unlocking based on built zones.}}