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

◆ EEItemLocationChanged()

override void ReplaceEdibleWithNewLambda::EEItemLocationChanged ( notnull InventoryLocation oldLoc,
notnull InventoryLocation newLoc )
private

disable sounds (from cooking)

check for DirectCooking slot name

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

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