DayZ 1.24
Loading...
Searching...
No Matches
ActionDetachPowerSourceFromPanel.c
Go to the documentation of this file.
1
3{
5 {
6 m_Text = "#detach_power_source";
7 }
8
9 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
10 {
11 Object target_object = target.GetObject();
12
13 if (player && target_object)
14 {
15 EntityAI target_entity = EntityAI.Cast(target.GetObject());
16 string selection = target_object.GetActionComponentName(target.GetComponentIndex());
17
18
19 if (target_entity && target_entity.GetInventory() && target_entity.GetInventory().AttachmentCount() > 0 && selection == "power_source") //has any power source attachment attached
20 return true;
21 }
22
23 return false;
24 }
25
30
35
37 {
38 EntityAI target_entity = EntityAI.Cast(action_data.m_Target.GetObject());
39
41 int attachments_count = target_entity.GetInventory().AttachmentCount();
42 for (int j = 0; j < attachments_count; j++) //find any attached power source
43 {
44 // @TODO: vezme prvni att?
45 attachment = target_entity.GetInventory().GetAttachmentFromIndex(j);
46 if (attachment)
47 break;
48 }
49
50 if (attachment)
51 action_data.m_Player.PredictiveTakeEntityToHands(attachment);
52 }
53}
string m_Text
Definition ActionBase.c:49
override void OnExecuteClient(ActionData action_data)
override void OnExecuteServer(ActionData action_data)
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)