Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
cablereel.c
Go to the documentation of this file.
1class CableReel extends ItemBase
2{
3 bool m_ForceIntoHands;
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 }
12
13 override bool IsElectricAppliance()
14 {
15 return true;
16 }
17
18 void ForceIntoHandsNow(PlayerBase player)
19 {
20 m_ForceIntoHands = true;
21 player.LocalTakeEntityToHands(this); // Local, because ForceIntoHandsNow is executed on both, Client and Server
22 m_ForceIntoHands = false;
23 }
24
25 override bool CanPutInCargo(EntityAI parent)
26 {
27 if (!super.CanPutInCargo(parent))
28 return false;
29
30 EntityAI owner = GetHierarchyParent();
31 if (owner && owner.IsKindOf("Fence"))
32 return true;
33
34 bool allowIntoInventory = !GetCompEM().IsPlugged();
35 return allowIntoInventory;
36 }
37
38 override bool CanPutIntoHands(EntityAI parent)
39 {
40 if (!super.CanPutIntoHands(parent))
41 return false;
42
43 if (m_ForceIntoHands)
44 {
45 return true;
46 }
47 else
48 {
49 EntityAI owner = GetHierarchyParent();
50 if (owner && owner.IsKindOf("Fence"))
51 return true;
52 }
53
54 return true;
55 }
56
57 // Event called on item when it is placed in the player(Man) inventory, passes the owner as a parameter
58 override void OnInventoryEnter(Man player)
59 {
60 super.OnInventoryEnter(player);
61
62 PlayerBase playerPB = PlayerBase.Cast(player);
63 if (playerPB.GetItemInHands() == this && GetCompEM().IsPlugged())
64 return;
65
66 GetCompEM().UnplugAllDevices();
67
68 if (!playerPB.IsPlacingLocal())
69 GetCompEM().UnplugThis();
70 }
71
72 override bool CanRemoveFromHands(EntityAI parent)
73 {
74 return true;
75 }
76
77 //================================================================
78 // ADVANCED PLACEMENT
79 //================================================================
80
81 override void OnPlacementStarted(Man player)
82 {
83 super.OnPlacementStarted(player);
84
85 array<string> selections = {
87 SEL_CORD_FOLDED
88 };
89
90 PlayerBase playerPB = PlayerBase.Cast(player);
91 if (GetGame().IsMultiplayer() && GetGame().IsServer())
92 playerPB.GetHologramServer().SetSelectionToRefresh(selections);
93 else
94 playerPB.GetHologramLocal().SetSelectionToRefresh(selections);
95 }
96
97 override string GetDeploySoundset()
98 {
99 return "placeCableReel_SoundSet";
100 }
101
102 override void SetActions()
103 {
104 super.SetActions();
105
107
116 }
117}
ActionPlaceObjectCB ActiondeployObjectCB ActionPlaceObject()
void AddAction(typename actionName)
void RemoveAction(typename actionName)
void SetActions()
override void OnInventoryEnter(Man player)
Definition barbedwire.c:203
override void OnPlacementStarted(Man player)
override bool IsElectricAppliance()
const string SEL_CORD_PLUGGED
override string GetDeploySoundset()
Definition barbedwire.c:392
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
override bool CanPutInCargo(EntityAI parent)
override bool CanPutIntoHands(EntityAI parent)
override bool CanRemoveFromHands(EntityAI parent)
proto native CGame GetGame()