DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ UpdateCookingState()

int UpdateCookingState ( Edible_Base item_to_cook,
CookingMethodType cooking_method,
ItemBase cooking_equipment,
float cooking_time_coef )
protected

enable cooking SoundEvent

Change food stage to new, IF DIFFERENT

any foodstage without lard

any foodstage without lard

См. определение в файле Cooking.c строка 196

197 {
198 //food properties
199 float food_temperature = item_to_cook.GetTemperature();
200
201 //{min_temperature, time_to_cook, max_temperature (optional)}
202 //get next stage name - if next stage is not defined, next stage name will be empty "" and no cooking properties (food_min_temp, food_time_to_cook, food_max_temp) will be set
203 FoodStageType new_stage_type = item_to_cook.GetNextFoodStageType(cooking_method);
204
205 float food_min_temp = 0;
206 float food_time_to_cook = 0;
207
208 //Set next stage cooking properties if next stage possible
209 if (item_to_cook.CanChangeToNewStage(cooking_method)) // new_stage_type != NONE
210 {
211 array<float> next_stage_cooking_properties = new array<float>();
212 next_stage_cooking_properties = FoodStage.GetAllCookingPropertiesForStage(new_stage_type, null, item_to_cook.GetType());
213
214 food_min_temp = next_stage_cooking_properties.Get(eCookingPropertyIndices.MIN_TEMP); //checked after temperature is changed
215 food_time_to_cook = next_stage_cooking_properties.Get(eCookingPropertyIndices.COOK_TIME);
216 }
217
218 //add temperature
219 AddTemperatureToItem(item_to_cook, cooking_equipment, food_min_temp);
220
221 //decrease qty of burned items (or cookable items that can't be burned)
222 if (item_to_cook.IsItemOverheated())
224
225 //add cooking time if the food can be cooked by this method
226 if (food_min_temp > 0 && food_temperature >= food_min_temp)
227 {
229 item_to_cook.MakeSoundsOnClient(true,cooking_method);
230
231 float new_cooking_time = item_to_cook.GetCookingTime() + COOKING_FOOD_TIME_INC_VALUE * cooking_time_coef;
232 item_to_cook.SetCookingTime(new_cooking_time);
233
234 //progress to next stage
235 if (item_to_cook.GetCookingTime() >= food_time_to_cook)
236 {
238 if (item_to_cook.GetFoodStageType() != new_stage_type)
239 {
240 item_to_cook.ChangeFoodStage(new_stage_type);
241
242 if (cooking_equipment && cooking_equipment != item_to_cook)
243 {
244 if (cooking_method == CookingMethodType.BAKING)
245 {
246 ItemBase lard = GetItemTypeFromCargo(COOKING_INGREDIENT_LARD, cooking_equipment);
247 if (lard)
248 {
249 //decrease lard quantity
250 float lardQuantity = lard.GetQuantity() - COOKING_LARD_DECREASE_COEF;
251 lardQuantity = Math.Clamp(lardQuantity, 0, lard.GetQuantityMax());
252 lard.SetQuantity(lardQuantity);
253 }
254 else
255 {
258 }
259 }
260 }
261 else
262 {
265 }
266 }
267
268 //reset cooking time
269 item_to_cook.ResetCookingTime();
270
271 return 1;
272 }
273 }
274 else
275 {
276 item_to_cook.MakeSoundsOnClient(false);
277 }
278
279 return 0;
280 }
static const float COOKING_FOOD_TIME_INC_VALUE
time modifier used when using support material
Определения Cooking.c:17
static const float COOKING_LARD_DECREASE_COEF
time increase when cooking a food
Определения Cooking.c:18
static const float COOKING_FOOD_QUANTITY_DECREASE_AMOUNT_NONE
how many units from quantity of lard are remove at each stage
Определения Cooking.c:19
CookingMethodType
Определения Cooking.c:2
COOKING_INGREDIENT_LARD
Определения Cooking.c:35
void DecreaseCookedItemQuantity(notnull Edible_Base pItem, float pAmount=0.0)
Определения Cooking.c:519
void AddTemperatureToItem(ItemBase cooked_item, ItemBase cooking_equipment, float min_temperature)
Определения Cooking.c:486
ItemBase GetItemTypeFromCargo(typename item_type, ItemBase cooking_equipment)
Cooking data.
Определения Cooking.c:410
FoodStageType
Определения FoodStage.c:2
void MakeSoundsOnClient(bool soundstate, CookingMethodType cookingMethod=CookingMethodType.NONE)
Определения Edible_Base.c:215
FoodStageType GetFoodStageType()
Определения Edible_Base.c:531
FoodStageType GetNextFoodStageType(CookingMethodType cooking_method)
Определения Edible_Base.c:603
float GetCookingTime()
Определения Edible_Base.c:657
void SetCookingTime(float time)
Определения Edible_Base.c:662
void ResetCookingTime()
Определения Edible_Base.c:670
void ChangeFoodStage(FoodStageType new_food_stage_type)
Определения Edible_Base.c:598
bool CanChangeToNewStage(CookingMethodType cooking_method)
Определения Edible_Base.c:613
override bool SetQuantity(float value, bool destroy_config=true, bool destroy_forced=false, bool allow_client=false, bool clamp_to_stack_max=true)
Определения PileOfWoodenPlanks.c:88
Определения InventoryItem.c:731
Определения EnMath.c:7
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.

Перекрестные ссылки AddTemperatureToItem(), Edible_Base::CanChangeToNewStage(), Edible_Base::ChangeFoodStage(), Math::Clamp(), COOKING_FOOD_QUANTITY_DECREASE_AMOUNT_NONE, COOKING_FOOD_TIME_INC_VALUE, COOKING_INGREDIENT_LARD, COOKING_LARD_DECREASE_COEF, DecreaseCookedItemQuantity(), Edible_Base::GetCookingTime(), Edible_Base::GetFoodStageType(), GetItemTypeFromCargo(), Edible_Base::GetNextFoodStageType(), Edible_Base::MakeSoundsOnClient(), Edible_Base::ResetCookingTime(), Edible_Base::SetCookingTime() и ItemBase::SetQuantity().

Используется в ProcessItemToCook().