3 const string DIRECT_COOKING_SLOT_NAME =
"DirectCooking";
5 const string SOUND_BAKING_START =
"Baking_SoundSet";
6 const string SOUND_BAKING_DONE =
"Baking_Done_SoundSet";
7 const string SOUND_BURNING_DONE =
"Food_Burning_SoundSet";
9 protected bool m_MakeCookingSounds;
10 protected SoundOnVehicle m_SoundCooking;
12 protected string m_SoundPlaying;
13 ref FoodStage m_FoodStage;
14 protected float m_DecayTimer;
15 protected float m_DecayDelta = 0.0;
27 RegisterNetSyncVariableInt(
"m_FoodStage.m_SelectionIndex", 0, 6);
28 RegisterNetSyncVariableInt(
"m_FoodStage.m_TextureIndex", 0, 6);
29 RegisterNetSyncVariableInt(
"m_FoodStage.m_MaterialIndex", 0, 6);
30 RegisterNetSyncVariableFloat(
"m_FoodStage.m_CookingTime", 0, 600, 0);
35 RegisterNetSyncVariableBool(
"m_MakeCookingSounds");
39 override void EEInit()
46 override void EEDelete(
EntityAI parent)
48 super.EEDelete(parent);
55 super.EEItemLocationChanged(oldLoc, newLoc);
60 switch (oldLoc.GetParent().GetType())
65 case "SharpWoodenStick":
66 MakeSoundsOnClient(
false);
73 MakeSoundsOnClient(
false);
82 GetFoodStage().UpdateVisuals();
86 bool Consume(
float amount,
PlayerBase consumer)
89 OnConsume(amount, consumer);
94 void OnConsume(
float amount,
PlayerBase consumer);
97 override bool CanBeCooked()
102 override bool CanBeCookedOnStick()
120 override void OnVariablesSynchronized()
122 super.OnVariablesSynchronized();
148 protected void RefreshAudio()
150 string soundName =
"";
154 switch (GetFoodStageType())
172 SoundCookingStart(soundName);
175 protected void RemoveAudio()
186 super.OnStoreSave(ctx);
190 GetFoodStage().OnStoreSave(ctx);
200 if (!super.OnStoreLoad(ctx, version))
205 if (!GetFoodStage().OnStoreLoad(ctx, version))
226 override void AfterStoreLoad()
228 super.AfterStoreLoad();
234 FoodStage GetFoodStage()
240 override bool IsMeat()
245 override bool IsCorpse()
250 override bool IsFruit()
255 override bool IsMushroom()
264 static float GetFoodTotalVolume(
ItemBase item,
string classname =
"",
int food_stage = 0)
267 if (food_item && food_item.GetFoodStage())
269 return FoodStage.GetFullnessIndex(food_item.GetFoodStage());
271 else if (classname !=
"" && food_stage)
273 return FoodStage.GetFullnessIndex(
null, food_stage, classname);
275 string class_path =
string.Format(
"cfgVehicles %1 Nutrition", classname);
276 return GetGame().ConfigGetFloat( class_path +
" fullnessIndex" );
280 static float GetFoodEnergy(
ItemBase item,
string classname =
"",
int food_stage = 0)
283 if (food_item && food_item.GetFoodStage())
285 return FoodStage.GetEnergy(food_item.GetFoodStage());
287 else if (classname !=
"" && food_stage)
289 return FoodStage.GetEnergy(
null, food_stage, classname);
291 string class_path =
string.Format(
"cfgVehicles %1 Nutrition", classname);
292 return GetGame().ConfigGetFloat( class_path +
" energy" );
295 static float GetFoodWater(
ItemBase item,
string classname =
"",
int food_stage = 0)
298 if (food_item && food_item.GetFoodStage())
300 return FoodStage.GetWater(food_item.GetFoodStage());
302 else if (classname !=
"" && food_stage)
304 return FoodStage.GetWater(
null, food_stage, classname);
306 string class_path =
string.Format(
"cfgVehicles %1 Nutrition", classname);
307 return GetGame().ConfigGetFloat( class_path +
" water" );
310 static float GetFoodNutritionalIndex(
ItemBase item,
string classname =
"",
int food_stage = 0)
313 if (food_item && food_item.GetFoodStage())
315 return FoodStage.GetNutritionalIndex(food_item.GetFoodStage());
317 else if (classname !=
"" && food_stage)
319 return FoodStage.GetNutritionalIndex(
null, food_stage, classname);
321 string class_path =
string.Format(
"cfgVehicles %1 Nutrition", classname);
322 return GetGame().ConfigGetFloat( class_path +
" nutritionalIndex" );
326 static float GetFoodToxicity(
ItemBase item,
string classname =
"",
int food_stage = 0)
329 if (food_item && food_item.GetFoodStage())
331 return FoodStage.GetToxicity(food_item.GetFoodStage());
333 else if (classname !=
"" && food_stage)
335 return FoodStage.GetToxicity(
null, food_stage, classname);
337 string class_path =
string.Format(
"cfgVehicles %1 Nutrition", classname);
338 return GetGame().ConfigGetFloat( class_path +
" toxicity" );
341 static int GetFoodAgents(
ItemBase item,
string classname =
"",
int food_stage = 0)
344 if (food_item && food_item.GetFoodStage())
346 return FoodStage.GetAgents(food_item.GetFoodStage());
348 else if (classname !=
"" && food_stage)
350 return FoodStage.GetAgents(
null, food_stage, classname);
352 string class_path =
string.Format(
"cfgVehicles %1 Nutrition", classname);
353 return GetGame().ConfigGetInt( class_path +
" agents" );
356 static float GetFoodDigestibility(
ItemBase item,
string classname =
"",
int food_stage = 0)
359 if (food_item && food_item.GetFoodStage())
361 return FoodStage.GetDigestibility(food_item.GetFoodStage());
363 else if (classname !=
"" && food_stage)
365 return FoodStage.GetDigestibility(
null, food_stage, classname);
367 string class_path =
string.Format(
"cfgVehicles %1 Nutrition", classname);
368 return GetGame().ConfigGetInt( class_path +
" digestibility" );
373 return new NutritionalProfile(GetFoodEnergy(item, classname, food_stage),GetFoodWater(item, classname, food_stage),GetFoodNutritionalIndex(item, classname, food_stage),GetFoodTotalVolume(item, classname, food_stage), GetFoodToxicity(item, classname, food_stage), GetFoodAgents(item, classname,food_stage), GetFoodDigestibility(item, classname,food_stage));
381 return GetFoodStage().GetFoodStageType();
387 if ( GetFoodStage() )
389 return GetFoodStage().IsFoodRaw();
397 if ( GetFoodStage() )
399 return GetFoodStage().IsFoodBaked();
407 if ( GetFoodStage() )
409 return GetFoodStage().IsFoodBoiled();
417 if ( GetFoodStage() )
419 return GetFoodStage().IsFoodDried();
427 if ( GetFoodStage() )
429 return GetFoodStage().IsFoodBurned();
437 if ( GetFoodStage() )
439 return GetFoodStage().IsFoodRotten();
448 GetFoodStage().ChangeFoodStage( new_food_stage_type );
453 return GetFoodStage().GetNextFoodStageType( cooking_method );
458 return GetFoodStage().GetFoodStageName( food_stage_type );
463 return GetFoodStage().CanChangeToNewStage( cooking_method );
467 void TransferFoodStage( notnull
Edible_Base source )
469 if ( !source.HasFoodStage())
472 ChangeFoodStage(source.GetFoodStage().GetFoodStageType());
481 float GetCookingTime()
483 return GetFoodStage().GetCookingTime();
486 void SetCookingTime(
float time )
488 GetFoodStage().SetCookingTime( time );
495 void ReplaceEdibleWithNew(
string typeName )
501 player.ServerReplaceItemInHandsWithNew(lambda);
504 Error(
"ReplaceEdibleWithNew - cannot use edible without player");
507 override void SetActions()
515 protected void SoundCookingStart(
string sound_name)
528 protected void SoundCookingStop()
540 override bool CanHaveTemperature()
545 override bool CanDecay()
550 override bool CanProcessDecay()
555 override void ProcessDecay(
float delta,
bool hasRootAsPlayer )
557 delta *= DayZGame.Cast(
GetGame()).GetFoodDecayModifier();
559 if ( hasRootAsPlayer )
568 if ( IsFruit() || IsMushroom() )
573 switch ( GetFoodStageType() )
615 int rng =
Math.RandomIntInclusive( 0, 100 );
641 switch ( GetFoodStageType() )
686 else if ( IsCorpse() )
691 switch ( GetFoodStageType() )
745 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
747 super.GetDebugActions(outputList);
758 super.OnAction(action_id, player, ctx);
762 if ( action_id ==
EActions.FOOD_STAGE_PREV )
764 int food_stage_prev = GetFoodStageType() - 1;
765 if (food_stage_prev <= 0)
769 ChangeFoodStage(food_stage_prev);
772 else if ( action_id ==
EActions.FOOD_STAGE_NEXT )
774 int food_stage_next = GetFoodStageType() + 1;
779 ChangeFoodStage(food_stage_next);
786 override string GetDebugText()
790 debug_output = super.GetDebugText();
802 float GetDecayTimer()
807 float GetDecayDelta()