DayZ 1.24
Loading...
Searching...
No Matches
FirearmActionAttachMagazineQuick Class Reference
Inheritance diagram for FirearmActionAttachMagazineQuick:
[legend]
Collaboration diagram for FirearmActionAttachMagazineQuick:
[legend]

Private Member Functions

void FirearmActionAttachMagazineQuick ()
 
override bool ActionCondition (PlayerBase player, ActionTarget target, ItemBase item)
 
override ActionData CreateActionData ()
 
override void WriteToContext (ParamsWriteContext ctx, ActionData action_data)
 
override bool ReadFromContext (ParamsReadContext ctx, out ActionReciveData action_recive_data)
 
override void HandleReciveData (ActionReciveData action_recive_data, ActionData action_data)
 
override bool Post_SetupAction (ActionData action_data)
 
override bool InventoryReservation (ActionData action_data)
 
override void Start (ActionData action_data)
 
override bool HasTarget ()
 
override bool HasProgress ()
 
override GetInputType ()
 
override void CreateConditionComponents ()
 

Detailed Description

Definition at line 205 of file FirearmActionAttachMagazine.c.

Constructor & Destructor Documentation

◆ FirearmActionAttachMagazineQuick()

void FirearmActionAttachMagazineQuick::FirearmActionAttachMagazineQuick ( )
inlineprivate

Definition at line 207 of file FirearmActionAttachMagazine.c.

208 {
209 }

Member Function Documentation

◆ ActionCondition()

override bool FirearmActionAttachMagazineQuick::ActionCondition ( PlayerBase player,
ActionTarget target,
ItemBase item )
inlineprivate

Definition at line 211 of file FirearmActionAttachMagazine.c.

212 {
213 if (!super.ActionCondition(player, target, item))
214 return false;
215
216 HumanCommandWeapons hcw = player.GetCommandModifier_Weapons();
217 if (hcw && hcw.GetRunningAction() == WeaponActions.RELOAD)
218 return false;
219
220 MagazineStorage mag = MagazineStorage.Cast(player.GetWeaponManager().GetPreparedMagazine());
221
222 if (!mag)
223 return false;
224
225 Weapon weapon = Weapon.Cast(item);
226 bool isLoadedMag = false;
227
228 for (int i = 0, count = weapon.GetMuzzleCount(); i < count; ++i)
229 isLoadedMag |= (mag == weapon.GetMagazine(i));
230
231 return !isLoadedMag;
232 }
script counterpart to engine's class Weapon
WeaponActions
actions
Definition human.c:796

◆ CreateActionData()

override ActionData FirearmActionAttachMagazineQuick::CreateActionData ( )
inlineprivate

Definition at line 234 of file FirearmActionAttachMagazine.c.

◆ CreateConditionComponents()

override void FirearmActionAttachMagazineQuick::CreateConditionComponents ( )
inlineprivate

Definition at line 403 of file FirearmActionAttachMagazine.c.

404 {
407 }
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56

References m_ConditionItem, and m_ConditionTarget.

◆ GetInputType()

override FirearmActionAttachMagazineQuick::GetInputType ( )
inlineprivate

◆ HandleReciveData()

override void FirearmActionAttachMagazineQuick::HandleReciveData ( ActionReciveData action_recive_data,
ActionData action_data )
inlineprivate

Definition at line 267 of file FirearmActionAttachMagazine.c.

268 {
271
272 action_data.m_MainItem = action_recive_data.m_MainItem;
273 if (!action_recive_data.m_Target)
274 action_data.m_Target = new ActionTarget(NULL, NULL, -1, vector.Zero, 0);
275 else
276 action_data.m_Target = action_recive_data.m_Target;
277 action_data_am.m_ilOldMagazine = recive_data_am.m_ilOldMagazine;
278 }
class ActionTargets ActionTarget
static const vector Zero
Definition EnConvert.c:110

References ActionTarget, and vector::Zero.

◆ HasProgress()

override bool FirearmActionAttachMagazineQuick::HasProgress ( )
inlineprivate

Definition at line 393 of file FirearmActionAttachMagazine.c.

394 {
395 return false;
396 }

◆ HasTarget()

override bool FirearmActionAttachMagazineQuick::HasTarget ( )
inlineprivate

Definition at line 388 of file FirearmActionAttachMagazine.c.

389 {
390 return true;
391 }

◆ InventoryReservation()

override bool FirearmActionAttachMagazineQuick::InventoryReservation ( ActionData action_data)
inlineprivate

Definition at line 302 of file FirearmActionAttachMagazine.c.

