Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
edible_base.c
Go to the documentation of this file.
1 class Edible_Base : ItemBase
2 {
3  const string DIRECT_COOKING_SLOT_NAME = "DirectCooking";
4 
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";
8 
9  protected bool m_MakeCookingSounds;
10  protected SoundOnVehicle m_SoundCooking;
11  protected EffectSound m_SoundEffectCooking;
12  protected string m_SoundPlaying;
13  ref FoodStage m_FoodStage;
14  protected float m_DecayTimer;
15  protected float m_DecayDelta = 0.0;
16  protected FoodStageType m_LastDecayStage = FoodStageType.NONE;
17 
18  private CookingMethodType m_CookedByMethod;
19 
20  void Edible_Base()
21  {
22  if (HasFoodStage())
23  {
24  m_FoodStage = new FoodStage(this);
25 
26  RegisterNetSyncVariableInt("m_FoodStage.m_FoodStageType", FoodStageType.NONE, FoodStageType.COUNT);
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);
31 
32  m_SoundPlaying = "";
34  RegisterNetSyncVariableInt("m_CookedByMethod", CookingMethodType.NONE, CookingMethodType.COUNT);
35  RegisterNetSyncVariableBool("m_MakeCookingSounds");
36  }
37  }
38 
39  override void EEInit()
40  {
41  super.EEInit();
42 
43  UpdateVisuals();
44  }
45 
46  override void EEDelete(EntityAI parent)
47  {
48  super.EEDelete(parent);
49 
50  RemoveAudio();
51  }
52 
53  override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
54  {
55  super.EEItemLocationChanged(oldLoc, newLoc);
56 
58  if (oldLoc.GetType() == InventoryLocationType.ATTACHMENT || oldLoc.GetType() == InventoryLocationType.CARGO)
59  {
60  switch (oldLoc.GetParent().GetType())
61  {
62  case "FryingPan":
63  case "Pot":
64  case "Cauldron":
65  case "SharpWoodenStick":
66  MakeSoundsOnClient(false);
67  break;
68  }
69 
71  if (oldLoc.GetSlot() > -1 && InventorySlots.GetSlotName(oldLoc.GetSlot()).Contains(DIRECT_COOKING_SLOT_NAME))
72  {
73  MakeSoundsOnClient(false);
74  }
75  }
76  }
77 
78  void UpdateVisuals()
79  {
80  if (GetFoodStage())
81  {
82  GetFoodStage().UpdateVisuals();
83  }
84  }
85 
86  bool Consume(float amount, PlayerBase consumer)
87  {
88  AddQuantity(-amount, false, false);
89  OnConsume(amount, consumer);
90 
91  return true;
92  }
93 
94  void OnConsume(float amount, PlayerBase consumer);
95 
96  //food staging
97  override bool CanBeCooked()
98  {
99  return false;
100  }
101 
102  override bool CanBeCookedOnStick()
103  {
104  return false;
105  }
106 
107  //================================================================
108  // SYNCHRONIZATION
109  //================================================================
110  void Synchronize()
111  {
112  SetSynchDirty();
113 
114  if (GetGame().IsMultiplayer())
115  {
116  UpdateVisuals();
117  }
118  }
119 
120  override void OnVariablesSynchronized()
121  {
122  super.OnVariablesSynchronized();
123 
124  UpdateVisuals();
125 
126  //update audio
128  {
129  RefreshAudio();
130  }
131  else
132  {
133  RemoveAudio();
134  }
135  }
136 
137  //================================================================
138  // AUDIO EFFECTS (WHEN ON DCS)
139  //================================================================
140  void MakeSoundsOnClient(bool soundstate, CookingMethodType cookingMethod = CookingMethodType.NONE)
141  {
142  m_MakeCookingSounds = soundstate;
143  m_CookedByMethod = cookingMethod;
144 
145  Synchronize();
146  }
147 
148  protected void RefreshAudio()
149  {
150  string soundName = "";
151 
152  FoodStageType nextFoodState = GetNextFoodStageType(m_CookedByMethod);
153 
154  switch (GetFoodStageType())
155  {
156  case FoodStageType.RAW:
157  soundName = SOUND_BAKING_START;
158  if (nextFoodState == FoodStageType.BOILED)
159  soundName = "";
160  break;
161  case FoodStageType.BAKED:
162  soundName = SOUND_BAKING_DONE;
163  break;
164  case FoodStageType.BURNED:
165  soundName = SOUND_BURNING_DONE;
166  break;
167  default:
168  soundName = "";
169  break;
170  }
171 
172  SoundCookingStart(soundName);
173  }
174 
175  protected void RemoveAudio()
176  {
177  m_MakeCookingSounds = false;
178  SoundCookingStop();
179  }
180 
181  //================================================================
182  // SERIALIZATION
183  //================================================================
184  override void OnStoreSave(ParamsWriteContext ctx)
185  {
186  super.OnStoreSave(ctx);
187 
188  if (GetFoodStage())
189  {
190  GetFoodStage().OnStoreSave(ctx);
191  }
192 
193  // food decay
194  ctx.Write(m_DecayTimer);
195  ctx.Write(m_LastDecayStage);
196  }
197 
198  override bool OnStoreLoad(ParamsReadContext ctx, int version)
199  {
200  if (!super.OnStoreLoad(ctx, version))
201  return false;
202 
203  if (GetFoodStage())
204  {
205  if (!GetFoodStage().OnStoreLoad(ctx, version))
206  return false;
207  }
208 
209  if (version >= 115)
210  {
211  if (!ctx.Read(m_DecayTimer))
212  {
213  m_DecayTimer = 0.0;
214  return false;
215  }
216  if (!ctx.Read(m_LastDecayStage))
217  {
219  return false;
220  }
221  }
222 
223  return true;
224  }
225 
226  override void AfterStoreLoad()
227  {
228  super.AfterStoreLoad();
229 
230  Synchronize();
231  }
232 
233  //get food stage
234  FoodStage GetFoodStage()
235  {
236  return m_FoodStage;
237  }
238 
239  //food types
240  override bool IsMeat()
241  {
242  return false;
243  }
244 
245  override bool IsCorpse()
246  {
247  return false;
248  }
249 
250  override bool IsFruit()
251  {
252  return false;
253  }
254 
255  override bool IsMushroom()
256  {
257  return false;
258  }
259 
260  //================================================================
261  // NUTRITIONAL VALUES
262  //================================================================
263  //food properties
264  static float GetFoodTotalVolume(ItemBase item, string classname = "", int food_stage = 0)
265  {
266  Edible_Base food_item = Edible_Base.Cast(item);
267  if (food_item && food_item.GetFoodStage())
268  {
269  return FoodStage.GetFullnessIndex(food_item.GetFoodStage());
270  }
271  else if (classname != "" && food_stage)
272  {
273  return FoodStage.GetFullnessIndex(null, food_stage, classname);
274  }
275  string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
276  return GetGame().ConfigGetFloat( class_path + " fullnessIndex" );
277 
278  }
279 
280  static float GetFoodEnergy(ItemBase item, string classname = "", int food_stage = 0)
281  {
282  Edible_Base food_item = Edible_Base.Cast(item);
283  if (food_item && food_item.GetFoodStage())
284  {
285  return FoodStage.GetEnergy(food_item.GetFoodStage());
286  }
287  else if (classname != "" && food_stage)
288  {
289  return FoodStage.GetEnergy(null, food_stage, classname);
290  }
291  string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
292  return GetGame().ConfigGetFloat( class_path + " energy" );
293  }
294 
295  static float GetFoodWater(ItemBase item, string classname = "", int food_stage = 0)
296  {
297  Edible_Base food_item = Edible_Base.Cast(item);
298  if (food_item && food_item.GetFoodStage())
299  {
300  return FoodStage.GetWater(food_item.GetFoodStage());
301  }
302  else if (classname != "" && food_stage)
303  {
304  return FoodStage.GetWater(null, food_stage, classname);
305  }
306  string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
307  return GetGame().ConfigGetFloat( class_path + " water" );
308  }
309 
310  static float GetFoodNutritionalIndex(ItemBase item, string classname = "", int food_stage = 0)
311  {
312  Edible_Base food_item = Edible_Base.Cast(item);
313  if (food_item && food_item.GetFoodStage())
314  {
315  return FoodStage.GetNutritionalIndex(food_item.GetFoodStage());
316  }
317  else if (classname != "" && food_stage)
318  {
319  return FoodStage.GetNutritionalIndex(null, food_stage, classname);
320  }
321  string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
322  return GetGame().ConfigGetFloat( class_path + " nutritionalIndex" );
323 
324  }
325 
326  static float GetFoodToxicity(ItemBase item, string classname = "", int food_stage = 0)
327  {
328  Edible_Base food_item = Edible_Base.Cast(item);
329  if (food_item && food_item.GetFoodStage())
330  {
331  return FoodStage.GetToxicity(food_item.GetFoodStage());
332  }
333  else if (classname != "" && food_stage)
334  {
335  return FoodStage.GetToxicity(null, food_stage, classname);
336  }
337  string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
338  return GetGame().ConfigGetFloat( class_path + " toxicity" );
339  }
340 
341  static int GetFoodAgents(ItemBase item, string classname = "", int food_stage = 0)
342  {
343  Edible_Base food_item = Edible_Base.Cast(item);
344  if (food_item && food_item.GetFoodStage())
345  {
346  return FoodStage.GetAgents(food_item.GetFoodStage());
347  }
348  else if (classname != "" && food_stage)
349  {
350  return FoodStage.GetAgents(null, food_stage, classname);
351  }
352  string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
353  return GetGame().ConfigGetInt( class_path + " agents" );
354  }
355 
356  static float GetFoodDigestibility(ItemBase item, string classname = "", int food_stage = 0)
357  {
358  Edible_Base food_item = Edible_Base.Cast(item);
359  if (food_item && food_item.GetFoodStage())
360  {
361  return FoodStage.GetDigestibility(food_item.GetFoodStage());
362  }
363  else if (classname != "" && food_stage)
364  {
365  return FoodStage.GetDigestibility(null, food_stage, classname);
366  }
367  string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
368  return GetGame().ConfigGetInt( class_path + " digestibility" );
369  }
370 
371  static NutritionalProfile GetNutritionalProfile(ItemBase item, string classname = "", int food_stage = 0)
372  {
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));
374  }
375 
376  //================================================================
377  // FOOD STAGING
378  //================================================================
379  FoodStageType GetFoodStageType()
380  {
381  return GetFoodStage().GetFoodStageType();
382  }
383 
384  //food stage states
385  bool IsFoodRaw()
386  {
387  if ( GetFoodStage() )
388  {
389  return GetFoodStage().IsFoodRaw();
390  }
391 
392  return false;
393  }
394 
395  bool IsFoodBaked()
396  {
397  if ( GetFoodStage() )
398  {
399  return GetFoodStage().IsFoodBaked();
400  }
401 
402  return false;
403  }
404 
405  bool IsFoodBoiled()
406  {
407  if ( GetFoodStage() )
408  {
409  return GetFoodStage().IsFoodBoiled();
410  }
411 
412  return false;
413  }
414 
415  bool IsFoodDried()
416  {
417  if ( GetFoodStage() )
418  {
419  return GetFoodStage().IsFoodDried();
420  }
421 
422  return false;
423  }
424 
425  bool IsFoodBurned()
426  {
427  if ( GetFoodStage() )
428  {
429  return GetFoodStage().IsFoodBurned();
430  }
431 
432  return false;
433  }
434 
435  bool IsFoodRotten()
436  {
437  if ( GetFoodStage() )
438  {
439  return GetFoodStage().IsFoodRotten();
440  }
441 
442  return false;
443  }
444 
445  //food stage change
446  void ChangeFoodStage( FoodStageType new_food_stage_type )
447  {
448  GetFoodStage().ChangeFoodStage( new_food_stage_type );
449  }
450 
451  FoodStageType GetNextFoodStageType( CookingMethodType cooking_method )
452  {
453  return GetFoodStage().GetNextFoodStageType( cooking_method );
454  }
455 
456  string GetFoodStageName( FoodStageType food_stage_type )
457  {
458  return GetFoodStage().GetFoodStageName( food_stage_type );
459  }
460 
461  bool CanChangeToNewStage( CookingMethodType cooking_method )
462  {
463  return GetFoodStage().CanChangeToNewStage( cooking_method );
464  }
465 
466  //Use this to receive food stage from another Edible_Base
467  void TransferFoodStage( notnull Edible_Base source )
468  {
469  if ( !source.HasFoodStage())
470  return;
471  m_LastDecayStage = source.GetLastDecayStage();
472  ChangeFoodStage(source.GetFoodStage().GetFoodStageType());
473  m_DecayTimer = source.GetDecayTimer();
474  m_DecayDelta = source.GetDecayDelta();
475  }
476 
477  //================================================================
478  // COOKING
479  //================================================================
480  //cooking time
481  float GetCookingTime()
482  {
483  return GetFoodStage().GetCookingTime();
484  }
485 
486  void SetCookingTime( float time )
487  {
488  GetFoodStage().SetCookingTime( time );
489 
490  //synchronize when calling on server
491  Synchronize();
492  }
493 
494  //replace edible with new item (opening cans)
495  void ReplaceEdibleWithNew( string typeName )
496  {
497  PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
498  if (player)
499  {
500  ReplaceEdibleWithNewLambda lambda = new ReplaceEdibleWithNewLambda(this, typeName, player);
501  player.ServerReplaceItemInHandsWithNew(lambda);
502  }
503  else
504  Error("ReplaceEdibleWithNew - cannot use edible without player");
505  }
506 
507  override void SetActions()
508  {
509  super.SetActions();
510 
513  }
514 
515  protected void SoundCookingStart(string sound_name)
516  {
517  #ifndef SERVER
518  if (m_SoundPlaying != sound_name)
519  {
520  SoundCookingStop();
521 
522  m_SoundEffectCooking = SEffectManager.PlaySound(sound_name, GetPosition(), 0, 0, true);
523  m_SoundPlaying = sound_name;
524  }
525  #endif
526  }
527 
528  protected void SoundCookingStop()
529  {
530  #ifndef SERVER
532  {
533  m_SoundEffectCooking.Stop();
534  m_SoundEffectCooking = null;
535  m_SoundPlaying = "";
536  }
537  #endif
538  }
539 
540  override bool CanHaveTemperature()
541  {
542  return true;
543  }
544 
545  override bool CanDecay()
546  {
547  return false;
548  }
549 
550  override bool CanProcessDecay()
551  {
552  return ( GetFoodStageType() != FoodStageType.ROTTEN );
553  }
554 
555  override void ProcessDecay( float delta, bool hasRootAsPlayer )
556  {
557  delta *= DayZGame.Cast(GetGame()).GetFoodDecayModifier();
558  m_DecayDelta += ( 1 + ( 1 - GetHealth01( "", "" ) ) );
559  if ( hasRootAsPlayer )
560  m_DecayDelta += GameConstants.DECAY_RATE_ON_PLAYER;
561 
562  /*Print( "-------------------------" );
563  Print( this );
564  Print( m_DecayTimer );
565  Print( m_DecayDelta );
566  Print( m_LastDecayStage );*/
567 
568  if ( IsFruit() || IsMushroom() )
569  {
570  // fruit, vegetables and mushrooms
571  if ( m_LastDecayStage != GetFoodStageType() )
572  {
573  switch ( GetFoodStageType() )
574  {
575  case FoodStageType.RAW:
576  m_DecayTimer = ( GameConstants.DECAY_FOOD_RAW_FRVG + ( Math.RandomFloat01() * ( GameConstants.DECAY_FOOD_RAW_FRVG * ( GameConstants.DECAY_TIMER_RANDOM_PERCENTAGE / 100.0 ) ) ) );
578  break;
579 
580  case FoodStageType.BOILED:
581  m_DecayTimer = ( GameConstants.DECAY_FOOD_BOILED_FRVG + ( Math.RandomFloat01() * ( GameConstants.DECAY_FOOD_BOILED_FRVG * ( GameConstants.DECAY_TIMER_RANDOM_PERCENTAGE / 100.0 ) ) ) );
583  break;
584 
585  case FoodStageType.BAKED:
586  m_DecayTimer = ( GameConstants.DECAY_FOOD_BAKED_FRVG + ( Math.RandomFloat01() * ( GameConstants.DECAY_FOOD_BAKED_FRVG * ( GameConstants.DECAY_TIMER_RANDOM_PERCENTAGE / 100.0 ) ) ) );
588  break;
589 
590  case FoodStageType.DRIED:
591  case FoodStageType.BURNED:
592  case FoodStageType.ROTTEN:
593  default:
594  m_DecayTimer = -1;
596  return;
597  }
598 
599  //m_DecayTimer = m_DecayTimer / 1000.0;
600  }
601 
602  m_DecayTimer -= ( delta * m_DecayDelta );
603 
604  if ( m_DecayTimer <= 0 )
605  {
606  if ( m_LastDecayStage != FoodStageType.NONE )
607  {
608  // switch to decayed stage
609  if ( ( m_LastDecayStage == FoodStageType.BOILED ) || ( m_LastDecayStage == FoodStageType.BAKED ) )
610  {
611  ChangeFoodStage( FoodStageType.ROTTEN );
612  }
613  if ( m_LastDecayStage == FoodStageType.RAW )
614  {
615  int rng = Math.RandomIntInclusive( 0, 100 );
616  if ( rng > GameConstants.DECAY_FOOD_FRVG_DRIED_CHANCE )
617  {
618  ChangeFoodStage( FoodStageType.ROTTEN );
619  }
620  else
621  {
622  if ( CanChangeToNewStage( FoodStageType.DRIED ) )
623  {
624  ChangeFoodStage( FoodStageType.DRIED );
625  }
626  else
627  {
628  ChangeFoodStage( FoodStageType.ROTTEN );
629  }
630  }
631  }
632  }
633  }
634 
635  }
636  else if ( IsMeat() )
637  {
638  // meat
639  if ( m_LastDecayStage != GetFoodStageType() )
640  {
641  switch ( GetFoodStageType() )
642  {
643  case FoodStageType.RAW:
644  m_DecayTimer = ( GameConstants.DECAY_FOOD_RAW_MEAT + ( Math.RandomFloat01() * ( GameConstants.DECAY_FOOD_RAW_MEAT * ( GameConstants.DECAY_TIMER_RANDOM_PERCENTAGE / 100.0 ) ) ) );
646  break;
647 
648  case FoodStageType.BOILED:
649  m_DecayTimer = ( GameConstants.DECAY_FOOD_BOILED_MEAT + ( Math.RandomFloat01() * ( GameConstants.DECAY_FOOD_BOILED_MEAT * ( GameConstants.DECAY_TIMER_RANDOM_PERCENTAGE / 100.0 ) ) ) );
651  break;
652 
653  case FoodStageType.BAKED:
654  m_DecayTimer = ( GameConstants.DECAY_FOOD_BAKED_MEAT + ( Math.RandomFloat01() * ( GameConstants.DECAY_FOOD_BAKED_MEAT * ( GameConstants.DECAY_TIMER_RANDOM_PERCENTAGE / 100.0 ) ) ) );
656  break;
657 
658  case FoodStageType.DRIED:
659  m_DecayTimer = ( GameConstants.DECAY_FOOD_DRIED_MEAT + ( Math.RandomFloat01() * ( GameConstants.DECAY_FOOD_DRIED_MEAT * ( GameConstants.DECAY_TIMER_RANDOM_PERCENTAGE / 100.0 ) ) ) );
661  break;
662 
663  case FoodStageType.BURNED:
664  case FoodStageType.ROTTEN:
665  default:
666  m_DecayTimer = -1;
668  return;
669  }
670  }
671 
672  m_DecayTimer -= ( delta * m_DecayDelta );
673 
674  if ( m_DecayTimer <= 0 )
675  {
676  if ( m_LastDecayStage != FoodStageType.NONE )
677  {
678  // switch to decayed stage
679  if ( ( m_LastDecayStage == FoodStageType.DRIED ) || ( m_LastDecayStage == FoodStageType.RAW ) || ( m_LastDecayStage == FoodStageType.BOILED ) || ( m_LastDecayStage == FoodStageType.BAKED ) )
680  {
681  ChangeFoodStage( FoodStageType.ROTTEN );
682  }
683  }
684  }
685  }
686  else if ( IsCorpse() )
687  {
688  // corpse
689  if ( m_LastDecayStage != GetFoodStageType() )
690  {
691  switch ( GetFoodStageType() )
692  {
693  case FoodStageType.RAW:
694  m_DecayTimer = ( GameConstants.DECAY_FOOD_RAW_CORPSE + ( Math.RandomFloat01() * ( GameConstants.DECAY_FOOD_RAW_CORPSE * ( GameConstants.DECAY_TIMER_RANDOM_PERCENTAGE / 100.0 ) ) ) );
696  break;
697 
698  case FoodStageType.BURNED:
699  case FoodStageType.ROTTEN:
700  default:
701  m_DecayTimer = -1;
703  return;
704  }
705  }
706 
707  m_DecayTimer -= ( delta * m_DecayDelta );
708 
709  if ( m_DecayTimer <= 0 )
710  {
711  if ( m_LastDecayStage != FoodStageType.NONE )
712  {
713  // switch to decayed stage
714  if ( ( m_LastDecayStage == FoodStageType.DRIED ) || ( m_LastDecayStage == FoodStageType.RAW ) || ( m_LastDecayStage == FoodStageType.BOILED ) || ( m_LastDecayStage == FoodStageType.BAKED ) )
715  {
716  ChangeFoodStage( FoodStageType.ROTTEN );
717  }
718  }
719  }
720  }
721  else
722  {
723  // opened cans
724  m_DecayTimer -= ( delta * m_DecayDelta );
725 
726  if ( ( m_DecayTimer <= 0 ) && ( m_LastDecayStage == FoodStageType.NONE ) )
727  {
728  m_DecayTimer = ( GameConstants.DECAY_FOOD_CAN_OPEN + ( Math.RandomFloat01() * ( GameConstants.DECAY_FOOD_DRIED_MEAT * ( GameConstants.DECAY_TIMER_RANDOM_PERCENTAGE / 100.0 ) ) ) );
730  //m_DecayTimer = m_DecayTimer / 1000.0;
731  }
732  else
733  {
734  if ( m_DecayTimer <= 0 )
735  {
736  InsertAgent(eAgents.FOOD_POISON, 1);
737  m_DecayTimer = -1;
738  }
739  }
740  }
741 
742  m_DecayDelta = 0.0;
743  }
744 
745  override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
746  {
747  super.GetDebugActions(outputList);
748 
749  if (HasFoodStage())
750  {
751  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FOOD_STAGE_PREV, "Food Stage Prev", FadeColors.WHITE));
752  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FOOD_STAGE_NEXT, "Food Stage Next", FadeColors.WHITE));
753  }
754  }
755 
756  override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
757  {
758  super.OnAction(action_id, player, ctx);
759 
760  if ( GetGame().IsServer() )
761  {
762  if ( action_id == EActions.FOOD_STAGE_PREV )
763  {
764  int food_stage_prev = GetFoodStageType() - 1;
765  if (food_stage_prev <= 0)
766  {
767  food_stage_prev = FoodStageType.COUNT - 1;
768  }
769  ChangeFoodStage(food_stage_prev);
770  return true;
771  }
772  else if ( action_id == EActions.FOOD_STAGE_NEXT )
773  {
774  int food_stage_next = GetFoodStageType() + 1;
775  if (food_stage_next >= FoodStageType.COUNT )
776  {
777  food_stage_next = FoodStageType.RAW;
778  }
779  ChangeFoodStage(food_stage_next);
780  return true;
781  }
782  }
783  return false;
784  }
785 
786  override string GetDebugText()
787  {
788  string debug_output;
789 
790  debug_output = super.GetDebugText();
791 
792  debug_output+="m_CookedByMethod:"+m_CookedByMethod+"\n";
793  debug_output+="m_MakeCookingSounds:"+m_MakeCookingSounds+"\n";
794 
795  return debug_output;
796  }
797 
798  //================================================================
799  // GENERAL GETTERS
800  //================================================================
801 
802  float GetDecayTimer()
803  {
804  return m_DecayTimer;
805  }
806 
807  float GetDecayDelta()
808  {
809  return m_DecayDelta;
810  }
811 
812  FoodStageType GetLastDecayStage()
813  {
814  return m_LastDecayStage;
815  }
816 }
817 
819 {
820  void ReplaceEdibleWithNewLambda(EntityAI old_item, string new_item_type, PlayerBase player) { }
821 };
ItemBase
Definition: inventoryitem.c:730
GetGame
proto native CGame GetGame()
Error
void Error(string err)
Messagebox with error message.
Definition: endebug.c:90
m_SoundEffectCooking
protected EffectSound m_SoundEffectCooking
DEPRECATED.
Definition: edible_base.c:10
SOUND_BAKING_DONE
const string SOUND_BAKING_DONE
Definition: edible_base.c:5
InventorySlots
provides access to slot configuration
Definition: inventoryslots.c:5
ActionDetach
void ActionDetach()
Definition: actiondetach.c:10
m_CookedByMethod
private CookingMethodType m_CookedByMethod
Definition: edible_base.c:17
HasFoodStage
bool HasFoodStage()
Definition: itembase.c:2359
InventoryLocation
InventoryLocation.
Definition: inventorylocation.c:27
AddQuantity
bool AddQuantity(float value, bool destroy_config=true, bool destroy_forced=false)
add item quantity[related to varQuantity... config entry], destroy_config = true > if the quantity re...
Definition: itembase.c:3221
InsertAgent
override void InsertAgent(int agent, float count=1)
Definition: itembase.c:3860
Serializer
Serialization general interface. Serializer API works with:
Definition: serializer.c:55
GetPosition
class JsonUndergroundAreaTriggerData GetPosition
Definition: undergroundarealoader.c:9
EffectSound
Wrapper class for managing sound through SEffectManager.
Definition: effectsound.c:4
ReplaceEdibleWithNewLambda
Edible_Base ItemBase ReplaceEdibleWithNewLambda(EntityAI old_item, string new_item_type, PlayerBase player)
Definition: edible_base.c:820
m_DecayDelta
protected float m_DecayDelta
Definition: edible_base.c:14
PlayerBase
Definition: playerbaseclient.c:1
eAgents
eAgents
Definition: eagents.c:2
InventoryLocationType
InventoryLocationType
types of Inventory Location
Definition: inventorylocation.c:3
AddAction
void AddAction(typename actionName)
Definition: advancedcommunication.c:86
FoodStageType
FoodStageType
Definition: foodstage.c:1
ActionAttach
ActionAttachWheels ActionAttach
EActions
EActions
Definition: eactions.c:1
m_DecayTimer
protected float m_DecayTimer
Definition: edible_base.c:13
m_FoodStage
ref FoodStage m_FoodStage
Definition: edible_base.c:12
NutritionalProfile
Definition: nutritionalprofile.c:1
m_MakeCookingSounds
protected bool m_MakeCookingSounds
Definition: edible_base.c:8
m_LastDecayStage
protected FoodStageType m_LastDecayStage
Definition: edible_base.c:15
GameConstants
Definition: constants.c:612
SOUND_BAKING_START
const string SOUND_BAKING_START
Definition: edible_base.c:4
DIRECT_COOKING_SLOT_NAME
const string DIRECT_COOKING_SLOT_NAME
Definition: edible_base.c:2
SOUND_BURNING_DONE
const string SOUND_BURNING_DONE
Definition: edible_base.c:6
CookingMethodType
CookingMethodType
Definition: cooking.c:1
SAT_DEBUG_ACTION
const int SAT_DEBUG_ACTION
Definition: constants.c:424
Math
Definition: enmath.c:6
TSelectableActionInfoWithColor
Param4< int, int, string, int > TSelectableActionInfoWithColor
Definition: entityai.c:97
SEffectManager
Manager class for managing Effect (EffectParticle, EffectSound)
Definition: effectmanager.c:5
TurnItemIntoItemLambda
Definition: miscgameplayfunctions.c:91
EntityAI
Definition: building.c:5
Edible_Base
Definition: bearsteakmeat.c:1
m_SoundPlaying
protected string m_SoundPlaying
Definition: edible_base.c:11