Game.InfomodePrefab
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: abstract class
Base: PrefabBase
Summary:
Base class for prefabs that participate in the game's "infomode" (colored overlay) system. Prefabs deriving from this class declare that they provide InfomodeData and can supply color and display parameters used by the infomode rendering. The class defines default behavior for color groups and activation rules; concrete prefabs should override the virtual methods to supply specific color values, grouping, and compatibility logic.
Fields
public int m_Priority
Priority value used by the infomode or prefab selection logic. Higher or lower meaning depends on how the system consumes this field; typically used to influence ordering/selection of which infomode takes precedence when multiple apply.
Properties
public virtual string infomodeTypeLocaleKey { get; }
Returns a localization key (default "ObjectColor") used to display the infomode type name in UI. Subclasses can override to provide a different locale key identifying the infomode category.
Constructors
public InfomodePrefab()
Default constructor for the abstract base. Concrete subclasses will be constructed by the prefab system; no special initialization is performed in the base.
Methods
public override void GetPrefabComponents(HashSet<ComponentType> components)
Adds required ECS component types for this prefab. The override calls the base implementation and then registersInfomodeData
(read/write) so the prefab entities include infomode information.
Parameters: - components: a HashSet to which this method should add all ComponentType entries the prefab requires.
public virtual void GetColors(out Color color0, out Color color1, out Color color2, out float steps, out float speed, out float tiling, out float fill)
Provides the infomode color palette and rendering parameters. The base implementation sets default values (default(Color) for colors, steps = 1, speed = 0, tiling = 0, fill = 0). Subclasses should override to supply meaningful colors and parameters.
Out parameters: - color0, color1, color2: main colors used by the infomode shader/palette. - steps: number of steps/levels in the palette (e.g., how many discrete color bands). - speed: animation speed for animated infomodes (if applicable). - tiling: texture tiling factor for the overlay. - fill: fill parameter controlling blending/intensity.
public virtual int GetColorGroup(out int secondaryGroup)
Returns the primary color group index used to group similar infomodes; also outputs an optional secondary group index via the out parameter. The default sets secondaryGroup to -1 and returns 2 (default primary group index). Override to return group indices meaningful to the prefab.
Returns: - primary group index (int). Out parameters: - secondaryGroup: secondary group index or -1 if not applicable.
public virtual bool CanActivateBoth(InfomodePrefab other)
Determines whether this infomode can be active simultaneously with another infomode prefab. Default implementation returns true (both can be active). Override to enforce mutual exclusion or compatibility rules between different infomode types.
Parameters: - other: the other InfomodePrefab being considered for simultaneous activation. Returns: - true if both can be active at the same time; false otherwise.
Usage Example
// Example subclass implementing specific infomode colors and grouping.
public class BuildingInfomodePrefab : InfomodePrefab
{
public override string infomodeTypeLocaleKey => "BuildingColor";
public override void GetPrefabComponents(HashSet<ComponentType> components)
{
base.GetPrefabComponents(components);
// add other required components for this prefab type if needed
}
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)
{
color0 = new Color(0.2f, 0.6f, 1f); // primary blue
color1 = new Color(0.1f, 0.3f, 0.8f); // secondary
color2 = new Color(0f, 0f, 0f); // unused
steps = 4f;
speed = 0.5f;
tiling = 1f;
fill = 0.8f;
}
public override int GetColorGroup(out int secondaryGroup)
{
secondaryGroup = 5;
return 1;
}
public override bool CanActivateBoth(InfomodePrefab other)
{
// Example: don't allow activation with traffic infomode prefabs
return other is not TrafficInfomodePrefab;
}
}