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

◆ ApplyWetnessToItem()

void ApplyWetnessToItem ( ItemBase pItem)
protected

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

736 {
737 if (pItem)
738 {
739 ItemBase parentItem;
740 bool isParentWet = false;
741 bool parentContainsLiquid = false;
743
744 if (pItem.GetInventory().GetCurrentInventoryLocation(iLoc))
745 {
746 EntityAI parent = iLoc.GetParent();
747 if (parent)
748 {
749 parentItem = ItemBase.Cast(parent);
750 if (parentItem)
751 {
752 if (parentItem.GetWet() >= GameConstants.STATE_SOAKING_WET)
753 isParentWet = true;
754
755 if ((parentItem.GetLiquidType() != 0) && (parentItem.GetQuantity() > 0))
756 parentContainsLiquid = true;
757 }
758 else
759 isParentWet = true;
760
761 if ((pItem.GetWet() > m_ItemsWetnessMax) && (parent == m_Player))
762 m_ItemsWetnessMax = pItem.GetWet();
763 }
764 }
765
766 if (isParentWet || parentContainsLiquid)
767 {
768 float soakingCoef = 0;
769 if (parentContainsLiquid)
770 {
771 soakingCoef = pItem.GetSoakingIncrement("parentWithLiquid");
772 #ifdef ENABLE_LOGGING
773 LogDryWetProcess(string.Format("%1 (soak coef=%2/s, current wetness=%3) [parent contains liquid]", pItem.GetDisplayName(), soakingCoef / GameConstants.ENVIRO_TICK_RATE, pItem.GetWet()), parentItem != null);
774 #endif
775 }
776 else if (isParentWet && parentItem)
777 {
778 if (pItem.GetWet() < parentItem.GetWet())
779 soakingCoef = GetWetDelta();
780
781 #ifdef ENABLE_LOGGING
782 LogDryWetProcess(string.Format("%1 (soak coef=%2/s, current wetness=%3) [parent wet]", pItem.GetDisplayName(), soakingCoef / GameConstants.ENVIRO_TICK_RATE, pItem.GetWet()), parentItem != null);
783 #endif
784 }
785 else
786 {
787 soakingCoef = GetWetDelta();
788 #ifdef ENABLE_LOGGING
789 LogDryWetProcess(string.Format("%1 (soak coef=%2/s, current wetness=%3) [normal]", pItem.GetDisplayName(), soakingCoef / GameConstants.ENVIRO_TICK_RATE, pItem.GetWet()), parentItem != null);
790 #endif
791 }
792
793 pItem.AddWet(soakingCoef);
794
795 if (pItem.GetInventory().GetCargo())
796 {
797 int inItemCount = pItem.GetInventory().GetCargo().GetItemCount();
798 for (int i = 0; i < inItemCount; ++i)
799 {
800 ItemBase inItem;
801 if (Class.CastTo(inItem, pItem.GetInventory().GetCargo().GetItem(i)))
802 ApplyWetnessToItem(inItem);
803 }
804 }
805
806 int attCount = pItem.GetInventory().AttachmentCount();
807 if (attCount > 0)
808 {
809 for (int attIdx = 0; attIdx < attCount; ++attIdx)
810 {
811 EntityAI attachment = pItem.GetInventory().GetAttachmentFromIndex(attIdx);
812 ItemBase itemAtt = ItemBase.Cast(attachment);
813 if (itemAtt)
814 ApplyWetnessToItem(itemAtt);
815 }
816 }
817 }
818 }
819 }
map m_Player
float GetWetDelta()
Calculates soaking/drying delta based on character's location and weather.
Определения Environment.c:566
void ApplyWetnessToItem(ItemBase pItem)
Определения Environment.c:735
float m_ItemsWetnessMax
Определения Environment.c:39
Super root of all classes in Enforce script.
Определения EnScript.c:11
proto native EntityAI GetParent()
returns parent of current inventory location
InventoryLocation.
Определения InventoryLocation.c:30
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
const float ENVIRO_TICK_RATE
Определения 3_Game/DayZ/constants.c:723
const float STATE_SOAKING_WET
Определения 3_Game/DayZ/constants.c:876

Перекрестные ссылки ApplyWetnessToItem(), Class::CastTo(), GameConstants::ENVIRO_TICK_RATE, InventoryLocation::GetParent(), GetWetDelta(), m_ItemsWetnessMax и GameConstants::STATE_SOAKING_WET.

Используется в ApplyWetnessToItem() и ProcessItemsWetness().