Arma Reforger Script API
Loading...
Searching...
No Matches
Static Public Member Functions | Static Public Attributes | Static Protected Member Functions | Static Protected Attributes | List of all members
SCR_PrefabHelper Interface Reference

Static Public Member Functions

static ResourceName ClonePrefab (ResourceName sourcePrefab, string absoluteFilePath)
 Create a clone of the provided prefab at the provided destination, overriding file if any Destination directory is created if it does not exist.
 
static ResourceName CreateChildPrefab (ResourceName sourcePrefab, string absoluteFilePath)
 Create a child of the provided prefab at the provided destination, overriding file if any Destination directory is created if it does not exist.
 
static array< ResourceName > CreatePrefabsFromXOBs (notnull array< ResourceName > xobs, string absoluteDirPath, ResourceName parentPrefab=string.Empty, bool createBasePrefab=false)
 Create Prefabs from the provided XOBs - only setting MeshObject to these Prefabs.
 
static ResourceName CreatePrefabFromXOB (ResourceName xob, string absoluteDestinationPath, ResourceName parentPrefab=string.Empty, bool createBasePrefab=false)
 Create Prefab from the provided XOB - only setting MeshObject to the Prefab.
 
static IEntitySource CreateEntitySource (ResourceName parentPrefab=string.Empty)
 Create an entity and return an IEntitySource Keeps the entity in the world, does NOT delete the entity itself.
 
static IEntityComponentSource CreateEntitySourceComponentIfNeeded (notnull IEntitySource entitySource, string componentClassname)
 Create and add a Component to the provided entitySource if not present.
 
static string GetResourceNameAbsolutePath (ResourceName resourceName, bool mustExist=true)
 Get the absolute file path of the provided resourceName.
 
static string GetRelativeParentDirectory (string relativeSourceDirectory, string relativeTargetDirectory)
 Gives the target's directory the source directory's hierarchy/path Relative paths are expected, so separator must be slash (/)
 
static ResourceName SaveEntitySourceAsPrefab (notnull IEntitySource entitySource, string absoluteDirPath, string prefabFileName, bool createBasePrefab=false)
 Save a Prefab from the provided IEntitySource, with a _base Prefab or not Destination directory is created if it does not exist Keeps the entity in the world, does NOT delete the entity itself.
 
static bool UpdatePrefab (IEntitySource actualPrefab)
 Update a Prefab.
 

Static Public Attributes

static const string PREFAB_BASE_SUFFIX = "_base"
 

Static Protected Member Functions

static IEntitySource CreateEntitySourceWithoutEntity (ResourceName parentPrefab=string.Empty)
 A wrapper method for CreateEntitySource + DeleteEntityFromSource and World Editor action management.
 
static IEntitySource CreateEntitySourceFromXOB (ResourceName xob, ResourceName parentPrefab=string.Empty)
 Create an entity from an XOB and return an IEntitySource Keeps the entity in the world, does NOT delete the entity itself.
 
static string FormatRelativePath (string relativePath)
 Format provided relative path, removing leading and trailing slashes, replacing antislashes by slashes, etc.
 
static bool BeginEntityAction ()
 Begin an Entity Action in World Editor API if required.
 
static void EndEntityAction (bool manageEditAction)
 End an Entity Action in World Editor API if required.
 

Static Protected Attributes

static const string MESHOBJECT_CLASSNAME = "MeshObject"
 
static const string DEFAULT_PARENT_PREFAB = "GenericEntity"
 
static const string PREFAB_DOTTED_EXTENSION = ".et"
 

Member Function Documentation

◆ BeginEntityAction()

static bool SCR_PrefabHelper.BeginEntityAction ( )
staticprotected

Begin an Entity Action in World Editor API if required.

Returns
true if a BeginEntityAction has been called and EndEntityAction has to be called by EndEntityAction(), false otherwise

◆ ClonePrefab()

static ResourceName SCR_PrefabHelper.ClonePrefab ( ResourceName  sourcePrefab,
string  absoluteFilePath 
)
static

