Zum Inhalt

hud_react_util

Quelle: base/tealdef/gui/hud/hud_react_util.d.tl

Hinweise

Helfer zum Einrichten von HUD-Icons in der 3D-Ansicht. Sie bauen und ändern Builtin.Type.VisibilityThresholds und liefern die Standard-Fangfaktoren der Linienansicht und die Icon-Versätze der Fahrzeuge pro Verkehrsträger.

HudReactUtil

record global base/tealdef/gui/hud/hud_react_util.d.tl:3

global record HudReactUtil

Laden: local hud_react_util = ug_require "::/gui/hud/hud_react_util.tl" as HudReactUtil

Hinweise

Helfer zum Bauen und Ändern der Builtin.Type.VisibilityThresholds. Sie legen fest, wann und in welcher Zeichenreihenfolge HUD-Icons erscheinen.

Details

Alle set*- und reset*-Funktionen geben ein neues Schwellenobjekt zurück und lassen die Eingabe unverändert. Das Ergebnis kommt in visibilityThresholds einer builtin.HudIconManagerConfig (siehe die Layer-Fenster in gui/layers).

Felder

Name Typ Beschreibung
DefaultVisDistDetailThreshold number Standard-Kameraentfernung (350), ab der eine Station ihr Haupt-Icon statt der Unter-Icons pro Terminal zeigt. Wird als detailsThreshold des Stationseintrags verwendet. 1-mal im Basisspiel verwendet
DefaultCameraHeightThreshold number Standardwert von cameraHeightThreshold der Sichtbarkeitsschwellen (150).
DefaultCameraHeightLowerCutoff number Standardwert von cameraHeightLowerCutoff der Sichtbarkeitsschwellen (30).
DefaultHudLodFarRangeThreshold number Standardwert von hudLodFarRangeThreshold der Sichtbarkeitsschwellen (3000).

Funktionen

convert the config formulated with lua tables into the actual userdata type

makeVisibilityThresholdsUserdata(visibilityThresholds : Builtin.Type.VisibilityThresholds) : Builtin.Type.VisibilityThresholds base/tealdef/gui/hud/hud_react_util.d.tl:10

Aufruf: hud_react_util.makeVisibilityThresholdsUserdata(…)

Die Spieldateien enthalten hierzu noch keine Beschreibung.

Rückgabe Builtin.Type.VisibilityThresholds

makeDefaultVisibilityThresholds() : Builtin.Type.VisibilityThresholds base/tealdef/gui/hud/hud_react_util.d.tl:12

Aufruf: hud_react_util.makeDefaultVisibilityThresholds(…)

Hinweise

Baut die Standard-Sichtbarkeitsschwellen des Basisspiels für HUD-Icons von Linien, Städten, Industrien, Lagerhäusern, Depots, Stationen, Signalen, Fahrzeugen, Sackgassen, Stadtgebäuden und Unterkonstruktionen.

Rückgabe Builtin.Type.VisibilityThresholds: Neue Builtin.Type.VisibilityThresholds-Userdata.

Details

Die scale-Werte pro Typ stammen aus HudGuiConfig.renderDistances. Die Reihenfolge zählt: Hat eine Entität mehrere Komponenten, gilt der erste passende Komponenteneintrag. Stadtgebiete sind standardmäßig ausgeblendet (detailsThreshold = -1 für SelectionDetails.Type.Town); siehe resetSubEntityThresholds.

Beispiel

local visibilityThresholds = hud_react_util.makeDefaultVisibilityThresholds()
-- show town districts as well (from gui/layers/layer_cargo_flow.tl)
visibilityThresholds = hud_react_util.resetSubEntityThresholds(visibilityThresholds, api.gui.SelectionDetails.Type.Town)
Im Basisspiel verwendet: 25-mal in 24 Dateien

base/content/game_mechanics/game_mechanics/emission/pollution_cleanup_facility_hud.script.tl:99

