21 override int GetActionCategory()
28 if (!super.ActionCondition( player, target, item ))
32 Magazine mag = Magazine.Cast(target.GetObject());
34 return mag && (player.GetWeaponManager().CanAttachMagazine(wpn,mag) || player.GetWeaponManager().CanSwapMagazine(wpn,mag)) && (!hcw || hcw.GetRunningAction() !=
WeaponActions.RELOAD);
37 override bool ActionConditionContinue(
ActionData action_data )
44 AttachMagazineActionData action_data =
new AttachMagazineActionData;
51 super.WriteToContext(ctx, action_data);
53 AttachMagazineActionData action_data_am = AttachMagazineActionData.Cast(action_data);
55 action_data_am.m_ilOldMagazine.WriteToContext(ctx);
58 override bool ReadFromContext(
ParamsReadContext ctx, out ActionReciveData action_recive_data )
60 if (!action_recive_data)
65 super.ReadFromContext(ctx, action_recive_data);
68 if (!il.ReadFromContext(ctx))
72 recive_data_am.m_ilOldMagazine = il;
77 override void HandleReciveData(ActionReciveData action_recive_data,
ActionData action_data)
80 AttachMagazineActionData action_data_am = AttachMagazineActionData.Cast(action_data);
82 action_data.m_MainItem = action_recive_data.m_MainItem;
83 if (!action_recive_data.m_Target)
89 action_data.m_Target = action_recive_data.m_Target;
91 action_data_am.m_ilOldMagazine = recive_data_am.m_ilOldMagazine;
94 override bool Post_SetupAction(
ActionData action_data )
96 if ( !
GetGame().IsDedicatedServer() )
99 int muzzle_index = wpn.GetCurrentMuzzle();
101 AttachMagazineActionData am_action_data = AttachMagazineActionData.Cast(action_data);
102 am_action_data.m_oldMagazine = wpn.GetMagazine(muzzle_index);
106 if (!action_data.m_Player.GetWeaponManager().PrepareInventoryLocationForMagazineSwap(wpn, Magazine.Cast(action_data.m_Target.GetObject()), new_il))
110 am_action_data.m_ilOldMagazine = new_il;
115 override bool InventoryReservation(
ActionData action_data)
126 AttachMagazineActionData am_action_data = AttachMagazineActionData.Cast(action_data);
129 int muzzle_index = wpn.GetCurrentMuzzle();
131 Magazine new_mag = Magazine.Cast(action_data.m_Target.GetObject());
133 if (am_action_data.m_oldMagazine)
136 if ( action_data.m_Player.GetInventory().HasInventoryReservation( am_action_data.m_oldMagazine, am_action_data.m_ilOldMagazine) )
142 player.GetInventory().AddInventoryReservationEx(am_action_data.m_oldMagazine,am_action_data.m_ilOldMagazine,
GameInventory.c_InventoryReservationTimeoutMS);
149 targetInventoryLocation.SetAttachment( wpn, new_mag,
InventorySlots.MAGAZINE);
150 if ( action_data.m_Player.GetInventory().HasInventoryReservation( new_mag, targetInventoryLocation) )
153 if (am_action_data.m_oldMagazine)
155 player.GetInventory().ClearInventoryReservation(am_action_data.m_oldMagazine,am_action_data.m_ilOldMagazine);
160 action_data.m_Player.GetInventory().AddInventoryReservationEx( new_mag, targetInventoryLocation,
GameInventory.c_InventoryReservationTimeoutMS);
167 handInventoryLocation.SetHands(action_data.m_Player, wpn);
169 if ( action_data.m_Player.GetInventory().HasInventoryReservation( wpn, handInventoryLocation) )
171 if (am_action_data.m_oldMagazine)
173 player.GetInventory().ClearInventoryReservation(am_action_data.m_oldMagazine,am_action_data.m_ilOldMagazine);
175 player.GetInventory().ClearInventoryReservation(new_mag, targetInventoryLocation);
180 action_data.m_Player.GetInventory().AddInventoryReservationEx( wpn, handInventoryLocation,
GameInventory.c_InventoryReservationTimeoutMS);
186 if (am_action_data.m_ilOldMagazine)
187 action_data.m_ReservedInventoryLocations.Insert(am_action_data.m_ilOldMagazine);
189 if (targetInventoryLocation)
190 action_data.m_ReservedInventoryLocations.Insert(targetInventoryLocation);
192 if (handInventoryLocation)
193 action_data.m_ReservedInventoryLocations.Insert(handInventoryLocation);
201 super.Start( action_data );
202 AttachMagazineActionData action_data_am = AttachMagazineActionData.Cast(action_data);
204 Magazine mag = Magazine.Cast(action_data.m_Target.GetObject());
206 if ( action_data.m_Player.GetWeaponManager().CanAttachMagazine(wpn,mag,
false) )
207 action_data.m_Player.GetWeaponManager().AttachMagazine(mag,
this);
209 action_data.m_Player.GetWeaponManager().SwapMagazineEx(mag, action_data_am.m_ilOldMagazine,
this);
210 InventoryReservation(action_data);
213 override bool CanBePerformedFromInventory()
218 override bool CanBePerformedFromQuickbar()
233 if (!super.ActionCondition( player, target, item ))
240 MagazineStorage mag = MagazineStorage.Cast(player.GetWeaponManager().GetPreparedMagazine());
246 bool isLoadedMag =
false;
248 for (
int i = 0, count = weapon.GetMuzzleCount(); i < count; ++i)
249 isLoadedMag |= ( mag == weapon.GetMagazine( i ) );
256 AttachMagazineActionData action_data =
new AttachMagazineActionData;
263 super.WriteToContext(ctx, action_data);
265 AttachMagazineActionData action_data_am = AttachMagazineActionData.Cast(action_data);
267 action_data_am.m_ilOldMagazine.WriteToContext(ctx);
270 override bool ReadFromContext(
ParamsReadContext ctx, out ActionReciveData action_recive_data )
272 if (!action_recive_data)
277 super.ReadFromContext(ctx, action_recive_data);
280 if (!il.ReadFromContext(ctx))
284 recive_data_am.m_ilOldMagazine = il;
289 override void HandleReciveData(ActionReciveData action_recive_data,
ActionData action_data)
292 AttachMagazineActionData action_data_am = AttachMagazineActionData.Cast(action_data);
294 action_data.m_MainItem = action_recive_data.m_MainItem;
295 if (!action_recive_data.m_Target)
301 action_data.m_Target = action_recive_data.m_Target;
303 action_data_am.m_ilOldMagazine = recive_data_am.m_ilOldMagazine;
306 override bool Post_SetupAction(
ActionData action_data )
308 if ( !
GetGame().IsDedicatedServer() )
311 int muzzle_index = wpn.GetCurrentMuzzle();
313 AttachMagazineActionData am_action_data = AttachMagazineActionData.Cast(action_data);
314 am_action_data.m_oldMagazine = wpn.GetMagazine(muzzle_index);
317 action_data.m_Target = newTarget;
321 if (!action_data.m_Player.GetWeaponManager().PrepareInventoryLocationForMagazineSwap(wpn, Magazine.Cast(action_data.m_Target.GetObject()), new_il))
325 am_action_data.m_ilOldMagazine = new_il;
330 override bool InventoryReservation(
ActionData action_data)
341 AttachMagazineActionData am_action_data = AttachMagazineActionData.Cast(action_data);
344 int muzzle_index = wpn.GetCurrentMuzzle();
346 Magazine new_mag = Magazine.Cast(action_data.m_Target.GetObject());
348 if (am_action_data.m_oldMagazine)
351 if ( action_data.m_Player.GetInventory().HasInventoryReservation( am_action_data.m_oldMagazine, am_action_data.m_ilOldMagazine) )
357 player.GetInventory().AddInventoryReservationEx(am_action_data.m_oldMagazine,am_action_data.m_ilOldMagazine,
GameInventory.c_InventoryReservationTimeoutMS);
364 targetInventoryLocation.SetAttachment( wpn, new_mag,
InventorySlots.MAGAZINE);
365 if ( action_data.m_Player.GetInventory().HasInventoryReservation( new_mag, targetInventoryLocation) )
368 if (am_action_data.m_oldMagazine)
370 player.GetInventory().ClearInventoryReservation(am_action_data.m_oldMagazine,am_action_data.m_ilOldMagazine);
375 action_data.m_Player.GetInventory().AddInventoryReservationEx( new_mag, targetInventoryLocation,
GameInventory.c_InventoryReservationTimeoutMS);
382 handInventoryLocation.SetHands(action_data.m_Player, wpn);
384 if ( action_data.m_Player.GetInventory().HasInventoryReservation( wpn, handInventoryLocation) )
386 if (am_action_data.m_oldMagazine)
388 player.GetInventory().ClearInventoryReservation(am_action_data.m_oldMagazine,am_action_data.m_ilOldMagazine);
390 player.GetInventory().ClearInventoryReservation(new_mag, targetInventoryLocation);
395 action_data.m_Player.GetInventory().AddInventoryReservationEx( wpn, handInventoryLocation,
GameInventory.c_InventoryReservationTimeoutMS);
401 if (am_action_data.m_ilOldMagazine)
402 action_data.m_ReservedInventoryLocations.Insert(am_action_data.m_ilOldMagazine);
404 if (targetInventoryLocation)
405 action_data.m_ReservedInventoryLocations.Insert(targetInventoryLocation);
407 if (handInventoryLocation)
408 action_data.m_ReservedInventoryLocations.Insert(handInventoryLocation);
416 super.Start( action_data );
417 AttachMagazineActionData action_data_am = AttachMagazineActionData.Cast(action_data);
419 Magazine mag = Magazine.Cast(action_data.m_Target.GetObject());
421 if ( action_data.m_Player.GetWeaponManager().CanAttachMagazine(wpn,mag,
false) )
422 action_data.m_Player.GetWeaponManager().AttachMagazine(mag,
this);
424 action_data.m_Player.GetWeaponManager().SwapMagazineEx(mag, action_data_am.m_ilOldMagazine,
this);
425 InventoryReservation(action_data);
428 override bool HasTarget()
433 override bool HasProgress()
438 override typename GetInputType()
443 override void CreateConditionComponents()