303 {
304 if ((IsLocal() || !UseAcknowledgment()) && IsInstant())
305 return true;
306
307 bool success = true;
311
312 PlayerBase player = action_data.m_Player;
314
315 Weapon_Base wpn = Weapon_Base.Cast(action_data.m_MainItem);
316 int muzzle_index = wpn.GetCurrentMuzzle();
317
318 Magazine new_mag = Magazine.Cast(action_data.m_Target.GetObject());
319
320 if (am_action_data.m_oldMagazine)
321 {
323 if (action_data.m_Player.GetInventory().HasInventoryReservation(am_action_data.m_oldMagazine, am_action_data.m_ilOldMagazine))
324 success = false;
325 else
326 player.GetInventory().AddInventoryReservationEx(am_action_data.m_oldMagazine, am_action_data.m_ilOldMagazine, GameInventory.c_InventoryReservationTimeoutMS);
327 }
328
329 if (success)
330 {
332 targetInventoryLocation.SetAttachment(wpn, new_mag, InventorySlots.MAGAZINE);
333 if (action_data.m_Player.GetInventory().HasInventoryReservation(new_mag, targetInventoryLocation))
334 {
335 success = false;
336 if (am_action_data.m_oldMagazine)
337 player.GetInventory().ClearInventoryReservation(am_action_data.m_oldMagazine, am_action_data.m_ilOldMagazine);
338 }
339 else
340 action_data.m_Player.GetInventory().AddInventoryReservationEx(new_mag, targetInventoryLocation, GameInventory.c_InventoryReservationTimeoutMS);
341 }
342
343 if (success)
344 {
346 handInventoryLocation.SetHands(action_data.m_Player, wpn);
347
348 if (action_data.m_Player.GetInventory().HasInventoryReservation(wpn, handInventoryLocation))
349 {
350 if (am_action_data.m_oldMagazine)
351 player.GetInventory().ClearInventoryReservation(am_action_data.m_oldMagazine, am_action_data.m_ilOldMagazine);
352 player.GetInventory().ClearInventoryReservation(new_mag, targetInventoryLocation);
353 success = false;
354 }
355 else
356 action_data.m_Player.GetInventory().AddInventoryReservationEx(wpn, handInventoryLocation, GameInventory.c_InventoryReservationTimeoutMS);
357 }
358
359 if (success)
360 {
361 if (am_action_data.m_ilOldMagazine)
362 action_data.m_ReservedInventoryLocations.Insert(am_action_data.m_ilOldMagazine);
363
365 action_data.m_ReservedInventoryLocations.Insert(targetInventoryLocation);
366
368 action_data.m_ReservedInventoryLocations.Insert(handInventoryLocation);
369 }
370
371 return success;
372 }
bool UseAcknowledgment()
Definition ActionBase.c:821
bool IsLocal()
Definition ActionBase.c:222
bool IsInstant()
Definition ActionBase.c:228
script counterpart to engine's class Inventory
Definition Inventory.c:79
const int c_InventoryReservationTimeoutMS
reservations
Definition Inventory.c:687
InventoryLocation.
provides access to slot configuration

References GameInventory::c_InventoryReservationTimeoutMS, IsInstant(), IsLocal(), and UseAcknowledgment().

Referenced by Start().

◆ Post_SetupAction()

override bool FirearmActionAttachMagazineQuick::Post_SetupAction ( ActionData action_data)
inlineprivate

Definition at line 280 of file FirearmActionAttachMagazine.c.

281 {
282 if (!GetGame().IsDedicatedServer())
283 {
284 Weapon_Base wpn = Weapon_Base.Cast(action_data.m_MainItem);
285 int muzzle_index = wpn.GetCurrentMuzzle();
286
288 am_action_data.m_oldMagazine = wpn.GetMagazine(muzzle_index);
289
290 ActionTarget newTarget = new ActionTarget(action_data.m_Player.GetWeaponManager().GetPreparedMagazine(), null, -1, vector.Zero, -1);
291 action_data.m_Target = newTarget;
292
294
295 if (!action_data.m_Player.GetWeaponManager().PrepareInventoryLocationForMagazineSwap(wpn, Magazine.Cast(action_data.m_Target.GetObject()), new_il))
296 return false;
297 am_action_data.m_ilOldMagazine = new_il;
298 }
299 return true;
300 }
proto native CGame GetGame()

References ActionTarget, GetGame(), and vector::Zero.

◆ ReadFromContext()

override bool FirearmActionAttachMagazineQuick::ReadFromContext ( ParamsReadContext ctx,
out ActionReciveData action_recive_data )
inlineprivate

Definition at line 250 of file FirearmActionAttachMagazine.c.

251 {
254
255 super.ReadFromContext(ctx, action_recive_data);
256
258 if (!il.ReadFromContext(ctx))
259 return false;
260
262 recive_data_am.m_ilOldMagazine = il;
263
264 return true;
265 }

◆ Start()

override void FirearmActionAttachMagazineQuick::Start ( ActionData action_data)
inlineprivate

Definition at line 374 of file FirearmActionAttachMagazine.c.

375 {
376 super.Start(action_data);
378 Weapon_Base wpn = Weapon_Base.Cast(action_data.m_MainItem);
379 Magazine mag = Magazine.Cast(action_data.m_Target.GetObject());
381 if (action_data.m_Player.GetWeaponManager().CanAttachMagazine(wpn, mag, false))
382 action_data.m_Player.GetWeaponManager().AttachMagazine(mag, this);
383 else
384 action_data.m_Player.GetWeaponManager().SwapMagazineEx(mag, action_data_am.m_ilOldMagazine, this);
386 }
void ClearInventoryReservationEx(ActionData action_data)
Definition ActionBase.c:790
override bool InventoryReservation(ActionData action_data)

References ClearInventoryReservationEx(), and InventoryReservation().

◆ WriteToContext()

override void FirearmActionAttachMagazineQuick::WriteToContext ( ParamsWriteContext ctx,
ActionData action_data )
inlineprivate

Definition at line 241 of file FirearmActionAttachMagazine.c.

242 {
243 super.WriteToContext(ctx, action_data);
244
246
247 action_data_am.m_ilOldMagazine.WriteToContext(ctx);
248 }

The documentation for this class was generated from the following file: