Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_MapDescriptorManualCameraComponent.c
Go to the documentation of this file.
1 
4 [BaseContainerProps(), SCR_BaseManualCameraComponentTitle()]
6 {
7  [Attribute("0", UIWidgets.SearchComboBox, "Descriptor type.", enums: ParamEnumArray.FromEnum(EMapDescriptorType))]
8  protected EMapDescriptorType m_iBaseType;
9 
10  [Attribute(desc: "Quad name from imageset defined on MapWidget.")]
11  protected string m_sImageDef;
12 
13  [Attribute("0 0 0 1", desc: "Color of camera icon.")]
14  protected ref Color m_IconColor;
15 
16  [Attribute("0 0 0 0.2", desc: "Color of the view cone.")]
17  protected ref Color m_ViewConeColor;
18 
19  [Attribute("0.375", uiwidget: UIWidgets.Slider, "Icon size coefficient.", params: "0 1 0.125")]
20  protected float m_fIconScale;
21 
22  [Attribute("1000", desc: "Maximum length of the view cone (and also maximum distance of tracing method).")]
23  protected float m_fMaxViewConeLength;
24 
25  [Attribute("ManualCamera", desc: "Name of canvas widget in which view cone will be rendered.")]
26  protected string m_sMapCanvasWidgetName;
27 
28  protected SCR_MapEntity m_MapEntity;
29  protected ref MapItem m_MapItem;
30  protected CanvasWidget m_MapCanvas;
31  protected ref PolygonDrawCommand m_DrawLine = new PolygonDrawCommand();
32  protected ref array<ref CanvasWidgetCommand> m_MapDrawCommands = { m_DrawLine };
33 
34  protected WorkspaceWidget m_Workspace;
35  protected BaseWorld m_World;
36  protected ref TraceParam m_Trace = new TraceParam();
37 
38  //------------------------------------------------------------------------------------------------
44  void TraceScreenPos(float width, float height, out vector dir, out float traceCoef)
45  {
46  vector pos = m_Workspace.ProjScreenToWorldNative(width, height, dir, m_World);
47  dir *= m_fMaxViewConeLength;
48 
49  TraceParam trace = new TraceParam();
50  m_Trace.Start = pos;
51  m_Trace.End = pos + dir;
52 
53  traceCoef = Math.Max(m_World.TraceMove(m_Trace, null), traceCoef);
54  }
55 
56  //------------------------------------------------------------------------------------------------
57  override void EOnCameraFrame(SCR_ManualCameraParam param)
58  {
59  if (!m_MapEntity.IsOpen())
60  return;
61 
62  //--- Update icon position
63  m_MapItem.SetPos(param.transform[3][0], param.transform[3][2]);
64  m_MapItem.SetAngle(param.rotOriginal[0] + param.rotDelta[0]);
65 
66  //--- Initialize view cone canvas (must be done after the map was opened)
67  if (!m_MapCanvas && m_MapEntity.GetMapMenuRoot())
68  m_MapCanvas = CanvasWidget.Cast(m_MapEntity.GetMapMenuRoot().FindWidget(m_sMapCanvasWidgetName));
69 
70  if (!m_MapCanvas)
71  return;
72 
73  //--- Trace left and right side of the screen
74  int widthLeft = 0;
75  int widthRight = m_Workspace.GetWidth();
76  float height = m_Workspace.GetHeight() / 2;
77  float traceCoef;
78  vector dirLeft, dirRight;
79  TraceScreenPos(widthLeft, height, dirLeft, traceCoef);
80  TraceScreenPos(widthRight, height, dirRight, traceCoef);
81 
82  //--- Convert positions to map space
83  vector posCam = param.transform[3];
84  vector posLeft = posCam + dirLeft * traceCoef;
85  vector posRight = posCam + dirRight * traceCoef;
86 
87  int posCamX, posCamY, posLeftX, posLeftY, posRightX, posRightY;
88  float mapZoom = m_MapEntity.GetCurrentZoom();
89  m_MapEntity.WorldToScreenCustom(posCam[0], posCam[2], posCamX, posCamY, mapZoom, true);
90  m_MapEntity.WorldToScreenCustom(posLeft[0], posLeft[2], posLeftX, posLeftY, mapZoom, true);
91  m_MapEntity.WorldToScreenCustom(posRight[0], posRight[2], posRightX, posRightY, mapZoom, true);
92 
93  //--- Draw the view cone
94  m_DrawLine.m_Vertices = {posCamX, posCamY, posLeftX, posLeftY, posRightX, posRightY};
95  m_MapCanvas.SetDrawCommands(m_MapDrawCommands);
96  }
97 
98  //------------------------------------------------------------------------------------------------
99  override bool EOnCameraInit()
100  {
101  m_MapEntity = SCR_MapEntity.GetMapInstance();
102  if (!m_MapEntity)
103  return false;
104 
105  m_MapItem = m_MapEntity.CreateCustomMapItem();
106  m_MapItem.SetBaseType(m_iBaseType);
107  m_MapItem.SetImageDef(m_sImageDef);
108 
109  MapDescriptorProps props = m_MapItem.GetProps();
110  props.SetFrontColor(m_IconColor);
111  props.SetOutlineColor(Color.FromInt(Color.BLACK));
112  props.SetIconSize(1, m_fIconScale, m_fIconScale);
113  props.Activate(true);
114  m_MapItem.SetProps(props);
115 
116  m_DrawLine.m_iColor = m_ViewConeColor.PackToInt();
117 
118  m_Workspace = GetGame().GetWorkspace();
119  m_World = GetCameraEntity().GetWorld();
120  m_Trace = new TraceParam();
121  m_Trace.Flags = TraceFlags.WORLD | TraceFlags.OCEAN;
122 
123  return true;
124  }
125 
126  //------------------------------------------------------------------------------------------------
127  override void EOnCameraExit()
128  {
129  if (m_MapItem)
130  m_MapItem.Recycle();
131  }
132 }
m_MapEntity
protected SCR_MapEntity m_MapEntity
Definition: SCR_MapGadgetComponent.c:14
SCR_BaseManualCameraComponent
Parent class from which all SCR_ManualCamera components inherit.
Definition: SCR_BaseManualCameraComponent.c:5
m_MapItem
protected MapItem m_MapItem
Definition: SCR_CampaignMobileAssemblyStandaloneComponent.c:14
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
MapDescriptorProps
Definition: MapDescriptorProps.c:12
Attribute
typedef Attribute
Post-process effect of scripted camera.
MapItem
Definition: MapItem.c:12
m_Workspace
protected WorkspaceWidget m_Workspace
Definition: SCR_EntitiesEditorUIComponent.c:13
SCR_MapEntity
Map entity.
Definition: SCR_MapEntity.c:20
m_World
protected BaseWorld m_World
Definition: SCR_PreviewEntityEditorUIComponent.c:46
GetCameraEntity
protected SCR_ManualCamera GetCameraEntity()
Definition: SCR_BaseManualCameraComponent.c:59
SCR_ManualCameraParam
Parameter for carrying information between individual camera components.
Definition: SCR_ManualCameraParam.c:5
SCR_MapDescriptorManualCameraComponent
Camera representation in the map.
Definition: SCR_MapDescriptorManualCameraComponent.c:5
EMapDescriptorType
EMapDescriptorType
Definition: EMapDescriptorType.c:15
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
BaseContainerProps
SCR_AIGoalReaction_Follow BaseContainerProps
Handles insects that are supposed to be spawned around selected prefabs defined in prefab names array...
Definition: SCR_AIGoalReaction.c:468