5 protected const int SERIALIZED_BYTES = 34;
9 protected int m_iMarkerID = -1;
10 protected int m_iConfigID = -1;
11 protected int m_iMarkerOwnerID = -1;
12 protected int m_iFlags;
13 protected int m_iPosWorldX;
14 protected int m_iPosWorldY;
15 protected int m_iFactionFlags;
16 protected int m_iColorEntry;
17 protected int m_iIconEntry;
18 protected int m_iRotation;
19 protected string m_sCustomText;
22 protected bool m_bIsServerSideDisabled;
25 protected bool m_bTestVisibleFrame =
true;
26 protected bool m_bIsUpdateDisabled;
27 protected bool m_bIsDragged;
28 protected int m_iScreenX;
29 protected int m_iScreenY;
32 protected Widget m_wRoot;
34 protected ref Color m_Color;
37 Widget GetRootWidget()
61 void SetMarkerID(
int id)
67 int GetMarkerConfigID()
73 void SetMarkerConfigID(
int id)
79 int GetMarkerOwnerID()
81 return m_iMarkerOwnerID;
85 void SetMarkerOwnerID(
int playerID)
87 m_iMarkerOwnerID = playerID;
97 void SetFlags(
int flags)
104 int GetMarkerFactionFlags()
106 return m_iFactionFlags;
111 void AddMarkerFactionFlags(
int flags)
116 int flag = Math.Pow(2, flags);
118 m_iFactionFlags |= flag;
123 void SetMarkerFactionFlags(
int flags)
125 m_iFactionFlags = flags;
130 bool IsFaction(
int factionID)
132 int flag = Math.Pow(2, factionID);
134 return (m_iFactionFlags & flag);
138 void GetWorldPos(out
int pos[2])
140 pos[0] = m_iPosWorldX;
141 pos[1] = m_iPosWorldY;
145 void SetWorldPos(
int posX,
int posY)
158 void SetRotation(
int angle)
166 return m_iColorEntry;
176 void SetColorEntry(
int colorEntry)
178 m_iColorEntry = colorEntry;
182 void SetIconEntry(
int iconEntry)
184 m_iIconEntry = iconEntry;
188 string GetCustomText()
190 return m_sCustomText;
194 void SetCustomText(
string text)
196 m_sCustomText = text;
201 void SetServerDisabled(
bool state)
203 m_bIsServerSideDisabled = state;
208 void SetUpdateDisabled(
bool state)
210 m_bIsUpdateDisabled = state;
218 void SetVisible(
bool state)
226 void SetDragged(
bool state)
233 bool TestVisibleFrame(vector visibleMin, vector visibleMax)
235 if( m_iPosWorldX < visibleMin[0]
236 || m_iPosWorldX > visibleMax[0]
237 || m_iPosWorldY < visibleMin[2]
238 || m_iPosWorldY > visibleMax[2])
244 SetUpdateDisabled(
false);
251 void OnCreateMarker()
253 if (m_bIsServerSideDisabled)
268 m_ConfigEntry = SCR_MapMarkerManagerComponent.GetInstance().GetMarkerConfig().GetMarkerEntryConfigByType(m_eType);
272 m_wRoot =
GetGame().GetWorkspace().CreateWidgets(m_ConfigEntry.GetMarkerLayout(), mapFrame);
277 m_MarkerWidgetComp.SetMarkerObject(
this);
278 m_ConfigEntry.InitClientSettings(
this, m_MarkerWidgetComp);
279 m_MarkerWidgetComp.SetRotation(m_iRotation);
294 protected void OnMapClosed(MapConfiguration config)
301 protected void OnMapLayerChanged(
int layerID)
303 if (m_MarkerWidgetComp)
304 m_MarkerWidgetComp.SetLayerID(layerID);
306 LayerChangeLogic(layerID);
310 void LayerChangeLogic(
int layerID)
312 if (m_ConfigEntry && m_MarkerWidgetComp)
313 m_ConfigEntry.OnMapLayerChanged(m_MarkerWidgetComp, layerID);
318 bool OnUpdate(vector visibleMin = vector.Zero, vector visibleMax = vector.Zero)
320 if (m_bIsServerSideDisabled || m_bIsDragged)
323 if (m_bTestVisibleFrame)
325 if ((m_iPosWorldX < visibleMin[0]) || (m_iPosWorldX > visibleMax[0]) || (m_iPosWorldY < visibleMin[2]) || (m_iPosWorldY > visibleMax[2]))
327 SetUpdateDisabled(
true);
332 m_MapEntity.WorldToScreen(m_iPosWorldX, m_iPosWorldY, m_iScreenX, m_iScreenY,
true);
333 FrameSlot.SetPos(m_wRoot,
GetGame().GetWorkspace().DPIUnscale(m_iScreenX),
GetGame().GetWorkspace().DPIUnscale(m_iScreenY));
339 static bool Extract(
SCR_MapMarkerBase instance, ScriptCtx ctx, SSnapSerializerBase snapshot)
341 snapshot.SerializeInt(instance.m_iPosWorldX);
342 snapshot.SerializeInt(instance.m_iPosWorldY);
343 snapshot.SerializeInt(instance.m_iMarkerID);
344 snapshot.SerializeInt(instance.m_iMarkerOwnerID);
345 snapshot.SerializeInt(instance.m_iFlags);
346 snapshot.SerializeInt(instance.m_iConfigID);
347 snapshot.SerializeInt(instance.m_iFactionFlags);
348 snapshot.SerializeBytes(instance.m_iRotation, 2);
349 snapshot.SerializeBytes(instance.m_eType, 1);
350 snapshot.SerializeBytes(instance.m_iColorEntry, 1);
351 snapshot.SerializeBytes(instance.m_iIconEntry, 2);
352 snapshot.SerializeString(instance.m_sCustomText);
357 static bool Inject(SSnapSerializerBase snapshot, ScriptCtx ctx,
SCR_MapMarkerBase instance)
359 snapshot.SerializeInt(instance.m_iPosWorldX);
360 snapshot.SerializeInt(instance.m_iPosWorldY);
361 snapshot.SerializeInt(instance.m_iMarkerID);
362 snapshot.SerializeInt(instance.m_iMarkerOwnerID);
363 snapshot.SerializeInt(instance.m_iFlags);
364 snapshot.SerializeInt(instance.m_iConfigID);
365 snapshot.SerializeInt(instance.m_iFactionFlags);
366 snapshot.SerializeBytes(instance.m_iRotation, 2);
367 snapshot.SerializeBytes(instance.m_eType, 1);
368 snapshot.SerializeBytes(instance.m_iColorEntry, 1);
369 snapshot.SerializeBytes(instance.m_iIconEntry, 2);
370 snapshot.SerializeString(instance.m_sCustomText);
375 static void Encode(SSnapSerializerBase snapshot, ScriptCtx ctx, ScriptBitSerializer packet)
377 snapshot.Serialize(packet, SERIALIZED_BYTES);
378 snapshot.EncodeString(packet);
382 static bool Decode(ScriptBitSerializer packet, ScriptCtx ctx, SSnapSerializerBase snapshot)
384 snapshot.Serialize(packet, SERIALIZED_BYTES);
385 snapshot.DecodeString(packet);
390 static bool SnapCompare(SSnapSerializerBase lhs, SSnapSerializerBase rhs , ScriptCtx ctx)
392 return lhs.CompareSnapshots(rhs, SERIALIZED_BYTES)
393 && lhs.CompareStringSnapshots(rhs);
397 static bool PropCompare(
SCR_MapMarkerBase instance, SSnapSerializerBase snapshot, ScriptCtx ctx)
399 return snapshot.CompareInt(instance.m_iPosWorldX)
400 && snapshot.CompareInt(instance.m_iPosWorldY)
401 && snapshot.CompareInt(instance.m_iMarkerID)
402 && snapshot.CompareInt(instance.m_iMarkerOwnerID)
403 && snapshot.CompareInt(instance.m_iFlags)
404 && snapshot.CompareInt(instance.m_iConfigID)
405 && snapshot.CompareInt(instance.m_iFactionFlags)
406 && snapshot.Compare(instance.m_iRotation, 2)
407 && snapshot.Compare(instance.m_eType, 1)
408 && snapshot.Compare(instance.m_iColorEntry, 1)
409 && snapshot.Compare(instance.m_iIconEntry, 2)
410 && snapshot.CompareString(instance.m_sCustomText);