Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_MapMarkerManagerComponent.c
Go to the documentation of this file.
1[ComponentEditorProps(category: "GameScripted/GameMode/Components", description: "")]
5
8class SCR_MapMarkerManagerComponent : SCR_BaseGameModeComponent
9{
10 [Attribute("{720E8E61D7692172}Configs/Map/MapMarkerConfig.conf", UIWidgets.ResourceNamePicker )]
11 protected ResourceName m_sMarkerCfgPath;
12
13 protected static SCR_MapMarkerManagerComponent s_Instance;
14
15 protected ref array<ref SCR_MapMarkerBase> m_aStaticMarkers = {}; // local or replicated static markers, one time RPC call for sync
16 protected ref array<ref SCR_MapMarkerBase> m_aDisabledMarkers = {}; // disabled static markers
17 protected ref array<SCR_MapMarkerEntity> m_aDynamicMarkers = {}; // dynamically replicated markers
18
19 protected ref array<ref SCR_ScriptProfanityFilterRequestCallback> m_aProfanityCallbacks = {}; // profanity callbacks of markers
20
21 protected int m_iID; // server side only, unique id created for markers
22 protected vector m_vVisibleFrameMin; // screen coords of the visible frame in map - min point
23 protected vector m_vVisibleFrameMax; // screen coords of the visible frame in map - max point
25 protected SCR_MapMarkerSyncComponent m_MarkerSyncComp;
26 protected ref SCR_MapMarkerConfig m_MarkerCfg;
27
28 //------------------------------------------------------------------------------------------------
30 //------------------------------------------------------------------------------------------------
31
32 //------------------------------------------------------------------------------------------------
34 static SCR_MapMarkerManagerComponent GetInstance()
35 {
36 return s_Instance;
37 }
38
39 //------------------------------------------------------------------------------------------------
41 SCR_MapMarkerConfig GetMarkerConfig()
42 {
43 return m_MarkerCfg;
44 }
45
46 //------------------------------------------------------------------------------------------------
48 array<SCR_MapMarkerBase> GetStaticMarkers()
49 {
50 array<SCR_MapMarkerBase> output = {};
51 foreach (SCR_MapMarkerBase marker: m_aStaticMarkers)
52 {
53 output.Insert(marker);
54 }
55
56 return output;
57 }
58
59 //------------------------------------------------------------------------------------------------
61 array<SCR_MapMarkerBase> GetDisabledMarkers()
62 {
63 array<SCR_MapMarkerBase> output = {};
65 {
66 output.Insert(marker);
67 }
68
69 return output;
70 }
71
72 //------------------------------------------------------------------------------------------------
74 array<SCR_MapMarkerEntity> GetDynamicMarkers()
75 {
76 return m_aDynamicMarkers;
77 }
78
79 //------------------------------------------------------------------------------------------------
83 {
84 foreach ( SCR_MapMarkerBase marker : m_aStaticMarkers )
85 {
86 if (w == marker.GetRootWidget())
87 return marker;
88 }
89
90 return null;
91 }
92
93 //------------------------------------------------------------------------------------------------
97 {
98 foreach ( SCR_MapMarkerBase marker : m_aStaticMarkers )
99 {
100 if (markerID == marker.GetMarkerID())
101 return marker;
102 }
103
104 return null;
105 }
106
107 //------------------------------------------------------------------------------------------------
111 {
112 foreach (SCR_MapMarkerBase marker : m_aDisabledMarkers)
113 {
114 if (markerID == marker.GetMarkerID())
115 return marker;
116 }
117
118 return null;
119 }
120
121 //------------------------------------------------------------------------------------------------
126 {
127 foreach (SCR_MapMarkerEntity marker : m_aDynamicMarkers)
128 {
129 if (type == marker.GetType() && target == marker.GetTarget())
130 return marker;
131 }
132
133 return null;
134 }
135
136 //------------------------------------------------------------------------------------------------
138 //------------------------------------------------------------------------------------------------
139
140 //------------------------------------------------------------------------------------------------
148 void InsertStaticMarkerByType(SCR_EMapMarkerType type, int worldX, int worldY, bool isLocal, int configId = -1, int factionFlags = 0, bool isServerMarker = false)
149 {
150 if (!m_MarkerCfg)
151 return;
152
154 marker.SetType(type);
155 marker.SetWorldPos(worldX, worldY);
156 marker.SetMarkerConfigID(configId);
157
158 if (factionFlags != 0)
159 marker.SetMarkerFactionFlags(factionFlags);
160
161 InsertStaticMarker(marker, isLocal, isServerMarker);
162 }
163
164 //------------------------------------------------------------------------------------------------
169 void InsertStaticMarker(SCR_MapMarkerBase marker, bool isLocal, bool isServerMarker = false)
170 {
171 if (isLocal) // local
172 {
174 m_aStaticMarkers.Insert(marker);
175 marker.OnCreateMarker();
176 }
177 else
178 {
179 if (isServerMarker)
180 {
181 AssignMarkerUID(marker);
182 marker.SetMarkerOwnerID(-1);
183
184 OnAddSynchedMarker(marker); // add server side
185 OnAskAddStaticMarker(marker);
186 }
187 else
188 {
189 if (!m_MarkerSyncComp)
190 {
192 return;
193 }
194
195 m_MarkerSyncComp.AskAddStaticMarker(marker);
196 }
197 }
198 }
199
200 //------------------------------------------------------------------------------------------------
207 {
208 if (!m_MarkerCfg)
209 return null;
210
211 SCR_MapMarkerEntryMilitary militaryConfig = SCR_MapMarkerEntryMilitary.Cast(m_MarkerCfg.GetMarkerEntryConfigByType(SCR_EMapMarkerType.PLACED_MILITARY));
212 if (!militaryConfig)
213 return null;
214
215 // check whether the provided parameters are defined within marker config
216 int factionID = militaryConfig.GetFactionEntryID(faction);
217 int dimensionID = militaryConfig.GetDimensionEntryID(dimension);
218 if (factionID == -1 || dimensionID == -1)
219 return null;
220
222 marker.SetType(SCR_EMapMarkerType.PLACED_MILITARY);
223 marker.SetMarkerConfigID(dimensionID * 100 + factionID); // combination of faction and dimension id
224 marker.SetFlags(typeFlags);
225
226 return marker;
227 }
228
229 //------------------------------------------------------------------------------------------------
236 {
237 if (!m_pGameMode.IsMaster())
238 return null;
239
240 SCR_MapMarkerEntryDynamic cfgEntry = SCR_MapMarkerEntryDynamic.Cast(m_MarkerCfg.GetMarkerEntryConfigByType(type));
241 if (!cfgEntry)
242 return null;
243
244 Resource prefab = Resource.Load(cfgEntry.GetMarkerPrefab());
245
246 SCR_MapMarkerEntity markerEnt = SCR_MapMarkerEntity.Cast(GetGame().SpawnEntityPrefab(prefab, GetGame().GetWorld()));
247 if (!markerEnt)
248 return null;
249
250 markerEnt.SetType(type, configId);
251 markerEnt.SetTarget(entity);
252
253 return markerEnt;
254 }
255
256 //------------------------------------------------------------------------------------------------
260 {
261 if (marker.GetMarkerID() == -1) // local
262 {
263 marker.OnDelete();
264 m_aStaticMarkers.RemoveItem(marker);
265 }
266 else // synched
267 {
268 if (marker.GetMarkerOwnerID() == -1) // is server marker
269 {
270 if (!Replication.IsServer()) // cannot delete server makers from client
271 return;
272
275 }
276 else
277 {
278 if (!m_MarkerSyncComp)
279 {
281 return;
282 }
283
284 m_MarkerSyncComp.AskRemoveStaticMarker(marker.GetMarkerID());
285 }
286 }
287 }
288
289 //------------------------------------------------------------------------------------------------
293 {
294 if (!m_pGameMode.IsMaster())
295 return;
296
297 RplComponent.DeleteRplEntity(ent, false);
298 }
299
300 //------------------------------------------------------------------------------------------------
302 {
303 if (!Replication.IsServer())
304 return;
305
306 if (m_iID == int.MAX)
307 m_iID == 0;
308 else
309 m_iID++;
310
311 marker.SetMarkerID(m_iID);
312 }
313
314 //------------------------------------------------------------------------------------------------
319 protected void HandleStreamOut(SCR_MapMarkerEntity marker, PlayerController pController, bool state)
320 {
321 RplComponent rplComponent = RplComponent.Cast(marker.FindComponent(RplComponent));
322 if (!rplComponent || !pController)
323 return;
324
325 RplIdentity identity = pController.GetRplIdentity();
326 if (!identity.IsValid())
327 return;
328
329 rplComponent.EnableStreamingConNode(identity, state);
330
331 if (identity == RplIdentity.Local()) // if this is a hosted server, we cannot control visibilty through streaming, and so it has to be set manually
332 marker.SetLocalVisible(!state);
333 }
334
335 //------------------------------------------------------------------------------------------------
340 {
341 array<int> players = {};
342 GetGame().GetPlayerManager().GetPlayers(players);
343
344 foreach (int player : players)
345 {
346 Faction markerFaction = marker.GetFaction();
347
348 if (!markerFaction || markerFaction == SCR_FactionManager.SGetPlayerFaction(player))
349 HandleStreamOut(marker, GetGame().GetPlayerManager().GetPlayerController(player), false);
350 else
351 HandleStreamOut(marker, GetGame().GetPlayerManager().GetPlayerController(player), true);
352 }
353 }
354
355 //------------------------------------------------------------------------------------------------
359 void SetStreamRulesForPlayer(int playerID)
360 {
361 foreach (SCR_MapMarkerEntity dynamicMarker : m_aDynamicMarkers)
362 {
363 Faction markerFaction = dynamicMarker.GetFaction();
364
365 if (!markerFaction || markerFaction == SCR_FactionManager.SGetPlayerFaction(playerID))
366 HandleStreamOut(dynamicMarker, GetGame().GetPlayerManager().GetPlayerController(playerID), false);
367 else
368 HandleStreamOut(dynamicMarker, GetGame().GetPlayerManager().GetPlayerController(playerID), true);
369 }
370 }
371
372 //------------------------------------------------------------------------------------------------
375 void EnableUpdate(bool state)
376 {
377 if (state)
379 else
381 }
382
383 //------------------------------------------------------------------------------------------------
384 protected bool FindMarkerSyncComponent()
385 {
386 PlayerController playerContr = GetGame().GetPlayerController();
387 if (!playerContr)
388 return false;
389
390 m_MarkerSyncComp = SCR_MapMarkerSyncComponent.Cast(playerContr.FindComponent(SCR_MapMarkerSyncComponent));
392 return true;
393
394 return false;
395 }
396
397 //------------------------------------------------------------------------------------------------
401 void SetStaticMarkerDisabled(notnull SCR_MapMarkerBase marker, bool state)
402 {
403 if (state || marker.GetBlocked())
404 {
405 if (!m_aDisabledMarkers.Contains(marker))
406 {
407 m_aDisabledMarkers.Insert(marker);
408 m_aStaticMarkers.RemoveItem(marker);
409 }
410
411 marker.SetUpdateDisabled(true);
412 }
413 else
414 {
415 if (!m_aStaticMarkers.Contains(marker))
416 {
417 m_aStaticMarkers.Insert(marker);
418 m_aDisabledMarkers.RemoveItem(marker);
419 }
420
421 marker.SetUpdateDisabled(false);
422
423 if (!marker.GetRootWidget()) // happens when map is closed and widget ref is lost
424 marker.OnCreateMarker();
425 }
426 }
427
428 //------------------------------------------------------------------------------------------------
432 {
433 if (!m_aDynamicMarkers.Contains(markerEnt))
434 m_aDynamicMarkers.Insert(markerEnt);
435 }
436
437 //------------------------------------------------------------------------------------------------
441 {
442 if (m_aDynamicMarkers.Contains(markerEnt))
443 m_aDynamicMarkers.RemoveItem(markerEnt);
444 }
445
446 //------------------------------------------------------------------------------------------------
448 {
449 World world = GetOwner().GetWorld();
451 if (!markerSystem)
452 return;
453
454 markerSystem.Register(this);
455 }
456
457 //------------------------------------------------------------------------------------------------
459 {
460 World world = GetOwner().GetWorld();
462 if (!markerSystem)
463 return;
464
465 markerSystem.Unregister(this);
466 }
467
468 //------------------------------------------------------------------------------------------------
469 void Update(float timeSlice)
470 {
472
473 for (int i = m_aStaticMarkers.Count() - 1; i >= 0; i--)
474 {
477 else
479 }
480
481 foreach (SCR_MapMarkerEntity markerEnt : m_aDynamicMarkers)
482 {
483 if (markerEnt)
484 markerEnt.OnUpdate();
485 }
486
487 #ifdef MARKERS_DEBUG
488 UpdateDebug(timeSlice);
489 #endif
490 }
491
492 #ifdef MARKERS_DEBUG
493 //------------------------------------------------------------------------------------------------
494 void UpdateDebug(float timeSlice)
495 {
496 DbgUI.Begin("Markers debug");
497 string dbg = "disabled: %1 | static: %2 | dynamic: %3 ";
498 DbgUI.Text( string.Format( dbg, m_aDisabledMarkers.Count(), m_aStaticMarkers.Count(), m_aDynamicMarkers.Count() ) );
499
500 /*string line = "name: %1 | distance: %2 | opacity base: %3 | opacity fade: %4 | %5";
501 foreach ( SCR_NameTagData tag : m_aNameTags )
502 {
503 DbgUI.Text( string.Format( line, tag.m_sName, (int)tag.m_fDistance, tag.m_fVisibleOpacity, tag.m_fOpacityFade, tag.m_NameTagWidget.GetOpacity() ));
504 }*/
505
506 DbgUI.End();
507 }
508 #endif
509
510 //------------------------------------------------------------------------------------------------
511 // EVENTS
512 //------------------------------------------------------------------------------------------------
513
514 //------------------------------------------------------------------------------------------------
519 {
520 m_aStaticMarkers.Insert(marker);
521 FactionManager factionManager = GetGame().GetFactionManager();
522
523 if (System.IsConsoleApp()) // on dedicated server markers are disabled
524 {
525 marker.SetServerDisabled(true);
526 }
527 else
528 {
529 if (marker.GetMarkerOwnerID() > -1)//player made marker
530 marker.RequestProfanityFilter();
531
532 if (factionManager && marker.GetMarkerFactionFlags() != 0)
533 {
534 Faction localFaction = SCR_FactionManager.SGetLocalPlayerFaction();
535 bool isMyFaction = marker.IsFaction(factionManager.GetFactionIndex(localFaction));
536
537 // faction is set but it is different from marker's faction - client or host
538 // if localFaction is null, we show marker
539 if (localFaction && !isMyFaction)
540 {
541 m_aStaticMarkers.RemoveItem(marker);
542 return;
543 }
544 }
545 }
546
548 if (mapEnt.IsOpen() && mapEnt.GetMapUIComponent(SCR_MapMarkersUI))
549 marker.OnCreateMarker(true);
550
552 }
553
554 //------------------------------------------------------------------------------------------------
558 void OnRemoveSynchedMarker(int markerID)
559 {
560 SCR_MapMarkerBase marker = GetStaticMarkerByID(markerID);
561 if (marker)
562 {
563 m_aStaticMarkers.RemoveItem(marker);
564 }
565 else
566 {
567 marker = GetDisabledMarkerByID(markerID);
568 if (!marker)
569 return;
570
571 m_aDisabledMarkers.RemoveItem(marker);
572 }
573
574 marker.OnDelete();
575 }
576
577 //------------------------------------------------------------------------------------------------
581 {
582 Rpc(RPC_DoAddStaticMarker, markerData);
583 }
584
585 //------------------------------------------------------------------------------------------------
588 void OnAskRemoveStaticMarker(int markerID)
589 {
590 Rpc(RPC_DoRemoveStaticMarker, markerID);
591 }
592
593 //------------------------------------------------------------------------------------------------
594 [RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
595 protected void RPC_DoAddStaticMarker(SCR_MapMarkerBase markerData)
596 {
597 OnAddSynchedMarker(markerData);
598 }
599
600 //------------------------------------------------------------------------------------------------
601 [RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
602 protected void RPC_DoRemoveStaticMarker(int markerID)
603 {
604 OnRemoveSynchedMarker(markerID);
605 }
606
607 //------------------------------------------------------------------------------------------------
612 void OnPlayerFactionChanged_S(int playerID, SCR_PlayerFactionAffiliationComponent playerComponent, Faction faction)
613 {
614 SetStreamRulesForPlayer(playerID);
615 }
616
617 //------------------------------------------------------------------------------------------------
618 protected void OnMapPanEnd(float x, float y)
619 {
620 m_MapEntity.UpdateViewPort();
622
623 for (int i = m_aDisabledMarkers.Count() - 1; i >= 0; i--)
624 {
627 }
628 }
629
630 //------------------------------------------------------------------------------------------------
632 {
633 SocialComponent sc = GetSocialComponent();
634 if (!sc || System.IsConsoleApp())
635 return;
636
637 for (int i = m_aStaticMarkers.Count() - 1; i >= 0; i--)
638 {
639 m_aStaticMarkers[i].SetBlocked(!sc.IsPrivilegedTo(EUserInteraction.UserGeneratedContent) || sc.IsRestricted(m_aStaticMarkers[i].GetMarkerOwnerID(), EUserInteraction.UserGeneratedContent));
641 }
642
643 for (int i = m_aDisabledMarkers.Count() - 1; i >= 0; i--)
644 {
645 m_aDisabledMarkers[i].SetBlocked(!sc.IsPrivilegedTo(EUserInteraction.UserGeneratedContent) || sc.IsRestricted(m_aDisabledMarkers[i].GetMarkerOwnerID(), EUserInteraction.UserGeneratedContent));
647 }
648 }
649
650 //------------------------------------------------------------------------------------------------
651 protected void OnMapOpen(MapConfiguration mapConfig)
652 {
653 m_MapEntity.UpdateViewPort();
654
656
657 for (int i = m_aDisabledMarkers.Count() - 1; i >= 0; i--)
658 {
660 }
661
663 }
664
665 //------------------------------------------------------------------------------------------------
666 protected SocialComponent GetSocialComponent()
667 {
668 PlayerController pc = GetGame().GetPlayerController();
669 if (!pc)
670 return null;
671
672 return SocialComponent.Cast(pc.FindComponent(SocialComponent));
673 }
674
675 //------------------------------------------------------------------------------------------------
676 // UTILITIES
677 //------------------------------------------------------------------------------------------------
678
679 //------------------------------------------------------------------------------------------------
681 {
682 if (text.IsEmpty())
683 return null;
684
685 return RequestProfanityFilter({text});
686 }
687
688 //------------------------------------------------------------------------------------------------
692 {
693 if (textsToFilter.IsEmpty())
694 return null;
695
697
698 if (!GetGame().GetPlatformService().FilterProfanityAsync(textsToFilter, profanityFilter))
699 return null;
700
701 m_aProfanityCallbacks.Insert(profanityFilter);
702
703 return profanityFilter;
704 }
705
706 //------------------------------------------------------------------------------------------------
707 protected void OnFilteredCallback(array<string> texts)
708 {
709 bool isPlatformXbox = GetGame().GetPlatformService().GetLocalPlatformKind() == PlatformKind.XBOX;
710
711 int i;
712 foreach (SCR_MapMarkerBase marker: m_aStaticMarkers)
713 {
714 if (marker.GetMarkerOwnerID() == -1)
715 continue;
716
717 if (!texts.IsIndexValid(i))
718 break;
719
720 if (isPlatformXbox)
721 {
722 string resultText;
723 SCR_ProfaneFilter.ReplaceProfanities(texts[i], resultText);
724 marker.SetCustomText(resultText);
725 }
726 else
727 {
728 marker.SetCustomText(texts[i]);
729 }
730
731 i++;
732 }
733 }
734
735 //------------------------------------------------------------------------------------------------
736 // OVERRIDES
737 //------------------------------------------------------------------------------------------------
738
739 //------------------------------------------------------------------------------------------------
740 override void OnPlayerDisconnected(int playerId, KickCauseCode cause, int timeout)
741 {
742 if (!m_pGameMode.IsMaster()) // server only
743 return;
744
745 PlayerController playerController = GetGame().GetPlayerManager().GetPlayerController(playerId);
746 SCR_MapMarkerSyncComponent markerSyncComp = SCR_MapMarkerSyncComponent.Cast(playerController.FindComponent(SCR_MapMarkerSyncComponent));
747 if (markerSyncComp)
748 markerSyncComp.ClearOwnedMarkers();
749 }
750
751 //------------------------------------------------------------------------------------------------
752 override event protected bool RplSave(ScriptBitWriter writer)
753 {
754 int count = 0;
755
756 // We want to replicate also the disabled markers to clients in the case of Listen server in coop missions
757 array<SCR_MapMarkerBase> markersSimple = GetStaticMarkers();
758 foreach(SCR_MapMarkerBase markerDis : GetDisabledMarkers())
759 {
760 markersSimple.Insert(markerDis);
761 }
762
763 if (markersSimple.IsEmpty())
764 {
765 writer.WriteInt(count);
766 return true;
767 }
768
769 foreach (SCR_MapMarkerBase marker : markersSimple)
770 {
771 if (marker.GetMarkerID() == -1)
772 continue;
773 else
774 count++;
775 }
776
777 writer.WriteInt(count);
778
779 WorldTimestamp timestamp;
780
781 foreach (SCR_MapMarkerBase marker : markersSimple)
782 {
783 if (marker.GetMarkerID() == -1)
784 continue;
785
786 int pos[2];
787 marker.GetWorldPos(pos);
788
789 writer.WriteInt(pos[0]);
790 writer.WriteInt(pos[1]);
791 writer.WriteInt(marker.GetMarkerID());
792 writer.WriteInt(marker.GetMarkerOwnerID());
793 writer.WriteInt(marker.GetFlags());
794 writer.WriteInt(marker.GetMarkerConfigID());
795 writer.WriteInt(marker.GetMarkerFactionFlags());
796 writer.Write(marker.GetRotation(), 16); // 2 bytes are enough
797 writer.Write(marker.GetType(), 8); // 1 byte is enough, not expected to go over 256 types
798 writer.Write(marker.GetColorEntry(), 8); // 1 byte is enough, no expected over 256 colors
799 writer.Write(marker.GetIconEntry(), 16); // 1 byte should be enough, leaving the extra byte to not underestimate modders
800 writer.WriteString(marker.GetCustomText());
801 writer.WriteBool(marker.IsTimestampVisible());
802 if (marker.IsTimestampVisible())
803 {
804 timestamp = marker.GetTimestamp();
805 writer.Write(timestamp, 64); // added timestamp
806 }
807 }
808
809 return true;
810 }
811
812 //------------------------------------------------------------------------------------------------
813 override event protected bool RplLoad(ScriptBitReader reader)
814 {
815 int count;
816 reader.ReadInt(count);
817 if (count == 0)
818 return true;
819
820 int posX, posY, markerID, markerOwnerID, flags, markerConfigID, factionFlags, markerType, colorID, iconID, rotation;
821 string customText;
822 bool isTimestampVisible;
823 WorldTimestamp timestamp;
824 SCR_MapMarkerBase marker;
825 array<string> textsToFilter = {};
826
827 for (int i; i < count; i++)
828 {
829 reader.ReadInt(posX);
830 reader.ReadInt(posY);
831 reader.ReadInt(markerID);
832 reader.ReadInt(markerOwnerID);
833 reader.ReadInt(flags);
834 reader.ReadInt(markerConfigID);
835 reader.ReadInt(factionFlags);
836 reader.Read(rotation, 16);
837 reader.Read(markerType, 8);
838 reader.Read(colorID, 8);
839 reader.Read(iconID, 16);
840 reader.ReadString(customText);
841 reader.ReadBool(isTimestampVisible);
842 if (isTimestampVisible)
843 reader.Read(timestamp, 64);
844
845 marker = new SCR_MapMarkerBase();
846 marker.SetType(markerType);
847 marker.SetWorldPos(posX, posY);
848 marker.SetMarkerID(markerID);
849 marker.SetMarkerOwnerID(markerOwnerID);
850 marker.SetFlags(flags);
851 marker.SetMarkerConfigID(markerConfigID);
852 marker.SetMarkerFactionFlags(factionFlags);
853 marker.SetRotation(rotation);
854 marker.SetColorEntry(colorID);
855 marker.SetIconEntry(iconID);
856 marker.SetCustomText(customText);
857
858 marker.SetTimestampVisibility(isTimestampVisible);
859 if (isTimestampVisible)
860 marker.SetTimestamp(timestamp);
861
862 m_aStaticMarkers.Insert(marker);
863 if (marker.GetMarkerOwnerID() > -1)
864 textsToFilter.Insert(marker.GetCustomText());
865 }
866
867 if (!textsToFilter.IsEmpty())
868 {
870 if (cb)
871 cb.m_OnResult.Insert(OnFilteredCallback);
872 }
873
874 return true;
875 }
876
877 //------------------------------------------------------------------------------------------------
880 void RegisterLocalController(notnull PlayerController playerController)
881 {
883 if (playerFactionAffiliation)
884 playerFactionAffiliation.GetOnFactionChanged().Insert(OnPlayerFactionChanged);
885 }
886
887 //------------------------------------------------------------------------------------------------
888 // run on proxy only, removes markers from array that are of different faction than player's
889 protected void RemoveMarkersOfOtherFactions(int factionIndexOfPlayer, notnull inout array<ref SCR_MapMarkerBase> markers)
890 {
892 for(int index = markers.Count() - 1; index >= 0; index --)
893 {
894 marker = markers[index];
895 if (!marker || marker.GetMarkerFactionFlags() == 0)
896 continue;
897
898 if (!marker.IsFaction(factionIndexOfPlayer)) // marker faction is not same as player faction
899 markers.Remove(index);
900 }
901 }
902
903 //------------------------------------------------------------------------------------------------
904 // run on proxy only
905 protected void OnPlayerFactionChanged(notnull FactionAffiliationComponent owner, Faction previousFaction, Faction newFaction)
906 {
907 // Note: we delete markers of different factions and thus if we change faction in runtime again, we might obtain incomplete list! TODO if it matters
908 FactionManager factionManager = GetGame().GetFactionManager();
909 if (!factionManager)
910 return;
911
912 int newFactionIndex = factionManager.GetFactionIndex(newFaction);
913
916 }
917
918 //------------------------------------------------------------------------------------------------
919 override protected void EOnInit(IEntity owner)
920 {
921 bool isMaster = m_pGameMode.IsMaster();
922
923 array<ref SCR_MapMarkerEntryConfig> entryCfgs = m_MarkerCfg.GetMarkerEntryConfigs();
924 foreach ( SCR_MapMarkerEntryConfig cfg : entryCfgs )
925 {
927 if (entryDynamic)
928 {
929 if (isMaster)
930 entryDynamic.InitServerLogic();
931
932 entryDynamic.InitClientLogic();
933 }
934 }
935
936 if (!isMaster) // init server logic below
937 return;
938
939 SCR_FactionManager mgr = SCR_FactionManager.Cast(GetGame().GetFactionManager());
940 if (mgr)
941 mgr.GetOnPlayerFactionChanged_S().Insert(OnPlayerFactionChanged_S);
942 }
943
944 //------------------------------------------------------------------------------------------------
945 override void OnPostInit(IEntity owner)
946 {
947 s_Instance = this;
949 m_MapEntity.GetOnMapPanEnd().Insert(OnMapPanEnd);
950 m_MapEntity.GetOnMapOpenComplete().Insert(OnMapOpen);
951
952 Resource container = BaseContainerTools.LoadContainer(m_sMarkerCfgPath);
953 if (container)
954 m_MarkerCfg = SCR_MapMarkerConfig.Cast(BaseContainerTools.CreateInstanceFromContainer(container.GetResource().ToBaseContainer()));
955
956 SetEventMask(owner, EntityEvent.INIT);
957 }
958
959 //------------------------------------------------------------------------------------------------
960 // destructor
962 {
963 s_Instance = null;
964 }
965}
SCR_EAIThreatSectorFlags flags
EMilitarySymbolIdentity
EMilitarySymbolDimension
EMilitarySymbolIcon
ArmaReforgerScripted GetGame()
Definition game.c:1398
PlatformKind
Definition PlatformKind.c:8
override bool RplLoad(ScriptBitReader reader)
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
void UpdateDebug()
SCR_BaseGameModeComponentClass m_pGameMode
The game mode entity this component is attached to.
void SCR_BaseGameModeComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
override bool RplSave(ScriptBitWriter writer)
void OnMapOpen(MapConfiguration config)
EDamageType type
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
void SCR_FactionManager(IEntitySource src, IEntity parent)
void OnMapPanEnd(float x, float y)
SCR_MapEntity m_MapEntity
SCR_EMapMarkerType
SCR_MapMarkerSyncComponent m_MarkerSyncComp
SocialComponent GetSocialComponent()
SCR_MapMarkerBase GetStaticMarkerByID(int markerID)
void OnPlayerFactionChanged_S(int playerID, SCR_PlayerFactionAffiliationComponent playerComponent, Faction faction)
void RemoveMarkersOfOtherFactions(int factionIndexOfPlayer, notnull inout array< ref SCR_MapMarkerBase > markers)
ref array< ref SCR_MapMarkerBase > m_aDisabledMarkers
void DisconnectFromMarkerManagerSystem()
SCR_MapMarkerConfig GetMarkerConfig()
void ConnectToMarkerManagerSystem()
void RegisterLocalController(notnull PlayerController playerController)
array< SCR_MapMarkerBase > GetDisabledMarkers()
void InsertStaticMarker(SCR_MapMarkerBase marker, bool isLocal, bool isServerMarker=false)
void CheckMarkersUserRestrictions()
SCR_MapMarkerEntity InsertDynamicMarker(SCR_EMapMarkerType type, IEntity entity, int configId=-1)
void HandleStreamOut(SCR_MapMarkerEntity marker, PlayerController pController, bool state)
void SetStreamRulesForPlayer(int playerID)
array< SCR_MapMarkerEntity > GetDynamicMarkers()
array< SCR_MapMarkerBase > GetStaticMarkers()
ref array< ref SCR_MapMarkerBase > m_aStaticMarkers
bool FindMarkerSyncComponent()
SCR_MapMarkerEntity GetDynamicMarkerByTarget(SCR_EMapMarkerType type, IEntity target)
void SetMarkerStreamRules(notnull SCR_MapMarkerEntity marker)
void OnRemoveSynchedMarker(int markerID)
void RegisterDynamicMarker(SCR_MapMarkerEntity markerEnt)
void ~SCR_MapMarkerManagerComponent()
ref SCR_MapMarkerConfig m_MarkerCfg
ref array< ref SCR_ScriptProfanityFilterRequestCallback > m_aProfanityCallbacks
SCR_MapMarkerBase GetMarkerByWidget(Widget w)
vector m_vVisibleFrameMin
void SetStaticMarkerDisabled(notnull SCR_MapMarkerBase marker, bool state)
void OnAskRemoveStaticMarker(int markerID)
vector m_vVisibleFrameMax
void OnAddSynchedMarker(SCR_MapMarkerBase marker)
SCR_MapMarkerBase GetDisabledMarkerByID(int markerID)
void AssignMarkerUID(SCR_MapMarkerBase marker)
void RemoveDynamicMarker(notnull SCR_MapMarkerEntity ent)
void UnregisterDynamicMarker(SCR_MapMarkerEntity markerEnt)
void InsertStaticMarkerByType(SCR_EMapMarkerType type, int worldX, int worldY, bool isLocal, int configId=-1, int factionFlags=0, bool isServerMarker=false)
SPAWN/REMOVE API.
void RPC_DoRemoveStaticMarker(int markerID)
SCR_MapMarkerBase PrepareMilitaryMarker(EMilitarySymbolIdentity faction, EMilitarySymbolDimension dimension, EMilitarySymbolIcon typeFlags)
void EnableUpdate(bool state)
ref array< SCR_MapMarkerEntity > m_aDynamicMarkers
SCR_ScriptProfanityFilterRequestCallback RequestProfanityFilter(string text)
void OnAskAddStaticMarker(SCR_MapMarkerBase markerData)
void RPC_DoAddStaticMarker(SCR_MapMarkerBase markerData)
void RemoveStaticMarker(SCR_MapMarkerBase marker)
void OnFilteredCallback(array< string > texts)
override void OnUpdate()
void OnPlayerFactionChanged(SCR_PlayerFactionAffiliationComponent component, Faction previous, Faction current)
proto external BaseWorld GetWorld()
Main replication API.
Definition Replication.c:14
Object holding reference to resource. In destructor release the resource.
Definition Resource.c:25
Replication connection identity.
Definition RplIdentity.c:14
SCR_MapUIBaseComponent GetMapUIComponent(typename componentType)
bool IsOpen()
Check if the map is opened.
static SCR_MapEntity GetMapInstance()
Get map entity instance.
void SetRotation(int angle)
void SetMarkerOwnerID(int playerID)
void SetColorEntry(int colorEntry)
void OnCreateMarker(bool skipProfanityFilter=false)
void SetMarkerFactionFlags(int flags)
Set faction flags directly without converting the faction indices.
bool IsFaction(int factionID)
Check whether the marker is one of the defined list of factions.
void SetIconEntry(int iconEntry)
void SetFlags(int flags)
void SetTimestamp(WorldTimestamp timestamp)
void SetMarkerConfigID(int id)
void SetCustomText(string text)
void SetType(SCR_EMapMarkerType type)
void SetMarkerID(int id)
void SetWorldPos(int posX, int posY)
void SetTimestampVisibility(bool isVisible)
int GetMarkerFactionFlags()
Get faction flags representing indices of factions within FactionManager prefab.
void RequestProfanityFilter()
Requests profanity filtering for the text of this marker.
void SetServerDisabled(bool state)
Disable marker UI display on server -> for dedicated servers(no UI) or hosted server enemy faction.
void SetTarget(IEntity target)
Set entity this marker is tracking.
void SetType(SCR_EMapMarkerType type, int configID=-1)
void SetLocalVisible(bool state)
Base entry config.
Marker dynamic entry base.
ResourceName GetMarkerPrefab()
override void InitServerLogic()
Override this to set up logic & event behavior on server.
Marker military symbol entry.
int GetDimensionEntryID(EMilitarySymbolDimension dimension)
int GetFactionEntryID(EMilitarySymbolIdentity faction)
void Register(SCR_MapMarkerManagerComponent component)
void Unregister(SCR_MapMarkerManagerComponent component)
Markers UI map component.
Handles filtering profanities in texts.
Definition World.c:16
IEntity GetOwner()
Owner entity of the fuel tank.
override void EOnInit(IEntity owner)
SCR_FieldOfViewSettings Attribute
EntityEvent
Various entity events.
Definition EntityEvent.c:14
RespawnSystemComponentClass GameComponentClass vector vector rotation
override void OnPlayerDisconnected(int playerId, KickCauseCode cause, int timeout)
proto external PlayerController GetPlayerController()
EUserInteraction
Interaction type between two players.
proto external int GetPlayerId()
void RplRpc(RplChannel channel, RplRcver rcver, RplCondition condition=RplCondition.None, string customConditionName="")
Definition EnNetwork.c:95
RplRcver
Definition RplRcver.c:59
RplChannel
Communication channel. Reliable is guaranteed to be delivered. Unreliable not.
Definition RplChannel.c:14
@ MAX