DayZ 1.27
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 GetGame().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 (GetGame().IsServer() || !GetGame().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 (GetGame().IsServer() || !GetGame().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 (GetGame().IsServer() || !GetGame().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 m_Light = StoveLight.Cast(ScriptedLightBase.CreateLight(StoveLight, "0 0 0"));
150 m_Light.AttachOnMemoryPoint(this, "light");
151 #endif
152
153 //refresh visual
155
156 //sound (client only)
158 }
159
160 override void OnWorkStop()
161 {
162 #ifndef SERVER
163 if (m_Light)
164 {
165 m_Light.FadeOut();
166 }
167 #endif
168
169 //refresh visual
170 RefreshFlameVisual(false, false);
171 //stop effects
173 //sound (client only)
175 }
176
177 //on update
178 override void OnWork(float consumed_energy)
179 {
180 if (GetGame().IsServer() || !GetGame().IsMultiplayer())
181 {
183 }
184
185 //manage cooking equipment
187 if (item && item.CanHaveTemperature())
188 {
189 if (GetGame() && GetGame().IsServer())
190 {
191 float cook_equip_temp = item.GetTemperature();
192 float target; //makes sense here, since gas stove does not heat itself, and we need some target
193 if (!GetCookingTargetTemperature(target))
194 target = PARAM_COOKING_TARGET_TEMP; //fallback value
195
196 float diff = target - cook_equip_temp;
197 float heatPermCoef = item.GetHeatPermeabilityCoef();
198
199 //heat only, no self-coolig like FireplaceBase
200 if (diff > 0)
201 item.SetTemperatureEx(new TemperatureDataInterpolated(target,ETemperatureAccessTypes.ACCESS_FIREPLACE,GetCompEM().GetUpdateInterval(),GameConstants.TEMP_COEF_GAS_STOVE,heatPermCoef));
202
203 m_TimeFactor = consumed_energy;
204 CookWithEquipment(); //heat children
205
207 GetCookingEquipment().DecreaseHealth(GameConstants.FIRE_ATTACHMENT_DAMAGE_PER_SECOND * GetCompEM().GetUpdateInterval(), false);
208 }
209 }
210 }
211
213 {
214 if (m_CookingProcess == null)
215 m_CookingProcess = new Cooking();
216
218 }
219
220 override bool GetCookingTargetTemperature(out float temperature)
221 {
222 temperature = PARAM_COOKING_TARGET_TEMP;
223 return true;
224 }
225
226 protected void RefreshFlameVisual(bool working = false, bool hasAttachment = false)
227 {
228 if (!working)
229 {
230 SetObjectTexture(0, FLAME_BUTANE_OFF);
231 SetObjectTexture(1, FLAME_BUTANE_OFF);
232
233 return;
234 }
235
236 if (!hasAttachment)
237 {
239 SetObjectTexture(0, FLAME_BUTANE_ON);
240 SetObjectTexture(1, FLAME_BUTANE_OFF);
241 }
242 else
243 {
245 SetObjectTexture(0, FLAME_BUTANE_OFF);
246 SetObjectTexture(1, FLAME_BUTANE_ON);
247 }
248 }
249
250 //================================================================
251 // PARTICLES
252 //================================================================
253 //cooking equipment steam
255 {
256 ItemBase cookEquipment;
257 if (Class.CastTo(cookEquipment,GetCookingEquipment()) && (cookEquipment.IsCookware() || cookEquipment.IsLiquidContainer())) //also stops boiling effect on bottles
258 cookEquipment.RemoveAudioVisualsOnClient();
259 }
260
261 //================================================================
262 // SOUNDS
263 //================================================================
264 protected void SoundBurningStart()
265 {
266 PlaySoundSetLoop(m_SoundBurningLoop, SOUND_BURNING, 0.1, 0.3);
267 }
268
269 protected void SoundBurningStop()
270 {
271 StopSoundSet(m_SoundBurningLoop);
272 }
273
274 protected void SoundTurnOn()
275 {
276 PlaySoundSet(m_SoundTurnOn, SOUND_TURN_ON, 0.1, 0.1);
277 }
278
279 protected void SoundTurnOff()
280 {
281 PlaySoundSet(m_SoundTurnOff, SOUND_TURN_OFF, 0.1, 0.1);
282 }
283
284 //================================================================
285 // CONDITIONS
286 //================================================================
287 override bool IsSelfAdjustingTemperature() //prevents CE temperature updates in vicinity, does not really have its own temperature
288 {
289 return GetCompEM().IsWorking();
290 }
291
292 //this into/outo parent.Cargo
293 override bool CanPutInCargo(EntityAI parent)
294 {
295 if (!super.CanPutInCargo(parent))
296 return false;
297
298 if (GetCompEM().IsSwitchedOn())
299 return false;
300
301 //can 'parent' be attached to 'this' (->assumed smaller size than 'this')?
302 if (parent)
303 {
304 int slotId;
305 for (int i = 0; i < GetInventory().GetAttachmentSlotsCount(); i++)
306 {
307 slotId = GetInventory().GetAttachmentSlotId(i);
308 if (parent.GetInventory().HasInventorySlot(slotId))
309 {
310 //Print("CanPutInCargo | parent " + parent + " matches in slot name: " + InventorySlots.GetSlotName(slotId) + " of " + this);
311 return false;
312 }
313 }
314 }
315
316 return true;
317 }
318
319 override bool CanRemoveFromCargo(EntityAI parent)
320 {
321 return true;
322 }
323
324 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
325 {
327 EntityAI ent = this;
328 EntityAI parent;
329 while (ent)
330 {
331 if (ent.GetInventory().GetCurrentInventoryLocation(loc) && loc.IsValid())
332 {
333 if (loc.GetType() == InventoryLocationType.CARGO)
334 {
335 parent = ent.GetHierarchyParent();
336 if (parent && parent.GetInventory().HasInventorySlot(slotId))
337 {
338 //Print("CanReceiveAttachment | parent " + parent + " matches in slot name: " + InventorySlots.GetSlotName(slotId) + " of " + this);
339 return false;
340 }
341 }
342 }
343
344 ent = ent.GetHierarchyParent();
345 }
346
347 return super.CanReceiveAttachment(attachment, slotId);
348 }
349
350 override bool CanLoadAttachment(EntityAI attachment)
351 {
352 int slotId;
353 for (int i = 0; i < attachment.GetInventory().GetSlotIdCount(); i++)
354 {
355 slotId = attachment.GetInventory().GetSlotId(i);
356 if (GetInventory().HasAttachmentSlot(slotId))
357 {
359 EntityAI ent = this;
360 EntityAI parent;
361 while (ent)
362 {
363 if (ent.GetInventory().GetCurrentInventoryLocation(loc) && loc.IsValid())
364 {
365 if (loc.GetType() == InventoryLocationType.CARGO)
366 {
367 parent = ent.GetHierarchyParent();
368 if (parent.GetInventory().HasInventorySlot(slotId))
369 {
370 //Print("CanLoadAttachment | parent " + parent + " matches in slot name: " + InventorySlots.GetSlotName(slotId) + " of " + this);
371 return false;
372 }
373 }
374 }
375
376 ent = ent.GetHierarchyParent();
377 }
378 }
379 }
380
381 return super.CanLoadAttachment(attachment);
382 }
383
384 //hands
385 override bool CanPutIntoHands(EntityAI parent)
386 {
387 if (!super.CanPutIntoHands(parent))
388 {
389 return false;
390 }
391
392 return !GetCompEM().IsSwitchedOn();
393 }
394
395 //================================================================
396 // ITEM-TO-ITEM FIRE DISTRIBUTION
397 //================================================================
398
399 override bool IsIgnited()
400 {
401 return GetCompEM().IsWorking();
402 }
403
404 override bool CanIgniteItem(EntityAI ignite_target = NULL)
405 {
406 return GetCompEM().IsWorking();
407 }
408
409 override void SetActions()
410 {
411 super.SetActions();
412
416 }
417
418 //Debug menu Spawn Ground Special
419 override void OnDebugSpawn()
420 {
421 EntityAI entity;
422 if ( Class.CastTo(entity, this) )
423 {
424 GetInventory().CreateInInventory("LargeGasCanister");
425 GetInventory().CreateInInventory("Pot");
426
427 SpawnEntityOnGroundPos("WaterBottle", entity.GetPosition() + Vector(0.2, 0, 0));
428 }
429 }
430
432 //DEPRECATED STUFF BELOW//
434 protected const float PARAM_COOKING_TEMP_THRESHOLD = 100;
435 protected const float PARAM_COOKING_EQUIP_MAX_TEMP = 400;
436 protected const float PARAM_COOKING_EQUIP_TEMP_INCREASE = 10;
438}
ActionLightItemOnFireCB ActionContinuousBaseCB ActionLightItemOnFire()
Определения ActionLightItemOnFire.c:11
void AddAction(typename actionName)
Определения AdvancedCommunication.c:220
void ClearCookingEquipment()
DEPRECATED.
Определения FireplaceBase.c:604
InventoryLocationType
types of Inventory Location
Определения InventoryLocation.c:4
ETemperatureAccessTypes
Определения TemperatureAccessConstants.c:2
proto native void ObjectDelete(Object obj)
Определения Cauldron.c:2
Super root of all classes in Enforce script.
Определения EnScript.c:11
Wrapper class for managing sound through SEffectManager.
Определения EffectSound.c:5
Определения Building.c:6
Определения FryingPan.c:2
Определения constants.c:659
proto native bool IsValid()
verify current set inventory location
proto native int GetType()
returns type of InventoryLocation
InventoryLocation.
Определения InventoryLocation.c:29
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:178
void RefreshFlameVisual(bool working=false, bool hasAttachment=false)
Определения PortableGasStove.c:226
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:435
const float PARAM_COOKING_TARGET_TEMP
Определения PortableGasStove.c:13
override bool CanPutIntoHands(EntityAI parent)
Определения PortableGasStove.c:385
override void SetActions()
Определения PortableGasStove.c:409
void RefreshFlameVisual(bool working=false)
Определения Blowtorch.c:37
ref UniversalTemperatureSourceSettings m_UTSSettings
Определения PortableGasStove.c:30
override bool CanLoadAttachment(EntityAI attachment)
Определения PortableGasStove.c:350
void SoundBurningStart()
Определения Blowtorch.c:51
BlowtorchLight m_Light
Определения Blowtorch.c:7
void RemoveCookingAudioVisuals()
Определения PortableGasStove.c:254
void SetCookingEquipment(ItemBase equipment)
Определения PortableGasStove.c:39
const string SOUND_BURNING
Определения Blowtorch.c:5
const float PARAM_COOKING_EQUIP_TEMP_INCREASE
DEPRECATED.
Определения PortableGasStove.c:436
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:399
override void OnWorkStop()
Определения PortableGasStove.c:160
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:287
void ClearCookingEquipment(ItemBase pItem)
Определения PortableGasStove.c:44
void CookWithEquipment()
Определения PortableGasStove.c:212
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:434
override bool CanRemoveFromCargo(EntityAI parent)
Определения PortableGasStove.c:319
override void OnSwitchOff()
Определения PortableGasStove.c:127
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
Определения PortableGasStove.c:324
override bool CanPutInCargo(EntityAI parent)
Определения PortableGasStove.c:293
override void EEInit()
Определения PortableGasStove.c:61
override void OnDebugSpawn()
Определения PortableGasStove.c:419
void SoundBurningStop()
Определения Blowtorch.c:56
const float PARAM_COOKING_TIME_INC_COEF
Определения PortableGasStove.c:12
override bool CanIgniteItem(EntityAI ignite_target=NULL)
Определения PortableGasStove.c:404
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:220
Определения InventoryItem.c:731
Определения Pot.c:2
original Timer deletes m_params which is unwanted
Определения UniversalTemperatureSource.c:38
proto native CGame GetGame()
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
Определения constants.c:944
const float FIRE_ATTACHMENT_DAMAGE_PER_SECOND
various damage per second constants
Определения constants.c:799
static const float ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE
Определения constants.c:806
proto native vector Vector(float x, float y, float z)
Vector constructor from components.