Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
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  {
21  return true;
22  }
23  }
24 
25  return false;
26  }
27 
28  override void OnExecuteClient( ActionData action_data )
29  {
30  Process(action_data);
31  }
32 
33  override void OnExecuteServer( ActionData action_data )
34  {
35  Process(action_data);
36  }
37 
38  void Process( ActionData action_data )
39  {
40  EntityAI target_entity = EntityAI.Cast( action_data.m_Target.GetObject() );
41 
42  EntityAI attachment;
43  int attachments_count = target_entity.GetInventory().AttachmentCount();
44  for ( int j = 0; j < attachments_count; j++ ) //find any attached power source
45  {
46  // @TODO: vezme prvni att?
47  attachment = target_entity.GetInventory().GetAttachmentFromIndex( j );
48  if ( attachment )
49  break;
50  }
51 
52  if ( attachment )
53  {
54  action_data.m_Player.PredictiveTakeEntityToHands(attachment );
55  }
56  }
57 }
ItemBase
Definition: inventoryitem.c:730
ActionDetachPowerSourceFromPanel
Definition: actiondetachpowersourcefrompanel.c:2
ActionInteractBase
Definition: actioninteractbase.c:54
PlayerBase
Definition: playerbaseclient.c:1
ActionTarget
class ActionTargets ActionTarget
ActionData
Definition: actionbase.c:20
Object
Definition: objecttyped.c:1
m_Text
protected string m_Text
Definition: actionbase.c:49
EntityAI
Definition: building.c:5