Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
kitbase.c
Go to the documentation of this file.
1 class KitBase extends ItemBase
2 {
3  ref protected EffectSound m_DeployLoopSound;
4  protected bool m_DeployedRegularly;
5 
6  void KitBase()
7  {
8  RegisterNetSyncVariableBool("m_IsSoundSynchRemote");
9  RegisterNetSyncVariableBool("m_IsDeploySound");
10  }
11 
12  void ~KitBase()
13  {
14  SEffectManager.DestroyEffect( m_DeployLoopSound );
15  }
16 
17  override bool IsBasebuildingKit()
18  {
19  return true;
20  }
21 
22  override bool HasProxyParts()
23  {
24  return true;
25  }
26 
27  override bool CanProxyObstruct()
28  {
29  return false;
30  }
31 
32  override void OnVariablesSynchronized()
33  {
34  super.OnVariablesSynchronized();
35 
36  if ( IsDeploySound() )
37  {
39  }
40 
41  if ( CanPlayDeployLoopSound() )
42  {
44  }
45 
47  {
49  }
50 
51  if ( m_DeployedRegularly && IsSoundSynchRemote() )
52  {
54  }
55  }
56 
57  override void EEInit()
58  {
59  super.EEInit();
60 
61  //set visual on init
62  UpdateVisuals();
63  UpdatePhysics();
64 
65  if (GetGame().IsServer())
66  {
67  GetGame().GetCallQueue( CALL_CATEGORY_GAMEPLAY ).Call( AssembleKit );
68  }
69  }
70 
71  override bool DisassembleOnLastDetach()
72  {
73  return true;
74  }
75 
76  override void EEItemDetached(EntityAI item, string slot_name)
77  {
78  super.EEItemDetached( item, slot_name );
79 
80  PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
81  if ( player && player.IsPlayerDisconnected() )
82  return;
83 
84  if (item && slot_name == "Rope")
85  {
86  if (GetGame().IsServer() && !m_DeployedRegularly)
87  {
88  DisassembleKit(ItemBase.Cast(item));
89  Delete();
90  }
91  }
92  }
93 
94  override void OnItemLocationChanged( EntityAI old_owner, EntityAI new_owner )
95  {
96  super.OnItemLocationChanged( old_owner, new_owner );
97 
98  //update visuals after location change
99  UpdatePhysics();
100  }
101 
102  override void OnEndPlacement()
103  {
104  m_DeployedRegularly = true;
106  }
107 
108  override void OnPlacementCancelled( Man player )
109  {
110  super.OnPlacementCancelled(player);
111  m_DeployedRegularly = false;
112  }
113 
114  override bool IsDeployable()
115  {
116  return true;
117  }
118 
119  override bool CanAssignAttachmentsToQuickbar()
120  {
121  return false;
122  }
123 
124  override string GetDeploySoundset()
125  {
126  return "putDown_FenceKit_SoundSet";
127  }
128 
129  override string GetLoopDeploySoundset()
130  {
131  //return "BarbedWire_Deploy_loop_SoundSet";
132  return "Shelter_Site_Build_Loop_SoundSet";
133  }
134 
135  override string GetDeployFinishSoundset()
136  {
137  return "";
138  }
139 
140  override void RefreshPhysics()
141  {
142  super.RefreshPhysics();
143 
144  UpdatePhysics();
145  }
146 
147  //Update visuals and physics
148  void UpdateVisuals()
149  {
150  SetAnimationPhase( "Inventory", 0 );
151  SetAnimationPhase( "Placing", 1 );
152  }
153 
154  void UpdatePhysics()
155  {
156  AddProxyPhysics( "Inventory" );
157  RemoveProxyPhysics( "Placing" );
158  }
159 
160  void PlayDeployLoopSound()
161  {
162  if ( !GetGame().IsDedicatedServer() )
163  {
164  if ( !m_DeployLoopSound || !m_DeployLoopSound.IsSoundPlaying() )
165  {
166  m_DeployLoopSound = SEffectManager.PlaySound( GetLoopDeploySoundset(), GetPosition() );
167  }
168  }
169  }
170 
171  void StopDeployLoopSound()
172  {
173  if ( !GetGame().IsDedicatedServer() )
174  {
175  m_DeployLoopSound.SetSoundFadeOut(0.5);
176  m_DeployLoopSound.SoundStop();
177  }
178  }
179 
180  void AssembleKit()
181  {
182  if (!IsHologram())
183  {
184  Rope rope = Rope.Cast(GetInventory().CreateAttachment("Rope"));
185  }
186  }
187 
188  void DisassembleKit(ItemBase item) {}
189 
190  void CreateRope(Rope rope)
191  {
192  if (!rope)
193  return;
194 
195  InventoryLocation targetLoc = rope.GetTargetLocation();
196  if (targetLoc && targetLoc.GetType() != InventoryLocationType.GROUND)
197  {
198  MiscGameplayFunctions.TransferItemProperties(this, rope);
199  return;
200  }
201 
202  EntityAI newRope = EntityAI.Cast(GetGame().CreateObjectEx(rope.GetType(), GetPosition(), ECE_PLACE_ON_SURFACE));
203 
204  if (newRope)
205  MiscGameplayFunctions.TransferItemProperties(this, newRope);
206 
207  rope.Delete();
208  }
209 
210  override void SetActions()
211  {
212  super.SetActions();
213 
216  }
217 }
ItemBase
Definition: inventoryitem.c:730
UpdatePhysics
void UpdatePhysics()
Definition: construction.c:207
GetGame
proto native CGame GetGame()
KitBase
Definition: fencekit.c:1
ActionDeployObject
PlaceObjectActionReciveData ActionReciveData ActionDeployObject()
Definition: actiondeployobject.c:9
CALL_CATEGORY_GAMEPLAY
const int CALL_CATEGORY_GAMEPLAY
Definition: tools.c:10
OnEndPlacement
void OnEndPlacement()
Definition: itembase.c:960
InventoryLocation
InventoryLocation.
Definition: inventorylocation.c:27
OnVariablesSynchronized
override void OnVariablesSynchronized()
Definition: anniversarymusicsource.c:42
ECE_PLACE_ON_SURFACE
const int ECE_PLACE_ON_SURFACE
Definition: centraleconomy.c:37
PlayDeploySound
void PlayDeploySound()
Definition: itembase.c:4324
PlayDeployLoopSound
void PlayDeployLoopSound()
PlayDeployFinishSound
void PlayDeployFinishSound()
Definition: itembase.c:4336
RefreshPhysics
void RefreshPhysics()
ActionTogglePlaceObject
Definition: actiontoggleplaceobject.c:1
IsDeploySound
bool IsDeploySound()
Definition: itembase.c:4298
GetPosition
class JsonUndergroundAreaTriggerData GetPosition
Definition: undergroundarealoader.c:9
EffectSound
Wrapper class for managing sound through SEffectManager.
Definition: effectsound.c:4
PlayerBase
Definition: playerbaseclient.c:1
InventoryLocationType
InventoryLocationType
types of Inventory Location
Definition: inventorylocation.c:3
AddAction
void AddAction(typename actionName)
Definition: advancedcommunication.c:86
SetActions
void SetActions()
Definition: advancedcommunication.c:79
UpdateVisuals
void UpdateVisuals()
Definition: construction.c:188
IsDeployable
override bool IsDeployable()
Definition: basebuildingbase.c:339
m_DeployLoopSound
protected ref EffectSound m_DeployLoopSound
Definition: trapbase.c:47
IsHologram
override bool IsHologram()
Definition: itembase.c:962
StopDeployLoopSound
void StopDeployLoopSound()
EEInit
override void EEInit()
Definition: contaminatedarea.c:27
CanPlayDeployLoopSound
bool CanPlayDeployLoopSound()
Definition: itembase.c:4360
OnItemLocationChanged
override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
Definition: combinationlock.c:75
SEffectManager
Manager class for managing Effect (EffectParticle, EffectSound)
Definition: effectmanager.c:5
EEItemDetached
override void EEItemDetached(EntityAI item, string slot_name)
Definition: basebuildingbase.c:529
EntityAI
Definition: building.c:5
OnPlacementCancelled
override void OnPlacementCancelled(Man player)
Definition: trap_tripwire.c:361
IsSoundSynchRemote
bool IsSoundSynchRemote()
Definition: itembase.c:4273
DisassembleOnLastDetach
override bool DisassembleOnLastDetach()
Definition: fireplacebase.c:2701
SoundSynchRemote
void SoundSynchRemote()
Definition: itembase.c:4266