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

Private Member Functions

void ActionTakeHybridAttachment ()
 
override void CreateConditionComponents ()
 
override bool HasProneException ()
 
override bool ActionConditionContinue (ActionData action_data)
 
override bool ActionCondition (PlayerBase player, ActionTarget target, ItemBase item)
 
override bool CanBeUsedOnBack ()
 
override bool InventoryReservation (ActionData action_data)
 
override void OnExecuteServer (ActionData action_data)
 
override void OnExecuteClient (ActionData action_data)
 

Private Attributes

string m_ItemName = ""
 

Detailed Description

Definition at line 2 of file ActionTakeHybridAttachment.c.

Constructor & Destructor Documentation

◆ ActionTakeHybridAttachment()

void ActionTakeHybridAttachment::ActionTakeHybridAttachment ( )
inlineprivate

Definition at line 6 of file ActionTakeHybridAttachment.c.

7 {
8 m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_PICKUP_INVENTORY;
9 m_CommandUIDProne = DayZPlayerConstants.CMD_ACTIONFB_PICKUP_INVENTORY;
10 m_Text = "#take";
11 }
string m_Text
Definition ActionBase.c:49
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597

References AnimatedActionBase::m_CommandUID, AnimatedActionBase::m_CommandUIDProne, and m_Text.

Member Function Documentation

◆ ActionCondition()

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

Definition at line 29 of file ActionTakeHybridAttachment.c.

30 {
31 EntityAI tgt_entity = EntityAI.Cast(target.GetObject());
32
33 if (tgt_entity && BaseBuildingBase.Cast(tgt_entity) && !tgt_entity.IsBeingPlaced())
34 {
35 string component_name = tgt_entity.GetActionComponentName(target.GetComponentIndex());
36
37 /*if (!tgt_entity.GetInventory().HasInventorySlot(InventorySlots.GetSlotIdFromString(component_name)))
38 return false;*/
39
40 ItemBase attachment = ItemBase.Cast(tgt_entity.FindAttachmentBySlotName(component_name));
41
42 if (attachment && player.GetInventory().CanAddEntityIntoInventory(attachment) && attachment.IsTakeable())
43 return true;
44 }
45 return false;
46 }

◆ ActionConditionContinue()

override bool ActionTakeHybridAttachment::ActionConditionContinue ( ActionData action_data)
inlineprivate

Definition at line 24 of file ActionTakeHybridAttachment.c.

25 {
26 return true;
27 }

◆ CanBeUsedOnBack()

override bool ActionTakeHybridAttachment::CanBeUsedOnBack ( )
inlineprivate

Definition at line 48 of file ActionTakeHybridAttachment.c.

49 {
50 return true;
51 }

◆ CreateConditionComponents()

override void ActionTakeHybridAttachment::CreateConditionComponents ( )
inlineprivate

Definition at line 13 of file ActionTakeHybridAttachment.c.

14 {
17 }
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56

References m_ConditionItem, and m_ConditionTarget.

◆ HasProneException()

override bool ActionTakeHybridAttachment::HasProneException ( )
inlineprivate

Definition at line 19 of file ActionTakeHybridAttachment.c.

20 {
21 return true;
22 }

◆ InventoryReservation()

override bool ActionTakeHybridAttachment::InventoryReservation ( ActionData action_data)
inlineprivate

Definition at line 53 of file ActionTakeHybridAttachment.c.

54 {
55 bool success = true;
56
58
59 EntityAI tgt_entity = EntityAI.Cast(action_data.m_Target.GetObject());
60 string component_name = tgt_entity.GetActionComponentName(action_data.m_Target.GetComponentIndex());
62
63 if (tgt_entity && ItemBase.CastTo(attachment, tgt_entity.FindAttachmentBySlotName(component_name)))
64 {
65 action_data.m_Player.GetInventory().FindFreeLocationFor(attachment, FindInventoryLocationType.ANY, il);
66 if (action_data.m_Player.GetInventory().HasInventoryReservation(attachment, il))
67 success = false;
68 else
69 action_data.m_Player.GetInventory().AddInventoryReservationEx(attachment, il, GameInventory.c_InventoryReservationTimeoutMS);
70 }
71
72 if (success)
73 {
74 if (il)
75 action_data.m_ReservedInventoryLocations.Insert(il);
76 }
77
78 return success;
79 }
FindInventoryLocationType
flags for searching locations in inventory
script counterpart to engine's class Inventory
Definition Inventory.c:79
const int c_InventoryReservationTimeoutMS
reservations
Definition Inventory.c:687
InventoryLocation.

