Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actionattachpowersourcetopanel.c
Go to the documentation of this file.
3 {
5  {
6  m_Text = "#attach";
7  }
8 
9  override void CreateConditionComponents()
10  {
13  }
14 
15  override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
16  {
17  EntityAI target_entity = EntityAI.Cast( target.GetObject() );
18  if ( player && target_entity && item )
19  {
20  if ( target_entity.IsStaticTransmitter() && target_entity.GetInventory().AttachmentCount() == 0 ) //has any power source attachment attached
21  {
22  return true;
23  }
24  }
25 
26  return false;
27  }
28 
29  protected void OnExecuteImpl( ActionData action_data )
30  {
31  EntityAI target_entity = EntityAI.Cast( action_data.m_Target.GetObject() );
32  EntityAI item_entity = action_data.m_MainItem;
33 
34  //find inventory location for attachment
35  InventoryLocation target_location = new InventoryLocation;
36  if ( target_entity.GetInventory().FindFirstFreeLocationForNewEntity( item_entity.GetType(), FindInventoryLocationType.ATTACHMENT, target_location ) )
37  {
38  action_data.m_Player.PredictiveTakeEntityToTargetAttachmentEx( target_entity, item_entity, target_location.GetSlot() );
39  }
40  }
41 
42  override void OnExecuteClient( ActionData action_data )
43  {
44  ClearInventoryReservationEx(action_data);
45  OnExecuteImpl(action_data);
46  }
47 
48  override void OnExecuteServer( ActionData action_data )
49  {
50  if (GetGame().IsMultiplayer())
51  return; // multiplayer handled on client side via OnExecuteClient
52  else
53  OnExecuteImpl(action_data); // single player
54  }
55 
56  override void OnEndClient( ActionData action_data )
57  {
58  // Probably not needed since attaching is done server side.
59  /*
60  EntityAI target_entity = EntityAI.Cast( action_data.m_Target.GetObject() );
61  EntityAI item_entity = EntityAI.Cast( action_data.m_MainItem );
62 
63  //find inventory location for attachment
64  InventoryLocation target_location = new InventoryLocation;
65 
66  if( target_entity.GetInventory().FindFirstFreeLocationForNewEntity( item_entity.GetType(), FindInventoryLocationType.ATTACHMENT, target_location ) )
67  {
68  //target_entity.PredictiveTakeEntityToTargetAttachmentEx( target_entity, item_entity, target_location.GetSlot() );
69  target_entity.LocalTakeEntityAsAttachmentEx( item_entity, target_location.GetSlot() );
70  }
71  */
72  }
73 }
ItemBase
Definition: inventoryitem.c:730
GetGame
proto native CGame GetGame()
ActionAttachPowerSourceToPanel
DEPRECATED.
Definition: actionattachpowersourcetopanel.c:2
InventoryLocation
InventoryLocation.
Definition: inventorylocation.c:27
UAMaxDistances
Definition: actionconstants.c:104
ClearInventoryReservationEx
void ClearInventoryReservationEx(ActionData action_data)
Definition: actionbase.c:862
PlayerBase
Definition: playerbaseclient.c:1
ActionTarget
class ActionTargets ActionTarget
ActionData
Definition: actionbase.c:20
CCTNonRuined
Definition: cctnonruined.c:1
FindInventoryLocationType
FindInventoryLocationType
flags for searching locations in inventory
Definition: inventorylocation.c:15
m_Text
protected string m_Text
Definition: actionbase.c:49
ActionSingleUseBase
Definition: actionsingleusebase.c:41
m_ConditionItem
ref CCIBase m_ConditionItem
Definition: actionbase.c:55
CCINonRuined
Definition: ccinonruined.c:1
m_ConditionTarget
ref CCTBase m_ConditionTarget
Definition: actionbase.c:56
EntityAI
Definition: building.c:5