visibilityThresholds = hud_react_util.makeDefaultVisibilityThresholds(),
base/content/game_mechanics/game_mechanics/subventions/subventions_gui.tl:455
visibilityThresholds = hud_react_util.makeDefaultVisibilityThresholds(),
base/content/gui/gui/construction/construction_react_util.tl:1266
local visibilityThresholds = hud_react_util.makeDefaultVisibilityThresholds()
base/content/gui/gui/entity_window/industry/industry.tl:387
visibilityThresholds = hud_react_util.makeDefaultVisibilityThresholds(),
base/content/gui/gui/entity_window/line/line.tl:198
visibilityThresholds = hud_react_util.makeDefaultVisibilityThresholds(),
base/content/gui/gui/entity_window/maintenance_station/maintenance_station.tl:165
visibilityThresholds = hud_react_util.makeDefaultVisibilityThresholds(),
… und 18 weitere Dateien.

findSubEntityThresholds(thresholds : Builtin.Type.VisibilityThresholds, detailsType : api.gui.SelectionDetails.Type, makeIfNotExisting? : boolean) : Builtin.Type.VisibilityThresholds.OfSubEntity base/tealdef/gui/hud/hud_react_util.d.tl:14

Aufruf: hud_react_util.findSubEntityThresholds(…)

Hinweise

Sucht die Schwellen der Unterentitäten für einen Selection-Details-Typ.

Parameter Typ Beschreibung
thresholds Builtin.Type.VisibilityThresholds Zu durchsuchende Schwellen.
detailsType api.gui.SelectionDetails.Type Typ der Unterentität, etwa api.gui.SelectionDetails.Type.Station.
makeIfNotExisting? boolean Bei wahr kommt ein neues leeres OfSubEntity statt nil zurück, wenn es keinen Eintrag gibt.

Rückgabe Builtin.Type.VisibilityThresholds.OfSubEntity: Der Eintrag aus thresholds.forSubEntities (keine Kopie), ein neues leeres Objekt oder nil.

Im Basisspiel verwendet: 1-mal in 1 Datei

base/content/gui/gui/entity_window/station_group/station_group.tl:932

local stationDetailsThresholds = hud_react_util.findSubEntityThresholds(visibilityThresholds, api.gui.SelectionDetails.Type.Station, true)

setSubEntityThresholds(thresholds : Builtin.Type.VisibilityThresholds, detailsType : api.gui.SelectionDetails.Type, value : Builtin.Type.VisibilityThresholds.OfSubEntity) : Builtin.Type.VisibilityThresholds base/tealdef/gui/hud/hud_react_util.d.tl:19

Aufruf: hud_react_util.setSubEntityThresholds(…)

Hinweise

Gibt eine Kopie der Schwellen zurück, in der der Unterentitäts-Eintrag für detailsType durch value ersetzt ist.

Parameter Typ Beschreibung
thresholds Builtin.Type.VisibilityThresholds Zu kopierende Schwellen.
detailsType api.gui.SelectionDetails.Type Typ der Unterentität, deren Eintrag ersetzt wird.
value Builtin.Type.VisibilityThresholds.OfSubEntity Neue Schwellen der Unterentität.

Rückgabe Builtin.Type.VisibilityThresholds: Neues Schwellenobjekt.

Details

Ist forSubEntities nicht gesetzt, entsteht eine Liste nur mit dem neuen Eintrag. Gibt es die Liste, aber keinen Eintrag für detailsType, wird kein Eintrag hinzugefügt.

Im Basisspiel verwendet: 1-mal in 1 Datei

base/content/gui/gui/entity_window/station_group/station_group.tl:934

visibilityThresholds = hud_react_util.setSubEntityThresholds(visibilityThresholds, api.gui.SelectionDetails.Type.Station, stationDetailsThresholds)

resetSubEntityThresholds(thresholds : Builtin.Type.VisibilityThresholds, detailsType : api.gui.SelectionDetails.Type) : Builtin.Type.VisibilityThresholds base/tealdef/gui/hud/hud_react_util.d.tl:24

