Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ParticleContactComponent.c
Go to the documentation of this file.
2{
3 [Attribute(category: "Sound")]
4 ref SCR_AudioSourceConfiguration m_AudioSourceConfiguration;
5
6 [Attribute("true", desc: "Set surface signal", category: "Sound")]
7 bool m_bSurfaceSignal;
8
9 [Attribute("false", desc: "If to play particle effect", category: "VFX")]
10 bool m_bPlayParticle;
11
12 [Attribute("", UIWidgets.ResourcePickerThumbnail, desc: "Particle effect", params: "ptc", category: "VFX")]
13 ResourceName m_Particle;
14
15 [Attribute("0", uiwidget: UIWidgets.ComboBox, "Desired type of Game Material effect", "", ParamEnumArray.FromEnum(EParticleEffectInfoType), category: "VFX")]
16 int m_iGameMaterialEffect;
17
18 [Attribute("0", desc: "Index of Material Effect type", category: "VFX")]
19 int m_iEffectIndex;
20
21 [Attribute("true", desc: "Disable OnContact after the first contact")]
22 bool m_bFirstContactOnly;
23
24 [Attribute("false", desc: "Particle oriented to surface", category: "VFX")]
25 bool m_bParticleOriented;
26}
27
28enum EParticleEffectInfoType
29{
30 NONE = 0,
32 BLAST = 2,
33}
34
35class SCR_ParticleContactComponent : ScriptComponent
36{
37 //------------------------------------------------------------------------------------------------
38 private void PlaySound(IEntity owner, SCR_ParticleContactComponentClass prefabData, Contact contact)
39 {
40 if (!prefabData.m_AudioSourceConfiguration || !prefabData.m_AudioSourceConfiguration.IsValid())
41 return;
42
43 SCR_SoundManagerModule soundManager = SCR_SoundManagerModule.GetInstance(owner.GetWorld());
44 if (!soundManager)
45 return;
47 // Create audio source
48 SCR_AudioSource audioSource = soundManager.CreateAudioSource(owner, prefabData.m_AudioSourceConfiguration, contact.Position);
49 if (!audioSource)
50 return;
51
52 // Set surface signal
53 if (prefabData.m_bSurfaceSignal)
54 {
55 GameMaterial material = contact.Material2;
56 if (material)
57 {
58 audioSource.SetSignalValue(SCR_AudioSource.SURFACE_SIGNAL_NAME, material.GetSoundInfo().GetSignalValue());
59 }
60 }
62 // Play sound
63 soundManager.PlayAudioSource(audioSource);
64 }
65
66 //------------------------------------------------------------------------------------------------
67 override void OnPostInit(IEntity owner)
68 {
70 if (!prefabData)
71 return;
72
73 SetEventMask(owner, EntityEvent.CONTACT);
74
75#ifdef ENABLE_DIAG
76 DiagMenu.RegisterBool(SCR_DebugMenuID.DEBUGUI_PARTICLES_CONTACT_COMPONENT, "", "Show Particle Contacts", "Particles");
77#endif
78
79 }
80
81 //------------------------------------------------------------------------------------------------
82 override void EOnContact(IEntity owner, IEntity other, Contact contact)
83 {
84 // Get prefab data
86 if (!prefabData)
87 {
88 ClearEventMask(owner, EntityEvent.CONTACT);
89 return;
90 }
91
92 // Play sound
93 PlaySound(owner, prefabData, contact);
94
95 //Play VFX
96 if (prefabData.m_bPlayParticle)
97 {
98
99 //Play game material effect
100 if (prefabData.m_iGameMaterialEffect == 1)
101 {
102 GameMaterial material = contact.Material2;
103 ParticleEffectInfo effectInfo = material.GetParticleEffectInfo();
104
105 if (effectInfo)
106 {
107 prefabData.m_Particle = effectInfo.GetVehicleDustResource(prefabData.m_iEffectIndex);
108 }
109 }
110 else if (prefabData.m_iGameMaterialEffect == 2)
111 {
112 GameMaterial material = contact.Material2;
113 ParticleEffectInfo effectInfo = material.GetParticleEffectInfo();
114
115 if (effectInfo)
116 {
117 prefabData.m_Particle = effectInfo.GetBlastResource(prefabData.m_iEffectIndex);
118 }
119 }
120
121 if (prefabData.m_Particle != string.Empty)
122 {
124 spawnParams.UseFrameEvent = true;
125
126 if (prefabData.m_bParticleOriented)
127 Math3D.AnglesToMatrix(contact.Normal, spawnParams.Transform);
128
129 spawnParams.Transform[3] = contact.Position;
130 ParticleEffectEntity.SpawnParticleEffect(prefabData.m_Particle, spawnParams);
131
132#ifdef ENABLE_DIAG
133 if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_PARTICLES_CONTACT_COMPONENT))
134 {
135 DebugTextWorldSpace.Create(GetOwner().GetWorld(), contact.Material2.GetName(), DebugTextFlags.CENTER, contact.Position[0], contact.Position[1], contact.Position[2]);
136 }
137#endif
138 }
139 }
140
141 // Disable OnContact after the first contact
142 if (prefabData.m_bFirstContactOnly)
143 ClearEventMask(owner, EntityEvent.CONTACT);
144 }
145}
SCR_DebugMenuID
This enum contains all IDs for DiagMenu entries added in script.
Definition DebugMenuID.c:4
void SCR_AudioSource(SCR_AudioSourceConfiguration audioSourceConfiguration, vector mat[4])
SCR_CharacterSoundComponentClass GetComponentData()
void PlaySound(string soundName)
SCR_ParticleContactComponentClass BLAST
void ParticleEffectEntity(IEntitySource src, IEntity parent)
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
enum EVehicleType IEntity
Diagnostic and developer menu system.
Definition DiagMenu.c:18
proto external int ClearEventMask(notnull IEntity owner, int mask)
proto external int SetEventMask(notnull IEntity owner, int mask)
proto external BaseWorld GetWorld()
void EOnContact(IEntity owner, IEntity other, Contact contact)
proto external GenericEntity GetOwner()
Get owner entity.
DebugTextFlags
@ NONE
When Shape is created and not initialized yet.
Definition ShapeType.c:15
SCR_FieldOfViewSettings Attribute
EntityEvent
Various entity events.
Definition EntityEvent.c:14