Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
actionplugtargetintothis.c
Go to the documentation of this file.
1
class
ActionPlugTargetIntoThis
:
ActionSingleUseBase
2
{
3
bool
m_Retoggle
;
4
5
void
ActionPlugTargetIntoThis
()
6
{
7
m_CommandUID
=
DayZPlayerConstants
.CMD_ACTIONMOD_INTERACTONCE;
8
m_Retoggle
=
false
;
9
m_Text
=
"#connect_together"
;
10
}
11
12
override
void
CreateConditionComponents
()
13
{
14
m_ConditionItem
=
new
CCINonRuined
();
15
m_ConditionTarget
=
new
CCTNonRuined
(
UAMaxDistances
.
DEFAULT
);
16
}
17
18
override
bool
Can
(
PlayerBase
player,
ActionTarget
target,
ItemBase
item)
19
{
20
if
(super.Can(player, target, item))
21
{
22
if
(player.IsPlacingLocal())
23
{
24
m_Retoggle
=
true
;
25
26
player.GetHologramLocal().SetIsHidden(
true
);
27
player.GetHologramLocal().GetProjectionEntity().HideAllSelections();
28
}
29
}
30
31
if
(!super.Can(player, target, item))
32
{
33
if
(
m_Retoggle
)
34
{
35
m_Retoggle
=
false
;
36
37
player.GetHologramLocal().SetIsHidden(
false
);
38
player.GetHologramLocal().GetProjectionEntity().ShowAllSelections();
39
}
40
}
41
42
return
super.Can(player, target, item);
43
}
44
45
override
bool
ActionCondition
(
PlayerBase
player,
ActionTarget
target,
ItemBase
item)
46
{
47
ItemBase
targetIB =
ItemBase
.Cast(target.GetObject());
48
49
//Prevent plugging to items in inventory
50
if
(targetIB && targetIB.GetHierarchyRoot() == targetIB && item && targetIB.HasEnergyManager() && item.HasEnergyManager())
51
{
52
if
(!targetIB.GetCompEM().IsPlugged() && item.GetCompEM().CanReceivePlugFrom(targetIB))
53
{
54
//hotfix, re-work entire action!
55
return
targetIB.
IsElectricAppliance
();
56
}
57
58
// Special case for vehicle batteries
59
if
(item.IsInherited(
VehicleBattery
))
60
{
61
MetalWire metalWire = MetalWire.Cast(item.GetCompEM().GetPluggedDevice());
62
63
if
(metalWire && metalWire.GetCompEM().CanReceivePlugFrom(targetIB))
64
{
65
return
true
;
// We can power the action_data.m_Target from vehicle battery because it has metal wire attached.
66
}
67
}
68
}
69
70
return
false
;
71
}
72
73
override
bool
IsDeploymentAction
()
74
{
75
return
true
;
76
}
77
78
override
void
OnExecuteServer
(
ActionData
action_data)
79
{
80
Process
(action_data);
81
}
82
83
override
void
OnExecuteClient
(
ActionData
action_data)
84
{
85
m_Retoggle
=
false
;
86
}
87
88
void
Process
(
ActionData
action_data)
89
{
90
ItemBase
targetIB =
ItemBase
.Cast(action_data.m_Target.GetObject());
91
92
if
(action_data.m_MainItem.IsInherited(
VehicleBattery
))
93
{
94
// Car/truck batteries can have a metal wire attached through which they can power common electric appliances
95
MetalWire metalWire = MetalWire.Cast(action_data.m_MainItem.GetCompEM().GetPluggedDevice());
96
if
(metalWire)
97
targetIB.GetCompEM().PlugThisInto(metalWire);
98
}
99
else
100
{
101
// Everything else in general
102
targetIB.GetCompEM().PlugThisInto(action_data.m_MainItem);
103
}
104
105
Spotlight spotlight;
106
if
(Spotlight.CastTo(spotlight, targetIB))
107
spotlight.
Unfold
();
108
109
targetIB.GetInventory().TakeEntityAsAttachment(
InventoryMode
.LOCAL, action_data.m_MainItem);
110
action_data.m_Player.ServerDropEntity(action_data.m_MainItem);
111
}
112
}
InventoryMode
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
Definition
inventory.c:22
ActionData
ActionBase ActionData
Definition
actionbase.c:30
ActionTarget
class ActionTargets ActionTarget
ActionBase::m_Text
string m_Text
Definition
actionbase.c:64
ActionBase::m_ConditionItem
ref CCIBase m_ConditionItem
Definition
actionbase.c:70
ActionBase::m_ConditionTarget
ref CCTBase m_ConditionTarget
Definition
actionbase.c:71
ActionPlugTargetIntoThis::OnExecuteServer
override void OnExecuteServer(ActionData action_data)
Definition
actionplugtargetintothis.c:78
ActionPlugTargetIntoThis::m_Retoggle
bool m_Retoggle
Definition
actionplugtargetintothis.c:3
ActionPlugTargetIntoThis::CreateConditionComponents
override void CreateConditionComponents()
Definition
actionplugtargetintothis.c:12
ActionPlugTargetIntoThis::OnExecuteClient
override void OnExecuteClient(ActionData action_data)
Definition
actionplugtargetintothis.c:83
ActionPlugTargetIntoThis::IsDeploymentAction
override bool IsDeploymentAction()
Definition
actionplugtargetintothis.c:73
ActionPlugTargetIntoThis::Can
override bool Can(PlayerBase player, ActionTarget target, ItemBase item)
Definition
actionplugtargetintothis.c:18
ActionPlugTargetIntoThis::ActionCondition
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Definition
actionplugtargetintothis.c:45
ActionPlugTargetIntoThis::ActionPlugTargetIntoThis
void ActionPlugTargetIntoThis()
Definition
actionplugtargetintothis.c:5
ActionPlugTargetIntoThis::Process
void Process(ActionData action_data)
Definition
actionplugtargetintothis.c:88
ActionSingleUseBase::ActionSingleUseBase
void ActionSingleUseBase()
Definition
actionsingleusebase.c:31
AnimatedActionBase::m_CommandUID
int m_CommandUID
Definition
animatedactionbase.c:143
CCINonRuined
Definition
ccinonruined.c:2
CCTNonRuined
Definition
cctnonruined.c:2
ItemBase
Definition
inventoryitem.c:742
ItemBase::IsElectricAppliance
override bool IsElectricAppliance()
Definition
batterycharger.c:43
ItemBase::Unfold
void Unfold()
Definition
spotlight.c:251
PlayerBase
Definition
playerbaseclient.c:2
UAMaxDistances
Definition
actionconstants.c:110
UAMaxDistances::DEFAULT
const float DEFAULT
Definition
actionconstants.c:112
VehicleBattery
Definition
vehiclebattery.c:2
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition
dayzplayer.c:602
Process
void Process()
Definition
effectmanager.c:743
Games
Dayz
scripts
4_world
classes
useractionscomponent
actions
singleuse
actionplugtargetintothis.c
Generated by
1.17.0