Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
actionattachpowersourcetopanel.c
Go to the documentation of this file.
1
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}
override void OnExecuteClient(ActionData action_data)
override void OnExecuteServer(ActionData action_data)
override void OnEndClient(ActionData action_data)
string m_Text
Definition actionbase.c:58
ref CCIBase m_ConditionItem
Definition actionbase.c:64
void ClearInventoryReservationEx(ActionData action_data)
ref CCTBase m_ConditionTarget
Definition actionbase.c:65
InventoryLocation.
proto native CGame GetGame()
FindInventoryLocationType
flags for searching locations in inventory