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

◆ SoundCookingStop()

void ReplaceEdibleWithNewLambda::SoundCookingStop ( )
protected

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

1826 : ItemBase
1827{
1828 const string DIRECT_COOKING_SLOT_NAME = "DirectCooking";
1829
1830 const string SOUND_BAKING_START = "Baking_SoundSet";
1831 const string SOUND_BAKING_DONE = "Baking_Done_SoundSet";
1832 const string SOUND_BOILING_START = "Boiling_SoundSet";
1833 const string SOUND_BOILING_DONE = "Boiling_Done_SoundSet";
1834 const string SOUND_DRYING_START = "Drying_SoundSet";
1835 const string SOUND_DRYING_DONE = "Drying_Done_SoundSet";
1836 const string SOUND_BURNING_DONE = "Food_Burning_SoundSet";
1837
1838 protected bool m_MakeCookingSounds;
1839 protected SoundOnVehicle m_SoundCooking;
1841 protected string m_SoundPlaying;
1842 ref FoodStage m_FoodStage;
1843 protected float m_DecayTimer;
1844 protected float m_DecayDelta = 0.0;
1847
1849
1850 void Edible_Base()
1851 {
1852 if (HasFoodStage())
1853 {
1854 m_FoodStage = new FoodStage(this);
1855
1856 RegisterNetSyncVariableInt("m_FoodStage.m_FoodStageType", FoodStageType.NONE, FoodStageType.COUNT);
1857 RegisterNetSyncVariableFloat("m_FoodStage.m_CookingTime", 0, 600, 0);
1858
1859 m_SoundPlaying = "";
1861 RegisterNetSyncVariableInt("m_CookedByMethod", CookingMethodType.NONE, CookingMethodType.COUNT);
1862 RegisterNetSyncVariableBool("m_MakeCookingSounds");
1863 }
1864 }
1865
1866 override void EEInit()
1867 {
1868 super.EEInit();
1869
1870 UpdateVisualsEx(true); //forced init visuals, mostly for debugs and SP
1871 }
1872
1873 override void EEDelete(EntityAI parent)
1874 {
1875 super.EEDelete(parent);
1876
1877 RemoveAudio();
1878
1880 m_HotVaporParticle.Stop();
1881 }
1882
1883 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
1884 {
1885 super.EEItemLocationChanged(oldLoc, newLoc);
1886
1888 if (oldLoc.GetType() == InventoryLocationType.ATTACHMENT || oldLoc.GetType() == InventoryLocationType.CARGO)
1889 {
1890 switch (oldLoc.GetParent().GetType())
1891 {
1892 case "FryingPan":
1893 case "Pot":
1894 case "Cauldron":
1895 case "SharpWoodenStick":
1896 MakeSoundsOnClient(false);
1897 break;
1898 }
1899
1901 if (oldLoc.GetSlot() > -1 && InventorySlots.GetSlotName(oldLoc.GetSlot()).Contains(DIRECT_COOKING_SLOT_NAME))
1902 {
1903 MakeSoundsOnClient(false);
1904 }
1905 }
1906
1907 if (oldLoc.IsValid())
1909
1910 if (CanHaveTemperature())
1912 }
1913
1914 void UpdateVisualsEx(bool forced = false)
1915 {
1916 if (GetFoodStage())
1917 GetFoodStage().UpdateVisualsEx(forced);
1918 }
1919
1920 bool Consume(float amount, PlayerBase consumer)
1921 {
1922 AddQuantity(-amount, false, false);
1923 OnConsume(amount, consumer);
1924
1925 return true;
1926 }
1927
1928 void OnConsume(float amount, PlayerBase consumer)
1929 {
1931 {
1932 consumer.ProcessDirectDamage(DamageType.CUSTOM, this, "", "EnviroDmg", "0 0 0", PlayerConstants.CONSUMPTION_DAMAGE_PER_BITE);
1933 }
1934 }
1935
1937 int FilterAgents(int agentsIn)
1938 {
1939 int foodStageType;
1940
1941 FoodStage foodStage = GetFoodStage();
1942 if (foodStage)
1943 foodStageType = foodStage.GetFoodStageType();
1944
1946 NutritionalProfile nutritionalProfile = GetNutritionalProfile(this, ClassName(), foodStageType);
1947 if ((agentsIn & eAgents.SALMONELLA == eAgents.SALMONELLA) && (nutritionalProfile.m_Agents == 0 || nutritionalProfile.m_AgentsPerDigest == 0))
1948 agentsIn &= ~eAgents.FOOD_POISON;
1949
1950 return agentsIn;
1951 }
1952
1953 //food staging
1954 override bool CanBeCooked()
1955 {
1956 return false;
1957 }
1958
1959 override bool CanBeCookedOnStick()
1960 {
1961 return false;
1962 }
1963
1964 override float GetTemperatureFreezeTime()
1965 {
1966 if (GetFoodStage())
1967 {
1968 switch (m_FoodStage.GetFoodStageType())
1969 {
1970 case FoodStageType.DRIED:
1971 return super.GetTemperatureFreezeTime() * GameConstants.TEMPERATURE_FREEZE_TIME_COEF_DRIED;
1972
1973 case FoodStageType.BURNED:
1974 return super.GetTemperatureFreezeTime() * GameConstants.TEMPERATURE_FREEZE_TIME_COEF_BURNED;
1975
1976 default:
1977 return super.GetTemperatureFreezeTime();
1978 }
1979 }
1980
1981 return super.GetTemperatureFreezeTime();
1982 }
1983
1984 override float GetTemperatureThawTime()
1985 {
1986 if (GetFoodStage())
1987 {
1988 switch (m_FoodStage.GetFoodStageType())
1989 {
1990 case FoodStageType.DRIED:
1991 return super.GetTemperatureThawTime() * GameConstants.TEMPERATURE_THAW_TIME_COEF_DRIED;
1992
1993 case FoodStageType.BURNED:
1994 return super.GetTemperatureThawTime() * GameConstants.TEMPERATURE_THAW_TIME_COEF_BURNED;
1995
1996 default:
1997 return super.GetTemperatureThawTime();
1998 }
1999 }
2000
2001 return super.GetTemperatureThawTime();
2002 }
2003
2004 override bool CanItemOverheat()
2005 {
2006 return super.CanItemOverheat() && (!GetFoodStage() || (IsFoodBurned() || !GetFoodStage().CanTransitionToFoodStageType(FoodStageType.BURNED))); //for foodstaged items - either is burned, or it can't get burned
2007 }
2008
2009 //================================================================
2010 // SYNCHRONIZATION
2011 //================================================================
2012 void Synchronize()
2013 {
2014 SetSynchDirty();
2015 }
2016
2017 override void OnVariablesSynchronized()
2018 {
2019 super.OnVariablesSynchronized();
2020
2021 //UpdateVisualsEx(); //performed on client only
2022
2023 //update audio
2025 {
2026 RefreshAudio();
2027 }
2028 else
2029 {
2030 RemoveAudio();
2031 }
2032
2033 if (CanHaveTemperature())
2035 }
2036
2037 //================================================================
2038 // AUDIO EFFECTS (WHEN ON DCS)
2039 //================================================================
2040 void MakeSoundsOnClient(bool soundstate, CookingMethodType cookingMethod = CookingMethodType.NONE)
2041 {
2042 m_MakeCookingSounds = soundstate;
2043 m_CookedByMethod = cookingMethod;
2044
2045 Synchronize();
2046 }
2047
2048 protected void RefreshAudio()
2049 {
2050 string soundName = "";
2051
2052 FoodStageType currentFoodStage = GetFoodStageType();
2054
2055 if (currentFoodStage == FoodStageType.BURNED)
2056 {
2057 soundName = SOUND_BURNING_DONE;
2058 }
2059 else
2060 {
2061 switch (m_CookedByMethod)
2062 {
2063 case CookingMethodType.BAKING:
2064 {
2065 if (nextFoodStage == FoodStageType.BAKED)
2066 soundName = SOUND_BAKING_START;
2067 else if (currentFoodStage == FoodStageType.BAKED)
2068 soundName = SOUND_BAKING_DONE;
2069 else
2070 soundName = "";
2071 break;
2072 }
2073
2074 case CookingMethodType.BOILING:
2075 {
2076 if (nextFoodStage == FoodStageType.BOILED)
2077 soundName = SOUND_BOILING_START;
2078 else if (currentFoodStage == FoodStageType.BOILED)
2079 soundName = SOUND_BOILING_DONE;
2080 else
2081 soundName = "";
2082 break;
2083 }
2084
2085 case CookingMethodType.DRYING:
2086 {
2087 if (nextFoodStage == FoodStageType.DRIED)
2088 soundName = SOUND_DRYING_START;
2089 else if (currentFoodStage == FoodStageType.DRIED)
2090 soundName = SOUND_DRYING_DONE;
2091 else
2092 soundName = "";
2093 break;
2094 }
2095
2096 default:
2097 soundName = "";
2098 break;
2099 }
2100
2101 if (nextFoodStage == FoodStageType.BURNED)
2102 {
2103 if (soundName == "") //on 'bad' transitions only, indicates bad outcome
2104 {
2105 soundName = SOUND_BURNING_DONE;
2106 }
2107 else // pre-emptive burning sounds replace regular ones
2108 {
2109 array<float> nextStageProperties = new array<float>();
2110 nextStageProperties = FoodStage.GetAllCookingPropertiesForStage(nextFoodStage, null, GetType());
2111 float nextStageTime = nextStageProperties.Get(eCookingPropertyIndices.COOK_TIME);
2112 float progress01 = GetCookingTime() / nextStageTime;
2113 if (progress01 > Cooking.BURNING_WARNING_THRESHOLD)
2114 {
2115 soundName = SOUND_BURNING_DONE;
2116 }
2117 }
2118 }
2119 }
2120
2121 SoundCookingStart(soundName);
2122 }
2123
2124 protected void RemoveAudio()
2125 {
2126 m_MakeCookingSounds = false;
2128 }
2129
2130 //================================================================
2131 // SERIALIZATION
2132 //================================================================
2133 override void OnStoreSave(ParamsWriteContext ctx)
2134 {
2135 super.OnStoreSave(ctx);
2136
2137 if (GetFoodStage())
2138 {
2139 GetFoodStage().OnStoreSave(ctx);
2140 }
2141
2142 // food decay
2143 ctx.Write(m_DecayTimer);
2145 }
2146
2147 override bool OnStoreLoad(ParamsReadContext ctx, int version)
2148 {
2149 if (!super.OnStoreLoad(ctx, version))
2150 return false;
2151
2152 if (GetFoodStage())
2153 {
2154 if (!GetFoodStage().OnStoreLoad(ctx, version))
2155 return false;
2156 }
2157
2158 if (version >= 115)
2159 {
2160 if (!ctx.Read(m_DecayTimer))
2161 {
2162 m_DecayTimer = 0.0;
2163 return false;
2164 }
2165 if (!ctx.Read(m_LastDecayStage))
2166 {
2168 return false;
2169 }
2170 }
2171
2172 UpdateVisualsEx(true); //forced init visuals
2173 Synchronize();
2174
2175 return true;
2176 }
2177
2178 override void AfterStoreLoad()
2179 {
2180 super.AfterStoreLoad();
2181
2182 Synchronize();
2183 }
2184
2185 //get food stage
2186 override FoodStage GetFoodStage()
2187 {
2188 return m_FoodStage;
2189 }
2190
2191 //food types
2192 override bool IsMeat()
2193 {
2194 return false;
2195 }
2196
2197 override bool IsCorpse()
2198 {
2199 return false;
2200 }
2201
2202 override bool IsFruit()
2203 {
2204 return false;
2205 }
2206
2207 override bool IsMushroom()
2208 {
2209 return false;
2210 }
2211
2212 //================================================================
2213 // NUTRITIONAL VALUES
2214 //================================================================
2215 //food properties
2216 static float GetFoodTotalVolume(ItemBase item, string classname = "", int food_stage = 0)
2217 {
2218 Edible_Base food_item = Edible_Base.Cast(item);
2219 if (food_item && food_item.GetFoodStage())
2220 {
2221 return FoodStage.GetFullnessIndex(food_item.GetFoodStage());
2222 }
2223 else if (classname != "" && food_stage)
2224 {
2225 return FoodStage.GetFullnessIndex(null, food_stage, classname);
2226 }
2227 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
2228 return GetGame().ConfigGetFloat( class_path + " fullnessIndex" );
2229
2230 }
2231
2232 static float GetFoodEnergy(ItemBase item, string classname = "", int food_stage = 0)
2233 {
2234 Edible_Base food_item = Edible_Base.Cast(item);
2235 if (food_item && food_item.GetFoodStage())
2236 {
2237 return FoodStage.GetEnergy(food_item.GetFoodStage());
2238 }
2239 else if (classname != "" && food_stage)
2240 {
2241 return FoodStage.GetEnergy(null, food_stage, classname);
2242 }
2243 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
2244 return GetGame().ConfigGetFloat( class_path + " energy" );
2245 }
2246
2247 static float GetFoodWater(ItemBase item, string classname = "", int food_stage = 0)
2248 {
2249 Edible_Base food_item = Edible_Base.Cast(item);
2250 if (food_item && food_item.GetFoodStage())
2251 {
2252 return FoodStage.GetWater(food_item.GetFoodStage());
2253 }
2254 else if (classname != "" && food_stage)
2255 {
2256 return FoodStage.GetWater(null, food_stage, classname);
2257 }
2258 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
2259 return GetGame().ConfigGetFloat( class_path + " water" );
2260 }
2261
2262 static float GetFoodNutritionalIndex(ItemBase item, string classname = "", int food_stage = 0)
2263 {
2264 Edible_Base food_item = Edible_Base.Cast(item);
2265 if (food_item && food_item.GetFoodStage())
2266 {
2267 return FoodStage.GetNutritionalIndex(food_item.GetFoodStage());
2268 }
2269 else if (classname != "" && food_stage)
2270 {
2271 return FoodStage.GetNutritionalIndex(null, food_stage, classname);
2272 }
2273 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
2274 return GetGame().ConfigGetFloat( class_path + " nutritionalIndex" );
2275
2276 }
2277
2278 static float GetFoodToxicity(ItemBase item, string classname = "", int food_stage = 0)
2279 {
2280 Edible_Base food_item = Edible_Base.Cast(item);
2281 if (food_item && food_item.GetFoodStage())
2282 {
2283 return FoodStage.GetToxicity(food_item.GetFoodStage());
2284 }
2285 else if (classname != "" && food_stage)
2286 {
2287 return FoodStage.GetToxicity(null, food_stage, classname);
2288 }
2289 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
2290 return GetGame().ConfigGetFloat( class_path + " toxicity" );
2291 }
2292
2293 static int GetFoodAgents(ItemBase item, string classname = "", int food_stage = 0)
2294 {
2295 Edible_Base food_item = Edible_Base.Cast(item);
2296 if (food_item && food_item.GetFoodStage())
2297 {
2298 return FoodStage.GetAgents(food_item.GetFoodStage());
2299 }
2300 else if (classname != "" && food_stage)
2301 {
2302 return FoodStage.GetAgents(null, food_stage, classname);
2303 }
2304 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
2305 return GetGame().ConfigGetInt( class_path + " agents" );
2306 }
2307
2308 static float GetFoodDigestibility(ItemBase item, string classname = "", int food_stage = 0)
2309 {
2310 Edible_Base food_item = Edible_Base.Cast(item);
2311 if (food_item && food_item.GetFoodStage())
2312 {
2313 return FoodStage.GetDigestibility(food_item.GetFoodStage());
2314 }
2315 else if (classname != "" && food_stage)
2316 {
2317 return FoodStage.GetDigestibility(null, food_stage, classname);
2318 }
2319 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
2320 return GetGame().ConfigGetInt( class_path + " digestibility" );
2321 }
2322
2323 static float GetAgentsPerDigest(ItemBase item, string className = "", int foodStage = 0)
2324 {
2325 Edible_Base foodItem = Edible_Base.Cast(item);
2326 if (foodItem && foodItem.GetFoodStage())
2327 {
2328 return FoodStage.GetAgentsPerDigest(foodItem.GetFoodStage());
2329 }
2330 else if (className != "" && foodStage)
2331 {
2332 return FoodStage.GetAgentsPerDigest(null, foodStage, className);
2333 }
2334 string classPath = string.Format("cfgVehicles %1 Nutrition", className);
2335 return GetGame().ConfigGetInt(classPath + " agentsPerDigest");
2336 }
2337
2338 static NutritionalProfile GetNutritionalProfile(ItemBase item, string classname = "", int food_stage = 0)
2339 {
2340 NutritionalProfile profile = new NutritionalProfile();
2341 profile.m_Energy = GetFoodEnergy(item, classname, food_stage);
2342 profile.m_WaterContent = GetFoodWater(item, classname, food_stage);
2343 profile.m_NutritionalIndex = GetFoodNutritionalIndex(item, classname, food_stage);
2344 profile.m_FullnessIndex = GetFoodTotalVolume(item, classname, food_stage);
2345 profile.m_Toxicity = GetFoodToxicity(item, classname, food_stage);
2346 profile.m_Agents = GetFoodAgents(item, classname, food_stage);
2347 profile.m_Digestibility = GetFoodDigestibility(item, classname, food_stage);
2348 profile.m_AgentsPerDigest = GetAgentsPerDigest(item, classname, food_stage);
2349
2350 return profile;
2351 }
2352
2353 //================================================================
2354 // FOOD STAGING
2355 //================================================================
2357 {
2358 return GetFoodStage().GetFoodStageType();
2359 }
2360
2361 //food stage states
2362 bool IsFoodRaw()
2363 {
2364 if ( GetFoodStage() )
2365 {
2366 return GetFoodStage().IsFoodRaw();
2367 }
2368
2369 return false;
2370 }
2371
2372 bool IsFoodBaked()
2373 {
2374 if ( GetFoodStage() )
2375 {
2376 return GetFoodStage().IsFoodBaked();
2377 }
2378
2379 return false;
2380 }
2381
2382 bool IsFoodBoiled()
2383 {
2384 if ( GetFoodStage() )
2385 {
2386 return GetFoodStage().IsFoodBoiled();
2387 }
2388
2389 return false;
2390 }
2391
2392 bool IsFoodDried()
2393 {
2394 if ( GetFoodStage() )
2395 {
2396 return GetFoodStage().IsFoodDried();
2397 }
2398
2399 return false;
2400 }
2401
2402 bool IsFoodBurned()
2403 {
2404 if ( GetFoodStage() )
2405 {
2406 return GetFoodStage().IsFoodBurned();
2407 }
2408
2409 return false;
2410 }
2411
2412 bool IsFoodRotten()
2413 {
2414 if ( GetFoodStage() )
2415 {
2416 return GetFoodStage().IsFoodRotten();
2417 }
2418
2419 return false;
2420 }
2421
2422 //food stage change
2423 void ChangeFoodStage( FoodStageType new_food_stage_type )
2424 {
2425 GetFoodStage().ChangeFoodStage( new_food_stage_type );
2426 }
2427
2429 {
2430 return GetFoodStage().GetNextFoodStageType( cooking_method );
2431 }
2432
2433 string GetFoodStageName( FoodStageType food_stage_type )
2434 {
2435 return GetFoodStage().GetFoodStageName( food_stage_type );
2436 }
2437
2438 bool CanChangeToNewStage( CookingMethodType cooking_method )
2439 {
2440 return GetFoodStage().CanChangeToNewStage( cooking_method );
2441 }
2442
2443 //Use this to receive food stage from another Edible_Base
2444 void TransferFoodStage( notnull Edible_Base source )
2445 {
2446 if ( !source.GetFoodStage())
2447 return;
2448 m_LastDecayStage = source.GetLastDecayStage();
2449 ChangeFoodStage(source.GetFoodStage().GetFoodStageType());
2450 m_DecayTimer = source.GetDecayTimer();
2451 m_DecayDelta = source.GetDecayDelta();
2452 }
2453
2455 void OnFoodStageChange(FoodStageType stageOld, FoodStageType stageNew)
2456 {
2457 HandleFoodStageChangeAgents(stageOld,stageNew);
2458 UpdateVisualsEx(); //performed on server only
2459 }
2460
2463 {
2464 switch (stageNew)
2465 {
2466 case FoodStageType.BAKED:
2467 case FoodStageType.BOILED:
2468 case FoodStageType.DRIED:
2469 RemoveAllAgentsExcept(eAgents.BRAIN|eAgents.HEAVYMETAL);
2470 break;
2471
2472 case FoodStageType.BURNED:
2473 RemoveAllAgentsExcept(eAgents.BRAIN|eAgents.HEAVYMETAL);
2474 break;
2475 }
2476 }
2477
2478 //================================================================
2479 // COOKING
2480 //================================================================
2481 //cooking time
2482 float GetCookingTime()
2483 {
2484 return GetFoodStage().GetCookingTime();
2485 }
2486
2487 void SetCookingTime( float time )
2488 {
2489 GetFoodStage().SetCookingTime( time );
2490
2491 //synchronize when calling on server
2492 Synchronize();
2493 }
2494
2495 void ResetCookingTime()
2496 {
2497 if (GetFoodStage())
2498 {
2499 GetFoodStage().SetCookingTime(0);
2500 Synchronize();
2501 }
2502 }
2503
2504 //replace edible with new item (opening cans)
2505 void ReplaceEdibleWithNew( string typeName )
2506 {
2507 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
2508 if (player)
2509 {
2510 ReplaceEdibleWithNewLambda lambda = new ReplaceEdibleWithNewLambda(this, typeName, player);
2511 player.ServerReplaceItemInHandsWithNew(lambda);
2512 }
2513 else
2514 Error("ReplaceEdibleWithNew - cannot use edible without player");
2515 }
2516
2518 {
2520 }
2521
2522 override void SetActions()
2523 {
2524 super.SetActions();
2525
2528 }
2529
2530 protected void SoundCookingStart(string sound_name)
2531 {
2532 #ifndef SERVER
2533 if (m_SoundPlaying != sound_name)
2534 {
2536
2537 m_SoundEffectCooking = SEffectManager.PlaySound(sound_name, GetPosition(), 0, 0, true);
2538 m_SoundPlaying = sound_name;
2539 }
2540 #endif
2541 }
2542
2543 protected void SoundCookingStop()
2544 {
2545 #ifndef SERVER
2547 {
2548 m_SoundEffectCooking.Stop();
2549 m_SoundEffectCooking = null;
2550 m_SoundPlaying = "";
2551 }
2552 #endif
2553 }
2554
2555 override bool CanDecay()
2556 {
2557 return false;
2558 }
2559
2560 override bool CanProcessDecay()
2561 {
2562 return !GetIsFrozen() && ( GetFoodStageType() != FoodStageType.ROTTEN );
2563 }
2564
2565 override void ProcessDecay( float delta, bool hasRootAsPlayer )
2566 {
2567 m_DecayDelta = 0.0;
2568
2569 delta *= DayZGame.Cast(GetGame()).GetFoodDecayModifier();
2570 m_DecayDelta += ( 1 + ( 1 - GetHealth01( "", "" ) ) );
2571 if ( hasRootAsPlayer )
2573
2574 /*Print( "-------------------------" );
2575 Print( this );
2576 Print( m_DecayTimer );
2577 Print( m_DecayDelta );
2578 Print( m_LastDecayStage );*/
2579
2580 if ( IsFruit() || IsMushroom() )
2581 {
2582 // fruit, vegetables and mushrooms
2584 {
2585 switch ( GetFoodStageType() )
2586 {
2587 case FoodStageType.RAW:
2590 break;
2591
2592 case FoodStageType.BOILED:
2595 break;
2596
2597 case FoodStageType.BAKED:
2600 break;
2601
2602 case FoodStageType.DRIED:
2603 case FoodStageType.BURNED:
2604 case FoodStageType.ROTTEN:
2605 default:
2606 m_DecayTimer = -1;
2608 return;
2609 }
2610
2611 //m_DecayTimer = m_DecayTimer / 1000.0;
2612 }
2613
2614 m_DecayTimer -= ( delta * m_DecayDelta );
2615
2616 if ( m_DecayTimer <= 0 )
2617 {
2618 if ( m_LastDecayStage != FoodStageType.NONE )
2619 {
2620 // switch to decayed stage
2621 if ( ( m_LastDecayStage == FoodStageType.BOILED ) || ( m_LastDecayStage == FoodStageType.BAKED ) )
2622 {
2624 }
2625 if ( m_LastDecayStage == FoodStageType.RAW )
2626 {
2627 int rng = Math.RandomIntInclusive( 0, 100 );
2629 {
2631 }
2632 else
2633 {
2634 if ( CanChangeToNewStage( FoodStageType.DRIED ) )
2635 {
2637 }
2638 else
2639 {
2641 }
2642 }
2643 }
2644 }
2645 }
2646
2647 }
2648 else if ( IsMeat() )
2649 {
2650 // meat
2652 {
2653 switch ( GetFoodStageType() )
2654 {
2655 case FoodStageType.RAW:
2658 break;
2659
2660 case FoodStageType.BOILED:
2663 break;
2664
2665 case FoodStageType.BAKED:
2668 break;
2669
2670 case FoodStageType.DRIED:
2673 break;
2674
2675 case FoodStageType.BURNED:
2676 case FoodStageType.ROTTEN:
2677 default:
2678 m_DecayTimer = -1;
2680 return;
2681 }
2682 }
2683
2684 m_DecayTimer -= ( delta * m_DecayDelta );
2685
2686 if ( m_DecayTimer <= 0 )
2687 {
2688 if ( m_LastDecayStage != FoodStageType.NONE )
2689 {
2690 // switch to decayed stage
2691 if ( ( m_LastDecayStage == FoodStageType.DRIED ) || ( m_LastDecayStage == FoodStageType.RAW ) || ( m_LastDecayStage == FoodStageType.BOILED ) || ( m_LastDecayStage == FoodStageType.BAKED ) )
2692 {
2694 }
2695 }
2696 }
2697 }
2698 else if ( IsCorpse() )
2699 {
2700 // corpse
2702 {
2703 switch ( GetFoodStageType() )
2704 {
2705 case FoodStageType.RAW:
2708 break;
2709
2710 case FoodStageType.BURNED:
2711 case FoodStageType.ROTTEN:
2712 default:
2713 m_DecayTimer = -1;
2715 return;
2716 }
2717 }
2718
2719 m_DecayTimer -= ( delta * m_DecayDelta );
2720
2721 if ( m_DecayTimer <= 0 )
2722 {
2723 if ( m_LastDecayStage != FoodStageType.NONE )
2724 {
2725 // switch to decayed stage
2726 if ( ( m_LastDecayStage == FoodStageType.DRIED ) || ( m_LastDecayStage == FoodStageType.RAW ) || ( m_LastDecayStage == FoodStageType.BOILED ) || ( m_LastDecayStage == FoodStageType.BAKED ) )
2727 {
2729 }
2730 }
2731 }
2732 }
2733 else
2734 {
2735 // opened cans
2736 m_DecayTimer -= ( delta * m_DecayDelta );
2737
2738 if ( ( m_DecayTimer <= 0 ) && ( m_LastDecayStage == FoodStageType.NONE ) )
2739 {
2742 //m_DecayTimer = m_DecayTimer / 1000.0;
2743 }
2744 else
2745 {
2746 if ( m_DecayTimer <= 0 )
2747 {
2748 InsertAgent(eAgents.FOOD_POISON, 1);
2749 m_DecayTimer = -1;
2750 }
2751 }
2752 }
2753 }
2754
2755 protected void UpdateVaporParticle()
2756 {
2757 if (GetGame().IsDedicatedServer())
2758 return;
2759
2760 if (m_VarTemperature >= GameConstants.STATE_HOT_LVL_TWO && !m_HotVaporParticle)
2761 {
2762 InventoryLocation invLoc = new InventoryLocation();
2763 GetInventory().GetCurrentInventoryLocation(invLoc);
2764 if (invLoc && (invLoc.GetType() == InventoryLocationType.GROUND || invLoc.GetType() == InventoryLocationType.HANDS || invLoc.GetType() == InventoryLocationType.ATTACHMENT))
2765 {
2766 ParticleManager ptcMgr = ParticleManager.GetInstance();
2767 if (ptcMgr)
2768 {
2769 m_HotVaporParticle = ParticleManager.GetInstance().PlayOnObject(ParticleList.ITEM_HOT_VAPOR, this);
2770 m_HotVaporParticle.SetParticleParam(EmitorParam.SIZE, 0.3);
2771 m_HotVaporParticle.SetParticleParam(EmitorParam.BIRTH_RATE, 10);
2772 m_HotVaporParticle.SetParticleAutoDestroyFlags(ParticleAutoDestroyFlags.ON_STOP);
2773 }
2774 }
2775 }
2776 else if (m_HotVaporParticle)
2777 {
2778 if (m_VarTemperature <= GameConstants.STATE_HOT_LVL_TWO)
2779 {
2780 m_HotVaporParticle.Stop();
2781 m_HotVaporParticle = null;
2782 return;
2783 }
2784
2785 InventoryLocation inventoryLoc = new InventoryLocation();
2786 GetInventory().GetCurrentInventoryLocation(inventoryLoc);
2787 if (invLoc && (invLoc.GetType() != InventoryLocationType.GROUND && invLoc.GetType() != InventoryLocationType.HANDS))
2788 {
2789 m_HotVaporParticle.Stop();
2790 m_HotVaporParticle = null;
2791 }
2792 }
2793 }
2794
2795 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
2796 {
2797 if (GetFoodStage())
2798 {
2799 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FOOD_NUTRITIONS_DATA, "Food Nutritions Data", FadeColors.WHITE));
2800 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FOOD_STAGE_PREV, "Food Stage Prev", FadeColors.WHITE));
2801 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FOOD_STAGE_NEXT, "Food Stage Next", FadeColors.WHITE));
2802 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
2803 }
2804
2805 super.GetDebugActions(outputList);
2806 }
2807
2808 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
2809 {
2810 super.OnAction(action_id, player, ctx);
2811
2812 if ( GetGame().IsServer() )
2813 {
2814 if ( action_id == EActions.FOOD_STAGE_PREV )
2815 {
2816 int food_stage_prev = GetFoodStageType() - 1;
2817 if (food_stage_prev <= 0)
2818 {
2819 food_stage_prev = FoodStageType.COUNT - 1;
2820 }
2821 ChangeFoodStage(food_stage_prev);
2822 return true;
2823 }
2824 else if ( action_id == EActions.FOOD_STAGE_NEXT )
2825 {
2826 int food_stage_next = GetFoodStageType() + 1;
2827 if (food_stage_next >= FoodStageType.COUNT )
2828 {
2829 food_stage_next = FoodStageType.RAW;
2830 }
2831 ChangeFoodStage(food_stage_next);
2832 return true;
2833 }
2834
2835 }
2836
2837 #ifdef DIAG_DEVELOPER
2838 if (action_id == EActions.FOOD_NUTRITIONS_DATA)
2839 {
2840 PrintNutritionsData();
2841 return true;
2842 }
2843 #endif
2844
2845 return false;
2846 }
2847
2848 override string GetDebugText()
2849 {
2850 string debug_output;
2851
2852 debug_output = super.GetDebugText();
2853
2854 debug_output+="m_CookedByMethod:"+m_CookedByMethod+"\n";
2855 debug_output+="m_MakeCookingSounds:"+m_MakeCookingSounds+"\n";
2856
2857 return debug_output;
2858 }
2859
2860 //================================================================
2861 // GENERAL GETTERS
2862 //================================================================
2863
2864 override float GetBaitEffectivity()
2865 {
2866 float ret = super.GetBaitEffectivity();
2867
2868 if (IsFoodRotten())
2869 {
2870 ret *= 0.5;
2871 }
2872
2873 return ret;
2874 }
2875
2876 float GetDecayTimer()
2877 {
2878 return m_DecayTimer;
2879 }
2880
2881 float GetDecayDelta()
2882 {
2883 return m_DecayDelta;
2884 }
2885
2887 {
2888 return m_LastDecayStage;
2889 }
2890
2891 #ifdef DIAG_DEVELOPER
2892 private void PrintNutritionsData()
2893 {
2894 string nutritionsData = "";
2895
2896 FoodStage stage = GetFoodStage();
2897 FoodStageType stageType = stage.GetFoodStageType();
2898
2899 NutritionalProfile profile = GetNutritionalProfile(this, ClassName(), stageType);
2900 if (profile)
2901 {
2902 nutritionsData = string.Format("Item: %1\n\n", this);
2903 nutritionsData += string.Format("Stage name: %1\n", GetFoodStageName(stageType));
2904 nutritionsData += string.Format("Energy: %1\n", profile.m_Energy);
2905 nutritionsData += string.Format("Water content: %1\n", profile.m_WaterContent);
2906 nutritionsData += string.Format("Nutritional index: %1\n", profile.m_NutritionalIndex);
2907 nutritionsData += string.Format("Fullness index: %1\n", profile.m_FullnessIndex);
2908 nutritionsData += string.Format("Toxicity (obsolete): %1\n", profile.m_Toxicity);
2909 nutritionsData += string.Format("Digestibility: %1\n", profile.m_Digestibility);
2910
2911 if (profile.IsLiquid())
2912 nutritionsData += string.Format("Liquid type: %1\n", profile.m_LiquidClassname);
2913
2914 nutritionsData += string.Format("Agents: %1\n", profile.m_Agents);
2915 nutritionsData += string.Format("Agents per consume: %1\n", profile.m_AgentsPerDigest);
2916 }
2917
2918 nutritionsData += "-----\n";
2919
2920 Debug.Log(nutritionsData);
2921 }
2922 #endif
2923
2925 //DEPRECATED
2927 void UpdateVisuals()
2928 {
2930 }
2931}
2932
2934{
2935 void ReplaceEdibleWithNewLambda(EntityAI old_item, string new_item_type, PlayerBase player) { }
2936};
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.

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