Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_LightningContextAction.c
Go to the documentation of this file.
3 {
4  [Attribute("{A8FFCD3F3697D77F}Prefabs/Editor/Lightning/LightningStrike.et")]
5  protected ResourceName m_sLightningPrefab;
6 
7 
8  override bool CanBeShown(SCR_EditableEntityComponent hoveredEntity, notnull set<SCR_EditableEntityComponent> selectedEntities, vector cursorWorldPosition, int flags)
9  {
10  ChimeraWorld world = GetGame().GetWorld();
11  if (world.IsGameTimePaused())
12  return false;
13 
14  //~ Only allow lightning strike if entity has a position
15  vector positionCheck;
16  return !hoveredEntity || hoveredEntity.GetPos(positionCheck);
17  }
18 
19  override bool CanBePerformed(SCR_EditableEntityComponent hoveredEntity, notnull set<SCR_EditableEntityComponent> selectedEntities, vector cursorWorldPosition, int flags)
20  {
21  return CanBeShown(hoveredEntity, selectedEntities, cursorWorldPosition, flags);
22  }
23 
24  override void Perform(SCR_EditableEntityComponent hoveredEntity, notnull set<SCR_EditableEntityComponent> selectedEntities, vector cursorWorldPosition,int flags, int param = -1)
25  {
26  if (hoveredEntity)
27  hoveredEntity.GetPos(cursorWorldPosition);
28 
29  Resource resource = Resource.Load(m_sLightningPrefab);
30  if (!resource)
31  return;
32 
33  IEntitySource entitySource = SCR_BaseContainerTools.FindEntitySource(resource);
34  if (!entitySource)
35  return;
36 
37  //~ Spawn at ground or sea position
38  EntitySpawnParams spawnParams = new EntitySpawnParams;
39  spawnParams.Transform[3] = cursorWorldPosition;
40 
41  SCR_TerrainHelper.SnapToTerrain(spawnParams.Transform, GetGame().GetWorld(), true);
42 
43  //~ Apply scale from prefab
44  float scale;
45  entitySource.Get("scale", scale);
46  if (scale != 1)
47  Math3D.MatrixScale(spawnParams.Transform, scale);
48 
49  //~ Random rotation
50  vector angles = Math3D.MatrixToAngles(spawnParams.Transform);
51  angles[0] = Math.RandomFloat(0, 360);
52  Math3D.AnglesToMatrix(angles, spawnParams.Transform);
53 
54  GetGame().SpawnEntityPrefab(resource, GetGame().GetWorld(), spawnParams);
55  }
56 };
SCR_TerrainHelper
Definition: SCR_TerrainHelper.c:1
ChimeraWorld
Definition: ChimeraWorld.c:12
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_BaseContextAction
Definition: SCR_BaseContextAction.c:7
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_LightningContextAction
Definition: SCR_LightningContextAction.c:2
SCR_EditableEntityComponent
Definition: SCR_EditableEntityComponent.c:13
SCR_BaseContainerTools
Definition: SCR_BaseContainerTools.c:3
SCR_BaseContainerCustomTitleUIInfo
void SCR_BaseContainerCustomTitleUIInfo(string propertyName, string format="%1")
Definition: Attributes.c:788
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