Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actionrepositionpluggeditem.c
Go to the documentation of this file.
2 {
3  // Through this action players can reposition already placed electric devices without unplugging them from the power source.
5  {
6  m_CallbackClass = ActionInteractBaseCB;
7  m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_PICKUP_HANDS;
8  m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT | DayZPlayerConstants.STANCEMASK_CROUCH;
9 
10  m_Text = "#reposition";
11  }
12 
13  override typename GetInputType()
14  {
16  }
17 
18  override bool HasProgress()
19  {
20  return false;
21  }
22 
23  override bool CanBeUsedOnBack()
24  {
25  return false;
26  }
27 
28  override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
29  {
30  ItemBase targetItem = ItemBase.Cast(target.GetObject());
31  EntityAI targetParent = EntityAI.Cast(targetItem.GetHierarchyParent());
32  if (!targetItem || !targetItem.IsTakeable() || targetItem.IsBeingPlaced() || (targetItem.GetCompEM() && !targetItem.GetCompEM().IsPlugged()) || ( targetItem.GetHierarchyParent() && !BaseBuildingBase.Cast(targetItem.GetHierarchyParent()) ) || ((targetParent && !targetItem.CanDetachAttachment(targetParent)) || (targetParent && !targetParent.CanReleaseAttachment(targetItem))))
33  return false;
34 
35  if (targetItem.HasEnergyManager() && targetItem.GetCompEM().IsPlugged())
36  return player.GetInventory().CanAddEntityIntoHands(targetItem);
37 
38  return false;
39  }
40 
41  override bool CanContinue(ActionData action_data)
42  {
43  EntityAI ent = EntityAI.Cast(action_data.m_Target.GetObject());
44  return ent && ent.GetCompEM().GetCordLength() > 0;
45  }
46 
47  override void Start(ActionData action_data)
48  {
49  super.Start(action_data);
50 
51  ItemBase ntarget = ItemBase.Cast(action_data.m_Target.GetObject());
52  if (GetGame().IsMultiplayer() && GetGame().IsServer())
53  action_data.m_Player.PlacingStartServer(ntarget);
54  else
55  action_data.m_Player.TogglePlacingLocal(ntarget);
56  }
57 
58  override void OnExecuteServer(ActionData action_data)
59  {
60  if (GetGame().IsMultiplayer())
61  return;
62 
64  ItemBase ntarget = ItemBase.Cast(action_data.m_Target.GetObject());
65  ClearInventoryReservationEx(action_data);
66 
67  action_data.m_Player.PredictiveTakeEntityToHands(ntarget);
68  }
69 
70  override void OnExecuteClient(ActionData action_data)
71  {
73  ItemBase ntarget = ItemBase.Cast(action_data.m_Target.GetObject());
74  ClearInventoryReservationEx(action_data);
75 
76  action_data.m_Player.PredictiveTakeEntityToHands(ntarget);
77  }
78 
79  override void CreateAndSetupActionCallback(ActionData action_data)
80  {
81  EntityAI target = EntityAI.Cast(action_data.m_Target.GetObject());
82  ActionBaseCB callback;
83  if (!target)
84  return;
85 
86  if (target.IsHeavyBehaviour())
87  {
88  Class.CastTo(callback, action_data.m_Player.StartCommand_Action(DayZPlayerConstants.CMD_ACTIONFB_PICKUP_HEAVY,GetCallbackClassTypename(), DayZPlayerConstants.STANCEMASK_ERECT));
89  }
90  else
91  {
92  Class.CastTo(callback, action_data.m_Player.AddCommandModifier_Action(DayZPlayerConstants.CMD_ACTIONMOD_PICKUP_HANDS,GetCallbackClassTypename()));
93  }
94 
95  callback.SetActionData(action_data);
96  callback.InitActionComponent();
97  action_data.m_Callback = callback;
98  }
99 
101  protected ItemBase m_SourceForReplug;
102 }
ItemBase
Definition: inventoryitem.c:730
GetGame
proto native CGame GetGame()
ContinuousInteractActionInput
Definition: actioninput.c:521
InventoryLocation
InventoryLocation.
Definition: inventorylocation.c:27
ActionInteractBaseCB
Definition: actioninteractbase.c:1
ClearInventoryReservationEx
void ClearInventoryReservationEx(ActionData action_data)
Definition: actionbase.c:862
ActionInteractBase
Definition: actioninteractbase.c:54
PlayerBase
Definition: playerbaseclient.c:1
ActionTarget
class ActionTargets ActionTarget
ActionData
Definition: actionbase.c:20
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
BaseBuildingBase
Definition: fence.c:1
ActionRepositionPluggedItem
Definition: actionrepositionpluggeditem.c:1
m_Text
protected string m_Text
Definition: actionbase.c:49
ActionBaseCB
Definition: animatedactionbase.c:1
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
m_StanceMask
protected int m_StanceMask
Definition: actionbase.c:53
EntityAI
Definition: building.c:5