diff --git a/LevelImposter/Core/Patches/Ship/DummyPatch.cs b/LevelImposter/Core/Patches/Ship/DummyPatch.cs index ca03272..cf2d602 100644 --- a/LevelImposter/Core/Patches/Ship/DummyPatch.cs +++ b/LevelImposter/Core/Patches/Ship/DummyPatch.cs @@ -1,5 +1,8 @@ using HarmonyLib; using LevelImposter.Shop; +using LevelImposter.Core.Models; +using LevelImposter.Core.Components; +using LevelImposter.Core.Utils; using System.Linq; namespace LevelImposter.Core; @@ -18,24 +21,26 @@ public static void Postfix(DummyBehaviour __instance) return; if (!GameState.IsInFreeplay) return; - if(MapLoader.CurrentMap == null) + if (GameConfiguration.CurrentMap == null) return; // Since the game is in freeplay, removing the local player just leaves all the dummy PlayerControls - var dummyPlayers = PlayerControl.AllPlayerControls.ToArray().Where(p => p != PlayerControl.LocalPlayer).ToArray(); + var dummyPlayers = PlayerControl.AllPlayerControls.ToArray() + .Where(p => p != PlayerControl.LocalPlayer) + .ToArray(); - // Finds a dummy element that has a corresponding location index (see DummyBuilder) - // which matches this DummyBehaviour's PlayerControl - foreach (var elem in MapLoader.CurrentMap.elements) + // Match custom dummy elements to freeplay dummy players by build/order index. + var dummyElements = GameConfiguration.CurrentMap.elements + .Where(e => e.type == "util-dummy") + .ToArray(); + + for (var index = 0; index < dummyElements.Length && index < dummyPlayers.Length; index++) { - if(elem.type != "util-dummy") - continue; - if (!LIShipStatus.GetInstance().DummyIndex.TryGetValue(elem.id, out int index)) - continue; if (__instance.myPlayer != dummyPlayers[index]) continue; - CustomizeDummy(__instance, elem); + CustomizeDummy(__instance, dummyElements[index]); + break; } } @@ -46,4 +51,4 @@ private static void CustomizeDummy(DummyBehaviour dummy, LIElement element) { dummy.myPlayer.SetName(element.name); } -} \ No newline at end of file +} diff --git a/LevelImposter/LevelImposter.csproj b/LevelImposter/LevelImposter.csproj index d1a3b42..b912a40 100644 --- a/LevelImposter/LevelImposter.csproj +++ b/LevelImposter/LevelImposter.csproj @@ -24,7 +24,7 @@ C:\Program Files (x86)\Steam\steamapps\common\Among Us - 2026.8.18 + 2026.9.29 @@ -51,4 +51,4 @@ - \ No newline at end of file +