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

Protected Member Functions

void OnExecuteImpl (ActionData action_data)
 
override void OnExecuteClient (ActionData action_data)
 
override void OnExecuteServer (ActionData action_data)
 

Private Member Functions

void ActionAttachToConstruction ()
 
override void CreateConditionComponents ()
 
override ActionData CreateActionData ()
 
override bool ActionCondition (PlayerBase player, ActionTarget target, ItemBase item)
 
override void OnStartClient (ActionData action_data)
 

Detailed Description

Definition at line 1 of file ActionAttachToConstruction.c.

Constructor & Destructor Documentation

◆ ActionAttachToConstruction()

void ActionAttachToConstruction::ActionAttachToConstruction ( )
inlineprivate

Definition at line 3 of file ActionAttachToConstruction.c.

4 {
5 m_Text = "#attach";
6 }
string m_Text
Definition ActionBase.c:49

References m_Text.

Member Function Documentation

◆ ActionCondition()

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

Definition at line 20 of file ActionAttachToConstruction.c.

21 {
22 EntityAI target_entity = EntityAI.Cast(target.GetObject());
23
24 if (target_entity && target_entity.CanUseConstruction())
25 {
26 string selection = target_entity.GetActionComponentName(target.GetComponentIndex());
27 ConstructionActionData construction_action_data = player.GetConstructionActionData();
28 int slot_id = construction_action_data.GetAttachmentSlotFromSelection(player, target_entity, item, selection);
30
31 if (slot_id != -1)
32 {
34 if (base_building.CheckSlotVerticalDistance(slot_id, player) && base_building.IsPlayerInside(player, ""))
35 {
37
38 return true;
39 }
40 }
41 else if (item.IsKindOf("CombinationLock"))
42 {
44
45 //simpler hack
46 /*construction_action_data.SetSlotId( InventorySlots.GetSlotIdFromString("Att_CombinationLock") );
47 return true;*/
48
50 bool found = base_building.GetInventory().FindFreeLocationFor(item, FindInventoryLocationType.ATTACHMENT, loc);
51
52 if (found)
53 {
54 //Print("slot name: " + InventorySlots.GetSlotName(loc.GetSlot()) );
55 construction_action_data.SetSlotId(loc.GetSlot());
56
57 return true;
58 }
59 }
60 }
61
62 return false;
63 }
FindInventoryLocationType
flags for searching locations in inventory
InventoryLocation.

◆ CreateActionData()

override ActionData ActionAttachToConstruction::CreateActionData ( )
inlineprivate

Definition at line 14 of file ActionAttachToConstruction.c.

◆ CreateConditionComponents()

override void ActionAttachToConstruction::CreateConditionComponents ( )
inlineprivate

Definition at line 8 of file ActionAttachToConstruction.c.

9 {
12 }
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56

References m_ConditionItem, and m_ConditionTarget.

◆ OnExecuteClient()

override void ActionAttachToConstruction::OnExecuteClient ( ActionData action_data)
inlineprotected

Definition at line 102 of file ActionAttachToConstruction.c.

103 {
106 }
void ClearInventoryReservationEx(ActionData action_data)
Definition ActionBase.c:790
void OnExecuteImpl(ActionData action_data)

References ClearInventoryReservationEx(), and OnExecuteImpl().

◆ OnExecuteImpl()

void ActionAttachToConstruction::OnExecuteImpl ( ActionData action_data)
inlineprotected

Definition at line 72 of file ActionAttachToConstruction.c.

73 {
74 EntityAI target_entity = EntityAI.Cast(action_data.m_Target.GetObject());
75 ItemBase item = ItemBase.Cast(action_data.m_MainItem);
76
77 ConstructionActionData construction_action_data = action_data.m_Player.GetConstructionActionData();
78 int slot_id = construction_action_data.GetSlotId();
79
80 if (slot_id != -1)
81 {
82 ItemBase attachment = ItemBase.Cast(target_entity.GetInventory().FindAttachment(slot_id));
83
84 if (attachment)
85 {
86 //combine
87 attachment.CombineItemsClient(item);
88 }
89 else// if( target_entity.GetInventory().CanAddAttachmentEx( item, slot_id ) )
90 {
92 float stackable = item_base.GetTargetQuantityMax(slot_id);
93
94 if (stackable == 0 || stackable >= item_base.GetQuantity())
95 action_data.m_Player.PredictiveTakeEntityToTargetAttachmentEx(target_entity, item, slot_id);
96 else if (stackable != 0 && stackable < item_base.GetQuantity())
97 item_base.SplitIntoStackMaxClient(target_entity, slot_id);
98 }
99 }
100 }

Referenced by OnExecuteClient(), and OnExecuteServer().

◆ OnExecuteServer()

override void ActionAttachToConstruction::OnExecuteServer ( ActionData action_data)
inlineprotected

Definition at line 108 of file ActionAttachToConstruction.c.

109 {
110 if (!GetGame().IsMultiplayer())
111 {
113
114 OnExecuteImpl(action_data); // single player
115 }
116 }
proto native CGame GetGame()

References ClearInventoryReservationEx(), GetGame(), and OnExecuteImpl().

◆ OnStartClient()

override void ActionAttachToConstruction::OnStartClient ( ActionData action_data)
inlineprivate

Definition at line 65 of file ActionAttachToConstruction.c.

66 {
67 //set action initiator
68 ConstructionActionData construction_action_data = action_data.m_Player.GetConstructionActionData();
69 construction_action_data.SetActionInitiator(action_data.m_Player);
70 }

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