Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCE_EntityEditorEffect.c
Go to the documentation of this file.
1[BaseContainerProps(), SCR_BaseContainerCustomTitleResourceName("m_Prefab", true, "ENT: \"%1\"")]
8{
9 //---- REFACTOR NOTE START: Should be protected ----
10 [Attribute(params: "et", uiwidget: UIWidgets.ResourcePickerThumbnail, desc: "Spawned entity")]
11 private ResourceName m_Prefab;
12 //---- REFACTOR NOTE END ----
13
14 [Attribute(desc: "Spawn the entity only when no entities are passed to the event.")]
15 protected bool m_bNoEntities;
16
17 [Attribute(desc: "True to delete previous entity created by this effect when a new one is being created.")]
18 protected bool m_bReplacePrevious;
19
20 protected IEntity m_Entity;
21
22 //---- REFACTOR NOTE START: Not up to date with internal scripting style ----
28 {
29 return m_Entity;
30 }
31
32 override bool EOnActivate(SCR_BaseEditorComponent editorComponent, vector position = vector.Zero, set<SCR_EditableEntityComponent> entities = null)
33 {
34 if (position == vector.Zero) return false;
35
36 if (m_bNoEntities && entities && !entities.IsEmpty()) return false;
37
38 Resource resource = Resource.Load(m_Prefab);
39 if (!resource || !resource.IsValid())
40 {
41 Print(string.Format("Invalid prefab '%1'!", m_Prefab), LogLevel.WARNING);
42 return false;
43 }
44
45 IEntitySource entitySource = SCR_BaseContainerTools.FindEntitySource(resource);
46 if (!entitySource)
47 {
48 Print(string.Format("Prefab '%1' is not an entity!", m_Prefab), LogLevel.WARNING);
49 return false;
50 }
51
52 EntitySpawnParams spawnParams = new EntitySpawnParams;
53 spawnParams.Transform[3] = position;
54
55 //--- Apply scale from prefab
56 float scale;
57 entitySource.Get("scale", scale);
58 if (scale != 1)
59 {
60 spawnParams.Transform[0] = spawnParams.Transform[0] * scale;
61 spawnParams.Transform[1] = spawnParams.Transform[1] * scale;
62 spawnParams.Transform[2] = spawnParams.Transform[2] * scale;
63 }
64
66 SCR_EntityHelper.DeleteEntityAndChildren(m_Entity);
67 m_Entity = GetGame().SpawnEntityPrefab(resource, GetGame().GetWorld(), spawnParams);
68 return true;
69 }
70 //---- REFACTOR NOTE END ----
71};
vector scale
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
SCR_CampaignMilitaryBaseComponent SCR_MilitaryBaseComponent SCR_BaseContainerCustomTitleResourceName("m_sBaseName", true)
vector position
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Object holding reference to resource. In destructor release the resource.
Definition Resource.c:25
override bool EOnActivate(SCR_BaseEditorComponent editorComponent, vector position=vector.Zero, set< SCR_EditableEntityComponent > entities=null)
void EntitySpawnParams()
Definition gameLib.c:130
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
SCR_FieldOfViewSettings Attribute