References GameInventory::c_InventoryReservationTimeoutMS.

◆ OnExecuteClient()

override void ActionTakeHybridAttachment::OnExecuteClient ( ActionData action_data)
inlineprivate

Definition at line 109 of file ActionTakeHybridAttachment.c.

110 {
111 //Debug.Log("[Action DEBUG] Start time stamp: " + action_data.m_Player.GetSimulationTimeStamp());
112 EntityAI tgt_entity = EntityAI.Cast(action_data.m_Target.GetObject());
113 string component_name = tgt_entity.GetActionComponentName(action_data.m_Target.GetComponentIndex());
115
116 if (tgt_entity && ItemBase.CastTo(attachment, tgt_entity.FindAttachmentBySlotName(component_name)))
117 {
118 InventoryLocation il = action_data.m_ReservedInventoryLocations.Get(0);
120 attachment.GetInventory().GetCurrentInventoryLocation(targetInventoryLocation);
122 //SplitItemUtils.TakeOrSplitToInventoryLocation( action_data.m_Player, il );
123 //action_data.m_Player.PredictiveTakeToDst(targetInventoryLocation, il);
124 float stackable = attachment.GetTargetQuantityMax(il.GetSlot());
125
126 if (stackable == 0 || stackable >= attachment.GetQuantity())
127 action_data.m_Player.PredictiveTakeToDst(targetInventoryLocation, il);
128 else
129 attachment.SplitIntoStackMaxToInventoryLocationClient(il);
130 }
131 }
void ClearInventoryReservationEx(ActionData action_data)
Definition ActionBase.c:790

References ClearInventoryReservationEx().

◆ OnExecuteServer()

override void ActionTakeHybridAttachment::OnExecuteServer ( ActionData action_data)
inlineprivate

Definition at line 81 of file ActionTakeHybridAttachment.c.

82 {
83 if (GetGame().IsMultiplayer())
84 return;
85
86 //Debug.Log("[Action DEBUG] Start time stamp: " + action_data.m_Player.GetSimulationTimeStamp());
87 EntityAI tgt_entity = EntityAI.Cast(action_data.m_Target.GetObject());
88 string component_name = tgt_entity.GetActionComponentName(action_data.m_Target.GetComponentIndex());
90
91 if (tgt_entity && ItemBase.CastTo(attachment, tgt_entity.FindAttachmentBySlotName(component_name)))
92 {
93 InventoryLocation il = action_data.m_ReservedInventoryLocations.Get(0);
95 attachment.GetInventory().GetCurrentInventoryLocation(targetInventoryLocation);
97 //SplitItemUtils.TakeOrSplitToInventoryLocation( action_data.m_Player, il );
98
99 float stackable = attachment.GetTargetQuantityMax(il.GetSlot());
100
101 if (stackable == 0 || stackable >= attachment.GetQuantity())
102 action_data.m_Player.PredictiveTakeToDst(targetInventoryLocation, il);
103 else
104 attachment.SplitIntoStackMaxToInventoryLocationClient(il);
105 }
106 //action_data.m_Player.PredictiveTakeToDst(targetInventoryLocation, il);
107 }
proto native CGame GetGame()

References ClearInventoryReservationEx(), and GetGame().

Member Data Documentation

◆ m_ItemName

string ActionTakeHybridAttachment::m_ItemName = ""
private

Definition at line 4 of file ActionTakeHybridAttachment.c.


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