From 8f2585da472f0200093743b7ce1437f5f5b939d6 Mon Sep 17 00:00:00 2001 From: PalmForest Date: Mon, 9 Jun 2025 13:18:39 +1000 Subject: [PATCH 1/2] Custom dummy naming --- .../Patches/Ship/DummiesCosmeticsPatch.cs | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 LevelImposter/Core/Patches/Ship/DummiesCosmeticsPatch.cs 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 From 9ae33914e4013c55755e82487b6492e34766c99f Mon Sep 17 00:00:00 2001 From: PalmForest Date: Mon, 9 Jun 2025 13:29:50 +1000 Subject: [PATCH 2/2] Removed TODO comment --- LevelImposter/Builders/Util/DummyBuilder.cs | 2 -- 1 file changed, 2 deletions(-) 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