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

◆ UpdateVisuals()

void ReplaceEdibleWithNewLambda::UpdateVisuals ( )
protected

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

2208 : ItemBase
2209{
2210 const string DIRECT_COOKING_SLOT_NAME = "DirectCooking";
2211
2212 const string SOUND_BAKING_START = "Baking_SoundSet";
2213 const string SOUND_BAKING_DONE = "Baking_Done_SoundSet";
2214 const string SOUND_BOILING_START = "Boiling_SoundSet";
2215 const string SOUND_BOILING_DONE = "Boiling_Done_SoundSet";
2216 const string SOUND_DRYING_START = "Drying_SoundSet";
2217 const string SOUND_DRYING_DONE = "Drying_Done_SoundSet";
2218 const string SOUND_BURNING_DONE = "Food_Burning_SoundSet";
2219
2220 protected bool m_MakeCookingSounds;
2221 protected SoundOnVehicle m_SoundCooking;
2223 protected string m_SoundPlaying;
2224 ref FoodStage m_FoodStage;
2225 protected float m_DecayTimer;
2226 protected float m_DecayDelta = 0.0;
2229
2231
2232 void Edible_Base()
2233 {
2234 if (HasFoodStage())
2235 {
2236 m_FoodStage = new FoodStage(this);
2237
2238 RegisterNetSyncVariableInt("m_FoodStage.m_FoodStageType", FoodStageType.NONE, FoodStageType.COUNT);
2239 RegisterNetSyncVariableFloat("m_FoodStage.m_CookingTime", 0, 600, 0);
2240
2241 m_SoundPlaying = "";
2243 RegisterNetSyncVariableInt("m_CookedByMethod", CookingMethodType.NONE, CookingMethodType.COUNT);
2244 RegisterNetSyncVariableBool("m_MakeCookingSounds");
2245 }
2246 }
2247
2248 override void EEInit()
2249 {
2250 super.EEInit();
2251
2252 UpdateVisualsEx(true); //forced init visuals, mostly for debugs and SP
2253 }
2254
2255 override void EEDelete(EntityAI parent)
2256 {
2257 super.EEDelete(parent);
2258
2259 RemoveAudio();
2260
2262 m_HotVaporParticle.Stop();
2263 }
2264
2265 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
2266 {
2267 super.EEItemLocationChanged(oldLoc, newLoc);
2268
2270 if (oldLoc.GetType() == InventoryLocationType.ATTACHMENT || oldLoc.GetType() == InventoryLocationType.CARGO)
2271 {
2272 switch (oldLoc.GetParent().GetType())
2273 {
2274 case "FryingPan":
2275 case "Pot":
2276 case "Cauldron":
2277 case "SharpWoodenStick":
2278 MakeSoundsOnClient(false);
2279 break;
2280 }
2281
2283 if (oldLoc.GetSlot() > -1 && InventorySlots.GetSlotName(oldLoc.GetSlot()).Contains(DIRECT_COOKING_SLOT_NAME))
2284 {
2285 MakeSoundsOnClient(false);
2286 }
2287 }
2288
2289 if (oldLoc.IsValid())
2291
2292 if (CanHaveTemperature())
2294 }
2295
2296 void UpdateVisualsEx(bool forced = false)
2297 {
2298 if (GetFoodStage())
2299 GetFoodStage().UpdateVisualsEx(forced);
2300 }
2301
2302 bool Consume(float amount, PlayerBase consumer)
2303 {
2304 AddQuantity(-amount, false, false);
2305 OnConsume(amount, consumer);
2306
2307 return true;
2308 }
2309
2310 void OnConsume(float amount, PlayerBase consumer)
2311 {
2313 {
2314 consumer.ProcessDirectDamage(DamageType.CUSTOM, this, "", "EnviroDmg", "0 0 0", PlayerConstants.CONSUMPTION_DAMAGE_PER_BITE);
2315 }
2316 }
2317
2319 int FilterAgents(int agentsIn)
2320 {
2321 int foodStageType;
2322
2323 FoodStage foodStage = GetFoodStage();
2324 if (foodStage)
2325 foodStageType = foodStage.GetFoodStageType();
2326
2328 NutritionalProfile nutritionalProfile = GetNutritionalProfile(this, ClassName(), foodStageType);
2329 if ((agentsIn & eAgents.SALMONELLA == eAgents.SALMONELLA) && (nutritionalProfile.m_Agents == 0 || nutritionalProfile.m_AgentsPerDigest == 0))
2330 agentsIn &= ~eAgents.FOOD_POISON;
2331
2332 return agentsIn;
2333 }
2334
2335 //food staging
2336 override bool CanBeCooked()
2337 {
2338 return false;
2339 }
2340
2341 override bool CanBeCookedOnStick()
2342 {
2343 return false;
2344 }
2345
2346 override float GetTemperatureFreezeTime()
2347 {
2348 if (GetFoodStage())
2349 {
2350 switch (m_FoodStage.GetFoodStageType())
2351 {
2352 case FoodStageType.DRIED:
2353 return super.GetTemperatureFreezeTime() * GameConstants.TEMPERATURE_FREEZE_TIME_COEF_DRIED;
2354
2355 case FoodStageType.BURNED:
2356 return super.GetTemperatureFreezeTime() * GameConstants.TEMPERATURE_FREEZE_TIME_COEF_BURNED;
2357
2358 default:
2359 return super.GetTemperatureFreezeTime();
2360 }
2361 }
2362
2363 return super.GetTemperatureFreezeTime();
2364 }
2365
2366 override float GetTemperatureThawTime()
2367 {
2368 if (GetFoodStage())
2369 {
2370 switch (m_FoodStage.GetFoodStageType())
2371 {
2372 case FoodStageType.DRIED:
2373 return super.GetTemperatureThawTime() * GameConstants.TEMPERATURE_THAW_TIME_COEF_DRIED;
2374
2375 case FoodStageType.BURNED:
2376 return super.GetTemperatureThawTime() * GameConstants.TEMPERATURE_THAW_TIME_COEF_BURNED;
2377
2378 default:
2379 return super.GetTemperatureThawTime();
2380 }
2381 }
2382
2383 return super.GetTemperatureThawTime();
2384 }
2385
2386 override bool CanItemOverheat()
2387 {
2388 return super.CanItemOverheat() && (!GetFoodStage() || (IsFoodBurned() || !GetFoodStage().CanTransitionToFoodStageType(FoodStageType.BURNED))); //for foodstaged items - either is burned, or it can't get burned
2389 }
2390
2391 //================================================================
2392 // SYNCHRONIZATION
2393 //================================================================
2394 void Synchronize()
2395 {
2396 SetSynchDirty();
2397 }
2398
2399 override void OnVariablesSynchronized()
2400 {
2401 super.OnVariablesSynchronized();
2402
2403 //UpdateVisualsEx(); //performed on client only
2404
2405 //update audio
2407 {
2408 RefreshAudio();
2409 }
2410 else
2411 {
2412 RemoveAudio();
2413 }
2414
2415 if (CanHaveTemperature())
2417 }
2418
2419 //================================================================
2420 // AUDIO EFFECTS (WHEN ON DCS)
2421 //================================================================
2422 void MakeSoundsOnClient(bool soundstate, CookingMethodType cookingMethod = CookingMethodType.NONE)
2423 {
2424 m_MakeCookingSounds = soundstate;
2425 m_CookedByMethod = cookingMethod;
2426
2427 Synchronize();
2428 }
2429
2430 protected void RefreshAudio()
2431 {
2432 string soundName = "";
2433
2434 FoodStageType currentFoodStage = GetFoodStageType();
2436
2437 if (currentFoodStage == FoodStageType.BURNED)
2438 {
2439 soundName = SOUND_BURNING_DONE;
2440 }
2441 else
2442 {
2443 switch (m_CookedByMethod)
2444 {
2445 case CookingMethodType.BAKING:
2446 {
2447 if (nextFoodStage == FoodStageType.BAKED)
2448 soundName = SOUND_BAKING_START;
2449 else if (currentFoodStage == FoodStageType.BAKED)
2450 soundName = SOUND_BAKING_DONE;
2451 else
2452 soundName = "";
2453 break;
2454 }
2455
2456 case CookingMethodType.BOILING:
2457 {
2458 if (nextFoodStage == FoodStageType.BOILED)
2459 soundName = SOUND_BOILING_START;
2460 else if (currentFoodStage == FoodStageType.BOILED)
2461 soundName = SOUND_BOILING_DONE;
2462 else
2463 soundName = "";
2464 break;
2465 }
2466
2467 case CookingMethodType.DRYING:
2468 {
2469 if (nextFoodStage == FoodStageType.DRIED)
2470 soundName = SOUND_DRYING_START;
2471 else if (currentFoodStage == FoodStageType.DRIED)
2472 soundName = SOUND_DRYING_DONE;
2473 else
2474 soundName = "";
2475 break;
2476 }
2477
2478 default:
2479 soundName = "";
2480 break;
2481 }
2482
2483 if (nextFoodStage == FoodStageType.BURNED)
2484 {
2485 if (soundName == "") //on 'bad' transitions only, indicates bad outcome
2486 {
2487 soundName = SOUND_BURNING_DONE;
2488 }
2489 else // pre-emptive burning sounds replace regular ones
2490 {
2491 array<float> nextStageProperties = new array<float>();
2492 nextStageProperties = FoodStage.GetAllCookingPropertiesForStage(nextFoodStage, null, GetType());
2493 float nextStageTime = nextStageProperties.Get(eCookingPropertyIndices.COOK_TIME);
2494 float progress01 = GetCookingTime() / nextStageTime;
2495 if (progress01 > Cooking.BURNING_WARNING_THRESHOLD)
2496 {
2497 soundName = SOUND_BURNING_DONE;
2498 }
2499 }
2500 }
2501 }
2502
2503 SoundCookingStart(soundName);
2504 }
2505
2506 protected void RemoveAudio()
2507 {
2508 m_MakeCookingSounds = false;
2510 }
2511
2512 //================================================================
2513 // SERIALIZATION
2514 //================================================================
2515 override void OnStoreSave(ParamsWriteContext ctx)
2516 {
2517 super.OnStoreSave(ctx);
2518
2519 if (GetFoodStage())
2520 {
2521 GetFoodStage().OnStoreSave(ctx);
2522 }
2523
2524 // food decay
2525 ctx.Write(m_DecayTimer);
2527 }
2528
2529 override bool OnStoreLoad(ParamsReadContext ctx, int version)
2530 {
2531 if (!super.OnStoreLoad(ctx, version))
2532 return false;
2533
2534 if (GetFoodStage())
2535 {
2536 if (!GetFoodStage().OnStoreLoad(ctx, version))
2537 return false;
2538 }
2539
2540 if (version >= 115)
2541 {
2542 if (!ctx.Read(m_DecayTimer))
2543 {
2544 m_DecayTimer = 0.0;
2545 return false;
2546 }
2547 if (!ctx.Read(m_LastDecayStage))
2548 {
2550 return false;
2551 }
2552 }
2553
2554 UpdateVisualsEx(true); //forced init visuals
2555 Synchronize();
2556
2557 return true;
2558 }
2559
2560 override void AfterStoreLoad()
2561 {
2562 super.AfterStoreLoad();
2563
2564 Synchronize();
2565 }
2566
2567 //get food stage
2568 override FoodStage GetFoodStage()
2569 {
2570 return m_FoodStage;
2571 }
2572
2573 //food types
2574 override bool IsMeat()
2575 {
2576 return false;
2577 }
2578
2579 override bool IsCorpse()
2580 {
2581 return false;
2582 }
2583
2584 override bool IsFruit()
2585 {
2586 return false;
2587 }
2588
2589 override bool IsMushroom()
2590 {
2591 return false;
2592 }
2593
2594 //================================================================
2595 // NUTRITIONAL VALUES
2596 //================================================================
2597 //food properties
2598 static float GetFoodTotalVolume(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.GetFullnessIndex(food_item.GetFoodStage());
2604 }
2605 else if (classname != "" && food_stage)
2606 {
2607 return FoodStage.GetFullnessIndex(null, food_stage, classname);
2608 }
2609 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
2610 return GetGame().ConfigGetFloat( class_path + " fullnessIndex" );
2611
2612 }
2613
2614 static float GetFoodEnergy(ItemBase item, string classname = "", int food_stage = 0)
2615 {
2616 Edible_Base food_item = Edible_Base.Cast(item);
2617 if (food_item && food_item.GetFoodStage())
2618 {
2619 return FoodStage.GetEnergy(food_item.GetFoodStage());
2620 }
2621 else if (classname != "" && food_stage)
2622 {
2623 return FoodStage.GetEnergy(null, food_stage, classname);
2624 }
2625 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
2626 return GetGame().ConfigGetFloat( class_path + " energy" );
2627 }
2628
2629 static float GetFoodWater(ItemBase item, string classname = "", int food_stage = 0)
2630 {
2631 Edible_Base food_item = Edible_Base.Cast(item);
2632 if (food_item && food_item.GetFoodStage())
2633 {
2634 return FoodStage.GetWater(food_item.GetFoodStage());
2635 }
2636 else if (classname != "" && food_stage)
2637 {
2638 return FoodStage.GetWater(null, food_stage, classname);
2639 }
2640 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
2641 return GetGame().ConfigGetFloat( class_path + " water" );
2642 }
2643
2644 static float GetFoodNutritionalIndex(ItemBase item, string classname = "", int food_stage = 0)
2645 {
2646 Edible_Base food_item = Edible_Base.Cast(item);
2647 if (food_item && food_item.GetFoodStage())
2648 {
2649 return FoodStage.GetNutritionalIndex(food_item.GetFoodStage());
2650 }
2651 else if (classname != "" && food_stage)
2652 {
2653 return FoodStage.GetNutritionalIndex(null, food_stage, classname);
2654 }
2655 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
2656 return GetGame().ConfigGetFloat( class_path + " nutritionalIndex" );
2657
2658 }
2659
2660 static float GetFoodToxicity(ItemBase item, string classname = "", int food_stage = 0)
2661 {
2662 Edible_Base food_item = Edible_Base.Cast(item);
2663 if (food_item && food_item.GetFoodStage())
2664 {
2665 return FoodStage.GetToxicity(food_item.GetFoodStage());
2666 }
2667 else if (classname != "" && food_stage)
2668 {
2669 return FoodStage.GetToxicity(null, food_stage, classname);
2670 }
2671 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
2672 return GetGame().ConfigGetFloat( class_path + " toxicity" );
2673 }
2674
2675 static int GetFoodAgents(ItemBase item, string classname = "", int food_stage = 0)
2676 {
2677 Edible_Base food_item = Edible_Base.Cast(item);
2678 if (food_item && food_item.GetFoodStage())
2679 {
2680 return FoodStage.GetAgents(food_item.GetFoodStage());
2681 }
2682 else if (classname != "" && food_stage)
2683 {
2684 return FoodStage.GetAgents(null, food_stage, classname);
2685 }
2686 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
2687 return GetGame().ConfigGetInt( class_path + " agents" );
2688 }
2689
2690 static float GetFoodDigestibility(ItemBase item, string classname = "", int food_stage = 0)
2691 {
2692 Edible_Base food_item = Edible_Base.Cast(item);
2693 if (food_item && food_item.GetFoodStage())
2694 {
2695 return FoodStage.GetDigestibility(food_item.GetFoodStage());
2696 }
2697 else if (classname != "" && food_stage)
2698 {
2699 return FoodStage.GetDigestibility(null, food_stage, classname);
2700 }
2701 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
2702 return GetGame().ConfigGetInt( class_path + " digestibility" );
2703 }
2704
2705 static float GetAgentsPerDigest(ItemBase item, string className = "", int foodStage = 0)
2706 {
2707 Edible_Base foodItem = Edible_Base.Cast(item);
2708 if (foodItem && foodItem.GetFoodStage())
2709 {
2710 return FoodStage.GetAgentsPerDigest(foodItem.GetFoodStage());
2711 }
2712 else if (className != "" && foodStage)
2713 {
2714 return FoodStage.GetAgentsPerDigest(null, foodStage, className);
2715 }
2716 string classPath = string.Format("cfgVehicles %1 Nutrition", className);
2717 return GetGame().ConfigGetInt(classPath + " agentsPerDigest");
2718 }
2719
2720 static NutritionalProfile GetNutritionalProfile(ItemBase item, string classname = "", int food_stage = 0)
2721 {
2722 NutritionalProfile profile = new NutritionalProfile();
2723 profile.m_Energy = GetFoodEnergy(item, classname, food_stage);
2724 profile.m_WaterContent = GetFoodWater(item, classname, food_stage);
2725 profile.m_NutritionalIndex = GetFoodNutritionalIndex(item, classname, food_stage);
2726 profile.m_FullnessIndex = GetFoodTotalVolume(item, classname, food_stage);
2727 profile.m_Toxicity = GetFoodToxicity(item, classname, food_stage);
2728 profile.m_Agents = GetFoodAgents(item, classname, food_stage);
2729 profile.m_Digestibility = GetFoodDigestibility(item, classname, food_stage);
2730 profile.m_AgentsPerDigest = GetAgentsPerDigest(item, classname, food_stage);
2731
2732 return profile;
2733 }
2734
2735 //================================================================
2736 // FOOD STAGING
2737 //================================================================
2739 {
2740 return GetFoodStage().GetFoodStageType();
2741 }
2742
2743 //food stage states
2744 bool IsFoodRaw()
2745 {
2746 if ( GetFoodStage() )
2747 {
2748 return GetFoodStage().IsFoodRaw();
2749 }
2750
2751 return false;
2752 }
2753
2754 bool IsFoodBaked()
2755 {
2756 if ( GetFoodStage() )
2757 {
2758 return GetFoodStage().IsFoodBaked();
2759 }
2760
2761 return false;
2762 }
2763
2764 bool IsFoodBoiled()
2765 {
2766 if ( GetFoodStage() )
2767 {
2768 return GetFoodStage().IsFoodBoiled();
2769 }
2770
2771 return false;
2772 }
2773
2774 bool IsFoodDried()
2775 {
2776 if ( GetFoodStage() )
2777 {
2778 return GetFoodStage().IsFoodDried();
2779 }
2780
2781 return false;
2782 }
2783
2784 bool IsFoodBurned()
2785 {
2786 if ( GetFoodStage() )
2787 {
2788 return GetFoodStage().IsFoodBurned();
2789 }
2790
2791 return false;
2792 }
2793
2794 bool IsFoodRotten()
2795 {
2796 if ( GetFoodStage() )
2797 {
2798 return GetFoodStage().IsFoodRotten();
2799 }
2800
2801 return false;
2802 }
2803
2804 //food stage change
2805 void ChangeFoodStage( FoodStageType new_food_stage_type )
2806 {
2807 GetFoodStage().ChangeFoodStage( new_food_stage_type );
2808 }
2809
2811 {
2812 return GetFoodStage().GetNextFoodStageType( cooking_method );
2813 }
2814
2815 string GetFoodStageName( FoodStageType food_stage_type )
2816 {
2817 return GetFoodStage().GetFoodStageName( food_stage_type );
2818 }
2819
2820 bool CanChangeToNewStage( CookingMethodType cooking_method )
2821 {
2822 return GetFoodStage().CanChangeToNewStage( cooking_method );
2823 }
2824
2825 //Use this to receive food stage from another Edible_Base
2826 void TransferFoodStage( notnull Edible_Base source )
2827 {
2828 if ( !source.GetFoodStage())
2829 return;
2830 m_LastDecayStage = source.GetLastDecayStage();
2831 ChangeFoodStage(source.GetFoodStage().GetFoodStageType());
2832 m_DecayTimer = source.GetDecayTimer();
2833 m_DecayDelta = source.GetDecayDelta();
2834 }
2835
2837 void OnFoodStageChange(FoodStageType stageOld, FoodStageType stageNew)
2838 {
2839 HandleFoodStageChangeAgents(stageOld,stageNew);
2840 UpdateVisualsEx(); //performed on server only
2841 }
2842
2845 {
2846 switch (stageNew)
2847 {
2848 case FoodStageType.BAKED:
2849 case FoodStageType.BOILED:
2850 case FoodStageType.DRIED:
2851 RemoveAllAgentsExcept(eAgents.BRAIN|eAgents.HEAVYMETAL);
2852 break;
2853
2854 case FoodStageType.BURNED:
2855 RemoveAllAgentsExcept(eAgents.BRAIN|eAgents.HEAVYMETAL);
2856 break;
2857 }
2858 }
2859
2860 //================================================================
2861 // COOKING
2862 //================================================================
2863 //cooking time
2864 float GetCookingTime()
2865 {
2866 return GetFoodStage().GetCookingTime();
2867 }
2868
2869 void SetCookingTime( float time )
2870 {
2871 GetFoodStage().SetCookingTime( time );
2872
2873 //synchronize when calling on server
2874 Synchronize();
2875 }
2876
2877 void ResetCookingTime()
2878 {
2879 if (GetFoodStage())
2880 {
2881 GetFoodStage().SetCookingTime(0);
2882 Synchronize();
2883 }
2884 }
2885
2886 //replace edible with new item (opening cans)
2887 void ReplaceEdibleWithNew( string typeName )
2888 {
2889 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
2890 if (player)
2891 {
2892 ReplaceEdibleWithNewLambda lambda = new ReplaceEdibleWithNewLambda(this, typeName, player);
2893 player.ServerReplaceItemInHandsWithNew(lambda);
2894 }
2895 else
2896 Error("ReplaceEdibleWithNew - cannot use edible without player");
2897 }
2898
2900 {
2902 }
2903
2904 override void SetActions()
2905 {
2906 super.SetActions();
2907
2910 }
2911
2912 protected void SoundCookingStart(string sound_name)
2913 {
2914 #ifndef SERVER
2915 if (m_SoundPlaying != sound_name)
2916 {
2918
2919 m_SoundEffectCooking = SEffectManager.PlaySound(sound_name, GetPosition(), 0, 0, true);
2920 m_SoundPlaying = sound_name;
2921 }
2922 #endif
2923 }
2924
2925 protected void SoundCookingStop()
2926 {
2927 #ifndef SERVER
2929 {
2930 m_SoundEffectCooking.Stop();
2931 m_SoundEffectCooking = null;
2932 m_SoundPlaying = "";
2933 }
2934 #endif
2935 }
2936
2937 override bool CanDecay()
2938 {
2939 return false;
2940 }
2941
2942 override bool CanProcessDecay()
2943 {
2944 return !GetIsFrozen() && ( GetFoodStageType() != FoodStageType.ROTTEN );
2945 }
2946
2947 override void ProcessDecay( float delta, bool hasRootAsPlayer )
2948 {
2949 m_DecayDelta = 0.0;
2950
2951 delta *= DayZGame.Cast(GetGame()).GetFoodDecayModifier();
2952 m_DecayDelta += ( 1 + ( 1 - GetHealth01( "", "" ) ) );
2953 if ( hasRootAsPlayer )
2955
2956 /*Print( "-------------------------" );
2957 Print( this );
2958 Print( m_DecayTimer );
2959 Print( m_DecayDelta );
2960 Print( m_LastDecayStage );*/
2961
2962 if ( IsFruit() || IsMushroom() )
2963 {
2964 // fruit, vegetables and mushrooms
2966 {
2967 switch ( GetFoodStageType() )
2968 {
2969 case FoodStageType.RAW:
2972 break;
2973
2974 case FoodStageType.BOILED:
2977 break;
2978
2979 case FoodStageType.BAKED:
2982 break;
2983
2984 case FoodStageType.DRIED:
2985 case FoodStageType.BURNED:
2986 case FoodStageType.ROTTEN:
2987 default:
2988 m_DecayTimer = -1;
2990 return;
2991 }
2992
2993 //m_DecayTimer = m_DecayTimer / 1000.0;
2994 }
2995
2996 m_DecayTimer -= ( delta * m_DecayDelta );
2997
2998 if ( m_DecayTimer <= 0 )
2999 {
3000 if ( m_LastDecayStage != FoodStageType.NONE )
3001 {
3002 // switch to decayed stage
3003 if ( ( m_LastDecayStage == FoodStageType.BOILED ) || ( m_LastDecayStage == FoodStageType.BAKED ) )
3004 {
3006 }
3007 if ( m_LastDecayStage == FoodStageType.RAW )
3008 {
3009 int rng = Math.RandomIntInclusive( 0, 100 );
3011 {
3013 }
3014 else
3015 {
3016 if ( CanChangeToNewStage( FoodStageType.DRIED ) )
3017 {
3019 }
3020 else
3021 {
3023 }
3024 }
3025 }
3026 }
3027 }
3028
3029 }
3030 else if ( IsMeat() )
3031 {
3032 // meat
3034 {
3035 switch ( GetFoodStageType() )
3036 {
3037 case FoodStageType.RAW:
3040 break;
3041
3042 case FoodStageType.BOILED:
3045 break;
3046
3047 case FoodStageType.BAKED:
3050 break;
3051
3052 case FoodStageType.DRIED:
3055 break;
3056
3057 case FoodStageType.BURNED:
3058 case FoodStageType.ROTTEN:
3059 default:
3060 m_DecayTimer = -1;
3062 return;
3063 }
3064 }
3065
3066 m_DecayTimer -= ( delta * m_DecayDelta );
3067
3068 if ( m_DecayTimer <= 0 )
3069 {
3070 if ( m_LastDecayStage != FoodStageType.NONE )
3071 {
3072 // switch to decayed stage
3073 if ( ( m_LastDecayStage == FoodStageType.DRIED ) || ( m_LastDecayStage == FoodStageType.RAW ) || ( m_LastDecayStage == FoodStageType.BOILED ) || ( m_LastDecayStage == FoodStageType.BAKED ) )
3074 {
3076 }
3077 }
3078 }
3079 }
3080 else if ( IsCorpse() )
3081 {
3082 // corpse
3084 {
3085 switch ( GetFoodStageType() )
3086 {
3087 case FoodStageType.RAW:
3090 break;
3091
3092 case FoodStageType.BURNED:
3093 case FoodStageType.ROTTEN:
3094 default:
3095 m_DecayTimer = -1;
3097 return;
3098 }
3099 }
3100
3101 m_DecayTimer -= ( delta * m_DecayDelta );
3102
3103 if ( m_DecayTimer <= 0 )
3104 {
3105 if ( m_LastDecayStage != FoodStageType.NONE )
3106 {
3107 // switch to decayed stage
3108 if ( ( m_LastDecayStage == FoodStageType.DRIED ) || ( m_LastDecayStage == FoodStageType.RAW ) || ( m_LastDecayStage == FoodStageType.BOILED ) || ( m_LastDecayStage == FoodStageType.BAKED ) )
3109 {
3111 }
3112 }
3113 }
3114 }
3115 else
3116 {
3117 // opened cans
3118 m_DecayTimer -= ( delta * m_DecayDelta );
3119
3120 if ( ( m_DecayTimer <= 0 ) && ( m_LastDecayStage == FoodStageType.NONE ) )
3121 {
3124 //m_DecayTimer = m_DecayTimer / 1000.0;
3125 }
3126 else
3127 {
3128 if ( m_DecayTimer <= 0 )
3129 {
3130 InsertAgent(eAgents.FOOD_POISON, 1);
3131 m_DecayTimer = -1;
3132 }
3133 }
3134 }
3135 }
3136
3137 protected void UpdateVaporParticle()
3138 {
3139 if (GetGame().IsDedicatedServer())
3140 return;
3141
3142 if (m_VarTemperature >= GameConstants.STATE_HOT_LVL_TWO && !m_HotVaporParticle)
3143 {
3144 InventoryLocation invLoc = new InventoryLocation();
3145 GetInventory().GetCurrentInventoryLocation(invLoc);
3146 if (invLoc && (invLoc.GetType() == InventoryLocationType.GROUND || invLoc.GetType() == InventoryLocationType.HANDS || invLoc.GetType() == InventoryLocationType.ATTACHMENT))
3147 {
3148 ParticleManager ptcMgr = ParticleManager.GetInstance();
3149 if (ptcMgr)
3150 {
3151 m_HotVaporParticle = ParticleManager.GetInstance().PlayOnObject(ParticleList.ITEM_HOT_VAPOR, this);
3152 m_HotVaporParticle.SetParticleParam(EmitorParam.SIZE, 0.3);
3153 m_HotVaporParticle.SetParticleParam(EmitorParam.BIRTH_RATE, 10);
3154 m_HotVaporParticle.SetParticleAutoDestroyFlags(ParticleAutoDestroyFlags.ON_STOP);
3155 }
3156 }
3157 }
3158 else if (m_HotVaporParticle)
3159 {
3160 if (m_VarTemperature <= GameConstants.STATE_HOT_LVL_TWO)
3161 {
3162 m_HotVaporParticle.Stop();
3163 m_HotVaporParticle = null;
3164 return;
3165 }
3166
3167 InventoryLocation inventoryLoc = new InventoryLocation();
3168 GetInventory().GetCurrentInventoryLocation(inventoryLoc);
3169 if (invLoc && (invLoc.GetType() != InventoryLocationType.GROUND && invLoc.GetType() != InventoryLocationType.HANDS))
3170 {
3171 m_HotVaporParticle.Stop();
3172 m_HotVaporParticle = null;
3173 }
3174 }
3175 }
3176
3177 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
3178 {
3179 super.GetDebugActions(outputList);
3180
3181 if (GetFoodStage())
3182 {
3183 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FOOD_NUTRITIONS_DATA, "Food Nutritions Data", FadeColors.WHITE));
3184 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FOOD_STAGE_PREV, "Food Stage Prev", FadeColors.WHITE));
3185 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FOOD_STAGE_NEXT, "Food Stage Next", FadeColors.WHITE));
3186 }
3187 }
3188
3189 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
3190 {
3191 super.OnAction(action_id, player, ctx);
3192
3193 if ( GetGame().IsServer() )
3194 {
3195 if ( action_id == EActions.FOOD_STAGE_PREV )
3196 {
3197 int food_stage_prev = GetFoodStageType() - 1;
3198 if (food_stage_prev <= 0)
3199 {
3200 food_stage_prev = FoodStageType.COUNT - 1;
3201 }
3202 ChangeFoodStage(food_stage_prev);
3203 return true;
3204 }
3205 else if ( action_id == EActions.FOOD_STAGE_NEXT )
3206 {
3207 int food_stage_next = GetFoodStageType() + 1;
3208 if (food_stage_next >= FoodStageType.COUNT )
3209 {
3210 food_stage_next = FoodStageType.RAW;
3211 }
3212 ChangeFoodStage(food_stage_next);
3213 return true;
3214 }
3215
3216 }
3217
3218 #ifdef DIAG_DEVELOPER
3219 if (action_id == EActions.FOOD_NUTRITIONS_DATA)
3220 {
3221 PrintNutritionsData();
3222 return true;
3223 }
3224 #endif
3225
3226 return false;
3227 }
3228
3229 override string GetDebugText()
3230 {
3231 string debug_output;
3232
3233 debug_output = super.GetDebugText();
3234
3235 debug_output+="m_CookedByMethod:"+m_CookedByMethod+"\n";
3236 debug_output+="m_MakeCookingSounds:"+m_MakeCookingSounds+"\n";
3237
3238 return debug_output;
3239 }
3240
3241 //================================================================
3242 // GENERAL GETTERS
3243 //================================================================
3244
3245 override float GetBaitEffectivity()
3246 {
3247 float ret = super.GetBaitEffectivity();
3248
3249 if (IsFoodRotten())
3250 {
3251 ret *= 0.5;
3252 }
3253
3254 return ret;
3255 }
3256
3257 float GetDecayTimer()
3258 {
3259 return m_DecayTimer;
3260 }
3261
3262 float GetDecayDelta()
3263 {
3264 return m_DecayDelta;
3265 }
3266
3268 {
3269 return m_LastDecayStage;
3270 }
3271
3272 #ifdef DIAG_DEVELOPER
3273 private void PrintNutritionsData()
3274 {
3275 string nutritionsData = "";
3276
3277 FoodStage stage = GetFoodStage();
3278 FoodStageType stageType = stage.GetFoodStageType();
3279
3280 NutritionalProfile profile = GetNutritionalProfile(this, ClassName(), stageType);
3281 if (profile)
3282 {
3283 nutritionsData = string.Format("Item: %1\n\n", this);
3284 nutritionsData += string.Format("Stage name: %1\n", GetFoodStageName(stageType));
3285 nutritionsData += string.Format("Energy: %1\n", profile.m_Energy);
3286 nutritionsData += string.Format("Water content: %1\n", profile.m_WaterContent);
3287 nutritionsData += string.Format("Nutritional index: %1\n", profile.m_NutritionalIndex);
3288 nutritionsData += string.Format("Fullness index: %1\n", profile.m_FullnessIndex);
3289 nutritionsData += string.Format("Toxicity (obsolete): %1\n", profile.m_Toxicity);
3290 nutritionsData += string.Format("Digestibility: %1\n", profile.m_Digestibility);
3291
3292 if (profile.IsLiquid())
3293 nutritionsData += string.Format("Liquid type: %1\n", profile.m_LiquidClassname);
3294
3295 nutritionsData += string.Format("Agents: %1\n", profile.m_Agents);
3296 nutritionsData += string.Format("Agents per consume: %1\n", profile.m_AgentsPerDigest);
3297 }
3298
3299 nutritionsData += "-----\n";
3300
3301 Debug.Log(nutritionsData);
3302 }
3303 #endif
3304
3306 //DEPRECATED
3308 void UpdateVisuals()
3309 {
3311 }
3312}
3313
3315{
3316 void ReplaceEdibleWithNewLambda(EntityAI old_item, string new_item_type, PlayerBase player) { }
3317};
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.