Fix QM, OPC, Sun Station debris labeled when locked on #623

This commit is contained in:
Nick 2023-07-03 10:13:53 -04:00
parent ffd2fe6911
commit 2f9e66398b
4 changed files with 15 additions and 26 deletions

View File

@ -7,9 +7,10 @@ namespace NewHorizons.Builder.General
{ {
public static class AstroObjectBuilder public static class AstroObjectBuilder
{ {
public static NHAstroObject Make(GameObject body, AstroObject primaryBody, PlanetConfig config) public static NHAstroObject Make(GameObject body, AstroObject primaryBody, PlanetConfig config, bool isVanilla)
{ {
NHAstroObject astroObject = body.AddComponent<NHAstroObject>(); NHAstroObject astroObject = body.AddComponent<NHAstroObject>();
astroObject.isVanilla = isVanilla;
astroObject.HideDisplayName = !config.Base.hasMapMarker; astroObject.HideDisplayName = !config.Base.hasMapMarker;
astroObject.invulnerableToSun = config.Base.invulnerableToSun; astroObject.invulnerableToSun = config.Base.invulnerableToSun;

View File

@ -12,6 +12,7 @@ namespace NewHorizons.Components.Orbital
public bool HideDisplayName { get; set; } public bool HideDisplayName { get; set; }
public bool IsDimension { get; set; } public bool IsDimension { get; set; }
public bool invulnerableToSun; public bool invulnerableToSun;
public bool isVanilla;
public void SetOrbitalParametersFromConfig(OrbitModule orbit) public void SetOrbitalParametersFromConfig(OrbitModule orbit)
{ {

View File

@ -343,7 +343,7 @@ namespace NewHorizons.Handlers
body.Config.Base.hasMapMarker = false; body.Config.Base.hasMapMarker = false;
var owRigidBody = RigidBodyBuilder.Make(go, body.Config); var owRigidBody = RigidBodyBuilder.Make(go, body.Config);
var ao = AstroObjectBuilder.Make(go, null, body.Config); var ao = AstroObjectBuilder.Make(go, null, body.Config, false);
var sector = SectorBuilder.Make(go, owRigidBody, 2000f); var sector = SectorBuilder.Make(go, owRigidBody, 2000f);
ao._rootSector = sector; ao._rootSector = sector;
@ -409,7 +409,7 @@ namespace NewHorizons.Handlers
} }
var owRigidBody = RigidBodyBuilder.Make(go, body.Config); var owRigidBody = RigidBodyBuilder.Make(go, body.Config);
var ao = AstroObjectBuilder.Make(go, primaryBody, body.Config); var ao = AstroObjectBuilder.Make(go, primaryBody, body.Config, false);
var sphereOfInfluence = GetSphereOfInfluence(body); var sphereOfInfluence = GetSphereOfInfluence(body);
@ -702,7 +702,7 @@ namespace NewHorizons.Handlers
} }
// Just destroy the existing AO after copying everything over // Just destroy the existing AO after copying everything over
var newAO = AstroObjectBuilder.Make(go, primary, body.Config); var newAO = AstroObjectBuilder.Make(go, primary, body.Config, true);
newAO._gravityVolume = ao._gravityVolume; newAO._gravityVolume = ao._gravityVolume;
newAO._moon = ao._moon; newAO._moon = ao._moon;
newAO._name = ao._name; newAO._name = ao._name;

View File

@ -7,32 +7,19 @@ namespace NewHorizons.Patches.MapPatches
[HarmonyPatch(typeof(ReferenceFrame))] [HarmonyPatch(typeof(ReferenceFrame))]
public static class ReferenceFramePatches public static class ReferenceFramePatches
{ {
[HarmonyPrefix] [HarmonyPostfix]
[HarmonyPatch(nameof(ReferenceFrame.GetHUDDisplayName))] [HarmonyPatch(nameof(ReferenceFrame.GetHUDDisplayName))]
public static bool ReferenceFrame_GetHUDDisplayName(ReferenceFrame __instance, ref string __result) public static void ReferenceFrame_GetHUDDisplayName(ReferenceFrame __instance, ref string __result)
{ {
var ao = __instance.GetAstroObject(); if (__instance.GetAstroObject() is NHAstroObject nhao && !nhao.isVanilla && !nhao.HideDisplayName)
if (ao == null) return true;
if (ao._name != AstroObject.Name.CustomString)
{ {
__result = AstroObject.AstroObjectNameToString(ao._name); var customName = nhao.GetCustomName();
return false;
if (!string.IsNullOrWhiteSpace(customName))
{
__result = TranslationHandler.GetTranslation(customName, TranslationHandler.TextType.UI, false);
}
} }
__result = string.Empty;
if (ao is NHAstroObject nhao && nhao.HideDisplayName) return false;
var customName = ao.GetCustomName();
if (!string.IsNullOrWhiteSpace(customName))
{
__result = TranslationHandler.GetTranslation(customName, TranslationHandler.TextType.UI, false);
}
return false;
} }
} }
} }