4 const static int SOUNDS_SPARK_COUNT = 4;
5 const static int SOUNDS_CUT_COUNT = 3;
6 const static int SOUNDS_COLLISION_COUNT = 4;
7 const static int SOUNDS_SHOCK_COUNT = 4;
8 const static float RANDOM_SPARK_INTERVAL = 5.0;
10 const static string m_SoundsSpark[SOUNDS_SPARK_COUNT] = {
"electricFenceSpark1",
"electricFenceSpark2",
"electricFenceSpark3",
"electricFenceSpark4"};
11 const static string m_SoundsCut[SOUNDS_CUT_COUNT] = {
"barbedFenceCut1",
"barbedFenceCut2",
"barbedFenceCut3"};
12 const static string m_SoundsCollision[SOUNDS_COLLISION_COUNT] = {
"barbedFenceCollision1",
"barbedFenceCollision2",
"barbedFenceCollision3",
"barbedFenceCollision4"};
13 const static string m_SoundsShock[SOUNDS_SHOCK_COUNT] = {
"electricFenceShock1",
"electricFenceShock2",
"electricFenceShock3",
"electricFenceShock4"};
14 const static string m_SoundBuzzLoop =
"electricFenceBuzzLoop1";
17 SoundOnVehicle m_BuzzSoundLoop;
19 ref
Timer m_SparkEvent;
22 protected bool m_TriggerActive;
23 protected bool m_IsPlaced;
26 protected bool m_IsMounted;
27 protected bool m_LastMountedState;
28 const string SOUND_MOUNT =
"putDown_BarbedWire_SoundSet";
35 m_TriggerActive =
false;
39 RegisterNetSyncVariableBool(
"m_IsSoundSynchRemote" );
40 RegisterNetSyncVariableBool(
"m_IsDeploySound" );
41 RegisterNetSyncVariableBool(
"m_IsMounted" );
58 return GetSlotLockedState();
61 protected bool GetSlotLockedState()
67 GetInventory().GetCurrentInventoryLocation( inventory_location );
68 return base_building.GetInventory().GetSlotLock( inventory_location.GetSlot() );
74 void SetMountedState(
bool is_mounted )
79 m_IsMounted = is_mounted;
80 LockAttachmentSlot( is_mounted );
87 protected void UpdateAttachmentSlot()
93 GetInventory().GetCurrentInventoryLocation( inventory_location );
94 bool is_mounted = base_building.GetInventory().GetSlotLock( inventory_location.GetSlot() );
95 string slot_name =
InventorySlots.GetSlotName( inventory_location.GetSlot() );
97 base_building.UpdateAttachmentVisuals( slot_name, is_mounted );
98 base_building.UpdateAttachmentPhysics( slot_name, is_mounted );
102 protected void LockAttachmentSlot(
bool lock_state )
108 GetInventory().GetCurrentInventoryLocation( inventory_location );
109 base_building.GetInventory().SetSlotLock( inventory_location.GetSlot(), lock_state );
127 super.OnVariablesSynchronized();
129 if ( ( m_IsMounted && !m_LastMountedState ) || ( !m_IsMounted && m_LastMountedState ) )
132 PlaySoundSet( m_MountSound, SOUND_MOUNT, 0.1, 0.1 );
134 m_LastMountedState = m_IsMounted;
154 if ( !
GetGame().IsDedicatedServer() )
165 if ( !
GetGame().IsDedicatedServer() )
175 super.OnStoreSave( ctx );
180 if ( !super.OnStoreLoad( ctx, version ) )
188 if ( !ctx.Read( is_mounted ) )
200 super.AfterStoreLoad();
203 SetMountedState( GetSlotLockedState() );
209 SoundBuzzLoopStart();
216 CreateElectrifiedDamageTrigger();
232 override void OnWork(
float consumed_energy ) {}
234 override void OnIsPlugged(
EntityAI source_device)
239 override void OnIsUnplugged(
EntityAI last_energy_source )
248 super.OnInventoryEnter(player);
249 HideSelection(
"placing");
250 ShowSelection(
"zbytek");
253 GetCompEM().UnplugThis();
254 GetCompEM().UnplugAllDevices();
259 protected void CreateElectrifiedDamageTrigger()
264 m_AreaDamage.SetHitZones({
"RightLeg",
"LeftLeg",
"RightFoot",
"LeftFoot"});
267 m_TriggerActive =
true;
274 m_AreaDamage.SetHitZones({
"RightLeg",
"LeftLeg",
"RightFoot",
"LeftFoot"});
277 m_TriggerActive =
true;
283 m_TriggerActive =
false;
314 int random_index =
Math.RandomInt(0, SOUNDS_CUT_COUNT);
315 string sound_type = m_SoundsCut[random_index];
325 int random_index =
Math.RandomInt(0, SOUNDS_SPARK_COUNT);
326 string sound_type = m_SoundsSpark[random_index];
332 void SoundBuzzLoopStart()
336 if (!m_BuzzSoundLoop)
338 m_BuzzSoundLoop = PlaySoundLoop(m_SoundBuzzLoop, 50);
344 void SoundBuzzLoopStop()
350 GetGame().ObjectDelete(m_BuzzSoundLoop);
351 m_BuzzSoundLoop = NULL;
357 void SoundElectricShock()
361 int random_index =
Math.RandomInt(0, SOUNDS_SHOCK_COUNT);
362 string sound_type = m_SoundsShock[random_index];
368 void SoundCollision()
372 int random_index =
Math.RandomInt(0, SOUNDS_COLLISION_COUNT);
373 string sound_type = m_SoundsCollision[random_index];
381 override void PreAreaDamageActions()
383 if ( GetCompEM().IsPlugged() && GetCompEM().IsSwitchedOn() )
386 SoundElectricShock();
391 override void PostAreaDamageActions()
394 MiscGameplayFunctions.DealAbsoluteDmg(
this, 1000);
402 super.OnItemLocationChanged(old_owner, new_owner);
417 super.OnPlacementComplete( player, position, orientation );
422 HideSelection(
"zbytek");
424 if (!GetHierarchyParent())
426 if (GetCompEM().IsPlugged() && GetCompEM().IsWorking() )
427 { CreateElectrifiedDamageTrigger(); }
439 return "placeBarbedWire_SoundSet";
444 return "barbedwire_deploy_SoundSet";