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" );
85 for (
int i = 0; i < req_parts.Count(); i++)
92 if( i != req_parts.Count() )
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 ) )
238 else if ( !ctx.
Read( m_GateState ) )
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 ) )
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();
637 vector test_angles = dir_to_fence_angle - ref_dir_angle;
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();
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 );
776 wire.SetMountedState(
false );
781 lock.UnlockServer(null,
this);
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);
ActionFoldBaseBuildingObjectCB ActionContinuousBaseCB ActionFoldBaseBuildingObject()
void AddAction(typename actionName)
Construction GetConstruction()
class BaseBuildingBase extends ItemBase bsbDebugPrint(string s)
void SynchronizeBaseState()
protected void UpdateNavmesh()
class JsonUndergroundAreaTriggerData GetPosition
override void OnDebugSpawn()
override bool CanDisplayAttachmentCategory(string category_name)
override array< string > OnDebugSpawnBuildExcludes()
Excludes certain parts from being built by OnDebugSpawn, uses Contains to compare.
protected void SoundGateCloseStart()
protected void SoundGateCloseEnd()
override bool IsFacingPlayer(PlayerBase player, string selection)
void GateAttachmentsSanityCheck()
override void OnStoreSave(ParamsWriteContext ctx)
protected bool m_IsOpened
override bool IsFacingCamera(string selection)
override bool CanBeRepairedToPristine()
override bool HasProperDistance(string selection, PlayerBase player)
CombinationLock GetCombinationLock()
override void PostAreaDamageActions()
bool HasFullyConstructedGate()
override void UpdateVisuals()
protected void CheckFenceClosed()
override void OnPartDismantledServer(notnull Man player, string part_name, int action_id)
protected void CheckFenceOpened()
BarbedWire GetBarbedWire2()
override bool IsPlayerInside(PlayerBase player, string selection)
override int GetMeleeTargetType()
void HandleDropAttachment(ItemBase item)
override void OnPartBuiltServer(notnull Man player, string part_name, int action_id)
const int GATE_STATE_NONE
override bool CanDisplayAttachmentSlot(int slot_id)
override void OnPartDestroyedServer(Man player, string part_name, int action_id, bool destroyed_by_connected_part=false)
override void CreateAreaDamage(string slot_name, float rotation_angle=0)
override void AfterStoreLoad()
void UpdateBarbedWireAreaDamagePos(float rotation_angle=0, bool to_delete=false)
override bool CanPutIntoHands(EntityAI parent)
const float GATE_ROTATION_ANGLE_DEG
override bool NameOverride(out string output)
bool GateAttachmentConditions(int slotId)
override bool CanUseConstructionBuild()
protected EffectSound m_SoundGate_Start
override bool OnStoreLoad(ParamsReadContext ctx, int version)
override bool TranslateSlotFromSelection(string selection_name, out int slot_id)
const int GATE_STATE_FULL
override string GetConstructionKitType()
BarbedWire GetBarbedWire1()
override void OnVariablesSynchronized()
const int GATE_STATE_PARTIAL
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
protected EffectSound m_SoundGate_End
override vector GetKitSpawnPosition()
void SetGateState(int state)
protected void SoundGateOpenStart()
protected int m_GateState
override void SetActions()
void SetOpenedState(bool state)
proto native vector GetCurrentCameraDirection()
override ScriptCallQueue GetCallQueue(int call_category)
Super root of all classes in Enforce script.
void SetActionInitiator(PlayerBase action_initiator)
array< string > GetRequiredParts()
Wrapper class for managing sound through SEffectManager.
provides access to slot configuration
static proto native int GetSlotIdFromString(string slot_name)
converts string to slot_id
static proto native owned string GetSlotName(int id)
converts slot_id to string
proto void CallLater(func fn, int delay=0, bool repeat=false, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
adds call into the queue with given parameters and arguments (arguments are held in memory until the ...
proto void Remove(func fn)
remove specific call from queue
Serialization general interface. Serializer API works with:
proto bool Write(void value_out)
proto bool Read(void value_in)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
proto float Normalize()
Normalizes vector. Returns length.
proto vector AnglesToVector()
Converts spherical coordinates (yaw, pitch, roll in degrees) to unit length vector.
proto vector VectorToAngles()
Converts vector to spherical coordinates with radius = 1.
proto native float Length()
Returns length of vector (magnitude)
proto native CGame GetGame()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
static proto float Acos(float c)
Returns angle in radians from cosinus.