10 protected ref map<SCR_AIGroup, SCR_MapMarkerSquadLeader> m_mGroupMarkers =
new map<SCR_AIGroup, SCR_MapMarkerSquadLeader>();
14 void RegisterMarker(SCR_MapMarkerSquadLeader marker,
SCR_AIGroup group)
16 m_mGroupMarkers.Insert(group, marker);
22 m_mGroupMarkers.Remove(group);
27 protected void FocusCurrentSquad()
32 SCR_MapMarkerSquadLeader leaderEnt = m_mGroupMarkers.Get(m_bCurrentSquad);
35 vector wPos = leaderEnt.GetWorldPos();
38 SCR_MapEntity.GetMapInstance().WorldToScreen(wPos[0], wPos[2], screenX, screenY);
45 protected void UpdateToolEntryState()
58 protected void OnPlayableGroupCreated(
SCR_AIGroup group)
60 SCR_MapMarkerSquadLeader marker = SCR_MapMarkerSquadLeader.Cast(m_MarkerMgr.InsertDynamicMarker(
SCR_EMapMarkerType.SQUAD_LEADER, group));
64 marker.SetFaction(group.GetFaction());
65 RegisterMarker(marker, group);
70 protected void OnPlayableGroupRemoved(
SCR_AIGroup group)
72 SCR_MapMarkerSquadLeader marker = m_mGroupMarkers.Get(group);
74 m_MarkerMgr.RemoveDynamicMarker(marker);
76 UnregisterMarker(group);
81 protected void OnPlayerLeaderChanged(
int groupID,
int playerId)
83 SCR_AIGroup group = m_GroupsManager.FindGroup(groupID);
84 SCR_MapMarkerSquadLeader marker = m_mGroupMarkers.Get(group);
86 marker.SetPlayerID(playerId);
91 protected void OnPlayerAdded(
SCR_AIGroup group,
int playerId)
93 PlayerController playerController =
GetGame().GetPlayerController();
94 if (!playerController)
97 if (group.IsPlayerInGroup(playerController.GetPlayerId() == playerId))
99 m_bCurrentSquad = group;
100 UpdateToolEntryState();
102 SCR_MapMarkerSquadLeader marker = m_mGroupMarkers.Get(group);
104 marker.UpdatePlayerAffiliation();
110 protected void OnPlayerRemoved(
SCR_AIGroup group,
int playerId)
112 PlayerController playerController =
GetGame().GetPlayerController();
113 if (!playerController)
116 if (m_bCurrentSquad == group && group.IsPlayerInGroup(playerController.GetPlayerId() == playerId))
118 m_bCurrentSquad =
null;
119 UpdateToolEntryState();
121 SCR_MapMarkerSquadLeader marker = m_mGroupMarkers.Get(group);
123 marker.UpdatePlayerAffiliation();
129 protected void OnPlayerSpawned(
int playerId, IEntity player)
131 UpdateMarkerTarget(playerId);
136 protected void OnPlayerKilled(
int playerId, IEntity playerEntity, IEntity killerEntity, notnull
Instigator killer)
138 UpdateMarkerTarget(playerId);
143 protected void OnPlayerDeleted(
int playerId, IEntity player)
145 UpdateMarkerTarget(playerId);
150 protected void OnGroupCustomNameChanged(
SCR_AIGroup group)
152 SCR_MapMarkerSquadLeader marker = m_mGroupMarkers.Get(group);
154 marker.SetTextUpdate();
159 protected void UpdateMarkerTarget(
int playerID)
161 SCR_AIGroup group = m_GroupsManager.GetPlayerGroup(playerID);
162 if (!group || !group.IsPlayerLeader(playerID))
165 SCR_MapMarkerSquadLeader marker = m_mGroupMarkers.Get(group);
167 marker.SetPlayerID(playerID);
177 override void InitServerLogic()
179 super.InitServerLogic();
186 m_GroupsManager.GetOnPlayableGroupCreated().Insert(OnPlayableGroupCreated);
187 m_GroupsManager.GetOnPlayableGroupRemoved().Insert(OnPlayableGroupRemoved);
189 SCR_AIGroup.GetOnPlayerLeaderChanged().Insert(OnPlayerLeaderChanged);
191 gameMode.GetOnPlayerSpawned().Insert(OnPlayerSpawned);
192 gameMode.GetOnPlayerKilled().Insert(OnPlayerKilled);
193 gameMode.GetOnPlayerDeleted().Insert(OnPlayerDeleted);
197 override void InitClientLogic()
199 SCR_AIGroup.GetOnCustomNameChanged().Insert(OnGroupCustomNameChanged);
200 SCR_AIGroup.GetOnPlayerAdded().Insert(OnPlayerAdded);
201 SCR_AIGroup.GetOnPlayerRemoved().Insert(OnPlayerRemoved);
208 widgetComp.SetTextVisible(
false);
210 widgetComp.SetTextVisible(
true);
216 super.OnMapOpen(mapEnt, markerUIComp);
218 UpdateToolEntryState();
224 super.OnMapInit(mapEnt, markerUIComp);
230 m_ToolMenuEntry = toolMenu.RegisterToolMenuEntry(
"{3262679C50EF4F01}UI/Textures/Icons/icons_wrapperUI.imageset",
"squad", 20);