Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
cablereel.c
Go to the documentation of this file.
1 class 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  RegisterNetSyncVariableBool("m_IsSoundSynchRemote");
12  RegisterNetSyncVariableBool("m_IsPlaceSound");
13  }
14 
15  override bool IsElectricAppliance()
16  {
17  return true;
18  }
19 
20  void ForceIntoHandsNow( PlayerBase player )
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  {
33  return true;
34  }
35 
36  bool allow_into_inv = !GetCompEM().IsPlugged();
37  return allow_into_inv;
38  }
39 
40  override bool CanPutIntoHands ( EntityAI player )
41  {
42  if ( !super.CanPutIntoHands( parent ) )
43  {
44  return false;
45  }
46  if ( m_ForceIntoHands )
47  {
48  return true;
49  }
50  else
51  {
52  EntityAI owner_EAI = GetHierarchyParent();
53  if ( owner_EAI && owner_EAI.IsKindOf("Fence"))
54  {
55  return true;
56  }
57  }
58 
59  return true;
60  }
61 
62  // Event called on item when it is placed in the player(Man) inventory, passes the owner as a parameter
63  override void OnInventoryEnter(Man player)
64  {
65  super.OnInventoryEnter(player);
66 
67  PlayerBase player_PB;
68  Class.CastTo(player_PB, player);
69  if (player_PB.GetItemInHands() == this && GetCompEM().IsPlugged())
70  {
71  //player_PB.TogglePlacingLocal();
72  return;
73  }
74 
75  GetCompEM().UnplugAllDevices();
76 
77  if (!player_PB.IsPlacingLocal())
78  GetCompEM().UnplugThis();
79  }
80 
81  override bool CanRemoveFromHands( EntityAI player )
82  {
83  return true;
84  }
85 
86  override void OnVariablesSynchronized()
87  {
88  super.OnVariablesSynchronized();
89 
90  if ( IsPlaceSound() )
91  {
93  }
94  }
95 
96  //================================================================
97  // ADVANCED PLACEMENT
98  //================================================================
99 
100  override void OnPlacementStarted(Man player)
101  {
102  super.OnPlacementStarted(player);
103 
104  array<string> selections = {
105  SEL_CORD_PLUGGED,
106  SEL_CORD_FOLDED
107  };
108 
109  PlayerBase playerPB = PlayerBase.Cast(player);
110  if (GetGame().IsMultiplayer() && GetGame().IsServer())
111  playerPB.GetHologramServer().SetSelectionToRefresh(selections);
112  else
113  if (playerPB.GetHologramLocal())
114  playerPB.GetHologramLocal().SetSelectionToRefresh(selections);
115  }
116 
117  override void OnPlacementComplete( Man player, vector position = "0 0 0", vector orientation = "0 0 0" )
118  {
119  super.OnPlacementComplete( player, position, orientation );
120 
121  SetIsPlaceSound( true );
122  }
123 
124  override string GetPlaceSoundset()
125  {
126  return "placeCableReel_SoundSet";
127  }
128 
129  override void SetActions()
130  {
131  super.SetActions();
133 
142  }
143 }
ItemBase
Definition: inventoryitem.c:730
GetGame
proto native CGame GetGame()
OnPlacementStarted
override void OnPlacementStarted(Man player)
Definition: itembase.c:3804
ActionPlugIn
Definition: actionplugin.c:1
ActionTakeItemToHands
Definition: actiontakeitemtohands.c:1
ActionPlaceObject
Definition: actionplaceobject.c:9
RemoveAction
void RemoveAction(typename actionName)
Definition: advancedcommunication.c:118
OnVariablesSynchronized
override void OnVariablesSynchronized()
Definition: anniversarymusicsource.c:42
IsPlaceSound
bool IsPlaceSound()
Definition: itembase.c:4288
OnInventoryEnter
override protected void OnInventoryEnter(Man player)
Definition: fireworksbase.c:71
OnPlacementComplete
override void OnPlacementComplete(Man player, vector position="0 0 0", vector orientation="0 0 0")
Definition: explosivesbase.c:133
ActionTogglePlaceObject
Definition: actiontoggleplaceobject.c:1
ActionPullOutPlug
Definition: actionpulloutplug.c:1
PlayerBase
Definition: playerbaseclient.c:1
CanPutIntoHands
override bool CanPutIntoHands(EntityAI parent)
Definition: explosivesbase.c:257
vector
Definition: enconvert.c:105
CanPutInCargo
override bool CanPutInCargo(EntityAI parent)
Definition: explosivesbase.c:247
PlayPlaceSound
void PlayPlaceSound()
Definition: itembase.c:4348
CanRemoveFromHands
override bool CanRemoveFromHands(EntityAI parent)
Definition: explosivesbase.c:267
AddAction
void AddAction(typename actionName)
Definition: advancedcommunication.c:86
SetActions
void SetActions()
Definition: advancedcommunication.c:79
SetIsPlaceSound
void SetIsPlaceSound(bool is_place_sound)
Definition: itembase.c:4283
ActionUnplugThisByCord
Definition: actionunplugthisbycord.c:1
ActionRepositionPluggedItem
Definition: actionrepositionpluggeditem.c:1
array< string >
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
ActionPlugTargetIntoThis
Definition: actionplugtargetintothis.c:1
EntityAI
Definition: building.c:5
GetPlaceSoundset
override string GetPlaceSoundset()
Definition: fireplacebase.c:2574