Game.UI.Tooltip.TempExtractorTooltipSystem
Assembly: Assembly-CSharp
Namespace: Game.UI.Tooltip
Type: class
Base: TooltipSystemBase
Summary:
TempExtractorTooltipSystem is an ECS system that produces the tooltips shown by the Extractor tool. It inspects "Temp" building preview entities (extractor buildings / upgrades), reads prefab / lot / extractor area definitions and nearby natural resource data, and then composes tooltips informing the player about:
- whether the map feature required by the extractor (forest, ore, oil, fish, fertile land) is present in its extraction area,
- whether the local climate meets any temperature requirement for the resource,
- whether the city's production of the resource is in surplus or deficit (and shows the resource icon).
The system queries multiple other game systems (NaturalResourceSystem, ResourceSystem, CitySystem, ClimateSystem, PrefabSystem, SearchSystem, etc.) and combines spatial checks (circle vs cell map, quad tree search for trees) with prefab / extractor-area metadata to determine tooltip content.
Fields
-
private NaturalResourceSystem m_NaturalResourceSystem
System reference to query map natural resource data used to test ore/oil/fish/fertility cells. -
private ResourceSystem m_ResourceSystem
System reference used to resolve resource prefabs and resource metadata. -
private CitySystem m_CitySystem
Provides city-level data (used to read city modifiers buffer for resource amount modifiers). -
private IndustrialDemandSystem m_IndustrialDemandSystem
Used to obtain industrial consumption numbers to compute deficit/surplus. -
private CountCompanyDataSystem m_CountCompanyDataSystem
Used to obtain production numbers for resources (to compute surplus/deficit). -
private ClimateSystem m_ClimateSystem
Used to check average temperature against resource temperature requirements. -
private PrefabSystem m_PrefabSystem
Used to access prefab metadata and icons. -
private Game.Objects.SearchSystem m_SearchSystem
Provides a static search tree used by the tree iterator to detect wood (forest) inside a radius. -
private EntityQuery m_ErrorQuery
Query to detect Temp entities in error state; used to early-out if an error is present. -
private EntityQuery m_TempQuery
Query for Temp preview entities (building Temp components plus Building/Transform/PrefabRef/Placeholder etc.) that the system evaluates. -
private EntityQuery m_ExtractorParameterQuery
Query for extractor parameter data (used to require update if those prefabs change). -
private StringTooltip m_ResourceAvailable
Tooltip template shown when the required map feature is present. -
private StringTooltip m_ResourceUnavailable
Tooltip template shown when the required map feature is missing (warning color). -
private IntTooltip m_Surplus
Tooltip template for resource surplus (value, unit, icon). -
private IntTooltip m_Deficit
Tooltip template for resource deficit (value, unit, icon, shown as deficit). -
private StringTooltip m_ClimateAvailable
Tooltip template for climate requirement satisfied. -
private StringTooltip m_ClimateUnavailable
Tooltip template for climate requirement unsatisfied (warning color). -
private TypeHandle __TypeHandle
Compiler-generated struct holding ComponentLookup/TypeHandles used by the system (used by internal component access wrappers). -
private struct TreeIterator
Internal quad-tree iterator used to scan static scene tree objects to compute total wood amount in a circle (used to detect forest presence). -
private struct TypeHandle
Compiler-generated helper that caches ComponentLookup/BufferLookup/TypeHandle instances and exposes __AssignHandles to initialize them.
Properties
- None (this system exposes no public properties).
Constructors
public TempExtractorTooltipSystem()
Default constructor. The class is an ECS system; meaningful initialization happens in OnCreate.
Methods
-
protected override void OnCreate()
Initializes system references (GetOrCreateSystemManaged for several systems), prepares EntityQueries, and constructs tooltip templates (StringTooltip / IntTooltip instances). Calls RequireForUpdate(m_TempQuery) so the system updates only when there are relevant Temp entities. -
protected override void OnUpdate()
Main update logic. High-level flow: - Early exit if there is an Error Temp or if the city's CityModifier buffer cannot be read.
- Completes dependencies and reads NaturalResourceCell map data.
- Iterates all Temp preview entities from m_TempQuery; for each building/upgrade preview that is an extractor building it:
- Determines the extractor's allowed manufactured resource.
- Processes SubAreas (and upgrade variants) to find a matching extractor area / lot and computes the max radius or node extent.
- For each relevant area, uses either FindWoodResource (for forest) or FindResource (for cell map-based resources) to determine whether the required map feature is present.
- If any extractor preview required a feature and processing succeeded, it computes city-wide production/consumption for the resource and shows either a surplus or deficit tooltip (with the resource icon).
- Adds map-feature tooltip (available / missing) using either the resource icon (for some resources like Fish) or the map feature icon.
-
Adds climate requirement tooltip if the resource has a temperature requirement.
-
private bool FindWoodResource(Circle2 circle)
Uses TreeIterator and the SearchSystem's static quad-tree to sum nearby tree wood amounts inside the circle. Returns true if total wood amount > 0. Uses component lookups for Overridden, Transform, PrefabRef and TreeData. -
private bool FindResource(Circle2 circle, MapFeature requiredFeature, CellMapData<NaturalResourceCell> resourceMap, DynamicBuffer<CityModifier> cityModifiers)
Performs a tiled cell scan over the NaturalResourceCell map that fully or partly intersects the provided circle. For ore/oil it applies city modifiers (if present) and subtracts used counts. Returns true if any tested cell contains available amount of the required feature (> 0). -
private bool ProcessAreas(DynamicBuffer<Game.Areas.SubArea> subAreas, ComponentLookup<ExtractorAreaData> extractorAreaDatas, ComponentLookup<LotData> lotDatas, Resource extractedResource, ResourcePrefabs resourcePrefabs, ComponentLookup<ResourceData> resourceDatas, Transform transform, CellMapData<NaturalResourceCell> resourceMap, DynamicBuffer<CityModifier> cityModifiers, ref MapFeature requiredFeature, ref bool foundResource)
Iterates area entries to find matching extractor area / lot prefabs. For each matching area it computes maxRadius from LotData and requests the required MapFeature (via ExtractorCompanySystem.GetRequiredMapFeature). If a required feature exists, it creates a Circle2 with the lot radius and uses FindWoodResource or FindResource to test presence. Returns true if any valid area was found (even if feature not present); sets requiredFeature and foundResource accordingly. -
private bool ProcessAreaNodes(DynamicBuffer<Game.Areas.SubArea> subAreas, DynamicBuffer<SubAreaNode> subAreaNodeBuf, ComponentLookup<ExtractorAreaData> extractorAreaDatas, ComponentLookup<LotData> lotDatas, Resource extractedResource, ResourcePrefabs resourcePrefabs, ComponentLookup<ResourceData> resourceDatas, Transform transform, CellMapData<NaturalResourceCell> resourceMap, DynamicBuffer<CityModifier> cityModifiers, ref MapFeature requiredFeature, ref bool foundResource)
Similar to ProcessAreas but computes an effective radius from the maximum absolute coordinate among SubAreaNode positions (used for custom-shaped extraction areas). Then tests the area nodes against required features. -
private bool ShouldMapFeatureUseResourceIcon(Resource resource)
Small helper that returns true when the map-feature tooltip should use the resource icon instead of the map feature icon. Currently returns true for Resource.Fish only. -
private void __AssignQueries(ref SystemState state)
Compiler-generated method, called by OnCreateForCompiler to initialize queries. (Contains no runtime logic in the decompiled body beyond a temp builder dispose.) -
protected override void OnCreateForCompiler()
Compiler integration method: sets up queries and assigns component lookup handles via __TypeHandle.__AssignHandles. Called during system bootstrap setup in compiled code.
Usage Example
[Preserve]
protected override void OnCreate()
{
base.OnCreate();
// Example: system initializes references to other game systems and tooltip templates.
m_NaturalResourceSystem = base.World.GetOrCreateSystemManaged<NaturalResourceSystem>();
m_ResourceSystem = base.World.GetOrCreateSystemManaged<ResourceSystem>();
m_CitySystem = base.World.GetOrCreateSystemManaged<CitySystem>();
m_ClimateSystem = base.World.GetOrCreateSystemManaged<ClimateSystem>();
// Prepare queries for Temp preview entities:
m_TempQuery = GetEntityQuery(ComponentType.ReadOnly<Temp>(),
ComponentType.ReadOnly<Building>(),
ComponentType.ReadOnly<Transform>(),
ComponentType.ReadOnly<PrefabRef>(),
ComponentType.ReadOnly<Placeholder>(),
ComponentType.Exclude<Hidden>(),
ComponentType.Exclude<Deleted>());
// Prepare tooltip templates used later in OnUpdate
m_ResourceAvailable = new StringTooltip { path = "extractorMapFeatureAvailable" };
m_ResourceUnavailable = new StringTooltip { path = "extractorMapFeatureUnavailable", color = TooltipColor.Warning };
RequireForUpdate(m_TempQuery);
}
Notes for modders: - The system uses low-level ECS lookups and completes job dependencies in several places (CompleteDependency / dependencies.Complete). If you add expensive checks, prefer to schedule jobs rather than force main-thread completion where possible. - To add a new resource type or change how required MapFeature is resolved, update ExtractorCompanySystem.GetRequiredMapFeature and resource prefab / extractor area components; this system queries those components and will pick up changes automatically. - Forest detection uses the static SearchSystem quad-tree and TreeData.m_WoodAmount; modifying tree prefabs or wood calculation may require adapting TreeIterator logic. - This system reads NaturalResourceCell map data and uses cell-based intersection. Be mindful of CellMapSystem coordinate conventions when computing radii or offsets.