Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_LampComponent.c
Go to the documentation of this file.
1 [EntityEditorProps(category: "GameScripted", color: "0 0 255 255")]
3 {
4  [Attribute("{40318DDE45FF4CC3}Particles/Enviroment/Lamp_fire_normal.ptc", UIWidgets.ResourceNamePicker, "Prefab of fire particle used for a fire action.", "ptc")]
5  protected ResourceName m_sParticle;
6 
7  [Attribute("0 0.1 0", UIWidgets.EditBox, "Particle offset in local space from the origin of the entity")]
8  protected vector m_vParticleOffset;
9 
10  //------------------------------------------------------------------------------------------------
12  ResourceName GetParticle()
13  {
14  return m_sParticle;
15  }
16 
17  //------------------------------------------------------------------------------------------------
19  vector GetParticleOffset()
20  {
21  return m_vParticleOffset;
22  }
23 }
24 
25 class SCR_LampComponent : SCR_BaseInteractiveLightComponent
26 {
27  private ParticleEffectEntity m_pFireParticle;
29 
30  //------------------------------------------------------------------------------------------------
31  override void ToggleLight(bool turnOn, bool skipTransition = false, bool playSound = true)
32  {
33  if (m_bIsOn == turnOn)
34  return;
35 
36  super.ToggleLight(turnOn, skipTransition, playSound);
37 
38  // don't continue if DS server is running in console (particles, decals)
39  if (System.IsConsoleApp())
40  return;
41 
42  if (turnOn)
43  {
44  TurnOn();
45  }
46  else
47  {
48  TurnOff();
49  }
50  }
51 
52  //------------------------------------------------------------------------------------------------
54  void TurnOn()
55  {
56  SCR_LampComponentClass componentData = SCR_LampComponentClass.Cast(GetComponentData(GetOwner()));
57  if (!m_pFireParticle && componentData)
58  {
59  ParticleEffectEntitySpawnParams spawnParams = new ParticleEffectEntitySpawnParams();
60  spawnParams.TargetWorld = GetOwner().GetWorld();
61  spawnParams.Parent = GetOwner();
62  Math3D.MatrixIdentity4(spawnParams.Transform);
63  spawnParams.Transform[3] = componentData.GetParticleOffset();
64 
65  m_pFireParticle = ParticleEffectEntity.SpawnParticleEffect(componentData.GetParticle(), spawnParams);
66  }
67  else if (m_pFireParticle)
68  {
69  m_pFireParticle.Play();
70  }
71  }
72 
73  //------------------------------------------------------------------------------------------------
75  void TurnOff()
76  {
77  //Reset fire particles
78  if (m_pFireParticle)
79  {
80  m_pFireParticle.Stop();
81  }
82  }
83 
84  //------------------------------------------------------------------------------------------------
85  override bool RplLoad(ScriptBitReader reader)
86  {
87  // Can't relay on RplLoad method of base class as with the lamp we have to execute ToggleLight method in both on / off state.
88  bool isOn = false;
89  reader.ReadBool(isOn);
90  ToggleLight(isOn, true);
91 
92  return true;
93  }
94 
95  //------------------------------------------------------------------------------------------------
96  override void OnDelete(IEntity owner)
97  {
98  super.OnDelete(owner);
99 
100  RemoveLights();
101  }
102 }
EntityEditorProps
enum EQueryType EntityEditorProps(category:"GameScripted/Sound", description:"THIS IS THE SCRIPT DESCRIPTION.", color:"0 0 255 255")
Definition: SCR_AmbientSoundsComponent.c:12
SCR_BaseInteractiveLightComponentClass
Definition: SCR_BaseInteractiveLightComponent.c:2
TurnOff
void TurnOff()
Remove every particle associed with this effect.
Definition: SCR_LampComponent.c:75
RemoveLights
void RemoveLights()
Definition: SCR_BaseInteractiveLightComponent.c:296
OnDelete
override void OnDelete(IEntity owner)
Definition: SCR_LampComponent.c:96
m_pFireParticle
SCR_LampComponentClass m_pFireParticle
Attribute
typedef Attribute
Post-process effect of scripted camera.
m_ComponentData
protected SCR_BaseInteractiveLightComponentClass m_ComponentData
Definition: SCR_LampComponent.c:28
RplLoad
override bool RplLoad(ScriptBitReader reader)
Definition: SCR_LampComponent.c:85
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition: SCR_FuelNode.c:128
ToggleLight
override void ToggleLight(bool turnOn, bool skipTransition=false, bool playSound=true)
Definition: SCR_LampComponent.c:31
TurnOn
void TurnOn()
Definition: SCR_LampComponent.c:54
m_bIsOn
protected bool m_bIsOn
Definition: SCR_BaseInteractiveLightComponent.c:50
SCR_LampComponentClass
Definition: SCR_LampComponent.c:2
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180