10 [
Attribute(
"{720E8E61D7692172}Configs/Map/MapMarkerConfig.conf", UIWidgets.ResourceNamePicker )]
11 protected ResourceName m_sMarkerCfgPath;
13 protected static SCR_MapMarkerManagerComponent
s_Instance;
72 if (w == marker.GetRootWidget())
86 if (markerID == marker.GetMarkerID())
101 if (
type == marker.GetType() && target == marker.GetTarget())
126 marker.SetType(
type);
127 marker.SetWorldPos(worldX, worldY);
128 marker.SetMarkerConfigID(configId);
130 if (factionFlags != 0)
131 marker.SetMarkerFactionFlags(factionFlags);
148 marker.OnCreateMarker();
155 marker.SetMarkerOwnerID(-1);
189 int factionID = militaryConfig.GetFactionEntryID(faction);
190 int dimensionID = militaryConfig.GetDimensionEntryID(dimension);
191 if (factionID == -1 || dimensionID == -1)
196 marker.SetMarkerConfigID(dimensionID * 100 + factionID);
197 marker.SetFlags(typeFlags);
217 Resource prefab = Resource.Load(cfgEntry.GetMarkerPrefab());
223 markerEnt.SetType(
type, configId);
224 markerEnt.SetTarget(entity);
234 if (marker.GetMarkerID() == -1)
241 if (marker.GetMarkerOwnerID() == -1)
243 if (!Replication.IsServer())
270 RplComponent.DeleteRplEntity(ent,
false);
276 if (!Replication.IsServer())
279 if (
m_iID ==
int.MAX)
284 marker.SetMarkerID(
m_iID);
294 RplComponent rplComponent = RplComponent.Cast(marker.FindComponent(RplComponent));
295 if (!rplComponent || !pController)
298 RplIdentity identity = pController.GetRplIdentity();
299 if (!identity.IsValid())
302 rplComponent.EnableStreamingConNode(identity, state);
304 if (identity == RplIdentity.Local())
305 marker.SetLocalVisible(!state);
314 array<int> players = {};
315 GetGame().GetPlayerManager().GetPlayers(players);
317 foreach (
int player : players)
319 Faction markerFaction = marker.GetFaction();
336 Faction markerFaction = dynamicMarker.GetFaction();
338 if (!markerFaction || markerFaction ==
SCR_FactionManager.SGetPlayerFaction(playerID))
359 PlayerController playerContr =
GetGame().GetPlayerController();
363 m_MarkerSyncComp = SCR_MapMarkerSyncComponent.Cast(playerContr.FindComponent(SCR_MapMarkerSyncComponent));
386 if (!marker.GetRootWidget())
387 marker.OnCreateMarker();
412 World world =
GetOwner().GetWorld();
417 markerSystem.Register(
this);
423 World world =
GetOwner().GetWorld();
428 markerSystem.Unregister(
this);
437 for (
int i = 0; i < count; i++)
450 markerEnt.OnUpdate();
462 DbgUI.Begin(
"Markers debug");
463 string dbg =
"disabled: %1 | static: %2 | dynamic: %3 ";
487 FactionManager factionManager =
GetGame().GetFactionManager();
489 if (System.IsConsoleApp())
491 marker.SetServerDisabled(
true);
493 else if (marker.GetMarkerFactionFlags() != 0 && factionManager)
496 bool isMyFaction = marker.IsFaction(factionManager.GetFactionIndex(localFaction));
498 if (!localFaction || !isMyFaction)
500 if (Replication.IsServer())
501 marker.SetServerDisabled(
true);
511 marker.OnCreateMarker();
544 [
RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
551 [
RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
573 for (
int i = 0; i < count; i++)
594 PlayerController playerController =
GetGame().GetPlayerManager().GetPlayerController(playerId);
595 SCR_MapMarkerSyncComponent markerSyncComp = SCR_MapMarkerSyncComponent.Cast(playerController.FindComponent(SCR_MapMarkerSyncComponent));
597 markerSyncComp.ClearOwnedMarkers();
601 override event protected bool RplSave(ScriptBitWriter writer)
607 writer.WriteInt(count);
613 if (marker.GetMarkerID() == -1)
619 writer.WriteInt(count);
623 if (marker.GetMarkerID() == -1)
627 marker.GetWorldPos(pos);
629 writer.WriteInt(pos[0]);
630 writer.WriteInt(pos[1]);
631 writer.WriteInt(marker.GetMarkerID());
632 writer.WriteInt(marker.GetMarkerOwnerID());
633 writer.WriteInt(marker.GetFlags());
634 writer.WriteInt(marker.GetMarkerConfigID());
635 writer.WriteInt(marker.GetMarkerFactionFlags());
636 writer.Write(marker.GetRotation(), 16);
637 writer.Write(marker.GetType(), 8);
638 writer.Write(marker.GetColorEntry(), 8);
639 writer.Write(marker.GetIconEntry(), 16);
640 writer.WriteString(marker.GetCustomText());
647 override event protected bool RplLoad(ScriptBitReader reader)
650 reader.ReadInt(count);
654 int posX, posY, markerID, markerOwnerID, flags, markerConfigID, factionFlags, markerType, colorID, iconID,
rotation;
658 for (
int i; i < count; i++)
661 reader.ReadInt(posX);
662 reader.ReadInt(posY);
663 reader.ReadInt(markerID);
664 reader.ReadInt(markerOwnerID);
665 reader.ReadInt(flags);
666 reader.ReadInt(markerConfigID);
667 reader.ReadInt(factionFlags);
669 reader.Read(markerType, 8);
670 reader.Read(colorID, 8);
671 reader.Read(iconID, 16);
672 reader.ReadString(customText);
675 marker.SetType(markerType);
676 marker.SetWorldPos(posX, posY);
677 marker.SetMarkerID(markerID);
678 marker.SetMarkerOwnerID(markerOwnerID);
679 marker.SetFlags(flags);
680 marker.SetMarkerConfigID(markerConfigID);
681 marker.SetMarkerFactionFlags(factionFlags);
683 marker.SetColorEntry(colorID);
684 marker.SetIconEntry(iconID);
685 marker.SetCustomText(customText);
694 override protected void EOnInit(IEntity owner)
698 array<ref SCR_MapMarkerEntryConfig> entryCfgs =
m_MarkerCfg.GetMarkerEntryConfigs();
705 entryDynamic.InitServerLogic();
707 entryDynamic.InitClientLogic();
726 Resource container = BaseContainerTools.LoadContainer(m_sMarkerCfgPath);
728 m_MarkerCfg = SCR_MapMarkerConfig.Cast(BaseContainerTools.CreateInstanceFromContainer(container.GetResource().ToBaseContainer()));
730 SetEventMask(owner, EntityEvent.INIT);