1 [
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")]
13 protected ref map<EEntityCatalogType, ref SCR_EntityCatalog>
m_mEntityCatalogs =
new map<EEntityCatalogType, ref SCR_EntityCatalog>();
19 protected static SCR_EntityCatalogManagerComponent
s_Instance;
21 protected bool m_bInitDone;
25 static SCR_EntityCatalogManagerComponent
GetInstance()
41 Debug.Error2(
"SCR_EntityCatalogManagerComponent",
"Trying to obtain catalog of type: '" +
typename.EnumToString(
EEntityCatalogType, catalogType) +
"' (Factionless) but catalog is not yet initialized! Call your function one frame later!");
52 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);
70 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);
85 return faction.GetFactionEntityCatalogOfType(catalogType);
97 outEntityCatalogs.Clear();
100 outEntityCatalogs.Insert(entityCatalog);
103 return outEntityCatalogs.Count();
121 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);
136 return faction.GetAllFactionEntityCatalogs(outEntityCatalogs);
160 return catalog.GetEntryWithPrefab(prefabToFind);
183 return catalog.GetEntryWithPrefab(prefabToFind);
204 if (!prioritizeGeneralCatalog)
247 if (!prioritizeGeneralOfPriorityFaction)
282 array<Faction> factions = {};
285 foreach (
Faction faction : factions)
290 if (!scrFaction || scrFaction == priorityFaction)
317 filteredPrefabsList.Clear();
319 array<Faction> factions = {};
323 if (delegateFactionManager)
325 SCR_SortedArray<SCR_EditableFactionComponent> sortedDelegates =
new SCR_SortedArray<SCR_EditableFactionComponent>();
326 int count = delegateFactionManager.GetSortedFactionDelegates(sortedDelegates);
329 for(
int i = 0; i < count; ++i)
331 factions.Insert(sortedDelegates.Get(i).GetFaction());
346 array<ResourceName> filteredPrefabsOfFaction = {};
350 foreach (
Faction faction : factions)
356 GetFilteredEditorPrefabs(catalogType, editorMode, scrFaction, filteredPrefabsOfFaction, includedLabels, excludedLabels, needsAllIncludedLabels);
357 filteredPrefabsList.InsertAll(filteredPrefabsOfFaction);
361 if (getFactionLessPrefabs)
363 GetFilteredEditorPrefabs(catalogType, editorMode,
null, filteredPrefabsOfFaction, includedLabels, excludedLabels, needsAllIncludedLabels);
364 filteredPrefabsList.InsertAll(filteredPrefabsOfFaction);
367 return filteredPrefabsList.Count();
382 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)
385 filteredPrefabsList.Clear();
397 array<SCR_EntityCatalogEntry> filteredEntityList = {};
398 array<typename> filterClassArray = {};
401 catalog.GetFullFilteredEntityList(filteredEntityList, includedLabels, excludedLabels, filterClassArray, needsAllIncludedLabels: needsAllIncludedLabels);
411 if (!editorData.IsValidInEditorMode(editorMode))
415 filteredPrefabsList.Insert(entry.GetPrefab());
418 return filteredPrefabsList.Count();
433 arsenalItems.Clear();
439 return GetArsenalItems(arsenalItems, itemCatalog, typeFilter, modeFilter, requiresDisplayType);
453 arsenalItems.Clear();
459 return GetArsenalItems(arsenalItems, itemCatalog, typeFilter, modeFilter, requiresDisplayType);
472 array<SCR_EntityCatalogEntry> arsenalEntries = {};
473 array<SCR_BaseEntityCatalogData> arsenalDataList = {};
474 itemCatalog.GetEntityListWithData(
SCR_ArsenalItem, arsenalEntries, arsenalDataList);
484 if (typeFilter != -1 && !
SCR_Enum.HasPartialFlag(arsenalItem.GetItemType(), typeFilter))
488 if (modeFilter != -1 && !
SCR_Enum.HasPartialFlag(arsenalItem.GetItemMode(), modeFilter))
492 if (requiresDisplayType != -1 && !arsenalItem.GetDisplayDataOfType(requiresDisplayType))
495 arsenalItems.Insert(arsenalItem);
498 return !arsenalItems.IsEmpty();
511 allArsenalItems.Clear();
513 array<Faction> factions = {};
516 array<SCR_ArsenalItem> arsenalItems = {};
518 foreach (
Faction faction : factions)
525 allArsenalItems.InsertAll(arsenalItems);
528 GetArsenalItems(arsenalItems, typeFilter, modeFilter, requiresDisplayType);
529 allArsenalItems.InsertAll(arsenalItems);
531 return allArsenalItems.Count();
543 array<SCR_ArsenalItem> refFilteredItems = {};
544 array<SCR_ArsenalItem> filteredItems = {};
549 GetArsenalItems(refFilteredItems, typeFilter, modeFilter, requiresDisplayType);
553 filteredItems.Insert(item);
556 return filteredItems;
565 static void InitCatalogs(notnull array<ref SCR_EntityCatalog> entityCatalogArray, notnull map<EEntityCatalogType, ref SCR_EntityCatalog> entityCatalogMap)
573 if (!entityCatalogMap.Find(entityCatalog.GetCatalogType(), foundCatalog))
574 entityCatalogMap.Insert(entityCatalog.GetCatalogType(), entityCatalog);
577 foundCatalog.MergeCatalogs(entityCatalog);
586 Debug.Error2(
"SCR_EntityCatalogManagerComponent",
"Could not find SCR_FactionManager, this is required for many the Getter Functions!");
605 Print(
"More than one 'SCR_EntityCatalogManagerComponent' excist in the world! Make sure there is only 1!", LogLevel.ERROR);
612 SetEventMask(owner, EntityEvent.INIT);