Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_MapMarkerEntity.c
Go to the documentation of this file.
1//------------------------------------------------------------------------------------------------
2[EntityEditorProps(category: "GameScripted/Markers")]
3class SCR_MapMarkerEntityClass : GenericEntityClass
4{
5 [Attribute(defvalue: "1", desc:"Update delay in seconds", params: "0 inf")]
6 protected float m_fUpdateDelayData;
7
8 //------------------------------------------------------------------------------------------------
10 {
11 return m_fUpdateDelayData;
12 }
13};
14
15//------------------------------------------------------------------------------------------------
19{
20 [RplProp(onRplName: "OnUpdateType")]
22
23 [RplProp()]
24 protected int m_iConfigID = -1; // config id used when marker of a single type has bigger amount of configuration options
25
26 [RplProp(condition: RplCondition.NoOwner, onRplName: "OnUpdatePosition")]
27 protected vector m_vPos;
28
29 [RplProp(onRplName: "OnUpdateVisibility")]
30 protected bool m_bIsGlobalVisible; // is this marker visible based on server main conditions, such as it having assigned target
31
32 protected bool m_bIsLocalVisible = true; // is this marker visible to the player based on custom local conditions
33 protected int m_iScreenX;
34 protected int m_iScreenY;
35 protected float m_fUpdateDelay = 1;
36 protected float m_fTimeTracker;
37
38 protected string m_sText;
40 protected string m_sIconName;
41 protected SCR_MapMarkerEntryDynamic m_ConfigEntry; // marker entry associated with this marker type
42
43 protected Widget m_wRoot;
46
47 // server side
48 protected IEntity m_Target;
49 protected Faction m_MarkerFaction; // if null, no streaming restrictions are applied
50
51 //------------------------------------------------------------------------------------------------
52 // RPL EVENTS
53 //------------------------------------------------------------------------------------------------
55 protected void OnUpdateType()
56 {
58 }
59
60 //------------------------------------------------------------------------------------------------
62 protected void OnUpdatePosition()
63 {}
64
65 //------------------------------------------------------------------------------------------------
67 protected void OnUpdateVisibility()
68 {
70 if (!mapEnt || !mapEnt.IsOpen() || mapEnt.GetMapUIComponent(SCR_MapMarkersUI) == null) // map not open or makers not enabled
71 return;
72
73 if (!IsVisible() && m_wRoot) // should not be visible
74 OnDelete();
75
76 if (IsVisible() && !m_wRoot) // should be visible
78 }
79
80 //------------------------------------------------------------------------------------------------
81 // API CLIENT
82 //------------------------------------------------------------------------------------------------
83 void SetLocalVisible(bool state)
84 {
85 m_bIsLocalVisible = state;
87 }
88
89 //------------------------------------------------------------------------------------------------
91 {
92 return m_eType;
93 }
94
95 //------------------------------------------------------------------------------------------------
97 {
98 return m_iConfigID;
99 }
100
101 //------------------------------------------------------------------------------------------------
102 void SetText(string text)
103 {
104 m_sText = text;
105 }
106
107 //------------------------------------------------------------------------------------------------
108 string GetText()
109 {
110 return m_sText;
111 }
112
113 //------------------------------------------------------------------------------------------------
114 void SetImage(string imageset, string icon)
115 {
116 m_sImageset = imageset;
117 m_sIconName = icon;
118 }
119
120 //------------------------------------------------------------------------------------------------
121 void GetImageResource(out ResourceName imageset, out string imageQuad)
122 {
123 imageset = m_sImageset;
124 imageQuad = m_sIconName;
125 }
126
127 //------------------------------------------------------------------------------------------------
130 {
131 return m_vPos;
132 }
133
134 //------------------------------------------------------------------------------------------------
135 // API SERVER
136 //------------------------------------------------------------------------------------------------
137 void SetType(SCR_EMapMarkerType type, int configID = -1)
138 {
139 m_eType = type;
140 OnUpdateType();
141
142 if (configID != -1)
143 m_iConfigID = configID;
144
145 Replication.BumpMe();
146 }
147
148 //------------------------------------------------------------------------------------------------
149 void SetGlobalVisible(bool state)
150 {
151 m_bIsGlobalVisible = state;
153 Replication.BumpMe();
154 }
155
156 //------------------------------------------------------------------------------------------------
159 {
160 return m_Target;
161 }
162
163 //------------------------------------------------------------------------------------------------
165 void SetTarget(IEntity target)
166 {
167 m_Target = target;
168
169 if (target)
171 else
173 }
174
175 //------------------------------------------------------------------------------------------------
177 {
178 return m_MarkerFaction;
179 }
180
181 //------------------------------------------------------------------------------------------------
182 void SetFaction(Faction faction)
183 {
184 SCR_MapMarkerManagerComponent markerMgr = SCR_MapMarkerManagerComponent.GetInstance();
185 if (!markerMgr)
186 return;
187
188 m_MarkerFaction = faction;
189
190 markerMgr.SetMarkerStreamRules(this);
191 }
192
193 //------------------------------------------------------------------------------------------------
194 // EVENTS & OTHERS
195 //------------------------------------------------------------------------------------------------
196 protected bool IsVisible()
197 {
199 }
200
201 //------------------------------------------------------------------------------------------------
204 {
205 if (!IsVisible())
206 return;
207
208 if (!m_MapEntity)
210
211 if (!m_ConfigEntry)
212 m_ConfigEntry = SCR_MapMarkerEntryDynamic.Cast(SCR_MapMarkerManagerComponent.GetInstance().GetMarkerConfig().GetMarkerEntryConfigByType(m_eType));
213
214 if (!m_MapEntity || !m_ConfigEntry)
215 return;
216
217 Widget mapFrame = m_MapEntity.GetMapMenuRoot().FindAnyWidget(SCR_MapConstants.MAP_FRAME_NAME);
218 if (!mapFrame)
219 return;
220
221 m_wRoot = GetGame().GetWorkspace().CreateWidgets(m_ConfigEntry.GetMarkerLayout(), mapFrame);
222 if (!m_wRoot)
223 return;
224
226 m_MarkerWidgetComp.SetMarkerEntity(this); // todo needs base class
227 m_ConfigEntry.InitClientSettingsDynamic(this, m_MarkerWidgetComp);
228
231 OnMapLayerChanged(m_MapEntity.GetLayerIndex());
232 }
233
234 //------------------------------------------------------------------------------------------------
235 void OnDelete()
236 {
237 if (m_wRoot)
238 m_wRoot.RemoveFromHierarchy();
239 }
240
241 //------------------------------------------------------------------------------------------------
247
248 //------------------------------------------------------------------------------------------------
249 protected void OnMapLayerChanged(int layerID)
250 {
252 m_MarkerWidgetComp.SetLayerID(layerID);
253
254 LayerChangeLogic(layerID);
255 }
256
257 //------------------------------------------------------------------------------------------------
258 void LayerChangeLogic(int layerID)
259 {
261 m_ConfigEntry.OnMapLayerChangedDynamic(m_MarkerWidgetComp, layerID);
262 }
263
264 //------------------------------------------------------------------------------------------------
266 void OnUpdate()
267 {
268 if (!m_wRoot)
269 return;
270
271 m_MapEntity.WorldToScreen(m_vPos[0], m_vPos[2], m_iScreenX, m_iScreenY, true);
272 FrameSlot.SetPos(m_wRoot, GetGame().GetWorkspace().DPIUnscale(m_iScreenX), GetGame().GetWorkspace().DPIUnscale(m_iScreenY)); // needs unscaled coords
273 }
274
275 //------------------------------------------------------------------------------------------------
276 // OVERRIDES
277 //------------------------------------------------------------------------------------------------
278 override protected void EOnInit(IEntity owner)
279 {
280 SCR_MapMarkerManagerComponent markerMgr = SCR_MapMarkerManagerComponent.GetInstance();
281 if (!markerMgr)
282 return;
283
284 markerMgr.RegisterDynamicMarker(this);
285
286 BaseRplComponent rplComp = BaseRplComponent.Cast(FindComponent(BaseRplComponent));
287 if (rplComp.IsOwner()) // Only authority runs frame update
288 {
289 SetFlags(EntityFlags.ACTIVE, true);
291 }
292
294 if (markerEntityClass)
295 m_fUpdateDelay = markerEntityClass.GetUpdateDelay();
296
297 m_fTimeTracker = m_fUpdateDelay; // tick first update instantly
298 }
299
300 //------------------------------------------------------------------------------------------------
302 override protected void EOnFrame(IEntity owner, float timeSlice)
303 {
304 if (!m_Target)
305 return;
306
307 m_fTimeTracker += timeSlice;
309 {
310 m_fTimeTracker = 0;
311 m_vPos = m_Target.GetOrigin();
312 Replication.BumpMe();
313 }
314 }
315
316 //------------------------------------------------------------------------------------------------
318 {
320 }
321
322 //------------------------------------------------------------------------------------------------
324 {
326 OnDelete();
327
328 SCR_MapMarkerManagerComponent markerMgr = SCR_MapMarkerManagerComponent.GetInstance();
329 if (markerMgr)
330 markerMgr.UnregisterDynamicMarker(this);
331 }
332
333}
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_CacheNoteComponentClass ScriptComponentClass RplProp()] protected ref array< string > m_aLines
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
EDamageType type
SCR_EMapMarkerType
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
void IEntity(IEntitySource src, IEntity parent)
protected script Constructor
proto external EntityEvent SetEventMask(EntityEvent e)
proto external Managed FindComponent(typename typeName)
proto external EntityEvent ClearEventMask(EntityEvent e)
proto external EntityFlags SetFlags(EntityFlags flags, bool recursively=false)
proto external EntityPrefabData GetPrefabData()
Main replication API.
Definition Replication.c:14
static ScriptInvokerBase< MapConfigurationInvoker > GetOnMapClose()
Get on map close invoker.
static ScriptInvokerInt GetOnLayerChanged()
Get on layer changed invoker.
SCR_MapUIBaseComponent GetMapUIComponent(typename componentType)
bool IsOpen()
Check if the map is opened.
static SCR_MapEntity GetMapInstance()
Get map entity instance.
Attached to root of marker dynamic base layout.
SCR_EMapMarkerType GetType()
void GetImageResource(out ResourceName imageset, out string imageQuad)
void EOnFrame(IEntity owner, float timeSlice)
Authority side update.
void OnMapLayerChanged(int layerID)
void SetFaction(Faction faction)
void EOnInit(IEntity owner)
IEntity GetTarget()
Return entity this marker is tracking.
void SCR_MapMarkerEntity(IEntitySource src, IEntity parent)
SCR_MapMarkerEntryDynamic m_ConfigEntry
void OnUpdateType()
used client side for initial visibility set
void LayerChangeLogic(int layerID)
void SetTarget(IEntity target)
Set entity this marker is tracking.
void OnMapClosed(MapConfiguration config)
SCR_EMapMarkerType m_eType
void OnUpdatePosition()
for override within children classes
void OnUpdate()
Called from SCR_MapMarkerManagerComponent.
vector GetWorldPos()
Get world position coordinates.
void SetType(SCR_EMapMarkerType type, int configID=-1)
void SetLocalVisible(bool state)
void SetGlobalVisible(bool state)
void SetText(string text)
void OnCreateMarker()
Fetch marker definition from config & create widget.
SCR_MapMarkerDynamicWComponent m_MarkerWidgetComp
void SetImage(string imageset, string icon)
void OnUpdateVisibility()
Create or destroy marker widget based on current state.
Marker dynamic entry base.
Markers UI map component.
SCR_FieldOfViewSettings Attribute
EntityEvent
Various entity events.
Definition EntityEvent.c:14
EntityFlags
Various entity flags.
Definition EntityFlags.c:14
RplCondition
Conditional replication rule. Fine grained selection of receivers.