DayZ 1.24
Loading...
Searching...
No Matches
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 {
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
42 {
43 EntityAI ent = EntityAI.Cast(action_data.m_Target.GetObject());
44 return ent && ent.GetCompEM().GetCordLength() > 0;
45 }
46
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
59 {
60 if (GetGame().IsMultiplayer())
61 return;
62
64 ItemBase ntarget = ItemBase.Cast(action_data.m_Target.GetObject());
66
67 action_data.m_Player.PredictiveTakeEntityToHands(ntarget);
68 }
69
71 {
73 ItemBase ntarget = ItemBase.Cast(action_data.m_Target.GetObject());
75
76 action_data.m_Player.PredictiveTakeEntityToHands(ntarget);
77 }
78
80 {
81 EntityAI target = EntityAI.Cast(action_data.m_Target.GetObject());
83 if (!target)
84 return;
85
86 if (target.IsHeavyBehaviour())
87 Class.CastTo(callback, action_data.m_Player.StartCommand_Action(DayZPlayerConstants.CMD_ACTIONFB_PICKUP_HEAVY, GetCallbackClassTypename(), DayZPlayerConstants.STANCEMASK_ERECT));
88 else
89 Class.CastTo(callback, action_data.m_Player.AddCommandModifier_Action(DayZPlayerConstants.CMD_ACTIONMOD_PICKUP_HANDS, GetCallbackClassTypename()));
90
91 callback.SetActionData(action_data);
92 callback.InitActionComponent();
93 action_data.m_Callback = callback;
94 }
95
98}
string m_Text
Definition ActionBase.c:49
void ClearInventoryReservationEx(ActionData action_data)
Definition ActionBase.c:790
int m_StanceMask
Definition ActionBase.c:53
override void OnExecuteClient(ActionData action_data)
override bool CanContinue(ActionData action_data)
override void OnExecuteServer(ActionData action_data)
override void CreateAndSetupActionCallback(ActionData action_data)
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
override void Start(ActionData action_data)
Super root of all classes in Enforce script.
Definition EnScript.c:11
InventoryLocation.
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597
proto native CGame GetGame()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.