Add display names to eye astro objects

This commit is contained in:
Noah Pilarski 2024-06-14 21:50:09 -04:00
parent e55818bfb8
commit e78a892bf4

View File

@ -1,4 +1,5 @@
using HarmonyLib;
using NewHorizons.Components.EyeOfTheUniverse;
using NewHorizons.Components.Orbital;
using NewHorizons.Handlers;
@ -11,7 +12,27 @@ namespace NewHorizons.Patches.MapPatches
[HarmonyPatch(nameof(ReferenceFrame.GetHUDDisplayName))]
public static void ReferenceFrame_GetHUDDisplayName(ReferenceFrame __instance, ref string __result)
{
if (__instance.GetAstroObject() is NHAstroObject nhao && !nhao.isVanilla && !nhao.HideDisplayName)
var ao = __instance.GetAstroObject();
if (ao is EyeAstroObject eyeao && !eyeao.HideDisplayName)
{
var name = eyeao.GetAstroObjectName();
if (name == AstroObject.Name.Eye)
{
__result = UITextLibrary.GetString(UITextType.LocationEye);
}
else
{
var customName = eyeao.GetCustomName();
if (!string.IsNullOrWhiteSpace(customName))
{
__result = TranslationHandler.GetTranslation(customName, TranslationHandler.TextType.UI, false);
}
}
}
else if (ao is NHAstroObject nhao && !nhao.isVanilla && !nhao.HideDisplayName)
{
var customName = nhao.GetCustomName();