Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_OptimizedMuzzleEffectComponent.c
Go to the documentation of this file.
4
5class SCR_OptimizedMuzzleEffectComponent : MuzzleEffectComponent
6{
7 protected bool m_bInScope;
9 protected const string PREFIX_EMITOR_TO_DISABLE = "noscope";
10
11 //------------------------------------------------------------------------------------------------
12 static void OptimizeMuzzleEffect(bool inScope, TurretControllerComponent m_TurretController)
13 {
14 BaseWeaponManagerComponent weaponManager = m_TurretController.GetWeaponManager();
15
16 if (!weaponManager)
17 return;
18
19 array<WeaponSlotComponent> weaponSlots = {};
20 weaponManager.GetWeaponsSlots(weaponSlots);
21
22 BaseMuzzleComponent baseMuzzle;
23 array<GenericComponent> comArray = new array<GenericComponent>();
24 SCR_OptimizedMuzzleEffectComponent muzzleEffect;
25
26 foreach (WeaponSlotComponent weaponSlot : weaponSlots)
27 {
28 baseMuzzle = weaponSlot.GetCurrentMuzzle();
29 if (!baseMuzzle)
30 continue;
31
32 comArray.Clear();
33 baseMuzzle.FindComponents(MuzzleEffectComponent, comArray);
34
35 foreach (GenericComponent component : comArray)
36 {
37 muzzleEffect = SCR_OptimizedMuzzleEffectComponent.Cast(component);
38
39 if (!muzzleEffect)
40 continue;
41
42 muzzleEffect.m_bInScope = inScope;
43 }
44 }
45 }
46
47 //------------------------------------------------------------------------------------------------
55
56 //------------------------------------------------------------------------------------------------
57 override void OnFired(IEntity effectEntity, BaseMuzzleComponent muzzle, IEntity projectileEntity)
58 {
60 m_OnWeaponFired.Invoke();
61
62 ParticleEffectEntity particleEntity = ParticleEffectEntity.Cast(effectEntity);
63
64 if (!particleEntity)
65 return;
66
67 Particles particles = particleEntity.GetParticles();
68
69 if (!particles)
70 return;
71
72 array<string> names = {};
73 particles.GetEmitterNames(names);
74
75 foreach (int idx, string name : names)
76 {
77 if (name.Contains(PREFIX_EMITOR_TO_DISABLE))
78 {
79 if (m_bInScope)
80 particles.MultParam(idx, EmitterParam.BIRTH_RATE, 0);
81 else
82 particles.MultParam(idx, EmitterParam.BIRTH_RATE, 1);
83 }
84 }
85 }
86}
const string PREFIX_EMITOR_TO_DISABLE
ScriptInvokerVoid GetOnWeaponFired()
ref ScriptInvokerVoid m_OnWeaponFired
SCR_OptimizedMuzzleEffectComponentClass m_bInScope
void ParticleEffectEntity(IEntitySource src, IEntity parent)
ScriptInvokerBase< ScriptInvokerVoidMethod > ScriptInvokerVoid
TurretControllerComponent m_TurretController
proto external int FindComponents(typename typeName, notnull array< GenericComponent > outComponents)
event void OnFired(IEntity effectEntity, BaseMuzzleComponent muzzle, IEntity projectileEntity)
EmitterParam