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

◆ EEDelete()

override void ReplaceEdibleWithNewLambda::EEDelete ( EntityAI parent)
private

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

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