Game.Prefabs.BuildingMarker
Assembly: Assembly-CSharp (game/mod assembly)
Namespace: Game.Prefabs
Type: class
Base: ComponentBase
Summary:
Component used on notification/prefab objects to mark a prefab with a building type. When the prefab is instantiated as an Entity, this Component ensures a BuildingMarkerData component is present on the Entity and initializes it with the configured m_BuildingType value. This is typically used by the notification/marker system to filter or identify markers that correspond to specific building types.
Fields
public BuildingType m_BuildingType
Holds the building type that this marker represents. This value is copied into the Entity's BuildingMarkerData during Initialize so that runtime systems (jobs, queries, or other entity logic) can read the building type from the ECS component.
Properties
- This class declares no properties.
Constructors
public BuildingMarker()
No explicit constructor is defined in the source. The class uses the implicit parameterless constructor provided by C#. Any initialization of m_BuildingType should be performed in inspector or by code after creating the component.
Methods
-
public override void GetPrefabComponents(HashSet<ComponentType> components)
AddsComponentType.ReadWrite<BuildingMarkerData>()
to the provided component set. This ensures the prefab / entity archetype created from this component will contain a BuildingMarkerData ECS component so Initialize can set values on it. -
public override void GetArchetypeComponents(HashSet<ComponentType> components)
Empty implementation. No additional archetype components are added by default. This method is available for subclasses to contribute archetype components if required. -
public override void Initialize(EntityManager entityManager, Entity entity)
Called when the prefab is turned into an Entity. Calls base.Initialize(entityManager, entity) and then creates a BuildingMarkerData instance with m_BuildingType copied from this component and writes it into the entity using entityManager.SetComponentData(entity, componentData). This ties the author-time setting on the prefab to runtime ECS data.
Usage Example
// Example: set up the marker on a prefab (inspector or code)
var marker = gameObject.AddComponent<Game.Prefabs.BuildingMarker>();
marker.m_BuildingType = BuildingType.Industrial;
// When the prefab is converted to an Entity, BuildingMarker.Initialize will run and
// write a BuildingMarkerData component containing the chosen building type onto the entity.
// Example: reading the BuildingMarkerData from the Entity side
var data = entityManager.GetComponentData<BuildingMarkerData>(entity);
UnityEngine.Debug.Log($"Marker building type: {data.m_BuildingType}");
Notes and assumptions: - BuildingMarkerData is expected to be an ECS IComponentData/struct with at least a field named m_BuildingType compatible with BuildingType. - BuildingType is assumed to be an enum declaring building categories (e.g., Residential, Commercial, Industrial). - This component participates in the prefab -> entity conversion process used by the game's modding ECS pipeline; ensure prefabs using this component go through that conversion so the BuildingMarkerData component exists on the resulting entity.