7 protected ResourceName m_sParticle;
9 protected ref PointInfo m_effectPosition;
10 [
Attribute(
desc:
"If not checked, the modul is activated and deactivated only with physics event. If checked, the effect is always active")]
11 protected bool m_bTickOnFrame;
14 protected bool m_bShowEffectInWB;
16 protected IEntity m_owner;
18 protected ParticleEffectEntity m_sParticleEffect;
19 protected SignalsManagerComponent m_SignalManager;
23 protected ref array<ref SCR_BaseEffectParticleAction> m_aEffectActions;
29 return m_bTickOnFrame;
35 return m_Manager.GetOwner();
41 if (!m_sParticleEffect)
43 if (!m_sParticleEffect)
45 m_sParticleEffect.Play();
51 if (!m_sParticleEffect)
53 m_sParticleEffect.Stop();
57 protected void CreateEmitter(
bool PlayOnSpawn =
false)
73 m_effectPosition.GetLocalTransform(transform);
75 ParticleEffectEntitySpawnParams spawnParams();
76 spawnParams.UseFrameEvent =
true;
78 spawnParams.PivotID = m_effectPosition.GetNodeId();
79 spawnParams.Transform = transform;
81 m_sParticleEffect = ParticleEffectEntity.SpawnParticleEffect(m_sParticle, spawnParams);
86 protected void WB_PlayEffect()
94 ParticleEffectEntity GetEmitter()
96 return m_sParticleEffect;
100 SignalsManagerComponent GetSignalManager()
106 protected void InitActions()
117 protected void DeInitActions()
125 m_aEffectActions.Clear();
134 m_SignalManager = SignalsManagerComponent.Cast(manager.GetOwner().FindComponent(SignalsManagerComponent));
136 m_effectPosition.Init(manager.GetOwner());
150 void Update(IEntity owner,
float timeSlice)
162 void WB_Update(IEntity owner,
float timeSlice)
164 if (m_bShowEffectInWB && m_sParticleEffect)
169 void WB_OnInit(IEntity owner, inout vector mat[4], IEntitySource src)
183 [
Attribute(
"10", UIWidgets.Auto,
desc:
"Time to play startup particle\n[s]")]
184 protected float m_fStartupTime;
186 protected SCR_HelicopterControllerComponent m_HelicopterController;
196 override void Update(IEntity owner,
float timeSlice)
198 super.Update(owner, timeSlice);
217 protected float m_fValue;
220 protected bool m_bPerformed =
false;
238 protected void PerformAction()
250 m_Module.GetEmitter().GetParticles().SetParam(-1, EmitterParam.BIRTH_RATE, m_fValue);
266 protected string m_sSignal;
269 [
Attribute(
desc:
"Value of signal when the action will be executed")]
270 protected float m_fSignalValue;
271 protected int m_iSignalID;
285 override void DeInit()
298 m_bPerformed =
false;
303 PrintFormat(
"Signal value = %1",
m_SignalManager.GetSignalValue(m_iSignalID));
305 if (SCR_Comparer<float>.
Compare(m_eOperator, (
float)
m_SignalManager.GetSignalValue(m_iSignalID), (
float)m_fSignalValue ))
325 [
Attribute(defvalue:
"0", UIWidgets.ComboBox,
"Events",
"", ParamEnumArray.FromEnum(EVehicleEvent))]
326 protected EVehicleEvent m_eEvent;
328 [
Attribute(defvalue:
"0",
desc:
"Perform the action only once")]
329 protected bool m_bOnce;
330 protected SCR_HelicopterControllerComponent m_VehicleController;
335 protected void RegisterEvent()
339 case EVehicleEvent.ON_ENGINE_START:
341 m_EventHandler = m_VehicleController.GetOnEngineStart();
344 case EVehicleEvent.ON_ENGINE_STOP:
346 m_EventHandler = m_VehicleController.GetOnEngineStop();
352 m_EventHandler.Insert(PerformAction);
359 IEntity owner = module.GetOwner();
362 m_VehicleController = SCR_HelicopterControllerComponent.Cast(owner.FindComponent(SCR_HelicopterControllerComponent));
363 if (!m_VehicleController)
365 Print(
"SCR_HelicopterControllerComponent controller not found. Action won't work", LogLevel.WARNING);
372 override void DeInit()
374 m_VehicleController =
null;
375 m_EventHandler.Clear();
380 override void PerformAction()
382 super.PerformAction();
384 m_EventHandler.Remove(PerformAction);
394 [
Attribute(
"", UIWidgets.EditBox,
"Speed in m/s which tops the effect's interpolation from 100 to 0% lifetime value" )]
395 float m_ExhaustEndSpeedInM;
397 const string SIGNAL_RPM =
"MainRotorRPM";
398 const int RPM_THRESHOLD = 50;
399 protected int m_iSignalID;
412 m_Physics = module.GetOwner().GetPhysics();
423 if ( !m_Effect &&
m_SignalManager.GetSignalValue(m_iSignalID) > RPM_THRESHOLD )
426 }
else if ( m_Effect &&
m_SignalManager.GetSignalValue(m_iSignalID) < RPM_THRESHOLD )
432 if (!m_Effect && m_Module.GetEmitter() )
433 m_Effect = m_Module.GetEmitter().GetParticles();
436 if (m_Effect &&
m_Physics && m_ExhaustEndSpeedInM > 0)
438 vector velocity_vector =
m_Physics.GetVelocity();
439 float speed_m_per_s = velocity_vector.Length();
441 float lifetime_scale = Math.Clamp( 1 - (speed_m_per_s / m_ExhaustEndSpeedInM) , 0 , 1 );
443 m_Effect.MultParam(-1, EmitterParam.LIFETIME, lifetime_scale);
444 m_Effect.MultParam(-1, EmitterParam.LIFETIME_RND, lifetime_scale);