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

◆ UpdateVisuals()

void ReplaceEdibleWithNewLambda::UpdateVisuals ( )
protected

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

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