DayZ 1.24
Loading...
Searching...
No Matches
CableReel.c
Go to the documentation of this file.
1class CableReel extends ItemBase
2{
4
5 static const string SEL_CORD_FOLDED = "cord_folded";
6 static const string SEL_CORD_PLUGGED = "cord_plugged";
7
8 void CableReel()
9 {
10 m_ForceIntoHands = false;
11 RegisterNetSyncVariableBool("m_IsSoundSynchRemote");
12 RegisterNetSyncVariableBool("m_IsPlaceSound");
13 }
14
15 override bool IsElectricAppliance()
16 {
17 return true;
18 }
19
21 {
22 m_ForceIntoHands = true;
23 player.LocalTakeEntityToHands(this); // Local, because ForceIntoHandsNow is executed on both, Client and Server
24 m_ForceIntoHands = false;
25 }
26
27 override bool CanPutInCargo(EntityAI parent)
28 {
29 if (!super.CanPutInCargo(parent)) return false;
30 EntityAI owner_EAI = GetHierarchyParent();
31 if (owner_EAI && owner_EAI.IsKindOf("Fence"))
32 return true;
33
34 bool allow_into_inv = !GetCompEM().IsPlugged();
35 return allow_into_inv;
36 }
37
39 {
40 if (!super.CanPutIntoHands(parent))
41 return false;
42 if (m_ForceIntoHands)
43 return true;
44 else
45 {
46 EntityAI owner_EAI = GetHierarchyParent();
47 if (owner_EAI && owner_EAI.IsKindOf("Fence"))
48 return true;
49 }
50
51 return true;
52 }
53
54 // Event called on item when it is placed in the player(Man) inventory, passes the owner as a parameter
55 override void OnInventoryEnter(Man player)
56 {
57 super.OnInventoryEnter(player);
58
61 if (player_PB.GetItemInHands() == this && GetCompEM().IsPlugged())
62 {
63 //player_PB.TogglePlacingLocal();
64 return;
65 }
66
67 GetCompEM().UnplugAllDevices();
68
69 if (!player_PB.IsPlacingLocal())
70 GetCompEM().UnplugThis();
71 }
72
74 {
75 return true;
76 }
77
79 {
80 super.OnVariablesSynchronized();
81
82 if (IsPlaceSound())
84 }
85
86 //================================================================
87 // ADVANCED PLACEMENT
88 //================================================================
89
90 override void OnPlacementStarted(Man player)
91 {
92 super.OnPlacementStarted(player);
93
96 SEL_CORD_FOLDED
97 };
98
100 if (GetGame().IsMultiplayer() && GetGame().IsServer())
101 playerPB.GetHologramServer().SetSelectionToRefresh(selections);
102 else if (playerPB.GetHologramLocal())
103 playerPB.GetHologramLocal().SetSelectionToRefresh(selections);
104 }
105
106 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
107 {
108 super.OnPlacementComplete(player, position, orientation);
109
110 SetIsPlaceSound(true);
111 }
112
113 override string GetPlaceSoundset()
114 {
115 return "placeCableReel_SoundSet";
116 }
117
132}
void AddAction(typename actionName)
void RemoveAction(typename actionName)
void PlayPlaceSound()
Definition ItemBase.c:9027
void SetIsPlaceSound(bool is_place_sound)
Definition ItemBase.c:8962
bool IsPlaceSound()
Definition ItemBase.c:8967
Super root of all classes in Enforce script.
Definition EnScript.c:11
override bool CanPutIntoHands(EntityAI player)
Definition CableReel.c:38
override void OnInventoryEnter(Man player)
Definition CableReel.c:55
override void OnPlacementStarted(Man player)
Definition CableReel.c:90
override bool CanRemoveFromHands(EntityAI player)
Definition CableReel.c:73
override bool IsElectricAppliance()
Definition CableReel.c:15
override void SetActions()
Definition CableReel.c:118
const string SEL_CORD_PLUGGED
bool m_ForceIntoHands
Definition CableReel.c:3
override string GetPlaceSoundset()
Definition CableReel.c:113
override void OnVariablesSynchronized()
Definition CableReel.c:78
override bool CanPutInCargo(EntityAI parent)
Definition CableReel.c:27
override void OnPlacementComplete(Man player, vector position="0 0 0", vector orientation="0 0 0")
Definition CableReel.c:106
void CableReel()
Definition CableReel.c:8
void ForceIntoHandsNow(PlayerBase player)
Definition CableReel.c:20
proto native CGame GetGame()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.