3class EditablePrefabsComponent_EditableEntity : EditablePrefabsComponent_Base
5 [
Attribute(defvalue:
"(%1)",
desc:
"Format of autogenerated placeholder name.\n%1 is the prefab file name (without extension).")]
6 protected string m_sNameFormat;
8 [
Attribute(defvalue:
"#AR-EditableEntity_%1_Name",
desc:
"Format of localized name.\nWhen found in the database, it will be applied instead of the placeholder name.\n%1 is the prefab file name (without extension).")]
9 protected string m_sLocKeyFormat;
11 [
Attribute(defvalue:
"UI/Textures/EditorPreviews",
desc:
"Directory where placeholder image will be auto-generated.\nHierarchy inside the folder mimics prefab folder hierarchy.",
params:
"folders")]
12 protected ResourceName m_ImagesDirectory;
14 [
Attribute(defvalue:
"",
desc:
"Placeholder image used when adding new editable entity", uiwidget: UIWidgets.ResourcePickerThumbnail,
params:
"edds")]
15 protected ResourceName m_ImagePlaceholder;
17 [
Attribute(defvalue:
"1",
desc:
"Enable budget update during autoconfiguration, costly procedure so can be disabled if budgets don't need to be updated")]
18 protected bool m_bUpdateBudgets;
21 protected ref array<ref EditablePrefabsLabel_Base> m_EntityLabelRules;
23 [
Attribute(
desc:
"Editor entity core config file", uiwidget: UIWidgets.ResourcePickerThumbnail,
params:
"conf")]
24 protected ResourceName m_EntityCoreConfigPrefab;
26 protected string m_sImagesPath;
27 protected string m_sImagePlaceholderPath;
28 protected string m_sImagePlaceholderSource;
29 protected string m_sImagePlaceholderExt;
30 protected ref SCR_EditableEntityCore m_EntityCoreConfig;
32 protected ref map<EEditableEntityBudget, int> m_MinBudgetCost =
new map<EEditableEntityBudget, int>();
34 protected const string IMG_EXTENSION =
"edds";
35 protected const string META_EXTENSION =
".meta";
38 protected bool SetUIInfo(EditablePrefabsConfig config, WorldEditorAPI api, ResourceName prefab,
string targetPath, IEntitySource entitySource, IEntitySource instanceEntitySource, IEntityComponentSource componentSource, IEntityComponentSource componentCurrent)
40 BaseContainer info = componentSource.GetObject(
"m_UIInfo");
44 typename infoType = info.GetClassName().ToType();
49 BaseContainer infoCurrent;
51 infoCurrent = componentCurrent.GetObject(
"m_UIInfo");
54 if (!m_sNameFormat.IsEmpty())
60 infoCurrent.Get(
"Name", name);
62 if (!name.StartsWith(
"#"))
64 string prefabName = FilePath.StripExtension(FilePath.StripPath(prefab));
66 string locKey =
string.Format(m_sLocKeyFormat, prefabName);
67 string locText = WidgetManager.Translate(locKey);
68 if (locText != locKey)
71 name =
string.Format(m_sNameFormat, prefabName);
74 api.SetVariableValue(entitySource,
path,
"Name", name);
81 if (infoCurrent.IsVariableSetDirectly(
"Description") && infoCurrent.Get(
"Description", description) && !description.IsEmpty())
82 api.SetVariableValue(entitySource,
path,
"Description", description);
85 string entityIconSetName;
86 if (infoCurrent.IsVariableSetDirectly(
"IconSetName") && infoCurrent.Get(
"IconSetName", entityIconSetName) && !entityIconSetName.IsEmpty())
87 api.SetVariableValue(entitySource,
path,
"IconSetName", entityIconSetName);
90 ResourceName entityIcon;
91 if (infoCurrent.IsVariableSetDirectly(
"Icon") && infoCurrent.Get(
"Icon", entityIcon) && !entityIcon.IsEmpty())
92 api.SetVariableValue(entitySource,
path,
"Icon", entityIcon);
95 ResourceManager resourceManager = Workbench.GetModule(ResourceManager);
98 string imagePath = targetPath;
99 if (GetImagePath(config, imagePath))
102 string addonName = SCR_AddonTool.GetResourceLastAddon(prefab);
103 addonName = SCR_AddonTool.ToFileSystem(addonName);
104 CreatePreviewImage(resourceManager, config, api, imagePath, entitySource, addonName);
106 api.SetVariableValue(entitySource,
path,
"m_Image", imagePath);
109 IEntityComponentSource horizontalAlignComponent = SCR_BaseContainerTools.FindComponentSource(entitySource, SCR_HorizontalAlignComponent);
110 if (horizontalAlignComponent)
112 bool isHorizontalAlign;
113 horizontalAlignComponent.Get(
"Enabled", isHorizontalAlign);
115 if (isHorizontalAlign)
118 componentSource.Get(
"m_Flags",
flags);
138 array<EEditableEntityLabel> autoLabels = {};
139 array<EEditableEntityLabel> authoredLabels = {};
140 if (GetLabelsFromSource(api, config, prefab, targetPath, instanceEntitySource, componentSource, componentCurrent, autoLabels, authoredLabels))
142 api.SetVariableValue(entitySource,
path,
"m_aAutoLabels", SCR_BaseContainerTools.GetArrayValue(autoLabels));
143 api.SetVariableValue(entitySource,
path,
"m_aAuthoredLabels", SCR_BaseContainerTools.GetArrayValue(authoredLabels));
146 if (m_bUpdateBudgets)
148 BaseContainer infoAncestor;
149 IEntityComponentSource componentAncestor;
150 if (componentCurrent)
152 componentAncestor = componentCurrent.GetAncestor();
153 if (componentAncestor)
154 infoAncestor = componentAncestor.GetObject(
"m_UIInfo");
158 if (infoType.IsInherited(SCR_EditableVehicleUIInfo))
160 array<ref SCR_EntityBudgetValue> crewBudgetCosts = {};
161 array<ref SCR_EntityBudgetValue> passengerBudgetCosts = {};
162 array<ECompartmentType> vehicleCompartmentTypes = {};
164 GetEntityBudgetCostsFromVehicle(entitySource, crewBudgetCosts, passengerBudgetCosts, vehicleCompartmentTypes);
166 string vehicleCompartmentTypesValue = SCR_BaseContainerTools.GetArrayValue(vehicleCompartmentTypes);
167 api.SetVariableValue(entitySource,
path,
"m_aOccupantFillCompartmentTypes", vehicleCompartmentTypesValue);
169 SetBudgets(api, entitySource, infoAncestor, infoCurrent,
path,
"m_aCrewEntityBudgetCost", crewBudgetCosts);
170 SetBudgets(api, entitySource, infoAncestor, infoCurrent,
path,
"m_aPassengerEntityBudgetCost", passengerBudgetCosts);
174 array<ref SCR_EntityBudgetValue> entityChildrenBudgetCosts = {};
175 GetEntityChildrenBudgetCostsFromSource(entitySource, entityChildrenBudgetCosts);
177 SetBudgets(api, entitySource, infoAncestor, infoCurrent,
path,
"m_EntityChildrenBudgetCost", entityChildrenBudgetCosts);
182 const string varName =
"m_EntityBudgetCost";
183 array<ref SCR_EntityBudgetValue> entityBudgetCosts = {};
184 PreserveBudgets(api, infoCurrent, varName, entityBudgetCosts);
187 BaseContainerList budgetList = infoAncestor.GetObjectArray(varName);
189 budgetListCount = budgetList.Count();
192 foreach (SCR_EntityBudgetValue budget : entityBudgetCosts)
194 api.CreateObjectArrayVariableMember(entitySource,
path, varName,
"SCR_EntityBudgetValue", budgetListCount);
197 api.SetVariableValue(entitySource, budgetPath,
"m_BudgetType",
typename.EnumToString(
EEditableEntityBudget, budget.GetBudgetType()));
198 api.SetVariableValue(entitySource, budgetPath,
"m_Value", budget.GetBudgetValue().ToString());
205 IEntityComponentSource slotCompositionComponent = SCR_BaseContainerTools.FindComponentSource(entitySource, SCR_SlotCompositionComponent);
206 if (slotCompositionComponent)
208 ResourceName slotPrefab = SCR_SlotCompositionComponentClass.GetSlotPrefab(slotCompositionComponent);
209 if (!slotPrefab.IsEmpty())
210 api.SetVariableValue(entitySource,
path,
"m_SlotPrefab", slotPrefab);
214 if (infoType.IsInherited(SCR_EditableGroupUIInfo))
216 IEntityComponentSource groupIdentitySource = SCR_BaseContainerTools.FindComponentSource(entitySource, SCR_GroupIdentityComponent);
217 if (groupIdentitySource)
219 BaseContainer symbolSource = groupIdentitySource.GetObject(
"m_MilitarySymbol");
222 SCR_MilitarySymbol symbol = SCR_MilitarySymbol.Cast(BaseContainerTools.CreateInstanceFromContainer(symbolSource));
223 Resource symbolResource = BaseContainerTools.CreateContainerFromInstance(symbol);
224 info.SetObject(
"m_MilitarySymbol", symbolResource.GetResource().ToBaseContainer());
232 protected void SetBudgets(WorldEditorAPI api, IEntitySource entitySource, BaseContainer info, BaseContainer infoCurrent, array<ref ContainerIdPathEntry>
path,
string varName, array<ref SCR_EntityBudgetValue> budgets)
234 PreserveBudgets(api, infoCurrent, varName, budgets);
236 api.ClearVariableValue(entitySource,
path, varName);
239 array<ref ContainerIdPathEntry> budgetPath = {};
245 budgetPath.Insert(null);
247 BaseContainerList budgetList;
251 budgetList = info.GetObjectArray(varName);
253 budgetListCount = budgetList.Count();
259 foreach (SCR_EntityBudgetValue entry : budgets)
262 int budgetValue = entry.GetBudgetValue();
266 for (
int l = 0; l < budgetListCount; l++)
268 if (budgetList.Get(l).Get(
"m_BudgetType", listBudgetType) && listBudgetType == budgetType)
270 if (budgetList.Get(l).Get(
"m_Value", listBudgetValue) && listBudgetValue == budgetValue)
286 index = budgetListCount;
288 api.CreateObjectArrayVariableMember(entitySource,
path, varName,
"SCR_EntityBudgetValue",
index);
293 api.SetVariableValue(entitySource, budgetPath,
"m_BudgetType",
typename.EnumToString(
EEditableEntityBudget, budgetType));
294 api.SetVariableValue(entitySource, budgetPath,
"m_Value", budgetValue.ToString());
299 protected void PreserveBudgets(WorldEditorAPI api, BaseContainer infoCurrent,
string varName, array<ref SCR_EntityBudgetValue> budgets)
301 BaseContainerList budgetList = infoCurrent.GetObjectArray(varName);
302 int budgetListCount = budgetList.Count();
304 for (
int l = 0; l < budgetListCount; l++)
306 budgetList.Get(l).Get(
"m_BudgetType", listBudgetType);
309 foreach (
int i, SCR_EntityBudgetValue entry : budgets)
311 if (entry.GetBudgetType() == listBudgetType)
322 budgetList.Get(l).Get(
"m_BudgetType", budgetType);
325 budgetList.Get(l).Get(
"m_Value", budgetValue);
327 budgets.Insert(
new SCR_EntityBudgetValue(budgetType, budgetValue));
333 protected void CreatePreviewImage(
334 notnull ResourceManager resourceManager,
335 EditablePrefabsConfig config,
337 out
string targetPath,
338 IEntitySource entitySource,
345 if (FileIO.FileExists(targetPath))
348 Workbench.GetAbsolutePath(targetPath, absolutePath);
349 MetaFile metaContainer = resourceManager.GetMetaFile(absolutePath);
350 targetPath = metaContainer.GetResourceID();
355 if (!targetPath.IsEmpty())
357 Print(
string.Format(
"Clearing missing preview image: '%1' for entity: '%2'", targetPath, entitySource.GetResourceName().GetPath()),
LogLevel.WARNING);
363 string sourceFile = FilePath.ReplaceExtension(FilePath.StripPath(targetPath), m_sImagePlaceholderExt);
364 if (sourceFile.IsEmpty() || m_sImagePlaceholderSource.IsEmpty())
368 string placeholderPath = m_ImagePlaceholder.GetPath();
370 Workbench.GetAbsolutePath(placeholderPath, absolutePath);
373 string imageDirectoryPath = FilePath.StripFileName(targetPath);
374 if (!config.CreateDirectoryFor(imageDirectoryPath, addonName))
378 FileIO.CopyFile(m_sImagePlaceholderPath + m_sImagePlaceholderSource, addonName + FilePath.StripFileName(targetPath) + sourceFile);
381 Workbench.GetAbsolutePath(addonName + FilePath.StripFileName(targetPath) + sourceFile, absolutePath,
false);
382 if (resourceManager.RegisterResourceFile(absolutePath,
false))
384 MetaFile metaContainer = resourceManager.GetMetaFile(absolutePath);
388 targetPath = metaContainer.GetResourceID();
389 BaseContainerList configurations = metaContainer.GetObjectArray(
"Configurations");
392 configurations.Get(0).Set(
"ColorSpace",
"ToSRGB");
393 metaContainer.Save();
394 Print(
string.Format(
"Editable entity preview image ADDED: @\"%1\"", targetPath),
LogLevel.DEBUG);
400 Print(
string.Format(
"Editable entity preview image creation FAILED: from @\"%1\"", entitySource.GetResourceName().GetPath()),
LogLevel.WARNING);
404 protected void DeletePreviewImage(EditablePrefabsConfig config,
string prefabPath)
407 if (!GetImagePath(config, prefabPath))
410 FileIO.DeleteFile(prefabPath);
411 FileIO.DeleteFile(prefabPath + META_EXTENSION);
414 prefabPath.Replace(IMG_EXTENSION, m_sImagePlaceholderExt);
415 FileIO.DeleteFile(prefabPath);
419 protected void MovePreviewImage(EditablePrefabsConfig config,
string currentPath,
string newPath)
422 if (!GetImagePath(config, currentPath))
425 if (!GetImagePath(config, newPath))
428 string currentSourcePath = currentPath;
429 string newSourcePath = newPath;
430 currentSourcePath.Replace(IMG_EXTENSION, m_sImagePlaceholderExt);
431 newSourcePath.Replace(IMG_EXTENSION, m_sImagePlaceholderExt);
433 FileIO.CopyFile(currentSourcePath, newSourcePath);
434 config.MoveFile(currentPath, newPath);
435 FileIO.DeleteFile(currentSourcePath);
439 protected bool GetImagePath(EditablePrefabsConfig config, out
string prefabPath)
441 if (m_sImagesPath.IsEmpty())
444 prefabPath = FilePath.ReplaceExtension(prefabPath, IMG_EXTENSION);
445 if (prefabPath.Replace(config.GetTargetPath(), m_sImagesPath) != 0)
448 if (prefabPath.Replace(config.GetSourcePath(), m_sImagesPath) != 0)
455 protected void SetEntityFlags(EditablePrefabsConfig config, WorldEditorAPI api, ResourceName prefab,
string targetPath, IEntitySource entitySource, IEntityComponentSource componentSource, IEntityComponentSource componentCurrent)
458 componentSource.Get(
"m_Flags", flagsOrig);
462 IEntityComponentSource compositionComponent = SCR_BaseContainerTools.FindComponentSource(entitySource, SCR_SlotCompositionComponent);
463 if (compositionComponent)
466 compositionComponent.Get(
"m_bOrientChildrenToTerrain", orientChildren);
470 flags =
flags & ~EEditableEntityFlag.ORIENT_CHILDREN;
473 if (
flags != flagsOrig)
474 componentSource.Set(
"m_Flags",
flags);
478 protected bool GetLabelsFromSource(WorldEditorAPI api, EditablePrefabsConfig config, ResourceName prefab,
string targetPath, IEntitySource entitySource, IEntityComponentSource componentSource, IEntityComponentSource componentSourceCurrent, notnull array<EEditableEntityLabel> autoLabels, notnull array<EEditableEntityLabel> authoredLabels)
483 if (componentSourceCurrent)
484 ReadEditableEntityComponent(componentSourceCurrent, entityType, authoredLabels);
486 ReadEditableEntityComponent(componentSource, entityType, authoredLabels);
489 foreach (EditablePrefabsLabel_Base labelRule : m_EntityLabelRules)
492 if (labelRule.GetLabelValid(api, entitySource, componentSource, targetPath, entityType, authoredLabels, label))
495 if (!autoLabels.Contains(label) && !authoredLabels.Contains(label))
496 autoLabels.Insert(label);
504 protected void ReadEditableEntityComponent(IEntityComponentSource componentSource, out
EEditableEntityType entityType, notnull array<EEditableEntityLabel> authoredLabels)
507 if (!componentSource)
510 BaseContainer componentUIInfoCurrent = componentSource.GetObject(
"m_UIInfo");
511 if (componentUIInfoCurrent)
512 componentUIInfoCurrent.Get(
"m_aAuthoredLabels", authoredLabels);
515 componentSource.Get(
"m_EntityType", entityType);
519 protected void GetEntityChildrenBudgetCostsFromSource(IEntitySource entitySource, out notnull array<ref SCR_EntityBudgetValue> entityBudgetCosts)
521 IEntityComponentSource compositionLinkComponent = SCR_BaseContainerTools.FindComponentSource(entitySource, SCR_EditorLinkComponent);
523 if (entitySource.GetClassName().ToType().IsInherited(
SCR_AIGroup))
524 GetEntityBudgetCostsFromGroup(entitySource, entityBudgetCosts);
525 else if (compositionLinkComponent)
526 GetEntityBudgetCostsFromLinkComponent(entitySource, compositionLinkComponent, entityBudgetCosts);
530 protected void GetEntityBudgetCostsFromVehicle(IEntitySource entitySource, out notnull array<ref SCR_EntityBudgetValue> crewBudgetCosts, out notnull array<ref SCR_EntityBudgetValue> passengerBudgetCosts, out notnull array<ECompartmentType> vehicleCompartmentTypes)
532 IEntityComponentSource componentSource;
533 typename componentType;
534 BaseContainerList slots;
535 BaseContainer slot, occupantData;
538 IEntitySource slotEntity;
540 array<IEntitySource> queue = {entitySource};
541 while (!queue.IsEmpty())
543 IEntitySource source = queue[0];
546 for (
int c = 0, componentCount = source.GetComponentCount(); c < componentCount; c++)
548 componentSource = source.GetComponent(c);
549 componentType = componentSource.GetClassName().ToType();
551 if (componentType.IsInherited(BaseCompartmentManagerComponent))
554 slots = componentSource.GetObjectArray(
"CompartmentSlots");
555 for (
int s = 0, slotCount = slots.Count(); s < slotCount; s++)
559 occupantData = slot.GetObject(
"m_DefaultOccupantData");
563 if (!occupantData.Get(
"m_sDefaultOccupantPrefab", prefab))
566 resource = Resource.Load(prefab);
567 if (!resource.IsValid())
570 slotEntity = SCR_BaseContainerTools.FindEntitySource(resource);
575 typename slotType = slot.GetClassName().ToType();
577 if (slotType.IsInherited(CargoCompartmentSlot))
579 AddBudgetCostsFromEntity(slotEntity, passengerBudgetCosts);
584 AddBudgetCostsFromEntity(slotEntity, crewBudgetCosts);
586 if (slotType.IsInherited(PilotCompartmentSlot))
592 if (!vehicleCompartmentTypes.Contains(compartmentType))
593 vehicleCompartmentTypes.Insert(compartmentType);
596 else if (componentType.IsInherited(SlotManagerComponent))
599 slots = componentSource.GetObjectArray(
"Slots");
600 for (
int s = 0, slotCount = slots.Count(); s < slotCount; s++)
602 if (!slots[s].
Get(
"Prefab", prefab))
605 resource = Resource.Load(prefab);
606 if (!resource.IsValid())
609 slotEntity = SCR_BaseContainerTools.FindEntitySource(resource);
611 queue.Insert(slotEntity);
619 protected void GetEntityBudgetCostsFromGroup(IEntitySource entitySource, out notnull array<ref SCR_EntityBudgetValue> entityBudgetCosts)
621 array<ResourceName> memberPrefabs = {};
623 entitySource.Get(
"m_aUnitPrefabSlots", memberPrefabs);
625 AddBudgetCostsFromEntities(memberPrefabs, entityBudgetCosts);
629 protected void GetEntityBudgetCostsFromLinkComponent(IEntitySource entitySource, IEntityComponentSource compositionLinkComponent, out notnull array<ref SCR_EntityBudgetValue> entityBudgetCosts)
631 array<ResourceName> childPrefabs = {};
633 if (compositionLinkComponent)
636 BaseContainerList entries = compositionLinkComponent.GetObjectArray(
"m_aEntries");
637 for (
int e = 0, count = entries.Count(); e < count; e++)
639 SCR_EditorLinkEntry compositionChild = SCR_EditorLinkEntry.Cast(BaseContainerTools.CreateInstanceFromContainer(entries.Get(e)));
640 if (!compositionChild)
643 resource = Resource.Load(compositionChild.m_Prefab);
644 if (!resource.IsValid())
647 IEntitySource childEntitySource = SCR_BaseContainerTools.FindEntitySource(resource);
648 if (!childEntitySource)
651 IEntityComponentSource childEditableEntity = SCR_BaseContainerTools.FindComponentSource(childEntitySource, SCR_EditableEntityComponent);
652 if (!childEditableEntity)
655 SCR_EditableEntityUIInfo childUiInfo = SCR_EditableEntityComponentClass.GetInfo(childEditableEntity);
659 array<ref SCR_EntityBudgetValue> entityPreviewBudgetCost = {};
662 SCR_EntityBudgetValue.MergeBudgetCosts(entityBudgetCosts, entityPreviewBudgetCost);
664 childPrefabs.Insert(compositionChild.m_Prefab);
668 AddBudgetCostsFromEntities(childPrefabs, entityBudgetCosts);
672 protected void AddBudgetCostsFromEntities(array<ResourceName> childPrefabs, out notnull array<ref SCR_EntityBudgetValue> entityBudgetCosts)
674 int childCount = childPrefabs.Count();
676 foreach (ResourceName childPrefab : childPrefabs)
678 resource = Resource.Load(childPrefab);
679 if (!resource.IsValid())
682 IEntitySource memberEntitySource = SCR_BaseContainerTools.FindEntitySource(resource);
683 if (memberEntitySource)
684 AddBudgetCostsFromEntity(memberEntitySource, entityBudgetCosts);
689 protected void AddBudgetCostsFromEntity(IEntitySource entitySource, out notnull array<ref SCR_EntityBudgetValue> entityBudgetCosts)
691 IEntityComponentSource editableEntitySource = SCR_EditableEntityComponentClass.GetEditableEntitySource(entitySource);
692 if (!editableEntitySource)
695 array<ref SCR_EntityBudgetValue> budgetCosts = {};
696 if (SCR_EditableEntityComponentClass.GetEntitySourceBudgetCost(editableEntitySource, budgetCosts))
698 SCR_EntityBudgetValue.MergeBudgetCosts(entityBudgetCosts, budgetCosts);
702 EEditableEntityBudget entityBudgetType = m_EntityCoreConfig.GetBudgetForEntityType(SCR_EditableEntityComponentClass.GetEntityType(editableEntitySource));
703 int minimumBudgetCost = m_MinBudgetCost.Get(entityBudgetType);
705 SCR_EntityBudgetValue.MergeBudgetCosts(entityBudgetCosts, {
new SCR_EntityBudgetValue(entityBudgetType, minimumBudgetCost) });
710 override void EOnCreate(EditablePrefabsConfig config, WorldEditorAPI api, ResourceName prefab,
string targetPath, IEntitySource entitySource, IEntitySource instanceEntitySource, IEntityComponentSource componentSource, IEntityComponentSource componentCurrent)
712 SetEntityFlags(config, api, prefab, targetPath, entitySource, componentSource, componentCurrent);
713 SetUIInfo(config, api, prefab, targetPath, entitySource, instanceEntitySource, componentSource, componentCurrent);
716 if (componentCurrent && componentCurrent.IsVariableSetDirectly(
"m_vIconPos"))
719 componentCurrent.Get(
"m_vIconPos", iconPos);
720 componentSource.Set(
"m_vIconPos", iconPos.ToString(
false));
725 override void EOnDelete(EditablePrefabsConfig config, WorldEditorAPI api,
string prefabPath)
727 DeletePreviewImage(config, prefabPath);
731 override void EOnMove(EditablePrefabsConfig config, WorldEditorAPI api,
string currentPath,
string newPath)
733 MovePreviewImage(config, currentPath, newPath);
738 void EditablePrefabsComponent_EditableEntity()
740 if (m_ImagePlaceholder.IsEmpty())
746 ResourceManager resourceManager = Workbench.GetModule(ResourceManager);
747 if (!resourceManager)
750 Resource resource = BaseContainerTools.LoadContainer(m_EntityCoreConfigPrefab);
751 BaseContainer configContainer = resource.GetResource().ToBaseContainer();
753 Managed configInstance = BaseContainerTools.CreateInstanceFromContainer(configContainer);
754 m_EntityCoreConfig = SCR_EditableEntityCore.Cast(configInstance);
755 if (!m_EntityCoreConfig)
757 Print(
"Editable entity core instance could not be created",
LogLevel.ERROR);
761 array<ref SCR_EditableEntityCoreBudgetSetting> budgetSettings = {};
762 m_EntityCoreConfig.GetBudgets(budgetSettings);
764 foreach (SCR_EditableEntityCoreBudgetSetting budget : budgetSettings)
766 m_MinBudgetCost.Set(budget.GetBudgetType(), budget.GetMinBudgetCost());
770 Workbench.GetAbsolutePath(m_ImagePlaceholder.GetPath(), absolutePath);
772 m_sImagesPath = m_ImagesDirectory.GetPath();
773 m_sImagePlaceholderPath = FilePath.StripFileName(m_ImagePlaceholder.GetPath());
775 MetaFile metaContainer = resourceManager.GetMetaFile(absolutePath);
780 BaseContainerList configurations = metaContainer.GetObjectArray(
"Configurations");
781 for (
int i = 0, count = configurations.Count(); i < count; i++)
783 BaseContainer configuration = configurations.Get(i);
786 configuration.Get(
"SourceFile", m_sImagePlaceholderSource);
787 if (!m_sImagePlaceholderSource.IsEmpty())
789 FilePath.StripExtension(m_sImagePlaceholderSource, m_sImagePlaceholderExt);
794 if (configuration.GetClassName() ==
"PNGResourceClass")
796 m_sImagePlaceholderExt =
"png";
797 m_sImagePlaceholderSource = FilePath.ReplaceExtension(m_ImagePlaceholder, m_sImagePlaceholderExt);
798 m_sImagePlaceholderSource = FilePath.StripPath(m_sImagePlaceholderSource);
803 Print(
string.Format(
"Placeholder file configuration is of type %1, must be PNGResourceClass!", configuration.GetClassName()),
LogLevel.ERROR);
SCR_EAIThreatSectorFlags flags
void ContainerIdPathEntry(string propertyName, int index=-1)
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
void SCR_AIGroup(IEntitySource src, IEntity parent)
SCR_CampaignMilitaryBaseComponent SCR_MilitaryBaseComponent SCR_BaseContainerCustomTitleResourceName("m_sBaseName", true)
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
void GetEntityChildrenBudgetCost(out notnull array< ref SCR_EntityBudgetValue > outBudgets)
Get only Entity's children budget costs, i.e. cost of entities inside a composition entitiy.
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
EEditableEntityType
Defines type of SCR_EditableEntityComponent. Assigned automatically based on IEntity inheritance.
EEditableEntityFlag
Unique flags of the entity.
SCR_FieldOfViewSettings Attribute