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

## Bug fixes
- Fixed vanilla objects being given labels (OPC, QM, SS) #623
This commit is contained in:
Nick 2023-07-03 10:42:34 -04:00 committed by GitHub
commit 6438f779ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 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>();
astroObject.isVanilla = isVanilla;
astroObject.HideDisplayName = !config.Base.hasMapMarker;
astroObject.invulnerableToSun = config.Base.invulnerableToSun;

View File

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

View File

@ -343,7 +343,7 @@ namespace NewHorizons.Handlers
body.Config.Base.hasMapMarker = false;
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);
ao._rootSector = sector;
@ -409,7 +409,7 @@ namespace NewHorizons.Handlers
}
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);
@ -705,7 +705,7 @@ namespace NewHorizons.Handlers
}
// 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._moon = ao._moon;
newAO._name = ao._name;

View File

@ -7,32 +7,19 @@ namespace NewHorizons.Patches.MapPatches
[HarmonyPatch(typeof(ReferenceFrame))]
public static class ReferenceFramePatches
{
[HarmonyPrefix]
[HarmonyPostfix]
[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 (ao == null) return true;
if (ao._name != AstroObject.Name.CustomString)
if (__instance.GetAstroObject() is NHAstroObject nhao && !nhao.isVanilla && !nhao.HideDisplayName)
{
__result = AstroObject.AstroObjectNameToString(ao._name);
return false;
var customName = nhao.GetCustomName();
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;
}
}
}