DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
ActionDetachFromTarget.c
См. документацию.
2{
3
9
11 {
12 m_Text = "#take_to_hands";
13 }
14
15 override typename GetInputType()
16 {
18 }
19
21 {
22 DetachActionData action_data = new DetachActionData;
23 return action_data;
24 }
25
27 {
28 EntityAI target_entity = EntityAI.Cast(target.GetObject());
29
30 if ( player && target_entity )
31 {
32 array<string> selections = new array<string>();
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 {
39 int target_slot_id = InventorySlots.GetSlotIdFromString( selections[i] );
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 }
52
53 override bool SetupAction(PlayerBase player, ActionTarget target, ItemBase item, out ActionData action_data, Param extra_data = NULL)
54 {
55 int attSlotId = InventorySlots.INVALID;
56 if (!GetGame().IsDedicatedServer() )
57 {
58 attSlotId = FindSlotIdToDetach(player, target, item);
59 }
60
61 if ( super.SetupAction( player, target, item, action_data, extra_data))
62 {
63 if (!GetGame().IsDedicatedServer())
64 {
65 if(attSlotId != InventorySlots.INVALID)
66 {
67 DetachActionData action_data_a = DetachActionData.Cast(action_data);
68 action_data_a.m_AttSlot = attSlotId;
69 return true;
70 }
71 return false;
72 }
73 return true;
74 }
75 return false;
76 }
77
78 override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
79 {
80 if ( GetGame().IsMultiplayer() && GetGame().IsServer() ) return true;
81
82 return FindSlotIdToDetach(player, target, item) != InventorySlots.INVALID);
83 }
84
86 {
87 int target_slot_id = FindSlotIdToDetach(player, target, null);
88 EntityAI target_entity = EntityAI.Cast( target.GetObject() );
89
90 if(target_slot_id != InventorySlots.INVALID)
91 {
92 return target_entity.GetInventory().FindAttachment(target_slot_id);
93 }
94 return null;
95 }
96
97 override void OnExecute(ActionData action_data)
98 {
99 if (GetGame().IsDedicatedServer())
100 {
101 ClearActionJuncture(action_data);
102 return;
103 }
104
105 Process(action_data);
106 }
107
108 void Process( ActionData action_data )
109 {
110 ClearInventoryReservationEx(action_data);
111
112 DetachActionData action_data_a = DetachActionData.Cast(action_data);
113 EntityAI target_entity = EntityAI.Cast( action_data_a.m_Target.GetObject() );
114
115 ItemBase attachment = ItemBase.Cast(target_entity.GetInventory().FindAttachment(action_data_a.m_AttSlot));
116
117 if(attachment)
118 {
119 float stackable = attachment.GetTargetQuantityMax();
120 if( stackable == 0 || stackable >= attachment.GetQuantity() )
121 {
122 //take to hands
123 action_data.m_Player.PredictiveTakeEntityToHands( attachment );
124 }
125 else if( stackable != 0 && stackable < attachment.GetQuantity() )
126 {
127 //split and take to hands
128 attachment.SplitIntoStackMaxHandsClient( action_data.m_Player );
129 }
130 }
131 }
132}
133
134class ActionDetachFromTarget_SpecificSlot: ActionDetachFromTarget
135{
137
138 override int FindSlotIdToDetach(PlayerBase player, ActionTarget target, ItemBase item)
139 {
140 EntityAI target_entity = EntityAI.Cast(target.GetObject());
141
142 if ( player && target_entity )
143 {
144 array<string> selections = new array<string>();
145 target_entity.GetActionComponentNameList( target.GetComponentIndex(),selections );
146
147 if ( target_entity && target_entity.GetInventory() && target_entity.GetInventory().AttachmentCount() > 0 )
148 {
149 for(int i = 0; i < selections.Count(); i++ )
150 {
151 if( selections[i] == m_slotToDetach )
152 {
153 int target_slot_id = InventorySlots.GetSlotIdFromString( selections[i] );
154 EntityAI att = target_entity.GetInventory().FindAttachment(target_slot_id);
155
156 if ( att && player.GetInventory().CanAddEntityIntoHands(att) )
157 {
158 if ( att.CanDetachAttachment( target_entity ) && target_entity.CanReleaseAttachment( att ) )
159 return target_slot_id;
160 }
161 }
162 }
163 }
164 }
165 return InventorySlots.INVALID;
166 }
167}
168
170{
172
173 override int FindSlotIdToDetach(PlayerBase player, ActionTarget target, ItemBase item)
174 {
175 EntityAI target_entity = EntityAI.Cast(target.GetObject());
176
177 if ( player && target_entity )
178 {
179 array<string> selections = new array<string>();
180 target_entity.GetActionComponentNameList( target.GetComponentIndex(),selections );
181
182 if ( target_entity && target_entity.GetInventory() && target_entity.GetInventory().AttachmentCount() > 0 )
183 {
184 for(int i = 0; i < selections.Count(); i++ )
185 {
186 if (selections[i].Contains(m_slotsToDetach))
187 {
188 int target_slot_id = InventorySlots.GetSlotIdFromString( selections[i] );
189 EntityAI att = target_entity.GetInventory().FindAttachment(target_slot_id);
190
191 if ( att && player.GetInventory().CanAddEntityIntoHands(att) )
192 {
193 if ( att.CanDetachAttachment( target_entity ) && target_entity.CanReleaseAttachment( att ) )
194 return target_slot_id;
195 }
196 }
197 }
198 }
199 }
200 return InventorySlots.INVALID;
201 }
202}
203
204
205class ActionDetachFromTarget_SpecificSlot_WoodenLogs: ActionDetachFromTarget_SpecificSlot
206{
209 m_slotToDetach = "truck_01_woodenlogs";
210 }
211}
212
213class ActionDetachFromTarget_SpecificSlot_WoodenPlanks: ActionDetachFromTarget_SpecificSlot
214{
216 {
217 m_slotToDetach = "truck_01_woodenplanks";
218 }
219}
220
221class ActionDetachFromTarget_SpecificSlot_MetalSheets: ActionDetachFromTarget_SpecificSlot
222{
225 m_slotToDetach = "truck_01_metalsheets";
226 }
227}
228
236
238{
241 m_slotsToDetach = "truck_01_woodencrate";
242 }
243}
ActionBase ActionData
Определения ActionBase.c:30
ActionDetachFromTarget_SpecificSlot_WoodenPlanks ActionDetachFromTarget_SpecificSlot ActionDetachFromTarget_SpecificSlot_MetalSheets()
Определения ActionDetachFromTarget.c:223
string m_slotsToDetach
Определения ActionDetachFromTarget.c:208
ActionDetachFromTarget_SpecificSlotsCategory_Barrel ActionDetachFromTarget_SpecificSlotsCategory ActionDetachFromTarget_SpecificSlotsCategory_WoodenCrate()
Определения ActionDetachFromTarget.c:239
override int FindSlotIdToDetach(PlayerBase player, ActionTarget target, ItemBase item)
Определения ActionDetachFromTarget.c:138
ActionDetachFromTarget_SpecificSlotsCategory ActionDetachFromTarget ActionDetachFromTarget_SpecificSlot_WoodenLogs()
Определения ActionDetachFromTarget.c:207
ActionDetachFromTarget m_slotToDetach
class ActionTargets ActionTarget
void Process()
Определения EffectManager.c:743
void ClearActionJuncture(ActionData action_data)
Определения ActionBase.c:1083
string m_Text
Определения ActionBase.c:58
ref CCIBase m_ConditionItem
Определения ActionBase.c:64
void ClearInventoryReservationEx(ActionData action_data)
Определения ActionBase.c:1025
ref CCTBase m_ConditionTarget
Определения ActionBase.c:65
override int FindSlotIdToDetach(PlayerBase player, ActionTarget target, ItemBase item)
Определения ActionDetachFromTarget.c:173
void ActionDetachFromTarget()
Определения ActionDetachFromTarget.c:10
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Определения ActionDetachFromTarget.c:78
override GetInputType()
Определения ActionDetachFromTarget.c:15
override ActionData CreateActionData()
Определения ActionDetachFromTarget.c:20
override void OnExecute(ActionData action_data)
Определения ActionDetachFromTarget.c:97
override bool SetupAction(PlayerBase player, ActionTarget target, ItemBase item, out ActionData action_data, Param extra_data=NULL)
Определения ActionDetachFromTarget.c:53
override void CreateConditionComponents()
Определения ActionDetachFromTarget.c:4
void Process(ActionData action_data)
Определения ActionDetachFromTarget.c:108
int FindSlotIdToDetach(PlayerBase player, ActionTarget target, ItemBase item)
Определения ActionDetachFromTarget.c:26
override Object GetDisplayInteractObject(PlayerBase player, ActionTarget target)
Определения ActionDetachFromTarget.c:85
void ActionInteractBase()
Определения ActionInteractBase.c:43
Определения CCINone.c:2
Определения CCTCursor.c:2
int m_AttSlot
Определения ActionDetach.c:3
Определения ActionDetach.c:2
Определения Building.c:6
const int INVALID
Invalid slot (-1)
Определения InventorySlots.c:17
static proto native int GetSlotIdFromString(string slot_name)
converts string to slot_id
provides access to slot configuration
Определения InventorySlots.c:6
Определения InventoryItem.c:731
Определения ObjectTyped.c:2
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Определения param.c:12
Определения PlayerBaseClient.c:2
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()