Create a clone of the provided prefab at the provided destination, overriding file if any Destination directory is created if it does not exist.

Parameters
[in]absoluteFilePaththe directory is automatically created if needed and a trailing '.et' is automatically added if missing
Returns
created clone's ResourceName

◆ CreateChildPrefab()

static ResourceName SCR_PrefabHelper.CreateChildPrefab ( ResourceName  sourcePrefab,
string  absoluteFilePath 
)
static

Create a child of the provided prefab at the provided destination, overriding file if any Destination directory is created if it does not exist.

Parameters
[in]absoluteFilePaththe directory is automatically created if needed and a trailing '.et' is automatically added if missing
Returns
created child's ResourceName

◆ CreateEntitySource()

static IEntitySource SCR_PrefabHelper.CreateEntitySource ( ResourceName  parentPrefab = string::Empty)
static

Create an entity and return an IEntitySource Keeps the entity in the world, does NOT delete the entity itself.

Parameters
[in]parentPrefabif not provided, GenericEntity is used
Returns
created entity's IEntitySource or null on error

◆ CreateEntitySourceComponentIfNeeded()

static IEntityComponentSource SCR_PrefabHelper.CreateEntitySourceComponentIfNeeded ( notnull IEntitySource  entitySource,
string  componentClassname 
)
static

Create and add a Component to the provided entitySource if not present.

Parameters
[in]entitySource
[in]componentClassname
Returns
found or created component, null on error

◆ CreateEntitySourceFromXOB()

static IEntitySource SCR_PrefabHelper.CreateEntitySourceFromXOB ( ResourceName  xob,
ResourceName  parentPrefab = string::Empty 
)
staticprotected

Create an entity from an XOB and return an IEntitySource Keeps the entity in the world, does NOT delete the entity itself.

Parameters
[in]xobpath of the XOB to import
[in]parentPrefabif not provided, GenericEntity is used
Returns
created entity's IEntitySource

◆ CreateEntitySourceWithoutEntity()

static IEntitySource SCR_PrefabHelper.CreateEntitySourceWithoutEntity ( ResourceName  parentPrefab = string::Empty)
staticprotected

A wrapper method for CreateEntitySource + DeleteEntityFromSource and World Editor action management.

Parameters
[in]parentPrefabif not provided, GenericEntity is used
Returns
created entity's IEntitySource or null on error

◆ CreatePrefabFromXOB()

static ResourceName SCR_PrefabHelper.CreatePrefabFromXOB ( ResourceName  xob,
string  absoluteDestinationPath,
ResourceName  parentPrefab = string::Empty,
bool  createBasePrefab = false 
)
static

Create Prefab from the provided XOB - only setting MeshObject to the Prefab.

Destination directory is created if it does not exist The difference with CreatePrefabsFromXOBs is that providing the .et path extracts the final file name the base prefab (if requested) will be named accordingly (name without extension + '_base.et')

Parameters
[in]xobpath of the XOB to import
[in]absoluteDestinationPathcan be either a directory (a trailing '/' is automatically added if missing) or a file path (.et), the directory is automatically created if needed
[in]parentPrefabif not provided, GenericEntity is used
[in]createBasePrefabif a prefab_base.et should be created (from which prefab.et inherits)
Returns
created prefabs, null on error

◆ CreatePrefabsFromXOBs()

static array< ResourceName > SCR_PrefabHelper.CreatePrefabsFromXOBs ( notnull array< ResourceName >  xobs,
string  absoluteDirPath,
ResourceName  parentPrefab = string::Empty,
bool  createBasePrefab = false 
)
static

Create Prefabs from the provided XOBs - only setting MeshObject to these Prefabs.

Destination directory is created if it does not exist The difference with CreatePrefabFromXOB is that prefabs here cannot be named, their name will be based on XOB filename

Parameters
[in]xobslist of XOBs to import
[in]absoluteDirPatha trailing '/' is automatically added if missing
[in]parentPrefabif not provided, GenericEntity is used
[in]createBasePrefabif a prefab_base.et should be created (from which prefab.et inherits)
Returns
created prefabs, null on error

