15enum eCookingPropertyIndices
28 protected int m_SelectionIndex;
29 protected int m_TextureIndex;
30 protected int m_MaterialIndex;
32 protected float m_CookingTime;
37 static const string VISUAL_PROPERTIES =
"visual_properties";
38 static const string NUTRITION_PROPERTIES =
"nutrition_properties";
39 static const string COOKING_PROPERTIES =
"cooking_properties";
40 static const int VISUAL_PROPERTIES_HASH = VISUAL_PROPERTIES.
Hash();
41 static const int NUTRITION_PROPERTIES_HASH = NUTRITION_PROPERTIES.
Hash();
42 static const int COOKING_PROPERTIES_HASH = COOKING_PROPERTIES.
Hash();
45 private static int m_StageRawHash = 0;
46 private static int m_StageBakedHash = 0;
47 private static int m_StageBoiledHash = 0;
48 private static int m_StageDriedHash = 0;
49 private static int m_StageBurnedHash = 0;
50 private static int m_StageRottenHash = 0;
58 static ref
array<int> m_FoodStageTransitionKeys;
65 m_FoodItem = food_item;
70 m_FoodStageTypeClientLast = m_FoodStageType;
73 if ( m_StageRawHash == 0 )
74 m_StageRawHash =
"Raw".Hash();
75 if ( m_StageBakedHash == 0 )
76 m_StageBakedHash =
"Baked".Hash();
77 if ( m_StageBoiledHash == 0 )
78 m_StageBoiledHash =
"Boiled".Hash();
79 if ( m_StageDriedHash == 0 )
80 m_StageDriedHash =
"Dried".Hash();
81 if ( m_StageBurnedHash == 0 )
82 m_StageBurnedHash =
"Burned".Hash();
83 if ( m_StageRottenHash == 0 )
84 m_StageRottenHash =
"Rotten".Hash();
87 SetupFoodStageMapping();
90 SetupFoodStageTransitionMapping();
95 void SetupFoodStageMapping()
98 if ( !m_EdibleBasePropertiesMap )
101 string foodType = m_FoodItem.GetType();
102 int hashedFood = foodType.
Hash();
105 if ( !m_EdibleBasePropertiesMap.Contains( hashedFood ) )
118 stagePropertiesMap.Insert( VISUAL_PROPERTIES_HASH , visual_properties );
125 stagePropertiesMap.Insert( NUTRITION_PROPERTIES_HASH, nutrition_properties );
132 stagePropertiesMap.Insert( COOKING_PROPERTIES_HASH , cooking_properties );
135 foodStagesMap.Insert( GetFoodStageNameHash( i ), stagePropertiesMap );
138 m_EdibleBasePropertiesMap.Insert( hashedFood, foodStagesMap );
142 void SetupFoodStageTransitionMapping()
145 if ( !m_EdibleBaseTransitionsMap )
149 if ( !m_FoodStageTransitionKeys )
152 string foodType = m_FoodItem.GetType();
153 int hashedFood = foodType.
Hash();
156 if ( !m_EdibleBaseTransitionsMap.Contains( hashedFood ) )
163 string config_path =
string.Format(
"CfgVehicles %1 Food FoodStageTransitions %2", foodType,
GetFoodStageName( i ) );
171 string transition_path =
string.Format(
"%1 %2", config_path, classCheck );
172 if (
GetGame().ConfigIsExisting( transition_path ) )
174 int transitionClassHash = classCheck.
Hash();
175 stageTransition.Insert(
GetGame().ConfigGetInt(
string.Format(
"%1 transition_to", transition_path) ) );
176 stageTransition.Insert(
GetGame().ConfigGetInt(
string.Format(
"%1 cooking_method", transition_path) ) );
177 stageTransitionsMap.Insert( transitionClassHash, stageTransition);
180 if ( m_FoodStageTransitionKeys.Find( transitionClassHash ) == -1 )
182 m_FoodStageTransitionKeys.Insert( transitionClassHash );
187 foodStagesMap.Insert( GetFoodStageNameHash(i), stageTransitionsMap );
190 m_EdibleBaseTransitionsMap.Insert( hashedFood, foodStagesMap );
197 return m_FoodStageType;
202 m_FoodStageType = food_stage_type;
206 int GetSelectionIndex()
208 return m_SelectionIndex;
210 void SetSelectionIndex(
int index )
212 m_SelectionIndex = index;
216 int GetTextureIndex()
218 return m_TextureIndex;
220 void SetTextureIndex(
int index )
222 m_TextureIndex = index;
226 int GetMaterialIndex()
228 return m_MaterialIndex;
230 void SetMaterialIndex(
int index )
232 m_MaterialIndex = index;
236 protected static float GetNutritionPropertyFromIndex(
int index,
FoodStageType stage_type, FoodStage stage,
string classname )
240 stage_type = stage.m_FoodStageType;
241 classname = stage.GetFoodItem().GetType();
245 int hashedStageName = GetFoodStageNameHash( stage_type );
252 if( !m_EdibleBasePropertiesMap.Find(classname.
Hash(), foodStagesMap))
254 if( !foodStagesMap.Find(hashedStageName, stagePropertiesMap))
256 if( !stagePropertiesMap.Find(NUTRITION_PROPERTIES_HASH, nutrition_properties))
259 if ( nutrition_properties.Count() > 0 )
261 if ( index > (nutrition_properties.Count() - 1) )
267 return nutrition_properties.Get( index );
275 string config_path =
string.
Format(
"CfgVehicles %1 Food nutrition_modifiers_class", classname);
277 if (
GetGame().ConfigIsExisting( config_path ) )
279 string nutr_mod_class;
282 config_path =
string.
Format(
"CfgVehicles NutritionModifiers %1 base_stage", nutr_mod_class);
283 string nutr_base_stage;
287 config_path =
string.
Format(
"CfgVehicles %1 Food FoodStages %2 nutrition_properties", classname, nutr_base_stage);
291 config_path =
string.
Format(
"CfgVehicles NutritionModifiers %1 %2 nutrition_properties", nutr_mod_class, food_stage_name);
296 if ( base_nutr_properties.Count() > 0 && nutr_mod_properties.Count() > 0 )
298 return ( base_nutr_properties.Get( index ) * nutr_mod_properties.Get( index ) );
306 static float GetFullnessIndex(FoodStage stage,
int stage_type = -1,
string classname =
"")
308 return GetNutritionPropertyFromIndex( 0 , stage_type, stage, classname );
311 static float GetEnergy(FoodStage stage,
int stage_type = -1,
string classname =
"")
313 return GetNutritionPropertyFromIndex( 1 , stage_type, stage, classname );
316 static float GetWater(FoodStage stage,
int stage_type = -1,
string classname =
"")
318 return GetNutritionPropertyFromIndex( 2 , stage_type, stage, classname );
321 static float GetNutritionalIndex(FoodStage stage,
int stage_type = -1,
string classname =
"")
323 return GetNutritionPropertyFromIndex( 3 , stage_type , stage, classname);
326 static float GetToxicity(FoodStage stage,
int stage_type = -1,
string classname =
"")
328 return GetNutritionPropertyFromIndex( 4 , stage_type, stage, classname );
331 static int GetAgents(FoodStage stage,
int stage_type = -1,
string classname =
"")
333 return GetNutritionPropertyFromIndex( 5 , stage_type, stage, classname );
336 static float GetDigestibility(FoodStage stage,
int stage_type = -1,
string classname =
"")
338 return GetNutritionPropertyFromIndex( 6 , stage_type, stage, classname );
350 return m_CookingTime;
354 m_CookingTime = time;
357 static float GetCookingPropertyFromIndex(
int index,
FoodStageType stage_type, FoodStage stage,
string classname )
361 stage_type = stage.m_FoodStageType;
362 classname = stage.GetFoodItem().GetType();
366 int hashedStageName = GetFoodStageNameHash( stage_type );
373 m_EdibleBasePropertiesMap.Find(classname.
Hash(), foodStagesMap);
374 foodStagesMap.Find(hashedStageName, stagePropertiesMap);
376 stagePropertiesMap.Find(COOKING_PROPERTIES_HASH, cooking_properties);
378 if ( cooking_properties.Count() > 0 )
380 if ( index > (cooking_properties.Count() - 1) )
386 return cooking_properties.Get( index );
396 stage_type = stage.m_FoodStageType;
397 classname = stage.GetFoodItem().GetType();
401 int hashedStageName = GetFoodStageNameHash( stage_type );
408 m_EdibleBasePropertiesMap.Find(classname.
Hash(), foodStagesMap);
409 foodStagesMap.Find(hashedStageName, stagePropertiesMap);
411 stagePropertiesMap.Find(COOKING_PROPERTIES_HASH, cooking_properties);
413 if ( cooking_properties.Count() > 0 )
415 return cooking_properties;
442 m_EdibleBaseTransitionsMap.Find(GetFoodItem().
GetType().Hash(), foodStagesMap);
443 foodStagesMap.Find( GetFoodStageNameHash(
GetFoodStageType() ), foodTransitionsMap );
446 for (
int i = 0; i < m_FoodStageTransitionKeys.Count(); ++i )
449 foodTransitionsMap.Find(m_FoodStageTransitionKeys.Get( i ), food_transition);
450 if ( food_transition )
453 if ( food_transition.Get( 1 ) == cooking_method )
455 return food_transition.Get( 0 );
470 SetFoodStageType( new_stage_type );
474 m_EdibleBasePropertiesMap.Find( GetFoodItem().
GetType().Hash(), foodStagesMap );
475 foodStagesMap.Find( GetFoodStageNameHash(
GetFoodStageType() ), stagePropertiesMap );
476 stagePropertiesMap.Find( VISUAL_PROPERTIES_HASH, visual_properties );
478 if ( visual_properties.Count() > 0 )
481 int index = visual_properties.Get( 0 );
484 SetSelectionIndex( index );
487 index = visual_properties.Get( 1 );
490 SetTextureIndex( index );
493 index = visual_properties.Get( 2 );
496 SetMaterialIndex( index );
501 GetFoodItem().Synchronize();
511 array<string> config_selections = food_item.GetHiddenSelections();
512 array<string> config_textures = food_item.GetHiddenSelectionsTextures();
513 array<string> config_materials = food_item.GetHiddenSelectionsMaterials();
517 if ( GetSelectionIndex() >= 0 && config_selections.Count() > GetSelectionIndex() )
519 selection_index = GetSelectionIndex();
524 if ( GetTextureIndex() >= 0 && config_textures.Count() > GetTextureIndex() )
526 texture_index = GetTextureIndex();
531 if ( GetMaterialIndex() >= 0 && config_materials.Count() > GetMaterialIndex() )
533 material_index = GetMaterialIndex();
537 for (
int i = 0; i < config_selections.Count(); i++ )
539 if ( config_selections.Get( i ) != config_selections.Get( selection_index ) )
541 food_item.SetAnimationPhase( config_selections.Get( i ), 1 );
549 food_item.SetAnimationPhase( config_selections.Get( selection_index ), 0 );
551 food_item.SetObjectTexture( selection_index, config_textures.Get( texture_index ) );
553 food_item.SetObjectMaterial( selection_index, config_materials.Get( material_index ) );
556 m_FoodStageTypeClientLast = m_FoodStageType;
604 switch ( food_stage_type )
618 static int GetFoodStageNameHash(
FoodStageType food_stage_type )
620 switch ( food_stage_type )
630 return m_StageRawHash;
639 ctx.
Write( m_FoodStageType );
642 ctx.
Write( m_SelectionIndex );
645 ctx.
Write( m_TextureIndex );
648 ctx.
Write( m_MaterialIndex );
654 if ( !ctx.
Read( m_FoodStageType ) )
661 if ( !ctx.
Read( m_SelectionIndex ) )
663 m_SelectionIndex = 0;
668 if ( !ctx.
Read( m_TextureIndex ) )
675 if ( !ctx.
Read( m_MaterialIndex ) )
eBleedingSourceType GetType()
void SetCookingTime(float time)
string GetFoodStageName(FoodStageType food_stage_type)
FoodStageType GetFoodStageType()
bool CanChangeToNewStage(CookingMethodType cooking_method)
FoodStageType GetNextFoodStageType(CookingMethodType cooking_method)
void ChangeFoodStage(FoodStageType new_food_stage_type)
enum FoodStageType MIN_TEMP
enum FoodStageType COOK_TIME
void OnStoreSave(ParamsWriteContext ctx)
bool OnStoreLoad(ParamsReadContext ctx, int version)
proto native int ConfigGetChildrenCount(string path)
Get count of subclasses in config class on path.
proto native void ConfigGetFloatArray(string path, out TFloatArray values)
Get array of floats from config on path.
proto bool ConfigGetText(string path, out string value)
Get string value from config on path.
proto bool ConfigGetChildName(string path, int index, out string name)
Get name of subclass in config class on path.
Serialization general interface. Serializer API works with:
proto bool Write(void value_out)
proto bool Read(void value_in)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.
proto native int Hash()
Returns hash of string.