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

◆ Consume()

bool ReplaceEdibleWithNewLambda::Consume ( float amount,
PlayerBase consumer )
private

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

1203 : ItemBase
1204{
1205 const string DIRECT_COOKING_SLOT_NAME = "DirectCooking";
1206
1207 const string SOUND_BAKING_START = "Baking_SoundSet";
1208 const string SOUND_BAKING_DONE = "Baking_Done_SoundSet";
1209 const string SOUND_BOILING_START = "Boiling_SoundSet";
1210 const string SOUND_BOILING_DONE = "Boiling_Done_SoundSet";
1211 const string SOUND_DRYING_START = "Drying_SoundSet";
1212 const string SOUND_DRYING_DONE = "Drying_Done_SoundSet";
1213 const string SOUND_BURNING_DONE = "Food_Burning_SoundSet";
1214
1215 protected bool m_MakeCookingSounds;
1216 protected SoundOnVehicle m_SoundCooking;
1218 protected string m_SoundPlaying;
1219 ref FoodStage m_FoodStage;
1220 protected float m_DecayTimer;
1221 protected float m_DecayDelta = 0.0;
1224
1226
1227 void Edible_Base()
1228 {
1229 if (HasFoodStage())
1230 {
1231 m_FoodStage = new FoodStage(this);
1232
1233 RegisterNetSyncVariableInt("m_FoodStage.m_FoodStageType", FoodStageType.NONE, FoodStageType.COUNT);
1234 RegisterNetSyncVariableFloat("m_FoodStage.m_CookingTime", 0, 600, 0);
1235
1236 m_SoundPlaying = "";
1238 RegisterNetSyncVariableInt("m_CookedByMethod", CookingMethodType.NONE, CookingMethodType.COUNT);
1239 RegisterNetSyncVariableBool("m_MakeCookingSounds");
1240 }
1241 }
1242
1243 override void EEInit()
1244 {
1245 super.EEInit();
1246
1247 UpdateVisualsEx(true); //forced init visuals, mostly for debugs and SP
1248 }
1249
1250 override void EEDelete(EntityAI parent)
1251 {
1252 super.EEDelete(parent);
1253
1254 RemoveAudio();
1255
1257 m_HotVaporParticle.Stop();
1258 }
1259
1260 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
1261 {
1262 super.EEItemLocationChanged(oldLoc, newLoc);
1263
1265 if (oldLoc.GetType() == InventoryLocationType.ATTACHMENT || oldLoc.GetType() == InventoryLocationType.CARGO)
1266 {
1267 switch (oldLoc.GetParent().GetType())
1268 {
1269 case "FryingPan":
1270 case "Pot":
1271 case "Cauldron":
1272 case "SharpWoodenStick":
1273 MakeSoundsOnClient(false);
1274 break;
1275 }
1276
1278 if (oldLoc.GetSlot() > -1 && InventorySlots.GetSlotName(oldLoc.GetSlot()).Contains(DIRECT_COOKING_SLOT_NAME))
1279 {
1280 MakeSoundsOnClient(false);
1281 }
1282 }
1283
1284 if (oldLoc.IsValid())
1286
1287 if (CanHaveTemperature())
1289 }
1290
1291 void UpdateVisualsEx(bool forced = false)
1292 {
1293 if (GetFoodStage())
1294 GetFoodStage().UpdateVisualsEx(forced);
1295 }
1296
1297 bool Consume(float amount, PlayerBase consumer)
1298 {
1299 AddQuantity(-amount, false, false);
1300 OnConsume(amount, consumer);
1301
1302 return true;
1303 }
1304
1305 void OnConsume(float amount, PlayerBase consumer)
1306 {
1308 {
1309 consumer.ProcessDirectDamage(DamageType.CUSTOM, this, "", "EnviroDmg", "0 0 0", PlayerConstants.CONSUMPTION_DAMAGE_PER_BITE);
1310 }
1311 }
1312
1314 int FilterAgents(int agentsIn)
1315 {
1316 int foodStageType;
1317
1318 FoodStage foodStage = GetFoodStage();
1319 if (foodStage)
1320 foodStageType = foodStage.GetFoodStageType();
1321
1323 NutritionalProfile nutritionalProfile = GetNutritionalProfile(this, ClassName(), foodStageType);
1324 if ((agentsIn & eAgents.SALMONELLA == eAgents.SALMONELLA) && (nutritionalProfile.m_Agents == 0 || nutritionalProfile.m_AgentsPerDigest == 0))
1325 agentsIn &= ~eAgents.FOOD_POISON;
1326
1327 return agentsIn;
1328 }
1329
1330 //food staging
1331 override bool CanBeCooked()
1332 {
1333 return false;
1334 }
1335
1336 override bool CanBeCookedOnStick()
1337 {
1338 return false;
1339 }
1340
1341 override float GetTemperatureFreezeTime()
1342 {
1343 if (GetFoodStage())
1344 {
1345 switch (m_FoodStage.GetFoodStageType())
1346 {
1347 case FoodStageType.DRIED:
1348 return super.GetTemperatureFreezeTime() * GameConstants.TEMPERATURE_FREEZE_TIME_COEF_DRIED;
1349
1350 case FoodStageType.BURNED:
1351 return super.GetTemperatureFreezeTime() * GameConstants.TEMPERATURE_FREEZE_TIME_COEF_BURNED;
1352
1353 default:
1354 return super.GetTemperatureFreezeTime();
1355 }
1356 }
1357
1358 return super.GetTemperatureFreezeTime();
1359 }
1360
1361 override float GetTemperatureThawTime()
1362 {
1363 if (GetFoodStage())
1364 {
1365 switch (m_FoodStage.GetFoodStageType())
1366 {
1367 case FoodStageType.DRIED:
1368 return super.GetTemperatureThawTime() * GameConstants.TEMPERATURE_THAW_TIME_COEF_DRIED;
1369
1370 case FoodStageType.BURNED:
1371 return super.GetTemperatureThawTime() * GameConstants.TEMPERATURE_THAW_TIME_COEF_BURNED;
1372
1373 default:
1374 return super.GetTemperatureThawTime();
1375 }
1376 }
1377
1378 return super.GetTemperatureThawTime();
1379 }
1380
1381 override bool CanItemOverheat()
1382 {
1383 return super.CanItemOverheat() && (!GetFoodStage() || (IsFoodBurned() || !GetFoodStage().CanTransitionToFoodStageType(FoodStageType.BURNED))); //for foodstaged items - either is burned, or it can't get burned
1384 }
1385
1386 //================================================================
1387 // SYNCHRONIZATION
1388 //================================================================
1389 void Synchronize()
1390 {
1391 SetSynchDirty();
1392 }
1393
1394 override void OnVariablesSynchronized()
1395 {
1396 super.OnVariablesSynchronized();
1397
1398 //UpdateVisualsEx(); //performed on client only
1399
1400 //update audio
1402 {
1403 RefreshAudio();
1404 }
1405 else
1406 {
1407 RemoveAudio();
1408 }
1409
1410 if (CanHaveTemperature())
1412 }
1413
1414 //================================================================
1415 // AUDIO EFFECTS (WHEN ON DCS)
1416 //================================================================
1417 void MakeSoundsOnClient(bool soundstate, CookingMethodType cookingMethod = CookingMethodType.NONE)
1418 {
1419 m_MakeCookingSounds = soundstate;
1420 m_CookedByMethod = cookingMethod;
1421
1422 Synchronize();
1423 }
1424
1425 protected void RefreshAudio()
1426 {
1427 string soundName = "";
1428
1429 FoodStageType currentFoodStage = GetFoodStageType();
1431
1432 if (currentFoodStage == FoodStageType.BURNED)
1433 {
1434 soundName = SOUND_BURNING_DONE;
1435 }
1436 else
1437 {
1438 switch (m_CookedByMethod)
1439 {
1440 case CookingMethodType.BAKING:
1441 {
1442 if (nextFoodStage == FoodStageType.BAKED)
1443 soundName = SOUND_BAKING_START;
1444 else if (currentFoodStage == FoodStageType.BAKED)
1445 soundName = SOUND_BAKING_DONE;
1446 else
1447 soundName = "";
1448 break;
1449 }
1450
1451 case CookingMethodType.BOILING:
1452 {
1453 if (nextFoodStage == FoodStageType.BOILED)
1454 soundName = SOUND_BOILING_START;
1455 else if (currentFoodStage == FoodStageType.BOILED)
1456 soundName = SOUND_BOILING_DONE;
1457 else
1458 soundName = "";
1459 break;
1460 }
1461
1462 case CookingMethodType.DRYING:
1463 {
1464 if (nextFoodStage == FoodStageType.DRIED)
1465 soundName = SOUND_DRYING_START;
1466 else if (currentFoodStage == FoodStageType.DRIED)
1467 soundName = SOUND_DRYING_DONE;
1468 else
1469 soundName = "";
1470 break;
1471 }
1472
1473 default:
1474 soundName = "";
1475 break;
1476 }
1477
1478 if (nextFoodStage == FoodStageType.BURNED)
1479 {
1480 if (soundName == "") //on 'bad' transitions only, indicates bad outcome
1481 {
1482 soundName = SOUND_BURNING_DONE;
1483 }
1484 else // pre-emptive burning sounds replace regular ones
1485 {
1486 array<float> nextStageProperties = new array<float>();
1487 nextStageProperties = FoodStage.GetAllCookingPropertiesForStage(nextFoodStage, null, GetType());
1488 float nextStageTime = nextStageProperties.Get(eCookingPropertyIndices.COOK_TIME);
1489 float progress01 = GetCookingTime() / nextStageTime;
1490 if (progress01 > Cooking.BURNING_WARNING_THRESHOLD)
1491 {
1492 soundName = SOUND_BURNING_DONE;
1493 }
1494 }
1495 }
1496 }
1497
1498 SoundCookingStart(soundName);
1499 }
1500
1501 protected void RemoveAudio()
1502 {
1503 m_MakeCookingSounds = false;
1505 }
1506
1507 //================================================================
1508 // SERIALIZATION
1509 //================================================================
1510 override void OnStoreSave(ParamsWriteContext ctx)
1511 {
1512 super.OnStoreSave(ctx);
1513
1514 if (GetFoodStage())
1515 {
1516 GetFoodStage().OnStoreSave(ctx);
1517 }
1518
1519 // food decay
1520 ctx.Write(m_DecayTimer);
1522 }
1523
1524 override bool OnStoreLoad(ParamsReadContext ctx, int version)
1525 {
1526 if (!super.OnStoreLoad(ctx, version))
1527 return false;
1528
1529 if (GetFoodStage())
1530 {
1531 if (!GetFoodStage().OnStoreLoad(ctx, version))
1532 return false;
1533 }
1534
1535 if (version >= 115)
1536 {
1537 if (!ctx.Read(m_DecayTimer))
1538 {
1539 m_DecayTimer = 0.0;
1540 return false;
1541 }
1542 if (!ctx.Read(m_LastDecayStage))
1543 {
1545 return false;
1546 }
1547 }
1548
1549 UpdateVisualsEx(true); //forced init visuals
1550 Synchronize();
1551
1552 return true;
1553 }
1554
1555 override void AfterStoreLoad()
1556 {
1557 super.AfterStoreLoad();
1558
1559 Synchronize();
1560 }
1561
1562 //get food stage
1563 override FoodStage GetFoodStage()
1564 {
1565 return m_FoodStage;
1566 }
1567
1568 //food types
1569 override bool IsMeat()
1570 {
1571 return false;
1572 }
1573
1574 override bool IsCorpse()
1575 {
1576 return false;
1577 }
1578
1579 override bool IsFruit()
1580 {
1581 return false;
1582 }
1583
1584 override bool IsMushroom()
1585 {
1586 return false;
1587 }
1588
1589 //================================================================
1590 // NUTRITIONAL VALUES
1591 //================================================================
1592 //food properties
1593 static float GetFoodTotalVolume(ItemBase item, string classname = "", int food_stage = 0)
1594 {
1595 Edible_Base food_item = Edible_Base.Cast(item);
1596 if (food_item && food_item.GetFoodStage())
1597 {
1598 return FoodStage.GetFullnessIndex(food_item.GetFoodStage());
1599 }
1600 else if (classname != "" && food_stage)
1601 {
1602 return FoodStage.GetFullnessIndex(null, food_stage, classname);
1603 }
1604 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
1605 return GetGame().ConfigGetFloat( class_path + " fullnessIndex" );
1606
1607 }
1608
1609 static float GetFoodEnergy(ItemBase item, string classname = "", int food_stage = 0)
1610 {
1611 Edible_Base food_item = Edible_Base.Cast(item);
1612 if (food_item && food_item.GetFoodStage())
1613 {
1614 return FoodStage.GetEnergy(food_item.GetFoodStage());
1615 }
1616 else if (classname != "" && food_stage)
1617 {
1618 return FoodStage.GetEnergy(null, food_stage, classname);
1619 }
1620 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
1621 return GetGame().ConfigGetFloat( class_path + " energy" );
1622 }
1623
1624 static float GetFoodWater(ItemBase item, string classname = "", int food_stage = 0)
1625 {
1626 Edible_Base food_item = Edible_Base.Cast(item);
1627 if (food_item && food_item.GetFoodStage())
1628 {
1629 return FoodStage.GetWater(food_item.GetFoodStage());
1630 }
1631 else if (classname != "" && food_stage)
1632 {
1633 return FoodStage.GetWater(null, food_stage, classname);
1634 }
1635 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
1636 return GetGame().ConfigGetFloat( class_path + " water" );
1637 }
1638
1639 static float GetFoodNutritionalIndex(ItemBase item, string classname = "", int food_stage = 0)
1640 {
1641 Edible_Base food_item = Edible_Base.Cast(item);
1642 if (food_item && food_item.GetFoodStage())
1643 {
1644 return FoodStage.GetNutritionalIndex(food_item.GetFoodStage());
1645 }
1646 else if (classname != "" && food_stage)
1647 {
1648 return FoodStage.GetNutritionalIndex(null, food_stage, classname);
1649 }
1650 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
1651 return GetGame().ConfigGetFloat( class_path + " nutritionalIndex" );
1652
1653 }
1654
1655 static float GetFoodToxicity(ItemBase item, string classname = "", int food_stage = 0)
1656 {
1657 Edible_Base food_item = Edible_Base.Cast(item);
1658 if (food_item && food_item.GetFoodStage())
1659 {
1660 return FoodStage.GetToxicity(food_item.GetFoodStage());
1661 }
1662 else if (classname != "" && food_stage)
1663 {
1664 return FoodStage.GetToxicity(null, food_stage, classname);
1665 }
1666 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
1667 return GetGame().ConfigGetFloat( class_path + " toxicity" );
1668 }
1669
1670 static int GetFoodAgents(ItemBase item, string classname = "", int food_stage = 0)
1671 {
1672 Edible_Base food_item = Edible_Base.Cast(item);
1673 if (food_item && food_item.GetFoodStage())
1674 {
1675 return FoodStage.GetAgents(food_item.GetFoodStage());
1676 }
1677 else if (classname != "" && food_stage)
1678 {
1679 return FoodStage.GetAgents(null, food_stage, classname);
1680 }
1681 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
1682 return GetGame().ConfigGetInt( class_path + " agents" );
1683 }
1684
1685 static float GetFoodDigestibility(ItemBase item, string classname = "", int food_stage = 0)
1686 {
1687 Edible_Base food_item = Edible_Base.Cast(item);
1688 if (food_item && food_item.GetFoodStage())
1689 {
1690 return FoodStage.GetDigestibility(food_item.GetFoodStage());
1691 }
1692 else if (classname != "" && food_stage)
1693 {
1694 return FoodStage.GetDigestibility(null, food_stage, classname);
1695 }
1696 string class_path = string.Format("cfgVehicles %1 Nutrition", classname);
1697 return GetGame().ConfigGetInt( class_path + " digestibility" );
1698 }
1699
1700 static float GetAgentsPerDigest(ItemBase item, string className = "", int foodStage = 0)
1701 {
1702 Edible_Base foodItem = Edible_Base.Cast(item);
1703 if (foodItem && foodItem.GetFoodStage())
1704 {
1705 return FoodStage.GetAgentsPerDigest(foodItem.GetFoodStage());
1706 }
1707 else if (className != "" && foodStage)
1708 {
1709 return FoodStage.GetAgentsPerDigest(null, foodStage, className);
1710 }
1711 string classPath = string.Format("cfgVehicles %1 Nutrition", className);
1712 return GetGame().ConfigGetInt(classPath + " agentsPerDigest");
1713 }
1714
1715 static NutritionalProfile GetNutritionalProfile(ItemBase item, string classname = "", int food_stage = 0)
1716 {
1717 NutritionalProfile profile = new NutritionalProfile();
1718 profile.m_Energy = GetFoodEnergy(item, classname, food_stage);
1719 profile.m_WaterContent = GetFoodWater(item, classname, food_stage);
1720 profile.m_NutritionalIndex = GetFoodNutritionalIndex(item, classname, food_stage);
1721 profile.m_FullnessIndex = GetFoodTotalVolume(item, classname, food_stage);
1722 profile.m_Toxicity = GetFoodToxicity(item, classname, food_stage);
1723 profile.m_Agents = GetFoodAgents(item, classname, food_stage);
1724 profile.m_Digestibility = GetFoodDigestibility(item, classname, food_stage);
1725 profile.m_AgentsPerDigest = GetAgentsPerDigest(item, classname, food_stage);
1726
1727 return profile;
1728 }
1729
1730 //================================================================
1731 // FOOD STAGING
1732 //================================================================
1734 {
1735 return GetFoodStage().GetFoodStageType();
1736 }
1737
1738 //food stage states
1739 bool IsFoodRaw()
1740 {
1741 if ( GetFoodStage() )
1742 {
1743 return GetFoodStage().IsFoodRaw();
1744 }
1745
1746 return false;
1747 }
1748
1749 bool IsFoodBaked()
1750 {
1751 if ( GetFoodStage() )
1752 {
1753 return GetFoodStage().IsFoodBaked();
1754 }
1755
1756 return false;
1757 }
1758
1759 bool IsFoodBoiled()
1760 {
1761 if ( GetFoodStage() )
1762 {
1763 return GetFoodStage().IsFoodBoiled();
1764 }
1765
1766 return false;
1767 }
1768
1769 bool IsFoodDried()
1770 {
1771 if ( GetFoodStage() )
1772 {
1773 return GetFoodStage().IsFoodDried();
1774 }
1775
1776 return false;
1777 }
1778
1779 bool IsFoodBurned()
1780 {
1781 if ( GetFoodStage() )
1782 {
1783 return GetFoodStage().IsFoodBurned();
1784 }
1785
1786 return false;
1787 }
1788
1789 bool IsFoodRotten()
1790 {
1791 if ( GetFoodStage() )
1792 {
1793 return GetFoodStage().IsFoodRotten();
1794 }
1795
1796 return false;
1797 }
1798
1799 //food stage change
1800 void ChangeFoodStage( FoodStageType new_food_stage_type )
1801 {
1802 GetFoodStage().ChangeFoodStage( new_food_stage_type );
1803 }
1804
1806 {
1807 return GetFoodStage().GetNextFoodStageType( cooking_method );
1808 }
1809
1810 string GetFoodStageName( FoodStageType food_stage_type )
1811 {
1812 return GetFoodStage().GetFoodStageName( food_stage_type );
1813 }
1814
1815 bool CanChangeToNewStage( CookingMethodType cooking_method )
1816 {
1817 return GetFoodStage().CanChangeToNewStage( cooking_method );
1818 }
1819
1820 //Use this to receive food stage from another Edible_Base
1821 void TransferFoodStage( notnull Edible_Base source )
1822 {
1823 if ( !source.GetFoodStage())
1824 return;
1825 m_LastDecayStage = source.GetLastDecayStage();
1826 ChangeFoodStage(source.GetFoodStage().GetFoodStageType());
1827 m_DecayTimer = source.GetDecayTimer();
1828 m_DecayDelta = source.GetDecayDelta();
1829 }
1830
1832 void OnFoodStageChange(FoodStageType stageOld, FoodStageType stageNew)
1833 {
1834 HandleFoodStageChangeAgents(stageOld,stageNew);
1835 UpdateVisualsEx(); //performed on server only
1836 }
1837
1840 {
1841 switch (stageNew)
1842 {
1843 case FoodStageType.BAKED:
1844 case FoodStageType.BOILED:
1845 case FoodStageType.DRIED:
1846 RemoveAllAgentsExcept(eAgents.BRAIN|eAgents.HEAVYMETAL);
1847 break;
1848
1849 case FoodStageType.BURNED:
1850 RemoveAllAgentsExcept(eAgents.BRAIN|eAgents.HEAVYMETAL);
1851 break;
1852 }
1853 }
1854
1855 //================================================================
1856 // COOKING
1857 //================================================================
1858 //cooking time
1859 float GetCookingTime()
1860 {
1861 return GetFoodStage().GetCookingTime();
1862 }
1863
1864 void SetCookingTime( float time )
1865 {
1866 GetFoodStage().SetCookingTime( time );
1867
1868 //synchronize when calling on server
1869 Synchronize();
1870 }
1871
1872 void ResetCookingTime()
1873 {
1874 if (GetFoodStage())
1875 {
1876 GetFoodStage().SetCookingTime(0);
1877 Synchronize();
1878 }
1879 }
1880
1881 //replace edible with new item (opening cans)
1882 void ReplaceEdibleWithNew( string typeName )
1883 {
1884 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
1885 if (player)
1886 {
1887 ReplaceEdibleWithNewLambda lambda = new ReplaceEdibleWithNewLambda(this, typeName, player);
1888 player.ServerReplaceItemInHandsWithNew(lambda);
1889 }
1890 else
1891 Error("ReplaceEdibleWithNew - cannot use edible without player");
1892 }
1893
1895 {
1897 }
1898
1899 override void SetActions()
1900 {
1901 super.SetActions();
1902
1905 }
1906
1907 protected void SoundCookingStart(string sound_name)
1908 {
1909 #ifndef SERVER
1910 if (m_SoundPlaying != sound_name)
1911 {
1913
1914 m_SoundEffectCooking = SEffectManager.PlaySound(sound_name, GetPosition(), 0, 0, true);
1915 m_SoundPlaying = sound_name;
1916 }
1917 #endif
1918 }
1919
1920 protected void SoundCookingStop()
1921 {
1922 #ifndef SERVER
1924 {
1925 m_SoundEffectCooking.Stop();
1926 m_SoundEffectCooking = null;
1927 m_SoundPlaying = "";
1928 }
1929 #endif
1930 }
1931
1932 override bool CanDecay()
1933 {
1934 return false;
1935 }
1936
1937 override bool CanProcessDecay()
1938 {
1939 return !GetIsFrozen() && ( GetFoodStageType() != FoodStageType.ROTTEN );
1940 }
1941
1942 override void ProcessDecay( float delta, bool hasRootAsPlayer )
1943 {
1944 m_DecayDelta = 0.0;
1945
1946 delta *= DayZGame.Cast(GetGame()).GetFoodDecayModifier();
1947 m_DecayDelta += ( 1 + ( 1 - GetHealth01( "", "" ) ) );
1948 if ( hasRootAsPlayer )
1950
1951 /*Print( "-------------------------" );
1952 Print( this );
1953 Print( m_DecayTimer );
1954 Print( m_DecayDelta );
1955 Print( m_LastDecayStage );*/
1956
1957 if ( IsFruit() || IsMushroom() )
1958 {
1959 // fruit, vegetables and mushrooms
1961 {
1962 switch ( GetFoodStageType() )
1963 {
1964 case FoodStageType.RAW:
1967 break;
1968
1969 case FoodStageType.BOILED:
1972 break;
1973
1974 case FoodStageType.BAKED:
1977 break;
1978
1979 case FoodStageType.DRIED:
1980 case FoodStageType.BURNED:
1981 case FoodStageType.ROTTEN:
1982 default:
1983 m_DecayTimer = -1;
1985 return;
1986 }
1987
1988 //m_DecayTimer = m_DecayTimer / 1000.0;
1989 }
1990
1991 m_DecayTimer -= ( delta * m_DecayDelta );
1992
1993 if ( m_DecayTimer <= 0 )
1994 {
1995 if ( m_LastDecayStage != FoodStageType.NONE )
1996 {
1997 // switch to decayed stage
1998 if ( ( m_LastDecayStage == FoodStageType.BOILED ) || ( m_LastDecayStage == FoodStageType.BAKED ) )
1999 {
2001 }
2002 if ( m_LastDecayStage == FoodStageType.RAW )
2003 {
2004 int rng = Math.RandomIntInclusive( 0, 100 );
2006 {
2008 }
2009 else
2010 {
2011 if ( CanChangeToNewStage( FoodStageType.DRIED ) )
2012 {
2014 }
2015 else
2016 {
2018 }
2019 }
2020 }
2021 }
2022 }
2023
2024 }
2025 else if ( IsMeat() )
2026 {
2027 // meat
2029 {
2030 switch ( GetFoodStageType() )
2031 {
2032 case FoodStageType.RAW:
2035 break;
2036
2037 case FoodStageType.BOILED:
2040 break;
2041
2042 case FoodStageType.BAKED:
2045 break;
2046
2047 case FoodStageType.DRIED:
2050 break;
2051
2052 case FoodStageType.BURNED:
2053 case FoodStageType.ROTTEN:
2054 default:
2055 m_DecayTimer = -1;
2057 return;
2058 }
2059 }
2060
2061 m_DecayTimer -= ( delta * m_DecayDelta );
2062
2063 if ( m_DecayTimer <= 0 )
2064 {
2065 if ( m_LastDecayStage != FoodStageType.NONE )
2066 {
2067 // switch to decayed stage
2068 if ( ( m_LastDecayStage == FoodStageType.DRIED ) || ( m_LastDecayStage == FoodStageType.RAW ) || ( m_LastDecayStage == FoodStageType.BOILED ) || ( m_LastDecayStage == FoodStageType.BAKED ) )
2069 {
2071 }
2072 }
2073 }
2074 }
2075 else if ( IsCorpse() )
2076 {
2077 // corpse
2079 {
2080 switch ( GetFoodStageType() )
2081 {
2082 case FoodStageType.RAW:
2085 break;
2086
2087 case FoodStageType.BURNED:
2088 case FoodStageType.ROTTEN:
2089 default:
2090 m_DecayTimer = -1;
2092 return;
2093 }
2094 }
2095
2096 m_DecayTimer -= ( delta * m_DecayDelta );
2097
2098 if ( m_DecayTimer <= 0 )
2099 {
2100 if ( m_LastDecayStage != FoodStageType.NONE )
2101 {
2102 // switch to decayed stage
2103 if ( ( m_LastDecayStage == FoodStageType.DRIED ) || ( m_LastDecayStage == FoodStageType.RAW ) || ( m_LastDecayStage == FoodStageType.BOILED ) || ( m_LastDecayStage == FoodStageType.BAKED ) )
2104 {
2106 }
2107 }
2108 }
2109 }
2110 else
2111 {
2112 // opened cans
2113 m_DecayTimer -= ( delta * m_DecayDelta );
2114
2115 if ( ( m_DecayTimer <= 0 ) && ( m_LastDecayStage == FoodStageType.NONE ) )
2116 {
2119 //m_DecayTimer = m_DecayTimer / 1000.0;
2120 }
2121 else
2122 {
2123 if ( m_DecayTimer <= 0 )
2124 {
2125 InsertAgent(eAgents.FOOD_POISON, 1);
2126 m_DecayTimer = -1;
2127 }
2128 }
2129 }
2130 }
2131
2132 protected void UpdateVaporParticle()
2133 {
2134 if (GetGame().IsDedicatedServer())
2135 return;
2136
2137 if (m_VarTemperature >= GameConstants.STATE_HOT_LVL_TWO && !m_HotVaporParticle)
2138 {
2139 InventoryLocation invLoc = new InventoryLocation();
2140 GetInventory().GetCurrentInventoryLocation(invLoc);
2141 if (invLoc && (invLoc.GetType() == InventoryLocationType.GROUND || invLoc.GetType() == InventoryLocationType.HANDS || invLoc.GetType() == InventoryLocationType.ATTACHMENT))
2142 {
2143 ParticleManager ptcMgr = ParticleManager.GetInstance();
2144 if (ptcMgr)
2145 {
2146 m_HotVaporParticle = ParticleManager.GetInstance().PlayOnObject(ParticleList.ITEM_HOT_VAPOR, this);
2147 m_HotVaporParticle.SetParticleParam(EmitorParam.SIZE, 0.3);
2148 m_HotVaporParticle.SetParticleParam(EmitorParam.BIRTH_RATE, 10);
2149 m_HotVaporParticle.SetParticleAutoDestroyFlags(ParticleAutoDestroyFlags.ON_STOP);
2150 }
2151 }
2152 }
2153 else if (m_HotVaporParticle)
2154 {
2155 if (m_VarTemperature <= GameConstants.STATE_HOT_LVL_TWO)
2156 {
2157 m_HotVaporParticle.Stop();
2158 m_HotVaporParticle = null;
2159 return;
2160 }
2161
2162 InventoryLocation inventoryLoc = new InventoryLocation();
2163 GetInventory().GetCurrentInventoryLocation(inventoryLoc);
2164 if (invLoc && (invLoc.GetType() != InventoryLocationType.GROUND && invLoc.GetType() != InventoryLocationType.HANDS))
2165 {
2166 m_HotVaporParticle.Stop();
2167 m_HotVaporParticle = null;
2168 }
2169 }
2170 }
2171
2172 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
2173 {
2174 if (GetFoodStage())
2175 {
2176 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FOOD_NUTRITIONS_DATA, "Food Nutritions Data", FadeColors.WHITE));
2177 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FOOD_STAGE_PREV, "Food Stage Prev", FadeColors.WHITE));
2178 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FOOD_STAGE_NEXT, "Food Stage Next", FadeColors.WHITE));
2179 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
2180 }
2181
2182 super.GetDebugActions(outputList);
2183 }
2184
2185 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
2186 {
2187 super.OnAction(action_id, player, ctx);
2188
2189 if ( GetGame().IsServer() )
2190 {
2191 if ( action_id == EActions.FOOD_STAGE_PREV )
2192 {
2193 int food_stage_prev = GetFoodStageType() - 1;
2194 if (food_stage_prev <= 0)
2195 {
2196 food_stage_prev = FoodStageType.COUNT - 1;
2197 }
2198 ChangeFoodStage(food_stage_prev);
2199 return true;
2200 }
2201 else if ( action_id == EActions.FOOD_STAGE_NEXT )
2202 {
2203 int food_stage_next = GetFoodStageType() + 1;
2204 if (food_stage_next >= FoodStageType.COUNT )
2205 {
2206 food_stage_next = FoodStageType.RAW;
2207 }
2208 ChangeFoodStage(food_stage_next);
2209 return true;
2210 }
2211
2212 }
2213
2214 #ifdef DIAG_DEVELOPER
2215 if (action_id == EActions.FOOD_NUTRITIONS_DATA)
2216 {
2217 PrintNutritionsData();
2218 return true;
2219 }
2220 #endif
2221
2222 return false;
2223 }
2224
2225 override string GetDebugText()
2226 {
2227 string debug_output;
2228
2229 debug_output = super.GetDebugText();
2230
2231 debug_output+="m_CookedByMethod:"+m_CookedByMethod+"\n";
2232 debug_output+="m_MakeCookingSounds:"+m_MakeCookingSounds+"\n";
2233
2234 return debug_output;
2235 }
2236
2237 //================================================================
2238 // GENERAL GETTERS
2239 //================================================================
2240
2241 override float GetBaitEffectivity()
2242 {
2243 float ret = super.GetBaitEffectivity();
2244
2245 if (IsFoodRotten())
2246 {
2247 ret *= 0.5;
2248 }
2249
2250 return ret;
2251 }
2252
2253 float GetDecayTimer()
2254 {
2255 return m_DecayTimer;
2256 }
2257
2258 float GetDecayDelta()
2259 {
2260 return m_DecayDelta;
2261 }
2262
2264 {
2265 return m_LastDecayStage;
2266 }
2267
2268 #ifdef DIAG_DEVELOPER
2269 private void PrintNutritionsData()
2270 {
2271 string nutritionsData = "";
2272
2273 FoodStage stage = GetFoodStage();
2274 FoodStageType stageType = stage.GetFoodStageType();
2275
2276 NutritionalProfile profile = GetNutritionalProfile(this, ClassName(), stageType);
2277 if (profile)
2278 {
2279 nutritionsData = string.Format("Item: %1\n\n", this);
2280 nutritionsData += string.Format("Stage name: %1\n", GetFoodStageName(stageType));
2281 nutritionsData += string.Format("Energy: %1\n", profile.m_Energy);
2282 nutritionsData += string.Format("Water content: %1\n", profile.m_WaterContent);
2283 nutritionsData += string.Format("Nutritional index: %1\n", profile.m_NutritionalIndex);
2284 nutritionsData += string.Format("Fullness index: %1\n", profile.m_FullnessIndex);
2285 nutritionsData += string.Format("Toxicity (obsolete): %1\n", profile.m_Toxicity);
2286 nutritionsData += string.Format("Digestibility: %1\n", profile.m_Digestibility);
2287
2288 if (profile.IsLiquid())
2289 nutritionsData += string.Format("Liquid type: %1\n", profile.m_LiquidClassname);
2290
2291 nutritionsData += string.Format("Agents: %1\n", profile.m_Agents);
2292 nutritionsData += string.Format("Agents per consume: %1\n", profile.m_AgentsPerDigest);
2293 }
2294
2295 nutritionsData += "-----\n";
2296
2297 Debug.Log(nutritionsData);
2298 }
2299 #endif
2300
2302 //DEPRECATED
2304 void UpdateVisuals()
2305 {
2307 }
2308}
2309
2311{
2312 void ReplaceEdibleWithNewLambda(EntityAI old_item, string new_item_type, PlayerBase player) { }
2313};
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.

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