16 override bool HasTarget()
21 override typename GetInputType()
26 override bool CanBePerformedFromQuickbar()
31 override void CreateConditionComponents()
37 override bool HasProgress()
42 override bool InventoryReservation(
ActionData action_data)
44 Magazine mag = Magazine.Cast(action_data.m_Target.GetObject());
49 if( !super.InventoryReservation( action_data) )
52 DetachMagActionData action_data_dm = DetachMagActionData.Cast(action_data);
53 if( !action_data.m_Player.GetInventory().AddInventoryReservationEx(mag,il,10000) )
56 action_data_dm.m_ReservedInventoryLocations.Insert(il);
57 action_data_dm.m_ilMagazine = il;
64 ActionData action_data =
new DetachMagActionData;
70 super.WriteToContext(ctx, action_data);
72 DetachMagActionData action_data_dm;
73 DetachMagActionData.CastTo(action_data_dm, action_data);
75 action_data_dm.m_ilMagazine.WriteToContext(ctx);
78 override bool ReadFromContext(
ParamsReadContext ctx, out ActionReciveData action_recive_data )
80 if(!action_recive_data)
85 if(!super.ReadFromContext( ctx, action_recive_data ))
93 if(!recive_data_dm.m_ilMagazine.ReadFromContext(ctx))
99 override void HandleReciveData(ActionReciveData action_recive_data,
ActionData action_data)
101 super.HandleReciveData(action_recive_data, action_data);
104 DetachMagActionData action_data_dm = DetachMagActionData.Cast(action_data);
106 action_data_dm.m_ilMagazine = recive_data_dm.m_ilMagazine;
112 if (!super.ActionCondition( player, target, item ))
115 Magazine mag = Magazine.Cast(target.GetObject());
117 return mag && player.GetWeaponManager().CanDetachMagazine(wpn,mag);
120 override bool ActionConditionContinue(
ActionData action_data)
127 super.Start( action_data );
128 DetachMagActionData action_data_dm = DetachMagActionData.Cast(action_data);
132 action_data.m_Player.GetWeaponManager().DetachMagazine(action_data_dm.m_ilMagazine,
this);
155 ActionData action_data =
new AdvDetachMagActionData;
160 override bool InventoryReservation(
ActionData action_data)
163 Magazine mag = Magazine.Cast(action_data.m_Target.GetObject());
169 int ur_index = action_data.m_Player.GetHumanInventory().FindUserReservedLocationIndex(wpn);
172 action_data.m_Player.GetHumanInventory().GetUserReservedLocation(ur_index,ilWpn);
184 if( !super.InventoryReservation( action_data ) )
187 AdvDetachMagActionData action_data_dm = AdvDetachMagActionData.Cast(action_data);
188 if( !action_data.m_Player.GetInventory().AddInventoryReservationEx(wpn,ilWpn,10000) )
191 if( !action_data.m_Player.GetInventory().AddInventoryReservationEx(mag,ilMag,10000) )
194 action_data_dm.m_ReservedInventoryLocations.Insert(ilWpn);
195 action_data_dm.m_ReservedInventoryLocations.Insert(ilMag);
196 action_data_dm.m_ilWeapon = ilWpn;
197 action_data_dm.m_ilMagazine = ilMag;
204 super.WriteToContext(ctx, action_data);
206 AdvDetachMagActionData action_data_dm;
207 AdvDetachMagActionData.CastTo(action_data_dm, action_data);
209 action_data_dm.m_ilWeapon.WriteToContext(ctx);
210 action_data_dm.m_ilMagazine.WriteToContext(ctx);
213 override bool ReadFromContext(
ParamsReadContext ctx, out ActionReciveData action_recive_data )
215 if(!action_recive_data)
220 if(!super.ReadFromContext( ctx, action_recive_data ))
229 if(!recive_data_dm.m_ilWeapon.ReadFromContext(ctx))
232 if(!recive_data_dm.m_ilMagazine.ReadFromContext(ctx))
238 override void HandleReciveData(ActionReciveData action_recive_data,
ActionData action_data)
240 super.HandleReciveData(action_recive_data, action_data);
243 AdvDetachMagActionData action_data_dm = AdvDetachMagActionData.Cast(action_data);
245 action_data_dm.m_ilWeapon.Copy(recive_data_dm.m_ilWeapon);
246 action_data_dm.m_ilMagazine.Copy(recive_data_dm.m_ilMagazine);
250 override typename GetInputType()
255 override void CreateConditionComponents()
261 override bool CanBePerformedFromQuickbar()
268 if (!super.ActionCondition( player, target, item ))
272 int mi = wpn.GetCurrentMuzzle();
273 return wpn && wpn.GetMagazine(mi) == target.GetObject();
276 override bool ActionConditionContinue(
ActionData action_data )
283 if( action_data.m_ReciveEndInput )
288 super.OnStageStart(action_data);
292 AdvDetachMagActionData action_data_dm = AdvDetachMagActionData.Cast(action_data);
294 switch (action_data.m_Stage)
297 action_data.m_Player.GetWeaponManager().DetachMagazine(action_data_dm.m_ilMagazine,
this);
301 if ( !action_data_dm.m_ilWeapon.IsValid() )
308 mag = Magazine.Cast(action_data.m_Target.GetObject());
310 action_data.m_Player.GetHumanInventory().ClearUserReservedLocation(wpn);
311 if ( ( !
GetGame().IsDedicatedServer() ) && !mag.GetHierarchyParent() )
315 if ( action_data.m_Player.NeedInventoryJunctureFromServer(mag, action_data.m_Player, action_data.m_Player) || action_data.m_Player.NeedInventoryJunctureFromServer(wpn, action_data.m_Player, action_data.m_Player) )
318 action_data.m_Player.GetInventory().ForceSwapEntities(invMode, mag, wpn, action_data_dm.m_ilWeapon);
329 override void OnUpdate(
ActionData action_data )
331 super.OnUpdate( action_data );
341 if ( (!wpn || ad.m_Player.GetItemInHands()!=wpn || !ad.m_Player.GetWeaponManager().IsRunning()) && !ad.m_Player.IsJumpInProgress() )
356 override void OnStartServer(
ActionData action_data )
358 AdvDetachMagActionData action_data_dm = AdvDetachMagActionData.Cast(action_data);
359 GetGame().AddInventoryJunctureEx(action_data.m_Player,
EntityAI.Cast(action_data.m_Target.GetObject()),action_data_dm.m_ilMagazine,
true, 10000);
362 override void OnEndServer(
ActionData action_data )
364 GetGame().ClearJuncture(action_data.m_Player,
EntityAI.Cast(action_data.m_Target.GetObject()));