Game.Prefabs.ZonePrefab
Assembly:
Namespace: Game.Prefabs
Type: class
Base: PrefabBase
Summary:
Represents a zone prefab used by the game to describe area/zone types (residential, commercial, industrial, etc.). Exposed in the Unity Component Menu under "Zones/". Contains visual settings (color, edge color), an AreaType, and an Office flag which changes behavior for building-related component provisioning. The prefab is responsible for reporting ECS components required for zone entities and for delegating zone-specific building component setup to IZoneBuildingComponent implementations found on the underlying prefab.
Fields
-
public AreaType m_AreaType
Area type for this zone prefab (enum from Game.Zones). Determines the tag produced when m_Office is false and is used by systems that differentiate zones by AreaType. -
public Color m_Color = Color.white
Primary color for the zone (default white). Typically used for visualization in editor/infoview. -
public Color m_Edge = Color.white
Edge color for the zone (default white). Used for visualization of zone borders. -
public bool m_Office
If true, this zone prefab represents an office-style zone. Affects mod tags and which building components are added (OfficeBuilding is added for buildings created from this zone prefab).
Properties
public override IEnumerable<string> modTags { get; }
Yields mod tags describing this prefab. It first yields the base.modTags, then yields "Zones". If m_Office is true it yields "ZonesOffice"; otherwise it yields "Zones{m_AreaType}" (e.g. "ZonesResidential"). Useful for mod filtering/identification in tools or pipelines.
Constructors
public ZonePrefab()
No explicit constructor is defined; a default parameterless constructor is used. Initialization of serialized fields occurs via field initializers (m_Color and m_Edge default to Color.white).
Methods
public override void GetPrefabComponents(HashSet<ComponentType> components)
Adds required ECS component types for a zone prefab to the provided HashSet. Calls base.GetPrefabComponents(...) then adds:- ZoneData (read/write)
- PlaceableInfoviewItem (read/write)
-
ProcessEstimate (read/write)
These components represent the runtime data and UI/processing hooks needed by zone entities. -
public void GetBuildingPrefabComponents(HashSet<ComponentType> components, BuildingPrefab buildingPrefab, byte level)
Collects building-specific component types required when a building is created under this zone prefab. If m_Office is true, adds OfficeBuilding. Then attempts to retrieve all IZoneBuildingComponent implementations attached to the underlying base.prefab and asks each to add its building-prefab component requirements via IZoneBuildingComponent.GetBuildingPrefabComponents(...). If base.prefab.TryGet(list) returns false, the method returns without adding further components. -
public void GetBuildingArchetypeComponents(HashSet<ComponentType> components, BuildingPrefab buildingPrefab, byte level)
Delegates to any IZoneBuildingComponent implementations found on the underlying prefab to add archetype-level ECS components for the building archetype. Similar lookup pattern as GetBuildingPrefabComponents; returns early if TryGet fails. -
public void InitializeBuilding(EntityManager entityManager, Entity entity, BuildingPrefab buildingPrefab, byte level)
Initializes an instantiated building entity using each IZoneBuildingComponent found on the underlying prefab. For each IZoneBuildingComponent, calls InitializeBuilding(entityManager, entity, buildingPrefab, level). If base.prefab.TryGet(list) fails, nothing is invoked.
Usage Example
// Example: collect ECS components required by a zone prefab
ZonePrefab zone = /* obtain reference (from prefab, inspector, factory, etc.) */;
var components = new HashSet<Unity.Entities.ComponentType>();
zone.GetPrefabComponents(components);
// Example: collect building components for a building created from this zone
BuildingPrefab buildingPrefab = /* reference */;
byte level = 1;
zone.GetBuildingPrefabComponents(components, buildingPrefab, level);
// Example: initialize a building entity for this zone
// (assuming entityManager and entity were created using an archetype that includes the required components)
zone.InitializeBuilding(entityManager, entity, buildingPrefab, level);