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

◆ CanItemOverheat()

override bool ReplaceEdibleWithNewLambda::CanItemOverheat ( )
private

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

1291 : ItemBase
1292{
1293 const string DIRECT_COOKING_SLOT_NAME = "DirectCooking";
1294
1295 const string SOUND_BAKING_START = "Baking_SoundSet";
1296 const string SOUND_BAKING_DONE = "Baking_Done_SoundSet";
1297 const string SOUND_BOILING_START = "Boiling_SoundSet";
1298 const string SOUND_BOILING_DONE = "Boiling_Done_SoundSet";
1299 const string SOUND_DRYING_START = "Drying_SoundSet";
1300 const string SOUND_DRYING_DONE = "Drying_Done_SoundSet";
1301 const string SOUND_BURNING_DONE = "Food_Burning_SoundSet";
1302
1303 protected bool m_MakeCookingSounds;
1304 protected SoundOnVehicle m_SoundCooking;
1306 protected string m_SoundPlaying;
1307 ref FoodStage m_FoodStage;
1308 protected float m_DecayTimer;
1309 protected float m_DecayDelta = 0.0;
1312
1314
1315 void Edible_Base()
1316 {
1317 if (HasFoodStage())
1318 {
1319 m_FoodStage = new FoodStage(this);
1320
1321 RegisterNetSyncVariableInt("m_FoodStage.m_FoodStageType", FoodStageType.NONE, FoodStageType.COUNT);
1322 RegisterNetSyncVariableFloat("m_FoodStage.m_CookingTime", 0, 600, 0);
1323
1324 m_SoundPlaying = "";
1326 RegisterNetSyncVariableInt("m_CookedByMethod", CookingMethodType.NONE, CookingMethodType.COUNT);
1327 RegisterNetSyncVariableBool("m_MakeCookingSounds");
1328 }
1329 }
1330
1331 override void EEInit()
1332 {
1333 super.EEInit();
1334
1335 UpdateVisualsEx(true); //forced init visuals, mostly for debugs and SP
1336 }
1337
1338 override void EEDelete(EntityAI parent)
1339 {
1340 super.EEDelete(parent);
1341
1342 RemoveAudio();
1343
1345 m_HotVaporParticle.Stop();
1346 }
1347
1348 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
1349 {
1350 super.EEItemLocationChanged(oldLoc, newLoc);
1351
1353 if (oldLoc.GetType() == InventoryLocationType.ATTACHMENT || oldLoc.GetType() == InventoryLocationType.CARGO)
1354 {
1355 switch (oldLoc.GetParent().GetType())
1356 {
1357 case "FryingPan":
1358 case "Pot":
1359 case "Cauldron":
1360 case "SharpWoodenStick":
1361 MakeSoundsOnClient(false);
1362 break;
1363 }
1364
1366 if (oldLoc.GetSlot() > -1 && InventorySlots.GetSlotName(oldLoc.GetSlot()).Contains(DIRECT_COOKING_SLOT_NAME))
1367 {
1368 MakeSoundsOnClient(false);
1369 }
1370 }
1371
1372 if (oldLoc.IsValid())
1374
1375 if (CanHaveTemperature())
1377 }
1378
1379 void UpdateVisualsEx(bool forced = false)
1380 {
1381 if (GetFoodStage())
1382 GetFoodStage().UpdateVisualsEx(forced);
1383 }
1384
1385 bool Consume(float amount, PlayerBase consumer)
1386 {
1387 AddQuantity(-amount, false, false);
1388 OnConsume(amount, consumer);
1389
1390 return true;
1391 }
1392
1393 void OnConsume(float amount, PlayerBase consumer)
1394 {
1396 {
1397 consumer.ProcessDirectDamage(DamageType.CUSTOM, this, "", "EnviroDmg", "0 0 0", PlayerConstants.CONSUMPTION_DAMAGE_PER_BITE);
1398 }
1399 }
1400
1402 int FilterAgents(int agentsIn)
1403 {
1404 int foodStageType;
1405
1406 FoodStage foodStage = GetFoodStage();
1407 if (foodStage)
1408 foodStageType = foodStage.GetFoodStageType();
1409
1411 NutritionalProfile nutritionalProfile = GetNutritionalProfile(this, ClassName(), foodStageType);
1412 if ((agentsIn & eAgents.SALMONELLA == eAgents.SALMONELLA) && (nutritionalProfile.m_Agents == 0 || nutritionalProfile.m_AgentsPerDigest == 0))
1413 agentsIn &= ~eAgents.FOOD_POISON;
1414
1415 return agentsIn;
1416 }
1417
1418 //food staging
1419 override bool CanBeCooked()
1420 {
1421 return false;
1422 }
1423
1424 override bool CanBeCookedOnStick()
1425 {
1426 return false;
1427 }
1428
1429 override float GetTemperatureFreezeTime()
1430 {
1431 if (GetFoodStage())
1432 {
1433 switch (m_FoodStage.GetFoodStageType())
1434 {
1435 case FoodStageType.DRIED:
1436 return super.GetTemperatureFreezeTime() * GameConstants.TEMPERATURE_FREEZE_TIME_COEF_DRIED;
1437
1438 case FoodStageType.BURNED:
1439 return super.GetTemperatureFreezeTime() * GameConstants.TEMPERATURE_FREEZE_TIME_COEF_BURNED;
1440
1441 default:
1442 return super.GetTemperatureFreezeTime();
1443 }
1444 }
1445
1446 return super.GetTemperatureFreezeTime();
1447 }
1448
1449 override float GetTemperatureThawTime()
1450 {
1451 if (GetFoodStage())
1452 {
1453 switch (m_FoodStage.GetFoodStageType())
1454 {
1455 case FoodStageType.DRIED:
1456 return super.GetTemperatureThawTime() * GameConstants.TEMPERATURE_THAW_TIME_COEF_DRIED;
1457
1458 case FoodStageType.BURNED:
1459 return super.GetTemperatureThawTime() * GameConstants.TEMPERATURE_THAW_TIME_COEF_BURNED;
1460
1461 default:
1462 return super.GetTemperatureThawTime();
1463 }
1464 }
1465
1466 return super.GetTemperatureThawTime();
1467 }
1468
1469 override bool CanItemOverheat()
1470 {
1471 return super.CanItemOverheat() && (!GetFoodStage() || (IsFoodBurned() || !GetFoodStage().CanTransitionToFoodStageType(FoodStageType.BURNED))); //for foodstaged items - either is burned, or it can't get burned
1472 }
1473
1474 //================================================================
1475 // SYNCHRONIZATION
1476 //================================================================
1477 void Synchronize()
1478 {
1479 SetSynchDirty();
1480 }
1481
1482 override void OnVariablesSynchronized()
1483 {
1484 super.OnVariablesSynchronized();
1485
1486 //UpdateVisualsEx(); //performed on client only
1487
1488 //update audio
1490 {
1491 RefreshAudio();
1492 }
1493 else
1494 {
1495 RemoveAudio();
1496 }
1497
1498 if (CanHaveTemperature())
1500 }
1501
1502 //================================================================
1503 // AUDIO EFFECTS (WHEN ON DCS)
1504 //================================================================
1505 void MakeSoundsOnClient(bool soundstate, CookingMethodType cookingMethod = CookingMethodType.NONE)
1506 {
1507 m_MakeCookingSounds = soundstate;
1508 m_CookedByMethod = cookingMethod;
1509
1510 Synchronize();
1511 }
1512
1513 protected void RefreshAudio()
1514 {
1515 string soundName = "";
1516
1517 FoodStageType currentFoodStage = GetFoodStageType();
1519
1520 if (currentFoodStage == FoodStageType.BURNED)
1521 {
1522 soundName = SOUND_BURNING_DONE;
1523 }
1524 else
1525 {
1526 switch (m_CookedByMethod)
1527 {
1528 case CookingMethodType.BAKING:
1529 {
1530 if (nextFoodStage == FoodStageType.BAKED)
1531 soundName = SOUND_BAKING_START;
1532 else if (currentFoodStage == FoodStageType.BAKED)
1533 soundName = SOUND_BAKING_DONE;
1534 else
1535 soundName = "";
1536 break;
1537 }
1538
1539 case CookingMethodType.BOILING:
1540 {
1541 if (nextFoodStage == FoodStageType.BOILED)
1542 soundName = SOUND_BOILING_START;
1543 else if (currentFoodStage == FoodStageType.BOILED)
1544 soundName = SOUND_BOILING_DONE;
1545 else
1546 soundName = "";
1547 break;
1548 }
1549
1550 case CookingMethodType.DRYING:
1551 {
1552 if (nextFoodStage == FoodStageType.DRIED)
1553 soundName = SOUND_DRYING_START;
1554 else if (currentFoodStage == FoodStageType.DRIED)
1555 soundName = SOUND_DRYING_DONE;
1556 else
1557 soundName = "";
1558 break;
1559 }
1560
1561 default:
1562 soundName = "";
1563 break;
1564 }
1565
1566 if (nextFoodStage == FoodStageType.BURNED)
1567 {
1568 if (soundName == "") //on 'bad' transitions only, indicates bad outcome
1569 {
1570 soundName = SOUND_BURNING_DONE;
1571 }
1572 else // pre-emptive burning sounds replace regular ones
1573 {
1574 array<float> nextStageProperties = new array<float>();
1575 nextStageProperties = FoodStage.GetAllCookingPropertiesForStage(nextFoodStage, null, GetType());
1576 float nextStageTime = nextStageProperties.Get(eCookingPropertyIndices.COOK_TIME);
1577 float progress01 = GetCookingTime() / nextStageTime;
1578 if (progress01 > Cooking.BURNING_WARNING_THRESHOLD)
1579 {
1580 soundName = SOUND_BURNING_DONE;
1581 }
1582 }
1583 }
1584 }
1585
1586 SoundCookingStart(soundName);
1587 }
1588
1589 protected void RemoveAudio()
1590 {
1591 m_MakeCookingSounds = false;
1593 }
1594
1595 //================================================================
1596 // SERIALIZATION
1597 //================================================================
1598 override void OnStoreSave(ParamsWriteContext ctx)
1599 {
1600 super.OnStoreSave(ctx);
1601
1602 if (GetFoodStage())
1603 {
1604 GetFoodStage().OnStoreSave(ctx);
1605 }
1606
1607 // food decay
1608 ctx.Write(m_DecayTimer);
1610 }
1611
1612 override bool OnStoreLoad(ParamsReadContext ctx, int version)
1613 {
1614 if (!super.OnStoreLoad(ctx, version))
1615 return false;
1616
1617 if (GetFoodStage())
1618 {
1619 if (!GetFoodStage().OnStoreLoad(ctx, version))
1620 return false;
1621 }
1622
1623 if (version >= 115)
1624 {
1625 if (!ctx.Read(m_DecayTimer))
1626 {
1627 m_DecayTimer = 0.0;
1628 return false;
1629 }
1630 if (!ctx.Read(m_LastDecayStage))
1631 {
1633 return false;
1634 }
1635 }
1636
1637 UpdateVisualsEx(true); //forced init visuals
1638 Synchronize();
1639
1640 return true;
1641 }
1642
1643 override void AfterStoreLoad()
1644 {
1645 super.AfterStoreLoad();
1646
1647 Synchronize();
1648 }
1649
1650 //get food stage
1651 override FoodStage GetFoodStage()
1652 {
1653 return m_FoodStage;
1654 }
1655
1656 //food types
1657 override bool IsMeat()
1658 {
1659 return false;
1660 }
1661
1662 override bool IsCorpse()
1663 {
1664 return false;
1665 }
1666
1667 override bool IsFruit()
1668 {
1669 return false;
1670 }
1671
1672 override bool IsMushroom()
1673 {
1674 return false;
1675 }
1676
1677 //================================================================
1678 // NUTRITIONAL VALUES
1679 //================================================================
1680 //food properties
1681 static float GetFoodTotalVolume(ItemBase item, string classname = "", int food_stage = 0)
1682 {
1683 Edible_Base food_item = Edible_Base.Cast(item);
1684 if (food_item && food_item.GetFoodStage())
1685 {
1686 return FoodStage.GetFullnessIndex(food_item.GetFoodStage());
1687 }
1688 else if (classname != "" && food_stage)
1689 {
1690 return FoodStage.GetFullnessIndex(null, food_stage, classname);
1691 }
1692 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
1693 return g_Game.ConfigGetFloat( class_path + " fullnessIndex" );
1694
1695 }
1696
1697 static float GetFoodEnergy(ItemBase item, string classname = "", int food_stage = 0)
1698 {
1699 Edible_Base food_item = Edible_Base.Cast(item);
1700 if (food_item && food_item.GetFoodStage())
1701 {
1702 return FoodStage.GetEnergy(food_item.GetFoodStage());
1703 }
1704 else if (classname != "" && food_stage)
1705 {
1706 return FoodStage.GetEnergy(null, food_stage, classname);
1707 }
1708 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
1709 return g_Game.ConfigGetFloat( class_path + " energy" );
1710 }
1711
1712 static float GetFoodWater(ItemBase item, string classname = "", int food_stage = 0)
1713 {
1714 Edible_Base food_item = Edible_Base.Cast(item);
1715 if (food_item && food_item.GetFoodStage())
1716 {
1717 return FoodStage.GetWater(food_item.GetFoodStage());
1718 }
1719 else if (classname != "" && food_stage)
1720 {
1721 return FoodStage.GetWater(null, food_stage, classname);
1722 }
1723 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
1724 return g_Game.ConfigGetFloat( class_path + " water" );
1725 }
1726
1727 static float GetFoodNutritionalIndex(ItemBase item, string classname = "", int food_stage = 0)
1728 {
1729 Edible_Base food_item = Edible_Base.Cast(item);
1730 if (food_item && food_item.GetFoodStage())
1731 {
1732 return FoodStage.GetNutritionalIndex(food_item.GetFoodStage());
1733 }
1734 else if (classname != "" && food_stage)
1735 {
1736 return FoodStage.GetNutritionalIndex(null, food_stage, classname);
1737 }
1738 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
1739 return g_Game.ConfigGetFloat( class_path + " nutritionalIndex" );
1740
1741 }
1742
1743 static float GetFoodToxicity(ItemBase item, string classname = "", int food_stage = 0)
1744 {
1745 Edible_Base food_item = Edible_Base.Cast(item);
1746 if (food_item && food_item.GetFoodStage())
1747 {
1748 return FoodStage.GetToxicity(food_item.GetFoodStage());
1749 }
1750 else if (classname != "" && food_stage)
1751 {
1752 return FoodStage.GetToxicity(null, food_stage, classname);
1753 }
1754 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
1755 return g_Game.ConfigGetFloat( class_path + " toxicity" );
1756 }
1757
1758 static int GetFoodAgents(ItemBase item, string classname = "", int food_stage = 0)
1759 {
1760 Edible_Base food_item = Edible_Base.Cast(item);
1761 if (food_item && food_item.GetFoodStage())
1762 {
1763 return FoodStage.GetAgents(food_item.GetFoodStage());
1764 }
1765 else if (classname != "" && food_stage)
1766 {
1767 return FoodStage.GetAgents(null, food_stage, classname);
1768 }
1769 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
1770 return g_Game.ConfigGetInt( class_path + " agents" );
1771 }
1772
1773 static float GetFoodDigestibility(ItemBase item, string classname = "", int food_stage = 0)
1774 {
1775 Edible_Base food_item = Edible_Base.Cast(item);
1776 if (food_item && food_item.GetFoodStage())
1777 {
1778 return FoodStage.GetDigestibility(food_item.GetFoodStage());
1779 }
1780 else if (classname != "" && food_stage)
1781 {
1782 return FoodStage.GetDigestibility(null, food_stage, classname);
1783 }
1784 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
1785 return g_Game.ConfigGetInt( class_path + " digestibility" );
1786 }
1787
1788 static float GetAgentsPerDigest(ItemBase item, string className = "", int foodStage = 0)
1789 {
1790 Edible_Base foodItem = Edible_Base.Cast(item);
1791 if (foodItem && foodItem.GetFoodStage())
1792 {
1793 return FoodStage.GetAgentsPerDigest(foodItem.GetFoodStage());
1794 }
1795 else if (className != "" && foodStage)
1796 {
1797 return FoodStage.GetAgentsPerDigest(null, foodStage, className);
1798 }
1799 string classPath = string.Format("cfgVehicles %1 Nutrition", className);
1800 return g_Game.ConfigGetInt(classPath + " agentsPerDigest");
1801 }
1802
1803 static NutritionalProfile GetNutritionalProfile(ItemBase item, string classname = "", int food_stage = 0)
1804 {
1805 NutritionalProfile profile = new NutritionalProfile();
1806 profile.m_Energy = GetFoodEnergy(item, classname, food_stage);
1807 profile.m_WaterContent = GetFoodWater(item, classname, food_stage);
1808 profile.m_NutritionalIndex = GetFoodNutritionalIndex(item, classname, food_stage);
1809 profile.m_FullnessIndex = GetFoodTotalVolume(item, classname, food_stage);
1810 profile.m_Toxicity = GetFoodToxicity(item, classname, food_stage);
1811 profile.m_Agents = GetFoodAgents(item, classname, food_stage);
1812 profile.m_Digestibility = GetFoodDigestibility(item, classname, food_stage);
1813 profile.m_AgentsPerDigest = GetAgentsPerDigest(item, classname, food_stage);
1814
1815 return profile;
1816 }
1817
1818 //================================================================
1819 // FOOD STAGING
1820 //================================================================
1822 {
1823 return GetFoodStage().GetFoodStageType();
1824 }
1825
1826 //food stage states
1827 bool IsFoodRaw()
1828 {
1829 if ( GetFoodStage() )
1830 {
1831 return GetFoodStage().IsFoodRaw();
1832 }
1833
1834 return false;
1835 }
1836
1837 bool IsFoodBaked()
1838 {
1839 if ( GetFoodStage() )
1840 {
1841 return GetFoodStage().IsFoodBaked();
1842 }
1843
1844 return false;
1845 }
1846
1847 bool IsFoodBoiled()
1848 {
1849 if ( GetFoodStage() )
1850 {
1851 return GetFoodStage().IsFoodBoiled();
1852 }
1853
1854 return false;
1855 }
1856
1857 bool IsFoodDried()
1858 {
1859 if ( GetFoodStage() )
1860 {
1861 return GetFoodStage().IsFoodDried();
1862 }
1863
1864 return false;
1865 }
1866
1867 bool IsFoodBurned()
1868 {
1869 if ( GetFoodStage() )
1870 {
1871 return GetFoodStage().IsFoodBurned();
1872 }
1873
1874 return false;
1875 }
1876
1877 bool IsFoodRotten()
1878 {
1879 if ( GetFoodStage() )
1880 {
1881 return GetFoodStage().IsFoodRotten();
1882 }
1883
1884 return false;
1885 }
1886
1887 //food stage change
1888 void ChangeFoodStage( FoodStageType new_food_stage_type )
1889 {
1890 GetFoodStage().ChangeFoodStage( new_food_stage_type );
1891 }
1892
1894 {
1895 return GetFoodStage().GetNextFoodStageType( cooking_method );
1896 }
1897
1898 string GetFoodStageName( FoodStageType food_stage_type )
1899 {
1900 return GetFoodStage().GetFoodStageName( food_stage_type );
1901 }
1902
1903 bool CanChangeToNewStage( CookingMethodType cooking_method )
1904 {
1905 return GetFoodStage().CanChangeToNewStage( cooking_method );
1906 }
1907
1908 //Use this to receive food stage from another Edible_Base
1909 void TransferFoodStage( notnull Edible_Base source )
1910 {
1911 if ( !source.GetFoodStage())
1912 return;
1913 m_LastDecayStage = source.GetLastDecayStage();
1914 ChangeFoodStage(source.GetFoodStage().GetFoodStageType());
1915 m_DecayTimer = source.GetDecayTimer();
1916 m_DecayDelta = source.GetDecayDelta();
1917 }
1918
1920 void OnFoodStageChange(FoodStageType stageOld, FoodStageType stageNew)
1921 {
1922 HandleFoodStageChangeAgents(stageOld,stageNew);
1923 UpdateVisualsEx(); //performed on server only
1924 }
1925
1928 {
1929 switch (stageNew)
1930 {
1931 case FoodStageType.BAKED:
1932 case FoodStageType.BOILED:
1933 case FoodStageType.DRIED:
1934 RemoveAllAgentsExcept(eAgents.BRAIN|eAgents.HEAVYMETAL);
1935 break;
1936
1937 case FoodStageType.BURNED:
1938 RemoveAllAgentsExcept(eAgents.BRAIN|eAgents.HEAVYMETAL);
1939 break;
1940 }
1941 }
1942
1943 //================================================================
1944 // COOKING
1945 //================================================================
1946 //cooking time
1947 float GetCookingTime()
1948 {
1949 return GetFoodStage().GetCookingTime();
1950 }
1951
1952 void SetCookingTime( float time )
1953 {
1954 GetFoodStage().SetCookingTime( time );
1955
1956 //synchronize when calling on server
1957 Synchronize();
1958 }
1959
1960 void ResetCookingTime()
1961 {
1962 if (GetFoodStage())
1963 {
1964 GetFoodStage().SetCookingTime(0);
1965 Synchronize();
1966 }
1967 }
1968
1969 //replace edible with new item (opening cans)
1970 void ReplaceEdibleWithNew( string typeName )
1971 {
1972 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
1973 if (player)
1974 {
1975 ReplaceEdibleWithNewLambda lambda = new ReplaceEdibleWithNewLambda(this, typeName, player);
1976 player.ServerReplaceItemInHandsWithNew(lambda);
1977 }
1978 else
1979 Error("ReplaceEdibleWithNew - cannot use edible without player");
1980 }
1981
1983 {
1985 }
1986
1987 override void SetActions()
1988 {
1989 super.SetActions();
1990
1993 }
1994
1995 protected void SoundCookingStart(string sound_name)
1996 {
1997 #ifndef SERVER
1998 #ifndef NO_GUI
1999 if (m_SoundPlaying != sound_name)
2000 {
2002
2003 m_SoundEffectCooking = SEffectManager.PlaySound(sound_name, GetPosition(), 0, 0, true);
2004 m_SoundPlaying = sound_name;
2005 }
2006 #endif
2007 #endif
2008 }
2009
2010 protected void SoundCookingStop()
2011 {
2012 #ifndef SERVER
2013 #ifndef NO_GUI
2015 {
2016 m_SoundEffectCooking.Stop();
2017 m_SoundEffectCooking = null;
2018 m_SoundPlaying = "";
2019 }
2020 #endif
2021 #endif
2022 }
2023
2024 override bool CanDecay()
2025 {
2026 return false;
2027 }
2028
2029 override bool CanProcessDecay()
2030 {
2031 return !GetIsFrozen() && ( GetFoodStageType() != FoodStageType.ROTTEN );
2032 }
2033
2034 override void ProcessDecay( float delta, bool hasRootAsPlayer )
2035 {
2036 m_DecayDelta = 0.0;
2037
2038 delta *= DayZGame.Cast(g_Game).GetFoodDecayModifier();
2039 m_DecayDelta += ( 1 + ( 1 - GetHealth01( "", "" ) ) );
2040 if ( hasRootAsPlayer )
2042
2043 /*Print( "-------------------------" );
2044 Print( this );
2045 Print( m_DecayTimer );
2046 Print( m_DecayDelta );
2047 Print( m_LastDecayStage );*/
2048
2049 if ( IsFruit() || IsMushroom() )
2050 {
2051 // fruit, vegetables and mushrooms
2053 {
2054 switch ( GetFoodStageType() )
2055 {
2056 case FoodStageType.RAW:
2059 break;
2060
2061 case FoodStageType.BOILED:
2064 break;
2065
2066 case FoodStageType.BAKED:
2069 break;
2070
2071 case FoodStageType.DRIED:
2072 case FoodStageType.BURNED:
2073 case FoodStageType.ROTTEN:
2074 default:
2075 m_DecayTimer = -1;
2077 return;
2078 }
2079
2080 //m_DecayTimer = m_DecayTimer / 1000.0;
2081 }
2082
2083 m_DecayTimer -= ( delta * m_DecayDelta );
2084
2085 if ( m_DecayTimer <= 0 )
2086 {
2087 if ( m_LastDecayStage != FoodStageType.NONE )
2088 {
2089 // switch to decayed stage
2090 if ( ( m_LastDecayStage == FoodStageType.BOILED ) || ( m_LastDecayStage == FoodStageType.BAKED ) )
2091 {
2093 }
2094 if ( m_LastDecayStage == FoodStageType.RAW )
2095 {
2096 int rng = Math.RandomIntInclusive( 0, 100 );
2098 {
2100 }
2101 else
2102 {
2103 if ( CanChangeToNewStage( FoodStageType.DRIED ) )
2104 {
2106 }
2107 else
2108 {
2110 }
2111 }
2112 }
2113 }
2114 }
2115
2116 }
2117 else if ( IsMeat() )
2118 {
2119 // meat
2121 {
2122 switch ( GetFoodStageType() )
2123 {
2124 case FoodStageType.RAW:
2127 break;
2128
2129 case FoodStageType.BOILED:
2132 break;
2133
2134 case FoodStageType.BAKED:
2137 break;
2138
2139 case FoodStageType.DRIED:
2142 break;
2143
2144 case FoodStageType.BURNED:
2145 case FoodStageType.ROTTEN:
2146 default:
2147 m_DecayTimer = -1;
2149 return;
2150 }
2151 }
2152
2153 m_DecayTimer -= ( delta * m_DecayDelta );
2154
2155 if ( m_DecayTimer <= 0 )
2156 {
2157 if ( m_LastDecayStage != FoodStageType.NONE )
2158 {
2159 // switch to decayed stage
2160 if ( ( m_LastDecayStage == FoodStageType.DRIED ) || ( m_LastDecayStage == FoodStageType.RAW ) || ( m_LastDecayStage == FoodStageType.BOILED ) || ( m_LastDecayStage == FoodStageType.BAKED ) )
2161 {
2163 }
2164 }
2165 }
2166 }
2167 else if ( IsCorpse() )
2168 {
2169 // corpse
2171 {
2172 switch ( GetFoodStageType() )
2173 {
2174 case FoodStageType.RAW:
2177 break;
2178
2179 case FoodStageType.BURNED:
2180 case FoodStageType.ROTTEN:
2181 default:
2182 m_DecayTimer = -1;
2184 return;
2185 }
2186 }
2187
2188 m_DecayTimer -= ( delta * m_DecayDelta );
2189
2190 if ( m_DecayTimer <= 0 )
2191 {
2192 if ( m_LastDecayStage != FoodStageType.NONE )
2193 {
2194 // switch to decayed stage
2195 if ( ( m_LastDecayStage == FoodStageType.DRIED ) || ( m_LastDecayStage == FoodStageType.RAW ) || ( m_LastDecayStage == FoodStageType.BOILED ) || ( m_LastDecayStage == FoodStageType.BAKED ) )
2196 {
2198 }
2199 }
2200 }
2201 }
2202 else
2203 {
2204 // opened cans
2205 m_DecayTimer -= ( delta * m_DecayDelta );
2206
2207 if ( ( m_DecayTimer <= 0 ) && ( m_LastDecayStage == FoodStageType.NONE ) )
2208 {
2211 //m_DecayTimer = m_DecayTimer / 1000.0;
2212 }
2213 else
2214 {
2215 if ( m_DecayTimer <= 0 )
2216 {
2217 InsertAgent(eAgents.FOOD_POISON, 1);
2218 m_DecayTimer = -1;
2219 }
2220 }
2221 }
2222 }
2223
2224 protected void UpdateVaporParticle()
2225 {
2226 if (g_Game.IsHeadlessOrDedicatedServer())
2227 return;
2228
2229 if (m_VarTemperature >= GameConstants.STATE_HOT_LVL_TWO && !m_HotVaporParticle)
2230 {
2231 InventoryLocation invLoc = new InventoryLocation();
2232 GetInventory().GetCurrentInventoryLocation(invLoc);
2233 if (invLoc && (invLoc.GetType() == InventoryLocationType.GROUND || invLoc.GetType() == InventoryLocationType.HANDS || invLoc.GetType() == InventoryLocationType.ATTACHMENT))
2234 {
2235 ParticleManager ptcMgr = ParticleManager.GetInstance();
2236 if (ptcMgr)
2237 {
2238 m_HotVaporParticle = ParticleManager.GetInstance().PlayOnObject(ParticleList.ITEM_HOT_VAPOR, this);
2239 m_HotVaporParticle.SetParticleParam(EmitorParam.SIZE, 0.3);
2240 m_HotVaporParticle.SetParticleParam(EmitorParam.BIRTH_RATE, 10);
2241 m_HotVaporParticle.SetParticleAutoDestroyFlags(ParticleAutoDestroyFlags.ON_STOP);
2242 }
2243 }
2244 }
2245 else if (m_HotVaporParticle)
2246 {
2247 if (m_VarTemperature <= GameConstants.STATE_HOT_LVL_TWO)
2248 {
2249 m_HotVaporParticle.Stop();
2250 m_HotVaporParticle = null;
2251 return;
2252 }
2253
2254 InventoryLocation inventoryLoc = new InventoryLocation();
2255 GetInventory().GetCurrentInventoryLocation(inventoryLoc);
2256 if (invLoc && (invLoc.GetType() != InventoryLocationType.GROUND && invLoc.GetType() != InventoryLocationType.HANDS))
2257 {
2258 m_HotVaporParticle.Stop();
2259 m_HotVaporParticle = null;
2260 }
2261 }
2262 }
2263
2264 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
2265 {
2266 if (GetFoodStage())
2267 {
2268 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FOOD_NUTRITIONS_DATA, "Food Nutritions Data", FadeColors.WHITE));
2269 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FOOD_STAGE_PREV, "Food Stage Prev", FadeColors.WHITE));
2270 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FOOD_STAGE_NEXT, "Food Stage Next", FadeColors.WHITE));
2271 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
2272 }
2273
2274 super.GetDebugActions(outputList);
2275 }
2276
2277 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
2278 {
2279 super.OnAction(action_id, player, ctx);
2280
2281 if ( g_Game.IsServer() )
2282 {
2283 if ( action_id == EActions.FOOD_STAGE_PREV )
2284 {
2285 int food_stage_prev = GetFoodStageType() - 1;
2286 if (food_stage_prev <= 0)
2287 {
2288 food_stage_prev = FoodStageType.COUNT - 1;
2289 }
2290 ChangeFoodStage(food_stage_prev);
2291 return true;
2292 }
2293 else if ( action_id == EActions.FOOD_STAGE_NEXT )
2294 {
2295 int food_stage_next = GetFoodStageType() + 1;
2296 if (food_stage_next >= FoodStageType.COUNT )
2297 {
2298 food_stage_next = FoodStageType.RAW;
2299 }
2300 ChangeFoodStage(food_stage_next);
2301 return true;
2302 }
2303
2304 }
2305
2306 #ifdef DIAG_DEVELOPER
2307 if (action_id == EActions.FOOD_NUTRITIONS_DATA)
2308 {
2309 PrintNutritionsData();
2310 return true;
2311 }
2312 #endif
2313
2314 return false;
2315 }
2316
2317 override string GetDebugText()
2318 {
2319 string debug_output;
2320
2321 debug_output = super.GetDebugText();
2322
2323 debug_output+="m_CookedByMethod:"+m_CookedByMethod+"\n";
2324 debug_output+="m_MakeCookingSounds:"+m_MakeCookingSounds+"\n";
2325
2326 return debug_output;
2327 }
2328
2329 //================================================================
2330 // GENERAL GETTERS
2331 //================================================================
2332
2333 override float GetBaitEffectivity()
2334 {
2335 float ret = super.GetBaitEffectivity();
2336
2337 if (IsFoodRotten())
2338 {
2339 ret *= 0.5;
2340 }
2341
2342 return ret;
2343 }
2344
2345 float GetDecayTimer()
2346 {
2347 return m_DecayTimer;
2348 }
2349
2350 float GetDecayDelta()
2351 {
2352 return m_DecayDelta;
2353 }
2354
2356 {
2357 return m_LastDecayStage;
2358 }
2359
2360 #ifdef DIAG_DEVELOPER
2361 private void PrintNutritionsData()
2362 {
2363 string nutritionsData = "";
2364
2365 FoodStage stage = GetFoodStage();
2366 FoodStageType stageType = stage.GetFoodStageType();
2367
2368 NutritionalProfile profile = GetNutritionalProfile(this, ClassName(), stageType);
2369 if (profile)
2370 {
2371 nutritionsData = string.Format("Item: %1\n\n", this);
2372 nutritionsData += string.Format("Stage name: %1\n", GetFoodStageName(stageType));
2373 nutritionsData += string.Format("Energy: %1\n", profile.m_Energy);
2374 nutritionsData += string.Format("Water content: %1\n", profile.m_WaterContent);
2375 nutritionsData += string.Format("Nutritional index: %1\n", profile.m_NutritionalIndex);
2376 nutritionsData += string.Format("Fullness index: %1\n", profile.m_FullnessIndex);
2377 nutritionsData += string.Format("Toxicity (obsolete): %1\n", profile.m_Toxicity);
2378 nutritionsData += string.Format("Digestibility: %1\n", profile.m_Digestibility);
2379
2380 if (profile.IsLiquid())
2381 nutritionsData += string.Format("Liquid type: %1\n", profile.m_LiquidClassname);
2382
2383 nutritionsData += string.Format("Agents: %1\n", profile.m_Agents);
2384 nutritionsData += string.Format("Agents per consume: %1\n", profile.m_AgentsPerDigest);
2385 }
2386
2387 nutritionsData += "-----\n";
2388
2389 Debug.Log(nutritionsData);
2390 }
2391 #endif
2392
2394 //DEPRECATED
2396 void UpdateVisuals()
2397 {
2399 }
2400}
2401
2403{
2404 void ReplaceEdibleWithNewLambda(EntityAI old_item, string new_item_type, PlayerBase player) { }
2405};
Param4< int, int, string, int > TSelectableActionInfoWithColor
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
DayZGame g_Game
Определения DayZGame.c:4074
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:1792
ref FoodStage m_FoodStage
Определения Edible_Base.c:1129
bool IsFoodRotten()
Определения Edible_Base.c:1699
static float GetFoodWater(ItemBase item, string classname="", int food_stage=0)
Определения Edible_Base.c:1534
override bool CanBeCooked()
Определения Edible_Base.c:1241
bool IsFoodBaked()
Определения Edible_Base.c:1659
override string GetDebugText()
Определения Edible_Base.c:2139
override void AfterStoreLoad()
Определения Edible_Base.c:1465
void Edible_Base()
Определения Edible_Base.c:1137
void OnFoodStageChange(FoodStageType stageOld, FoodStageType stageNew)
called on server
Определения Edible_Base.c:1742
float m_DecayDelta
Определения Edible_Base.c:1131
void Synchronize()
Определения Edible_Base.c:1299
override void OnVariablesSynchronized()
Определения Edible_Base.c:1304
const string SOUND_BURNING_DONE
Определения Edible_Base.c:1123
bool CanChangeToNewStage(CookingMethodType cooking_method)
Определения Edible_Base.c:1725
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
Определения Edible_Base.c:2099
void RemoveAudio()
Определения Edible_Base.c:1411
override bool CanItemOverheat()
Определения Edible_Base.c:1291
float GetDecayDelta()
Определения Edible_Base.c:2172
override float GetBaitEffectivity()
Определения Edible_Base.c:2155
override FoodStage GetFoodStage()
Определения Edible_Base.c:1473
override void SetActions()
Определения Edible_Base.c:1809
bool m_MakeCookingSounds
Определения Edible_Base.c:1125
override float GetTemperatureFreezeTime()
Определения Edible_Base.c:1251
void SoundCookingStop()
Определения Edible_Base.c:1832
const string DIRECT_COOKING_SLOT_NAME
Определения Edible_Base.c:1115
FoodStageType GetNextFoodStageType(CookingMethodType cooking_method)
Определения Edible_Base.c:1715
void ChangeFoodStage(FoodStageType new_food_stage_type)
Определения Edible_Base.c:1710
void OnConsume(float amount, PlayerBase consumer)
Определения Edible_Base.c:1215
static float GetFoodNutritionalIndex(ItemBase item, string classname="", int food_stage=0)
Определения Edible_Base.c:1549
SoundOnVehicle m_SoundCooking
Определения Edible_Base.c:1126
static float GetFoodToxicity(ItemBase item, string classname="", int food_stage=0)
Определения Edible_Base.c:1565
override bool CanDecay()
Определения Edible_Base.c:1846
void UpdateVisualsEx(bool forced=false)
Определения Edible_Base.c:1201
const string SOUND_BAKING_DONE
Определения Edible_Base.c:1118
static NutritionalProfile GetNutritionalProfile(ItemBase item, string classname="", int food_stage=0)
Определения Edible_Base.c:1625
int FilterAgents(int agentsIn)
Filter agents from the item (override on higher implementations)
Определения Edible_Base.c:1224
override void EEDelete(EntityAI parent)
Определения Edible_Base.c:1160
FoodStageType m_LastDecayStage
Определения Edible_Base.c:1132
float GetCookingTime()
Определения Edible_Base.c:1769
override bool CanBeCookedOnStick()
Определения Edible_Base.c:1246
override bool IsCorpse()
Определения Edible_Base.c:1484
void UpdateVisuals()
Определения Edible_Base.c:2218
float GetDecayTimer()
Определения Edible_Base.c:2167
FoodStageType GetLastDecayStage()
Определения Edible_Base.c:2177
string GetFoodStageName(FoodStageType food_stage_type)
Определения Edible_Base.c:1720
override float GetTemperatureThawTime()
Определения Edible_Base.c:1271
void UpdateVaporParticle()
Определения Edible_Base.c:2046
static float GetFoodDigestibility(ItemBase item, string classname="", int food_stage=0)
Определения Edible_Base.c:1595
void TransferFoodStage(notnull Edible_Base source)
Определения Edible_Base.c:1731
override void ProcessDecay(float delta, bool hasRootAsPlayer)
Определения Edible_Base.c:1856
const string SOUND_DRYING_START
Определения Edible_Base.c:1121
void SetCookingTime(float time)
Определения Edible_Base.c:1774
void SoundCookingStart(string sound_name)
Определения Edible_Base.c:1817
override bool IsMeat()
Определения Edible_Base.c:1479
const string SOUND_BAKING_START
Определения Edible_Base.c:1117
static float GetFoodTotalVolume(ItemBase item, string classname="", int food_stage=0)
Определения Edible_Base.c:1503
const string SOUND_DRYING_DONE
Определения Edible_Base.c:1122
void HandleFoodStageChangeAgents(FoodStageType stageOld, FoodStageType stageNew)
removes select agents on foodstage transitions
Определения Edible_Base.c:1749
void ResetCookingTime()
Определения Edible_Base.c:1782
override bool IsFruit()
Определения Edible_Base.c:1489
Edible_Base ItemBase ReplaceEdibleWithNewLambda(EntityAI old_item, string new_item_type, PlayerBase player)
Определения Edible_Base.c:1114
bool Consume(float amount, PlayerBase consumer)
Определения Edible_Base.c:1207
EffectSound m_SoundEffectCooking
DEPRECATED.
Определения Edible_Base.c:1127
override bool OnStoreLoad(ParamsReadContext ctx, int version)
Определения Edible_Base.c:1434
FoodStageType GetFoodStageType()
Определения Edible_Base.c:1643
override bool CanProcessDecay()
Определения Edible_Base.c:1851
ParticleSource m_HotVaporParticle
Определения Edible_Base.c:1133
void MakeSoundsOnClient(bool soundstate, CookingMethodType cookingMethod=CookingMethodType.NONE)
Определения Edible_Base.c:1327
static int GetFoodAgents(ItemBase item, string classname="", int food_stage=0)
Определения Edible_Base.c:1580
override bool IsMushroom()
Определения Edible_Base.c:1494
static float GetFoodEnergy(ItemBase item, string classname="", int food_stage=0)
Определения Edible_Base.c:1519
static float GetAgentsPerDigest(ItemBase item, string className="", int foodStage=0)
Определения Edible_Base.c:1610
void RefreshAudio()
Определения Edible_Base.c:1335
const string SOUND_BOILING_DONE
Определения Edible_Base.c:1120
int GetConsumptionPenaltyContext()
Определения Edible_Base.c:1804
const string SOUND_BOILING_START
Определения Edible_Base.c:1119
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Определения Edible_Base.c:2086
CookingMethodType m_CookedByMethod
Определения Edible_Base.c:1135
bool IsFoodDried()
Определения Edible_Base.c:1679
override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Определения Edible_Base.c:1170
override void OnStoreSave(ParamsWriteContext ctx)
Определения Edible_Base.c:1420
bool IsFoodRaw()
Определения Edible_Base.c:1649
bool IsFoodBurned()
Определения Edible_Base.c:1689
override void EEInit()
Определения Edible_Base.c:1153
bool IsFoodBoiled()
Определения Edible_Base.c:1669
float m_DecayTimer
Определения Edible_Base.c:1130
override bool CanHaveTemperature()
Определения FireplaceBase.c:575
FoodStageType
Определения FoodStage.c:2
InventoryLocationType
types of Inventory Location
Определения InventoryLocation.c:4
override void RemoveAllAgentsExcept(int agent_to_keep)
Определения ItemBase.c:3979
override void InsertAgent(int agent, float count=1)
Определения ItemBase.c:3984
bool HasFoodStage()
Определения ItemBase.c:2589
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:3389
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
Определения ParticleManager.c:88
ParticleAutoDestroyFlags
Flags to pass to ParticleSource.SetParticleAutoDestroyFlags.
Определения ParticleSource.c:3
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/DayZ/tools/Debug.c:183
Определения 3_Game/DayZ/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:30
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:78
Определения ParticleList.c:12
Entity which has the particle instance as an ObjectComponent.
Определения ParticleSource.c:128
Определения PlayerBaseClient.c:2
static const float CONSUMPTION_DAMAGE_PER_BITE
Определения PlayerConstants.c:146
static const float CONSUMPTION_DAMAGE_TEMP_THRESHOLD
Определения PlayerConstants.c:147
Определения 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:178
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
Serializer ParamsWriteContext
Определения gameplay.c:16
void Error(string err)
Messagebox with error message.
Определения EnDebug.c:90
const float DECAY_FOOD_BAKED_FRVG
Определения 3_Game/DayZ/constants.c:1101
const float DECAY_FOOD_CAN_OPEN
Определения 3_Game/DayZ/constants.c:1103
const float DECAY_FOOD_RAW_FRVG
Определения 3_Game/DayZ/constants.c:1097
const int DECAY_TIMER_RANDOM_PERCENTAGE
Определения 3_Game/DayZ/constants.c:1105
const int DECAY_FOOD_FRVG_DRIED_CHANCE
Определения 3_Game/DayZ/constants.c:1104
const float DECAY_FOOD_RAW_MEAT
Определения 3_Game/DayZ/constants.c:1095
const float DECAY_FOOD_BAKED_MEAT
Определения 3_Game/DayZ/constants.c:1100
const float DECAY_FOOD_BOILED_MEAT
Определения 3_Game/DayZ/constants.c:1098
const float DECAY_FOOD_BOILED_FRVG
Определения 3_Game/DayZ/constants.c:1099
const float DECAY_FOOD_DRIED_MEAT
Определения 3_Game/DayZ/constants.c:1102
const float DECAY_FOOD_RAW_CORPSE
Определения 3_Game/DayZ/constants.c:1096
const float DECAY_RATE_ON_PLAYER
Определения 3_Game/DayZ/constants.c:1106
static const float TEMPERATURE_THAW_TIME_COEF_BURNED
Определения 3_Game/DayZ/constants.c:998
static const float TEMPERATURE_FREEZE_TIME_COEF_BURNED
Определения 3_Game/DayZ/constants.c:997
static const float TEMPERATURE_THAW_TIME_COEF_DRIED
Определения 3_Game/DayZ/constants.c:999
static const float TEMPERATURE_FREEZE_TIME_COEF_DRIED
Определения 3_Game/DayZ/constants.c:996
const int STATE_HOT_LVL_TWO
Определения 3_Game/DayZ/constants.c:947
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/DayZ/constants.c:486
vector GetPosition()
Get the world position of the Effect.
Определения Effect.c:473
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.

Используется в Entity::SetTemperatureEx().