diff --git a/QSB/SectorSync.cs b/QSB/SectorSync.cs index 12e1ce05..e3b89463 100644 --- a/QSB/SectorSync.cs +++ b/QSB/SectorSync.cs @@ -13,7 +13,7 @@ namespace QSB { DebugLog.Screen("Start SectorSync"); playerSectors = new Dictionary(); - QSB.Helper.HarmonyHelper.AddPrefix("OnAddSector", typeof(Patches), "PreAddSector"); + QSB.Helper.HarmonyHelper.AddPostfix("OnAddSector", typeof(Patches), "PostAddSector"); } public static void SetSector (uint id, Transform sectorTransform) { @@ -21,12 +21,6 @@ namespace QSB { } public static void SetSector (uint id, Sector.Name sectorName) { - if (sectorName == Sector.Name.Unnamed || sectorName == Sector.Name.Ship && sectorName == Sector.Name.Sun) { - return; - } - - DebugLog.Screen("Gonna set sector"); - playerSectors[id] = FindSectorTransform(sectorName); SectorMessage msg = new SectorMessage(); @@ -75,9 +69,17 @@ namespace QSB { } static class Patches { - static void PreAddSector (Sector sector, PlayerSectorDetector __instance) { - if (NetworkPlayer.localInstance != null) { - NetworkPlayer.localInstance.EnterSector(sector); + static void PostAddSector (PlayerSectorDetector __instance, List ____sectorList) { + if (NetworkPlayer.localInstance == null) { + return; + } + + foreach (var sector in ____sectorList) { + if (sector.GetName() != Sector.Name.Unnamed && sector.GetName() != Sector.Name.Ship && sector.GetName() != Sector.Name.Sun && sector.GetName() != Sector.Name.HourglassTwins) { + sector.GetOWRigidbody().GetReferenceFrame(); + NetworkPlayer.localInstance.EnterSector(sector); + return; + } } } }