39 if (
LogManager.IsWeaponLogEnable()) {
wpnDebugPrint(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" DetachOldMagazine, ok - no inventory space for old magazine - dropped to ground"); }
42 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" DetachOldMagazine, error - cannot drop magazine from left hand after not found inventory space for old magazine");
48 m_oldMagazine.GetInventory().GetCurrentInventoryLocation(oldSrc);
55 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" DetachOldMagazine, error - cannot remove old mag from wpn");
67 if (!super.SaveCurrentFSMState(ctx))
72 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" DetachOldMagazine.SaveCurrentFSMState: cannot write m_oldMagazine for weapon=" +
m_weapon);
79 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" DetachOldMagazine.SaveCurrentFSMState: cannot write m_newDst for weapon=" +
m_weapon);
88 if (!super.LoadCurrentFSMState(ctx, version))
93 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" DetachOldMagazine.LoadCurrentFSMState: cannot read m_oldMagazine for weapon=" +
m_weapon);
99 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" DetachOldMagazine.LoadCurrentFSMState: cannot read m_newDst for weapon=" +
m_weapon);
123 Magazine m_newMagazine;
132 if (!m_newMagazine || !m_newDst || !m_newDst.IsValid())
134 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" SwapOldAndNewMagazine, error - m_newMagazine(" + m_newMagazine +
") or destination(" +
InventoryLocation.DumpToStringNullSafe(m_newDst) +
") is not set ");
138 e.m_player.GetInventory().ClearInventoryReservationEx( m_newMagazine , m_newDst );
141 lhand.SetAttachment(e.m_player, m_newMagazine,
InventorySlots.LEFTHAND);
148 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" SwapOldAndNewMagazine, error - cannot remove new mag from LHand");
157 m_newMagazine = NULL;
165 m_newMagazine = NULL;
173 if (!super.SaveCurrentFSMState(ctx))
176 if (!ctx.Write(m_newMagazine))
178 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" SwapOldAndNewMagazine.SaveCurrentFSMState: cannot write m_newMagazine for weapon=" +
m_weapon);
184 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" SwapOldAndNewMagazine.SaveCurrentFSMState: cannot write m_newDst for weapon=" +
m_weapon);
193 if (!super.LoadCurrentFSMState(ctx, version))
196 if (!ctx.Read(m_newMagazine))
198 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" SwapOldAndNewMagazine.LoadCurrentFSMState: cannot read m_newMagazine for weapon=" +
m_weapon);
203 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" SwapOldAndNewMagazine.LoadCurrentFSMState: cannot read m_newDst for weapon=" +
m_weapon);
216 Magazine m_newMagazine;
221 m_newMagazine = NULL;
235 if (m_newMagazine && m_newDst)
238 if (m_newMagazine.GetInventory().GetCurrentInventoryLocation(il))
241 lhand.SetAttachment(e.m_player, m_newMagazine,
InventorySlots.LEFTHAND);
253 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" AttachNewMagazine, error - cannot get curr location");
256 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" AttachNewMagazine, error - no magazines configured for replace (m_new=NULL)");
262 if (m_newMagazine && m_newDst)
266 if (
LogManager.IsWeaponLogEnable()) {
wpnDebugPrint(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponDetachingMag_Store, ok - aborting, detached magazine dropped to ground"); }
269 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponDetachingMag_Store, error - cannot abort detaching of magazine");
275 m_newMagazine = NULL;
283 m_newMagazine = NULL;
290 if (!super.SaveCurrentFSMState(ctx))
293 if (!ctx.Write(m_newMagazine))
295 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" AttachNewMagazine.SaveCurrentFSMState: cannot write m_newMagazine for weapon=" +
m_weapon);
301 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" AttachNewMagazine.SaveCurrentFSMState: cannot write m_newDst for weapon=" +
m_weapon);
309 if (!super.LoadCurrentFSMState(ctx, version))
312 if (!ctx.Read(m_newMagazine))
314 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" AttachNewMagazine.LoadCurrentFSMState: cannot read m_newMagazine for weapon=" +
m_weapon);
319 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" AttachNewMagazine.LoadCurrentFSMState: cannot read m_newDst for weapon=" +
m_weapon);
347 ref AttachNewMagazine_W4T m_attach;
348 ref WeaponChamberFromAttMag_W4T
m_chamber;
349 ref WeaponCharging_CK m_onCK;
354 Magazine m_newMagazine;
360 m_actionType = actionType;
361 m_newMagazine = NULL;
369 m_attach =
new AttachNewMagazine_W4T(
m_weapon,
this);
371 m_onCK =
new WeaponCharging_CK(
m_weapon,
this);
403 m_fsm.SetInitialState(
m_start);
410 WeaponEventSwapMagazine se;
411 if (
Class.CastTo(se, e))
413 int mi =
m_weapon.GetCurrentMuzzle();
415 m_newMagazine = se.m_magazine;
423 if (!m_newMagazine.GetInventory().GetCurrentInventoryLocation(newSrc))
425 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" WeaponReplacingMagAndChamberNext cannot get curr inv loc of NEW mag=" +
Object.GetDebugName(m_newMagazine));
427 if (!
m_oldMagazine.GetInventory().GetCurrentInventoryLocation(oldSrc))
434 lhand.SetAttachment(e.m_player, m_newMagazine,
InventorySlots.LEFTHAND);
438 if (
LogManager.IsWeaponLogEnable()) {
wpnDebugPrint(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" RemoveNewMagazineFromInventory, ok - new magazine removed from inv (inv->LHand)"); }
441 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" RemoveNewMagazineFromInventory, error - cannot new remove mag from inv");
444 m_detach.m_newDst = m_newDst;
446 m_swapMags.m_newMagazine = m_newMagazine;
448 oldSrc.SetItem(m_newMagazine);
449 m_swapMags.m_newDst = oldSrc;
460 Magazine mag = Magazine.Cast(leftHandItem);
465 e.m_player.GetInventory().ClearInventoryReservationEx( m_newMagazine ,
null );
467 e.m_player.GetInventory().ClearInventoryReservationEx(
m_oldMagazine ,
null );
477 if (
LogManager.IsWeaponLogEnable()) {
wpnDebugPrint(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" DetachOldMagazine, ok - no inventory space for old magazine - dropped to ground - exit"); }
480 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" DetachOldMagazine, error - cannot drop magazine from left hand after not found inventory space for old magazine - exit");
486 mag.GetInventory().GetCurrentInventoryLocation(oldSrc);
493 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" DetachOldMagazine, error - cannot remove old mag from wpn - exit");
498 m_newMagazine = NULL;
507 Magazine mag = Magazine.Cast(leftHandItem);
512 e.m_player.GetInventory().ClearInventoryReservationEx( m_newMagazine ,
null );
514 e.m_player.GetInventory().ClearInventoryReservationEx(
m_oldMagazine ,
null );
524 if (
LogManager.IsWeaponLogEnable()) {
wpnDebugPrint(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" DetachOldMagazine, ok - no inventory space for old magazine - dropped to ground - abort"); }
527 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" DetachOldMagazine, error - cannot drop magazine from left hand after not found inventory space for old magazine - abort");
533 mag.GetInventory().GetCurrentInventoryLocation(oldSrc);
540 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" DetachOldMagazine, error - cannot remove old mag from wpn - abort");
547 if (!super.SaveCurrentFSMState(ctx))
550 if (!ctx.Write(m_newMagazine))
552 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" DetachOldMagazine.SaveCurrentFSMState: cannot write m_newMagazine for weapon=" +
m_weapon);
558 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" DetachOldMagazine.SaveCurrentFSMState: cannot write m_oldMagazine for weapon=" +
m_weapon);
562 if (!m_newDst.WriteToContext(ctx))
564 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" DetachOldMagazine.SaveCurrentFSMState: cannot write m_newDst for weapon=" +
m_weapon);
573 if (!super.LoadCurrentFSMState(ctx, version))
576 if (!ctx.Read(m_newMagazine))
578 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" DetachOldMagazine.LoadCurrentFSMState: cannot read m_newMagazine for weapon=" +
m_weapon);
583 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" DetachOldMagazine.LoadCurrentFSMState: cannot read m_oldMagazine for weapon=" +
m_weapon);
588 if (!m_newDst.ReadFromContext(ctx))
590 Error(
"[wpnfsm] " +
Object.GetDebugName(
m_weapon) +
" DetachOldMagazine.LoadCurrentFSMState: cannot read m_newDst for weapon=" +
m_weapon);