Aufruf: hud_react_util.resetSubEntityThresholds(…)

Hinweise

Gibt eine Kopie der Schwellen zurück, in der der Unterentitäts-Eintrag für detailsType kein detailsThreshold hat. Haupt-Icon und Icons der Unterentitäten erscheinen dann gemeinsam.

Parameter Typ Beschreibung
thresholds Builtin.Type.VisibilityThresholds Zu kopierende Schwellen.
detailsType api.gui.SelectionDetails.Type Typ der Unterentität, etwa api.gui.SelectionDetails.Type.Town, um Stadtgebiete anzuzeigen.

Rückgabe Builtin.Type.VisibilityThresholds: Neues Schwellenobjekt. layer und physicsImpact des Eintrags bleiben erhalten.

Im Basisspiel verwendet: 4-mal in 4 Dateien

base/content/gui/gui/construction/construction_react_util.tl:1268

visibilityThresholds = hud_react_util.resetSubEntityThresholds(
base/content/gui/gui/entity_window/town/town.tl:1041
visibilityThresholds = hud_react_util.resetSubEntityThresholds(
base/content/gui/gui/layers/layer_cargo_flow.tl:322
visibilityThresholds = hud_react_util.resetSubEntityThresholds(
base/content/gui/gui/line_vehicle_mgmt/line_util.tl:1133
visibilityThresholds = hud_react_util.resetSubEntityThresholds(

setMainIconsLayer(thresholds : Builtin.Type.VisibilityThresholds, componentType : Engine.ComponentType, layer : integer) : Builtin.Type.VisibilityThresholds base/tealdef/gui/hud/hud_react_util.d.tl:29

Aufruf: hud_react_util.setMainIconsLayer(…)

Hinweise

Gibt eine Kopie der Schwellen zurück, in der die Haupt-Icons eines Komponententyps eine neue Zeichenreihenfolge layer haben.

Parameter Typ Beschreibung
thresholds Builtin.Type.VisibilityThresholds Zu kopierende Schwellen.
componentType Engine.ComponentType Komponententyp des zu ändernden Eintrags.
layer integer Neue Zeichenreihenfolge (kleiner wird weiter vorne gezeichnet).

Rückgabe Builtin.Type.VisibilityThresholds: Neues Schwellenobjekt. Die übrigen Werte des Eintrags bleiben erhalten.

Im Basisspiel verwendet: 1-mal in 1 Datei

base/content/gui/gui/line_vehicle_mgmt/line_util.tl:1144

visibilityThresholds = hud_react_util.setMainIconsLayer(

setSubAndMainIconsLayer(thresholds : Builtin.Type.VisibilityThresholds, componentType : Engine.ComponentType, detailsType : api.gui.SelectionDetails.Type, layer : integer) : Builtin.Type.VisibilityThresholds base/tealdef/gui/hud/hud_react_util.d.tl:34

Aufruf: hud_react_util.setSubAndMainIconsLayer(…)

Hinweise

Wie setMainIconsLayer, setzt denselben layer aber auch im Unterentitäts-Eintrag für detailsType.

Parameter Typ Beschreibung
thresholds Builtin.Type.VisibilityThresholds Zu kopierende Schwellen.
componentType Engine.ComponentType Komponententyp des zu ändernden Haupt-Icon-Eintrags.
detailsType api.gui.SelectionDetails.Type Typ der Unterentität des zu ändernden Unter-Icon-Eintrags.
layer integer Neue Zeichenreihenfolge (kleiner wird weiter vorne gezeichnet).

Rückgabe Builtin.Type.VisibilityThresholds: Neues Schwellenobjekt.

Im Basisspiel verwendet: 1-mal in 1 Datei

base/content/gui/gui/line_vehicle_mgmt/line_util.tl:1138

visibilityThresholds = hud_react_util.setSubAndMainIconsLayer(

findComponentEntityThresholds(thresholds : Builtin.Type.VisibilityThresholds, type : api.engine.ComponentType, makeIfNotExisting? : boolean) : Builtin.Type.VisibilityThresholds.OfComponent base/tealdef/gui/hud/hud_react_util.d.tl:41

Aufruf: hud_react_util.findComponentEntityThresholds(…)

Hinweise

Sucht den Schwelleneintrag für einen Komponententyp.

Parameter Typ Beschreibung
thresholds Builtin.Type.VisibilityThresholds Zu durchsuchende Schwellen.
type api.engine.ComponentType Komponententyp, etwa api.type.ComponentType.STATION_GROUP.
makeIfNotExisting? boolean Bei wahr kommt ein neues leeres OfComponent statt nil zurück, wenn es keinen Eintrag gibt.

Rückgabe Builtin.Type.VisibilityThresholds.OfComponent: Der Eintrag aus thresholds.forComponents (keine Kopie), ein neues leeres Objekt oder nil.

setComponentEntityThresholds(thresholds : Builtin.Type.VisibilityThresholds, type : api.engine.ComponentType, value : Builtin.Type.VisibilityThresholds.OfComponent) : Builtin.Type.VisibilityThresholds base/tealdef/gui/hud/hud_react_util.d.tl:46

Aufruf: hud_react_util.setComponentEntityThresholds(…)

Hinweise

Gibt eine Kopie der Schwellen zurück, in der der Eintrag für type durch value ersetzt ist.

Parameter Typ Beschreibung
thresholds Builtin.Type.VisibilityThresholds Zu kopierende Schwellen.
type api.engine.ComponentType Komponententyp, dessen Eintrag ersetzt wird.
value Builtin.Type.VisibilityThresholds.OfComponent Neue Schwellen der Komponente.

Rückgabe Builtin.Type.VisibilityThresholds: Neues Schwellenobjekt.

Details

Ersetzt nur einen vorhandenen Eintrag. Gibt es für den Komponententyp keinen, wird auch keiner hinzugefügt.

makeDefaultLineViewerSnapFactors() : LineViewerSnapFactors base/tealdef/gui/hud/hud_react_util.d.tl:56

Aufruf: hud_react_util.makeDefaultLineViewerSnapFactors(…)

Hinweise

Gibt die Standard-Fangfaktoren der Linienansicht zurück (view = 0.05, world = 10.0).

Rückgabe LineViewerSnapFactors

Im Basisspiel verwendet: 6-mal in 6 Dateien

base/content/gui/gui/entity_window/line/line.tl:173

local snapFactorRef = react.useRefLazy(function() : HudReactUtil.LineViewerSnapFactors return hud_react_util.makeDefaultLineViewerSnapFactors() end)
base/content/gui/gui/entity_window/station_group/station_group.tl:928
local snapFactorRef = react.useRefLazy(function() : HudReactUtil.LineViewerSnapFactors return hud_react_util.makeDefaultLineViewerSnapFactors() end)
base/content/gui/gui/entity_window/town/town.tl:1056
local snapFactorRef = react.useRefLazy(function() : HudReactUtil.LineViewerSnapFactors return hud_react_util.makeDefaultLineViewerSnapFactors() end)
base/content/gui/gui/entity_window/vehicle/vehicle.tl:565
local snapFactorRef = react.useRefLazy(function() : HudReactUtil.LineViewerSnapFactors return hud_react_util.makeDefaultLineViewerSnapFactors() end)
base/content/gui/gui/line_vehicle_mgmt/line_util.tl:1153
local snapFactor = hud_react_util.makeDefaultLineViewerSnapFactors()
base/content/gui/gui/statistics/statistics.tl:287
local snapFactorRef = react.useRefLazy(function() : HudReactUtil.LineViewerSnapFactors return hud_react_util.makeDefaultLineViewerSnapFactors() end)

makeVehicleIconOffsets(vehicleIconOffsets : {string : {number}}) : {Carrier : Vec3f} base/tealdef/gui/hud/hud_react_util.d.tl:58

Aufruf: hud_react_util.makeVehicleIconOffsets(…)

Hinweise

Wandelt HudGuiConfig.vehicleIconOffsets (Name des Verkehrsträgers zu {x, y, z}) in eine Tabelle um, deren Schlüssel Werte des Enums Carrier und deren Werte Vec3f sind.

Parameter Typ Beschreibung
vehicleIconOffsets {string : {number}} Versätze nach Name des Verkehrsträgers. Namen, die kein Wert des Enums Carrier sind, werden übersprungen.

Rückgabe {Carrier : Vec3f}: Versätze nach Wert von api.type.enum.Carrier, fertig für vehicleIconOffsets in der Konfiguration des HUD-Icon-Managers.

Im Basisspiel verwendet: 13-mal in 12 Dateien

base/content/game_mechanics/game_mechanics/subventions/subventions_gui.tl:442

local vehicleIconOffsets = hud_react_util.makeVehicleIconOffsets(hudGuiConfig.vehicleIconOffsets)
base/content/gui/gui/entity_window/industry/industry.tl:376
local vehicleIconOffsets = hud_react_util.makeVehicleIconOffsets(hudGuiConfig.vehicleIconOffsets)
base/content/gui/gui/entity_window/line/line.tl:184
local vehicleIconOffsets = hud_react_util.makeVehicleIconOffsets(hudGuiConfig.vehicleIconOffsets)
base/content/gui/gui/entity_window/maintenance_station/maintenance_station.tl:148
local vehicleIconOffsets = hud_react_util.makeVehicleIconOffsets(hudGuiConfig.vehicleIconOffsets)
base/content/gui/gui/entity_window/perk/perk.tl:180
local vehicleIconOffsets = hud_react_util.makeVehicleIconOffsets(hudGuiConfig.vehicleIconOffsets)
base/content/gui/gui/entity_window/station_group/station_group.tl:938
local vehicleIconOffsets = hud_react_util.makeVehicleIconOffsets(hudGuiConfig.vehicleIconOffsets)
… und 6 weitere Dateien.

HudReactUtil.LineViewerSnapFactors

record base/tealdef/gui/hud/hud_react_util.d.tl:52

record LineViewerSnapFactors

Hinweise

Fangfaktoren der Linienansicht. Sie gehen als maxSnapFactorView und maxSnapFactorWorld an die Konfiguration des Linien-Renderers (siehe gui/line_vehicle_mgmt/line_util.tl).

Im Basisspiel verwendet: 6-mal in 6 Dateien

base/content/gui/gui/entity_window/line/line.tl:173

local snapFactorRef = react.useRefLazy(function() : HudReactUtil.LineViewerSnapFactors return hud_react_util.makeDefaultLineViewerSnapFactors() end)
base/content/gui/gui/entity_window/station_group/station_group.tl:928
local snapFactorRef = react.useRefLazy(function() : HudReactUtil.LineViewerSnapFactors return hud_react_util.makeDefaultLineViewerSnapFactors() end)
base/content/gui/gui/entity_window/town/town.tl:1056
local snapFactorRef = react.useRefLazy(function() : HudReactUtil.LineViewerSnapFactors return hud_react_util.makeDefaultLineViewerSnapFactors() end)
base/content/gui/gui/entity_window/vehicle/vehicle.tl:565
local snapFactorRef = react.useRefLazy(function() : HudReactUtil.LineViewerSnapFactors return hud_react_util.makeDefaultLineViewerSnapFactors() end)
base/content/gui/gui/hud/hud_react_util.tl:375
hud_react_util.makeDefaultLineViewerSnapFactors = function() : HudReactUtil.LineViewerSnapFactors
base/content/gui/gui/statistics/statistics.tl:287
local snapFactorRef = react.useRefLazy(function() : HudReactUtil.LineViewerSnapFactors return hud_react_util.makeDefaultLineViewerSnapFactors() end)

Felder

Name Typ Beschreibung
view number Wert für maxSnapFactorView (Standard 0,05).
world number Wert für maxSnapFactorWorld (Standard 10,0).