Game.UI.InGame.DeathcareVehicleSection
Assembly:
Game (Game.dll)
Namespace:
Game.UI.InGame
Type:
class
Base:
VehicleSection
Summary:
DeathcareVehicleSection is a UI section class used by the in-game vehicle UI to display information for hearses and their target corpse (dead entity). It extends VehicleSection and adds logic to determine visibility for hearse vehicles, track the currently conveyed corpse (if any), and write corpse-related properties into a JSON writer for UI serialization. The class is marked CompilerGenerated and uses Preserve on runtime-facing methods/ctor to avoid stripping.
Fields
private Unity.Entities.Entity deadEntity { get; set; }
Holds the Entity id of the corpse currently being conveyed by the selected hearse, or Entity.Null when there is none. This is implemented as a private auto-property and is reset to Entity.Null by Reset().
Properties
protected override string group => "DeathcareVehicleSection"
Identifier for this UI section used by the VehicleSection base. The overridden getter returns the constant "DeathcareVehicleSection".
Constructors
public DeathcareVehicleSection()
Parameterless constructor. Marked with [Preserve] in the original source to ensure it is retained by linkers/strippers used in build pipelines.
Methods
-
protected override void Reset()
Resets transient state for the UI section. Calls base.Reset() then clears deadEntity by setting it to Entity.Null. -
private bool Visible()
Determines whether this section should be visible for the currently selected entity. Returns true only if: - the selected entity has a Vehicle component,
- the selected entity has a Hearse component,
-
and the selected entity has an Owner component. Otherwise returns false.
-
[Preserve] protected override void OnUpdate()
Called every UI update frame. Updates base.visible by calling Visible() so the section is shown/hidden dynamically depending on the selected entity and its components. -
protected override void OnProcess()
Main processing step before rendering/serializing the section. It: - Reads Hearse component data from the selected entity.
- Computes the section state key via VehicleUIUtils.GetStateKey(selectedEntity, componentData, base.EntityManager).
- If the vehicle state indicates the hearse is conveying (VehicleStateLocaleKey.Conveying), sets deadEntity to the hearse's target corpse (componentData.m_TargetCorpse); otherwise sets deadEntity to Entity.Null.
-
Calls base.OnProcess() to let VehicleSection perform its processing.
-
public override void OnWriteProperties(IJsonWriter writer)
Serializes properties relevant to the UI section into the provided JSON writer. Writes two properties: - "dead": if deadEntity == Entity.Null writes JSON null; otherwise delegates to m_NameSystem.BindName(writer, deadEntity) to write the corpse's display name.
- "deadEntity": writes JSON null if deadEntity == Entity.Null; otherwise writes the numeric entity id (deadEntity).
Notes on dependencies used in methods: - Relies on EntityManager (inherited from VehicleSection) to read component data and check for components. - Uses components: Vehicle, Hearse, Owner. - Uses helper VehicleUIUtils.GetStateKey(...) and VehicleStateLocaleKey.Conveying to determine conveying state. - Uses m_NameSystem.BindName(writer, deadEntity) to serialize the name of the dead entity.
Usage Example
// This class is instantiated and driven by the game's UI system.
// Example: how the section ensures visibility and writes corpse info.
[Preserve]
protected override void OnUpdate()
{
// Keep visibility in sync with selected entity components
base.visible = Visible();
}
// When the selected hearse is conveying, OnProcess will set deadEntity
// and OnWriteProperties will output the "dead" name and "deadEntity" id.
public override void OnWriteProperties(IJsonWriter writer)
{
base.OnWriteProperties(writer);
writer.PropertyName("dead");
if (deadEntity == Entity.Null)
{
writer.WriteNull();
}
else
{
m_NameSystem.BindName(writer, deadEntity);
}
writer.PropertyName("deadEntity");
if (deadEntity == Entity.Null)
{
writer.WriteNull();
}
else
{
writer.Write(deadEntity);
}
}
Additional implementation notes: - Reset() ensures no stale corpse reference is shown when selection changes. - The class is minimal and delegates most UI rendering and state handling to VehicleSection and shared utilities (VehicleUIUtils, m_NameSystem).