Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions LevelImposter/Builders/Util/DummyBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
30 changes: 30 additions & 0 deletions LevelImposter/Core/Patches/Ship/DummiesCosmeticsPatch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using HarmonyLib;
using LevelImposter.Shop;
using System.Linq;

namespace LevelImposter.Core;

/// <summary>
/// Renames all dummies to the names of
/// their corresponding objects in the editor
/// </summary>
[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);
}
}