Add fallback key to rich presence

This commit is contained in:
Noah Pilarski 2023-01-22 14:52:23 -05:00
parent d6479df127
commit a98b2dd2f2
3 changed files with 15 additions and 3 deletions

View File

@ -466,7 +466,7 @@ namespace NewHorizons.Handlers
});
}
RichPresenceHandler.SetUpPlanet(body.Config.name, go, sector);
RichPresenceHandler.SetUpPlanet(body.Config.name, go, sector, body.Config.Star != null, body.Config.Atmosphere != null);
Logger.LogVerbose($"Finished creating [{body.Config.name}]");

View File

@ -9,6 +9,14 @@ namespace NewHorizons.OtherMods.OWRichPresence
public void SetTriggerActivation(bool active);
public GameObject CreateTrigger(GameObject parent, string message, string imageKey);
public GameObject CreateTrigger(GameObject parent, Sector sector, string message, string imageKey);
public GameObject CreateTrigger(GameObject parent, string message, string imageKey, string fallback);
public GameObject CreateTrigger(GameObject parent, Sector sector, string message, string imageKey, string fallback);
public void CreateTriggerVolume(OWTriggerVolume triggerVolume, string message, string imageKey);
public void CreateTriggerVolume(OWTriggerVolume triggerVolume, string message, string imageKey, string fallback);
public GameObject CreateTriggerVolume(GameObject parent, float radius, string message, string imageKey);
public GameObject CreateTriggerVolume(GameObject parent, float radius, string message, string imageKey, string fallback);
public GameObject CreateTriggerVolume(GameObject parent, Vector3 localPosition, float radius, string message, string imageKey);
public GameObject CreateTriggerVolume(GameObject parent, Vector3 localPosition, float radius, string message, string imageKey, string fallback);
public void SetCurrentRootPresence(string message, string imageKey);
}
}

View File

@ -38,7 +38,7 @@ namespace NewHorizons.OtherMods.OWRichPresence
}
}
public static void SetUpPlanet(string name, GameObject go, Sector sector)
public static void SetUpPlanet(string name, GameObject go, Sector sector, bool isStar = false, bool hasAtmosphere = false)
{
if (!Enabled) return;
@ -47,7 +47,11 @@ namespace NewHorizons.OtherMods.OWRichPresence
var localizedName = TranslationHandler.GetTranslation(name, TranslationHandler.TextType.UI);
var message = TranslationHandler.GetTranslation("RICH_PRESENCE_EXPLORING", TranslationHandler.TextType.UI).Replace("{0}", localizedName);
API.CreateTrigger(go, sector, message, name.Replace(" ", "").Replace("'", "").Replace("-", "").ToLowerInvariant());
string fallbackKey = "defaultplanet";
if (isStar) fallbackKey = "defaultstar";
else if (hasAtmosphere) fallbackKey = "defaultplanetatmosphere";
API.CreateTrigger(go, sector, message, name.Replace(" ", "").Replace("'", "").Replace("-", "").ToLowerInvariant(), fallbackKey);
}
public static void OnStarSystemLoaded(string name)