Game.Prefabs.NetStatusInfomodePrefab
Assembly: Assembly-CSharp.dll
Namespace: Game.Prefabs
Type: public class
Base: GradientInfomodeBasePrefab
Summary:
NetStatusInfomodePrefab is an infomode prefab used by the game to display network (road/transport) status visualizations. It exposes configurable fields for the type of network status to display, the range used for mapping values to the gradient, and flow visualization parameters (speed, tiling and minimum flow). The prefab ensures the required ECS component (InfoviewNetStatusData) is declared and initializes that component on the Entity with values derived from the prefab fields. It also provides runtime color/flow parameter outputs used by the renderer and enforces activation rules so certain net-status infomodes that render on the road surface do not activate simultaneously.
Fields
-
public NetStatusType m_Type
Specifies which network status is visualized (an enum identifying the metric, e.g., flow, congestion, etc.). Used to initialize the InfoviewNetStatusData and to decide whether the visualization is considered visible on the road surface. -
public Bounds1 m_Range
Range used to map network metric values into the gradient (min/max mapping data). Stored into the InfoviewNetStatusData during Initialize. -
public float m_FlowSpeed
Controls the visual flow animation speed used by the infomode renderer. Propagated out via GetColors. -
public float m_FlowTiling
Tiling input for flow texture mapping. The prefab stores this as the reciprocal (1 / m_FlowTiling) when non-zero (both in Initialize — written to component.m_Tiling — and in GetColors). -
public float m_MinFlow
Minimum flow clamp used to compute a fill value; when non-zero it's converted to a reciprocal (1 / m_MinFlow) and returned by GetColors as fill.
Properties
public override string infomodeTypeLocaleKey { get; }
Returns the locale key for this infomode: "NetworkColor". This is used for UI localization/display name of the infomode.
Constructors
- (implicit)
public NetStatusInfomodePrefab()
No custom constructor is declared in the source; the default parameterless constructor is used.
Methods
-
public override void GetPrefabComponents(HashSet<ComponentType> components)
Adds required ECS component types to the provided set. Calls the base implementation and then addsComponentType.ReadWrite<InfoviewNetStatusData>()
. This tells the entity creation pipeline that the prefab will require an InfoviewNetStatusData component. -
public override void Initialize(EntityManager entityManager, Entity entity)
Called when the prefab is instantiated as an Entity. It: - Calls the base.Initialize.
- Constructs an InfoviewNetStatusData with m_Type and m_Range copied from the prefab fields.
- If m_FlowTiling != 0f, sets component.m_Tiling to 1f / m_FlowTiling.
-
Writes the InfoviewNetStatusData to the entity via entityManager.SetComponentData(entity, componentData).
-
public override bool CanActivateBoth(InfomodePrefab other)
Controls whether this infomode can be activated together with another infomode. If the other prefab is also a NetStatusInfomodePrefab and both this and the other are visible on the road surface (VisibleOnRoadSurface returns true), this method returns false to prevent both from activating at the same time. Otherwise, the base.CanActivateBoth(other) result is returned. -
public override void GetColors(out Color color0, out Color color1, out Color color2, out float steps, out float speed, out float tiling, out float fill)
Provides color and visualization parameters to the renderer. It: - Invokes the base.GetColors to fill default colors and parameters.
- Overrides speed with m_FlowSpeed.
- If m_FlowTiling != 0f, overrides tiling with 1f / m_FlowTiling.
-
If m_MinFlow != 0f, sets fill to 1f / m_MinFlow.
-
private bool VisibleOnRoadSurface()
Helper that determines whether this infomode type should be considered "visible on the road surface". Implementation checks the m_Type enum value and returns true when m_Type is in a small range (the code checks (uint)type <= 4u). This is used by CanActivateBoth to avoid overlapping road-surface visualizations.
Usage Example
// Simple usage example: configure an instance and read visualization parameters.
var prefab = new NetStatusInfomodePrefab
{
m_Type = NetStatusType.Flow, // example enum value
m_Range = new Bounds1(0f, 100f),
m_FlowSpeed = 2.0f,
m_FlowTiling = 0.5f,
m_MinFlow = 0.1f
};
prefab.GetColors(out Color color0, out Color color1, out Color color2,
out float steps, out float speed, out float tiling, out float fill);
Debug.Log($"Flow speed: {speed}, tiling: {tiling}, fill: {fill}");
// Expected: speed == 2.0f, tiling == 1 / 0.5f == 2.0f, fill == 1 / 0.1f == 10.0f
Notes and implementation details: - The prefab ensures the ECS component InfoviewNetStatusData is present and initializes it with the prefab values. That component is the runtime carrier of the data the renderer uses to display the network infomode. - Tiling and fill parameters are stored/supplied as reciprocals of the user-configured fields when those fields are non-zero — be aware of that inversion when authoring prefabs or reading values. - VisibleOnRoadSurface uses a numeric range check on the NetStatusType enum; if you extend or change NetStatusType, ensure any road-surface types are consistent with this logic or update VisibleOnRoadSurface accordingly.