4 [
Attribute(
"{7134157CA6B1FA8E}Configs/Notifications/Notifications.conf",
desc:
"Link to config that holds all notification data",
params:
"conf class=SCR_NotificationConfig")]
5 protected ResourceName m_sNotificationConfig;
7 protected ref map<ENotification, ref SCR_NotificationDisplayData> m_mNotificationDisplayDataMap =
new map<ENotification, ref SCR_NotificationDisplayData>();
19 if (m_mNotificationDisplayDataMap.Find(notificationID, notificationData))
20 return notificationData;
22 Print(
"Notification data not found in 'SCR_NotificationsComponent' for key: '" +
typename.EnumToString(
ENotification, notificationID) +
"'.", LogLevel.WARNING);
23 m_mNotificationDisplayDataMap.Find(
ENotification.UNKNOWN, notificationData);
25 return notificationData;
30 array<string> GetStickyNotifications()
32 return notificationConfig.GetStickyNotifications();
37 array<ref SCR_NotificationDisplayColor> GetNotificationDisplayColor()
39 return notificationConfig.GetNotificationDisplayColor();
49 if (!m_mNotificationDisplayDataMap.IsEmpty())
54 if (!notificationConfig)
56 Print(
"'SCR_NotificationsComponentClass' failed to load notifications config!", LogLevel.ERROR);
61 array<ref SCR_NotificationDisplayData>
data = {};
62 int count = notificationConfig.GetNotificationData(
data);
65 for(
int i = 0; i < count; i++)
67 if (!m_mNotificationDisplayDataMap.Contains(
data[i].m_NotificationKey))
68 m_mNotificationDisplayDataMap.Set(
data[i].m_NotificationKey,
data[i]);
70 Print(
"Notification data in 'SCR_NotificationsLogDisplay' has duplicate notification info key: '" +
typename.EnumToString(
ENotification,
data[i].m_NotificationKey) +
"'. There should only be one of each key!", LogLevel.WARNING);
78 protected ref array<ref SCR_NotificationData>
m_aHistory = {};
85 static const int NOTIFICATION_DELETE_TIME = 30;
88 static const int NOTIFICATION_HISTORY_LENGTH = 10;
110 outHistory.Insert(entry);
123 if (maxHistoryIndex > 0 && count > maxHistoryIndex)
124 count = maxHistoryIndex;
126 for (
int i = count -1; i >= 0; i--)
168 PlayerController playerController =
GetGame().GetPlayerController();
169 if (playerController)
170 return SCR_NotificationsComponent.Cast(playerController.FindComponent(SCR_NotificationsComponent));
185 static bool SendToEveryone(
ENotification notificationID,
int param1 = 0,
int param2 = 0,
int param3 = 0,
int param4 = 0,
int param5 = 0,
int param6 = 0)
187 return SendToEveryone(notificationID, vector.Zero, param1, param2, param3, param4, param5, param6);
201 static bool SendToEveryone(
ENotification notificationID, vector
position,
int param1 = 0,
int param2 = 0,
int param3 = 0,
int param4 = 0,
int param5 = 0,
int param6 = 0)
204 if (!Replication.IsServer())
207 if (!playerController)
210 SCR_NotificationsComponent notificationsComponent = SCR_NotificationsComponent.Cast(playerController.FindComponent(SCR_NotificationsComponent));
211 if (!notificationsComponent)
214 array<int> paramArray = {};
215 CreateParamArray(paramArray, param1, param2, param3, param4, param5, param6);
217 notificationsComponent.Rpc(notificationsComponent.Rpc_SendToEveryone, notificationID,
position, paramArray);
222 newNotificationData.SetParameters(
ENotificationReceiver.EVERYONE, param1, param2, param3, param4, param5, param6);
223 newNotificationData.SetPosition(
position);
224 return SendToEveryoneData(notificationID, newNotificationData);
229 [
RplRpc(RplChannel.Reliable, RplRcver.Server)]
232 int param1, param2, param3, param4, param5, param6;
233 GetParamsFromArray(paramArray, param1, param2, param3, param4, param5, param6);
235 SendToEveryone(notificationID,
position, param1, param2, param3, param4, param5, param6);
243 if (!Replication.IsServer())
246 array<int> players = {};
247 for (
int i = 0, count =
GetGame().GetPlayerManager().
GetPlayers(players); i < count; i++)
249 SendToPlayerData(players[i], notificationID,
data);
265 static bool SendToPlayer(
int playerID,
ENotification notificationID,
int param1 = 0,
int param2 = 0,
int param3 = 0,
int param4 = 0,
int param5 = 0,
int param6 = 0)
267 return SendToPlayer(playerID, notificationID, vector.Zero, param1, param2, param3, param4, param5, param6);
282 static bool SendToPlayer(
int playerID,
ENotification notificationID, vector
position,
int param1 = 0,
int param2 = 0,
int param3 = 0,
int param4 = 0,
int param5 = 0,
int param6 = 0)
285 if (!Replication.IsServer())
288 if (!playerController)
291 SCR_NotificationsComponent notificationsComponent = SCR_NotificationsComponent.Cast(playerController.FindComponent(SCR_NotificationsComponent));
292 if (!notificationsComponent)
295 array<int> paramArray = {};
296 CreateParamArray(paramArray, param1, param2, param3, param4, param5, param6);
298 notificationsComponent.Rpc(notificationsComponent.Rpc_SendToPlayer, playerID, notificationID,
position, paramArray);
303 newNotificationData.SetParameters(
ENotificationReceiver.SPECIFIC_PLAYER, param1, param2, param3, param4, param5, param6);
304 newNotificationData.SetPosition(
position);
305 return SendToPlayerData(playerID, notificationID, newNotificationData);
310 [
RplRpc(RplChannel.Reliable, RplRcver.Server)]
313 int param1, param2, param3, param4, param5, param6;
314 GetParamsFromArray(paramArray, param1, param2, param3, param4, param5, param6);
316 SendToPlayer(playerID, notificationID,
position, param1, param2, param3, param4, param5, param6);
324 if (!Replication.IsServer())
327 PlayerController playerController =
GetGame().GetPlayerManager().GetPlayerController(playerID);
328 if (!playerController)
331 SCR_NotificationsComponent notificationsComponent = SCR_NotificationsComponent.Cast(playerController.FindComponent(SCR_NotificationsComponent));
332 if (!notificationsComponent)
335 notificationsComponent.SendToOwner(notificationID,
data);
351 static bool SendToFaction(notnull
SCR_Faction faction,
bool includeFriendlyFactions,
ENotification notificationID,
int param1 = 0,
int param2 = 0,
int param3 = 0,
int param4 = 0,
int param5 = 0,
int param6 = 0)
353 return SendToFaction(faction, includeFriendlyFactions, notificationID, vector.Zero, param1, param2, param3, param4, param5, param6);
369 static bool SendToFaction(notnull
SCR_Faction faction,
bool includeFriendlyFactions,
ENotification notificationID, vector
position,
int param1 = 0,
int param2 = 0,
int param3 = 0,
int param4 = 0,
int param5 = 0,
int param6 = 0)
372 if (!Replication.IsServer())
375 if (!playerController)
378 SCR_NotificationsComponent notificationsComponent = SCR_NotificationsComponent.Cast(playerController.FindComponent(SCR_NotificationsComponent));
379 if (!notificationsComponent)
382 FactionManager factionManager =
GetGame().GetFactionManager();
386 array<int> paramArray = {};
387 CreateParamArray(paramArray, param1, param2, param3, param4, param5, param6);
389 notificationsComponent.Rpc(notificationsComponent.Rpc_SendToFaction, factionManager.GetFactionIndex(faction), includeFriendlyFactions, notificationID,
position, paramArray);
394 newNotificationData.SetParameters(
ENotificationReceiver.SPECIFIC_PLAYER, param1, param2, param3, param4, param5, param6);
395 newNotificationData.SetPosition(
position);
396 return SendToFactionData(faction, includeFriendlyFactions, notificationID, newNotificationData);
401 [
RplRpc(RplChannel.Reliable, RplRcver.Server)]
404 FactionManager factionManager =
GetGame().GetFactionManager();
412 int param1, param2, param3, param4, param5, param6;
413 GetParamsFromArray(paramArray, param1, param2, param3, param4, param5, param6);
415 SendToFaction(faction, includeFriendlyFactions, notificationID,
position, param1, param2, param3, param4, param5, param6);
423 if (!Replication.IsServer())
426 array<int> players = {};
427 faction.GetPlayersInFaction(players);
429 foreach(
int playerID : players)
431 SendToPlayerData(playerID, notificationID,
data);
434 if (!includeFriendlyFactions)
438 FactionManager factionManager =
GetGame().GetFactionManager();
442 array<Faction> allFactions = {};
444 factionManager.GetFactionsList(allFactions);
446 foreach(
Faction otherFaction : allFactions)
448 if (otherFaction == faction)
455 if (!faction.IsFactionFriendly(scrFaction))
459 scrFaction.GetPlayersInFaction(players);
460 foreach(
int playerID : players)
462 SendToPlayerData(playerID, notificationID,
data);
480 static bool SendToUnlimitedEditorPlayers(
ENotification notificationID,
int param1 = 0,
int param2 = 0,
int param3 = 0,
int param4 = 0,
int param5 = 0,
int param6 = 0)
482 return SendToUnlimitedEditorPlayers(notificationID, vector.Zero, param1, param2, param3, param4, param5, param6);
496 static bool SendToUnlimitedEditorPlayers(
ENotification notificationID, vector
position,
int param1 = 0,
int param2 = 0,
int param3 = 0,
int param4 = 0,
int param5 = 0,
int param6 = 0)
499 if (!Replication.IsServer())
502 if (!playerController)
505 SCR_NotificationsComponent notificationsComponent = SCR_NotificationsComponent.Cast(playerController.FindComponent(SCR_NotificationsComponent));
506 if (!notificationsComponent)
509 array<int> paramArray = {};
510 CreateParamArray(paramArray, param1, param2, param3, param4, param5, param6);
512 notificationsComponent.Rpc(notificationsComponent.Rpc_SendToUnlimitedEditorPlayers, notificationID,
position, paramArray);
517 newNotificationData.SetParameters(
ENotificationReceiver.GM_ONLY, param1, param2, param3, param4, param5, param6);
518 newNotificationData.SetPosition(
position);
519 return SendToUnlimitedEditorPlayersData(notificationID, newNotificationData);
524 [
RplRpc(RplChannel.Reliable, RplRcver.Server)]
527 int param1, param2, param3, param4, param5, param6;
528 GetParamsFromArray(paramArray, param1, param2, param3, param4, param5, param6);
530 SendToUnlimitedEditorPlayers(notificationID,
position, param1, param2, param3, param4, param5, param6);
538 if (!Replication.IsServer())
541 array<int> players = {};
542 for (
int i = 0, count =
GetGame().GetPlayerManager().
GetPlayers(players); i < count; i++)
544 if (playerID == players[i])
546 SendToPlayerData(players[i], notificationID,
data);
558 if (!editorManager.IsLimited())
559 SendToPlayerData(players[i], notificationID,
data);
576 static bool SendToUnlimitedEditorPlayersAndPlayer(
int playerID,
ENotification notificationID,
int param1 = 0,
int param2 = 0,
int param3 = 0,
int param4 = 0,
int param5 = 0,
int param6 = 0)
578 return SendToUnlimitedEditorPlayersAndPlayer(playerID, notificationID, vector.Zero, param1, param2, param3, param4, param5, param6);
593 static bool SendToUnlimitedEditorPlayersAndPlayer(
int playerID,
ENotification notificationID, vector
position,
int param1 = 0,
int param2 = 0,
int param3 = 0,
int param4 = 0,
int param5 = 0,
int param6 = 0)
596 if (!Replication.IsServer())
599 if (!playerController)
602 SCR_NotificationsComponent notificationsComponent = SCR_NotificationsComponent.Cast(playerController.FindComponent(SCR_NotificationsComponent));
603 if (!notificationsComponent)
606 array<int> paramArray = {};
607 CreateParamArray(paramArray, param1, param2, param3, param4, param5, param6);
609 notificationsComponent.Rpc(notificationsComponent.Rpc_SendToUnlimitedEditorPlayersAndPlayer, playerID, notificationID,
position, paramArray);
614 newNotificationData.SetParameters(
ENotificationReceiver.GM_OR_AFFECTED_PLAYER_ONLY, param1, param2, param3, param4, param5, param6);
615 newNotificationData.SetPosition(
position);
616 return SendToUnlimitedEditorPlayersData(notificationID, newNotificationData, playerID);
621 [
RplRpc(RplChannel.Reliable, RplRcver.Server)]
624 int param1, param2, param3, param4, param5, param6;
625 GetParamsFromArray(paramArray, param1, param2, param3, param4, param5, param6);
627 SendToUnlimitedEditorPlayersAndPlayer(playerID, notificationID,
position, param1, param2, param3, param4, param5, param6);
641 static bool SendToGroup(
int groupID,
ENotification notificationID,
int param1 = 0,
int param2 = 0,
int param3 = 0,
int param4 = 0,
int param5 = 0,
int param6 = 0)
643 return SendToGroup(groupID, notificationID, vector.Zero, param1, param2, param3, param4, param5, param6);
658 static bool SendToGroup(
int groupID,
ENotification notificationID, vector
position,
int param1 = 0,
int param2 = 0,
int param3 = 0,
int param4 = 0,
int param5 = 0,
int param6 = 0)
661 if (!Replication.IsServer())
664 if (!playerController)
667 SCR_NotificationsComponent notificationsComponent = SCR_NotificationsComponent.Cast(playerController.FindComponent(SCR_NotificationsComponent));
668 if (!notificationsComponent)
671 array<int> paramArray = {};
672 CreateParamArray(paramArray, param1, param2, param3, param4, param5, param6);
674 notificationsComponent.Rpc(notificationsComponent.Rpc_SendToGroup, groupID, notificationID,
position, paramArray);
679 newNotificationData.SetParameters(
ENotificationReceiver.PLAYER_GROUP, param1, param2, param3, param4, param5, param6);
680 newNotificationData.SetPosition(
position);
681 return SendToGroupData(notificationID, newNotificationData, groupID);
686 [
RplRpc(RplChannel.Reliable, RplRcver.Server)]
689 int param1, param2, param3, param4, param5, param6;
690 GetParamsFromArray(paramArray, param1, param2, param3, param4, param5, param6);
692 SendToGroup(groupID, notificationID,
position, param1, param2, param3, param4, param5, param6);
700 if (!Replication.IsServer())
707 SCR_AIGroup group = groupManager.FindGroup(groupID);
711 array<int> players = group.GetPlayerIDs();
713 if (players.IsEmpty())
716 foreach (
int playerID: players)
718 SendToPlayerData(playerID, notificationID,
data);
734 static bool SendLocal(
ENotification notificationID,
int param1 = 0,
int param2 = 0,
int param3 = 0,
int param4 = 0,
int param5 = 0,
int param6 = 0)
736 return SendLocal(notificationID, vector.Zero, param1, param2, param3, param4, param5, param6);
750 static bool SendLocal(
ENotification notificationID, vector
position,
int param1 = 0,
int param2 = 0,
int param3 = 0,
int param4 = 0,
int param5 = 0,
int param6 = 0)
753 newNotificationData.SetParameters(
ENotificationReceiver.LOCAL_ONLY, param1, param2, param3, param4, param5, param6);
754 newNotificationData.SetPosition(
position);
755 return SendLocalData(notificationID, newNotificationData);
768 static bool SendLocalUnlimitedEditor(
ENotification notificationID,
int param1 = 0,
int param2 = 0,
int param3 = 0,
int param4 = 0,
int param5 = 0,
int param6 = 0)
770 return SendLocalUnlimitedEditor(notificationID, vector.Zero, param1, param2, param3, param4, param5, param6);
784 static bool SendLocalUnlimitedEditor(
ENotification notificationID, vector
position,
int param1 = 0,
int param2 = 0,
int param3 = 0,
int param4 = 0,
int param5 = 0,
int param6 = 0)
787 if (!editorManager || editorManager.IsLimited())
791 newNotificationData.SetParameters(
ENotificationReceiver.LOCAL_GM_ONLY, param1, param2, param3, param4, param5, param6);
792 newNotificationData.SetPosition(
position);
793 return SendLocalData(notificationID, newNotificationData);
806 static bool SendLocalLimitedEditor(
ENotification notificationID,
int param1 = 0,
int param2 = 0,
int param3 = 0,
int param4 = 0,
int param5 = 0,
int param6 = 0)
808 return SendLocalLimitedEditor(notificationID, vector.Zero, param1, param2, param3, param4, param5, param6);
822 static bool SendLocalLimitedEditor(
ENotification notificationID, vector
position,
int param1 = 0,
int param2 = 0,
int param3 = 0,
int param4 = 0,
int param5 = 0,
int param6 = 0)
825 if (!editorManager || !editorManager.IsLimited())
829 newNotificationData.SetParameters(
ENotificationReceiver.LOCAL_NON_GM_ONLY, param1, param2, param3, param4, param5, param6);
830 newNotificationData.SetPosition(
position);
831 return SendLocalData(notificationID, newNotificationData);
838 SCR_NotificationsComponent notificationsComponent =
GetInstance();
839 if (!notificationsComponent)
842 notificationsComponent.ReceiveSCR_NotificationData(notificationID,
data);
848 protected static void CreateParamArray(notnull out array<int> paramArray,
int param1 = 0,
int param2 = 0,
int param3 = 0,
int param4 = 0,
int param5 = 0,
int param6 = 0)
851 paramArray.Insert(param1);
854 paramArray.Insert(param2);
857 paramArray.Insert(param3);
860 paramArray.Insert(param4);
863 paramArray.Insert(param5);
866 paramArray.Insert(param6);
871 protected static void GetParamsFromArray(notnull array<int> paramArray, out
int param1 = 0, out
int param2 = 0, out
int param3 = 0, out
int param4 = 0, out
int param5 = 0, out
int param6 = 0)
873 int count = paramArray.Count();
877 param1 = paramArray[0];
881 param1 = paramArray[0];
882 param2 = paramArray[1];
886 param1 = paramArray[0];
887 param2 = paramArray[1];
888 param3 = paramArray[2];
892 param1 = paramArray[0];
893 param2 = paramArray[1];
894 param3 = paramArray[2];
895 param4 = paramArray[3];
899 param1 = paramArray[0];
900 param2 = paramArray[1];
901 param3 = paramArray[2];
902 param4 = paramArray[3];
903 param5 = paramArray[4];
907 param1 = paramArray[0];
908 param2 = paramArray[1];
909 param3 = paramArray[2];
910 param4 = paramArray[3];
911 param5 = paramArray[4];
912 param6 = paramArray[5];
932 [
RplRpc(RplChannel.Reliable, RplRcver.Owner)]
939 [
RplRpc(RplChannel.Reliable, RplRcver.Owner)]
974 if (!notificationClass)
977 return notificationClass.GetStickyNotifications();
986 if (!notificationClass)
989 return notificationClass.GetNotificationDisplayColor();
996 if (!notificationClass)
999 return notificationClass.GetNotificationDisplayData(notificationID);
1010 string playerName =
string.Empty;
1046 World world =
GetOwner().GetWorld();
1048 if (!notificationsSystem)
1051 notificationsSystem.Register(
this);
1057 World world =
GetOwner().GetWorld();
1059 if (!notificationsSystem)
1062 notificationsSystem.Unregister(
this);
1072 for(
int i = 0; i < count; i++)
1093 PlayerController playerController = PlayerController.Cast(owner);
1094 if (!playerController)
1101 if (Replication.IsClient())
1108 array<int> players = {};
1110 GetGame().GetPlayerManager().GetPlayers(players);
1112 foreach (
int player : players)
1125 if (Replication.IsClient())
1132 super.OnDelete(owner);