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);
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);
60 if (!action_recive_data)
65 super.ReadFromContext(ctx, action_recive_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;
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;
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) )
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);
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);
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);
233 if (!super.ActionCondition( player, target, item ))
242 magazine = Magazine.Cast(target.GetObject());
244 magazine = Magazine.Cast(player.GetWeaponManager().GetPreparedMagazine());
249 MagazineStorage mag = MagazineStorage.Cast(magazine);
254 bool isLoadedMag =
false;
256 for (
int i = 0, count = weapon.GetMuzzleCount(); i < count; ++i)
257 isLoadedMag |= ( mag == weapon.GetMagazine( i ) );
264 AttachMagazineActionData action_data =
new AttachMagazineActionData;
271 super.WriteToContext(ctx, action_data);
273 AttachMagazineActionData action_data_am = AttachMagazineActionData.Cast(action_data);
275 action_data_am.m_ilOldMagazine.WriteToContext(ctx);
280 if (!action_recive_data)
285 super.ReadFromContext(ctx, action_recive_data);
300 AttachMagazineActionData action_data_am = AttachMagazineActionData.Cast(action_data);
302 action_data.m_MainItem = action_recive_data.m_MainItem;
303 if (!action_recive_data.m_Target)
309 action_data.m_Target = action_recive_data.m_Target;
316 if ( !
GetGame().IsDedicatedServer() )
319 int muzzle_index = wpn.GetCurrentMuzzle();
321 AttachMagazineActionData am_action_data = AttachMagazineActionData.Cast(action_data);
322 am_action_data.m_oldMagazine = wpn.GetMagazine(muzzle_index);
325 action_data.m_Target = newTarget;
329 if (!action_data.m_Player.GetWeaponManager().PrepareInventoryLocationForMagazineSwap(wpn, Magazine.Cast(action_data.m_Target.GetObject()), new_il))
333 am_action_data.m_ilOldMagazine = new_il;
349 AttachMagazineActionData am_action_data = AttachMagazineActionData.Cast(action_data);
352 int muzzle_index = wpn.GetCurrentMuzzle();
354 Magazine new_mag = Magazine.Cast(action_data.m_Target.GetObject());
356 if (am_action_data.m_oldMagazine)
359 if ( action_data.m_Player.GetInventory().HasInventoryReservation( am_action_data.m_oldMagazine, am_action_data.m_ilOldMagazine) )
373 if ( action_data.m_Player.GetInventory().HasInventoryReservation( new_mag, targetInventoryLocation) )
376 if (am_action_data.m_oldMagazine)
378 player.GetInventory().ClearInventoryReservation(am_action_data.m_oldMagazine,am_action_data.m_ilOldMagazine);
390 handInventoryLocation.
SetHands(action_data.m_Player, wpn);
392 if ( action_data.m_Player.GetInventory().HasInventoryReservation( wpn, handInventoryLocation) )
394 if (am_action_data.m_oldMagazine)
396 player.GetInventory().ClearInventoryReservation(am_action_data.m_oldMagazine,am_action_data.m_ilOldMagazine);
398 player.GetInventory().ClearInventoryReservation(new_mag, targetInventoryLocation);
409 if (am_action_data.m_ilOldMagazine)
410 action_data.m_ReservedInventoryLocations.Insert(am_action_data.m_ilOldMagazine);
412 if (targetInventoryLocation)
413 action_data.m_ReservedInventoryLocations.Insert(targetInventoryLocation);
415 if (handInventoryLocation)
416 action_data.m_ReservedInventoryLocations.Insert(handInventoryLocation);
424 super.Start( action_data );
425 AttachMagazineActionData action_data_am = AttachMagazineActionData.Cast(action_data);
427 Magazine mag = Magazine.Cast(action_data.m_Target.GetObject());
429 if ( action_data.m_Player.GetWeaponManager().CanAttachMagazine(wpn,mag,
false) )
430 action_data.m_Player.GetWeaponManager().AttachMagazine(mag,
this);
432 action_data.m_Player.GetWeaponManager().SwapMagazineEx(mag, action_data_am.m_ilOldMagazine,
this);
void ActionTarget(Object object, Object parent, int componentIndex, vector cursorHitPos, float utility, string surfaceName="")
AttachMagazineActionReciveData m_ilOldMagazine
ref CCIBase m_ConditionItem
void ClearInventoryReservationEx(ActionData action_data)
ref CCTBase m_ConditionTarget
ref InventoryLocation m_ilOldMagazine
override bool CanBePerformedFromInventory()
override bool ReadFromContext(ParamsReadContext ctx, out ActionReciveData action_recive_data)
override void WriteToContext(ParamsWriteContext ctx, ActionData action_data)
override bool InventoryReservation(ActionData action_data)
override bool ActionConditionContinue(ActionData action_data)
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
override int GetActionCategory()
override void Start(ActionData action_data)
override bool CanBePerformedFromQuickbar()
override bool Post_SetupAction(ActionData action_data)
void FirearmActionAttachMagazine()
override void HandleReciveData(ActionReciveData action_recive_data, ActionData action_data)
override ActionData CreateActionData()
override bool HasTarget()
override bool HasProgress()
override void Start(ActionData action_data)
override void CreateConditionComponents()
override void HandleReciveData(ActionReciveData action_recive_data, ActionData action_data)
override bool Post_SetupAction(ActionData action_data)
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
override ActionData CreateActionData()
override void WriteToContext(ParamsWriteContext ctx, ActionData action_data)
void FirearmActionAttachMagazineQuick()
override bool InventoryReservation(ActionData action_data)
override bool ReadFromContext(ParamsReadContext ctx, out ActionReciveData action_recive_data)
const int c_InventoryReservationTimeoutMS
reservations
script counterpart to engine's class Inventory
proto native int GetRunningAction()
returns -1 when no action is running or RELOAD,MECHANISM, ....
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>
bool ReadFromContext(ParamsReadContext ctx)
provides access to slot configuration
script counterpart to engine's class Weapon
Serializer ParamsReadContext
proto native CGame GetGame()
Serializer ParamsWriteContext