DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
PortableGasStove.c
См. документацию.
1class PortableGasStove extends ItemBase
2{
3 StoveLight m_Light;
4
5 protected const string FLAME_BUTANE_ON = "dz\\gear\\cooking\\data\\flame_butane_ca.paa";
6 protected const string FLAME_BUTANE_OFF = "";
10
11 //cooking
12 protected const float PARAM_COOKING_TIME_INC_COEF = 0.5; //cooking time increase coeficient, can be used when balancing how fast a food can be cooked
13 protected const float PARAM_COOKING_TARGET_TEMP = 400; //target temperature for general item heating
14
15 private float m_TimeFactor;
16 //
17 ref Cooking m_CookingProcess;
19
20 //sound
21 const string SOUND_BURNING = "portablegasstove_burn_SoundSet";
22 const string SOUND_TURN_ON = "portablegasstove_turn_on_SoundSet";
23 const string SOUND_TURN_OFF = "portablegasstove_turn_off_SoundSet";
24
26 protected EffectSound m_SoundTurnOn;
28
31 protected ref UniversalTemperatureSourceLambdaConstant m_UTSLConst;
32
33 //cooking equipment
38
40 {
41 m_CookingEquipment = equipment;
42 }
43
45 {
47 {
48 m_CookingProcess.TerminateCookingSounds(pItem);
49 }
50
52 }
53
54 //Destroy
56 {
57 //delete object
58 g_Game.ObjectDelete(this);
59 }
60
61 override void EEInit()
62 {
63 super.EEInit();
64
65 if (m_CookingProcess == null)
66 m_CookingProcess = new Cooking();
67 m_CookingProcess.SetCookingUpdateTime(GetCompEM().GetUpdateInterval());
68
69 if (g_Game.IsServer() || !g_Game.IsMultiplayer())
70 {
72 m_UTSSettings.m_ManualUpdate = true;
74 m_UTSSettings.m_TemperatureCap = 0;
75 m_UTSSettings.m_RangeFull = 0;
76 m_UTSSettings.m_RangeMax = 0;
77 m_UTSSettings.m_IsWorldOverriden = false;
78
79 m_UTSLConst = new UniversalTemperatureSourceLambdaConstant();
81 }
82 }
83
84 //--- ATTACHMENTS
85 override void EEItemAttached(EntityAI item, string slot_name)
86 {
87 super.EEItemAttached(item, slot_name);
88
89 //cookware
90 if (item.IsCookware())
91 {
92 SetCookingEquipment(ItemBase.Cast(item));
93 RefreshFlameVisual(m_EM.IsSwitchedOn(), true);
94 }
95 }
96
97 override void EEItemDetached(EntityAI item, string slot_name)
98 {
99 super.EEItemDetached(item, slot_name);
100
101 //cookware
102 if (item.IsCookware())
103 {
104 //remove cooking equipment reference
106 RefreshFlameVisual(m_EM.IsSwitchedOn(), false);
107 }
108
109 //stop effects
111 }
112
113 //--- POWER EVENTS
114 override void OnSwitchOn()
115 {
116 super.OnSwitchOn();
117
118 if (g_Game.IsServer() || !g_Game.IsMultiplayer())
119 {
120 m_UTSource.SetDefferedActive(true, 3.0);
121 }
122
123 //sound (client only)
124 SoundTurnOn();
125 }
126
127 override void OnSwitchOff()
128 {
129 super.OnSwitchOff();
130
131 if (g_Game.IsServer() || !g_Game.IsMultiplayer())
132 {
133 m_UTSource.SetDefferedActive(false, 5.0);
134 }
135
136 //sound (client only)
137 SoundTurnOff();
139 {
140 m_CookingProcess.TerminateCookingSounds(GetCookingEquipment());
141 }
142 }
143
144 override void OnWorkStart()
145 {
146 super.OnWorkStart();
147
148 #ifndef SERVER
149 #ifndef NO_GUI
150 m_Light = StoveLight.Cast(ScriptedLightBase.CreateLight(StoveLight, "0 0 0"));
151 m_Light.AttachOnMemoryPoint(this, "light");
152 #endif
153 #endif
154
155 //refresh visual
157
158 //sound (client only)
160 }
161
162 override void OnWorkStop()
163 {
164 #ifndef SERVER
165 #ifndef NO_GUI
166 if (m_Light)
167 {
168 m_Light.FadeOut();
169 }
170 #endif
171 #endif
172
173 //refresh visual
174 RefreshFlameVisual(false, false);
175 //stop effects
177 //sound (client only)
179 }
180
181 //on update
182 override void OnWork(float consumed_energy)
183 {
184 if (g_Game.IsServer() || !g_Game.IsMultiplayer())
185 {
187 }
188
189 //manage cooking equipment
191 if (item && item.CanHaveTemperature())
192 {
193 if (g_Game && g_Game.IsServer())
194 {
195 float cook_equip_temp = item.GetTemperature();
196 float target; //makes sense here, since gas stove does not heat itself, and we need some target
197 if (!GetCookingTargetTemperature(target))
198 target = PARAM_COOKING_TARGET_TEMP; //fallback value
199
200 float diff = target - cook_equip_temp;
201 float heatPermCoef = item.GetHeatPermeabilityCoef();
202
203 //heat only, no self-coolig like FireplaceBase
204 if (diff > 0)
205 item.SetTemperatureEx(new TemperatureDataInterpolated(target,ETemperatureAccessTypes.ACCESS_FIREPLACE,GetCompEM().GetUpdateInterval(),GameConstants.TEMP_COEF_GAS_STOVE,heatPermCoef));
206
207 m_TimeFactor = consumed_energy;
208 CookWithEquipment(); //heat children
209
211 GetCookingEquipment().DecreaseHealth(GameConstants.FIRE_ATTACHMENT_DAMAGE_PER_SECOND * GetCompEM().GetUpdateInterval(), false);
212 }
213 }
214 }
215
217 {
218 if (m_CookingProcess == null)
219 m_CookingProcess = new Cooking();
220
222 }
223
224 override bool GetCookingTargetTemperature(out float temperature)
225 {
226 temperature = PARAM_COOKING_TARGET_TEMP;
227 return true;
228 }
229
230 protected void RefreshFlameVisual(bool working = false, bool hasAttachment = false)
231 {
232 if (!working)
233 {
234 SetObjectTexture(0, FLAME_BUTANE_OFF);
235 SetObjectTexture(1, FLAME_BUTANE_OFF);
236
237 return;
238 }
239
240 if (!hasAttachment)
241 {
243 SetObjectTexture(0, FLAME_BUTANE_ON);
244 SetObjectTexture(1, FLAME_BUTANE_OFF);
245 }
246 else
247 {
249 SetObjectTexture(0, FLAME_BUTANE_OFF);
250 SetObjectTexture(1, FLAME_BUTANE_ON);
251 }
252 }
253
254 //================================================================
255 // PARTICLES
256 //================================================================
257 //cooking equipment steam
259 {
260 ItemBase cookEquipment;
261 if (Class.CastTo(cookEquipment,GetCookingEquipment()) && (cookEquipment.IsCookware() || cookEquipment.IsLiquidContainer())) //also stops boiling effect on bottles
262 cookEquipment.RemoveAudioVisualsOnClient();
263 }
264
265 //================================================================
266 // SOUNDS
267 //================================================================
268 protected void SoundBurningStart()
269 {
270 PlaySoundSetLoop(m_SoundBurningLoop, SOUND_BURNING, 0.1, 0.3);
271 }
272
273 protected void SoundBurningStop()
274 {
275 StopSoundSet(m_SoundBurningLoop);
276 }
277
278 protected void SoundTurnOn()
279 {
280 PlaySoundSet(m_SoundTurnOn, SOUND_TURN_ON, 0.1, 0.1);
281 }
282
283 protected void SoundTurnOff()
284 {
285 PlaySoundSet(m_SoundTurnOff, SOUND_TURN_OFF, 0.1, 0.1);
286 }
287
288 //================================================================
289 // CONDITIONS
290 //================================================================
291 override bool IsSelfAdjustingTemperature() //prevents CE temperature updates in vicinity, does not really have its own temperature
292 {
293 return GetCompEM().IsWorking();
294 }
295
296 //this into/outo parent.Cargo
297 override bool CanPutInCargo(EntityAI parent)
298 {
299 if (!super.CanPutInCargo(parent))
300 return false;
301
302 if (GetCompEM().IsSwitchedOn())
303 return false;
304
305 //can 'parent' be attached to 'this' (->assumed smaller size than 'this')?
306 if (parent)
307 {
308 int slotId;
309 for (int i = 0; i < GetInventory().GetAttachmentSlotsCount(); i++)
310 {
311 slotId = GetInventory().GetAttachmentSlotId(i);
312 if (parent.GetInventory().HasInventorySlot(slotId))
313 {
314 //Print("CanPutInCargo | parent " + parent + " matches in slot name: " + InventorySlots.GetSlotName(slotId) + " of " + this);
315 return false;
316 }
317 }
318 }
319
320 return true;
321 }
322
323 override bool CanRemoveFromCargo(EntityAI parent)
324 {
325 return true;
326 }
327
328 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
329 {
331 EntityAI ent = this;
332 EntityAI parent;
333 while (ent)
334 {
335 if (ent.GetInventory().GetCurrentInventoryLocation(loc) && loc.IsValid())
336 {
337 if (loc.GetType() == InventoryLocationType.CARGO)
338 {
339 parent = ent.GetHierarchyParent();
340 if (parent && parent.GetInventory().HasInventorySlot(slotId))
341 {
342 //Print("CanReceiveAttachment | parent " + parent + " matches in slot name: " + InventorySlots.GetSlotName(slotId) + " of " + this);
343 return false;
344 }
345 }
346 }
347
348 ent = ent.GetHierarchyParent();
349 }
350
351 return super.CanReceiveAttachment(attachment, slotId);
352 }
353
354 override bool CanLoadAttachment(EntityAI attachment)
355 {
356 int slotId;
357 for (int i = 0; i < attachment.GetInventory().GetSlotIdCount(); i++)
358 {
359 slotId = attachment.GetInventory().GetSlotId(i);
360 if (GetInventory().HasAttachmentSlot(slotId))
361 {
363 EntityAI ent = this;
364 EntityAI parent;
365 while (ent)
366 {
367 if (ent.GetInventory().GetCurrentInventoryLocation(loc) && loc.IsValid())
368 {
369 if (loc.GetType() == InventoryLocationType.CARGO)
370 {
371 parent = ent.GetHierarchyParent();
372 if (parent.GetInventory().HasInventorySlot(slotId))
373 {
374 //Print("CanLoadAttachment | parent " + parent + " matches in slot name: " + InventorySlots.GetSlotName(slotId) + " of " + this);
375 return false;
376 }
377 }
378 }
379
380 ent = ent.GetHierarchyParent();
381 }
382 }
383 }
384
385 return super.CanLoadAttachment(attachment);
386 }
387
388 //hands
389 override bool CanPutIntoHands(EntityAI parent)
390 {
391 if (!super.CanPutIntoHands(parent))
392 {
393 return false;
394 }
395
396 return !GetCompEM().IsSwitchedOn();
397 }
398
399 //================================================================
400 // ITEM-TO-ITEM FIRE DISTRIBUTION
401 //================================================================
402
403 override bool IsIgnited()
404 {
405 return GetCompEM().IsWorking();
406 }
407
408 override bool CanIgniteItem(EntityAI ignite_target = NULL)
409 {
410 return GetCompEM().IsWorking();
411 }
412
413 override void SetActions()
414 {
415 super.SetActions();
416
420 }
421
422 //Debug menu Spawn Ground Special
423 override void OnDebugSpawn()
424 {
425 EntityAI entity;
426 if ( Class.CastTo(entity, this) )
427 {
428 GetInventory().CreateInInventory("LargeGasCanister");
429 GetInventory().CreateInInventory("Pot");
430
431 SpawnEntityOnGroundPos("WaterBottle", entity.GetPosition() + Vector(0.2, 0, 0));
432 }
433 }
434
436 //DEPRECATED STUFF BELOW//
438 protected const float PARAM_COOKING_TEMP_THRESHOLD = 100;
439 protected const float PARAM_COOKING_EQUIP_MAX_TEMP = 400;
440 protected const float PARAM_COOKING_EQUIP_TEMP_INCREASE = 10;
442}
ActionLightItemOnFireCB ActionContinuousBaseCB ActionLightItemOnFire()
Определения ActionLightItemOnFire.c:11
void AddAction(typename actionName)
Определения AdvancedCommunication.c:220
DayZGame g_Game
Определения DayZGame.c:4074
void ClearCookingEquipment()
DEPRECATED.
Определения FireplaceBase.c:622
InventoryLocationType
types of Inventory Location
Определения InventoryLocation.c:4
ETemperatureAccessTypes
Определения TemperatureAccessConstants.c:2
Определения Cauldron.c:2
Super root of all classes in Enforce script.
Определения EnScript.c:11
Wrapper class for managing sound through SEffectManager.
Определения EffectSound.c:5
Определения FryingPan.c:2
proto native bool IsValid()
verify current set inventory location
proto native int GetType()
returns type of InventoryLocation
InventoryLocation.
Определения InventoryLocation.c:30
override void EEItemAttached(EntityAI item, string slot_name)
Определения PortableGasStove.c:85
override void OnSwitchOn()
Определения PortableGasStove.c:114
float m_TimeFactor
Определения PortableGasStove.c:15
override void OnWork(float consumed_energy)
Определения PortableGasStove.c:182
void RefreshFlameVisual(bool working=false, bool hasAttachment=false)
Определения PortableGasStove.c:230
EffectSound m_SoundTurnOn
Определения PortableGasLamp.c:14
EffectSound m_SoundTurnOff
Определения PortableGasLamp.c:15
override void OnWorkStart()
Определения PortableGasStove.c:144
ref UniversalTemperatureSource m_UTSource
DEPRECATED Attached spark plug item.
Определения PortableGasStove.c:29
ATTACHMENT_CAULDRON
Определения PortableGasStove.c:9
void SoundTurnOn()
Определения PortableGasLamp.c:74
ref Cooking m_CookingProcess
Определения PortableGasStove.c:17
const float PARAM_COOKING_EQUIP_MAX_TEMP
DEPRECATED.
Определения PortableGasStove.c:439
const float PARAM_COOKING_TARGET_TEMP
Определения PortableGasStove.c:13
override bool CanPutIntoHands(EntityAI parent)
Определения PortableGasStove.c:389
override void SetActions()
Определения PortableGasStove.c:413
void RefreshFlameVisual(bool working=false)
Определения Blowtorch.c:41
ref UniversalTemperatureSourceSettings m_UTSSettings
Определения PortableGasStove.c:30
override bool CanLoadAttachment(EntityAI attachment)
Определения PortableGasStove.c:354
void SoundBurningStart()
Определения Blowtorch.c:55
BlowtorchLight m_Light
Определения Blowtorch.c:7
void RemoveCookingAudioVisuals()
Определения PortableGasStove.c:258
void SetCookingEquipment(ItemBase equipment)
Определения PortableGasStove.c:39
const string SOUND_BURNING
Определения Blowtorch.c:5
const float PARAM_COOKING_EQUIP_TEMP_INCREASE
DEPRECATED.
Определения PortableGasStove.c:440
void SoundTurnOff()
Определения PortableGasLamp.c:79
void DestroyFireplace()
Определения PortableGasStove.c:55
ATTACHMENT_FRYING_PAN
Определения PortableGasStove.c:8
EffectSound m_SoundBurningLoop
Определения Blowtorch.c:9
override bool IsIgnited()
Определения PortableGasStove.c:403
override void OnWorkStop()
Определения PortableGasStove.c:162
const string SOUND_TURN_OFF
Определения PortableGasLamp.c:11
ItemBase m_CookingEquipment
Определения PortableGasStove.c:18
const string SOUND_TURN_ON
Определения PortableGasLamp.c:10
override bool IsSelfAdjustingTemperature()
Определения PortableGasStove.c:291
void ClearCookingEquipment(ItemBase pItem)
Определения PortableGasStove.c:44
void CookWithEquipment()
Определения PortableGasStove.c:216
ref UniversalTemperatureSourceLambdaConstant m_UTSLConst
Определения PortableGasStove.c:31
override void EEItemDetached(EntityAI item, string slot_name)
Определения PortableGasStove.c:97
const float PARAM_COOKING_TEMP_THRESHOLD
Определения PortableGasStove.c:438
override bool CanRemoveFromCargo(EntityAI parent)
Определения PortableGasStove.c:323
override void OnSwitchOff()
Определения PortableGasStove.c:127
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
Определения PortableGasStove.c:328
override bool CanPutInCargo(EntityAI parent)
Определения PortableGasStove.c:297
override void EEInit()
Определения PortableGasStove.c:61
override void OnDebugSpawn()
Определения PortableGasStove.c:423
void SoundBurningStop()
Определения Blowtorch.c:60
const float PARAM_COOKING_TIME_INC_COEF
Определения PortableGasStove.c:12
override bool CanIgniteItem(EntityAI ignite_target=NULL)
Определения PortableGasStove.c:408
ATTACHMENT_COOKING_POT
Определения PortableGasStove.c:7
const string FLAME_BUTANE_OFF
Определения PortableGasStove.c:6
const string FLAME_BUTANE_ON
Определения PortableGasStove.c:5
ItemBase GetCookingEquipment()
Определения PortableGasStove.c:34
override bool GetCookingTargetTemperature(out float temperature)
Определения PortableGasStove.c:224
Определения Pot.c:2
original Timer deletes m_params which is unwanted
Определения UniversalTemperatureSource.c:39
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
const float TEMP_COEF_GAS_STOVE
Определения 3_Game/DayZ/constants.c:1007
const float FIRE_ATTACHMENT_DAMAGE_PER_SECOND
various damage per second constants
Определения 3_Game/DayZ/constants.c:849
static const float ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE
Определения 3_Game/DayZ/constants.c:856
proto native vector Vector(float x, float y, float z)
Vector constructor from components.