13 bool m_bPriorityNotification;
15 [
Attribute(
desc:
"Holds the display information of the notification, Fill in Name and Color. Optional: Icon")]
19 const int MAX_USERNAME_CHARACTERS = 32;
33 SetFactionRelatedColor(
data);
47 colorEnum = m_info.GetNotificationColor();
50 colorEnum =
data.GetFactionRelatedColor();
68 colorEnum =
data.GetFactionRelatedTextColor();
84 if (!splitNotificationUIInfo)
88 data.GetSplitFactionRelatedColor(leftFactionColor, rightFactionColor);
90 leftTextColorEnum = splitNotificationUIInfo.GetLeftTextColor();
92 if (leftTextColorEnum >=
ENotificationColor.FACTION_FRIENDLY_IS_NEGATIVE || splitNotificationUIInfo.ShouldReplaceLeftColorWithRightColorIfAlly())
93 leftTextColorEnum = leftFactionColor;
95 rightTextColorEnum = splitNotificationUIInfo.GetRightTextColor();
98 rightTextColorEnum = rightFactionColor;
111 Print(
"(" +
typename.EnumToString(
ENotification,
data.GetID()) +
") SCR_NotificationDisplayData has no UIInfo assigned!", LogLevel.WARNING);
115 return m_info.GetName();
124 bool MergeParam1With2()
136 return m_bPriorityNotification;
150 protected bool GetPlayerName(
int playerID, out
string playerName)
153 if (!playerName.IsEmpty())
160 playerName = playerManager.GetPlayerName(playerID);
163 if (playerName.IsEmpty())
165 SCR_NotificationsComponent notificationsManager = SCR_NotificationsComponent.GetInstance();
166 if (notificationsManager)
167 playerName = notificationsManager.GetPlayerNameFromHistory(playerID);
170 if (playerName.Length() > MAX_USERNAME_CHARACTERS)
172 string trimedName = playerName.Substring(0, MAX_USERNAME_CHARACTERS);
173 playerName = trimedName +
"...";
176 return !playerName.IsEmpty();
180 protected bool GetEditableEntityName(
int entityRplID, out
string entityName,
bool useCharacterName =
false)
183 if (!entityName.IsEmpty())
190 IEntity entity = IEntity.Cast(Replication.FindItem(entityRplID));
193 RplComponent rplComponent = RplComponent.Cast(Replication.FindItem(entityRplID));
195 entity = rplComponent.GetEntity();
207 if (editableEntity.GetPlayerID() > 0)
208 return GetPlayerName(editableEntity.GetPlayerID(), entityName);
210 if (useCharacterName)
212 if (SCR_EditableCharacterComponent.Cast(editableEntity))
214 string format, firstname, alias, surname;
215 if (GetCharacterName(entityRplID, format, firstname, alias, surname))
217 entityName = WidgetManager.Translate(format, firstname, alias, surname);
218 if (!entityName.IsEmpty())
225 entityName = editableEntity.GetDisplayName();
232 entityName = taskPrefabData.GetObjectiveTypeName();
234 entityName = editableEntity.GetDisplayName();
238 return !entityName.IsEmpty();
243 protected bool GetFactionName(
int factionIndex, out
string factionName)
246 if (!factionName.IsEmpty())
249 FactionManager factionManager =
GetGame().GetFactionManager();
253 Faction faction = factionManager.GetFactionByIndex(factionIndex);
257 factionName = faction.GetFactionName();
258 return !factionName.IsEmpty();
262 protected bool GetCharacterName(
int entityRplID, out
string format, out
string firstname, out
string alias, out
string surname)
268 IEntity entity = IEntity.Cast(Replication.FindItem(entityRplID));
271 RplComponent rplComponent = RplComponent.Cast(Replication.FindItem(entityRplID));
273 entity = rplComponent.GetEntity();
282 SCR_CharacterIdentityComponent charIdentity = SCR_CharacterIdentityComponent.Cast(editableEntity.GetOwner().FindComponent(SCR_CharacterIdentityComponent));
286 charIdentity.GetFormattedFullName(format, firstname, alias, surname);
292 protected bool GetEntityCallsign(
int rplID, out
string callsign)
295 if (!callsign.IsEmpty())
298 Managed managed = Replication.FindItem(rplID);
313 IEntity entity = IEntity.Cast(managed);
320 if (!callsignComponent)
323 string company, platoon, squad, character, format;
324 if (!callsignComponent.GetCallsignNames(company, platoon, squad, character, format))
328 callsign = WidgetManager.Translate(format, company, platoon, squad, character);
334 protected bool GetGroupNameFromGroupID(
int playerGroupId, out
string groupName)
337 if (!groupName.IsEmpty())
345 aiGroup = groupsManager.FindGroup(playerGroupId);
350 groupName = aiGroup.GetCustomName();
354 return GetEntityCallsign(Replication.FindId(aiGroup), groupName);
361 protected bool GetInventoryItemName(RplId rplId, out
string itemName)
363 if (!itemName.IsEmpty())
366 RplComponent itemRplcComp = RplComponent.Cast(Replication.FindItem(rplId));
370 IEntity itemEntity = itemRplcComp.GetEntity();
382 UIInfo uiInfo = attributeCollection.GetUIInfo();
386 itemName = uiInfo.GetName();
388 return !itemName.IsEmpty();
459 if (!targetEntity)
return;
462 if (!targetEntity.GetPos(
position))
return;
493 Faction playerSelfFaction = factionManager.GetLocalPlayerFaction();
494 Faction notificationPlayerFaction = factionManager.GetPlayerFaction(notificationPlayerID);
496 if (!playerSelfFaction || !notificationPlayerFaction)
500 if (playerSelfFaction.IsFactionFriendly(notificationPlayerFaction))
544 SCR_ChimeraCharacter notificationEntityChimera = SCR_ChimeraCharacter.Cast(notificationEntity.GetOwner());
548 Faction playerSelfFaction = factionManager.GetLocalPlayerFaction();
549 Faction notificationEntityFaction = notificationEntityChimera.GetFaction();
551 if (!playerSelfFaction || !notificationEntityFaction)
return ENotificationColor.NEUTRAL;
554 if (playerSelfFaction.IsFactionFriendly(notificationEntityFaction))
583 protected bool AreEntitiesFriendly(
int entity1ID,
bool entity1IsPlayer,
int entity2ID,
bool entity2IsPlayer)
589 if (entity1IsPlayer || entity2IsPlayer)
596 SCR_ChimeraCharacter entityChimera;
603 faction1 = factionManager.GetPlayerFaction(entity1ID);
612 entityChimera = SCR_ChimeraCharacter.Cast(entity.GetOwner());
616 faction1 = entityChimera.GetFaction();
622 faction2 = factionManager.GetPlayerFaction(entity2ID);
631 entityChimera = SCR_ChimeraCharacter.Cast(entity.GetOwner());
635 faction2 = entityChimera.GetFaction();
638 if (!faction1 || !faction2)
641 return faction1.IsFactionFriendly(faction2);