4 protected string m_sNameTextWidgetName;
6 [
Attribute(defvalue:
"#AR-Editor_PlayerVehicle_Name")]
7 protected string m_sVehicleNameText;
9 protected RichTextWidget m_wNameTextWidget;
11 protected SCR_EditableVehicleComponent m_VehicleComponent;
12 protected SCR_EditableCharacterComponent m_VehicleOwningPlayer;
13 protected BaseWorld m_World;
19 void DetermineNameVisibility()
21 if (!
m_World || !m_VehicleComponent || !m_VehicleOwningPlayer || !m_wNameTextWidget || !m_RenderFilter)
24 vector cameraMatrix[4];
25 vector playerPosition;
26 float playerMaxViewDistance = m_VehicleOwningPlayer.GetMaxDrawDistanceSq();
28 m_VehicleOwningPlayer.GetPos(playerPosition);
29 m_World.GetCurrentCamera(cameraMatrix);
31 float distanceSquared = vector.DistanceSq(playerPosition, cameraMatrix[3]);
33 if (distanceSquared < playerMaxViewDistance * m_RenderFilter.GetCameraDisCoef())
34 m_wNameTextWidget.SetVisible(
false);
36 m_wNameTextWidget.SetVisible(
true);
42 m_wNameTextWidget = RichTextWidget.Cast(
GetWidget().FindAnyWidget(m_sNameTextWidgetName));
43 if (!m_wNameTextWidget)
45 Print(
"SCR_VehicleEditableEntityUIComponent: Failed to find Name Widget: " + m_sNameTextWidgetName, LogLevel.ERROR);
63 if (!m_VehicleComponent)
65 m_VehicleComponent = SCR_EditableVehicleComponent.Cast(slot.GetEntity());
66 if (!m_VehicleComponent)
70 int playerID = m_VehicleComponent.GetPlayerID();
75 IEntity playerEntity = playerManager.GetPlayerControlledEntity(playerID);
77 m_VehicleOwningPlayer = SCR_EditableCharacterComponent.Cast(playerEntity.FindComponent(SCR_EditableCharacterComponent));
79 string playerName = playerManager.GetPlayerName(playerID);
80 int playerCount = m_VehicleComponent.GetPlayerCountInVehicle();
83 m_wNameTextWidget.SetTextFormat(m_sVehicleNameText, playerName, playerCount - 1);
85 m_wNameTextWidget.SetText(playerName);
89 override bool OnUpdate(Widget w)
92 GetGame().GetCallqueue().CallLater(DetermineNameVisibility, 0,
false);