diff --git a/Ringway/Data/Scripts/TeleportGateway/TeleportGateway.cs b/Ringway/Data/Scripts/TeleportGateway/TeleportGateway.cs index d83a174..a8e1c92 100644 --- a/Ringway/Data/Scripts/TeleportGateway/TeleportGateway.cs +++ b/Ringway/Data/Scripts/TeleportGateway/TeleportGateway.cs @@ -902,6 +902,10 @@ public static void ProcessJumpRequest(long gatewayId, string link) return; } + // Get the gateway's GridGroup + List gatewayGridGroup = new List(); + MyAPIGateway.GridGroups.GetGroup(sourceGateway.CubeGrid, GridLinkTypeEnum.Physical, gatewayGridGroup); + // Schedule the actual teleport MyAPIGateway.Utilities.InvokeOnGameThread(() => { @@ -924,27 +928,39 @@ public static void ProcessJumpRequest(long gatewayId, string link) } else if (grid != null && sourceGatewayLogic.Settings.AllowShips) { - if (!grid.IsStatic && grid.EntityId != sourceGateway.CubeGrid.EntityId) + // Check 1: Skip if grid is static + if (grid.IsStatic) { - List landingGears = new List(); - grid.GetBlocks(landingGears, b => b.FatBlock is SpaceEngineers.Game.ModAPI.Ingame.IMyLandingGear); - bool hasLockedGear = false; + MyLogger.Log($"TPGate: ProcessJumpRequest: Skipping static grid {grid.DisplayName}"); + continue; + } - foreach (var gear in landingGears) - { - var landingGear = gear.FatBlock as SpaceEngineers.Game.ModAPI.Ingame.IMyLandingGear; - if (landingGear != null && landingGear.IsLocked) - { - hasLockedGear = true; - break; - } - } + // Check 2: Skip if grid is part of the gateway's GridGroup + if (gatewayGridGroup.Contains(grid)) + { + MyLogger.Log($"TPGate: ProcessJumpRequest: Skipping grid {grid.DisplayName} as it's part of the gateway's GridGroup"); + continue; + } + + // Additional existing checks + List landingGears = new List(); + grid.GetBlocks(landingGears, b => b.FatBlock is SpaceEngineers.Game.ModAPI.Ingame.IMyLandingGear); + bool hasLockedGear = false; - if (!hasLockedGear) + foreach (var gear in landingGears) + { + var landingGear = gear.FatBlock as SpaceEngineers.Game.ModAPI.Ingame.IMyLandingGear; + if (landingGear != null && landingGear.IsLocked) { - shouldTeleport = true; + hasLockedGear = true; + break; } } + + if (!hasLockedGear) + { + shouldTeleport = true; + } } if (shouldTeleport)