DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
MetalWire.c
См. документацию.
1class 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
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 {
100 }
101
102 // Called when THIS is detached from battery
103 override void OnIsUnplugged(EntityAI last_energy_source)
104 {
106 GetCompEM().UnplugAllDevices();
107 }
108
109 // Called when some device is plugged into THIS
110 override void OnOwnSocketTaken( EntityAI device )
111 {
113 }
114
115 // Called when some device is unplugged from THIS
116 override void OnOwnSocketReleased( EntityAI device )
117 {
119 }
120
121 override void SetActions()
122 {
123 super.SetActions();
124
129 }
130}
AttachActionData ActionData ActionAttach()
Определения ActionAttach.c:9
void AddAction(typename actionName)
Определения AdvancedCommunication.c:220
Super root of all classes in Enforce script.
Определения EnScript.c:11
Определения Building.c:6
override void OnInventoryEnter(Man player)
Определения MetalWire.c:72
override bool CanPutAsAttachment(EntityAI parent)
Определения MetalWire.c:13
override void OnIsPlugged(EntityAI source_device)
Определения MetalWire.c:97
override void OnOwnSocketReleased(EntityAI device)
Определения MetalWire.c:116
override void OnOwnSocketTaken(EntityAI device)
Определения MetalWire.c:110
override void SetActions()
Определения MetalWire.c:121
static string SEL_WIRE_ROLLED
Определения MetalWire.c:3
static string SEL_PLUG_SUFIX
Определения MetalWire.c:6
static string SEL_WIRE_PREFIX
Определения MetalWire.c:4
override void OnIsUnplugged(EntityAI last_energy_source)
Определения MetalWire.c:103
void MetalWire()
Определения MetalWire.c:8
static string SEL_WIRE_SUFIX
Определения MetalWire.c:5
void UpdateAllSelections()
Определения MetalWire.c:32
Определения InventoryItem.c:731
Определения PlayerBaseClient.c:2
Определения VehicleBattery.c:2
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
proto int ToLower()
Changes string to lowercase. Returns length.