Visualizers - giosuel/imperium GitHub Wiki

Insights API

Insights are a way to expose internal component values to the player at runtime. Registered insights for each object are listed in the object's insight panel. Insights support inheritance and polymorphism, meaning children of a component inherit the insights of their parent. If a child component registers an insight with a name of an insight that has already been registered in the parent, it gets overridden for that child component.

When active, insights panels are rendered as screen space overlays next to their corresponding game objects. Besides the insight list, they feature a title field, a subtitle field and an overlay that can be used to indicate the alive status of an object.

Working with Insights

To manage insights, you can use the function Imperium.API.Visualization.InsightsFor<EnemyAI>(). This function returns an InsightDefinition object, that can be used to register and unregister insights, set generators and config keys. All of these functions are chainable as shown in the example below.

Generators

Generators are functions that are provided by the developer that are used by the insight to get the title, subtitle, and more metadata properties of the component. Usually, the title (or name) is used for the object name (e.g. Entity Name) or the instance ID of the component or object.

Entity Insights of a Jester

Example

Imperium.API.Visualization.InsightsFor<EnemyAI>()
    .SetNameGenerator(entity => entity.entityInfo.entityName)
    .SetPersonalNameGenerator(entity => entity.entityInfo.entityName)
    .SetIsDeadGenerator(entity => entity.isEnemyDead)
    .SetPositionOverride(entity => entity.transform.position + Vector.up)
    .RegisterInsight("Health", entity => $"{entity.enemyHP} HP")
    .SetConfigKey("Entities");
⚠️ **GitHub.com Fallback** ⚠️