Game.UI.InGame.ParkingSection
Assembly:
Assembly-CSharp (game code)
Namespace:
Game.UI.InGame
Type:
class ParkingSection
Base:
InfoSectionBase
Summary:
UI info section used by the in-game inspector to show parking-related information for the currently selected entity. It scans the selected entity and its sub-objects / sub-nets / sub-lanes to collect parking capacity, number of parked cars and the aggregated parking fee. The section is visible only when the selected entity has a Game.Buildings.ParkingFacility component. The class uses ECS EntityManager, DynamicBuffer types and component data to compute the values and exposes them via JSON serialization in OnWriteProperties.
Fields
- None (no explicit private fields declared in the source).
This class uses auto-properties and methods; state is kept in private auto-properties (see Properties).
Properties
-
protected override string group => "ParkingSection"
Identifies the UI group/name for this section. Overrides InfoSectionBase.group to return the literal "ParkingSection". -
private int parkingFee { get; set; }
Accumulated parking fee total across discovered parking lanes/garages. The value is summed while scanning lanes and later averaged by the number of lanes found (if any). -
private int parkedCars { get; set; }
Counter for currently parked cars found on lanes / in garage lanes while scanning the selected entity's structure. -
private int parkingCapacity { get; set; }
Computed parking capacity across lanes/garages. If a parking lane has a slot interval of 0f the implementation sets this to a sentinel negative value (-1000000) to indicate unknown/unbounded capacity; finally the capacity is clamped to be non-negative (0) in OnProcess unless that sentinel was set.
Constructors
public ParkingSection()
Default constructor. Marked with [Preserve] at the class-level (constructor is empty in source). Initializes the object; actual numeric fields are reset by Reset() when section is prepared.
Methods
-
protected override void Reset()
: System.Void
Resets internal counters (parkingFee, parkedCars, parkingCapacity) to 0. Called by the framework to initialize/clear the section state. -
private bool Visible()
: System.Boolean
Returns true when the currently selected entity has a Game.Buildings.ParkingFacility component. Used to decide whether the section should be shown. -
[Preserve] protected override void OnUpdate()
: System.Void
Sets base.visible based on Visible(). Called each update tick; ensures section visibility follows selection changes. -
protected override void OnProcess()
: System.Void
Main processing method that scans the selected entity for parking-related sub-objects. It: - Tries to get DynamicBuffer
, DynamicBuffer , and DynamicBuffer on the selected entity (if present) and delegates each to the corresponding CheckParkingLanes overload. - Keeps a laneCount used to average parkingFee (parkingFee /= laneCount if laneCount != 0).
-
Ensures parkingCapacity is non-negative (if negative sets to 0) after processing (except when sentinel value was intentionally set).
-
private void CheckParkingLanes(DynamicBuffer<Game.Objects.SubObject> subObjects, ref int laneCount)
: System.Void
Recursively examines SubObject entries: for each sub-object entity it attempts to retrieve SubLane and SubObject buffers and continues scanning those. -
private void CheckParkingLanes(DynamicBuffer<Game.Net.SubNet> subNets, ref int laneCount)
: System.Void
Iterates sub-nets and for each obtains its SubLane buffer and processes lanes. -
private void CheckParkingLanes(DynamicBuffer<Game.Net.SubLane> subLanes, ref int laneCount)
: System.Void
For each sub-lane entity: - If it has a Game.Net.ParkingLane component:
- Skips lanes marked as VirtualLane.
- Gets the lane's PrefabRef and Curve component and the LaneObject buffer.
- Reads ParkingLaneData from the prefab to determine slot interval.
- If slot interval != 0f, computes parking slot count via NetUtils.GetParkingSlotCount(componentData, component, componentData2) and accumulates into parkingCapacity. If slot interval == 0f sets parkingCapacity to -1000000 (sentinel).
- Counts parked cars by checking each LaneObject for a ParkedCar component.
- Adds component.m_ParkingFee to parkingFee and increments laneCount.
-
Else if it has a GarageLane component:
- Adds component2.m_VehicleCapacity to parkingCapacity.
- Adds component2.m_VehicleCount to parkedCars.
- Adds component2.m_ParkingFee to parkingFee and increments laneCount.
-
public override void OnWriteProperties(IJsonWriter writer)
: System.Void
Writes the parking properties to the provided JSON writer: - "parkedCars" : parkedCars
- "parkingCapacity" : parkingCapacity
Usage Example
[Preserve]
protected override void OnUpdate()
{
base.OnUpdate();
// Ensure UI section visibility follows whether the selected entity is a parking facility
base.visible = base.EntityManager.HasComponent<Game.Buildings.ParkingFacility>(selectedEntity);
}
Notes and implementation details: - The class relies on Unity.Entities (EntityManager, DynamicBuffer) and game component types such as Game.Net.ParkingLane, ParkingLaneData, GarageLane, ParkedCar, PrefabRef and Curve. - Parking slot counting delegates to NetUtils.GetParkingSlotCount when a valid slot interval is available. - The code treats a slot interval of 0f as a special case and sets parkingCapacity to a large negative sentinel (-1000000) to denote an indeterminate/unbounded state; OnProcess later clamps capacity to zero unless the sentinel is set (the sentinel handling may be domain-specific — review if you need a different representation). - The section aggregates parkingFee and divides by the number of lanes found to produce an average per-lane fee (if any lanes were discovered).