Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
metalwire.c
Go to the documentation of this file.
1
class
MetalWire
extends
ItemBase
2
{
3
static
string
SEL_WIRE_ROLLED
=
"rolled"
;
4
static
string
SEL_WIRE_PREFIX
=
"Att_"
;
5
static
string
SEL_WIRE_SUFIX
=
"_plugged"
;
6
static
string
SEL_PLUG_SUFIX
=
"_plug"
;
7
8
void
MetalWire
()
9
{
10
11
}
12
13
override
bool
CanPutAsAttachment
(
EntityAI
parent )
14
{
15
if
(!super.CanPutAsAttachment(parent))
16
return
false
;
17
18
if
( parent.IsInherited(
VehicleBattery
) )
19
{
20
EntityAI
battery_owner =
EntityAI
.Cast( parent.GetHierarchyParent() );
21
22
// Check for Not player as if parent is not player, battery is already attached and should not receive new attachment
23
if
( battery_owner && !battery_owner.IsInherited(
PlayerBase
) )
24
{
25
return
false
;
26
}
27
}
28
29
return
true
;
30
}
31
32
void
UpdateAllSelections
()
33
{
34
HideAllSelections();
35
EntityAI
energy_source = GetCompEM().GetEnergySource();
36
37
if
(energy_source)
38
{
39
string
ES_model = energy_source.GetModelName();
40
EntityAI
powered_device = GetCompEM().GetPluggedDevice();
41
42
if
(powered_device)
43
{
44
// Show metal wire selection
45
string
selection_wire =
SEL_WIRE_PREFIX
+ ES_model +
SEL_WIRE_SUFIX
;
46
ShowSelection(selection_wire);
47
48
// Show plug selection
49
string
selection_plug =
SEL_WIRE_PREFIX
+ ES_model +
SEL_PLUG_SUFIX
;
50
selection_plug.
ToLower
();
51
ShowSelection(selection_plug);
52
53
// Set plug's texture
54
int
selection_index = GetHiddenSelectionIndex(selection_plug);
55
string
texture_path = powered_device.GetCompEM().GetCordTextureFile();
56
SetObjectTexture( selection_index, texture_path );
57
}
58
else
59
{
60
// Show metal wire selection
61
string
selection_wire2 =
SEL_WIRE_PREFIX
+ ES_model;
62
ShowSelection(selection_wire2);
63
}
64
}
65
else
66
{
67
ShowSelection(
SEL_WIRE_ROLLED
);
68
}
69
}
70
71
// Event called on item when it is placed in the player(Man) inventory, passes the owner as a parameter
72
override
void
OnInventoryEnter
( Man player )
73
{
74
super.OnInventoryEnter( player );
75
76
PlayerBase
player_PB;
77
Class
.
CastTo
( player_PB, player );
78
if
( player_PB.GetItemInHands() ==
this
&& GetCompEM().IsPlugged() )
79
{
80
return
;
81
}
82
83
//Only unplug if we are "powering" something
84
ItemBase
powered_device =
ItemBase
.Cast( GetCompEM().GetPluggedDevice() );
85
if
( powered_device )
86
{
87
GetCompEM().UnplugAllDevices();
88
89
if
( !player_PB.IsPlacingLocal() )
90
{
91
GetCompEM().UnplugThis();
92
}
93
}
94
}
95
96
// Called when THIS is attached to battery
97
override
void
OnIsPlugged
(
EntityAI
source_device)
98
{
99
UpdateAllSelections
();
100
}
101
102
// Called when THIS is detached from battery
103
override
void
OnIsUnplugged
(
EntityAI
last_energy_source)
104
{
105
UpdateAllSelections
();
106
GetCompEM().UnplugAllDevices();
107
}
108
109
// Called when some device is plugged into THIS
110
override
void
OnOwnSocketTaken
(
EntityAI
device )
111
{
112
UpdateAllSelections
();
113
}
114
115
// Called when some device is unplugged from THIS
116
override
void
OnOwnSocketReleased
(
EntityAI
device )
117
{
118
UpdateAllSelections
();
119
}
120
121
override
void
SetActions
()
122
{
123
super.SetActions();
124
125
AddAction
(
ActionRestrainTarget
);
126
AddAction
(
ActionRestrainSelf
);
127
AddAction
(
ActionAttachToConstruction
);
128
AddAction
(
ActionAttach
);
129
}
130
}
ActionAttach
AttachActionData ActionData ActionAttach()
Definition
actionattach.c:9
AddAction
void AddAction(typename actionName)
Definition
advancedcommunication.c:220
ActionAttachToConstruction
Definition
actionattachtoconstruction.c:2
ActionRestrainSelf
Definition
actionrestrainself.c:24
ActionRestrainTarget
Definition
actionrestraintarget.c:24
Class
Super root of all classes in Enforce script.
Definition
enscript.c:11
EntityAI
Definition
inventoryitem.c:2
ItemBase
Definition
inventoryitem.c:742
ItemBase::SEL_WIRE_PREFIX
static string SEL_WIRE_PREFIX
Definition
metalwire.c:4
ItemBase::MetalWire
void MetalWire()
Definition
metalwire.c:8
ItemBase::SEL_WIRE_ROLLED
static string SEL_WIRE_ROLLED
Definition
metalwire.c:3
ItemBase::OnIsUnplugged
override void OnIsUnplugged(EntityAI last_energy_source)
Definition
metalwire.c:103
ItemBase::SEL_WIRE_SUFIX
static string SEL_WIRE_SUFIX
Definition
metalwire.c:5
ItemBase::OnIsPlugged
override void OnIsPlugged(EntityAI source_device)
Definition
metalwire.c:97
ItemBase::CanPutAsAttachment
override bool CanPutAsAttachment(EntityAI parent)
Definition
metalwire.c:13
ItemBase::OnOwnSocketReleased
override void OnOwnSocketReleased(EntityAI device)
Definition
metalwire.c:116
ItemBase::OnOwnSocketTaken
override void OnOwnSocketTaken(EntityAI device)
Definition
metalwire.c:110
ItemBase::UpdateAllSelections
void UpdateAllSelections()
Definition
metalwire.c:32
ItemBase::SEL_PLUG_SUFIX
static string SEL_PLUG_SUFIX
Definition
metalwire.c:6
ItemBase::OnInventoryEnter
override void OnInventoryEnter(Man player)
Definition
metalwire.c:72
ItemBase::SetActions
override void SetActions()
Definition
metalwire.c:121
PlayerBase
Definition
playerbaseclient.c:2
VehicleBattery
Definition
vehiclebattery.c:2
Class::CastTo
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
string::ToLower
proto int ToLower()
Changes string to lowercase.
Games
Dayz
scripts
4_world
entities
itembase
metalwire.c
Generated by
1.17.0