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

Private Member Functions

override void CreateConditionComponents ()
 
void ActionDetachFromTarget ()
 
override GetInputType ()
 
override ActionData CreateActionData ()
 
int FindSlotIdToDetach (PlayerBase player, ActionTarget target, ItemBase item)
 
override bool SetupAction (PlayerBase player, ActionTarget target, ItemBase item, out ActionData action_data, Param extra_data=NULL)
 
override bool ActionCondition (PlayerBase player, ActionTarget target, ItemBase item)
 
override Object GetDisplayInteractObject (PlayerBase player, ActionTarget target)
 
override void OnExecuteClient (ActionData action_data)
 
override void OnExecuteServer (ActionData action_data)
 
void Process (ActionData action_data)
 

Detailed Description

Definition at line 1 of file ActionDetachFromTarget.c.

Constructor & Destructor Documentation

◆ ActionDetachFromTarget()

void ActionDetachFromTarget::ActionDetachFromTarget ( )
inlineprivate

Definition at line 10 of file ActionDetachFromTarget.c.

11 {
12 m_Text = "#take_to_hands";
13 }
string m_Text
Definition ActionBase.c:49

References m_Text.

Member Function Documentation

◆ ActionCondition()

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

Definition at line 76 of file ActionDetachFromTarget.c.

77 {
78 if (GetGame().IsMultiplayer() && GetGame().IsServer()) return true;
79
81 }
int FindSlotIdToDetach(PlayerBase player, ActionTarget target, ItemBase item)
provides access to slot configuration
const int INVALID
Invalid slot (-1)
proto native CGame GetGame()

References FindSlotIdToDetach(), GetGame(), and InventorySlots::INVALID.

◆ CreateActionData()

override ActionData ActionDetachFromTarget::CreateActionData ( )
inlineprivate

Definition at line 20 of file ActionDetachFromTarget.c.

◆ CreateConditionComponents()

override void ActionDetachFromTarget::CreateConditionComponents ( )
inlineprivate

Definition at line 4 of file ActionDetachFromTarget.c.

5 {
8 }
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56

References m_ConditionItem, and m_ConditionTarget.

◆ FindSlotIdToDetach()

int ActionDetachFromTarget::FindSlotIdToDetach ( PlayerBase player,
ActionTarget target,
ItemBase item )
inlineprivate

Definition at line 26 of file ActionDetachFromTarget.c.

27 {
28 EntityAI target_entity = EntityAI.Cast(target.GetObject());
29
30 if (player && target_entity)
31 {
33 target_entity.GetActionComponentNameList(target.GetComponentIndex(), selections);
34
35 if (target_entity && target_entity.GetInventory() && target_entity.GetInventory().AttachmentCount() > 0)
36 {
37 for (int i = 0; i < selections.Count(); i++)
38 {
40 EntityAI att = target_entity.GetInventory().FindAttachment(target_slot_id);
41
42 if (att && player.GetInventory().CanAddEntityIntoHands(att))
43 {
44 if (att.CanDetachAttachment(target_entity) && target_entity.CanReleaseAttachment(att))
45 return target_slot_id;
46 }
47 }
48 }
49 }
51 }
static proto native int GetSlotIdFromString(string slot_name)
converts string to slot_id

References InventorySlots::GetSlotIdFromString(), and InventorySlots::INVALID.

Referenced by ActionCondition(), GetDisplayInteractObject(), and SetupAction().

◆ GetDisplayInteractObject()

override Object ActionDetachFromTarget::GetDisplayInteractObject ( PlayerBase player,
ActionTarget target )
inlineprivate

Definition at line 83 of file ActionDetachFromTarget.c.

84 {
86 EntityAI target_entity = EntityAI.Cast(target.GetObject());
87
89 return target_entity.GetInventory().FindAttachment(target_slot_id);
90 return null;
91 }

References FindSlotIdToDetach(), and InventorySlots::INVALID.

◆ GetInputType()

override ActionDetachFromTarget::GetInputType ( )
inlineprivate

◆ OnExecuteClient()

override void ActionDetachFromTarget::OnExecuteClient ( ActionData action_data)
inlineprivate

Definition at line 93 of file ActionDetachFromTarget.c.

94 {
96 }
void Process(ActionData action_data)

References Process().

◆ OnExecuteServer()

override void ActionDetachFromTarget::OnExecuteServer ( ActionData action_data)
inlineprivate

Definition at line 98 of file ActionDetachFromTarget.c.

99 {
100 if (!GetGame().IsMultiplayer())
102 }

References GetGame(), and Process().

◆ Process()

void ActionDetachFromTarget::Process ( ActionData action_data)
inlineprivate

Definition at line 104 of file ActionDetachFromTarget.c.

105 {
107
109 EntityAI target_entity = EntityAI.Cast(action_data_a.m_Target.GetObject());
110
111 ItemBase attachment = ItemBase.Cast(target_entity.GetInventory().FindAttachment(action_data_a.m_AttSlot));
112
113 if (attachment)
114 {
115 float stackable = attachment.GetTargetQuantityMax();
116 if (stackable == 0 || stackable >= attachment.GetQuantity())
117 {
118 //take to hands
119 action_data.m_Player.PredictiveTakeEntityToHands(attachment);
120 }
121 else if (stackable != 0 && stackable < attachment.GetQuantity())
122 {
123 //split and take to hands
124 attachment.SplitIntoStackMaxHandsClient(action_data.m_Player);
125 }
126 }
127 }
void ClearInventoryReservationEx(ActionData action_data)
Definition ActionBase.c:790

References ClearInventoryReservationEx().

Referenced by OnExecuteClient(), and OnExecuteServer().

◆ SetupAction()

override bool ActionDetachFromTarget::SetupAction ( PlayerBase player,
ActionTarget target,
ItemBase item,
out ActionData action_data,
Param extra_data = NULL )
inlineprivate

Definition at line 53 of file ActionDetachFromTarget.c.

54 {
56 if (!GetGame().IsDedicatedServer())
58
59 if (super.SetupAction(player, target, item, action_data, extra_data))
60 {
61 if (!GetGame().IsDedicatedServer())
62 {
64 {
66 action_data_a.m_AttSlot = attSlotId;
67 return true;
68 }
69 return false;
70 }
71 return true;
72 }
73 return false;
74 }

References FindSlotIdToDetach(), GetGame(), and InventorySlots::INVALID.


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