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

◆ MoveItemToCorrectPosition()

bool PluginBase::MoveItemToCorrectPosition ( InventoryLocation ilCorrect)
inlineprotected

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

58 {
59 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
60 InventoryLocation ilTemp = new InventoryLocation;
61
62 EntityAI item = ilCorrect.GetItem();
63 EntityAI parent = ilCorrect.GetParent();
64 item.GetInventory().GetCurrentInventoryLocation(ilTemp);
65
66 switch(ilCorrect.GetType())
67 {
68 case InventoryLocationType.CARGO:
69 InventoryLocation ilCargoItem = new InventoryLocation;
70 CargoBase cargo = parent.GetInventory().GetCargo();
71 for(int i = cargo.GetItemCount() - 1; i >= 0 ; --i)
72 {
73 EntityAI itemInCargo = cargo.GetItem(i);
74 if (itemInCargo != item)
75 {
76 itemInCargo.GetInventory().GetCurrentInventoryLocation(ilCargoItem);
77 if (ilCorrect.CollidesWith(ilCargoItem))
78 {
79 if (!RepairItem(itemInCargo))
80 {
81 return false;
82 }
83 }
84 }
85 }
86 break;
87 case InventoryLocationType.ATTACHMENT:
88 EntityAI entityInAttachment = parent.GetInventory().FindAttachment(ilCorrect.GetSlot());
89
90 if(entityInAttachment)
91 {
92 if (!RepairItem(entityInAttachment))
93 {
94 return false;
95 }
96 }
97
98 break;
99 case InventoryLocationType.HANDS:
100 EntityAI entityInHands = player.GetItemInHands();
101 if(entityInHands)
102 {
103 if (!RepairItem(entityInHands))
104 {
105 return false;
106 }
107 }
108
109 break;
110 default:
111 break;
112 }
113
114 if (!GameInventory.LocationSyncMoveEntity(ilTemp, ilCorrect))
115 {
116 if (ilTemp.GetType() != InventoryLocationType.TEMP)
117 RepairItem(item);
118 return false;
119 }
120
121 return true;
122 }
class LogManager EntityAI
DayZGame g_Game
Определения DayZGame.c:3942
InventoryLocationType
types of Inventory Location
Определения InventoryLocation.c:4
proto native int GetItemCount()
proto native EntityAI GetItem(int index)
proto native EntityAI GetParent()
returns parent of current inventory location
proto native int GetSlot()
returns slot id if current type is Attachment
proto native bool CollidesWith(notnull InventoryLocation rhs)
checks if inventory locations collides each with other
proto native int GetType()
returns type of InventoryLocation
proto native EntityAI GetItem()
returns item of current inventory location
bool RepairItem(EntityAI itemToRepair)
Определения PluginInventoryRepair.c:19

Перекрестные ссылки InventoryLocation::CollidesWith(), g_Game, CargoBase::GetItem(), InventoryLocation::GetItem(), CargoBase::GetItemCount(), InventoryLocation::GetParent(), InventoryLocation::GetSlot(), InventoryLocation::GetType(), GameInventory::LocationSyncMoveEntity() и RepairItem().

Используется в OnUpdate().