22using EFT . Interactive ;
33using HarmonyLib ;
44using System ;
5+ using System . Linq ;
56using System . Reflection ;
67using UnityEngine ;
78
@@ -17,6 +18,8 @@ protected override MethodBase GetTargetMethod()
1718 [ PatchPrefix ]
1819 public static void PatchPrefix ( BotCellController __instance )
1920 {
21+ int i = 0 ;
22+
2023 // Prior to finding door links, add our own doorlinks for locked/breachable doors
2124 Door [ ] doors = UnityEngine . Object . FindObjectsOfType < Door > ( ) ;
2225 foreach ( Door door in doors )
@@ -34,7 +37,7 @@ public static void PatchPrefix(BotCellController __instance)
3437 Vector3 shutPos = door . transform . position + ( door . GetDoorRotation ( door . GetAngle ( EDoorState . Shut ) ) * WorldInteractiveObject . GetRotationAxis ( door . DoorForward , door . transform ) ) ;
3538
3639 // Create the DoorLink object and setup its properties, create the carvers
37- GameObject gameObject = new GameObject ( "DoorLink_Custom ") ;
40+ GameObject gameObject = new GameObject ( $ "DoorLink_Custom_ { i } ") ;
3841 NavMeshDoorLink navMeshDoorLink = gameObject . AddComponent < NavMeshDoorLink > ( ) ;
3942 navMeshDoorLink . Close1 = hingePos ;
4043 navMeshDoorLink . Open1 = hingePos ;
@@ -53,6 +56,7 @@ public static void PatchPrefix(BotCellController __instance)
5356
5457 // Add to the AiCellData. NOTE: Will need to redo this for 3.8.0, yay
5558 AddToCells ( __instance , door , navMeshDoorLink ) ;
59+ i ++ ;
5660 }
5761 }
5862
@@ -69,11 +73,11 @@ private static void AddToCells(BotCellController controller, Door door, NavMeshD
6973 {
7074 // Make sure our bounds are valid
7175 if ( i < 0 || j < 0 ) continue ;
72- if ( i > controller . Data . MaxIx || j > controller . Data . MaxIz ) continue ;
7376
7477 // Get the cell and validate it has a links list
7578 AICell cell = controller . Data . GetCell ( i , j ) ;
7679 if ( cell . Links == null ) cell . Links = new NavMeshDoorLink [ 0 ] ;
80+ if ( cell . Links . Contains ( navMeshDoorLink ) ) continue ;
7781
7882 // Resizing an array is probably slow, but we're only doing this on match start, so should be fine
7983 Array . Resize ( ref cell . Links , cell . Links . Length + 1 ) ;
0 commit comments