diff --git a/LevelImposter/Builders/Util/DummyBuilder.cs b/LevelImposter/Builders/Util/DummyBuilder.cs index dafa138b..15b85821 100644 --- a/LevelImposter/Builders/Util/DummyBuilder.cs +++ b/LevelImposter/Builders/Util/DummyBuilder.cs @@ -15,7 +15,5 @@ public void OnBuild(LIElement elem, GameObject obj) // Add Location shipStatus.DummyLocations = MapUtils.AddToArr(shipStatus.DummyLocations, obj.transform); - - // TODO: Customize each dummy location with name/outfit } } \ No newline at end of file diff --git a/LevelImposter/Core/Patches/Ship/DummiesCosmeticsPatch.cs b/LevelImposter/Core/Patches/Ship/DummiesCosmeticsPatch.cs new file mode 100644 index 00000000..5bb9208e --- /dev/null +++ b/LevelImposter/Core/Patches/Ship/DummiesCosmeticsPatch.cs @@ -0,0 +1,30 @@ +using HarmonyLib; +using LevelImposter.Shop; +using System.Linq; + +namespace LevelImposter.Core; + +/// +/// Renames all dummies to the names of +/// their corresponding objects in the editor +/// +[HarmonyPatch(typeof(DummyBehaviour), nameof(DummyBehaviour.Start))] +public static class DummiesCosmeticsPatch +{ + public static void Postfix(DummyBehaviour __instance) + { + // Only execute in custom freeplay maps + if (!LIShipStatus.IsInstance()) + return; + if (!GameState.IsInFreeplay) + return; + + // Get all dummy elements on the map + LIElement[] dummyElements = MapLoader.CurrentMap.elements.Where(element => element.type == "util-dummy").ToArray(); + // Determine which one this dummy belongs to + // (subtract 1 to account for the player PlayerControl) + LIElement thisElement = dummyElements[PlayerControl.AllPlayerControls.IndexOf(__instance.myPlayer) - 1]; + + __instance.myPlayer.SetName(thisElement.name); + } +} \ No newline at end of file