2[
ComponentEditorProps(
category:
"GameScripted/GameMode/Components", description:
"Manager for holding non-faction enities and to getter functions for entities from factions")]
9 [
Attribute(
desc:
"List of non-faction related Entity catalogs. Each holds a list of entity Prefab and data of a given type. Catalogs of the same type are merged into one. Note this array is moved to a map on init and set to null")]
19 protected static SCR_EntityCatalogManagerComponent s_Instance;
23 protected bool m_bInitDone;
27 static SCR_EntityCatalogManagerComponent GetInstance()
36 if (!s_OnEntityCatalogInitialized)
39 return s_OnEntityCatalogInitialized;
64 Print(
string.Format(
"'SCR_EntityCatalogManagerComponent' trying to get entity list of type '%1' but there is no catalog with that type.",
typename.EnumToString(
EEntityCatalogType, catalogType)),
LogLevel.WARNING);
84 Print(
string.Format(
"'SCR_EntityCatalogManagerComponent', GetFactionEntityCatalogOfType could not get Catalog as faction '%1' is invalid or does not exist in current game", factionKey),
LogLevel.ERROR);
100 return faction.GetFactionEntityCatalogOfType(catalogType, printNotFound);
112 outEntityCatalogs.Clear();
115 outEntityCatalogs.Insert(entityCatalog);
118 return outEntityCatalogs.Count();
136 Print(
string.Format(
"'SCR_EntityCatalogManagerComponent', GetAllFactionEntityCatalogs could not get Catalog as faction '%1' is invalid or does not exist in current game", factionKey),
LogLevel.ERROR);
151 return faction.GetAllFactionEntityCatalogs(outEntityCatalogs);
219 if (!prioritizeGeneralCatalog)
262 if (!prioritizeGeneralOfPriorityFaction)
297 array<Faction> factions = {};
300 foreach (
Faction faction : factions)
305 if (!scrFaction || scrFaction == priorityFaction)
332 filteredPrefabsList.Clear();
334 array<Faction> factions = {};
338 if (delegateFactionManager)
340 SCR_SortedArray<SCR_EditableFactionComponent> sortedDelegates =
new SCR_SortedArray<SCR_EditableFactionComponent>();
344 for(
int i = 0; i < count; ++i)
346 factions.Insert(sortedDelegates.Get(i).GetFaction());
361 array<ResourceName> filteredPrefabsOfFaction = {};
363 set<ResourceName> uniquePrefabs();
366 foreach (
Faction faction : factions)
372 GetFilteredEditorPrefabs(catalogType, editorMode, scrFaction, filteredPrefabsOfFaction, includedLabels, excludedLabels, needsAllIncludedLabels);
373 foreach (
ResourceName prefab : filteredPrefabsOfFaction)
375 if (uniquePrefabs.Insert(prefab))
377 filteredPrefabsList.Insert(prefab);
382 PrintFormat(
"SCR_EntityCatalogManagerComponent.GetFilteredEditorPrefabsOfAllFactions: Detected that %1 is present in at least two different faction entity catalogs! Since this may cause issues, such as dupliacted entries in build mode, one of them will be discarded! This is only supported for items. Other things require creation of faction specific variants.",
SCR_FileIOHelper.
GetShortResourceName(prefab), level:
LogLevel.WARNING);
389 if (getFactionLessPrefabs)
391 GetFilteredEditorPrefabs(catalogType, editorMode, null, filteredPrefabsOfFaction, includedLabels, excludedLabels, needsAllIncludedLabels);
392 foreach (
ResourceName prefab : filteredPrefabsOfFaction)
394 if (uniquePrefabs.Insert(prefab))
396 filteredPrefabsList.Insert(prefab)
401 PrintFormat(
"SCR_EntityCatalogManagerComponent.GetFilteredEditorPrefabsOfAllFactions: Detected that %1 is present more than once in ! Since this may cause issues, such as dupliacted entries in build mode, one of them will be discarded! This is only supported for items. Other things require creation of faction specific variants.",
SCR_FileIOHelper.
GetShortResourceName(prefab), level:
LogLevel.WARNING);
407 return filteredPrefabsList.Count();
422 int GetFilteredEditorPrefabs(
EEntityCatalogType catalogType,
EEditorMode editorMode,
SCR_Faction faction, notnull out array<ResourceName> filteredPrefabsList, array<EEditableEntityLabel> includedLabels = null, array<EEditableEntityLabel> excludedLabels = null,
bool needsAllIncludedLabels =
true)
425 filteredPrefabsList.Clear();
437 array<SCR_EntityCatalogEntry> filteredEntityList = {};
438 array<typename> filterClassArray = {};
441 catalog.GetFullFilteredEntityList(filteredEntityList, includedLabels, excludedLabels, filterClassArray, needsAllIncludedLabels: needsAllIncludedLabels);
444 set<ResourceName> uniquePrefabs();
458 if (uniquePrefabs.Insert(prefab))
460 filteredPrefabsList.Insert(prefab);
465 PrintFormat(
"SCR_EntityCatalogManagerComponent.GetFilteredEditorPrefabs: Detected that %1 is present in at least two different faction entity catalogs! Since this may cause issues, such as dupliacted entries in build mode, one of them will be discarded! This is only supported for items. Other things require creation of faction specific variants.",
SCR_FileIOHelper.
GetShortResourceName(entry.GetPrefab()), level:
LogLevel.WARNING);
470 return filteredPrefabsList.Count();
486 arsenalItems.Clear();
492 return GetArsenalItems(arsenalItems, itemCatalog, typeFilter, modeFilter, arsenalGameModeType, requiresDisplayType);
507 arsenalItems.Clear();
513 return GetArsenalItems(arsenalItems, itemCatalog, typeFilter, modeFilter, arsenalGameModeType, requiresDisplayType);
527 array<SCR_EntityCatalogEntry> arsenalEntries = {};
528 array<SCR_BaseEntityCatalogData> arsenalDataList = {};
529 itemCatalog.GetEntityListWithData(
SCR_ArsenalItem, arsenalEntries, arsenalDataList);
554 arsenalItems.Insert(arsenalItem);
557 return !arsenalItems.IsEmpty();
571 allArsenalItems.Clear();
573 array<Faction> factions = {};
576 array<SCR_ArsenalItem> arsenalItems = {};
578 foreach (
Faction faction : factions)
584 GetFactionArsenalItems(arsenalItems, scrFaction, typeFilter, modeFilter, arsenalGameModeType, requiresDisplayType);
585 allArsenalItems.InsertAll(arsenalItems);
588 GetArsenalItems(arsenalItems, typeFilter, modeFilter, arsenalGameModeType, requiresDisplayType);
589 allArsenalItems.InsertAll(arsenalItems);
591 return allArsenalItems.Count();
604 array<SCR_ArsenalItem> refFilteredItems = {};
605 array<SCR_ArsenalItem> filteredItems = {};
608 GetFactionArsenalItems(refFilteredItems, faction, typeFilter, modeFilter, arsenalGameModeType, requiresDisplayType);
610 GetArsenalItems(refFilteredItems, typeFilter, modeFilter, arsenalGameModeType, requiresDisplayType);
614 filteredItems.Insert(item);
617 return filteredItems;
628 FactionAffiliationComponent factionAffiliationComp = FactionAffiliationComponent.Cast(character.FindComponent(FactionAffiliationComponent));
629 if (!factionAffiliationComp)
640 array<SCR_EntityCatalogEntry> filteredEntityList = {};
643 if (filteredEntityList.IsEmpty())
646 if (filteredEntityList.Count() > 1)
647 Print(
"SCR_EntityCatalogManagerComponent: GetIdentityItemForCharacter Multiple Identity Items found for faction " + faction.GetFactionKey() +
"! Only the first found will be used");
649 return filteredEntityList[0].GetPrefab();
660 array<SCR_EntityCatalogEntry> filteredEntityList = {};
663 if (filteredEntityList.IsEmpty())
666 if (filteredEntityList.Count() > 0)
667 Print(
"SCR_EntityCatalogManagerComponent: GetIdentityItemForCharacter Multiple Identity Items found for factionless list! Only the first found will be used");
669 return filteredEntityList[0].GetPrefab();
677 static void InitCatalogs(notnull array<ref SCR_EntityCatalog> entityCatalogArray, notnull map<EEntityCatalogType, ref SCR_EntityCatalog> entityCatalogMap)
679 SCR_EntityCatalog foundCatalog;
682 foreach (SCR_EntityCatalog entityCatalog : entityCatalogArray)
685 if (!entityCatalogMap.Find(entityCatalog.GetCatalogType(), foundCatalog))
686 entityCatalogMap.Insert(entityCatalog.GetCatalogType(), entityCatalog);
689 foundCatalog.MergeCatalogs(entityCatalog);
693 foreach (SCR_EntityCatalog entityCatalog : entityCatalogArray)
696 entityCatalog.InitCatalog();
714 Debug.Error2(
"SCR_EntityCatalogManagerComponent",
"Could not find SCR_FactionManager, this is required for many the Getter Functions!");
722 if (s_OnEntityCatalogInitialized)
723 s_OnEntityCatalogInitialized.Invoke();
734 Print(
"More than one 'SCR_EntityCatalogManagerComponent' excist in the world! Make sure there is only 1!",
LogLevel.ERROR);
ArmaReforgerScripted GetGame()
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
void SCR_BaseGameModeComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Get all prefabs that have the spawner the given labels and are valid in the editor mode for all factions param catalogType Type to catalog to get prefabs from param editorMode Editor mode to get valid entries from param[out] filteredPrefabsList Filltered array of valid prefabs param includedLabels A list of labels the entity needs all any to have Can be null if any of the other arrays are filled param excludedLabels A list of labels the entity CANNOT have ANY of Can be null if any of the other arrays are filled param needsAllIncludedLabels If true included List all needs to be if false any needs to be true param getFactionLessPrefabs If true than it will also get the prefabs not assigned to any faction return Size of found prefabs *int GetFilteredEditorPrefabsOfAllFactions(EEntityCatalogType catalogType, EEditorMode editorMode, notnull out array< ResourceName > filteredPrefabsList, array< EEditableEntityLabel > includedLabels=null, array< EEditableEntityLabel > excludedLabels=null, bool needsAllIncludedLabels=true, bool getFactionLessPrefabs=false)
SCR_EntityCatalogEntry GetEntryWithPrefabFromAnyCatalog(EEntityCatalogType catalogType, ResourceName prefabToFind, SCR_Faction priorityFaction=null, bool prioritizeGeneralOfPriorityFaction=false)
int GetAllFactionEntityCatalogs(notnull out array< SCR_EntityCatalog > outEntityCatalogs, FactionKey factionKey)
SCR_EntityCatalogEntry GetEntryWithPrefabFromFactionCatalog(EEntityCatalogType catalogType, ResourceName prefabToFind, notnull SCR_Faction faction)
SCR_EntityCatalogEntry GetEntryWithPrefabFromGeneralOrFactionCatalog(EEntityCatalogType catalogType, ResourceName prefabToFind, notnull SCR_Faction faction, bool prioritizeGeneralCatalog=false)
bool GetFactionArsenalItems(out array< SCR_ArsenalItem > arsenalItems, SCR_Faction faction, SCR_EArsenalItemType typeFilter=-1, SCR_EArsenalItemMode modeFilter=-1, SCR_EArsenalGameModeType arsenalGameModeType=-1, EArsenalItemDisplayType requiresDisplayType=-1)
SCR_EntityCatalogEntry GetEntryWithPrefabFromCatalog(EEntityCatalogType catalogType, ResourceName prefabToFind)
int GetAllArsenalItems(out array< SCR_ArsenalItem > allArsenalItems, SCR_EArsenalItemType typeFilter=-1, SCR_EArsenalItemMode modeFilter=-1, SCR_EArsenalGameModeType arsenalGameModeType=-1, EArsenalItemDisplayType requiresDisplayType=-1)
int GetAllEntityCatalogs(notnull out array< SCR_EntityCatalog > outEntityCatalogs)
array< SCR_ArsenalItem > GetFilteredArsenalItems(SCR_EArsenalItemType typeFilter, SCR_EArsenalItemMode modeFilter, SCR_EArsenalGameModeType arsenalGameModeType, SCR_Faction faction=null, EArsenalItemDisplayType requiresDisplayType=-1)
SCR_EntityCatalog GetFactionEntityCatalogOfType(EEntityCatalogType catalogType, FactionKey factionKey, bool printNotFound=true)
ResourceName GetIdentityItemForCharacter(ChimeraCharacter character)
bool GetArsenalItems(out array< SCR_ArsenalItem > arsenalItems, SCR_EArsenalItemType typeFilter=-1, SCR_EArsenalItemMode modeFilter=-1, SCR_EArsenalGameModeType arsenalGameModeType=-1, EArsenalItemDisplayType requiresDisplayType=-1)
ResourceName GetDefaultIdentityItem()
SCR_EntityCatalog GetEntityCatalogOfType(EEntityCatalogType catalogType, bool printNotFound=true)
ref map< EEntityCatalogType, ref SCR_EntityCatalog > m_mEntityCatalogs
ref array< ref SCR_EntityCatalog > m_aEntityCatalogs
void SCR_FactionManager(IEntitySource src, IEntity parent)
SCR_FactionManager m_FactionManager
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
ScriptInvokerBase< ScriptInvokerVoidMethod > ScriptInvokerVoid
SCR_EArsenalItemType GetItemType()
SCR_ArsenalItemDisplayData GetDisplayDataOfType(EArsenalItemDisplayType displayType)
SCR_EArsenalGameModeType GetArsenalGameModeTypes()
SCR_EArsenalItemMode GetItemMode()
static SCR_DelegateFactionManagerComponent GetInstance()
int GetSortedFactionDelegates(notnull out SCR_SortedArray< SCR_EditableFactionComponent > outDelegates)
Info for which editor modes the entity is added to.
bool IsValidInEditorMode(EEditorMode editorMode)
SCR_EntityCatalogEntry GetEntryWithPrefab(ResourceName prefabToFind)
Manager for non-faction specific entity catalogs as well as getters for faction specific catalogs.
SCR_EntityCatalog GetFactionEntityCatalogOfType(EEntityCatalogType catalogType, bool printNotFound=true)
static string GetShortResourceName(ResourceName rn)
static bool IsEmptyOrWhiteSpace(string input)
override void EOnInit(IEntity owner)
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
proto void PrintFormat(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL, LogLevel level=LogLevel.NORMAL)
SCR_FieldOfViewSettings Attribute
EEditorMode
Editor mode that defines overall functionality.
EntityEvent
Various entity events.