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

◆ GetDebugText()

override string ReplaceEdibleWithNewLambda::GetDebugText ( )
protected

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

2129 : ItemBase
2130{
2131 const string DIRECT_COOKING_SLOT_NAME = "DirectCooking";
2132
2133 const string SOUND_BAKING_START = "Baking_SoundSet";
2134 const string SOUND_BAKING_DONE = "Baking_Done_SoundSet";
2135 const string SOUND_BOILING_START = "Boiling_SoundSet";
2136 const string SOUND_BOILING_DONE = "Boiling_Done_SoundSet";
2137 const string SOUND_DRYING_START = "Drying_SoundSet";
2138 const string SOUND_DRYING_DONE = "Drying_Done_SoundSet";
2139 const string SOUND_BURNING_DONE = "Food_Burning_SoundSet";
2140
2141 protected bool m_MakeCookingSounds;
2142 protected SoundOnVehicle m_SoundCooking;
2144 protected string m_SoundPlaying;
2145 ref FoodStage m_FoodStage;
2146 protected float m_DecayTimer;
2147 protected float m_DecayDelta = 0.0;
2150
2152
2153 void Edible_Base()
2154 {
2155 if (HasFoodStage())
2156 {
2157 m_FoodStage = new FoodStage(this);
2158
2159 RegisterNetSyncVariableInt("m_FoodStage.m_FoodStageType", FoodStageType.NONE, FoodStageType.COUNT);
2160 RegisterNetSyncVariableFloat("m_FoodStage.m_CookingTime", 0, 600, 0);
2161
2162 m_SoundPlaying = "";
2164 RegisterNetSyncVariableInt("m_CookedByMethod", CookingMethodType.NONE, CookingMethodType.COUNT);
2165 RegisterNetSyncVariableBool("m_MakeCookingSounds");
2166 }
2167 }
2168
2169 override void EEInit()
2170 {
2171 super.EEInit();
2172
2173 UpdateVisualsEx(true); //forced init visuals, mostly for debugs and SP
2174 }
2175
2176 override void EEDelete(EntityAI parent)
2177 {
2178 super.EEDelete(parent);
2179
2180 RemoveAudio();
2181
2183 m_HotVaporParticle.Stop();
2184 }
2185
2186 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
2187 {
2188 super.EEItemLocationChanged(oldLoc, newLoc);
2189
2191 if (oldLoc.GetType() == InventoryLocationType.ATTACHMENT || oldLoc.GetType() == InventoryLocationType.CARGO)
2192 {
2193 switch (oldLoc.GetParent().GetType())
2194 {
2195 case "FryingPan":
2196 case "Pot":
2197 case "Cauldron":
2198 case "SharpWoodenStick":
2199 MakeSoundsOnClient(false);
2200 break;
2201 }
2202
2204 if (oldLoc.GetSlot() > -1 && InventorySlots.GetSlotName(oldLoc.GetSlot()).Contains(DIRECT_COOKING_SLOT_NAME))
2205 {
2206 MakeSoundsOnClient(false);
2207 }
2208 }
2209
2210 if (oldLoc.IsValid())
2212
2213 if (CanHaveTemperature())
2215 }
2216
2217 void UpdateVisualsEx(bool forced = false)
2218 {
2219 if (GetFoodStage())
2220 GetFoodStage().UpdateVisualsEx(forced);
2221 }
2222
2223 bool Consume(float amount, PlayerBase consumer)
2224 {
2225 AddQuantity(-amount, false, false);
2226 OnConsume(amount, consumer);
2227
2228 return true;
2229 }
2230
2231 void OnConsume(float amount, PlayerBase consumer)
2232 {
2234 {
2235 consumer.ProcessDirectDamage(DamageType.CUSTOM, this, "", "EnviroDmg", "0 0 0", PlayerConstants.CONSUMPTION_DAMAGE_PER_BITE);
2236 }
2237 }
2238
2240 int FilterAgents(int agentsIn)
2241 {
2242 int foodStageType;
2243
2244 FoodStage foodStage = GetFoodStage();
2245 if (foodStage)
2246 foodStageType = foodStage.GetFoodStageType();
2247
2249 NutritionalProfile nutritionalProfile = GetNutritionalProfile(this, ClassName(), foodStageType);
2250 if ((agentsIn & eAgents.SALMONELLA == eAgents.SALMONELLA) && (nutritionalProfile.m_Agents == 0 || nutritionalProfile.m_AgentsPerDigest == 0))
2251 agentsIn &= ~eAgents.FOOD_POISON;
2252
2253 return agentsIn;
2254 }
2255
2256 //food staging
2257 override bool CanBeCooked()
2258 {
2259 return false;
2260 }
2261
2262 override bool CanBeCookedOnStick()
2263 {
2264 return false;
2265 }
2266
2267 override float GetTemperatureFreezeTime()
2268 {
2269 if (GetFoodStage())
2270 {
2271 switch (m_FoodStage.GetFoodStageType())
2272 {
2273 case FoodStageType.DRIED:
2274 return super.GetTemperatureFreezeTime() * GameConstants.TEMPERATURE_FREEZE_TIME_COEF_DRIED;
2275
2276 case FoodStageType.BURNED:
2277 return super.GetTemperatureFreezeTime() * GameConstants.TEMPERATURE_FREEZE_TIME_COEF_BURNED;
2278
2279 default:
2280 return super.GetTemperatureFreezeTime();
2281 }
2282 }
2283
2284 return super.GetTemperatureFreezeTime();
2285 }
2286
2287 override float GetTemperatureThawTime()
2288 {
2289 if (GetFoodStage())
2290 {
2291 switch (m_FoodStage.GetFoodStageType())
2292 {
2293 case FoodStageType.DRIED:
2294 return super.GetTemperatureThawTime() * GameConstants.TEMPERATURE_THAW_TIME_COEF_DRIED;
2295
2296 case FoodStageType.BURNED:
2297 return super.GetTemperatureThawTime() * GameConstants.TEMPERATURE_THAW_TIME_COEF_BURNED;
2298
2299 default:
2300 return super.GetTemperatureThawTime();
2301 }
2302 }
2303
2304 return super.GetTemperatureThawTime();
2305 }
2306
2307 override bool CanItemOverheat()
2308 {
2309 return super.CanItemOverheat() && (!GetFoodStage() || (IsFoodBurned() || !GetFoodStage().CanTransitionToFoodStageType(FoodStageType.BURNED))); //for foodstaged items - either is burned, or it can't get burned
2310 }
2311
2312 //================================================================
2313 // SYNCHRONIZATION
2314 //================================================================
2315 void Synchronize()
2316 {
2317 SetSynchDirty();
2318 }
2319
2320 override void OnVariablesSynchronized()
2321 {
2322 super.OnVariablesSynchronized();
2323
2324 //UpdateVisualsEx(); //performed on client only
2325
2326 //update audio
2328 {
2329 RefreshAudio();
2330 }
2331 else
2332 {
2333 RemoveAudio();
2334 }
2335
2336 if (CanHaveTemperature())
2338 }
2339
2340 //================================================================
2341 // AUDIO EFFECTS (WHEN ON DCS)
2342 //================================================================
2343 void MakeSoundsOnClient(bool soundstate, CookingMethodType cookingMethod = CookingMethodType.NONE)
2344 {
2345 m_MakeCookingSounds = soundstate;
2346 m_CookedByMethod = cookingMethod;
2347
2348 Synchronize();
2349 }
2350
2351 protected void RefreshAudio()
2352 {
2353 string soundName = "";
2354
2355 FoodStageType currentFoodStage = GetFoodStageType();
2357
2358 if (currentFoodStage == FoodStageType.BURNED)
2359 {
2360 soundName = SOUND_BURNING_DONE;
2361 }
2362 else
2363 {
2364 switch (m_CookedByMethod)
2365 {
2366 case CookingMethodType.BAKING:
2367 {
2368 if (nextFoodStage == FoodStageType.BAKED)
2369 soundName = SOUND_BAKING_START;
2370 else if (currentFoodStage == FoodStageType.BAKED)
2371 soundName = SOUND_BAKING_DONE;
2372 else
2373 soundName = "";
2374 break;
2375 }
2376
2377 case CookingMethodType.BOILING:
2378 {
2379 if (nextFoodStage == FoodStageType.BOILED)
2380 soundName = SOUND_BOILING_START;
2381 else if (currentFoodStage == FoodStageType.BOILED)
2382 soundName = SOUND_BOILING_DONE;
2383 else
2384 soundName = "";
2385 break;
2386 }
2387
2388 case CookingMethodType.DRYING:
2389 {
2390 if (nextFoodStage == FoodStageType.DRIED)
2391 soundName = SOUND_DRYING_START;
2392 else if (currentFoodStage == FoodStageType.DRIED)
2393 soundName = SOUND_DRYING_DONE;
2394 else
2395 soundName = "";
2396 break;
2397 }
2398
2399 default:
2400 soundName = "";
2401 break;
2402 }
2403
2404 if (nextFoodStage == FoodStageType.BURNED)
2405 {
2406 if (soundName == "") //on 'bad' transitions only, indicates bad outcome
2407 {
2408 soundName = SOUND_BURNING_DONE;
2409 }
2410 else // pre-emptive burning sounds replace regular ones
2411 {
2412 array<float> nextStageProperties = new array<float>();
2413 nextStageProperties = FoodStage.GetAllCookingPropertiesForStage(nextFoodStage, null, GetType());
2414 float nextStageTime = nextStageProperties.Get(eCookingPropertyIndices.COOK_TIME);
2415 float progress01 = GetCookingTime() / nextStageTime;
2416 if (progress01 > Cooking.BURNING_WARNING_THRESHOLD)
2417 {
2418 soundName = SOUND_BURNING_DONE;
2419 }
2420 }
2421 }
2422 }
2423
2424 SoundCookingStart(soundName);
2425 }
2426
2427 protected void RemoveAudio()
2428 {
2429 m_MakeCookingSounds = false;
2431 }
2432
2433 //================================================================
2434 // SERIALIZATION
2435 //================================================================
2436 override void OnStoreSave(ParamsWriteContext ctx)
2437 {
2438 super.OnStoreSave(ctx);
2439
2440 if (GetFoodStage())
2441 {
2442 GetFoodStage().OnStoreSave(ctx);
2443 }
2444
2445 // food decay
2446 ctx.Write(m_DecayTimer);
2448 }
2449
2450 override bool OnStoreLoad(ParamsReadContext ctx, int version)
2451 {
2452 if (!super.OnStoreLoad(ctx, version))
2453 return false;
2454
2455 if (GetFoodStage())
2456 {
2457 if (!GetFoodStage().OnStoreLoad(ctx, version))
2458 return false;
2459 }
2460
2461 if (version >= 115)
2462 {
2463 if (!ctx.Read(m_DecayTimer))
2464 {
2465 m_DecayTimer = 0.0;
2466 return false;
2467 }
2468 if (!ctx.Read(m_LastDecayStage))
2469 {
2471 return false;
2472 }
2473 }
2474
2475 UpdateVisualsEx(true); //forced init visuals
2476 Synchronize();
2477
2478 return true;
2479 }
2480
2481 override void AfterStoreLoad()
2482 {
2483 super.AfterStoreLoad();
2484
2485 Synchronize();
2486 }
2487
2488 //get food stage
2489 override FoodStage GetFoodStage()
2490 {
2491 return m_FoodStage;
2492 }
2493
2494 //food types
2495 override bool IsMeat()
2496 {
2497 return false;
2498 }
2499
2500 override bool IsCorpse()
2501 {
2502 return false;
2503 }
2504
2505 override bool IsFruit()
2506 {
2507 return false;
2508 }
2509
2510 override bool IsMushroom()
2511 {
2512 return false;
2513 }
2514
2515 //================================================================
2516 // NUTRITIONAL VALUES
2517 //================================================================
2518 //food properties
2519 static float GetFoodTotalVolume(ItemBase item, string classname = "", int food_stage = 0)
2520 {
2521 Edible_Base food_item = Edible_Base.Cast(item);
2522 if (food_item && food_item.GetFoodStage())
2523 {
2524 return FoodStage.GetFullnessIndex(food_item.GetFoodStage());
2525 }
2526 else if (classname != "" && food_stage)
2527 {
2528 return FoodStage.GetFullnessIndex(null, food_stage, classname);
2529 }
2530 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
2531 return GetGame().ConfigGetFloat( class_path + " fullnessIndex" );
2532
2533 }
2534
2535 static float GetFoodEnergy(ItemBase item, string classname = "", int food_stage = 0)
2536 {
2537 Edible_Base food_item = Edible_Base.Cast(item);
2538 if (food_item && food_item.GetFoodStage())
2539 {
2540 return FoodStage.GetEnergy(food_item.GetFoodStage());
2541 }
2542 else if (classname != "" && food_stage)
2543 {
2544 return FoodStage.GetEnergy(null, food_stage, classname);
2545 }
2546 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
2547 return GetGame().ConfigGetFloat( class_path + " energy" );
2548 }
2549
2550 static float GetFoodWater(ItemBase item, string classname = "", int food_stage = 0)
2551 {
2552 Edible_Base food_item = Edible_Base.Cast(item);
2553 if (food_item && food_item.GetFoodStage())
2554 {
2555 return FoodStage.GetWater(food_item.GetFoodStage());
2556 }
2557 else if (classname != "" && food_stage)
2558 {
2559 return FoodStage.GetWater(null, food_stage, classname);
2560 }
2561 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
2562 return GetGame().ConfigGetFloat( class_path + " water" );
2563 }
2564
2565 static float GetFoodNutritionalIndex(ItemBase item, string classname = "", int food_stage = 0)
2566 {
2567 Edible_Base food_item = Edible_Base.Cast(item);
2568 if (food_item && food_item.GetFoodStage())
2569 {
2570 return FoodStage.GetNutritionalIndex(food_item.GetFoodStage());
2571 }
2572 else if (classname != "" && food_stage)
2573 {
2574 return FoodStage.GetNutritionalIndex(null, food_stage, classname);
2575 }
2576 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
2577 return GetGame().ConfigGetFloat( class_path + " nutritionalIndex" );
2578
2579 }
2580
2581 static float GetFoodToxicity(ItemBase item, string classname = "", int food_stage = 0)
2582 {
2583 Edible_Base food_item = Edible_Base.Cast(item);
2584 if (food_item && food_item.GetFoodStage())
2585 {
2586 return FoodStage.GetToxicity(food_item.GetFoodStage());
2587 }
2588 else if (classname != "" && food_stage)
2589 {
2590 return FoodStage.GetToxicity(null, food_stage, classname);
2591 }
2592 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
2593 return GetGame().ConfigGetFloat( class_path + " toxicity" );
2594 }
2595
2596 static int GetFoodAgents(ItemBase item, string classname = "", int food_stage = 0)
2597 {
2598 Edible_Base food_item = Edible_Base.Cast(item);
2599 if (food_item && food_item.GetFoodStage())
2600 {
2601 return FoodStage.GetAgents(food_item.GetFoodStage());
2602 }
2603 else if (classname != "" && food_stage)
2604 {
2605 return FoodStage.GetAgents(null, food_stage, classname);
2606 }
2607 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
2608 return GetGame().ConfigGetInt( class_path + " agents" );
2609 }
2610
2611 static float GetFoodDigestibility(ItemBase item, string classname = "", int food_stage = 0)
2612 {
2613 Edible_Base food_item = Edible_Base.Cast(item);
2614 if (food_item && food_item.GetFoodStage())
2615 {
2616 return FoodStage.GetDigestibility(food_item.GetFoodStage());
2617 }
2618 else if (classname != "" && food_stage)
2619 {
2620 return FoodStage.GetDigestibility(null, food_stage, classname);
2621 }
2622 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
2623 return GetGame().ConfigGetInt( class_path + " digestibility" );
2624 }
2625
2626 static float GetAgentsPerDigest(ItemBase item, string className = "", int foodStage = 0)
2627 {
2628 Edible_Base foodItem = Edible_Base.Cast(item);
2629 if (foodItem && foodItem.GetFoodStage())
2630 {
2631 return FoodStage.GetAgentsPerDigest(foodItem.GetFoodStage());
2632 }
2633 else if (className != "" && foodStage)
2634 {
2635 return FoodStage.GetAgentsPerDigest(null, foodStage, className);
2636 }
2637 string classPath = string.Format("cfgVehicles %1 Nutrition", className);
2638 return GetGame().ConfigGetInt(classPath + " agentsPerDigest");
2639 }
2640
2641 static NutritionalProfile GetNutritionalProfile(ItemBase item, string classname = "", int food_stage = 0)
2642 {
2643 NutritionalProfile profile = new NutritionalProfile();
2644 profile.m_Energy = GetFoodEnergy(item, classname, food_stage);
2645 profile.m_WaterContent = GetFoodWater(item, classname, food_stage);
2646 profile.m_NutritionalIndex = GetFoodNutritionalIndex(item, classname, food_stage);
2647 profile.m_FullnessIndex = GetFoodTotalVolume(item, classname, food_stage);
2648 profile.m_Toxicity = GetFoodToxicity(item, classname, food_stage);
2649 profile.m_Agents = GetFoodAgents(item, classname, food_stage);
2650 profile.m_Digestibility = GetFoodDigestibility(item, classname, food_stage);
2651 profile.m_AgentsPerDigest = GetAgentsPerDigest(item, classname, food_stage);
2652
2653 return profile;
2654 }
2655
2656 //================================================================
2657 // FOOD STAGING
2658 //================================================================
2660 {
2661 return GetFoodStage().GetFoodStageType();
2662 }
2663
2664 //food stage states
2665 bool IsFoodRaw()
2666 {
2667 if ( GetFoodStage() )
2668 {
2669 return GetFoodStage().IsFoodRaw();
2670 }
2671
2672 return false;
2673 }
2674
2675 bool IsFoodBaked()
2676 {
2677 if ( GetFoodStage() )
2678 {
2679 return GetFoodStage().IsFoodBaked();
2680 }
2681
2682 return false;
2683 }
2684
2685 bool IsFoodBoiled()
2686 {
2687 if ( GetFoodStage() )
2688 {
2689 return GetFoodStage().IsFoodBoiled();
2690 }
2691
2692 return false;
2693 }
2694
2695 bool IsFoodDried()
2696 {
2697 if ( GetFoodStage() )
2698 {
2699 return GetFoodStage().IsFoodDried();
2700 }
2701
2702 return false;
2703 }
2704
2705 bool IsFoodBurned()
2706 {
2707 if ( GetFoodStage() )
2708 {
2709 return GetFoodStage().IsFoodBurned();
2710 }
2711
2712 return false;
2713 }
2714
2715 bool IsFoodRotten()
2716 {
2717 if ( GetFoodStage() )
2718 {
2719 return GetFoodStage().IsFoodRotten();
2720 }
2721
2722 return false;
2723 }
2724
2725 //food stage change
2726 void ChangeFoodStage( FoodStageType new_food_stage_type )
2727 {
2728 GetFoodStage().ChangeFoodStage( new_food_stage_type );
2729 }
2730
2732 {
2733 return GetFoodStage().GetNextFoodStageType( cooking_method );
2734 }
2735
2736 string GetFoodStageName( FoodStageType food_stage_type )
2737 {
2738 return GetFoodStage().GetFoodStageName( food_stage_type );
2739 }
2740
2741 bool CanChangeToNewStage( CookingMethodType cooking_method )
2742 {
2743 return GetFoodStage().CanChangeToNewStage( cooking_method );
2744 }
2745
2746 //Use this to receive food stage from another Edible_Base
2747 void TransferFoodStage( notnull Edible_Base source )
2748 {
2749 if ( !source.GetFoodStage())
2750 return;
2751 m_LastDecayStage = source.GetLastDecayStage();
2752 ChangeFoodStage(source.GetFoodStage().GetFoodStageType());
2753 m_DecayTimer = source.GetDecayTimer();
2754 m_DecayDelta = source.GetDecayDelta();
2755 }
2756
2758 void OnFoodStageChange(FoodStageType stageOld, FoodStageType stageNew)
2759 {
2760 HandleFoodStageChangeAgents(stageOld,stageNew);
2761 UpdateVisualsEx(); //performed on server only
2762 }
2763
2766 {
2767 switch (stageNew)
2768 {
2769 case FoodStageType.BAKED:
2770 case FoodStageType.BOILED:
2771 case FoodStageType.DRIED:
2772 RemoveAllAgentsExcept(eAgents.BRAIN|eAgents.HEAVYMETAL);
2773 break;
2774
2775 case FoodStageType.BURNED:
2776 RemoveAllAgentsExcept(eAgents.BRAIN|eAgents.HEAVYMETAL);
2777 break;
2778 }
2779 }
2780
2781 //================================================================
2782 // COOKING
2783 //================================================================
2784 //cooking time
2785 float GetCookingTime()
2786 {
2787 return GetFoodStage().GetCookingTime();
2788 }
2789
2790 void SetCookingTime( float time )
2791 {
2792 GetFoodStage().SetCookingTime( time );
2793
2794 //synchronize when calling on server
2795 Synchronize();
2796 }
2797
2798 void ResetCookingTime()
2799 {
2800 if (GetFoodStage())
2801 {
2802 GetFoodStage().SetCookingTime(0);
2803 Synchronize();
2804 }
2805 }
2806
2807 //replace edible with new item (opening cans)
2808 void ReplaceEdibleWithNew( string typeName )
2809 {
2810 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
2811 if (player)
2812 {
2813 ReplaceEdibleWithNewLambda lambda = new ReplaceEdibleWithNewLambda(this, typeName, player);
2814 player.ServerReplaceItemInHandsWithNew(lambda);
2815 }
2816 else
2817 Error("ReplaceEdibleWithNew - cannot use edible without player");
2818 }
2819
2821 {
2823 }
2824
2825 override void SetActions()
2826 {
2827 super.SetActions();
2828
2831 }
2832
2833 protected void SoundCookingStart(string sound_name)
2834 {
2835 #ifndef SERVER
2836 if (m_SoundPlaying != sound_name)
2837 {
2839
2840 m_SoundEffectCooking = SEffectManager.PlaySound(sound_name, GetPosition(), 0, 0, true);
2841 m_SoundPlaying = sound_name;
2842 }
2843 #endif
2844 }
2845
2846 protected void SoundCookingStop()
2847 {
2848 #ifndef SERVER
2850 {
2851 m_SoundEffectCooking.Stop();
2852 m_SoundEffectCooking = null;
2853 m_SoundPlaying = "";
2854 }
2855 #endif
2856 }
2857
2858 override bool CanDecay()
2859 {
2860 return false;
2861 }
2862
2863 override bool CanProcessDecay()
2864 {
2865 return !GetIsFrozen() && ( GetFoodStageType() != FoodStageType.ROTTEN );
2866 }
2867
2868 override void ProcessDecay( float delta, bool hasRootAsPlayer )
2869 {
2870 m_DecayDelta = 0.0;
2871
2872 delta *= DayZGame.Cast(GetGame()).GetFoodDecayModifier();
2873 m_DecayDelta += ( 1 + ( 1 - GetHealth01( "", "" ) ) );
2874 if ( hasRootAsPlayer )
2876
2877 /*Print( "-------------------------" );
2878 Print( this );
2879 Print( m_DecayTimer );
2880 Print( m_DecayDelta );
2881 Print( m_LastDecayStage );*/
2882
2883 if ( IsFruit() || IsMushroom() )
2884 {
2885 // fruit, vegetables and mushrooms
2887 {
2888 switch ( GetFoodStageType() )
2889 {
2890 case FoodStageType.RAW:
2893 break;
2894
2895 case FoodStageType.BOILED:
2898 break;
2899
2900 case FoodStageType.BAKED:
2903 break;
2904
2905 case FoodStageType.DRIED:
2906 case FoodStageType.BURNED:
2907 case FoodStageType.ROTTEN:
2908 default:
2909 m_DecayTimer = -1;
2911 return;
2912 }
2913
2914 //m_DecayTimer = m_DecayTimer / 1000.0;
2915 }
2916
2917 m_DecayTimer -= ( delta * m_DecayDelta );
2918
2919 if ( m_DecayTimer <= 0 )
2920 {
2921 if ( m_LastDecayStage != FoodStageType.NONE )
2922 {
2923 // switch to decayed stage
2924 if ( ( m_LastDecayStage == FoodStageType.BOILED ) || ( m_LastDecayStage == FoodStageType.BAKED ) )
2925 {
2927 }
2928 if ( m_LastDecayStage == FoodStageType.RAW )
2929 {
2930 int rng = Math.RandomIntInclusive( 0, 100 );
2932 {
2934 }
2935 else
2936 {
2937 if ( CanChangeToNewStage( FoodStageType.DRIED ) )
2938 {
2940 }
2941 else
2942 {
2944 }
2945 }
2946 }
2947 }
2948 }
2949
2950 }
2951 else if ( IsMeat() )
2952 {
2953 // meat
2955 {
2956 switch ( GetFoodStageType() )
2957 {
2958 case FoodStageType.RAW:
2961 break;
2962
2963 case FoodStageType.BOILED:
2966 break;
2967
2968 case FoodStageType.BAKED:
2971 break;
2972
2973 case FoodStageType.DRIED:
2976 break;
2977
2978 case FoodStageType.BURNED:
2979 case FoodStageType.ROTTEN:
2980 default:
2981 m_DecayTimer = -1;
2983 return;
2984 }
2985 }
2986
2987 m_DecayTimer -= ( delta * m_DecayDelta );
2988
2989 if ( m_DecayTimer <= 0 )
2990 {
2991 if ( m_LastDecayStage != FoodStageType.NONE )
2992 {
2993 // switch to decayed stage
2994 if ( ( m_LastDecayStage == FoodStageType.DRIED ) || ( m_LastDecayStage == FoodStageType.RAW ) || ( m_LastDecayStage == FoodStageType.BOILED ) || ( m_LastDecayStage == FoodStageType.BAKED ) )
2995 {
2997 }
2998 }
2999 }
3000 }
3001 else if ( IsCorpse() )
3002 {
3003 // corpse
3005 {
3006 switch ( GetFoodStageType() )
3007 {
3008 case FoodStageType.RAW:
3011 break;
3012
3013 case FoodStageType.BURNED:
3014 case FoodStageType.ROTTEN:
3015 default:
3016 m_DecayTimer = -1;
3018 return;
3019 }
3020 }
3021
3022 m_DecayTimer -= ( delta * m_DecayDelta );
3023
3024 if ( m_DecayTimer <= 0 )
3025 {
3026 if ( m_LastDecayStage != FoodStageType.NONE )
3027 {
3028 // switch to decayed stage
3029 if ( ( m_LastDecayStage == FoodStageType.DRIED ) || ( m_LastDecayStage == FoodStageType.RAW ) || ( m_LastDecayStage == FoodStageType.BOILED ) || ( m_LastDecayStage == FoodStageType.BAKED ) )
3030 {
3032 }
3033 }
3034 }
3035 }
3036 else
3037 {
3038 // opened cans
3039 m_DecayTimer -= ( delta * m_DecayDelta );
3040
3041 if ( ( m_DecayTimer <= 0 ) && ( m_LastDecayStage == FoodStageType.NONE ) )
3042 {
3045 //m_DecayTimer = m_DecayTimer / 1000.0;
3046 }
3047 else
3048 {
3049 if ( m_DecayTimer <= 0 )
3050 {
3051 InsertAgent(eAgents.FOOD_POISON, 1);
3052 m_DecayTimer = -1;
3053 }
3054 }
3055 }
3056 }
3057
3058 protected void UpdateVaporParticle()
3059 {
3060 if (GetGame().IsDedicatedServer())
3061 return;
3062
3063 if (m_VarTemperature >= GameConstants.STATE_HOT_LVL_TWO && !m_HotVaporParticle)
3064 {
3065 InventoryLocation invLoc = new InventoryLocation();
3066 GetInventory().GetCurrentInventoryLocation(invLoc);
3067 if (invLoc && (invLoc.GetType() == InventoryLocationType.GROUND || invLoc.GetType() == InventoryLocationType.HANDS || invLoc.GetType() == InventoryLocationType.ATTACHMENT))
3068 {
3069 ParticleManager ptcMgr = ParticleManager.GetInstance();
3070 if (ptcMgr)
3071 {
3072 m_HotVaporParticle = ParticleManager.GetInstance().PlayOnObject(ParticleList.ITEM_HOT_VAPOR, this);
3073 m_HotVaporParticle.SetParticleParam(EmitorParam.SIZE, 0.3);
3074 m_HotVaporParticle.SetParticleParam(EmitorParam.BIRTH_RATE, 10);
3075 m_HotVaporParticle.SetParticleAutoDestroyFlags(ParticleAutoDestroyFlags.ON_STOP);
3076 }
3077 }
3078 }
3079 else if (m_HotVaporParticle)
3080 {
3081 if (m_VarTemperature <= GameConstants.STATE_HOT_LVL_TWO)
3082 {
3083 m_HotVaporParticle.Stop();
3084 m_HotVaporParticle = null;
3085 return;
3086 }
3087
3088 InventoryLocation inventoryLoc = new InventoryLocation();
3089 GetInventory().GetCurrentInventoryLocation(inventoryLoc);
3090 if (invLoc && (invLoc.GetType() != InventoryLocationType.GROUND && invLoc.GetType() != InventoryLocationType.HANDS))
3091 {
3092 m_HotVaporParticle.Stop();
3093 m_HotVaporParticle = null;
3094 }
3095 }
3096 }
3097
3098 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
3099 {
3100 super.GetDebugActions(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 }
3108 }
3109
3110 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
3111 {
3112 super.OnAction(action_id, player, ctx);
3113
3114 if ( GetGame().IsServer() )
3115 {
3116 if ( action_id == EActions.FOOD_STAGE_PREV )
3117 {
3118 int food_stage_prev = GetFoodStageType() - 1;
3119 if (food_stage_prev <= 0)
3120 {
3121 food_stage_prev = FoodStageType.COUNT - 1;
3122 }
3123 ChangeFoodStage(food_stage_prev);
3124 return true;
3125 }
3126 else if ( action_id == EActions.FOOD_STAGE_NEXT )
3127 {
3128 int food_stage_next = GetFoodStageType() + 1;
3129 if (food_stage_next >= FoodStageType.COUNT )
3130 {
3131 food_stage_next = FoodStageType.RAW;
3132 }
3133 ChangeFoodStage(food_stage_next);
3134 return true;
3135 }
3136
3137 }
3138
3139 #ifdef DIAG_DEVELOPER
3140 if (action_id == EActions.FOOD_NUTRITIONS_DATA)
3141 {
3142 PrintNutritionsData();
3143 return true;
3144 }
3145 #endif
3146
3147 return false;
3148 }
3149
3150 override string GetDebugText()
3151 {
3152 string debug_output;
3153
3154 debug_output = super.GetDebugText();
3155
3156 debug_output+="m_CookedByMethod:"+m_CookedByMethod+"\n";
3157 debug_output+="m_MakeCookingSounds:"+m_MakeCookingSounds+"\n";
3158
3159 return debug_output;
3160 }
3161
3162 //================================================================
3163 // GENERAL GETTERS
3164 //================================================================
3165
3166 override float GetBaitEffectivity()
3167 {
3168 float ret = super.GetBaitEffectivity();
3169
3170 if (IsFoodRotten())
3171 {
3172 ret *= 0.5;
3173 }
3174
3175 return ret;
3176 }
3177
3178 float GetDecayTimer()
3179 {
3180 return m_DecayTimer;
3181 }
3182
3183 float GetDecayDelta()
3184 {
3185 return m_DecayDelta;
3186 }
3187
3189 {
3190 return m_LastDecayStage;
3191 }
3192
3193 #ifdef DIAG_DEVELOPER
3194 private void PrintNutritionsData()
3195 {
3196 string nutritionsData = "";
3197
3198 FoodStage stage = GetFoodStage();
3199 FoodStageType stageType = stage.GetFoodStageType();
3200
3201 NutritionalProfile profile = GetNutritionalProfile(this, ClassName(), stageType);
3202 if (profile)
3203 {
3204 nutritionsData = string.Format("Item: %1\n\n", this);
3205 nutritionsData += string.Format("Stage name: %1\n", GetFoodStageName(stageType));
3206 nutritionsData += string.Format("Energy: %1\n", profile.m_Energy);
3207 nutritionsData += string.Format("Water content: %1\n", profile.m_WaterContent);
3208 nutritionsData += string.Format("Nutritional index: %1\n", profile.m_NutritionalIndex);
3209 nutritionsData += string.Format("Fullness index: %1\n", profile.m_FullnessIndex);
3210 nutritionsData += string.Format("Toxicity (obsolete): %1\n", profile.m_Toxicity);
3211 nutritionsData += string.Format("Digestibility: %1\n", profile.m_Digestibility);
3212
3213 if (profile.IsLiquid())
3214 nutritionsData += string.Format("Liquid type: %1\n", profile.m_LiquidClassname);
3215
3216 nutritionsData += string.Format("Agents: %1\n", profile.m_Agents);
3217 nutritionsData += string.Format("Agents per consume: %1\n", profile.m_AgentsPerDigest);
3218 }
3219
3220 nutritionsData += "-----\n";
3221
3222 Debug.Log(nutritionsData);
3223 }
3224 #endif
3225
3227 //DEPRECATED
3229 void UpdateVisuals()
3230 {
3232 }
3233}
3234
3236{
3237 void ReplaceEdibleWithNewLambda(EntityAI old_item, string new_item_type, PlayerBase player) { }
3238};
Param4< int, int, string, int > TSelectableActionInfoWithColor
Определения EntityAI.c:97
class LogManager EntityAI
eBleedingSourceType GetType()
Определения BleedingSource.c:63
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
EActions
Определения EActions.c:2
eAgents
Определения EAgents.c:3
EConsumptionPenaltyContext
Определения EConsumptionPenaltyContext.c:2
void ReplaceEdibleWithNew(string typeName)
Определения Edible_Base.c:1787
ref FoodStage m_FoodStage
Определения Edible_Base.c:1124
bool IsFoodRotten()
Определения Edible_Base.c:1694
static float GetFoodWater(ItemBase item, string classname="", int food_stage=0)
Определения Edible_Base.c:1529
override bool CanBeCooked()
Определения Edible_Base.c:1236
bool IsFoodBaked()
Определения Edible_Base.c:1654
override string GetDebugText()
Определения Edible_Base.c:2129
override void AfterStoreLoad()
Определения Edible_Base.c:1460
string m_SoundPlaying
Определения Edible_Base.c:1123
void Edible_Base()
Определения Edible_Base.c:1132
void OnFoodStageChange(FoodStageType stageOld, FoodStageType stageNew)
called on server
Определения Edible_Base.c:1737
float m_DecayDelta
Определения Edible_Base.c:1126
void Synchronize()
Определения Edible_Base.c:1294
override void OnVariablesSynchronized()
Определения Edible_Base.c:1299
const string SOUND_BURNING_DONE
Определения Edible_Base.c:1118
bool CanChangeToNewStage(CookingMethodType cooking_method)
Определения Edible_Base.c:1720
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
Определения Edible_Base.c:2089
void RemoveAudio()
Определения Edible_Base.c:1406
override bool CanItemOverheat()
Определения Edible_Base.c:1286
float GetDecayDelta()
Определения Edible_Base.c:2162
override float GetBaitEffectivity()
Определения Edible_Base.c:2145
override FoodStage GetFoodStage()
Определения Edible_Base.c:1468
override void SetActions()
Определения Edible_Base.c:1804
bool m_MakeCookingSounds
Определения Edible_Base.c:1120
override float GetTemperatureFreezeTime()
Определения Edible_Base.c:1246
void SoundCookingStop()
Определения Edible_Base.c:1825
const string DIRECT_COOKING_SLOT_NAME
Определения Edible_Base.c:1110
FoodStageType GetNextFoodStageType(CookingMethodType cooking_method)
Определения Edible_Base.c:1710
void ChangeFoodStage(FoodStageType new_food_stage_type)
Определения Edible_Base.c:1705
void OnConsume(float amount, PlayerBase consumer)
Определения Edible_Base.c:1210
static float GetFoodNutritionalIndex(ItemBase item, string classname="", int food_stage=0)
Определения Edible_Base.c:1544
SoundOnVehicle m_SoundCooking
Определения Edible_Base.c:1121
static float GetFoodToxicity(ItemBase item, string classname="", int food_stage=0)
Определения Edible_Base.c:1560
override bool CanDecay()
Определения Edible_Base.c:1837
void UpdateVisualsEx(bool forced=false)
Определения Edible_Base.c:1196
const string SOUND_BAKING_DONE
Определения Edible_Base.c:1113
static NutritionalProfile GetNutritionalProfile(ItemBase item, string classname="", int food_stage=0)
Определения Edible_Base.c:1620
int FilterAgents(int agentsIn)
Filter agents from the item (override on higher implementations)
Определения Edible_Base.c:1219
override void EEDelete(EntityAI parent)
Определения Edible_Base.c:1155
FoodStageType m_LastDecayStage
Определения Edible_Base.c:1127
float GetCookingTime()
Определения Edible_Base.c:1764
override bool CanBeCookedOnStick()
Определения Edible_Base.c:1241
override bool IsCorpse()
Определения Edible_Base.c:1479
void UpdateVisuals()
Определения Edible_Base.c:2208
float GetDecayTimer()
Определения Edible_Base.c:2157
FoodStageType GetLastDecayStage()
Определения Edible_Base.c:2167
string GetFoodStageName(FoodStageType food_stage_type)
Определения Edible_Base.c:1715
override float GetTemperatureThawTime()
Определения Edible_Base.c:1266
void UpdateVaporParticle()
Определения Edible_Base.c:2037
static float GetFoodDigestibility(ItemBase item, string classname="", int food_stage=0)
Определения Edible_Base.c:1590
void TransferFoodStage(notnull Edible_Base source)
Определения Edible_Base.c:1726
override void ProcessDecay(float delta, bool hasRootAsPlayer)
Определения Edible_Base.c:1847
const string SOUND_DRYING_START
Определения Edible_Base.c:1116
void SetCookingTime(float time)
Определения Edible_Base.c:1769
void SoundCookingStart(string sound_name)
Определения Edible_Base.c:1812
override bool IsMeat()
Определения Edible_Base.c:1474
const string SOUND_BAKING_START
Определения Edible_Base.c:1112
static float GetFoodTotalVolume(ItemBase item, string classname="", int food_stage=0)
Определения Edible_Base.c:1498
const string SOUND_DRYING_DONE
Определения Edible_Base.c:1117
void HandleFoodStageChangeAgents(FoodStageType stageOld, FoodStageType stageNew)
removes select agents on foodstage transitions
Определения Edible_Base.c:1744
void ResetCookingTime()
Определения Edible_Base.c:1777
override bool IsFruit()
Определения Edible_Base.c:1484
Edible_Base ItemBase ReplaceEdibleWithNewLambda(EntityAI old_item, string new_item_type, PlayerBase player)
Определения Edible_Base.c:1109
bool Consume(float amount, PlayerBase consumer)
Определения Edible_Base.c:1202
EffectSound m_SoundEffectCooking
DEPRECATED.
Определения Edible_Base.c:1122
override bool OnStoreLoad(ParamsReadContext ctx, int version)
Определения Edible_Base.c:1429
FoodStageType GetFoodStageType()
Определения Edible_Base.c:1638
override bool CanProcessDecay()
Определения Edible_Base.c:1842
ParticleSource m_HotVaporParticle
Определения Edible_Base.c:1128
void MakeSoundsOnClient(bool soundstate, CookingMethodType cookingMethod=CookingMethodType.NONE)
Определения Edible_Base.c:1322
static int GetFoodAgents(ItemBase item, string classname="", int food_stage=0)
Определения Edible_Base.c:1575
override bool IsMushroom()
Определения Edible_Base.c:1489
static float GetFoodEnergy(ItemBase item, string classname="", int food_stage=0)
Определения Edible_Base.c:1514
static float GetAgentsPerDigest(ItemBase item, string className="", int foodStage=0)
Определения Edible_Base.c:1605
void RefreshAudio()
Определения Edible_Base.c:1330
const string SOUND_BOILING_DONE
Определения Edible_Base.c:1115
int GetConsumptionPenaltyContext()
Определения Edible_Base.c:1799
const string SOUND_BOILING_START
Определения Edible_Base.c:1114
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Определения Edible_Base.c:2077
CookingMethodType m_CookedByMethod
Определения Edible_Base.c:1130
bool IsFoodDried()
Определения Edible_Base.c:1674
override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Определения Edible_Base.c:1165
override void OnStoreSave(ParamsWriteContext ctx)
Определения Edible_Base.c:1415
bool IsFoodRaw()
Определения Edible_Base.c:1644
bool IsFoodBurned()
Определения Edible_Base.c:1684
override void EEInit()
Определения Edible_Base.c:1148
bool IsFoodBoiled()
Определения Edible_Base.c:1664
float m_DecayTimer
Определения Edible_Base.c:1125
override bool CanHaveTemperature()
Определения FireplaceBase.c:557
FoodStageType
Определения FoodStage.c:2
InventoryLocationType
types of Inventory Location
Определения InventoryLocation.c:4
override void InsertAgent(int agent, float count=1)
Определения ItemBase.c:8653
override void RemoveAllAgentsExcept(int agent_to_keep)
Определения ItemBase.c:8648
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:8060
bool HasFoodStage()
Определения ItemBase.c:7324
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.
Определения Debug.c:122
Определения Debug.c:2
override FoodStage GetFoodStage()
Определения Edible_Base.c:361
Определения Edible_Base.c:2
Wrapper class for managing sound through SEffectManager.
Определения EffectSound.c:5
Определения Building.c:6
Определения constants.c:659
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
Определения InventoryItem.c:731
Определения 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:70
Определения 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
Определения constants.c:1038
const float DECAY_FOOD_CAN_OPEN
Определения constants.c:1040
const float DECAY_FOOD_RAW_FRVG
Определения constants.c:1034
const int DECAY_TIMER_RANDOM_PERCENTAGE
Определения constants.c:1042
const int DECAY_FOOD_FRVG_DRIED_CHANCE
Определения constants.c:1041
const float DECAY_FOOD_RAW_MEAT
Определения constants.c:1032
const float DECAY_FOOD_BAKED_MEAT
Определения constants.c:1037
const float DECAY_FOOD_BOILED_MEAT
Определения constants.c:1035
const float DECAY_FOOD_BOILED_FRVG
Определения constants.c:1036
const float DECAY_FOOD_DRIED_MEAT
Определения constants.c:1039
const float DECAY_FOOD_RAW_CORPSE
Определения constants.c:1033
const float DECAY_RATE_ON_PLAYER
Определения constants.c:1043
static const float TEMPERATURE_THAW_TIME_COEF_BURNED
Определения constants.c:935
static const float TEMPERATURE_FREEZE_TIME_COEF_BURNED
Определения constants.c:934
static const float TEMPERATURE_THAW_TIME_COEF_DRIED
Определения constants.c:936
static const float TEMPERATURE_FREEZE_TIME_COEF_DRIED
Определения constants.c:933
const int STATE_HOT_LVL_TWO
Определения constants.c:884
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
Определения constants.c:452
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.