Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCE_EntityEditorEffect.c
Go to the documentation of this file.
1 [BaseContainerProps(), SCR_BaseContainerCustomTitleResourceName("m_Prefab", true, "ENT: \"%1\"")]
8 {
9  [Attribute(params: "et", uiwidget: UIWidgets.ResourcePickerThumbnail, desc: "Spawned entity")]
10  private ResourceName m_Prefab;
11 
12  [Attribute(desc: "Spawn the entity only when no entities are passed to the event.")]
13  protected bool m_bNoEntities;
14 
15  [Attribute(desc: "True to delete previous entity created by this effect when a new one is being created.")]
16  protected bool m_bReplacePrevious;
17 
18  protected IEntity m_Entity;
19 
24  IEntity GetEntity()
25  {
26  return m_Entity;
27  }
28 
29  override bool EOnActivate(SCR_BaseEditorComponent editorComponent, vector position = vector.Zero, set<SCR_EditableEntityComponent> entities = null)
30  {
31  if (position == vector.Zero) return false;
32 
33  if (m_bNoEntities && entities && !entities.IsEmpty()) return false;
34 
35  Resource resource = Resource.Load(m_Prefab);
36  if (!resource || !resource.IsValid())
37  {
38  Print(string.Format("Invalid prefab '%1'!", m_Prefab), LogLevel.WARNING);
39  return false;
40  }
41 
42  IEntitySource entitySource = SCR_BaseContainerTools.FindEntitySource(resource);
43  if (!entitySource)
44  {
45  Print(string.Format("Prefab '%1' is not an entity!", m_Prefab), LogLevel.WARNING);
46  return false;
47  }
48 
49  EntitySpawnParams spawnParams = new EntitySpawnParams;
50  spawnParams.Transform[3] = position;
51 
52  //--- Apply scale from prefab
53  float scale;
54  entitySource.Get("scale", scale);
55  if (scale != 1)
56  {
57  spawnParams.Transform[0] = spawnParams.Transform[0] * scale;
58  spawnParams.Transform[1] = spawnParams.Transform[1] * scale;
59  spawnParams.Transform[2] = spawnParams.Transform[2] * scale;
60  }
61 
62  if (m_bReplacePrevious)
63  SCR_EntityHelper.DeleteEntityAndChildren(m_Entity);
64  m_Entity = GetGame().SpawnEntityPrefab(resource, GetGame().GetWorld(), spawnParams);
65  return true;
66  }
67 };
SCR_EntityHelper
Definition: SCR_EntityHelper.c:1
SCR_BaseContainerCustomTitleResourceName
SCR_CampaignMilitaryBaseComponent SCR_MilitaryBaseComponent SCR_BaseContainerCustomTitleResourceName("m_sBaseName", true)
Definition: SCR_CampaignMilitaryBaseComponent.c:2522
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
m_Entity
enum EAITargetInfoCategory m_Entity
SCR_BaseEditorComponent
Definition: SCR_BaseEditorComponent.c:119
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_BaseContainerTools
Definition: SCR_BaseContainerTools.c:3
SCR_EntityEditorEffect
Definition: SCE_EntityEditorEffect.c:7
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
m_Prefab
ResourceName m_Prefab
Definition: ForestGeneratorObjects.c:48
position
vector position
Definition: SCR_DestructibleTreeV2.c:30
SCR_BaseEditorEffect
Definition: SCR_BaseEditorEffect.c:7
BaseContainerProps
SCR_AIGoalReaction_Follow BaseContainerProps
Handles insects that are supposed to be spawned around selected prefabs defined in prefab names array...
Definition: SCR_AIGoalReaction.c:468