3 const int GATE_STATE_NONE = 0;
4 const int GATE_STATE_PARTIAL = 1;
5 const int GATE_STATE_FULL = 2;
7 const string ATTACHMENT_SLOT_COMBINATION_LOCK =
"Att_CombinationLock";
8 const string SOUND_GATE_OPEN_START =
"DoorWoodTowerOpen_SoundSet";
9 const string SOUND_GATE_CLOSE_START =
"DoorWoodTowerClose_start_SoundSet";
10 const string SOUND_GATE_CLOSE_END =
"DoorWoodTowerClose_end_SoundSet";
13 const float GATE_ROTATION_ANGLE_DEG = 100;
14 const float GATE_ROTATION_TIME_APPROX = 2000;
16 const float MAX_ACTION_DETECTION_ANGLE_RAD = 1.3;
17 const float MAX_ACTION_DETECTION_DISTANCE = 2.0;
19 typename ATTACHMENT_WOODEN_LOG = WoodenLog;
22 string ATTSLOT_CAMONET =
"Wall_Camonet";
23 string ATTSLOT_BARBEDWIRE_DOWN =
"Wall_Barbedwire_1";
24 string ATTSLOT_BARBEDWIRE_UP =
"Wall_Barbedwire_2";
28 protected bool m_ToDiscard =
false;
30 protected bool m_IsOpenedClient =
false;
31 protected int m_GateState = 0;
41 RegisterNetSyncVariableBool(
"m_IsOpened" );
42 RegisterNetSyncVariableInt(
"m_GateState" );
58 return m_GateState > GATE_STATE_NONE;
63 return m_GateState == GATE_STATE_FULL;
80 int state = GATE_STATE_NONE;
81 if( gate_part.IsBuilt() )
85 for (
int i = 0; i < req_parts.Count(); i++)
88 if(!req_part.IsBuilt())
92 if( i != req_parts.Count() )
94 state = GATE_STATE_PARTIAL;
98 state = GATE_STATE_FULL;
118 if ( combination_lock && combination_lock.IsLocked() )
128 if ( m_GateState != GATE_STATE_NONE )
130 output =
"#str_cfgvehicles_construction_part_gate";
140 return combination_lock;
145 CamoNet camonet = CamoNet.Cast( FindAttachmentBySlotName(
"Wall_Camonet" ) );
151 BarbedWire barbedwire = BarbedWire.Cast( FindAttachmentBySlotName(
"Wall_Barbedwire_1" ) );
157 BarbedWire barbedwire = BarbedWire.Cast( FindAttachmentBySlotName(
"Wall_Barbedwire_2" ) );
164 if ( MemoryPointExists(
"kit_spawn_position" ) )
167 position = GetMemoryPointPos(
"kit_spawn_position" );
169 return ModelToWorld( position );
178 if (!super.CanDisplayAttachmentSlot(slot_id))
183 if ( slot_name ==
"Att_CombinationLock" )
199 if ( category_name ==
"Attachments" || category_name ==
"Material" )
214 super.OnStoreSave( ctx );
217 ctx.Write( m_GateState );
224 if ( !super.OnStoreLoad( ctx, version ) )
231 if ( !ctx.Read( m_ToDiscard ) )
236 m_GateState = GATE_STATE_NONE;
238 else if ( !ctx.Read( m_GateState ) )
240 m_GateState = GATE_STATE_NONE;
259 super.AfterStoreLoad();
278 super.OnVariablesSynchronized();
284 if ( m_IsOpenedClient )
301 super.OnPartBuiltServer( player, part_name, action_id );
314 if ( constrution_part.IsGate() )
319 combination_lock.UnlockServer( player ,
this );
323 super.OnPartDismantledServer( player, part_name, action_id );
331 override void OnPartDestroyedServer( Man player,
string part_name,
int action_id,
bool destroyed_by_connected_part =
false )
333 super.OnPartDestroyedServer( player, part_name, action_id );
337 if ( constrution_part.IsGate() && destroyed_by_connected_part )
349 if ( part_name ==
"wall_base_down" )
354 if ( part_name ==
"wall_base_up" )
369 if ( !super.CanReceiveAttachment(attachment, slotId) )
373 if ( !
GetGame().IsDedicatedServer() )
386 if ( attachment.Type() != ATTACHMENT_WOODEN_LOG )
394 if ( attachment.IsInherited( ATTACHMENT_COMBINATION_LOCK ) )
408 if( !super.CanPutIntoHands( parent ) )
452 float value = GATE_ROTATION_ANGLE_DEG;
453 SetAnimationPhase(
"Wall_Interact_Rotate", value );
454 SetAnimationPhase(
"Wall_Barbedwire_1_Mounted_Rotate", value );
455 SetAnimationPhase(
"Wall_Barbedwire_2_Mounted_Rotate", value );
456 SetAnimationPhase(
"Wall_Camonet_Rotate", value );
457 SetAnimationPhase(
"Wall_Gate_Rotate", value );
458 SetAnimationPhase(
"Wall_Base_Down_Rotate", value );
459 SetAnimationPhase(
"Wall_Base_Up_Rotate", value );
460 SetAnimationPhase(
"Wall_Wood_Down_Rotate", value );
461 SetAnimationPhase(
"Wall_Wood_Up_Rotate", value );
462 SetAnimationPhase(
"Wall_Metal_Down_Rotate", value );
463 SetAnimationPhase(
"Wall_Metal_Up_Rotate", value );
475 if ( !
GetGame().IsDedicatedServer() )
495 SetAnimationPhase(
"Wall_Interact_Rotate", value );
496 SetAnimationPhase(
"Wall_Barbedwire_1_Mounted_Rotate", value );
497 SetAnimationPhase(
"Wall_Barbedwire_2_Mounted_Rotate", value );
498 SetAnimationPhase(
"Wall_Camonet_Rotate", value );
499 SetAnimationPhase(
"Wall_Gate_Rotate", value );
500 SetAnimationPhase(
"Wall_Base_Down_Rotate", value );
501 SetAnimationPhase(
"Wall_Base_Up_Rotate", value );
502 SetAnimationPhase(
"Wall_Wood_Down_Rotate", value );
503 SetAnimationPhase(
"Wall_Wood_Up_Rotate", value );
504 SetAnimationPhase(
"Wall_Metal_Down_Rotate", value );
505 SetAnimationPhase(
"Wall_Metal_Up_Rotate", value );
517 if ( !
GetGame().IsDedicatedServer() )
533 if ( GetAnimationPhase(
"Wall_Gate_Rotate" ) == GATE_ROTATION_ANGLE_DEG )
543 if ( GetAnimationPhase(
"Wall_Gate_Rotate" ) == 0 )
546 if ( !
GetGame().IsDedicatedServer() )
562 rotation_angle = 100;
565 super.CreateAreaDamage( slot_name, rotation_angle );
573 string slot_name_mounted;
576 GetBarbedWire1().GetInventory().GetCurrentAttachmentSlotInfo(slot_id,slot_name);
577 slot_name_mounted = slot_name +
"_Mounted";
584 super.CreateAreaDamage( slot_name_mounted, rotation_angle );
589 GetBarbedWire2().GetInventory().GetCurrentAttachmentSlotInfo(slot_id,slot_name);
590 slot_name_mounted = slot_name +
"_Mounted";
597 super.CreateAreaDamage( slot_name_mounted, rotation_angle );
617 vector player_pos = player.GetPosition();
619 vector ref_dir = GetDirection();
629 vector dir_to_fence = fence_pos - player_pos;
631 float len = dir_to_fence.Length();
633 dir_to_fence.Normalize();
635 vector ref_dir_angle = ref_dir.VectorToAngles();
636 vector dir_to_fence_angle = dir_to_fence.VectorToAngles();
637 vector test_angles = dir_to_fence_angle - ref_dir_angle;
639 vector test_position = test_angles.AnglesToVector() * len;
641 if(test_position[0] < b1[0] || test_position[0] > b2[0] || test_position[2] < 0.2 || test_position[2] > 2.2 )
654 vector player_pos = player.GetPosition();
655 vector ref_dir = GetDirection();
658 vector fence_player_dir = player.GetDirection();
659 fence_player_dir.Normalize();
660 fence_player_dir[1] = 0;
665 if ( ref_dir.Length() != 0 )
667 float angle =
Math.Acos( fence_player_dir * ref_dir );
669 if ( angle >= MAX_ACTION_DETECTION_ANGLE_RAD )
680 vector ref_dir = GetDirection();
690 if ( ref_dir.Length() != 0 )
692 float angle =
Math.Acos( cam_dir * ref_dir );
694 if ( angle >= MAX_ACTION_DETECTION_ANGLE_RAD )
705 if ( MemoryPointExists( selection ) )
707 vector selection_pos = ModelToWorld( GetMemoryPointPos( selection ) );
708 float distance =
vector.Distance( selection_pos, player.GetPosition() );
709 if ( distance >= MAX_ACTION_DETECTION_DISTANCE )
729 if ( !
GetGame().IsDedicatedServer() )
731 PlaySoundSet( m_SoundGate_Start, SOUND_GATE_OPEN_START, 0.1, 0.1 );
738 if ( !
GetGame().IsDedicatedServer() )
740 PlaySoundSet( m_SoundGate_Start, SOUND_GATE_CLOSE_START, 0.1, 0.1 );
747 if ( !
GetGame().IsDedicatedServer() )
749 PlaySoundSet( m_SoundGate_End, SOUND_GATE_CLOSE_END, 0.1, 0.1 );
774 if (
Class.CastTo(wire,item))
776 wire.SetMountedState(
false );
779 else if (
Class.CastTo(lock,item))
781 lock.UnlockServer(null,
this);
796 if ( !wall_base_up.IsBuilt() )
798 if ( slot_name == ATTSLOT_CAMONET || slot_name == ATTSLOT_BARBEDWIRE_UP )
803 if ( !wall_base_down.IsBuilt() )
805 if ( slot_name == ATTSLOT_BARBEDWIRE_DOWN )
817 if ( selection_name ==
"wall_camonet_attach" )
858 #ifdef DIAG_DEVELOPER
866 excludes.Insert(
"_metal_");
870 excludes.Insert(
"_wood_");
873 #ifdef DIAG_DEVELOPER
881 excludes.Insert(
"platform");
885 excludes.Insert(
"gate");
894 super.OnDebugSpawn();
896 GetInventory().CreateInInventory(
"CamoNet");
898 for (
int i = 0; i < 2; ++i)
900 BarbedWire wire = BarbedWire.Cast(GetInventory().CreateInInventory(
"BarbedWire"));
901 wire.SetMountedState(
true);
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
ActionFoldBaseBuildingObjectCB ActionContinuousBaseCB ActionFoldBaseBuildingObject()
ActionPlaceObjectCB ActiondeployObjectCB ActionPlaceObject()
void AddAction(typename actionName)
Construction GetConstruction()
class BaseBuildingBase extends ItemBase bsbDebugPrint(string s)
void SynchronizeBaseState()
override bool CanDisplayAttachmentCategory(string category_name)
override void PostAreaDamageActions()
override void OnDebugSpawn()
override bool IsPlayerInside(PlayerBase player, string selection)
override void OnVariablesSynchronized()
override bool TranslateSlotFromSelection(string selection_name, out int slot_id)
void SetOpenedState(bool state)
override bool CanDisplayAttachmentSlot(int slot_id)
EffectSound m_SoundGate_Start
override string GetConstructionKitType()
void SetGateState(int state)
override bool NameOverride(out string output)
override bool CanPutIntoHands(EntityAI parent)
override array< string > OnDebugSpawnBuildExcludes()
Excludes certain parts from being built by OnDebugSpawn, uses Contains to compare.
void GateAttachmentsSanityCheck()
void SoundGateOpenStart()
override void OnPartBuiltServer(notnull Man player, string part_name, int action_id)
bool HasFullyConstructedGate()
bool GateAttachmentConditions(int slotId)
EffectSound m_SoundGate_End
override void SetActions()
void HandleDropAttachment(ItemBase item)
void SoundGateCloseStart()
override bool IsFacingCamera(string selection)
override bool IsFacingPlayer(PlayerBase player, string selection)
override void AfterStoreLoad()
override bool CanUseConstructionBuild()
override bool OnStoreLoad(ParamsReadContext ctx, int version)
override int GetMeleeTargetType()
override bool HasProperDistance(string selection, PlayerBase player)
BarbedWire GetBarbedWire1()
CombinationLock GetCombinationLock()
override void OnPartDestroyedServer(Man player, string part_name, int action_id, bool destroyed_by_connected_part=false)
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
override void OnStoreSave(ParamsWriteContext ctx)
void UpdateBarbedWireAreaDamagePos(float rotation_angle=0, bool to_delete=false)
override vector GetKitSpawnPosition()
override bool CanBeRepairedToPristine()
override void CreateAreaDamage(string slot_name, float rotation_angle=0)
override void OnPartDismantledServer(notnull Man player, string part_name, int action_id)
BarbedWire GetBarbedWire2()
Super root of all classes in Enforce script.
void SetActionInitiator(PlayerBase action_initiator)
Wrapper class for managing sound through SEffectManager.
provides access to slot configuration
Serialization general interface. Serializer API works with:
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
class JsonUndergroundAreaTriggerData GetPosition