Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ParticleSpawnable.c
Go to the documentation of this file.
1[BaseContainerProps(), SCR_Spawnable_ParticleTitle()]
3{
4 [Attribute(ResourceName.Empty, UIWidgets.ResourceNamePicker, "Particle effect to spawn", "ptc")]
5 ResourceName m_Particle;
6
7 [Attribute("1", UIWidgets.CheckBox, "If true, the particle effect will play at the object's bounding box instead of at its origin")]
8 bool m_bAtCenter;
9
10 [Attribute("1", desc: "If true, the particle effect will play rotated in the hit direction.")]
11 bool m_bDirectional;
12
13#ifdef WORKBENCH
14 //------------------------------------------------------------------------------------------------
15 void GetPositionAndRotation(out notnull array<vector> positionAndRotation)
16 {
17 positionAndRotation.Clear();
18 positionAndRotation.Insert(m_vOffsetPosition);
19 positionAndRotation.Insert(m_vOffsetRotation);
20 }
21
22 //------------------------------------------------------------------------------------------------
25 override bool CompareAttributes(SCR_BaseSpawnable other)
26 {
27 SCR_ParticleSpawnable otherParticle = SCR_ParticleSpawnable.Cast(other);
28
29 if (!super.CompareAttributes(other))
30 return false;
31
32 if (otherParticle.m_Particle != m_Particle)
33 return false;
34
35 if (otherParticle.m_bAtCenter != m_bAtCenter)
36 return false;
37
38 if (otherParticle.m_bDirectional != m_bDirectional)
39 return false;
40
41 return true;
42 }
43 //------------------------------------------------------------------------------------------------
44 override void SetVariables(WorldEditorAPI api, IEntitySource source, array<ref ContainerIdPathEntry> path, int index)
45 {
46 super.SetVariables(api, source, path, index);
47
48 // Set all variables of the spawn object
49 api.SetVariableValue(source, path, "m_Particle", m_Particle);
50 api.SetVariableValue(source, path, "m_bAtCenter", m_bAtCenter.ToString(true));
51 api.SetVariableValue(source, path, "m_bDirectional", m_bDirectional.ToString(true));
52 }
53
54 //------------------------------------------------------------------------------------------------
55 override bool CreateObject(WorldEditorAPI api, IEntitySource source, array<ref ContainerIdPathEntry> path, int index)
56 {
57 if (!AlreadyExists(api, source, index))
58 {
59 api.CreateObjectArrayVariableMember(source, path, "m_aPhaseDestroySpawnObjects", "SCR_ParticleSpawnable", index);
60 return true;
61 }
62
63 return false;
64 }
65#endif
66
67 //------------------------------------------------------------------------------------------------
68 ParticleEffectEntity SpawnAsChild(IEntity owner, SCR_HitInfo hitInfo, bool snapToTerrain = false)
69 {
70 if (m_Particle == ResourceName.Empty)
71 return null;
72
73 vector spawnMat[4];
74 GetSpawnTransform(owner, spawnMat);
75
76 if (m_bAtCenter)
77 {
78 vector mins, maxs;
79 owner.GetBounds(mins, maxs);
80 vector center = (maxs - mins) * 0.5 + mins;
81 spawnMat[3] = center.Multiply4(spawnMat);
82 }
83
84 vector position = spawnMat[3];
85 if (snapToTerrain)
86 {
88 spawnMat[3] = position;
89 }
90
91 if (m_bDirectional)
92 {
93 vector newRight, newUp, newForward;
94
95 newUp = -hitInfo.m_HitDirection;
96 newRight = newUp * spawnMat[2];
97 newForward = newUp * newRight;
98
99 spawnMat[0] = newRight;
100 spawnMat[1] = newUp;
101 spawnMat[2] = newForward;
102 }
103
104 return SCR_DestructionCommon.PlayParticleEffect_Child(m_Particle, hitInfo.m_DamageType, owner, spawnMat);
105 }
106
107 //------------------------------------------------------------------------------------------------
109 override ParticleEffectEntity Spawn(IEntity owner, Physics parentPhysics, SCR_HitInfo hitInfo, bool snapToTerrain = false)
110 {
111 if (!hitInfo || m_Particle == ResourceName.Empty)
112 return null;
113
114 vector spawnMat[4];
115 GetSpawnTransform(owner, spawnMat);
116
117 if (m_bAtCenter)
118 {
119 vector mins, maxs;
120 owner.GetBounds(mins, maxs);
121 vector center = (maxs - mins) * 0.5 + mins;
122 spawnMat[3] = center.Multiply4(spawnMat);
123 }
124
125 vector position = spawnMat[3];
126 if (snapToTerrain)
127 {
129 spawnMat[3] = position;
130 }
131
132 if (m_bDirectional)
133 {
134 vector newRight, newUp, newForward;
135
136 newUp = -hitInfo.m_HitDirection;
137 newRight = newUp * spawnMat[2];
138 newForward = newUp * newRight;
139
140 spawnMat[0] = newRight;
141 spawnMat[1] = newUp;
142 spawnMat[2] = newForward;
143 }
144
145 return SCR_DestructionCommon.PlayParticleEffect_Transform(m_Particle, hitInfo.m_DamageType, spawnMat);
146 }
147}
string path
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
SCR_AIGroupClass snapToTerrain
vector position
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
override void GetPositionAndRotation(out vector pos, out vector rot)
void ParticleEffectEntity(IEntitySource src, IEntity parent)
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
proto external void GetBounds(out vector mins, out vector maxs)
proto external BaseWorld GetWorld()
void GetSpawnTransform(IEntity owner, out vector outMat[4], bool localCoords=false)
Calculates the spawn tranformation matrix for the object.
Class containing common functions between destructible classes.
Class to temporarily store information about the last hit that dealt damage.
Definition SCR_HitInfo.c:3
static float GetTerrainY(vector pos, BaseWorld world=null, bool noUnderwater=false, TraceParam trace=null)
AISpawnerGroupClass AIGroupClass Spawn()
Spawns a new group entity, sets its transformation and then calls OnSpawn.
SCR_FieldOfViewSettings Attribute