Game.UI.InGame.PostVehicleSection
Assembly:
Namespace: Game.UI.InGame
Type: class
Base: VehicleSection
Summary:
A UI section class used by the in-game vehicle UI to show information for postal vehicles (PostVan). This class determines whether the UI section should be visible for the currently selected entity and prepares the state key used by the base VehicleSection rendering logic. It relies on the ECS-style EntityManager to inspect entity components (Vehicle, PostVan, Owner). Methods marked with [Preserve] indicate they should not be stripped by Unity's code stripping.
Fields
- None
This type does not declare any instance fields. It relies on members inherited from VehicleSection (such as selectedEntity, stateKey, and visible) and on ECS component data accessed from the EntityManager.
Properties
protected override string group { get; }
Returns the group name for the UI section. In this class it returns the constant "PostVehicleSection". The group string is typically used by the UI system to identify/organize sections.
Constructors
public PostVehicleSection()
Default constructor. Marked with [Preserve] in the source for Unity code-stripping safety (the attribute is applied to the constructor in the source file).
Methods
private bool Visible()
Checks whether the UI section should be shown for the currently selected entity. It returns true only when:- The selected entity has a Vehicle component.
- The selected entity has a PostVan component.
-
The selected entity has an Owner component. If any of the above checks fails, the method returns false.
-
protected override void OnUpdate()
Unity/engine lifecycle hook for UI sections. This override sets the inherited visible flag to the result of Visible(). Marked with [Preserve] in the source to prevent stripping. -
protected override void OnProcess()
Called when the section is being processed (rendered/updated). This override: - Reads the PostVan component data for the selected entity via EntityManager.GetComponentData
(selectedEntity). - Computes a state key by calling VehicleUIUtils.GetStateKey(selectedEntity, componentData, EntityManager) and assigns it to the inherited stateKey field/property.
- Calls base.OnProcess() to let the base class perform its processing using the computed stateKey and visibility state.
Usage Example
// The class already implements the typical pattern for a specialized vehicle UI section.
// This snippet demonstrates how the class controls visibility and prepares state for the base UI.
[Preserve]
protected override void OnUpdate()
{
// Show this UI section only for entities that are vehicles, are PostVans and have an Owner.
base.visible = Visible();
}
protected override void OnProcess()
{
// Read PostVan data and compute a state key used by the base VehicleSection rendering logic.
PostVan componentData = base.EntityManager.GetComponentData<PostVan>(selectedEntity);
base.stateKey = VehicleUIUtils.GetStateKey(selectedEntity, componentData, base.EntityManager);
base.OnProcess();
}
Notes and modding tips: - The class uses an ECS-style EntityManager. When creating or testing entities, ensure the entity has the Vehicle, PostVan and Owner components for this UI section to appear. - The [Preserve] attribute is used to prevent Unity's managed code stripping from removing these methods; keep it if you subclass or copy this pattern into your own mod to avoid unexpected stripping. - VehicleUIUtils.GetStateKey(...) centralizes vehicle state-to-UI mapping. If you need custom state behavior for postal vehicles, consider extending or wrapping that utility.