3class EditablePrefabsConfig
5 [
Attribute(defvalue:
"Prefabs",
desc:
"Source directory where all prefabs are placed.",
params:
"unregFolders")]
6 protected ResourceName m_SourceDirectory;
8 [
Attribute(defvalue:
"PrefabsEditable",
desc:
"Target directory where editable sub-prefabs will be crated.\nFolder structure inside will mimic the structure in the source directory.",
params:
"folders")]
9 protected ResourceName m_TargetDirectory;
11 [
Attribute(defvalue:
"Auto",
desc:
"Auto-generated Prefabs folder name")]
12 protected string m_sAutoFolderName;
14 [
Attribute(defvalue:
"E_",
desc:
"Prefix added before file name of each prefab (i.e., editable entity prefab of 'Car.et' will be 'E_Car.et')")]
15 protected string m_sFileNamePrefix;
17 [
Attribute(defvalue:
"",
desc:
"Ignore file names containing this string. To define mutliple, separate them by a comma (without a space afterwards).")]
18 protected string m_sSourceBlacklist;
20 [
Attribute(
desc:
"Entities that will be created in temporary world to ensure correct functionality (e.g., AIWorld for AI groups)",
params:
"et")]
21 protected ref array<ResourceName> m_SupportEntities;
24 protected ref array<ref EditablePrefabsSetting> m_Settings;
26 protected bool m_bIsValid;
27 protected string m_sSourcePath;
28 protected string m_sTargetPath;
29 protected string m_sTargetPathAuto;
30 protected ref map<string, string> m_mLinksFromTarget;
31 protected ref map<string, string> m_mLinksFromSource;
32 protected ref array<string> m_aSourceBlacklist = {};
33 protected string m_sCurrentAddon =
"$ArmaReforger:";
35 protected static const string ADDON_PREFIX =
"$profile:";
36 protected static const string WORLD_PATH =
"worlds/Plugins/EditablePrefabsConfig";
37 protected static const string WORLD_NAME =
"EditablePrefabsWorld";
38 protected static const string META_EXTENSION =
".meta";
39 protected static const string COPY_EXTENSION =
"_copy";
49 void CreateEditablePrefab(WorldEditorAPI api, ResourceName prefab,
bool onlyUpdate =
false, map<string, SCR_EEditablePrefabResult> results = null)
54 if (IsBlacklisted(prefab))
57 results.Set(
string.Format(
"@\"%1\"", prefab.GetPath()), SCR_EEditablePrefabResult.IGNORED);
61 if (!m_mLinksFromSource)
64 string addonName = SCR_AddonTool.GetResourceLastAddon(prefab);
65 m_sCurrentAddon = SCR_AddonTool.ToFileSystem(addonName);
68 string prefabPath = prefab.GetPath();
69 if (prefabPath.StartsWith(m_sTargetPath))
72 if (prefabPath.StartsWith(m_sTargetPathAuto))
75 prefab = GetSourcePrefab(prefab);
83 Print(
string.Format(
"Cannot update editable prefab @\"%1\", it's not auto-generated (i.e., not in '%2' folder)!", prefabPath, m_sTargetPathAuto),
LogLevel.WARNING);
90 Resource prefabResource = Resource.Load(prefab);
91 if (prefabResource && SCR_EditableEntityComponentClass.GetEditableEntitySource(prefabResource))
94 UpdateEditablePrefab(api, prefab);
100 ResourceName existingPrefab;
101 exists = GetLinkFromSource(SCR_ConfigHelper.GetGUID(prefab,
true), existingPrefab);
103 if (existingPrefab.IsEmpty())
108 string prefabName = FilePath.StripPath(prefabPath);
109 prefabPath.Replace(prefabName, m_sFileNamePrefix + prefabName);
110 prefabPath.Replace(m_sSourcePath, m_sTargetPathAuto);
115 prefabPath = existingPrefab.GetPath();
121 string directoryPath = FilePath.StripFileName(prefabPath);
122 if (!CreateDirectoryFor(directoryPath))
125 IEntitySource entitySource = api.CreateEntity(prefab,
"", api.GetCurrentEntityLayerId(), null, vector.Zero, vector.Zero);
128 Print(
string.Format(
"Unable to create entity %1!", prefab),
LogLevel.ERROR);
133 entitySource.ClearVariable(
"coords");
136 api.SetVariableValue(entitySource, null,
"placement",
"none");
140 bool editableChildren =
true;
141 IEntityComponentSource compositionComponentSource = SCR_BaseContainerTools.FindComponentSource(entitySource, SCR_SlotCompositionComponent);
142 if (compositionComponentSource)
144 compositionComponentSource.Get(
"m_bEditableChildren", editableChildren);
145 SCR_SlotCompositionComponent compositionComponent = SCR_SlotCompositionComponent.Cast(api.SourceToEntity(entitySource).
FindComponent(SCR_SlotCompositionComponent));
147 if (compositionComponent)
148 needSave = compositionComponent._WB_ConfigureComposition(api, entitySource.GetAncestor());
153 IEntitySource currentEntitySource;
154 Resource currentResource = Resource.Load(prefabPath);
155 if (currentResource && currentResource.IsValid())
156 currentEntitySource = currentResource.GetResource().ToEntitySource();
159 array<ref SCR_EditorLinkEntry> links = {};
160 if (editableChildren && !UpdateChildPrefabs(api, entitySource, links, results: results))
163 results.Set(
string.Format(
"@\"%1\"", prefab.GetPath()), SCR_EEditablePrefabResult.FAILED);
166 api.DeleteEntity(entitySource);
167 entitySource.Release(
true);
172 if (links.Count() != 0)
175 IEntityComponentSource linkComponent = api.CreateComponent(entitySource,
"SCR_EditorLinkComponent");
176 foreach (
int i, SCR_EditorLinkEntry entry : links)
178 if (api.CreateObjectArrayVariableMember(entitySource, {ContainerIdPathEntry(
"SCR_EditorLinkComponent")},
"m_aEntries",
"SCR_EditorLinkEntry", i))
181 api.SetVariableValue(entitySource, entryPath,
"m_Prefab", entry.m_Prefab);
182 api.SetVariableValue(entitySource, entryPath,
"m_vPosition", entry.m_vPosition.ToString(
false));
183 api.SetVariableValue(entitySource, entryPath,
"m_vAngles", entry.m_vAngles.ToString(
false));
184 api.SetVariableValue(entitySource, entryPath,
"m_fScale", entry.m_fScale.ToString());
187 if (hasVariants == 0)
188 hasVariants = SCR_EditableEntityComponentClass.HasVariants(entry.m_Prefab);
192 api.SetVariableValue(entitySource, {
ContainerIdPathEntry(
"SCR_EditorLinkComponent")},
"m_bRandomizeVariants", hasVariants.ToString());
198 EditablePrefabsSetting settings = GetSettings(prefabPath);
200 settings.AddComponents(
this, api, prefab, prefabPath, entitySource, currentEntitySource, entitySource);
204 Workbench.GetAbsolutePath(m_sCurrentAddon + prefabPath, absolutePath,
false);
207 string metaPath = prefabPath + META_EXTENSION;
208 string metaPathCopy = metaPath + COPY_EXTENSION;
209 array<string> backup = {};
212 BackupFile(prefabPath, backup);
213 FileIO.CopyFile(metaPath, metaPathCopy);
217 api.CreateEntityTemplate(entitySource, absolutePath);
222 CompareBackup(prefabPath, backup);
223 FileIO.CopyFile(metaPathCopy, metaPath);
224 FileIO.DeleteFile(metaPathCopy);
229 Workbench.GetModule(WorldEditor).Save();
231 api.DeleteEntity(entitySource);
232 entitySource.Release(
true);
237 results.Set(
string.Format(
"@\"%1\" from @\"%2\"", prefabPath, prefab.GetPath()), SCR_EEditablePrefabResult.UPDATED);
243 results.Set(
string.Format(
"@\"%1\" from @\"%2\"", prefabPath, prefab.GetPath()), SCR_EEditablePrefabResult.CREATED);
252 void UpdateEditablePrefab(WorldEditorAPI api, ResourceName prefab)
254 IEntitySource entitySource = api.CreateEntity(prefab,
"", api.GetCurrentEntityLayerId(), null, vector.Zero, vector.Zero);
255 IEntitySource prefabSource = entitySource.GetAncestor();
259 string prefabPath = prefab.GetPath();
260 EditablePrefabsSetting settings = GetSettings(prefabPath);
262 settings.AddComponents(
this, api, prefab, prefabPath, prefabSource, prefabSource, entitySource);
264 WorldEditor worldEditor = Workbench.GetModule(WorldEditor);
267 api.DeleteEntity(entitySource);
268 entitySource.Release(
true);
270 Print(
string.Format(
"Editable entity UPDATED: @\"%1\"", prefabPath),
LogLevel.DEBUG);
279 string VerifyEditablePrefab(WorldEditorAPI api, ResourceName prefab,
bool onlyFileChanges =
false)
281 Resource prefabResource = Resource.Load(prefab);
282 if (!prefabResource || !prefabResource.IsValid())
285 BaseResourceObject prefabBase = prefabResource.GetResource();
289 IEntitySource prefabEntity = prefabBase.ToEntitySource();
293 string prefabPath = prefab.GetPath();
294 IEntitySource ancestorEntity = prefabEntity.GetAncestor();
297 string correctPath = ancestorEntity.GetResourceName().GetPath();
298 correctPath.Replace(m_sSourcePath, m_sTargetPathAuto);
300 string correctName = FilePath.StripPath(correctPath);
301 correctPath.Replace(correctName, m_sFileNamePrefix + correctName);
304 if (prefabPath != correctPath)
305 prefab = MoveEditablePrefab(api, prefabPath, correctPath);
308 if (!onlyFileChanges)
309 CreateEditablePrefab(api, prefab);
316 DeleteEditablePrefab(api, prefabPath);
327 protected ResourceName MoveEditablePrefab(WorldEditorAPI api,
string prevPath,
string newPath)
329 if (!MoveFile(prevPath, newPath))
330 return ResourceName.Empty;
332 EditablePrefabsSetting settings = GetSettings(newPath);
334 settings.Move(
this, api, prevPath, newPath);
339 Workbench.GetAbsolutePath(newPath, absPath);
340 if (absPath.IsEmpty())
342 Print(
string.Format(
"Cannot MOVE '%1', unable to find absolute path for '%2'!", prevPath, newPath),
LogLevel.ERROR);
343 return ResourceName.Empty;
346 Print(
string.Format(
"Editable entity MOVED:\n Old: '%1'\n New: '%2'", prevPath, newPath),
LogLevel.WARNING);
348 ResourceManager resourceManager = Workbench.GetModule(ResourceManager);
349 resourceManager.RegisterResourceFile(absPath,
false);
350 return Workbench.GetResourceName(absPath);
355 protected void DeleteEditablePrefab(WorldEditorAPI api,
string prefabPath)
357 FileIO.DeleteFile(prefabPath);
358 FileIO.DeleteFile(prefabPath + META_EXTENSION);
360 EditablePrefabsSetting settings = GetSettings(prefabPath);
362 settings.Delete(
this, api, prefabPath);
364 Print(
string.Format(
"Editable entity DELETED '%1' (its source no longer exists)!", prefabPath),
LogLevel.WARNING);
441 bool MoveFile(
string prevPath,
string newPath)
443 if (prevPath == newPath)
445 Print(
string.Format(
"Cannot MOVE '%1', target path is the same as current path!", prevPath),
LogLevel.ERROR);
448 if (newPath.IsEmpty())
450 Print(
string.Format(
"Cannot MOVE '%1', target path is empty!", prevPath),
LogLevel.ERROR);
454 string newDirectory = FilePath.StripFileName(newPath);
455 if (!CreateDirectoryFor(newDirectory))
459 FileIO.CopyFile(prevPath, newPath);
460 FileIO.DeleteFile(prevPath);
463 string prevMetaPath = prevPath + META_EXTENSION;
464 string newMetaPath = newPath + META_EXTENSION;
465 if (FileIO.FileExists(prevMetaPath))
467 FileIO.CopyFile(prevMetaPath, newMetaPath + COPY_EXTENSION);
468 FileIO.DeleteFile(prevMetaPath);
469 FileIO.CopyFile(newMetaPath + COPY_EXTENSION, newMetaPath);
470 FileIO.DeleteFile(newMetaPath + COPY_EXTENSION);
479 void LogResults(notnull map<string, SCR_EEditablePrefabResult> results)
481 map<SCR_EEditablePrefabResult, LogLevel> logLevels =
new map<SCR_EEditablePrefabResult, LogLevel>();
482 logLevels.Insert(SCR_EEditablePrefabResult.FAILED,
LogLevel.ERROR);
483 logLevels.Insert(SCR_EEditablePrefabResult.CREATED,
LogLevel.DEBUG);
484 logLevels.Insert(SCR_EEditablePrefabResult.UPDATED,
LogLevel.DEBUG);
485 logLevels.Insert(SCR_EEditablePrefabResult.MOVED,
LogLevel.DEBUG);
486 logLevels.Insert(SCR_EEditablePrefabResult.DELETED,
LogLevel.WARNING);
487 logLevels.Insert(SCR_EEditablePrefabResult.NON_EDITABLE,
LogLevel.VERBOSE);
488 logLevels.Insert(SCR_EEditablePrefabResult.IGNORED,
LogLevel.VERBOSE);
490 typename resultTypeName = SCR_EEditablePrefabResult;
491 SCR_EEditablePrefabResult resultQueried;
494 for (
int i = 0, count = resultTypeName.GetVariableCount(); i < count; i++)
496 resultTypeName.GetVariableValue(null, i, resultQueried);
497 resultName = resultTypeName.GetVariableName(i);
498 logLevel = logLevels.Get(resultQueried);
500 foreach (
string resourceName, SCR_EEditablePrefabResult result : results)
502 if (result == resultQueried)
503 Print(
string.Format(
"Editable Entity %1: %2", resultName,
resourceName), logLevel);
513 protected bool UpdateChildPrefabs(WorldEditorAPI api, IEntitySource entitySource, array<ref SCR_EditorLinkEntry> links,
bool forceDisable =
false, map<string, SCR_EEditablePrefabResult> results = null,
int depth = 0)
515 ResourceName ancestor, prefabEditable;
517 BaseContainer ancestorSource;
518 bool prefabFound, sourcePrefabFound;
520 for (
int e = 0, childrenCount = entitySource.GetNumChildren(); e < childrenCount; e++)
522 child = entitySource.GetChild(e);
524 sourcePrefabFound =
false;
525 bool forceDisableChildren = forceDisable;
530 api.SetVariableValue(child, null,
"Flags",
EntityFlags.EDITOR_ONLY.ToString());
535 ancestorSource = child.GetAncestor();
536 while (ancestorSource)
538 ancestor = ancestorSource.GetResourceName();
539 if (ancestor.Contains(
"/"))
541 ancestor = Workbench.GetResourceName(ancestor);
543 if (SCR_BaseContainerTools.FindComponentSource(child, SCR_EditableEntityComponent))
546 prefabEditable = ancestor;
550 prefabFound = GetLinkFromSource(SCR_ConfigHelper.GetGUID(ancestor,
true), prefabEditable);
551 sourcePrefabFound = GetLinkFromTarget(SCR_ConfigHelper.GetGUID(ancestor,
true));
555 ancestorSource = ancestorSource.GetAncestor();
565 child.Get(
"angles",
angles);
568 child.Get(
"scale",
scale);
574 api.SetVariableValue(child, null,
"Flags",
EntityFlags.EDITOR_ONLY.ToString());
575 forceDisableChildren =
true;
577 else if (sourcePrefabFound)
580 Print(
string.Format(
"Child entity of type '%1' is already auto-generated! Source compositions must not contain any editable prefabs from '%2/%3'!", GetResourceNameLink(child), m_TargetDirectory, m_sAutoFolderName),
LogLevel.WARNING);
592 results.Set(GetResourceNameLink(child), SCR_EEditablePrefabResult.NON_EDITABLE);
594 if (!SCR_BaseContainerTools.FindComponentSource(child,
"Hierarchy"))
597 api.CreateComponent(child,
"Hierarchy");
603 isValid &= UpdateChildPrefabs(api, child, links, forceDisableChildren, results, depth + 1);
609 protected void DisableComponent(WorldEditorAPI api, IEntitySource entitySource, BaseContainer componentSource, array<ref ContainerIdPathEntry> componentsPath)
611 if (!componentSource)
614 array<ref ContainerIdPathEntry> componentsPathNew = {};
617 componentsPathNew.Insert(entry);
621 if (componentSource.GetClassName() !=
"Hierarchy")
622 api.SetVariableValue(entitySource, componentsPathNew,
"Enabled",
"0");
624 BaseContainerList components = componentSource.GetObjectArray(
"components");
627 int componentsCount = components.Count();
628 for (
int i = 0; i < componentsCount; i++)
630 DisableComponent(api, entitySource, components.Get(i), componentsPathNew);
636 protected void BackupFile(
string filePath, out notnull array<string> backup)
638 FileHandle file = FileIO.OpenFile(filePath,
FileMode.READ);
640 while (file.ReadLine(line) > 0)
648 protected void CompareBackup(
string filePath, notnull array<string> backup)
650 FileHandle file = FileIO.OpenFile(filePath,
FileMode.READ);
653 int backupCount = backup.Count();
655 while (file.ReadLine(line) > 0)
657 if (i >= backupCount)
663 if (line != backup[i])
665 if (line.Contains(
".ct"))
687 file = FileIO.OpenFile(filePath,
FileMode.WRITE);
694 protected ResourceName GetResourceNameLink(BaseContainer container)
699 if (container.GetResourceName().Contains(
"/"))
701 resourceName =
string.Format(
"@\"%1\"", container.GetResourceName().GetPath());
704 container = container.GetAncestor();
710 protected EditablePrefabsSetting GetSettings(
string prefabPath)
712 EditablePrefabsSetting settings = null;
713 int pathLengthMax = -1;
714 foreach (EditablePrefabsSetting settingsTemp : m_Settings)
716 string targetPath = settingsTemp.GetTarget();
717 int pathLength = targetPath.Length();
718 if (prefabPath.StartsWith(targetPath) && pathLength > pathLengthMax)
720 settings = settingsTemp;
721 pathLengthMax = pathLength;
728 protected bool IsBlacklisted(
string path)
730 foreach (
string entry : m_aSourceBlacklist)
732 if (
path.Contains(entry))
745 string GetSourcePath()
747 return m_sSourcePath;
753 string GetTargetPath()
755 return m_sTargetPath;
761 string GetTargetPathAuto()
763 return m_sTargetPathAuto;
771 return m_sFileNamePrefix;
782 static EditablePrefabsConfig
GetConfig(ResourceName configPath)
784 Resource configResource = Resource.Load(configPath);
785 if (!configResource.IsValid())
787 Print(
string.Format(
"Cannot load config '%1'!", configPath),
LogLevel.ERROR);
791 BaseResourceObject configContainer = configResource.GetResource();
792 if (!configContainer)
795 BaseContainer configBase = configContainer.ToBaseContainer();
799 if (configBase.GetClassName() !=
"EditablePrefabsConfig")
801 Print(
string.Format(
"Config '%1' is of type '%2', must be 'EditablePrefabsConfig'!", configPath, configBase.GetClassName()),
LogLevel.ERROR);
805 return EditablePrefabsConfig.Cast(BaseContainerTools.CreateInstanceFromContainer(configBase));
821 bool CreateDirectoryFor(out
string filePath,
string addon =
"")
823 array<string> directories = {};
824 filePath.Split(
"/", directories,
true);
826 int directoriesCount = directories.Count();
827 if (directoriesCount == 0)
831 addon = m_sCurrentAddon;
834 for (
int i = 0; i < directoriesCount; i++)
836 filePath = FilePath.Concat(filePath, directories[i]);
838 if (!FileIO.MakeDirectory(filePath))
840 Print(
string.Format(
"Unable to create directory '%1'!", filePath),
LogLevel.ERROR);
853 WorldEditor worldEditor = Workbench.GetModule(WorldEditor);
857 WorldEditorAPI api = worldEditor.GetApi();
863 api.GetWorldPath(currentWorld);
864 if (currentWorld == ADDON_PREFIX + WORLD_PATH +
"/" +
WORLD_NAME +
".ent")
867 string worldPath = SCR_WorldFilesHelper.CreateWorld(ADDON_PREFIX + WORLD_PATH,
WORLD_NAME, m_SupportEntities,
false,
true);
868 if (worldPath.IsEmpty())
870 Print(
"Cannot create Editable Prefabs world files",
LogLevel.WARNING);
875 if (!worldEditor.SetOpenedResource(worldPath))
877 Print(
"Cannot open Editable Prefabs world - if the world was just created, try restarting Workbench - " + worldPath,
LogLevel.NORMAL);
887 void GetLinks(
bool forced =
false)
890 if (!forced && m_mLinksFromTarget && m_mLinksFromSource)
893 m_mLinksFromTarget =
new map<string, string>();
894 m_mLinksFromSource =
new map<string, string>();
896 ref array<ResourceName> resources = {};
897 SearchResourcesFilter filter =
new SearchResourcesFilter();
898 filter.fileExtensions = {
"et" };
899 ResourceDatabase.SearchResources(filter, resources.Insert);
901 string prefabPath, prefabGUID, ancestorGUID;
902 ResourceName ancestor;
903 Resource prefabResource;
904 IEntitySource entitySource, ancestorSource;
905 foreach (ResourceName prefab : resources)
907 prefabPath = prefab.GetPath();
908 if (!prefabPath.StartsWith(m_sTargetPathAuto))
911 prefabResource = Resource.Load(prefab);
912 if (!prefabResource || !prefabResource.IsValid())
915 entitySource = SCR_BaseContainerTools.FindEntitySource(prefabResource);
919 ancestorSource = entitySource.GetAncestor();
923 ancestor = ancestorSource.GetResourceName();
925 prefabGUID = SCR_ConfigHelper.GetGUID(prefab,
true);
926 ancestorGUID = SCR_ConfigHelper.GetGUID(ancestor,
true);
928 m_mLinksFromTarget.Insert(prefabGUID, ancestor);
929 m_mLinksFromSource.Insert(ancestorGUID, prefab);
938 bool GetLinkFromSource(
string guid, out ResourceName linkedPrefab = ResourceName.Empty)
940 return m_mLinksFromSource.Find(guid, linkedPrefab);
949 bool GetLinkFromTarget(
string guid, out ResourceName linkedPrefab = ResourceName.Empty)
951 return m_mLinksFromTarget.Find(guid, linkedPrefab);
957 bool IsEditableEntity(ResourceName prefab)
959 return prefab.GetPath().StartsWith(m_sTargetPath);
966 ResourceName GetSourcePrefab(ResourceName prefab)
968 if (!IsEditableEntity(prefab))
969 return ResourceName.Empty;
971 Resource prefabResource = Resource.Load(prefab);
972 if (!prefabResource.IsValid())
973 return ResourceName.Empty;
975 IEntitySource prefabEntity = SCR_BaseContainerTools.FindEntitySource(prefabResource);
977 return ResourceName.Empty;
979 IEntitySource ancestorEntity = prefabEntity.GetAncestor();
981 return ResourceName.Empty;
983 return ancestorEntity.GetResourceName();
988 void EditablePrefabsConfig()
990 if (m_SourceDirectory.IsEmpty())
991 Print(
"Cannot use config EditablePrefabsConfig, m_SourceDirectory attribute is empty!",
LogLevel.ERROR);
993 if (m_TargetDirectory.IsEmpty())
994 Print(
"Cannot use config EditablePrefabsConfig, m_TargetDirectory attribute is empty!",
LogLevel.ERROR);
997 m_sSourcePath = m_SourceDirectory.GetPath();
998 m_sTargetPath = m_TargetDirectory.GetPath();
999 m_sTargetPathAuto = m_sTargetPath +
"/" + m_sAutoFolderName;
1000 m_sSourceBlacklist.Split(
",", m_aSourceBlacklist,
true);
1005class EditablePrefabsSetting
1011 protected ref array<ref EditablePrefabsComponent_Base> m_Components;
1029 void AddComponents(EditablePrefabsConfig config, WorldEditorAPI api, ResourceName prefab,
string targetPath, IEntitySource entitySource, IEntitySource currentEntitySource, IEntitySource instanceEntitySource)
1032 BaseContainer componentContainer, componentCurrent;
1033 map<string, BaseContainer> sourceComponentClasses =
new map<string, BaseContainer>;
1034 int componentsCount = entitySource.GetComponentCount();
1035 for (
int i = 0; i < componentsCount; i++)
1037 componentContainer = entitySource.GetComponent(i);
1038 sourceComponentClasses.Insert(componentContainer.GetClassName(), componentContainer);
1042 map<string, BaseContainer> currentComponentClasses =
new map<string, BaseContainer>;
1043 if (currentEntitySource)
1045 componentsCount = currentEntitySource.GetComponentCount();
1046 for (
int i = 0; i < componentsCount; i++)
1048 componentContainer = currentEntitySource.GetComponent(i);
1049 currentComponentClasses.Insert(componentContainer.GetClassName(), componentContainer);
1054 Resource componentResource;
1055 BaseResourceObject componentBase;
1056 foreach (EditablePrefabsComponent_Base component : m_Components)
1059 if (!sourceComponentClasses.Find(component.GetClassName(), componentContainer))
1060 componentContainer = component.AddComponent(config, api, prefab, targetPath, entitySource);
1062 if (componentContainer)
1066 componentContainer.Get(
"Enabled", enabled);
1068 api.SetVariableValue(entitySource, {
new ContainerIdPathEntry(componentContainer.GetClassName()) },
"Enabled",
"1");
1070 currentComponentClasses.Find(component.GetClassName(), componentCurrent);
1071 component.EOnCreate(config, api, prefab, targetPath, entitySource, instanceEntitySource, componentContainer, componentCurrent);
1072 sourceComponentClasses.Insert(componentContainer.GetClassName(), componentContainer);
1082 void Delete(EditablePrefabsConfig config, WorldEditorAPI api,
string prefabPath)
1084 foreach (EditablePrefabsComponent_Base component : m_Components)
1086 component.EOnDelete(config, api, prefabPath);
1096 void Move(EditablePrefabsConfig config, WorldEditorAPI api,
string currentPath,
string newPath)
1098 foreach (EditablePrefabsComponent_Base component : m_Components)
1100 component.EOnMove(config, api, currentPath, newPath);
1105enum SCR_EEditablePrefabResult
void ContainerIdPathEntry(string propertyName, int index=-1)
ref array< string > angles
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
ResourceName resourceName
class SCR_AIPolar m_Target
@ FAILED
Job failed during its processing and can be retried.
SCR_CampaignMilitaryBaseComponent SCR_MilitaryBaseComponent SCR_BaseContainerCustomTitleResourceName("m_sBaseName", true)
@ DELETED
Character was deleted.
override bool Delete(bool changedByUser=false, bool updateNavmesh=true)
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
proto external Managed FindComponent(typename typeName)
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
SCR_FieldOfViewSettings Attribute
EntityFlags
Various entity flags.
FileMode
Mode for opening file. See FileSystem::Open.