Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
fence.c
Go to the documentation of this file.
1class Fence extends BaseBuildingBase
2{
3 const int GATE_STATE_NONE = 0;
4 const int GATE_STATE_PARTIAL = 1;
5 const int GATE_STATE_FULL = 2;
6
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";
11
12 //gate openining
13 const float GATE_ROTATION_ANGLE_DEG = 100;
14 const float GATE_ROTATION_TIME_APPROX = 2000; //ms
15
16 const float MAX_ACTION_DETECTION_ANGLE_RAD = 1.3; //1.3 RAD = ~75 DEG
17 const float MAX_ACTION_DETECTION_DISTANCE = 2.0; //meters
18
19 typename ATTACHMENT_WOODEN_LOG = WoodenLog;
20 typename ATTACHMENT_COMBINATION_LOCK = CombinationLock;
21
22 string ATTSLOT_CAMONET = "Wall_Camonet";
23 string ATTSLOT_BARBEDWIRE_DOWN = "Wall_Barbedwire_1";
24 string ATTSLOT_BARBEDWIRE_UP = "Wall_Barbedwire_2";
25
26 //protected bool m_HasHinges = false;
27 //protected bool m_GateFullyConstructed = false;
28 protected bool m_ToDiscard = false; //for legacy OnStoreLoad handling
29 protected bool m_IsOpened = false;
30 protected bool m_IsOpenedClient = false;
31 protected int m_GateState = 0;
32
35
36 void Fence()
37 {
38 //synchronized variables
39 //RegisterNetSyncVariableBool( "m_HasHinges" );
40 //RegisterNetSyncVariableBool( "m_GateFullyConstructed" );
41 RegisterNetSyncVariableBool( "m_IsOpened" );
42 RegisterNetSyncVariableInt( "m_GateState" );
43 }
44
45 override string GetConstructionKitType()
46 {
47 return "FenceKit";
48 }
49
50 override int GetMeleeTargetType()
51 {
52 return EMeleeTargetType.NONALIGNABLE;
53 }
54
55 //Gate
56 bool HasHinges()
57 {
58 return m_GateState > GATE_STATE_NONE;
59 }
60
62 {
63 return m_GateState == GATE_STATE_FULL;
64 }
65
66 void SetGateState( int state )
67 {
68 m_GateState = state;
69 SetSynchDirty();
70 }
71
73 {
74 return m_GateState;
75 }
76
78 {
79 ConstructionPart gate_part = GetConstruction().GetGateConstructionPart();
80 int state = GATE_STATE_NONE;
81 if( gate_part.IsBuilt() )
82 {
83 ConstructionPart req_part;
84 array<string> req_parts = gate_part.GetRequiredParts();
85 for (int i = 0; i < req_parts.Count(); i++)
86 {
87 req_part = GetConstruction().GetConstructionPart(req_parts.Get(i));
88 if(!req_part.IsBuilt())
89 break;
90 }
91
92 if( i != req_parts.Count() )
93 {
94 state = GATE_STATE_PARTIAL;
95 }
96 else
97 {
98 state = GATE_STATE_FULL;
99 }
100
101 }
102 return state;
103 }
104
105 void SetOpenedState( bool state )
106 {
107 m_IsOpened = state;
108 }
109
110 override bool IsOpened()
111 {
112 return m_IsOpened;
113 }
114
115 bool IsLocked()
116 {
117 CombinationLock combination_lock = GetCombinationLock();
118 if ( combination_lock && combination_lock.IsLocked() )
119 {
120 return true;
121 }
122
123 return false;
124 }
125
126 override bool NameOverride(out string output)
127 {
128 if ( m_GateState != GATE_STATE_NONE )
129 {
130 output = "#str_cfgvehicles_construction_part_gate"; //changes object displayed name if in 'gate' state
131 output.ToUpper();
132 return true;
133 }
134 return false;
135 }
136//
138 {
139 CombinationLock combination_lock = CombinationLock.Cast( FindAttachmentBySlotName( ATTACHMENT_SLOT_COMBINATION_LOCK ) );
140 return combination_lock;
141 }
142
143 CamoNet GetCamoNet()
144 {
145 CamoNet camonet = CamoNet.Cast( FindAttachmentBySlotName( "Wall_Camonet" ) );
146 return camonet;
147 }
148
149 BarbedWire GetBarbedWire1()
150 {
151 BarbedWire barbedwire = BarbedWire.Cast( FindAttachmentBySlotName( "Wall_Barbedwire_1" ) );
152 return barbedwire;
153 }
154
155 BarbedWire GetBarbedWire2()
156 {
157 BarbedWire barbedwire = BarbedWire.Cast( FindAttachmentBySlotName( "Wall_Barbedwire_2" ) );
158 return barbedwire;
159 }
160
161 //--- CONSTRUCTION KIT
163 {
164 if ( MemoryPointExists( "kit_spawn_position" ) )
165 {
166 vector position;
167 position = GetMemoryPointPos( "kit_spawn_position" );
168
169 return ModelToWorld( position );
170 }
171
172 return GetPosition();
173 }
174
175 // --- INVENTORY
176 override bool CanDisplayAttachmentSlot( int slot_id )
177 {
178 if (!super.CanDisplayAttachmentSlot(slot_id))
179 return false;
180
181 string slot_name = InventorySlots.GetSlotName(slot_id);
182
183 if ( slot_name == "Att_CombinationLock" )
184 {
186 {
187 return false;
188 }
189 }
190
191 if ( !GateAttachmentConditions(InventorySlots.GetSlotIdFromString(slot_name)) )
192 return false;
193
194 return true;
195 }
196
197 override bool CanDisplayAttachmentCategory( string category_name )
198 {
199 if ( category_name == "Attachments" || category_name == "Material" )
200 {
201 if ( !HasBase() )
202 {
203 return false;
204 }
205 }
206
207 return true;
208 }
209 // ---
210
211 // --- EVENTS
212 override void OnStoreSave( ParamsWriteContext ctx )
213 {
214 super.OnStoreSave( ctx );
215
216 //write
217 ctx.Write( m_GateState );
218 ctx.Write( m_IsOpened );
219 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] OnStoreSave - build=" + m_GateState + " opened=" + m_IsOpened);
220 }
221
222 override bool OnStoreLoad( ParamsReadContext ctx, int version )
223 {
224 if ( !super.OnStoreLoad( ctx, version ) )
225 return false;
226
227 //--- Fence data ---
228 //has gate
229 if (version < 110)
230 {
231 if ( !ctx.Read( m_ToDiscard ) )
232 {
233 m_ToDiscard = false;
234 return false;
235 }
236 m_GateState = GATE_STATE_NONE;
237 }
238 else if ( !ctx.Read( m_GateState ) )
239 {
240 m_GateState = GATE_STATE_NONE;
241 return false;
242 }
243
244 //is opened
245 if ( !ctx.Read( m_IsOpened ) )
246 {
247 m_IsOpened = false;
248 return false;
249 }
250
251 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] OnStoreLoad - build=" + m_GateState + " opened=" + m_IsOpened);
252 //---
253
254 return true;
255 }
256
257 override void AfterStoreLoad()
258 {
259 super.AfterStoreLoad();
260
261 //set gate state
262 ConstructionPart gate_part = GetConstruction().GetGateConstructionPart();
264
265 //update gate state visual
266 if ( IsOpened() )
267 {
268 OpenFence();
269 }
270
272
273 if (LogManager.IsBaseBuildingLogEnable()) bsbDebugPrint("[bsb] AfterStoreLoad - build=" + gate_part.IsBuilt() + " opened=" + IsOpened());
274 }
275
277 {
278 super.OnVariablesSynchronized();
279
280 if ( m_IsOpenedClient != m_IsOpened )
281 {
282 m_IsOpenedClient = m_IsOpened;
283
284 if ( m_IsOpenedClient )
285 {
286 OpenFence();
287 }
288 else
289 {
290 CloseFence();
291 }
292 }
293 }
294
295 //--- BUILD EVENTS
296 //CONSTRUCTION EVENTS
297 override void OnPartBuiltServer( notnull Man player, string part_name, int action_id )
298 {
299 ConstructionPart constrution_part = GetConstruction().GetConstructionPart( part_name );
300
301 super.OnPartBuiltServer( player, part_name, action_id );
302
304
305 //update visuals (server)
307 }
308
309 override void OnPartDismantledServer( notnull Man player, string part_name, int action_id )
310 {
311 ConstructionPart constrution_part = GetConstruction().GetConstructionPart( part_name );
312
313 //check gate state
314 if ( constrution_part.IsGate() )
315 {
316 if ( IsLocked() )
317 {
318 CombinationLock combination_lock = CombinationLock.Cast( FindAttachmentBySlotName( ATTACHMENT_SLOT_COMBINATION_LOCK ) );
319 combination_lock.UnlockServer( player , this );
320 }
321 }
322
323 super.OnPartDismantledServer( player, part_name, action_id );
324
326
327 //update visuals (server)
329 }
330
331 override void OnPartDestroyedServer( Man player, string part_name, int action_id, bool destroyed_by_connected_part = false )
332 {
333 super.OnPartDestroyedServer( player, part_name, action_id );
334
335 //check gate state
336 ConstructionPart constrution_part = GetConstruction().GetConstructionPart( part_name );
337 if ( constrution_part.IsGate() && destroyed_by_connected_part ) //avoids attachment dropping on regular hinges destruction
338 {
339 //drop regular attachments
344
345 //rotate back to place
346 if ( IsOpened() )
347 CloseFence();
348 }
349 if ( part_name == "wall_base_down" )
350 {
353 }
354 if ( part_name == "wall_base_up" )
355 {
359 }
360
362 //update visuals (server)
364 }
365
366 //--- ATTACHMENT & CONDITIONS
367 override bool CanReceiveAttachment( EntityAI attachment, int slotId )
368 {
369 if ( !super.CanReceiveAttachment(attachment, slotId) )
370 return false;
371
372 //manage action initiator (AT_ATTACH_TO_CONSTRUCTION)
373 if ( !GetGame().IsDedicatedServer() )
374 {
375 PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
376 if ( player )
377 {
378 ConstructionActionData construction_action_data = player.GetConstructionActionData();
379
380 //reset action initiator
381 construction_action_data.SetActionInitiator( NULL );
382 }
383 }
384
385 //conditions
386 if ( attachment.Type() != ATTACHMENT_WOODEN_LOG )
387 {
388 if ( !HasBase() )
389 {
390 return false;
391 }
392 }
393
394 if ( attachment.IsInherited( ATTACHMENT_COMBINATION_LOCK ) )
395 {
396 return ( HasFullyConstructedGate() && !IsOpened() );
397 }
398
399 if ( !GateAttachmentConditions(slotId) )
400 return false;
401
402 return true;
403 }
404
405 //hands
406 override bool CanPutIntoHands( EntityAI parent )
407 {
408 if( !super.CanPutIntoHands( parent ) )
409 {
410 return false;
411 }
412
413 if ( HasBase() )
414 {
415 return false;
416 }
417
418 return true;
419 }
420
422 {
423 return true;
424 }
425
426 //--- OPEN/CLOSE ACTIONS
428 {
429 if ( HasHinges() && !IsOpened() && !IsLocked() )
430 {
431 return true;
432 }
433
434 return false;
435 }
436
438 {
439 if ( HasHinges() && IsOpened() )
440 {
441 return true;
442 }
443
444 return false;
445 }
446
448 {
449 //server or single player
450 if ( GetGame().IsServer() )
451 {
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 );
464
465 SetOpenedState( true );
466
467 //regenerate navmesh
468 GetGame().GetCallQueue( CALL_CATEGORY_GAMEPLAY ).CallLater( UpdateNavmesh, GATE_ROTATION_TIME_APPROX, false );
469
470 //synchronize
472 }
473
474 //client or single player
475 if ( !GetGame().IsDedicatedServer() )
476 {
477 //play sound
479 }
480
481 //remove BarbedWire AreaDamageTrigger
483
484 //add check
485 GetGame().GetCallQueue( CALL_CATEGORY_GAMEPLAY ).Remove(CheckFenceClosed);
486 GetGame().GetCallQueue( CALL_CATEGORY_GAMEPLAY ).CallLater( CheckFenceOpened, 0, true );
487 }
488
490 {
491 //server or single player
492 if ( GetGame().IsServer() )
493 {
494 float value = 0;
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 );
506
507 SetOpenedState( false );
508
509 //regenerate navmesh
510 GetGame().GetCallQueue( CALL_CATEGORY_GAMEPLAY ).CallLater( UpdateNavmesh, GATE_ROTATION_TIME_APPROX, false );
511
512 //synchronize
514 }
515
516 //client or single player
517 if ( !GetGame().IsDedicatedServer() )
518 {
519 //play sound
521 }
522
523 //remove BarbedWire AreaDamageTrigger
525
526 //add check
527 GetGame().GetCallQueue( CALL_CATEGORY_GAMEPLAY ).Remove(CheckFenceOpened);
528 GetGame().GetCallQueue( CALL_CATEGORY_GAMEPLAY ).CallLater( CheckFenceClosed, 0, true );
529 }
530
531 protected void CheckFenceOpened()
532 {
533 if ( GetAnimationPhase( "Wall_Gate_Rotate" ) == GATE_ROTATION_ANGLE_DEG ) //animation finished - open
534 {
535 UpdateBarbedWireAreaDamagePos(GetAnimationPhase( "Wall_Gate_Rotate" ));
536 //remove check
537 GetGame().GetCallQueue( CALL_CATEGORY_GAMEPLAY ).Remove( CheckFenceOpened );
538 }
539 }
540
541 protected void CheckFenceClosed()
542 {
543 if ( GetAnimationPhase( "Wall_Gate_Rotate" ) == 0 ) //animation finished - closed
544 {
545 //client or single player
546 if ( !GetGame().IsDedicatedServer() )
547 {
548 //play sound
549 if ( this ) SoundGateCloseEnd();
550 }
551 UpdateBarbedWireAreaDamagePos(GetAnimationPhase( "Wall_Gate_Rotate" ));
552 //remove check
553 GetGame().GetCallQueue( CALL_CATEGORY_GAMEPLAY ).Remove( CheckFenceClosed );
554 }
555 }
556
557 //Damage triggers
558 override void CreateAreaDamage( string slot_name, float rotation_angle = 0 )
559 {
560 if ( IsOpened() )
561 {
562 rotation_angle = 100;
563 }
564
565 super.CreateAreaDamage( slot_name, rotation_angle );
566 }
567
568 //BarbedWire update
569 void UpdateBarbedWireAreaDamagePos(float rotation_angle = 0, bool to_delete = false )
570 {
571 int slot_id;
572 string slot_name;
573 string slot_name_mounted;
574 if ( GetBarbedWire1() && GetBarbedWire1().IsMounted() )
575 {
576 GetBarbedWire1().GetInventory().GetCurrentAttachmentSlotInfo(slot_id,slot_name);
577 slot_name_mounted = slot_name + "_Mounted";
578 if (to_delete)
579 {
580 DestroyAreaDamage( slot_name_mounted );
581 }
582 else
583 {
584 super.CreateAreaDamage( slot_name_mounted, rotation_angle );
585 }
586 }
587 if ( GetBarbedWire2() && GetBarbedWire2().IsMounted() )
588 {
589 GetBarbedWire2().GetInventory().GetCurrentAttachmentSlotInfo(slot_id,slot_name);
590 slot_name_mounted = slot_name + "_Mounted";
591 if (to_delete)
592 {
593 DestroyAreaDamage( slot_name_mounted );
594 }
595 else
596 {
597 super.CreateAreaDamage( slot_name_mounted, rotation_angle );
598 }
599 }
600 }
601
602 //Here deal damage to BarbedWire when entity taking damage from it
603 override void PostAreaDamageActions()
604 {
605 /*if (GetBarbedWire1())
606 {
607 //DecreaseHealth("Wall_BarbedWire_1", "", 1000); //why no dmg to wire???
608 //BarbedWire wire = GetBarbedWire1();
609 //wire.PostAreaDamageActions();
610 //Print(GetHealth("BarbedWire1", ""));
611 }*/
612 }
613
614 //--- ACTION CONDITIONS
615 override bool IsPlayerInside( PlayerBase player, string selection )
616 {
617 vector player_pos = player.GetPosition();
618 vector fence_pos = GetPosition();
619 vector ref_dir = GetDirection();
620 ref_dir[1] = 0;
621 ref_dir.Normalize();
622
623 vector x[2];
624 vector b1,b2;
625 GetCollisionBox(x);
626 b1 = x[0];
627 b2 = x[1];
628
629 vector dir_to_fence = fence_pos - player_pos;
630 dir_to_fence[1] = 0;
631 float len = dir_to_fence.Length();
632
633 dir_to_fence.Normalize();
634
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;
638
639 vector test_position = test_angles.AnglesToVector() * len;
640
641 if(test_position[0] < b1[0] || test_position[0] > b2[0] || test_position[2] < 0.2 || test_position[2] > 2.2 )
642 {
643 return false;
644 }
645 else
646 {
647 return true;
648 }
649 }
650
651 override bool IsFacingPlayer( PlayerBase player, string selection )
652 {
653 vector fence_pos = GetPosition();
654 vector player_pos = player.GetPosition();
655 vector ref_dir = GetDirection();
656
657 //vector fence_player_dir = player_pos - fence_pos;
658 vector fence_player_dir = player.GetDirection();
659 fence_player_dir.Normalize();
660 fence_player_dir[1] = 0; //ignore height
661
662 ref_dir.Normalize();
663 ref_dir[1] = 0; //ignore height
664
665 if ( ref_dir.Length() != 0 )
666 {
667 float angle = Math.Acos( fence_player_dir * ref_dir );
668
669 if ( angle >= MAX_ACTION_DETECTION_ANGLE_RAD )
670 {
671 return true;
672 }
673 }
674
675 return false;
676 }
677
678 override bool IsFacingCamera( string selection )
679 {
680 vector ref_dir = GetDirection();
681 vector cam_dir = GetGame().GetCurrentCameraDirection();
682
683 //ref_dir = GetGame().GetCurrentCameraPosition() - GetPosition();
684 ref_dir.Normalize();
685 ref_dir[1] = 0; //ignore height
686
687 cam_dir.Normalize();
688 cam_dir[1] = 0; //ignore height
689
690 if ( ref_dir.Length() != 0 )
691 {
692 float angle = Math.Acos( cam_dir * ref_dir );
693
694 if ( angle >= MAX_ACTION_DETECTION_ANGLE_RAD )
695 {
696 return true;
697 }
698 }
699
700 return false;
701 }
702
703 override bool HasProperDistance( string selection, PlayerBase player )
704 {
705 if ( MemoryPointExists( selection ) )
706 {
707 vector selection_pos = ModelToWorld( GetMemoryPointPos( selection ) );
708 float distance = vector.Distance( selection_pos, player.GetPosition() );
709 if ( distance >= MAX_ACTION_DETECTION_DISTANCE )
710 {
711 return false;
712 }
713 }
714
715 return true;
716 }
717
719 {
720 return !IsOpened();
721 }
722
723 //================================================================
724 // SOUNDS
725 //================================================================
726 protected void SoundGateOpenStart()
727 {
728 //client or single player
729 if ( !GetGame().IsDedicatedServer() )
730 {
731 PlaySoundSet( m_SoundGate_Start, SOUND_GATE_OPEN_START, 0.1, 0.1 );
732 }
733 }
734
735 protected void SoundGateCloseStart()
736 {
737 //client or single player
738 if ( !GetGame().IsDedicatedServer() )
739 {
740 PlaySoundSet( m_SoundGate_Start, SOUND_GATE_CLOSE_START, 0.1, 0.1 );
741 }
742 }
743
744 protected void SoundGateCloseEnd()
745 {
746 //client or single player
747 if ( !GetGame().IsDedicatedServer() )
748 {
749 PlaySoundSet( m_SoundGate_End, SOUND_GATE_CLOSE_END, 0.1, 0.1 );
750 }
751 }
752
754 {
755 ConstructionPart wall_base_down = GetConstruction().GetConstructionPart("wall_base_down");
756 ConstructionPart wall_base_up = GetConstruction().GetConstructionPart("wall_base_up");
757 if(GetBarbedWire1() && !wall_base_down.IsBuilt())
758 {
761 }
762 if( ( GetCamoNet() || GetBarbedWire2() ) && !wall_base_up.IsBuilt() )
763 {
767 }
768 }
769
771 {
772 BarbedWire wire;
773 CombinationLock lock;
774 if (Class.CastTo(wire,item)) //special barbed wire beh.
775 {
776 wire.SetMountedState( false );
777 GetInventory().DropEntity(InventoryMode.SERVER, this, wire);
778 }
779 else if (Class.CastTo(lock,item))
780 {
781 lock.UnlockServer(null,this);
782 }
783 else if (item)//generic behaviour
784 {
785 GetInventory().DropEntity(InventoryMode.SERVER, this, item);
786 }
787 }
788
790 {
791 if ( GetGateState() == GATE_STATE_PARTIAL )
792 {
793 ConstructionPart wall_base_down = GetConstruction().GetConstructionPart("wall_base_down");
794 ConstructionPart wall_base_up = GetConstruction().GetConstructionPart("wall_base_up");
795 string slot_name = InventorySlots.GetSlotName(slotId);
796 if ( !wall_base_up.IsBuilt() )
797 {
798 if ( slot_name == ATTSLOT_CAMONET || slot_name == ATTSLOT_BARBEDWIRE_UP )
799 {
800 return false;
801 }
802 }
803 if ( !wall_base_down.IsBuilt() )
804 {
805 if ( slot_name == ATTSLOT_BARBEDWIRE_DOWN )
806 {
807 return false;
808 }
809 }
810 }
811 return true;
812 }
813
814 //specific selection for camonet attaching (other ones might be animated via rotation!)
815 override bool TranslateSlotFromSelection(string selection_name, out int slot_id)
816 {
817 if ( selection_name == "wall_camonet_attach" )
818 {
819 slot_id = InventorySlots.GetSlotIdFromString("Wall_Camonet");
820 return true;
821 }
822 return false;
823 }
824
825 override void SetActions()
826 {
827 super.SetActions();
828
832 //AddAction(ActionDialCombinationLockOnTarget);
833 //AddAction(ActionNextCombinationLockDialOnTarget);
836 }
837
838 //================================================================
839 // DEBUG
840 //================================================================
841 /*
842 override void DebugCustomState()
843 {
844 //debug
845 m_SyncParts01 = 881; //full fence with gate
846 m_HasHinges = true;
847 m_HasBase = true;
848
849 OnVariablesSynchronized();
850 }
851 */
852
855 {
856 array<string> excludes = {};
857
858 #ifdef DIAG_DEVELOPER
859 bool bWood = DiagMenu.GetBool(DiagMenuIDs.BASEBUILDING_WOOD);
860 #else
861 bool bWood = false;
862 #endif
863
864 if (bWood)
865 {
866 excludes.Insert("_metal_");
867 }
868 else
869 {
870 excludes.Insert("_wood_");
871 }
872
873 #ifdef DIAG_DEVELOPER
874 bool bGate = DiagMenu.GetBool(DiagMenuIDs.BASEBUILDING_GATE);
875 #else
876 bool bGate = false;
877 #endif
878
879 if (bGate)
880 {
881 excludes.Insert("platform");
882 }
883 else
884 {
885 excludes.Insert("gate");
886 }
887
888 return excludes;
889 }
890
891 //Debug menu Spawn Ground Special
892 override void OnDebugSpawn()
893 {
894 super.OnDebugSpawn();
895
896 GetInventory().CreateInInventory("CamoNet");
897
898 for (int i = 0; i < 2; ++i)
899 {
900 BarbedWire wire = BarbedWire.Cast(GetInventory().CreateInInventory("BarbedWire"));
901 wire.SetMountedState(true);
902 }
903 }
904}
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
Definition inventory.c:22
ActionFoldBaseBuildingObjectCB ActionContinuousBaseCB ActionFoldBaseBuildingObject()
ActionPlaceObjectCB ActiondeployObjectCB ActionPlaceObject()
void AddAction(typename actionName)
void UpdateNavmesh()
Construction GetConstruction()
class BaseBuildingBase extends ItemBase bsbDebugPrint(string s)
bool IsOpened()
bool HasBase()
void SynchronizeBaseState()
override bool CanDisplayAttachmentCategory(string category_name)
Definition fence.c:197
bool HasHinges()
Definition fence.c:56
override void PostAreaDamageActions()
Definition fence.c:603
override void OnDebugSpawn()
Definition fence.c:892
override bool IsPlayerInside(PlayerBase player, string selection)
Definition fence.c:615
override void OnVariablesSynchronized()
Definition fence.c:276
override bool TranslateSlotFromSelection(string selection_name, out int slot_id)
Definition fence.c:815
void SetOpenedState(bool state)
Definition fence.c:105
void Fence()
Definition fence.c:36
override bool CanDisplayAttachmentSlot(int slot_id)
Definition fence.c:176
EffectSound m_SoundGate_Start
Definition fence.c:33
override string GetConstructionKitType()
Definition fence.c:45
void CloseFence()
Definition fence.c:489
void SetGateState(int state)
Definition fence.c:66
override bool IsOpened()
Definition fence.c:110
override bool NameOverride(out string output)
Definition fence.c:126
bool IsLocked()
Definition fence.c:115
override bool CanPutIntoHands(EntityAI parent)
Definition fence.c:406
override array< string > OnDebugSpawnBuildExcludes()
Excludes certain parts from being built by OnDebugSpawn, uses Contains to compare.
Definition fence.c:854
void GateAttachmentsSanityCheck()
Definition fence.c:753
void SoundGateOpenStart()
Definition fence.c:726
override void OnPartBuiltServer(notnull Man player, string part_name, int action_id)
Definition fence.c:297
bool HasFullyConstructedGate()
Definition fence.c:61
bool GateAttachmentConditions(int slotId)
Definition fence.c:789
EffectSound m_SoundGate_End
Definition fence.c:34
override void SetActions()
Definition fence.c:825
void HandleDropAttachment(ItemBase item)
Definition fence.c:770
bool m_IsOpened
Definition fence.c:29
void CheckFenceClosed()
Definition fence.c:541
void SoundGateCloseStart()
Definition fence.c:735
CamoNet GetCamoNet()
Definition fence.c:143
override bool IsFacingCamera(string selection)
Definition fence.c:678
override bool IsFacingPlayer(PlayerBase player, string selection)
Definition fence.c:651
override void AfterStoreLoad()
Definition fence.c:257
override bool CanUseConstructionBuild()
Definition fence.c:718
override bool OnStoreLoad(ParamsReadContext ctx, int version)
Definition fence.c:222
void CheckFenceOpened()
Definition fence.c:531
override int GetMeleeTargetType()
Definition fence.c:50
bool CanCloseFence()
Definition fence.c:437
override bool HasProperDistance(string selection, PlayerBase player)
Definition fence.c:703
BarbedWire GetBarbedWire1()
Definition fence.c:149
int GetGateState()
Definition fence.c:72
bool CanOpenFence()
Definition fence.c:427
void OpenFence()
Definition fence.c:447
CombinationLock GetCombinationLock()
Definition fence.c:137
override void OnPartDestroyedServer(Man player, string part_name, int action_id, bool destroyed_by_connected_part=false)
Definition fence.c:331
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
Definition fence.c:367
override void OnStoreSave(ParamsWriteContext ctx)
Definition fence.c:212
void UpdateBarbedWireAreaDamagePos(float rotation_angle=0, bool to_delete=false)
Definition fence.c:569
override vector GetKitSpawnPosition()
Definition fence.c:162
void SoundGateCloseEnd()
Definition fence.c:744
override bool CanBeRepairedToPristine()
Definition fence.c:421
int m_GateState
Definition fence.c:31
int CheckGateState()
Definition fence.c:77
override void CreateAreaDamage(string slot_name, float rotation_angle=0)
Definition fence.c:558
override void OnPartDismantledServer(notnull Man player, string part_name, int action_id)
Definition fence.c:309
BarbedWire GetBarbedWire2()
Definition fence.c:155
Super root of all classes in Enforce script.
Definition enscript.c:11
void SetActionInitiator(PlayerBase action_initiator)
Wrapper class for managing sound through SEffectManager.
Definition effectsound.c:5
provides access to slot configuration
Definition enmath.c:7
Serialization general interface. Serializer API works with:
Definition serializer.c:56
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
void CombinationLock()
void UpdateVisuals()
DiagMenuIDs
Definition ediagmenuids.c:2
EMeleeTargetType
void DestroyAreaDamage()
proto native CGame GetGame()
class JsonUndergroundAreaTriggerData GetPosition
const int CALL_CATEGORY_GAMEPLAY
Definition tools.c:10
Icon x
bool m_IsOpened
PlayerBase GetPlayer()