◆ EndEntityAction()

static void SCR_PrefabHelper.EndEntityAction ( bool  manageEditAction)
staticprotected

End an Entity Action in World Editor API if required.

Parameters
[in]manageEditActionif World Editor Entity Action should be terminated, result of an earlier BeginEntityAction call

◆ FormatRelativePath()

static string SCR_PrefabHelper.FormatRelativePath ( string  relativePath)
staticprotected

Format provided relative path, removing leading and trailing slashes, replacing antislashes by slashes, etc.

Parameters
[in]relativePaththe relative path
Returns
formatted relativePath

◆ GetRelativeParentDirectory()

static string SCR_PrefabHelper.GetRelativeParentDirectory ( string  relativeSourceDirectory,
string  relativeTargetDirectory 
)
static

Gives the target's directory the source directory's hierarchy/path Relative paths are expected, so separator must be slash (/)

string relativeSourceDirectory = "Assets/Rocks/Granite";
string relativeTargetDirectory = "Prefabs/Miniatures";
string result = GetRelativeParentDirectory(relativeSourceDirectory, relativeTargetDirectory);
Print(result); // Prefabs/Miniatures/Rocks/Granite
static string GetRelativeParentDirectory(string relativeSourceDirectory, string relativeTargetDirectory)
Gives the target's directory the source directory's hierarchy/path Relative paths are expected,...
Definition: SCR_PrefabHelper.c:447

See SCR_PrefabHelper.FormatRelativePath

Parameters
[in]relativeSourceDirectorythe relative source directory, e.g Assets/Rocks/Granite
[in]relativeTargetDirectorythe relative target directory, e.g Prefabs/Miniatures
Returns
target relative directory without leading or trailing slash, e.g Prefabs/Miniatures/Rocks/Granite

◆ GetResourceNameAbsolutePath()

static string SCR_PrefabHelper.GetResourceNameAbsolutePath ( ResourceName  resourceName,
bool  mustExist = true 
)
static

Get the absolute file path of the provided resourceName.

Parameters
[in]resourceNamethe resourceName from which to obtain the absolute file path
[in]mustExistif true, the file MUST exist to return a valid value
Returns
the provided resourceName's absolute file path or string.Empty on error / file not existing with mustExist true

◆ SaveEntitySourceAsPrefab()

static ResourceName SCR_PrefabHelper.SaveEntitySourceAsPrefab ( notnull IEntitySource  entitySource,
string  absoluteDirPath,
string  prefabFileName,
bool  createBasePrefab = false 
)
static

Save a Prefab from the provided IEntitySource, with a _base Prefab or not Destination directory is created if it does not exist Keeps the entity in the world, does NOT delete the entity itself.

Parameters
[in]absoluteDirPatha trailing '/' is automatically added if missing
[in]prefabFileNamea trailing '.et' is automatically added if missing
Returns
ResourceName, empty on error

◆ UpdatePrefab()

static bool SCR_PrefabHelper.UpdatePrefab ( IEntitySource  actualPrefab)
static

Update a Prefab.

Parameters
[in]actualPrefabthe spawned Prefab's IEntitySource ancestor
Returns
true on success, false on failure

Member Data Documentation

◆ DEFAULT_PARENT_PREFAB

const string SCR_PrefabHelper.DEFAULT_PARENT_PREFAB = "GenericEntity"
staticprotected

◆ MESHOBJECT_CLASSNAME

const string SCR_PrefabHelper.MESHOBJECT_CLASSNAME = "MeshObject"
staticprotected

◆ PREFAB_BASE_SUFFIX

const string SCR_PrefabHelper.PREFAB_BASE_SUFFIX = "_base"
static

◆ PREFAB_DOTTED_EXTENSION

const string SCR_PrefabHelper.PREFAB_DOTTED_EXTENSION = ".et"
staticprotected

The documentation for this interface was generated from the following file: