Game.Prefabs.ServiceCoverageInfomodePrefab
Assembly:
Namespace: Game.Prefabs
Type: class
Base: GradientInfomodeBasePrefab
Summary:
ServiceCoverageInfomodePrefab is a prefab component used by the infomode system to display service coverage as a gradient. It exposes the service type (CoverageService) and a coverage range (Bounds1) which are written into an InfoviewCoverageData ECS component on initialization. The prefab is exposed in the Unity component menu under "Tools/Infomode/".
Fields
-
public CoverageService m_Service
Holds the service whose coverage will be visualized (e.g., health, fire, police). This value is transferred to the InfoviewCoverageData component so the rendering/system side knows which service to evaluate. -
public Bounds1 m_Range = new Bounds1(0f, 5f)
Defines the coverage range parameters used for the infomode visualization. Default constructed here with min 0 and max 5. This value is also written into InfoviewCoverageData.
Properties
public override string infomodeTypeLocaleKey => "NetworkColor"
Overrides the base infomode locale key to return "NetworkColor". This key is used for localization/display of the infomode type in UI.
Constructors
public ServiceCoverageInfomodePrefab()
Default parameterless constructor (implicit). Initialization of fields uses field initializers (m_Range default shown in the source).
Methods
-
public override void GetPrefabComponents(HashSet<ComponentType> components)
Adds required ECS component types to the prefab's component set. Calls base implementation and then addsComponentType.ReadWrite<InfoviewCoverageData>()
, ensuring the entity created from this prefab will contain InfoviewCoverageData for reading/writing coverage parameters. -
public override void Initialize(EntityManager entityManager, Entity entity)
Called when the prefab is instantiated into an entity. This method calls the base Initialize and then sets the InfoviewCoverageData component on the created entity with the prefab's m_Service and m_Range values: -
Creates an InfoviewCoverageData struct with:
- m_Service = this.m_Service
- m_Range = this.m_Range
- Writes that struct into the entity via entityManager.SetComponentData.
Notes: - Relies on the presence and definition of the InfoviewCoverageData component struct/type. - Uses Unity.Entities (ECS) API: EntityManager, Entity, ComponentType.
Usage Example
// Example taken from the prefab Initialize override.
// When the prefab is instantiated, this will set the InfoviewCoverageData component.
public override void Initialize(EntityManager entityManager, Entity entity)
{
base.Initialize(entityManager, entity);
entityManager.SetComponentData(entity, new InfoviewCoverageData
{
m_Service = m_Service,
m_Range = m_Range
});
}
Additional notes for modders: - Assign m_Service and m_Range in the prefab inspector (or via code) to control what service is visualized and with what range. - Ensure InfoviewCoverageData and CoverageService types are available and compatible with the rest of the infomode/rendering systems. - The ComponentMenu attribute places this prefab under "Tools/Infomode/" in the Unity component menu for easier access when editing prefabs.