Game.Prefabs.BuildingSpawnGroupData
Assembly:
Game (assembly name may vary between game builds; this struct is part of the game's runtime assemblies)
Namespace: Game.Prefabs
Type:
struct
Base:
ISharedComponentData, IQueryTypeParameter
Summary:
A lightweight shared component that tags an entity (typically a prefab or spawn-group entity) with a ZoneType. Used to group and filter building spawn groups by zone (e.g., Residential, Commercial, Industrial) within the ECS. Being a shared component, instances with the same ZoneType are stored together to allow efficient filtering and reduce chunk fragmentation. Implementing IQueryTypeParameter indicates it can be used directly in some query APIs as a query parameter type.
Fields
public ZoneType m_ZoneType
Stores the zone type for this spawn group. The ZoneType enum is defined in Game.Zones and indicates which zoning category this building spawn group belongs to (for example: Residential, Commercial, Industrial, etc.). This field is assigned by the constructor and is the value used for shared-component grouping and filtering.
Properties
- None
This struct does not expose properties; it only contains the public field m_ZoneType.
Constructors
public BuildingSpawnGroupData(ZoneType type)
Initializes a new BuildingSpawnGroupData with the specified ZoneType. Use this constructor when creating the shared component to attach to an entity or when passing it to a shared-component filter.
Example behavior: assigns the provided type to m_ZoneType so entities with identical ZoneType values will share the same shared-component value.
Methods
- None
This struct defines no methods beyond the compiler-provided ones (e.g., default Equals/GetHashCode for value types). Its behavior is purely data-driven.
Usage Example
using Game.Zones;
using Game.Prefabs;
using Unity.Entities;
// Example: attach the shared component to an entity (e.g., a building spawn-group entity)
public void AssignSpawnGroup(EntityManager entityManager, Entity entity)
{
var spawnGroup = new BuildingSpawnGroupData(ZoneType.Residential);
entityManager.AddSharedComponentData(entity, spawnGroup);
}
// Example: create an Entities query that filters by shared component (pseudo-API; exact calls depend on Entities version)
public void QueryByZone(EntityManager entityManager)
{
// Create an entity query that matches entities having this shared component type
var query = entityManager.CreateEntityQuery(ComponentType.ReadOnly<BuildingSpawnGroupData>());
// Optionally filter by specific shared component value:
entityManager.AddSharedComponentFilter(query, new BuildingSpawnGroupData(ZoneType.Commercial));
// Then use the query to operate on matching entities...
}