Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
blowtorch.c
Go to the documentation of this file.
1 class Blowtorch extends ItemBase
2 {
3  const string TEXTURE_FLAME = "dz\\gear\\cooking\\data\\flame_butane_ca.paa";
4  const string ANIM_PHASE_FLAME = "FlameHide";
5  const string SOUND_BURNING = "Blowtorch_Loop_SoundSet";
6 
7  protected BlowtorchLight m_Light;
8 
9  protected EffectSound m_SoundBurningLoop;
10 
11  override void OnWorkStart()
12  {
13  super.OnWorkStart();
14 
15  #ifndef SERVER
16  m_Light = BlowtorchLight.Cast(ScriptedLightBase.CreateLight(BlowtorchLight, "0 0 0"));
17  m_Light.AttachOnMemoryPoint(this, "light");
18  #endif
19 
20  RefreshFlameVisual(true);
21  SoundBurningStart();
22  }
23 
24  override void OnWorkStop()
25  {
26  #ifndef SERVER
27  if (m_Light)
28  {
29  m_Light.FadeOut();
30  }
31  #endif
32 
33  RefreshFlameVisual(false);
34  SoundBurningStop();
35  }
36 
37  protected void RefreshFlameVisual(bool working = false)
38  {
39  if (working)
40  {
41  SetObjectTexture(0, TEXTURE_FLAME);
42  SetAnimationPhase(ANIM_PHASE_FLAME, 0.0);
43  }
44  else
45  {
46  SetObjectTexture(0, "");
47  SetAnimationPhase(ANIM_PHASE_FLAME, 1.0);
48  }
49  }
50 
51  protected void SoundBurningStart()
52  {
53  PlaySoundSetLoop(m_SoundBurningLoop, SOUND_BURNING, 0.1, 0.0);
54  }
55 
56  protected void SoundBurningStop()
57  {
58  StopSoundSet(m_SoundBurningLoop);
59  }
60 
61  override bool CanPutInCargo(EntityAI parent)
62  {
63  if (!super.CanPutInCargo(parent))
64  {
65  return false;
66  }
67 
68  return !GetCompEM().IsSwitchedOn();
69  }
70 
71  override bool CanRemoveFromCargo(EntityAI parent)
72  {
73  return true;
74  }
75 
76  override bool IsIgnited()
77  {
78  return GetCompEM().IsWorking();
79  }
80 
81  override void OnIgnitedTarget(EntityAI ignited_item)
82  {
83  if (GetGame().IsServer())
84  {
85  if (GetGasCanister())
86  {
87  ComponentEnergyManager canisterEM = GetGasCanister().GetCompEM();
88  if (canisterEM)
89  canisterEM.AddEnergy(-1 * (GetCompEM().GetEnergyUsage() * UATimeSpent.FIREPLACE_IGNITE));
90  }
91  }
92  }
93 
94  override bool CanIgniteItem(EntityAI ignite_target = NULL)
95  {
96  return ignite_target.CanBeIgnitedBy(this);
97  }
98 
99  override void SetActions()
100  {
101  super.SetActions();
102 
108  }
109 
110  protected EntityAI GetGasCanister()
111  {
112  if (GetInventory().AttachmentCount() != 0)
113  {
114  return GetInventory().GetAttachmentFromIndex(0);
115  }
116 
117  return null;
118  }
119 
120  bool HasEnoughEnergyForRepair(float pTime)
121  {
122  if (GetGasCanister())
123  {
124  ComponentEnergyManager canisterEM = GetGasCanister().GetCompEM();
125  if (canisterEM)
126  {
127  return canisterEM.GetEnergy() > GetCompEM().GetEnergyUsage() * pTime;
128  }
129  }
130 
131  return false;
132  }
133 
134  override void OnDebugSpawn()
135  {
136  GetInventory().CreateInInventory("LargeGasCanister");
137  }
138 }
ItemBase
Definition: inventoryitem.c:730
GetGame
proto native CGame GetGame()
ComponentEnergyManager
Definition: componentenergymanager.c:18
ActionLightItemOnFireWithBlowtorch
ActionLoadMagazineCB ActionLightItemOnFireWithBlowtorch
ActionRepairCarChassisWithBlowtorch
ActionRepairCarChassisWithBlowtorchCB ActionRepairCarChassisCB ActionRepairCarChassisWithBlowtorch()
Definition: actionrepaircarchassiswithblowtorch.c:11
ActionRepairCarPartWithBlowtorch
ActionRepairCarPartWithBlowtorchCB ActionRepairCarPartCB ActionRepairCarPartWithBlowtorch()
Definition: actionrepaircarpartwithblowtorch.c:11
BlowtorchLight
Definition: blowtorchlight.c:1
OnWorkStop
override void OnWorkStop()
Definition: m18smokegrenade_colorbase.c:2
m_Light
protected ExplosiveLight m_Light
light
Definition: explosivesbase.c:31
ActionRepairItemWithBlowtorch
ActionRepairItemWithBlowtorchCB ActionContinuousBaseCB ActionRepairItemWithBlowtorch()
Definition: actionrepairitemwithblowtorch.c:11
OnDebugSpawn
class Hatchback_02_Blue extends Hatchback_02 OnDebugSpawn
Definition: hatchback_02.c:404
EffectSound
Wrapper class for managing sound through SEffectManager.
Definition: effectsound.c:4
CanPutInCargo
override bool CanPutInCargo(EntityAI parent)
Definition: explosivesbase.c:247
AddAction
void AddAction(typename actionName)
Definition: advancedcommunication.c:86
ScriptedLightBase
Definition: pointlightbase.c:1
SetActions
void SetActions()
Definition: advancedcommunication.c:79
CanRemoveFromCargo
override bool CanRemoveFromCargo(EntityAI parent)
Definition: basebuildingbase.c:927
UATimeSpent
Definition: actionconstants.c:26
ActionRepairCarEngineWithBlowtorch
ActionRepairCarEngineWithBlowtorchCB ActionRepairCarEngineCB ActionRepairCarEngineWithBlowtorch()
Definition: actionrepaircarenginewithblowtorch.c:11
EntityAI
Definition: building.c:5
OnWorkStart
override void OnWorkStart()
Definition: smokegrenadebase.c:175