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

◆ InventoryReservation()

override bool FirearmActionAttachMagazine::InventoryReservation ( ActionData action_data)
inlineprivate

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

116 {
117 if( (IsLocal() || !UseAcknowledgment()) && IsInstant() )
118 return true;
119
120 bool success = true;
121 InventoryLocation oldMagTargetInventoryLocation = NULL;
122 InventoryLocation targetInventoryLocation = NULL;
123 InventoryLocation handInventoryLocation = NULL;
124
125 PlayerBase player = action_data.m_Player;
126 AttachMagazineActionData am_action_data = AttachMagazineActionData.Cast(action_data);
127
128 Weapon_Base wpn = Weapon_Base.Cast(action_data.m_MainItem);
129 int muzzle_index = wpn.GetCurrentMuzzle();
130
131 Magazine new_mag = Magazine.Cast(action_data.m_Target.GetObject());
132
133 if (am_action_data.m_oldMagazine)
134 {
135 oldMagTargetInventoryLocation = new InventoryLocation;
136 if ( action_data.m_Player.GetInventory().HasInventoryReservation( am_action_data.m_oldMagazine, am_action_data.m_ilOldMagazine) )
137 {
138 success = false;
139 }
140 else
141 {
142 player.GetInventory().AddInventoryReservationEx(am_action_data.m_oldMagazine,am_action_data.m_ilOldMagazine,GameInventory.c_InventoryReservationTimeoutMS);
143 }
144 }
145
146 if (success)
147 {
148 targetInventoryLocation = new InventoryLocation;
149 targetInventoryLocation.SetAttachment( wpn, new_mag, InventorySlots.MAGAZINE);
150 if ( action_data.m_Player.GetInventory().HasInventoryReservation( new_mag, targetInventoryLocation) )
151 {
152 success = false;
153 if (am_action_data.m_oldMagazine)
154 {
155 player.GetInventory().ClearInventoryReservation(am_action_data.m_oldMagazine,am_action_data.m_ilOldMagazine);
156 }
157 }
158 else
159 {
160 action_data.m_Player.GetInventory().AddInventoryReservationEx( new_mag, targetInventoryLocation, GameInventory.c_InventoryReservationTimeoutMS);
161 }
162 }
163
164 if (success)
165 {
166 handInventoryLocation = new InventoryLocation;
167 handInventoryLocation.SetHands(action_data.m_Player, wpn);
168
169 if ( action_data.m_Player.GetInventory().HasInventoryReservation( wpn, handInventoryLocation) )
170 {
171 if (am_action_data.m_oldMagazine)
172 {
173 player.GetInventory().ClearInventoryReservation(am_action_data.m_oldMagazine,am_action_data.m_ilOldMagazine);
174 }
175 player.GetInventory().ClearInventoryReservation(new_mag, targetInventoryLocation);
176 success = false;
177 }
178 else
179 {
180 action_data.m_Player.GetInventory().AddInventoryReservationEx( wpn, handInventoryLocation, GameInventory.c_InventoryReservationTimeoutMS);
181 }
182 }
183
184 if ( success )
185 {
186 if (am_action_data.m_ilOldMagazine)
187 action_data.m_ReservedInventoryLocations.Insert(am_action_data.m_ilOldMagazine);
188
189 if (targetInventoryLocation)
190 action_data.m_ReservedInventoryLocations.Insert(targetInventoryLocation);
191
192 if (handInventoryLocation)
193 action_data.m_ReservedInventoryLocations.Insert(handInventoryLocation);
194 }
195
196 return success;
197 }
bool UseAcknowledgment()
Определения ActionBase.c:1123
bool IsInstant()
Определения ActionBase.c:262
bool IsLocal()
Определения ActionBase.c:256
proto native void SetHands(notnull EntityAI parent, EntityAI e)
sets current inventory location type to Hands
proto native void SetAttachment(notnull EntityAI parent, EntityAI e, int slotId)
sets current inventory location type to Attachment with slot id set to <slotId>

Перекрестные ссылки ActionData, GameInventory::c_InventoryReservationTimeoutMS, ActionBase::IsInstant(), ActionBase::IsLocal(), InventoryLocation::SetAttachment(), InventoryLocation::SetHands() и ActionBase::UseAcknowledgment().

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