5 [
Attribute(
"5",
UIWidgets.Slider,
"Maximum amount of individual cached Widgets per kind.")]
8 [
Attribute(
"{BF5FA7B21D658280}UI/layouts/HUD/InteractionSystem/ContextBasicInteractionBlip.layout",
UIWidgets.ResourceNamePicker,
"Layout",
"layout",
category:
"NearbyContextDisplay")]
14 [
Attribute(
"",
desc:
"SCR_NearbyContextCachingConfig Config that hold all the Widgets that will be cached.",
params:
"conf class=SCR_NearbyContextCachingConfig")]
17 [
Attribute(
"0.2",
desc:
"Minimum Opacity of the Blip Widget when calculating Opacity based on distance to Camera.")]
31 private ref array<Widget> m_aWidgets = {};
33 private int m_iVisibleWidgets;
35 private float m_fOriginalSizeX;
37 private float m_fOriginalSizeY;
62 int widgetsCount = m_aWidgets.Count();
63 for (
int i = widgetsCount-1; i >= 0; i--)
66 m_aWidgets[i].RemoveFromHierarchy();
77 Print(
"The SCR_NearbyContextDisplay root is NULL, the pre-cached SCR_NearbyContextDisplay widgets cannot be re-rooted!",
LogLevel.ERROR);
84 foreach (
Widget w : m_aWidgets)
102 Print(
"Interaction handler component could not be found! SCR_NearbyContextDisplay will not work.",
LogLevel.WARNING);
110 if (rsc && rsc.IsValid())
112 BaseContainer container = rsc.GetResource().ToBaseContainer();
130 data.GetPrecacheAmount(precacheAmount);
187 array<UserActionContext> contexts = {};
190 array<UserActionContext> additionalContexts = {};
195 contexts.Insert(ctx);
198 #ifdef DEBUG_ACTIONICONS
199 contexts.InsertAll(additionalContexts);
204 int cameraIndex = world.GetCurrentCameraId();
206 world.GetCamera(cameraIndex, mat);
207 vector referencePos = mat[3];
212 const float threshold = 0.25;
213 const float fovBase = 100;
217 CameraManager cameraManager =
GetGame().GetCameraManager();
220 CameraBase camera = cameraManager.CurrentCamera();
222 #ifdef DEBUG_NEARBY_CONTEXT_DISPLAY
224 PrintFormat(
"%1 [DisplayUpdate] None Projection",
this);
227 if (camera && camera.GetProjType() !=
CameraType.NONE)
228 zoom = fovBase /
Math.Max(camera.GetVerticalFOV(), 1);
233 float resX;
float resY;
234 GetGame().GetWorkspace().GetScreenSize(resX, resY);
251 SCR_NearbyContextColorsComponentInteract nearbyColors;
255 #ifdef DEBUG_ACTIONICONS
256 array<BaseUserAction> outActions = {};
265 if (currentContext == ctx)
272 #ifdef DEBUG_ACTIONICONS
273 if (ctx.GetActionsList(outActions) < 1)
276 entAction = outActions[0].GetOwner();
285 Print(
"DEBUG_ACTIONICONS:: No icons found for "+ baseAction);
288 currAction = ctx.GetAction(0);
301 if (!isOverrideEnabled && ctx.ShouldCheckLineOfSight() &&
IsObstructed(
position, referencePos, world, entAction))
307 array<Widget> mapWidgets;
322 if (!mapWidgets || mapWidgets.IsEmpty())
327 foreach (
Widget w : mapWidgets)
349 if (!mapWidgets || mapWidgets.IsEmpty())
354 foreach (
Widget w : mapWidgets)
376 bool visible = ctx.IsInVisibilityAngle(referencePos);
419 array<Widget> cachedWidgets = {};
429 for (
int i = 0; i < amount; i++)
435 cachedWidgets.Insert(widgetToCache);
437 FrameSlot.SetAnchor(widgetToCache, 0, 0);
438 FrameSlot.SetAlignment(widgetToCache, 0.5, 0.5);
439 widgetToCache.SetVisible(
false);
443 m_aWidgets.Insert(widgetToCache);
451 widgetToReturn = cachedWidgets[0];
463 SCR_NearbyContextCachingData
data;
469 data.GetMaxCacheAmount(maxCachedAmount);
471 count = cachedWidgets.Count();
473 if (count <= maxCachedAmount)
478 cachedWidget = cachedWidgets[
index];
480 if (cachedWidget && !cachedWidget.IsVisible())
482 cachedWidget.RemoveFromHierarchy();
483 cachedWidgets.Remove(
index);
511 if (parentEntityRay != parentEntityAct)
553 widget.SetOpacity(alpha);
565 vector screenPosition =
GetGame().GetWorkspace().ProjWorldToScreen(worldPosition, world, cameraIndex);
566 posX = screenPosition[0];
567 posY = screenPosition[1];
583 const float threshold = 0.25;
597 protected bool IsOnScreen(
float resX,
float resY,
float posX,
float posY)
599 if (posX > resX || posY > resY || posX < 0 || posY < 0)
614 float aspectRatio = resX / resY;
619 float xDistance =
Math.AbsFloat(posX - resX * 0.5) / resX * aspectRatio;
620 float yDistance =
Math.AbsFloat(posY - resY * 0.5) / resY;
623 return Math.Sqrt(
Math.Pow(xDistance, 2) +
Math.Pow(yDistance, 2));
ArmaReforgerScripted GetGame()
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Get all prefabs that have the spawner data
UI layouts Menus CleanSweep CleanSweepAreaSelection layout
SCR_CharacterCameraHandlerComponent m_CameraHandler
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
proto external IEntity GetOwner()
Returns the parent entity of this action.
proto external Managed FindComponent(typename typeName)
proto external BaseWorld GetWorld()
proto external IEntity GetRootParent()
Object holding reference to resource. In destructor release the resource.
bool IsObstructed(vector contextPos, vector cameraPos, BaseWorld world, notnull IEntity entAction)
float m_fInteractionDistance
Distance in meters in which a context can be interacted with. Defined in 'InteractionHandlerComponent...
ResourceName m_sDefaultIconImage
ChimeraCharacter m_Character
void CacheWidget(ResourceName layout, int amount, bool returnWidget=false, Widget widgetToReturn=null)
void ClearCachedWidgets()
float m_fContextCollectDistance
Distnace in meters in which contexts will be collected and visible to indicate a possible interaction...
int m_iMaxPrecachedWidgets
override void DisplayUpdate(IEntity owner, float timeSlice)
void ~SCR_NearbyContextDisplay()
Performs cleanup.
override void DisplayStartDraw(IEntity owner)
bool IsInLineOfSight(vector point, vector transform[4], float val)
ResourceName m_sCachingConfigResource
ref array< ref SCR_NearbyContextColorsComponentInteract > m_aNearbyWidgetColors
void SetVisibleWidgets()
Iterates through available precached widgets and leaves only provided count enabled.
static bool IsCharacter(notnull IEntity entity)
ref TraceParam m_RaycastParam
SCR_InteractionHandlerComponent m_InteractionHandlerComponent
Interaction handler attached to parent entity.
ref map< SCR_ENearbyInteractionContextColors, ref SCR_NearbyContextColorsComponentInteract > m_mCachedActionColors
Holds all the different cached id with the enum as key.
override void DisplayStopDraw(IEntity owner)
bool GetWorldToScreenPosition(BaseWorld world, int cameraIndex, vector worldPosition, out float posX, out float posY)
ref array< Widget > m_aCurrentlyUsedWidgets
bool IsOnScreen(float resX, float resY, float posX, float posY)
void SetWidgetAlpha(Widget widget, float distance, float limit)
ref SCR_NearbyContextCachingConfig m_CachingConfig
float GetDistanceFromScreenCenter(float resX, float resY, float posX, float posY)
override void DisplayInit(IEntity owner)
ref map< string, ref array< Widget > > m_mCachedWidgets
Holds all the different cached Widgets with the Layout GUID as key.
ResourceName m_sIconLayoutPath
ref array< SCR_NearbyContextCachingData > m_aConfigLayouts
void SetColorsData(map< SCR_ENearbyInteractionContextColors, ref SCR_NearbyContextColorsComponentInteract > cachedActionColors)
void ChangeVisibility(bool isInLineOfSight)
void UpdateColors(UserActionContext ctx, SCR_ENearbyInteractionContextColors nearbyColorState=UIConstants.NEARBY_INTERACTION_DEFAULT_STATE)
static bool IsHealingAction(BaseUserAction userAct)
UserActionContext GetAssignedContext()
Get the context that currently uses this Widget.
void OnAssigned(SCR_ActionContextUIInfo info, UserActionContext context)
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
proto void PrintFormat(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL, LogLevel level=LogLevel.NORMAL)
SCR_FieldOfViewSettings Attribute