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

◆ GetDebugText()

override string ReplaceEdibleWithNewLambda::GetDebugText ( )
protected

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

2131 : ItemBase
2132{
2133 const string DIRECT_COOKING_SLOT_NAME = "DirectCooking";
2134
2135 const string SOUND_BAKING_START = "Baking_SoundSet";
2136 const string SOUND_BAKING_DONE = "Baking_Done_SoundSet";
2137 const string SOUND_BOILING_START = "Boiling_SoundSet";
2138 const string SOUND_BOILING_DONE = "Boiling_Done_SoundSet";
2139 const string SOUND_DRYING_START = "Drying_SoundSet";
2140 const string SOUND_DRYING_DONE = "Drying_Done_SoundSet";
2141 const string SOUND_BURNING_DONE = "Food_Burning_SoundSet";
2142
2143 protected bool m_MakeCookingSounds;
2144 protected SoundOnVehicle m_SoundCooking;
2146 protected string m_SoundPlaying;
2147 ref FoodStage m_FoodStage;
2148 protected float m_DecayTimer;
2149 protected float m_DecayDelta = 0.0;
2152
2154
2155 void Edible_Base()
2156 {
2157 if (HasFoodStage())
2158 {
2159 m_FoodStage = new FoodStage(this);
2160
2161 RegisterNetSyncVariableInt("m_FoodStage.m_FoodStageType", FoodStageType.NONE, FoodStageType.COUNT);
2162 RegisterNetSyncVariableFloat("m_FoodStage.m_CookingTime", 0, 600, 0);
2163
2164 m_SoundPlaying = "";
2166 RegisterNetSyncVariableInt("m_CookedByMethod", CookingMethodType.NONE, CookingMethodType.COUNT);
2167 RegisterNetSyncVariableBool("m_MakeCookingSounds");
2168 }
2169 }
2170
2171 override void EEInit()
2172 {
2173 super.EEInit();
2174
2175 UpdateVisualsEx(true); //forced init visuals, mostly for debugs and SP
2176 }
2177
2178 override void EEDelete(EntityAI parent)
2179 {
2180 super.EEDelete(parent);
2181
2182 RemoveAudio();
2183
2185 m_HotVaporParticle.Stop();
2186 }
2187
2188 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
2189 {
2190 super.EEItemLocationChanged(oldLoc, newLoc);
2191
2193 if (oldLoc.GetType() == InventoryLocationType.ATTACHMENT || oldLoc.GetType() == InventoryLocationType.CARGO)
2194 {
2195 switch (oldLoc.GetParent().GetType())
2196 {
2197 case "FryingPan":
2198 case "Pot":
2199 case "Cauldron":
2200 case "SharpWoodenStick":
2201 MakeSoundsOnClient(false);
2202 break;
2203 }
2204
2206 if (oldLoc.GetSlot() > -1 && InventorySlots.GetSlotName(oldLoc.GetSlot()).Contains(DIRECT_COOKING_SLOT_NAME))
2207 {
2208 MakeSoundsOnClient(false);
2209 }
2210 }
2211
2212 if (oldLoc.IsValid())
2214
2215 if (CanHaveTemperature())
2217 }
2218
2219 void UpdateVisualsEx(bool forced = false)
2220 {
2221 if (GetFoodStage())
2222 GetFoodStage().UpdateVisualsEx(forced);
2223 }
2224
2225 bool Consume(float amount, PlayerBase consumer)
2226 {
2227 AddQuantity(-amount, false, false);
2228 OnConsume(amount, consumer);
2229
2230 return true;
2231 }
2232
2233 void OnConsume(float amount, PlayerBase consumer)
2234 {
2236 {
2237 consumer.ProcessDirectDamage(DamageType.CUSTOM, this, "", "EnviroDmg", "0 0 0", PlayerConstants.CONSUMPTION_DAMAGE_PER_BITE);
2238 }
2239 }
2240
2242 int FilterAgents(int agentsIn)
2243 {
2244 int foodStageType;
2245
2246 FoodStage foodStage = GetFoodStage();
2247 if (foodStage)
2248 foodStageType = foodStage.GetFoodStageType();
2249
2251 NutritionalProfile nutritionalProfile = GetNutritionalProfile(this, ClassName(), foodStageType);
2252 if ((agentsIn & eAgents.SALMONELLA == eAgents.SALMONELLA) && (nutritionalProfile.m_Agents == 0 || nutritionalProfile.m_AgentsPerDigest == 0))
2253 agentsIn &= ~eAgents.FOOD_POISON;
2254
2255 return agentsIn;
2256 }
2257
2258 //food staging
2259 override bool CanBeCooked()
2260 {
2261 return false;
2262 }
2263
2264 override bool CanBeCookedOnStick()
2265 {
2266 return false;
2267 }
2268
2269 override float GetTemperatureFreezeTime()
2270 {
2271 if (GetFoodStage())
2272 {
2273 switch (m_FoodStage.GetFoodStageType())
2274 {
2275 case FoodStageType.DRIED:
2276 return super.GetTemperatureFreezeTime() * GameConstants.TEMPERATURE_FREEZE_TIME_COEF_DRIED;
2277
2278 case FoodStageType.BURNED:
2279 return super.GetTemperatureFreezeTime() * GameConstants.TEMPERATURE_FREEZE_TIME_COEF_BURNED;
2280
2281 default:
2282 return super.GetTemperatureFreezeTime();
2283 }
2284 }
2285
2286 return super.GetTemperatureFreezeTime();
2287 }
2288
2289 override float GetTemperatureThawTime()
2290 {
2291 if (GetFoodStage())
2292 {
2293 switch (m_FoodStage.GetFoodStageType())
2294 {
2295 case FoodStageType.DRIED:
2296 return super.GetTemperatureThawTime() * GameConstants.TEMPERATURE_THAW_TIME_COEF_DRIED;
2297
2298 case FoodStageType.BURNED:
2299 return super.GetTemperatureThawTime() * GameConstants.TEMPERATURE_THAW_TIME_COEF_BURNED;
2300
2301 default:
2302 return super.GetTemperatureThawTime();
2303 }
2304 }
2305
2306 return super.GetTemperatureThawTime();
2307 }
2308
2309 override bool CanItemOverheat()
2310 {
2311 return super.CanItemOverheat() && (!GetFoodStage() || (IsFoodBurned() || !GetFoodStage().CanTransitionToFoodStageType(FoodStageType.BURNED))); //for foodstaged items - either is burned, or it can't get burned
2312 }
2313
2314 //================================================================
2315 // SYNCHRONIZATION
2316 //================================================================
2317 void Synchronize()
2318 {
2319 SetSynchDirty();
2320 }
2321
2322 override void OnVariablesSynchronized()
2323 {
2324 super.OnVariablesSynchronized();
2325
2326 //UpdateVisualsEx(); //performed on client only
2327
2328 //update audio
2330 {
2331 RefreshAudio();
2332 }
2333 else
2334 {
2335 RemoveAudio();
2336 }
2337
2338 if (CanHaveTemperature())
2340 }
2341
2342 //================================================================
2343 // AUDIO EFFECTS (WHEN ON DCS)
2344 //================================================================
2345 void MakeSoundsOnClient(bool soundstate, CookingMethodType cookingMethod = CookingMethodType.NONE)
2346 {
2347 m_MakeCookingSounds = soundstate;
2348 m_CookedByMethod = cookingMethod;
2349
2350 Synchronize();
2351 }
2352
2353 protected void RefreshAudio()
2354 {
2355 string soundName = "";
2356
2357 FoodStageType currentFoodStage = GetFoodStageType();
2359
2360 if (currentFoodStage == FoodStageType.BURNED)
2361 {
2362 soundName = SOUND_BURNING_DONE;
2363 }
2364 else
2365 {
2366 switch (m_CookedByMethod)
2367 {
2368 case CookingMethodType.BAKING:
2369 {
2370 if (nextFoodStage == FoodStageType.BAKED)
2371 soundName = SOUND_BAKING_START;
2372 else if (currentFoodStage == FoodStageType.BAKED)
2373 soundName = SOUND_BAKING_DONE;
2374 else
2375 soundName = "";
2376 break;
2377 }
2378
2379 case CookingMethodType.BOILING:
2380 {
2381 if (nextFoodStage == FoodStageType.BOILED)
2382 soundName = SOUND_BOILING_START;
2383 else if (currentFoodStage == FoodStageType.BOILED)
2384 soundName = SOUND_BOILING_DONE;
2385 else
2386 soundName = "";
2387 break;
2388 }
2389
2390 case CookingMethodType.DRYING:
2391 {
2392 if (nextFoodStage == FoodStageType.DRIED)
2393 soundName = SOUND_DRYING_START;
2394 else if (currentFoodStage == FoodStageType.DRIED)
2395 soundName = SOUND_DRYING_DONE;
2396 else
2397 soundName = "";
2398 break;
2399 }
2400
2401 default:
2402 soundName = "";
2403 break;
2404 }
2405
2406 if (nextFoodStage == FoodStageType.BURNED)
2407 {
2408 if (soundName == "") //on 'bad' transitions only, indicates bad outcome
2409 {
2410 soundName = SOUND_BURNING_DONE;
2411 }
2412 else // pre-emptive burning sounds replace regular ones
2413 {
2414 array<float> nextStageProperties = new array<float>();
2415 nextStageProperties = FoodStage.GetAllCookingPropertiesForStage(nextFoodStage, null, GetType());
2416 float nextStageTime = nextStageProperties.Get(eCookingPropertyIndices.COOK_TIME);
2417 float progress01 = GetCookingTime() / nextStageTime;
2418 if (progress01 > Cooking.BURNING_WARNING_THRESHOLD)
2419 {
2420 soundName = SOUND_BURNING_DONE;
2421 }
2422 }
2423 }
2424 }
2425
2426 SoundCookingStart(soundName);
2427 }
2428
2429 protected void RemoveAudio()
2430 {
2431 m_MakeCookingSounds = false;
2433 }
2434
2435 //================================================================
2436 // SERIALIZATION
2437 //================================================================
2438 override void OnStoreSave(ParamsWriteContext ctx)
2439 {
2440 super.OnStoreSave(ctx);
2441
2442 if (GetFoodStage())
2443 {
2444 GetFoodStage().OnStoreSave(ctx);
2445 }
2446
2447 // food decay
2448 ctx.Write(m_DecayTimer);
2450 }
2451
2452 override bool OnStoreLoad(ParamsReadContext ctx, int version)
2453 {
2454 if (!super.OnStoreLoad(ctx, version))
2455 return false;
2456
2457 if (GetFoodStage())
2458 {
2459 if (!GetFoodStage().OnStoreLoad(ctx, version))
2460 return false;
2461 }
2462
2463 if (version >= 115)
2464 {
2465 if (!ctx.Read(m_DecayTimer))
2466 {
2467 m_DecayTimer = 0.0;
2468 return false;
2469 }
2470 if (!ctx.Read(m_LastDecayStage))
2471 {
2473 return false;
2474 }
2475 }
2476
2477 UpdateVisualsEx(true); //forced init visuals
2478 Synchronize();
2479
2480 return true;
2481 }
2482
2483 override void AfterStoreLoad()
2484 {
2485 super.AfterStoreLoad();
2486
2487 Synchronize();
2488 }
2489
2490 //get food stage
2491 override FoodStage GetFoodStage()
2492 {
2493 return m_FoodStage;
2494 }
2495
2496 //food types
2497 override bool IsMeat()
2498 {
2499 return false;
2500 }
2501
2502 override bool IsCorpse()
2503 {
2504 return false;
2505 }
2506
2507 override bool IsFruit()
2508 {
2509 return false;
2510 }
2511
2512 override bool IsMushroom()
2513 {
2514 return false;
2515 }
2516
2517 //================================================================
2518 // NUTRITIONAL VALUES
2519 //================================================================
2520 //food properties
2521 static float GetFoodTotalVolume(ItemBase item, string classname = "", int food_stage = 0)
2522 {
2523 Edible_Base food_item = Edible_Base.Cast(item);
2524 if (food_item && food_item.GetFoodStage())
2525 {
2526 return FoodStage.GetFullnessIndex(food_item.GetFoodStage());
2527 }
2528 else if (classname != "" && food_stage)
2529 {
2530 return FoodStage.GetFullnessIndex(null, food_stage, classname);
2531 }
2532 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
2533 return GetGame().ConfigGetFloat( class_path + " fullnessIndex" );
2534
2535 }
2536
2537 static float GetFoodEnergy(ItemBase item, string classname = "", int food_stage = 0)
2538 {
2539 Edible_Base food_item = Edible_Base.Cast(item);
2540 if (food_item && food_item.GetFoodStage())
2541 {
2542 return FoodStage.GetEnergy(food_item.GetFoodStage());
2543 }
2544 else if (classname != "" && food_stage)
2545 {
2546 return FoodStage.GetEnergy(null, food_stage, classname);
2547 }
2548 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
2549 return GetGame().ConfigGetFloat( class_path + " energy" );
2550 }
2551
2552 static float GetFoodWater(ItemBase item, string classname = "", int food_stage = 0)
2553 {
2554 Edible_Base food_item = Edible_Base.Cast(item);
2555 if (food_item && food_item.GetFoodStage())
2556 {
2557 return FoodStage.GetWater(food_item.GetFoodStage());
2558 }
2559 else if (classname != "" && food_stage)
2560 {
2561 return FoodStage.GetWater(null, food_stage, classname);
2562 }
2563 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
2564 return GetGame().ConfigGetFloat( class_path + " water" );
2565 }
2566
2567 static float GetFoodNutritionalIndex(ItemBase item, string classname = "", int food_stage = 0)
2568 {
2569 Edible_Base food_item = Edible_Base.Cast(item);
2570 if (food_item && food_item.GetFoodStage())
2571 {
2572 return FoodStage.GetNutritionalIndex(food_item.GetFoodStage());
2573 }
2574 else if (classname != "" && food_stage)
2575 {
2576 return FoodStage.GetNutritionalIndex(null, food_stage, classname);
2577 }
2578 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
2579 return GetGame().ConfigGetFloat( class_path + " nutritionalIndex" );
2580
2581 }
2582
2583 static float GetFoodToxicity(ItemBase item, string classname = "", int food_stage = 0)
2584 {
2585 Edible_Base food_item = Edible_Base.Cast(item);
2586 if (food_item && food_item.GetFoodStage())
2587 {
2588 return FoodStage.GetToxicity(food_item.GetFoodStage());
2589 }
2590 else if (classname != "" && food_stage)
2591 {
2592 return FoodStage.GetToxicity(null, food_stage, classname);
2593 }
2594 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
2595 return GetGame().ConfigGetFloat( class_path + " toxicity" );
2596 }
2597
2598 static int GetFoodAgents(ItemBase item, string classname = "", int food_stage = 0)
2599 {
2600 Edible_Base food_item = Edible_Base.Cast(item);
2601 if (food_item && food_item.GetFoodStage())
2602 {
2603 return FoodStage.GetAgents(food_item.GetFoodStage());
2604 }
2605 else if (classname != "" && food_stage)
2606 {
2607 return FoodStage.GetAgents(null, food_stage, classname);
2608 }
2609 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
2610 return GetGame().ConfigGetInt( class_path + " agents" );
2611 }
2612
2613 static float GetFoodDigestibility(ItemBase item, string classname = "", int food_stage = 0)
2614 {
2615 Edible_Base food_item = Edible_Base.Cast(item);
2616 if (food_item && food_item.GetFoodStage())
2617 {
2618 return FoodStage.GetDigestibility(food_item.GetFoodStage());
2619 }
2620 else if (classname != "" && food_stage)
2621 {
2622 return FoodStage.GetDigestibility(null, food_stage, classname);
2623 }
2624 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
2625 return GetGame().ConfigGetInt( class_path + " digestibility" );
2626 }
2627
2628 static float GetAgentsPerDigest(ItemBase item, string className = "", int foodStage = 0)
2629 {
2630 Edible_Base foodItem = Edible_Base.Cast(item);
2631 if (foodItem && foodItem.GetFoodStage())
2632 {
2633 return FoodStage.GetAgentsPerDigest(foodItem.GetFoodStage());
2634 }
2635 else if (className != "" && foodStage)
2636 {
2637 return FoodStage.GetAgentsPerDigest(null, foodStage, className);
2638 }
2639 string classPath = string.Format("cfgVehicles %1 Nutrition", className);
2640 return GetGame().ConfigGetInt(classPath + " agentsPerDigest");
2641 }
2642
2643 static NutritionalProfile GetNutritionalProfile(ItemBase item, string classname = "", int food_stage = 0)
2644 {
2645 NutritionalProfile profile = new NutritionalProfile();
2646 profile.m_Energy = GetFoodEnergy(item, classname, food_stage);
2647 profile.m_WaterContent = GetFoodWater(item, classname, food_stage);
2648 profile.m_NutritionalIndex = GetFoodNutritionalIndex(item, classname, food_stage);
2649 profile.m_FullnessIndex = GetFoodTotalVolume(item, classname, food_stage);
2650 profile.m_Toxicity = GetFoodToxicity(item, classname, food_stage);
2651 profile.m_Agents = GetFoodAgents(item, classname, food_stage);
2652 profile.m_Digestibility = GetFoodDigestibility(item, classname, food_stage);
2653 profile.m_AgentsPerDigest = GetAgentsPerDigest(item, classname, food_stage);
2654
2655 return profile;
2656 }
2657
2658 //================================================================
2659 // FOOD STAGING
2660 //================================================================
2662 {
2663 return GetFoodStage().GetFoodStageType();
2664 }
2665
2666 //food stage states
2667 bool IsFoodRaw()
2668 {
2669 if ( GetFoodStage() )
2670 {
2671 return GetFoodStage().IsFoodRaw();
2672 }
2673
2674 return false;
2675 }
2676
2677 bool IsFoodBaked()
2678 {
2679 if ( GetFoodStage() )
2680 {
2681 return GetFoodStage().IsFoodBaked();
2682 }
2683
2684 return false;
2685 }
2686
2687 bool IsFoodBoiled()
2688 {
2689 if ( GetFoodStage() )
2690 {
2691 return GetFoodStage().IsFoodBoiled();
2692 }
2693
2694 return false;
2695 }
2696
2697 bool IsFoodDried()
2698 {
2699 if ( GetFoodStage() )
2700 {
2701 return GetFoodStage().IsFoodDried();
2702 }
2703
2704 return false;
2705 }
2706
2707 bool IsFoodBurned()
2708 {
2709 if ( GetFoodStage() )
2710 {
2711 return GetFoodStage().IsFoodBurned();
2712 }
2713
2714 return false;
2715 }
2716
2717 bool IsFoodRotten()
2718 {
2719 if ( GetFoodStage() )
2720 {
2721 return GetFoodStage().IsFoodRotten();
2722 }
2723
2724 return false;
2725 }
2726
2727 //food stage change
2728 void ChangeFoodStage( FoodStageType new_food_stage_type )
2729 {
2730 GetFoodStage().ChangeFoodStage( new_food_stage_type );
2731 }
2732
2734 {
2735 return GetFoodStage().GetNextFoodStageType( cooking_method );
2736 }
2737
2738 string GetFoodStageName( FoodStageType food_stage_type )
2739 {
2740 return GetFoodStage().GetFoodStageName( food_stage_type );
2741 }
2742
2743 bool CanChangeToNewStage( CookingMethodType cooking_method )
2744 {
2745 return GetFoodStage().CanChangeToNewStage( cooking_method );
2746 }
2747
2748 //Use this to receive food stage from another Edible_Base
2749 void TransferFoodStage( notnull Edible_Base source )
2750 {
2751 if ( !source.GetFoodStage())
2752 return;
2753 m_LastDecayStage = source.GetLastDecayStage();
2754 ChangeFoodStage(source.GetFoodStage().GetFoodStageType());
2755 m_DecayTimer = source.GetDecayTimer();
2756 m_DecayDelta = source.GetDecayDelta();
2757 }
2758
2760 void OnFoodStageChange(FoodStageType stageOld, FoodStageType stageNew)
2761 {
2762 HandleFoodStageChangeAgents(stageOld,stageNew);
2763 UpdateVisualsEx(); //performed on server only
2764 }
2765
2768 {
2769 switch (stageNew)
2770 {
2771 case FoodStageType.BAKED:
2772 case FoodStageType.BOILED:
2773 case FoodStageType.DRIED:
2774 RemoveAllAgentsExcept(eAgents.BRAIN|eAgents.HEAVYMETAL);
2775 break;
2776
2777 case FoodStageType.BURNED:
2778 RemoveAllAgentsExcept(eAgents.BRAIN|eAgents.HEAVYMETAL);
2779 break;
2780 }
2781 }
2782
2783 //================================================================
2784 // COOKING
2785 //================================================================
2786 //cooking time
2787 float GetCookingTime()
2788 {
2789 return GetFoodStage().GetCookingTime();
2790 }
2791
2792 void SetCookingTime( float time )
2793 {
2794 GetFoodStage().SetCookingTime( time );
2795
2796 //synchronize when calling on server
2797 Synchronize();
2798 }
2799
2800 void ResetCookingTime()
2801 {
2802 if (GetFoodStage())
2803 {
2804 GetFoodStage().SetCookingTime(0);
2805 Synchronize();
2806 }
2807 }
2808
2809 //replace edible with new item (opening cans)
2810 void ReplaceEdibleWithNew( string typeName )
2811 {
2812 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
2813 if (player)
2814 {
2815 ReplaceEdibleWithNewLambda lambda = new ReplaceEdibleWithNewLambda(this, typeName, player);
2816 player.ServerReplaceItemInHandsWithNew(lambda);
2817 }
2818 else
2819 Error("ReplaceEdibleWithNew - cannot use edible without player");
2820 }
2821
2823 {
2825 }
2826
2827 override void SetActions()
2828 {
2829 super.SetActions();
2830
2833 }
2834
2835 protected void SoundCookingStart(string sound_name)
2836 {
2837 #ifndef SERVER
2838 if (m_SoundPlaying != sound_name)
2839 {
2841
2842 m_SoundEffectCooking = SEffectManager.PlaySound(sound_name, GetPosition(), 0, 0, true);
2843 m_SoundPlaying = sound_name;
2844 }
2845 #endif
2846 }
2847
2848 protected void SoundCookingStop()
2849 {
2850 #ifndef SERVER
2852 {
2853 m_SoundEffectCooking.Stop();
2854 m_SoundEffectCooking = null;
2855 m_SoundPlaying = "";
2856 }
2857 #endif
2858 }
2859
2860 override bool CanDecay()
2861 {
2862 return false;
2863 }
2864
2865 override bool CanProcessDecay()
2866 {
2867 return !GetIsFrozen() && ( GetFoodStageType() != FoodStageType.ROTTEN );
2868 }
2869
2870 override void ProcessDecay( float delta, bool hasRootAsPlayer )
2871 {
2872 m_DecayDelta = 0.0;
2873
2874 delta *= DayZGame.Cast(GetGame()).GetFoodDecayModifier();
2875 m_DecayDelta += ( 1 + ( 1 - GetHealth01( "", "" ) ) );
2876 if ( hasRootAsPlayer )
2878
2879 /*Print( "-------------------------" );
2880 Print( this );
2881 Print( m_DecayTimer );
2882 Print( m_DecayDelta );
2883 Print( m_LastDecayStage );*/
2884
2885 if ( IsFruit() || IsMushroom() )
2886 {
2887 // fruit, vegetables and mushrooms
2889 {
2890 switch ( GetFoodStageType() )
2891 {
2892 case FoodStageType.RAW:
2895 break;
2896
2897 case FoodStageType.BOILED:
2900 break;
2901
2902 case FoodStageType.BAKED:
2905 break;
2906
2907 case FoodStageType.DRIED:
2908 case FoodStageType.BURNED:
2909 case FoodStageType.ROTTEN:
2910 default:
2911 m_DecayTimer = -1;
2913 return;
2914 }
2915
2916 //m_DecayTimer = m_DecayTimer / 1000.0;
2917 }
2918
2919 m_DecayTimer -= ( delta * m_DecayDelta );
2920
2921 if ( m_DecayTimer <= 0 )
2922 {
2923 if ( m_LastDecayStage != FoodStageType.NONE )
2924 {
2925 // switch to decayed stage
2926 if ( ( m_LastDecayStage == FoodStageType.BOILED ) || ( m_LastDecayStage == FoodStageType.BAKED ) )
2927 {
2929 }
2930 if ( m_LastDecayStage == FoodStageType.RAW )
2931 {
2932 int rng = Math.RandomIntInclusive( 0, 100 );
2934 {
2936 }
2937 else
2938 {
2939 if ( CanChangeToNewStage( FoodStageType.DRIED ) )
2940 {
2942 }
2943 else
2944 {
2946 }
2947 }
2948 }
2949 }
2950 }
2951
2952 }
2953 else if ( IsMeat() )
2954 {
2955 // meat
2957 {
2958 switch ( GetFoodStageType() )
2959 {
2960 case FoodStageType.RAW:
2963 break;
2964
2965 case FoodStageType.BOILED:
2968 break;
2969
2970 case FoodStageType.BAKED:
2973 break;
2974
2975 case FoodStageType.DRIED:
2978 break;
2979
2980 case FoodStageType.BURNED:
2981 case FoodStageType.ROTTEN:
2982 default:
2983 m_DecayTimer = -1;
2985 return;
2986 }
2987 }
2988
2989 m_DecayTimer -= ( delta * m_DecayDelta );
2990
2991 if ( m_DecayTimer <= 0 )
2992 {
2993 if ( m_LastDecayStage != FoodStageType.NONE )
2994 {
2995 // switch to decayed stage
2996 if ( ( m_LastDecayStage == FoodStageType.DRIED ) || ( m_LastDecayStage == FoodStageType.RAW ) || ( m_LastDecayStage == FoodStageType.BOILED ) || ( m_LastDecayStage == FoodStageType.BAKED ) )
2997 {
2999 }
3000 }
3001 }
3002 }
3003 else if ( IsCorpse() )
3004 {
3005 // corpse
3007 {
3008 switch ( GetFoodStageType() )
3009 {
3010 case FoodStageType.RAW:
3013 break;
3014
3015 case FoodStageType.BURNED:
3016 case FoodStageType.ROTTEN:
3017 default:
3018 m_DecayTimer = -1;
3020 return;
3021 }
3022 }
3023
3024 m_DecayTimer -= ( delta * m_DecayDelta );
3025
3026 if ( m_DecayTimer <= 0 )
3027 {
3028 if ( m_LastDecayStage != FoodStageType.NONE )
3029 {
3030 // switch to decayed stage
3031 if ( ( m_LastDecayStage == FoodStageType.DRIED ) || ( m_LastDecayStage == FoodStageType.RAW ) || ( m_LastDecayStage == FoodStageType.BOILED ) || ( m_LastDecayStage == FoodStageType.BAKED ) )
3032 {
3034 }
3035 }
3036 }
3037 }
3038 else
3039 {
3040 // opened cans
3041 m_DecayTimer -= ( delta * m_DecayDelta );
3042
3043 if ( ( m_DecayTimer <= 0 ) && ( m_LastDecayStage == FoodStageType.NONE ) )
3044 {
3047 //m_DecayTimer = m_DecayTimer / 1000.0;
3048 }
3049 else
3050 {
3051 if ( m_DecayTimer <= 0 )
3052 {
3053 InsertAgent(eAgents.FOOD_POISON, 1);
3054 m_DecayTimer = -1;
3055 }
3056 }
3057 }
3058 }
3059
3060 protected void UpdateVaporParticle()
3061 {
3062 if (GetGame().IsDedicatedServer())
3063 return;
3064
3065 if (m_VarTemperature >= GameConstants.STATE_HOT_LVL_TWO && !m_HotVaporParticle)
3066 {
3067 InventoryLocation invLoc = new InventoryLocation();
3068 GetInventory().GetCurrentInventoryLocation(invLoc);
3069 if (invLoc && (invLoc.GetType() == InventoryLocationType.GROUND || invLoc.GetType() == InventoryLocationType.HANDS || invLoc.GetType() == InventoryLocationType.ATTACHMENT))
3070 {
3071 ParticleManager ptcMgr = ParticleManager.GetInstance();
3072 if (ptcMgr)
3073 {
3074 m_HotVaporParticle = ParticleManager.GetInstance().PlayOnObject(ParticleList.ITEM_HOT_VAPOR, this);
3075 m_HotVaporParticle.SetParticleParam(EmitorParam.SIZE, 0.3);
3076 m_HotVaporParticle.SetParticleParam(EmitorParam.BIRTH_RATE, 10);
3077 m_HotVaporParticle.SetParticleAutoDestroyFlags(ParticleAutoDestroyFlags.ON_STOP);
3078 }
3079 }
3080 }
3081 else if (m_HotVaporParticle)
3082 {
3083 if (m_VarTemperature <= GameConstants.STATE_HOT_LVL_TWO)
3084 {
3085 m_HotVaporParticle.Stop();
3086 m_HotVaporParticle = null;
3087 return;
3088 }
3089
3090 InventoryLocation inventoryLoc = new InventoryLocation();
3091 GetInventory().GetCurrentInventoryLocation(inventoryLoc);
3092 if (invLoc && (invLoc.GetType() != InventoryLocationType.GROUND && invLoc.GetType() != InventoryLocationType.HANDS))
3093 {
3094 m_HotVaporParticle.Stop();
3095 m_HotVaporParticle = null;
3096 }
3097 }
3098 }
3099
3100 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
3101 {
3102 if (GetFoodStage())
3103 {
3104 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FOOD_NUTRITIONS_DATA, "Food Nutritions Data", FadeColors.WHITE));
3105 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FOOD_STAGE_PREV, "Food Stage Prev", FadeColors.WHITE));
3106 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FOOD_STAGE_NEXT, "Food Stage Next", FadeColors.WHITE));
3107 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
3108 }
3109
3110 super.GetDebugActions(outputList);
3111 }
3112
3113 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
3114 {
3115 super.OnAction(action_id, player, ctx);
3116
3117 if ( GetGame().IsServer() )
3118 {
3119 if ( action_id == EActions.FOOD_STAGE_PREV )
3120 {
3121 int food_stage_prev = GetFoodStageType() - 1;
3122 if (food_stage_prev <= 0)
3123 {
3124 food_stage_prev = FoodStageType.COUNT - 1;
3125 }
3126 ChangeFoodStage(food_stage_prev);
3127 return true;
3128 }
3129 else if ( action_id == EActions.FOOD_STAGE_NEXT )
3130 {
3131 int food_stage_next = GetFoodStageType() + 1;
3132 if (food_stage_next >= FoodStageType.COUNT )
3133 {
3134 food_stage_next = FoodStageType.RAW;
3135 }
3136 ChangeFoodStage(food_stage_next);
3137 return true;
3138 }
3139
3140 }
3141
3142 #ifdef DIAG_DEVELOPER
3143 if (action_id == EActions.FOOD_NUTRITIONS_DATA)
3144 {
3145 PrintNutritionsData();
3146 return true;
3147 }
3148 #endif
3149
3150 return false;
3151 }
3152
3153 override string GetDebugText()
3154 {
3155 string debug_output;
3156
3157 debug_output = super.GetDebugText();
3158
3159 debug_output+="m_CookedByMethod:"+m_CookedByMethod+"\n";
3160 debug_output+="m_MakeCookingSounds:"+m_MakeCookingSounds+"\n";
3161
3162 return debug_output;
3163 }
3164
3165 //================================================================
3166 // GENERAL GETTERS
3167 //================================================================
3168
3169 override float GetBaitEffectivity()
3170 {
3171 float ret = super.GetBaitEffectivity();
3172
3173 if (IsFoodRotten())
3174 {
3175 ret *= 0.5;
3176 }
3177
3178 return ret;
3179 }
3180
3181 float GetDecayTimer()
3182 {
3183 return m_DecayTimer;
3184 }
3185
3186 float GetDecayDelta()
3187 {
3188 return m_DecayDelta;
3189 }
3190
3192 {
3193 return m_LastDecayStage;
3194 }
3195
3196 #ifdef DIAG_DEVELOPER
3197 private void PrintNutritionsData()
3198 {
3199 string nutritionsData = "";
3200
3201 FoodStage stage = GetFoodStage();
3202 FoodStageType stageType = stage.GetFoodStageType();
3203
3204 NutritionalProfile profile = GetNutritionalProfile(this, ClassName(), stageType);
3205 if (profile)
3206 {
3207 nutritionsData = string.Format("Item: %1\n\n", this);
3208 nutritionsData += string.Format("Stage name: %1\n", GetFoodStageName(stageType));
3209 nutritionsData += string.Format("Energy: %1\n", profile.m_Energy);
3210 nutritionsData += string.Format("Water content: %1\n", profile.m_WaterContent);
3211 nutritionsData += string.Format("Nutritional index: %1\n", profile.m_NutritionalIndex);
3212 nutritionsData += string.Format("Fullness index: %1\n", profile.m_FullnessIndex);
3213 nutritionsData += string.Format("Toxicity (obsolete): %1\n", profile.m_Toxicity);
3214 nutritionsData += string.Format("Digestibility: %1\n", profile.m_Digestibility);
3215
3216 if (profile.IsLiquid())
3217 nutritionsData += string.Format("Liquid type: %1\n", profile.m_LiquidClassname);
3218
3219 nutritionsData += string.Format("Agents: %1\n", profile.m_Agents);
3220 nutritionsData += string.Format("Agents per consume: %1\n", profile.m_AgentsPerDigest);
3221 }
3222
3223 nutritionsData += "-----\n";
3224
3225 Debug.Log(nutritionsData);
3226 }
3227 #endif
3228
3230 //DEPRECATED
3232 void UpdateVisuals()
3233 {
3235 }
3236}
3237
3239{
3240 void ReplaceEdibleWithNewLambda(EntityAI old_item, string new_item_type, PlayerBase player) { }
3241};
Param4< int, int, string, int > TSelectableActionInfoWithColor
Определения 3_Game/Entities/EntityAI.c:97
class LogManager EntityAI
eBleedingSourceType GetType()
AttachActionData ActionData ActionAttach()
Определения ActionAttach.c:9
void ActionDetach()
Определения ActionDetach.c:10
void AddAction(typename actionName)
Определения AdvancedCommunication.c:220
CookingMethodType
Определения Cooking.c:2
DamageType
exposed from C++ (do not change)
Определения DamageSystem.c:11
AbstractWave m_SoundPlaying
Определения DynamicMusicPlayer.c:118
EActions
Определения EActions.c:2
eAgents
Определения EAgents.c:3
EConsumptionPenaltyContext
Определения EConsumptionPenaltyContext.c:2
void ReplaceEdibleWithNew(string typeName)
Определения Edible_Base.c:1788
ref FoodStage m_FoodStage
Определения Edible_Base.c:1125
bool IsFoodRotten()
Определения Edible_Base.c:1695
static float GetFoodWater(ItemBase item, string classname="", int food_stage=0)
Определения Edible_Base.c:1530
override bool CanBeCooked()
Определения Edible_Base.c:1237
bool IsFoodBaked()
Определения Edible_Base.c:1655
override string GetDebugText()
Определения Edible_Base.c:2131
override void AfterStoreLoad()
Определения Edible_Base.c:1461
void Edible_Base()
Определения Edible_Base.c:1133
void OnFoodStageChange(FoodStageType stageOld, FoodStageType stageNew)
called on server
Определения Edible_Base.c:1738
float m_DecayDelta
Определения Edible_Base.c:1127
void Synchronize()
Определения Edible_Base.c:1295
override void OnVariablesSynchronized()
Определения Edible_Base.c:1300
const string SOUND_BURNING_DONE
Определения Edible_Base.c:1119
bool CanChangeToNewStage(CookingMethodType cooking_method)
Определения Edible_Base.c:1721
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
Определения Edible_Base.c:2091
void RemoveAudio()
Определения Edible_Base.c:1407
override bool CanItemOverheat()
Определения Edible_Base.c:1287
float GetDecayDelta()
Определения Edible_Base.c:2164
override float GetBaitEffectivity()
Определения Edible_Base.c:2147
override FoodStage GetFoodStage()
Определения Edible_Base.c:1469
override void SetActions()
Определения Edible_Base.c:1805
bool m_MakeCookingSounds
Определения Edible_Base.c:1121
override float GetTemperatureFreezeTime()
Определения Edible_Base.c:1247
void SoundCookingStop()
Определения Edible_Base.c:1826
const string DIRECT_COOKING_SLOT_NAME
Определения Edible_Base.c:1111
FoodStageType GetNextFoodStageType(CookingMethodType cooking_method)
Определения Edible_Base.c:1711
void ChangeFoodStage(FoodStageType new_food_stage_type)
Определения Edible_Base.c:1706
void OnConsume(float amount, PlayerBase consumer)
Определения Edible_Base.c:1211
static float GetFoodNutritionalIndex(ItemBase item, string classname="", int food_stage=0)
Определения Edible_Base.c:1545
SoundOnVehicle m_SoundCooking
Определения Edible_Base.c:1122
static float GetFoodToxicity(ItemBase item, string classname="", int food_stage=0)
Определения Edible_Base.c:1561
override bool CanDecay()
Определения Edible_Base.c:1838
void UpdateVisualsEx(bool forced=false)
Определения Edible_Base.c:1197
const string SOUND_BAKING_DONE
Определения Edible_Base.c:1114
static NutritionalProfile GetNutritionalProfile(ItemBase item, string classname="", int food_stage=0)
Определения Edible_Base.c:1621
int FilterAgents(int agentsIn)
Filter agents from the item (override on higher implementations)
Определения Edible_Base.c:1220
override void EEDelete(EntityAI parent)
Определения Edible_Base.c:1156
FoodStageType m_LastDecayStage
Определения Edible_Base.c:1128
float GetCookingTime()
Определения Edible_Base.c:1765
override bool CanBeCookedOnStick()
Определения Edible_Base.c:1242
override bool IsCorpse()
Определения Edible_Base.c:1480
void UpdateVisuals()
Определения Edible_Base.c:2210
float GetDecayTimer()
Определения Edible_Base.c:2159
FoodStageType GetLastDecayStage()
Определения Edible_Base.c:2169
string GetFoodStageName(FoodStageType food_stage_type)
Определения Edible_Base.c:1716
override float GetTemperatureThawTime()
Определения Edible_Base.c:1267
void UpdateVaporParticle()
Определения Edible_Base.c:2038
static float GetFoodDigestibility(ItemBase item, string classname="", int food_stage=0)
Определения Edible_Base.c:1591
void TransferFoodStage(notnull Edible_Base source)
Определения Edible_Base.c:1727
override void ProcessDecay(float delta, bool hasRootAsPlayer)
Определения Edible_Base.c:1848
const string SOUND_DRYING_START
Определения Edible_Base.c:1117
void SetCookingTime(float time)
Определения Edible_Base.c:1770
void SoundCookingStart(string sound_name)
Определения Edible_Base.c:1813
override bool IsMeat()
Определения Edible_Base.c:1475
const string SOUND_BAKING_START
Определения Edible_Base.c:1113
static float GetFoodTotalVolume(ItemBase item, string classname="", int food_stage=0)
Определения Edible_Base.c:1499
const string SOUND_DRYING_DONE
Определения Edible_Base.c:1118
void HandleFoodStageChangeAgents(FoodStageType stageOld, FoodStageType stageNew)
removes select agents on foodstage transitions
Определения Edible_Base.c:1745
void ResetCookingTime()
Определения Edible_Base.c:1778
override bool IsFruit()
Определения Edible_Base.c:1485
Edible_Base ItemBase ReplaceEdibleWithNewLambda(EntityAI old_item, string new_item_type, PlayerBase player)
Определения Edible_Base.c:1110
bool Consume(float amount, PlayerBase consumer)
Определения Edible_Base.c:1203
EffectSound m_SoundEffectCooking
DEPRECATED.
Определения Edible_Base.c:1123
override bool OnStoreLoad(ParamsReadContext ctx, int version)
Определения Edible_Base.c:1430
FoodStageType GetFoodStageType()
Определения Edible_Base.c:1639
override bool CanProcessDecay()
Определения Edible_Base.c:1843
ParticleSource m_HotVaporParticle
Определения Edible_Base.c:1129
void MakeSoundsOnClient(bool soundstate, CookingMethodType cookingMethod=CookingMethodType.NONE)
Определения Edible_Base.c:1323
static int GetFoodAgents(ItemBase item, string classname="", int food_stage=0)
Определения Edible_Base.c:1576
override bool IsMushroom()
Определения Edible_Base.c:1490
static float GetFoodEnergy(ItemBase item, string classname="", int food_stage=0)
Определения Edible_Base.c:1515
static float GetAgentsPerDigest(ItemBase item, string className="", int foodStage=0)
Определения Edible_Base.c:1606
void RefreshAudio()
Определения Edible_Base.c:1331
const string SOUND_BOILING_DONE
Определения Edible_Base.c:1116
int GetConsumptionPenaltyContext()
Определения Edible_Base.c:1800
const string SOUND_BOILING_START
Определения Edible_Base.c:1115
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Определения Edible_Base.c:2078
CookingMethodType m_CookedByMethod
Определения Edible_Base.c:1131
bool IsFoodDried()
Определения Edible_Base.c:1675
override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Определения Edible_Base.c:1166
override void OnStoreSave(ParamsWriteContext ctx)
Определения Edible_Base.c:1416
bool IsFoodRaw()
Определения Edible_Base.c:1645
bool IsFoodBurned()
Определения Edible_Base.c:1685
override void EEInit()
Определения Edible_Base.c:1149
bool IsFoodBoiled()
Определения Edible_Base.c:1665
float m_DecayTimer
Определения Edible_Base.c:1126
float GetTemperature()
Определения Environment.c:497
override bool CanHaveTemperature()
Определения FireplaceBase.c:559
FoodStageType
Определения FoodStage.c:2
InventoryLocationType
types of Inventory Location
Определения InventoryLocation.c:4
override void InsertAgent(int agent, float count=1)
Определения ItemBase.c:8795
override void RemoveAllAgentsExcept(int agent_to_keep)
Определения ItemBase.c:8790
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...
Определения ItemBase.c:8202
bool HasFoodStage()
Определения ItemBase.c:7466
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
Определения ParticleManager.c:88
ParticleAutoDestroyFlags
Flags to pass to ParticleSource.SetParticleAutoDestroyFlags.
Определения ParticleSource.c:3
proto native float ConfigGetFloat(string path)
Get float value from config on path.
proto native int ConfigGetInt(string path)
Get int value from config on path.
static void Log(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message with normal prio.
Определения 3_Game/tools/Debug.c:122
Определения 3_Game/tools/Debug.c:2
override FoodStage GetFoodStage()
Определения Edible_Base.c:361
Определения Edible_Base.c:2
Wrapper class for managing sound through SEffectManager.
Определения EffectSound.c:5
proto native int GetType()
returns type of InventoryLocation
InventoryLocation.
Определения InventoryLocation.c:29
static proto native owned string GetSlotName(int id)
converts slot_id to string
provides access to slot configuration
Определения InventorySlots.c:6
override void EEInit()
Определения BarbedWire.c:41
Определения EnMath.c:7
float m_Digestibility
Определения NutritionalProfile.c:11
bool IsLiquid()
Определения NutritionalProfile.c:47
float m_WaterContent
Определения NutritionalProfile.c:4
string m_LiquidClassname
Определения NutritionalProfile.c:10
float m_FullnessIndex
Определения NutritionalProfile.c:6
float m_Toxicity
Определения NutritionalProfile.c:7
float m_Energy
Определения NutritionalProfile.c:3
int m_Agents
Определения NutritionalProfile.c:9
float m_AgentsPerDigest
Определения NutritionalProfile.c:12
float m_NutritionalIndex
Определения NutritionalProfile.c:5
static const int ITEM_HOT_VAPOR
Определения ParticleList.c:71
Определения ParticleList.c:12
Entity which has the particle instance as an ObjectComponent.
Определения ParticleSource.c:124
Определения PlayerBaseClient.c:2
static const float CONSUMPTION_DAMAGE_PER_BITE
Определения PlayerConstants.c:145
static const float CONSUMPTION_DAMAGE_TEMP_THRESHOLD
Определения PlayerConstants.c:146
Определения PlayerConstants.c:2
static EffectSound PlaySound(string sound_set, vector position, float play_fade_in=0, float stop_fade_out=0, bool loop=false)
Create and play an EffectSound.
Определения EffectManager.c:169
Manager class for managing Effect (EffectParticle, EffectSound)
Определения EffectManager.c:6
proto bool Write(void value_out)
proto bool Read(void value_in)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Serializer ParamsReadContext
Определения gameplay.c:15
proto native CGame GetGame()
Serializer ParamsWriteContext
Определения gameplay.c:16
void Error(string err)
Messagebox with error message.
Определения EnDebug.c:90
const float DECAY_FOOD_BAKED_FRVG
Определения 3_Game/constants.c:1040
const float DECAY_FOOD_CAN_OPEN
Определения 3_Game/constants.c:1042
const float DECAY_FOOD_RAW_FRVG
Определения 3_Game/constants.c:1036
const int DECAY_TIMER_RANDOM_PERCENTAGE
Определения 3_Game/constants.c:1044
const int DECAY_FOOD_FRVG_DRIED_CHANCE
Определения 3_Game/constants.c:1043
const float DECAY_FOOD_RAW_MEAT
Определения 3_Game/constants.c:1034
const float DECAY_FOOD_BAKED_MEAT
Определения 3_Game/constants.c:1039
const float DECAY_FOOD_BOILED_MEAT
Определения 3_Game/constants.c:1037
const float DECAY_FOOD_BOILED_FRVG
Определения 3_Game/constants.c:1038
const float DECAY_FOOD_DRIED_MEAT
Определения 3_Game/constants.c:1041
const float DECAY_FOOD_RAW_CORPSE
Определения 3_Game/constants.c:1035
const float DECAY_RATE_ON_PLAYER
Определения 3_Game/constants.c:1045
static const float TEMPERATURE_THAW_TIME_COEF_BURNED
Определения 3_Game/constants.c:937
static const float TEMPERATURE_FREEZE_TIME_COEF_BURNED
Определения 3_Game/constants.c:936
static const float TEMPERATURE_THAW_TIME_COEF_DRIED
Определения 3_Game/constants.c:938
static const float TEMPERATURE_FREEZE_TIME_COEF_DRIED
Определения 3_Game/constants.c:935
const int STATE_HOT_LVL_TWO
Определения 3_Game/constants.c:886
static float RandomFloat01()
Returns a random float number between and min [inclusive] and max [inclusive].
Определения EnMath.c:126
static int RandomIntInclusive(int min, int max)
Returns a random int number between and min [inclusive] and max [inclusive].
Определения EnMath.c:54
EmitorParam
Определения EnVisual.c:114
const int SAT_DEBUG_ACTION
Определения 3_Game/constants.c:454
class JsonUndergroundAreaTriggerData GetPosition
Определения UndergroundAreaLoader.c:9
bool Contains(string sample)
Returns true if sample is substring of string.
Определения EnString.c:286
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.