DayZ 1.24
Loading...
Searching...
No Matches
ActionAttachPowerSourceToPanel.c
Go to the documentation of this file.
1
3{
5 {
6 m_Text = "#attach";
7 }
8
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 return true;
22 }
23
24 return false;
25 }
26
28 {
29 EntityAI target_entity = EntityAI.Cast(action_data.m_Target.GetObject());
30 EntityAI item_entity = action_data.m_MainItem;
31
32 //find inventory location for attachment
34 if (target_entity.GetInventory().FindFirstFreeLocationForNewEntity(item_entity.GetType(), FindInventoryLocationType.ATTACHMENT, target_location))
35 action_data.m_Player.PredictiveTakeEntityToTargetAttachmentEx(target_entity, item_entity, target_location.GetSlot());
36 }
37
43
45 {
46 if (GetGame().IsMultiplayer())
47 return; // multiplayer handled on client side via OnExecuteClient
48 else
49 OnExecuteImpl(action_data); // single player
50 }
51
53 {
54 // Probably not needed since attaching is done server side.
55 /*
56 EntityAI target_entity = EntityAI.Cast( action_data.m_Target.GetObject() );
57 EntityAI item_entity = EntityAI.Cast( action_data.m_MainItem );
58
59 //find inventory location for attachment
60 InventoryLocation target_location = new InventoryLocation;
61
62 if( target_entity.GetInventory().FindFirstFreeLocationForNewEntity( item_entity.GetType(), FindInventoryLocationType.ATTACHMENT, target_location ) )
63 {
64 //target_entity.PredictiveTakeEntityToTargetAttachmentEx( target_entity, item_entity, target_location.GetSlot() );
65 target_entity.LocalTakeEntityAsAttachmentEx( item_entity, target_location.GetSlot() );
66 }
67 */
68 }
69}
string m_Text
Definition ActionBase.c:49
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56
void ClearInventoryReservationEx(ActionData action_data)
Definition ActionBase.c:790
FindInventoryLocationType
flags for searching locations in inventory
override void OnExecuteClient(ActionData action_data)
override void OnExecuteServer(ActionData action_data)
override void OnEndClient(ActionData action_data)
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
InventoryLocation.
const float DEFAULT
proto native CGame GetGame()