Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
foodstage.c
Go to the documentation of this file.
2{
3 NONE = 0, //food stage not defined
4 RAW = 1, //default
5 BAKED = 2,
6 BOILED = 3,
7 DRIED = 4,
8 BURNED = 5,
9 ROTTEN = 6,
10
11 COUNT //for net sync purposes
13
14// Used to make getting data more readable
15enum eCookingPropertyIndices
16{
19 MAX_TEMP = 2
20}
21
22class FoodStage
23{
24 protected Edible_Base m_FoodItem;
25 protected int m_SelectionIndex; //visual properties
26 protected int m_TextureIndex;
27 protected int m_MaterialIndex;
28
29 //synced variables
30 protected FoodStageType m_FoodStageType;
31 protected float m_CookingTime;
32
33 //mirror variables (local, as needed)
34 protected FoodStageType m_FoodStageTypeClientLast;
35
36 // Lookup and search values
37 // STRINGs are mostly used for CONFIG searches
38 // INTs are mostly used for MAP searches
39 static const string VISUAL_PROPERTIES = "visual_properties";
40 static const string NUTRITION_PROPERTIES = "nutrition_properties";
41 static const string COOKING_PROPERTIES = "cooking_properties";
42 static const int VISUAL_PROPERTIES_HASH = VISUAL_PROPERTIES.Hash();
43 static const int NUTRITION_PROPERTIES_HASH = NUTRITION_PROPERTIES.Hash();
44 static const int COOKING_PROPERTIES_HASH = COOKING_PROPERTIES.Hash();
45
46 static const int TRANSITION_FOODSTAGE_IDX = 0;
47 static const int TRANSITION_COOKINGMETHOD_IDX = 1;
48
49 // The following will be filled in constructor
50 private static int m_StageRawHash = 0;
51 private static int m_StageBakedHash = 0;
52 private static int m_StageBoiledHash = 0;
53 private static int m_StageDriedHash = 0;
54 private static int m_StageBurnedHash = 0;
55 private static int m_StageRottenHash = 0;
56
57 // Cache food stage data for each Edible_Base
58 // Used to get information for specific Edible_Base, information from 'class FoodStages'
59 static ref map<int, ref map<int, ref map<int, ref array<float>>>> m_EdibleBasePropertiesMap; //<foodTypeHash,<FoodStageNameHash,<stagePropertiesIdx,<visual_properties,nutrition_properties,cooking_properties>>>>
60 // Used to store food stage transitions for every Edible_Base, information from 'class FoodStageTransitions'
61 static ref map<int, ref map<int, ref map<int, ref array<int>>>> m_EdibleBaseTransitionsMap; //<<foodTypeHash,<FoodStageNameHash,<transitionClassHash('ToBaked' etc.),<transition_to,cooking_method>>>>
62 // Used to store the Hashed key of all possible food transitions ( including modded ones )
63 static ref array<int> m_FoodStageTransitionKeys;
64
65 //constructor
66 void FoodStage( Edible_Base food_item )
67 {
68 m_FoodStageType = FoodStageType.NONE;
69 m_FoodStageTypeClientLast = FoodStageType.NONE;
70 m_FoodItem = food_item;
71
72 //reset cooking time
73 m_CookingTime = 0;
74
75 // We fill all FoodStageHash values
76 if ( m_StageRawHash == 0 )
77 m_StageRawHash = "Raw".Hash();
78 if ( m_StageBakedHash == 0 )
79 m_StageBakedHash = "Baked".Hash();
80 if ( m_StageBoiledHash == 0 )
81 m_StageBoiledHash = "Boiled".Hash();
82 if ( m_StageDriedHash == 0 )
83 m_StageDriedHash = "Dried".Hash();
84 if ( m_StageBurnedHash == 0 )
85 m_StageBurnedHash = "Burned".Hash();
86 if ( m_StageRottenHash == 0 )
87 m_StageRottenHash = "Rotten".Hash();
88
89 //get config data for all food stages
90 SetupFoodStageMapping();
91
92 // Get all config data relative to food stage transitions
93 SetupFoodStageTransitionMapping();
94
95 //set default food type
97 }
98
99 void SetupFoodStageMapping()
100 {
101 // We ensure we have the map is setup before trying to fill it
102 if ( !m_EdibleBasePropertiesMap )
103 m_EdibleBasePropertiesMap = new map<int, ref map<int, ref map< int, ref array<float>>>>;
104
105 string foodType = m_FoodItem.GetType();
106 int hashedFood = foodType.Hash();
107
108 // We start to fill the map, we don't want duplicates of the same food type
109 if ( !m_EdibleBasePropertiesMap.Contains( hashedFood ) )
110 {
112
113 for ( int i = 1; i < FoodStageType.COUNT; ++i )
114 {
115 map<int, ref array<float>> stagePropertiesMap = new map<int, ref array<float>>;
116
117 // Insert visual properties
118 array<float> visual_properties = new array<float>;
119 string path = string.Format("CfgVehicles %1 Food FoodStages %2 visual_properties", foodType, GetFoodStageName(i));
120 GetGame().ConfigGetFloatArray( path, visual_properties);
121
122 stagePropertiesMap.Insert( VISUAL_PROPERTIES_HASH , visual_properties );
123
124 // Insert nutrition properties
125 array<float> nutrition_properties = new array<float>;
126 path = string.Format("CfgVehicles %1 Food FoodStages %2 nutrition_properties", foodType, GetFoodStageName(i));
127 GetGame().ConfigGetFloatArray( path, nutrition_properties);
128
129 stagePropertiesMap.Insert( NUTRITION_PROPERTIES_HASH, nutrition_properties );
130
131 // Insert cooking properties
132 array<float> cooking_properties = new array<float>;
133 path = string.Format("CfgVehicles %1 Food FoodStages %2 cooking_properties", foodType, GetFoodStageName(i));
134 GetGame().ConfigGetFloatArray( path, cooking_properties);
135
136 stagePropertiesMap.Insert( COOKING_PROPERTIES_HASH , cooking_properties );
137
138 // Insert all properties for relevant food stage
139 foodStagesMap.Insert( GetFoodStageNameHash( i ), stagePropertiesMap );
140 }
141
142 m_EdibleBasePropertiesMap.Insert( hashedFood, foodStagesMap );
143 }
144 }
145
146 void SetupFoodStageTransitionMapping()
147 {
148 // We ensure we have only one map and that it does exist
149 if ( !m_EdibleBaseTransitionsMap )
150 m_EdibleBaseTransitionsMap = new map<int, ref map<int, ref map< int, ref array<int>>>>;
151
152 // We ensure we have our key array setup
153 if ( !m_FoodStageTransitionKeys )
154 m_FoodStageTransitionKeys = new array<int>;
155
156 string foodType = m_FoodItem.GetType();
157 int hashedFood = foodType.Hash();
158
159 // We start to fill the map, we don't want duplicates of the same food type
160 if ( !m_EdibleBaseTransitionsMap.Contains( hashedFood ) )
161 {
163
164 for ( int i = 1; i < FoodStageType.COUNT; ++i )
165 {
166 map<int, ref array<int>> stageTransitionsMap = new map<int, ref array<int>>;
167 string config_path = string.Format("CfgVehicles %1 Food FoodStageTransitions %2", foodType, GetFoodStageName( i ) );
168
169 for ( int j = 0; j < GetGame().ConfigGetChildrenCount( config_path ); ++j )
170 {
171 array<int> stageTransition = new array<int>;
172 string classCheck; // Used to get any existing transition class
173 GetGame().ConfigGetChildName( config_path, j, classCheck );
174
175 string transition_path = string.Format("%1 %2", config_path, classCheck );
176 if ( GetGame().ConfigIsExisting( transition_path ) ) //TODO: we already know that from 'ConfigGetChildName', redundant?
177 {
178 int transitionClassHash = classCheck.Hash();
179 stageTransition.Insert( GetGame().ConfigGetInt( string.Format("%1 transition_to", transition_path) ) );
180 stageTransition.Insert( GetGame().ConfigGetInt( string.Format("%1 cooking_method", transition_path) ) );
181 stageTransitionsMap.Insert( transitionClassHash, stageTransition);
182
183 // We only want one entry per key
184 if ( m_FoodStageTransitionKeys.Find( transitionClassHash ) == -1 )
185 {
186 m_FoodStageTransitionKeys.Insert( transitionClassHash );
187 }
188 }
189 }
190
191 foodStagesMap.Insert( GetFoodStageNameHash(i), stageTransitionsMap );
192 }
193
194 m_EdibleBaseTransitionsMap.Insert( hashedFood, foodStagesMap );
195 }
196 }
197
198 //Food Stage Type
200 {
201 return m_FoodStageType;
202 }
203
204 void SetFoodStageType( FoodStageType food_stage_type )
205 {
206 FoodStageType stageOld = m_FoodStageType;
207 m_FoodStageType = food_stage_type;
208 OnFoodStageChange(stageOld,food_stage_type);
209
210 GetFoodItem().Synchronize();
211 }
212
213 //Selection index
214 int GetSelectionIndex()
215 {
216 return m_SelectionIndex;
217 }
218 void SetSelectionIndex( int index )
219 {
220 m_SelectionIndex = index;
221 }
222
223 //Texture index
224 int GetTextureIndex()
225 {
226 return m_TextureIndex;
227 }
228 void SetTextureIndex( int index )
229 {
230 m_TextureIndex = index;
231 }
232
233 //Material index
234 int GetMaterialIndex()
235 {
236 return m_MaterialIndex;
237 }
238 void SetMaterialIndex( int index )
239 {
240 m_MaterialIndex = index;
241 }
242
243 //Food properties
244 protected static float GetNutritionPropertyFromIndex( int index, FoodStageType stage_type, FoodStage stage, string classname )
245 {
246 if ( stage )
247 {
248 stage_type = stage.m_FoodStageType;
249 classname = stage.GetFoodItem().GetType();
250 }
251
252 string food_stage_name = GetFoodStageName( stage_type );
253 int hashedStageName = GetFoodStageNameHash( stage_type );
254
255 array<float> nutrition_properties;
256
258 map<int, ref array<float>> stagePropertiesMap;
259
260 if( !m_EdibleBasePropertiesMap.Find(classname.Hash(), foodStagesMap))
261 return 0;
262 if( !foodStagesMap.Find(hashedStageName, stagePropertiesMap))
263 return 0;
264 if( !stagePropertiesMap.Find(NUTRITION_PROPERTIES_HASH, nutrition_properties))
265 return 0;
266
267 if ( nutrition_properties.Count() > 0 )
268 {
269 if ( index > (nutrition_properties.Count() - 1) )
270 {
271 return 0;
272 }
273 else
274 {
275 return nutrition_properties.Get( index );
276 }
277 }
278 //calculate nutrition properties from base stage and nutrition modifiers
279 else
280 {
281 // Will not attempt to optimize this as it is for a setup we do not support internally
282 //get modifiers class for nutrition values
283 string config_path = string.Format("CfgVehicles %1 Food nutrition_modifiers_class", classname);
284
285 if ( GetGame().ConfigIsExisting( config_path ) )
286 {
287 string nutr_mod_class;
288 GetGame().ConfigGetText( config_path, nutr_mod_class );
289
290 config_path = string.Format("CfgVehicles NutritionModifiers %1 base_stage", nutr_mod_class);
291 string nutr_base_stage;
292 GetGame().ConfigGetText( config_path, nutr_base_stage );
293
294 //get nutrition values for food stage and modifiers
295 config_path = string.Format("CfgVehicles %1 Food FoodStages %2 nutrition_properties", classname, nutr_base_stage);
296 array<float> base_nutr_properties = new array<float>;
297 GetGame().ConfigGetFloatArray( config_path, base_nutr_properties );
298
299 config_path = string.Format("CfgVehicles NutritionModifiers %1 %2 nutrition_properties", nutr_mod_class, food_stage_name);
300 array<float> nutr_mod_properties = new array<float>;
301 GetGame().ConfigGetFloatArray( config_path, nutr_mod_properties );
302
303 //base nutrition * food stage nutrition modifier
304 if ( base_nutr_properties.Count() > 0 && nutr_mod_properties.Count() > 0 )
305 {
306 return ( base_nutr_properties.Get( index ) * nutr_mod_properties.Get( index ) );
307 }
308 }
309 }
310
311 return 0;
312 }
313
314 static float GetFullnessIndex(FoodStage stage, int stage_type = -1, string classname = "")
315 {
316 return GetNutritionPropertyFromIndex( 0 , stage_type, stage, classname );
317 }
318
319 static float GetEnergy(FoodStage stage, int stage_type = -1, string classname = "")
320 {
321 return GetNutritionPropertyFromIndex( 1 , stage_type, stage, classname );
322 }
323
324 static float GetWater(FoodStage stage, int stage_type = -1, string classname = "")
325 {
326 return GetNutritionPropertyFromIndex( 2 , stage_type, stage, classname );
327 }
328
329 static float GetNutritionalIndex(FoodStage stage, int stage_type = -1, string classname = "")
330 {
331 return GetNutritionPropertyFromIndex( 3 , stage_type , stage, classname);
332 }
333
334 static float GetToxicity(FoodStage stage, int stage_type = -1, string classname = "")
335 {
336 return GetNutritionPropertyFromIndex( 4 , stage_type, stage, classname );
337 }
338
339 static int GetAgents(FoodStage stage, int stage_type = -1, string classname = "")
340 {
341 return GetNutritionPropertyFromIndex( 5 , stage_type, stage, classname );
342 }
343
344 static float GetDigestibility(FoodStage stage, int stage_type = -1, string classname = "")
345 {
346 return GetNutritionPropertyFromIndex( 6 , stage_type, stage, classname );
347 }
348
349 static float GetAgentsPerDigest(FoodStage stage, int stageType = -1, string className = "")
350 {
351 return GetNutritionPropertyFromIndex(7, stageType, stage, className);
352 }
353
354 //Food item
355 protected Edible_Base GetFoodItem()
356 {
357 return m_FoodItem;
358 }
359
360 //Cooking time
361 float GetCookingTime()
362 {
363 return m_CookingTime;
364 }
365 void SetCookingTime( float time )
366 {
367 m_CookingTime = time;
368 }
369
370 static float GetCookingPropertyFromIndex( int index, FoodStageType stage_type, FoodStage stage, string classname )
371 {
372 if ( stage )
373 {
374 stage_type = stage.m_FoodStageType;
375 classname = stage.GetFoodItem().GetType();
376 }
377
378 string food_stage_name = GetFoodStageName( stage_type );
379 int hashedStageName = GetFoodStageNameHash( stage_type );
380
381 array<float> cooking_properties = new array<float>;
382
384 map<int, ref array<float>> stagePropertiesMap = new map<int, ref array<float>>;
385
386 m_EdibleBasePropertiesMap.Find(classname.Hash(), foodStagesMap);
387 foodStagesMap.Find(hashedStageName, stagePropertiesMap);
388
389 stagePropertiesMap.Find(COOKING_PROPERTIES_HASH, cooking_properties);
390
391 if ( cooking_properties.Count() > 0 )
392 {
393 if ( index > (cooking_properties.Count() - 1) )
394 {
395 return -1;
396 }
397 else
398 {
399 return cooking_properties.Get( index );
400 }
401 }
402 return 0;
403 }
404
405 static array<float> GetAllCookingPropertiesForStage( FoodStageType stage_type, FoodStage stage, string classname )
406 {
407 if ( stage )
408 {
409 stage_type = stage.m_FoodStageType;
410 classname = stage.GetFoodItem().GetType();
411 }
412
413 string food_stage_name = GetFoodStageName( stage_type );
414 int hashedStageName = GetFoodStageNameHash( stage_type );
415
416 array<float> cooking_properties = new array<float>;
417
419 map<int, ref array<float>> stagePropertiesMap = new map<int, ref array<float>>;
420
421 m_EdibleBasePropertiesMap.Find(classname.Hash(), foodStagesMap);
422 foodStagesMap.Find(hashedStageName, stagePropertiesMap);
423
424 stagePropertiesMap.Find(COOKING_PROPERTIES_HASH, cooking_properties);
425
426 if ( cooking_properties.Count() > 0 )
427 {
428 return cooking_properties;
429 }
430 return null;
431 }
432
433 //********************************************/
434 // FOOD STAGE CHANGE
435 //********************************************/
436 //Checks if food stage can be changed to another stage
437 bool CanChangeToNewStage( CookingMethodType cooking_method )
438 {
439 if ( GetNextFoodStageType( cooking_method ) == FoodStageType.NONE )
440 {
441 return false;
442 }
443
444 return true;
445 }
446
447 //returns possible food stage type according to given cooking method
449 {
450 array<int> food_transition = new array<int>;
451
453 map<int, ref array<int>> foodTransitionsMap = new map<int, ref array<int>>;
454
455 m_EdibleBaseTransitionsMap.Find(GetFoodItem().GetType().Hash(), foodStagesMap);
456 foodStagesMap.Find( GetFoodStageNameHash( GetFoodStageType() ), foodTransitionsMap );
457
458 // We go through the key array, checking every possible transition
459 int count = m_FoodStageTransitionKeys.Count();
460 for (int i = 0; i < count; ++i) //TODO: foodTransitionsMap should contain same info (keys) as m_FoodStageTransitionKeys. Just iterate through those instead?
461 {
462 // We test if a given transition is setup on this item
463 foodTransitionsMap.Find(m_FoodStageTransitionKeys[i], food_transition);
464 if (food_transition)
465 {
466 // We now check if the given transition class is relevant
467 if (food_transition[TRANSITION_COOKINGMETHOD_IDX] == cooking_method)
468 {
469 return food_transition[TRANSITION_FOODSTAGE_IDX];
470 }
471 }
472 }
473
474 return FoodStageType.BURNED; //If the item cannot transition out of current state, burn it //TODO: return 'NONE' and substitute BURNED from that, where appropriate
475 }
476
477 bool CanTransitionToFoodStageType(FoodStageType type)
478 {
479 array<int> food_transition = new array<int>;
480
482 map<int, ref array<int>> foodTransitionsMap = new map<int, ref array<int>>;
483
484 m_EdibleBaseTransitionsMap.Find(GetFoodItem().GetType().Hash(), foodStagesMap);
485 foodStagesMap.Find(GetFoodStageNameHash(GetFoodStageType()), foodTransitionsMap);
486
487 // We go through the key array, checking every possible transition
488 int count = m_FoodStageTransitionKeys.Count();
489 for (int i = 0; i < count; ++i) //TODO: foodTransitionsMap should contain same info (keys) as m_FoodStageTransitionKeys. Just iterate through those instead?
490 {
491 // We test if a given transition is setup on this item
492 foodTransitionsMap.Find(m_FoodStageTransitionKeys[i], food_transition);
493 if (food_transition )
494 {
495 // We now check if the given transition class is relevant
496 if (food_transition[0] == type)
497 {
498 return true;
499 }
500 }
501 }
502
503 return false;
504 }
505
506 void ChangeFoodStage(FoodStageType new_stage_type)
507 {
508 SetFoodStageType(new_stage_type);
509 }
510
511 void OnFoodStageChange(FoodStageType stageOld, FoodStageType stageNew)
512 {
513 //init value setting, not a change
514 if (stageOld == FoodStageType.NONE)
515 return ;
516
517 //not a change
518 if (stageOld == stageNew)
519 return ;
520
521 m_FoodItem.OnFoodStageChange(stageOld,stageNew);
522 }
523
524 void UpdateVisualsEx(bool forced = false)
525 {
526 if (forced || m_FoodStageTypeClientLast != m_FoodStageType)
527 {
528 Edible_Base food_item = GetFoodItem();
530 map<int, ref array<float>> stagePropertiesMap = new map<int, ref array<float>>;
531 array<float> visual_properties = new array<float>;
532
533 m_EdibleBasePropertiesMap.Find(food_item.GetType().Hash(), foodStagesMap);
534 foodStagesMap.Find(GetFoodStageNameHash( GetFoodStageType() ), stagePropertiesMap);
535 stagePropertiesMap.Find(VISUAL_PROPERTIES_HASH, visual_properties);
536
537 if (visual_properties.Count() > 0)
538 {
539 //selection index
540 int index = visual_properties.Get( 0 );
541 if ( index >= 0 ) //leaves last valid idx otherwise
542 {
543 SetSelectionIndex( index );
544 }
545 //texture index
546 index = visual_properties.Get( 1 );
547 if ( index >= 0 ) //leaves last valid idx otherwise
548 {
549 SetTextureIndex( index );
550 }
551 //material index
552 index = visual_properties.Get( 2 );
553 if ( index >= 0 ) //leaves last valid idx otherwise
554 {
555 SetMaterialIndex( index );
556 }
557 }
558
559 array<string> config_selections = food_item.GetHiddenSelections();
560 array<string> config_textures = food_item.GetHiddenSelectionsTextures();
561 array<string> config_materials = food_item.GetHiddenSelectionsMaterials();
562
563 //selection index
564 int selection_index;
565 if ( GetSelectionIndex() >= 0 && config_selections.Count() > GetSelectionIndex() ) //USES the last valid idx
566 {
567 selection_index = GetSelectionIndex();
568 }
569
570 //texture index
571 int texture_index;
572 if ( GetTextureIndex() >= 0 && config_textures.Count() > GetTextureIndex() ) //USES the last valid idx
573 {
574 texture_index = GetTextureIndex();
575 }
576
577 //material index
578 int material_index;
579 if ( GetMaterialIndex() >= 0 && config_materials.Count() > GetMaterialIndex() ) //USES the last valid idx
580 {
581 material_index = GetMaterialIndex();
582 }
583
584 //hide all selection except the configured one
585 for ( int i = 0; i < config_selections.Count(); i++ )
586 {
587 if ( config_selections.Get( i ) != config_selections.Get( selection_index ) )
588 {
589 food_item.SetAnimationPhase( config_selections.Get( i ), 1 );
590 }
591 }
592
593 //show selection
594 food_item.SetAnimationPhase( config_selections.Get( selection_index ), 0 );
595 //set texture
596 food_item.SetObjectTexture( selection_index, config_textures.Get( texture_index ) );
597 //set materials
598 food_item.SetObjectMaterial( selection_index, config_materials.Get( material_index ) );
599
600 m_FoodStageTypeClientLast = m_FoodStageType;
601 }
602 }
603
604 //Food States
605 //check food stages
606 bool IsFoodInStage( FoodStageType food_stage_type )
607 {
608 if ( GetFoodStageType() == food_stage_type )
609 {
610 return true;
611 }
612
613 return false;
614 }
615
616 bool IsFoodRaw()
617 {
618 return IsFoodInStage( FoodStageType.RAW );
619 }
620
621 bool IsFoodBaked()
622 {
623 return IsFoodInStage( FoodStageType.BAKED );
624 }
625
626 bool IsFoodBoiled()
627 {
628 return IsFoodInStage( FoodStageType.BOILED );
629 }
630
631 bool IsFoodDried()
632 {
633 return IsFoodInStage( FoodStageType.DRIED );
634 }
635
636 bool IsFoodBurned()
637 {
638 return IsFoodInStage( FoodStageType.BURNED );
639 }
640
641 bool IsFoodRotten()
642 {
643 return IsFoodInStage( FoodStageType.ROTTEN );
644 }
645
646 //get name of food stage type
647 static string GetFoodStageName( FoodStageType food_stage_type )
648 {
649 switch ( food_stage_type )
650 {
651 case FoodStageType.RAW: return "Raw";
652 case FoodStageType.BAKED: return "Baked";
653 case FoodStageType.BOILED: return "Boiled";
654 case FoodStageType.DRIED: return "Dried";
655 case FoodStageType.BURNED: return "Burned";
656 case FoodStageType.ROTTEN: return "Rotten";
657 }
658
659 return "Raw";
660 }
661
662 // Get hashed name of food stage type for quicker access
663 static int GetFoodStageNameHash( FoodStageType food_stage_type )
664 {
665 switch ( food_stage_type )
666 {
667 case FoodStageType.RAW: return m_StageRawHash;
668 case FoodStageType.BAKED: return m_StageBakedHash;
669 case FoodStageType.BOILED: return m_StageBoiledHash;
670 case FoodStageType.DRIED: return m_StageDriedHash;
671 case FoodStageType.BURNED: return m_StageBurnedHash;
672 case FoodStageType.ROTTEN: return m_StageRottenHash;
673 }
674
675 return m_StageRawHash;
676 }
677
678 //================================================================
679 // SERIALIZATION
680 //================================================================
682 {
683 //Food stage type
684 ctx.Write( m_FoodStageType );
685
686 //Selection index
687 ctx.Write( m_SelectionIndex );
688
689 //Texture index
690 ctx.Write( m_TextureIndex );
691
692 //Material index
693 ctx.Write( m_MaterialIndex );
694 }
695
696 bool OnStoreLoad( ParamsReadContext ctx, int version )
697 {
698 //Food stage type
699 if ( !ctx.Read( m_FoodStageType ) )
700 {
701 m_FoodStageType = FoodStageType.RAW; //set default
702 return false;
703 }
704
705 //Selection index
706 if ( !ctx.Read( m_SelectionIndex ) )
707 {
708 m_SelectionIndex = 0; //set default
709 return false;
710 }
711
712 //Texture index
713 if ( !ctx.Read( m_TextureIndex ) )
714 {
715 m_TextureIndex = 0; //set default
716 return false;
717 }
718
719 //Material index
720 if ( !ctx.Read( m_MaterialIndex ) )
721 {
722 m_MaterialIndex = 0; //set default
723 return false;
724 }
725
726 return true;
727 }
728
730 //DEPRECATED
732 void UpdateVisuals()
733 {
734 UpdateVisualsEx();
735 }
736}
eBleedingSourceType GetType()
void OnFoodStageChange(FoodStageType stageOld, FoodStageType stageNew)
called on server
Serialization general interface. Serializer API works with:
Definition serializer.c:56
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
void UpdateVisuals()
CookingMethodType
Definition cooking.c:2
bool IsFoodRotten()
bool IsFoodBaked()
void OnFoodStageChange(FoodStageType stageOld, FoodStageType stageNew)
called on server
bool CanChangeToNewStage(CookingMethodType cooking_method)
FoodStageType GetNextFoodStageType(CookingMethodType cooking_method)
void ChangeFoodStage(FoodStageType new_food_stage_type)
float GetCookingTime()
string GetFoodStageName(FoodStageType food_stage_type)
void SetCookingTime(float time)
FoodStageType GetFoodStageType()
bool IsFoodDried()
bool IsFoodRaw()
bool IsFoodBurned()
bool IsFoodBoiled()
enum FoodStageType MIN_TEMP
FoodStageType
Definition foodstage.c:2
@ COUNT
Definition foodstage.c:11
@ ROTTEN
Definition foodstage.c:9
@ BOILED
Definition foodstage.c:6
@ BAKED
Definition foodstage.c:5
@ BURNED
Definition foodstage.c:8
@ RAW
Definition foodstage.c:4
@ NONE
Definition foodstage.c:3
@ DRIED
Definition foodstage.c:7
enum FoodStageType COOK_TIME
proto native CGame GetGame()
float GetEnergy()
Definition itembase.c:8420
override int GetAgents()
Definition itembase.c:8810
void OnStoreSave(ParamsWriteContext ctx)
bool OnStoreLoad(ParamsReadContext ctx, int version)