Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_LightningContextAction.c
Go to the documentation of this file.
3{
4 [Attribute("{A8FFCD3F3697D77F}Prefabs/Editor/Lightning/LightningStrike.et")]
6
7 //------------------------------------------------------------------------------------------------
8 override int GetParam()
9 {
10 return GetGame().GetPlayerController().GetPlayerId();
11 }
12
13 //------------------------------------------------------------------------------------------------
14 override bool CanBeShown(SCR_EditableEntityComponent hoveredEntity, notnull set<SCR_EditableEntityComponent> selectedEntities, vector cursorWorldPosition, int flags)
15 {
16 if (!SCR_Global.IsPositionWithinTerrainBounds(cursorWorldPosition))
17 return false;
18
19 ChimeraWorld world = GetGame().GetWorld();
20 if (world.IsGameTimePaused())
21 return false;
22
23 //~ Only allow lightning strike if entity has a position
24 vector positionCheck;
25 return !hoveredEntity || hoveredEntity.GetPos(positionCheck);
26 }
27
28 //------------------------------------------------------------------------------------------------
29 override bool CanBePerformed(SCR_EditableEntityComponent hoveredEntity, notnull set<SCR_EditableEntityComponent> selectedEntities, vector cursorWorldPosition, int flags)
30 {
31 return CanBeShown(hoveredEntity, selectedEntities, cursorWorldPosition, flags);
32 }
33
34 //------------------------------------------------------------------------------------------------
35 override void Perform(SCR_EditableEntityComponent hoveredEntity, notnull set<SCR_EditableEntityComponent> selectedEntities, vector cursorWorldPosition, int flags, int param = -1)
36 {
37 if (hoveredEntity)
38 hoveredEntity.GetPos(cursorWorldPosition);
39
40 Resource resource = Resource.Load(m_sLightningPrefab);
41 if (!resource)
42 return;
43
44 IEntitySource entitySource = SCR_BaseContainerTools.FindEntitySource(resource);
45 if (!entitySource)
46 return;
47
48 //~ Spawn at ground or sea position
49 EntitySpawnParams spawnParams = new EntitySpawnParams;
50 spawnParams.Transform[3] = cursorWorldPosition;
51
52 SCR_TerrainHelper.SnapToTerrain(spawnParams.Transform, GetGame().GetWorld(), true);
53
54 //~ Apply scale from prefab
55 float scale;
56 entitySource.Get("scale", scale);
57 if (scale != 1)
58 Math3D.MatrixScale(spawnParams.Transform, scale);
59
60 //~ Random rotation
61 vector angles = Math3D.MatrixToAngles(spawnParams.Transform);
62 angles[0] = Math.RandomFloat(0, 360);
63 Math3D.AnglesToMatrix(angles, spawnParams.Transform);
64
65 IEntity lightning = GetGame().SpawnEntityPrefab(resource, GetGame().GetWorld(), spawnParams);
66 if (!lightning)
67 return;
68
70 if (!trigger)
71 return;
72
73 //~ Add GM as instigator
74 trigger.SetInstigator(Instigator.CreateInstigatorGM(param));
75 }
76}
SCR_EAIThreatSectorFlags flags
vector scale
ArmaReforgerScripted GetGame()
Definition game.c:1398
ref array< string > angles
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
class SCR_ArsenalGameModeUIDataHolder SCR_BaseContainerCustomTitleUIInfo("m_UIInfo")
proto external Managed FindComponent(typename typeName)
Definition Math.c:13
Object holding reference to resource. In destructor release the resource.
Definition Resource.c:25
static bool IsPositionWithinTerrainBounds(vector pos)
Definition Functions.c:1981
override bool CanBePerformed(SCR_EditableEntityComponent hoveredEntity, notnull set< SCR_EditableEntityComponent > selectedEntities, vector cursorWorldPosition, int flags)
override void Perform(SCR_EditableEntityComponent hoveredEntity, notnull set< SCR_EditableEntityComponent > selectedEntities, vector cursorWorldPosition, int flags, int param=-1)
override bool CanBeShown(SCR_EditableEntityComponent hoveredEntity, notnull set< SCR_EditableEntityComponent > selectedEntities, vector cursorWorldPosition, int flags)
static bool SnapToTerrain(out vector transform[4], BaseWorld world=null, bool noUnderwater=false, TraceParam trace=null)
void EntitySpawnParams()
Definition gameLib.c:130
SCR_FieldOfViewSettings Attribute