diff --git a/NewHorizons/Assets/translations/english.json b/NewHorizons/Assets/translations/english.json index 62c8b150..b7aae651 100644 --- a/NewHorizons/Assets/translations/english.json +++ b/NewHorizons/Assets/translations/english.json @@ -11,7 +11,10 @@ "FREQ_WARP_CORE": "Anti-Graviton Flux", "FREQ_UNKNOWN": "???", "ENGAGE_WARP_PROMPT": "Engage Warp To {0}", - "WARP_LOCKED": "AUTOPILOT LOCKED TO:\n{0}" + "WARP_LOCKED": "AUTOPILOT LOCKED TO:\n{0}", + "LOCK_AUTOPILOT_WARP": "Lock Autopilot to Star System", + "RICH_PRESENCE_EXPLORING": "Exploring {0}.", + "RICH_PRESENCE_WARPING": "Warping to {0}." }, "AchievementTranslations": { "NH_EATEN_OUTSIDE_BRAMBLE": { @@ -39,4 +42,4 @@ "Description": "Warp to a star system using the Vessel." } } -} \ No newline at end of file +} diff --git a/NewHorizons/Assets/translations/french.json b/NewHorizons/Assets/translations/french.json index 15099fc0..37adf8ac 100644 --- a/NewHorizons/Assets/translations/french.json +++ b/NewHorizons/Assets/translations/french.json @@ -6,9 +6,40 @@ "NEW_HORIZONS_WARP_DRIVE_DIALOGUE_3": "Ensuite, bouclez votre ceinture et engagez le pilote automatique pour y aller!" }, "UIDictionary": { - "INTERSTELLAR_MODE": "Mode Interstellaire", + "INTERSTELLAR_MODE": "Mode interstellaire", "FREQ_STATUE": "Statue Nomaï", "FREQ_WARP_CORE": "Flux Anti-Gravitonique", - "FREQ_UNKNOWN": "???" + "FREQ_UNKNOWN": "???", + "ENGAGE_WARP_PROMPT": "Engagez la distorsion vers {0}", + "WARP_LOCKED": "PILOTE AUTOMATIQUE VISÉ SUR:\n{0}", + "LOCK_AUTOPILOT_WARP": "Visez le pilote automatique", + "RICH_PRESENCE_EXPLORING": "En explorant {0}.", + "RICH_PRESENCE_WARPING": "En route vers {0}." + }, + "AchievementTranslations": { + "NH_EATEN_OUTSIDE_BRAMBLE": { + "Name": "Brèche de confinement", + "Description": "Soyez mangé à l'extérieur de Sombronces." + }, + "NH_MULTIPLE_SYSTEM": { + "Name": "Le voyageur", + "Description": "Visitez 5 systèmes solaires uniques d'affilée." + }, + "NH_NEW_FREQ": { + "Name": "Fréquence anormale", + "Description": "Découvrez une nouvelle fréquence." + }, + "NH_PROBE_LOST": { + "Name": "Connexion perdue", + "Description": "Perdez votre lance-guetteur." + }, + "NH_WARP_DRIVE": { + "Name": "En désaccord avec l'histoire.", + "Description": "Utilisez le moteur de distorsion de votre fusée." + }, + "NH_VESSEL_WARP": { + "Name": "En accord avec l'histoire.", + "Description": "Voyagez vers un autre système solaire avec le Vaissau." + } } -} \ No newline at end of file +} diff --git a/NewHorizons/Builder/Props/SignalBuilder.cs b/NewHorizons/Builder/Props/SignalBuilder.cs index 8cc01ef2..a6b2a86c 100644 --- a/NewHorizons/Builder/Props/SignalBuilder.cs +++ b/NewHorizons/Builder/Props/SignalBuilder.cs @@ -1,4 +1,4 @@ -using NewHorizons.AchievementsPlus; +using NewHorizons.OtherMods.AchievementsPlus; using NewHorizons.Components; using NewHorizons.External.Modules; using NewHorizons.Utility; diff --git a/NewHorizons/Builder/Props/VolcanoBuilder.cs b/NewHorizons/Builder/Props/VolcanoBuilder.cs index 54cf68e0..a5ddd810 100644 --- a/NewHorizons/Builder/Props/VolcanoBuilder.cs +++ b/NewHorizons/Builder/Props/VolcanoBuilder.cs @@ -45,6 +45,7 @@ namespace NewHorizons.Builder.Props } }); } + private static void FixMeteor(MeteorController meteor, PropModule.VolcanoInfo info) { meteor.transform.localScale = Vector3.one * info.scale; @@ -53,24 +54,16 @@ namespace NewHorizons.Builder.Props mat.SetColor(Color1, info.stoneTint?.ToColor() ?? defaultStoneTint); mat.SetColor(EmissionColor, info.lavaTint?.ToColor() ?? defaultLavaTint); - var detectors = meteor.transform.Find("ConstantDetectors").gameObject; - GameObject.Destroy(detectors.GetComponent()); - GameObject.Destroy(detectors.GetComponent()); + GameObject.Destroy(meteor.transform.Find("ConstantDetectors").gameObject); + + var detectors = meteor.transform.Find("DynamicDetector").gameObject; + + meteor._constantFluidDetector = null; + meteor._constantForceDetector = null; var forceDetector = detectors.gameObject.AddComponent(); - detectors.gameObject.AddComponent(); - detectors.layer = LayerMask.NameToLayer("BasicDetector"); - - var sphere = detectors.AddComponent(); - sphere.radius = 1; - - var sphere2 = detectors.AddComponent(); - sphere2._collisionMode = Shape.CollisionMode.Detector; - sphere2.radius = 1; - - forceDetector._collider = sphere; - forceDetector._shape = sphere2; + meteor._owColliders = meteor.gameObject.GetComponentsInChildren(); } } } diff --git a/NewHorizons/Components/Achievement/AchievementObserveTrigger.cs b/NewHorizons/Components/Achievement/AchievementObserveTrigger.cs index 0b5bb37b..1a6acf5f 100644 --- a/NewHorizons/Components/Achievement/AchievementObserveTrigger.cs +++ b/NewHorizons/Components/Achievement/AchievementObserveTrigger.cs @@ -1,4 +1,4 @@ -using NewHorizons.AchievementsPlus; +using NewHorizons.OtherMods.AchievementsPlus; using System; using System.Collections.Generic; using System.Linq; diff --git a/NewHorizons/Components/Achievement/AchievementSnapshotTrigger.cs b/NewHorizons/Components/Achievement/AchievementSnapshotTrigger.cs index d1a6c895..f67f0749 100644 --- a/NewHorizons/Components/Achievement/AchievementSnapshotTrigger.cs +++ b/NewHorizons/Components/Achievement/AchievementSnapshotTrigger.cs @@ -1,4 +1,4 @@ -using NewHorizons.AchievementsPlus; +using NewHorizons.OtherMods.AchievementsPlus; using System; using System.Collections.Generic; using System.Linq; diff --git a/NewHorizons/Components/Achievement/AchievementVolume.cs b/NewHorizons/Components/Achievement/AchievementVolume.cs index 1b3c9151..a5f39b15 100644 --- a/NewHorizons/Components/Achievement/AchievementVolume.cs +++ b/NewHorizons/Components/Achievement/AchievementVolume.cs @@ -1,4 +1,4 @@ -using NewHorizons.AchievementsPlus; +using NewHorizons.OtherMods.AchievementsPlus; using UnityEngine; namespace NewHorizons.Components.Achievement diff --git a/NewHorizons/Components/BlackHoleDestructionVolume.cs b/NewHorizons/Components/BlackHoleDestructionVolume.cs index 4ed3d759..145a0c5c 100644 --- a/NewHorizons/Components/BlackHoleDestructionVolume.cs +++ b/NewHorizons/Components/BlackHoleDestructionVolume.cs @@ -1,4 +1,4 @@ -using NewHorizons.AchievementsPlus.NH; +using NewHorizons.OtherMods.AchievementsPlus.NH; namespace NewHorizons.Components { diff --git a/NewHorizons/Components/ShipLogStarChartMode.cs b/NewHorizons/Components/ShipLogStarChartMode.cs index 2496bc01..a5d9dad0 100644 --- a/NewHorizons/Components/ShipLogStarChartMode.cs +++ b/NewHorizons/Components/ShipLogStarChartMode.cs @@ -47,8 +47,8 @@ namespace NewHorizons.Components _centerPromptList = centerPromptList; _upperRightPromptList = upperRightPromptList; - _detectiveModePrompt = new ScreenPrompt(InputLibrary.swapShipLogMode, "Rumor Mode", 0, ScreenPrompt.DisplayState.Normal, false); - _targetSystemPrompt = new ScreenPrompt(InputLibrary.markEntryOnHUD, "Lock Autopilot to Star System", 0, ScreenPrompt.DisplayState.Normal, false); + _detectiveModePrompt = new ScreenPrompt(InputLibrary.swapShipLogMode, UITextLibrary.GetString(UITextType.LogRumorModePrompt), 0, ScreenPrompt.DisplayState.Normal, false); + _targetSystemPrompt = new ScreenPrompt(InputLibrary.markEntryOnHUD, TranslationHandler.GetTranslation("LOCK_AUTOPILOT_WARP", TranslationHandler.TextType.UI), 0, ScreenPrompt.DisplayState.Normal, false); GlobalMessenger.AddListener("TargetReferenceFrame", new Callback(OnTargetReferenceFrame)); diff --git a/NewHorizons/External/Configs/AddonConfig.cs b/NewHorizons/External/Configs/AddonConfig.cs index 2fe85d7b..08069e00 100644 --- a/NewHorizons/External/Configs/AddonConfig.cs +++ b/NewHorizons/External/Configs/AddonConfig.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Linq; -using NewHorizons.AchievementsPlus; +using NewHorizons.OtherMods.AchievementsPlus; using NewHorizons.External.Modules; using NewHorizons.External.Modules.VariableSize; using Newtonsoft.Json; diff --git a/NewHorizons/Handlers/PlanetCreationHandler.cs b/NewHorizons/Handlers/PlanetCreationHandler.cs index 13301fd6..e40f1c3d 100644 --- a/NewHorizons/Handlers/PlanetCreationHandler.cs +++ b/NewHorizons/Handlers/PlanetCreationHandler.cs @@ -7,6 +7,7 @@ using NewHorizons.Components; using NewHorizons.Components.Orbital; using NewHorizons.Components.SizeControllers; using NewHorizons.External.Modules; +using NewHorizons.OtherMods.OWRichPresence; using NewHorizons.Utility; using System; using System.Collections.Generic; @@ -455,6 +456,8 @@ namespace NewHorizons.Handlers }); } + RichPresenceHandler.SetUpPlanet(body.Config.name, go, sector); + Logger.LogVerbose($"Finished creating [{body.Config.name}]"); return go; diff --git a/NewHorizons/Handlers/TranslationHandler.cs b/NewHorizons/Handlers/TranslationHandler.cs index 634bbe4d..aa253c3e 100644 --- a/NewHorizons/Handlers/TranslationHandler.cs +++ b/NewHorizons/Handlers/TranslationHandler.cs @@ -2,6 +2,8 @@ using NewHorizons.External.Configs; using System; using System.Collections.Generic; using System.Linq; +using Logger = NewHorizons.Utility.Logger; + namespace NewHorizons.Handlers { public static class TranslationHandler @@ -18,11 +20,6 @@ namespace NewHorizons.Handlers } public static string GetTranslation(string text, TextType type) - { - return GetTranslation(text, type, out var _); - } - - public static string GetTranslation(string text, TextType type, out TextTranslation.Language translatedLanguage) { Dictionary> dictionary; var language = TextTranslation.Get().m_language; @@ -39,32 +36,25 @@ namespace NewHorizons.Handlers dictionary = _uiTranslationDictionary; break; default: - translatedLanguage = TextTranslation.Language.UNKNOWN; + Logger.LogVerbose($"Invalid TextType {type}"); return text; } + // Get the translated text if (dictionary.TryGetValue(language, out var table)) - { if (table.TryGetValue(text, out var translatedText)) - { - translatedLanguage = language; return translatedText; - } - } + + Logger.LogVerbose($"Defaulting to english for {text}"); // Try to default to English if (dictionary.TryGetValue(TextTranslation.Language.ENGLISH, out var englishTable)) - { - if (englishTable.TryGetValue(text, out var englishText)) - { - translatedLanguage = TextTranslation.Language.ENGLISH; return englishText; - } - } + + Logger.LogVerbose($"Defaulting to key for {text}"); // Default to the key - translatedLanguage = TextTranslation.Language.UNKNOWN; return text; } diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index 4e7c8114..bdaf697b 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -1,5 +1,5 @@ using HarmonyLib; -using NewHorizons.AchievementsPlus; +using NewHorizons.OtherMods.AchievementsPlus; using NewHorizons.Builder.Atmosphere; using NewHorizons.Builder.Body; using NewHorizons.Builder.Props; @@ -10,7 +10,7 @@ using NewHorizons.Handlers; using NewHorizons.Utility; using NewHorizons.Utility.DebugMenu; using NewHorizons.Utility.DebugUtilities; -using NewHorizons.VoiceActing; +using NewHorizons.OtherMods.VoiceActing; using OWML.Common; using OWML.ModHelper; using System; @@ -22,6 +22,7 @@ using UnityEngine; using UnityEngine.Events; using UnityEngine.SceneManagement; using Logger = NewHorizons.Utility.Logger; +using NewHorizons.OtherMods.OWRichPresence; namespace NewHorizons { @@ -198,6 +199,9 @@ namespace NewHorizons AchievementHandler.Init(); VoiceHandler.Init(); + RichPresenceHandler.Init(); + OnStarSystemLoaded.AddListener(RichPresenceHandler.OnStarSystemLoaded); + OnChangeStarSystem.AddListener(RichPresenceHandler.OnChangeStarSystem); LoadAddonManifest("Assets/addon-manifest.json", this); } diff --git a/NewHorizons/AchievementsPlus/AchievementHandler.cs b/NewHorizons/OtherMods/AchievementsPlus/AchievementHandler.cs similarity index 69% rename from NewHorizons/AchievementsPlus/AchievementHandler.cs rename to NewHorizons/OtherMods/AchievementsPlus/AchievementHandler.cs index b7ea6a48..32942654 100644 --- a/NewHorizons/AchievementsPlus/AchievementHandler.cs +++ b/NewHorizons/OtherMods/AchievementsPlus/AchievementHandler.cs @@ -1,10 +1,11 @@ using NewHorizons.External.Configs; using NewHorizons.Utility; using OWML.ModHelper; +using System; using System.Collections.Generic; using System.Linq; -namespace NewHorizons.AchievementsPlus +namespace NewHorizons.OtherMods.AchievementsPlus { public static class AchievementHandler { @@ -16,30 +17,37 @@ namespace NewHorizons.AchievementsPlus public static void Init() { - API = Main.Instance.ModHelper.Interaction.TryGetModApi("xen.AchievementTracker"); - - if (API == null) + try { - Logger.LogVerbose("Achievements+ isn't installed"); - Enabled = false; - return; + API = Main.Instance.ModHelper.Interaction.TryGetModApi("xen.AchievementTracker"); + + if (API == null) + { + Logger.LogVerbose("Achievements+ isn't installed"); + Enabled = false; + return; + } + + Enabled = true; + + _achievements = new List(); + + // Register base NH achievements + NH.WarpDriveAchievement.Init(); + NH.VesselWarpAchievement.Init(); + NH.MultipleSystemAchievement.Init(); + NH.EatenOutsideBrambleAchievement.Init(); + NH.NewFrequencyAchievement.Init(); + NH.ProbeLostAchievement.Init(); + + API.RegisterTranslationsFromFiles(Main.Instance, "Assets/translations"); + + GlobalMessenger.AddListener("DialogueConditionChanged", OnDialogueConditionChanged); + } + catch(Exception ex) + { + Logger.LogError($"Achievements+ handler failed to initialize: {ex}"); } - - Enabled = true; - - _achievements = new List(); - - // Register base NH achievements - NH.WarpDriveAchievement.Init(); - NH.VesselWarpAchievement.Init(); - NH.MultipleSystemAchievement.Init(); - NH.EatenOutsideBrambleAchievement.Init(); - NH.NewFrequencyAchievement.Init(); - NH.ProbeLostAchievement.Init(); - - API.RegisterTranslationsFromFiles(Main.Instance, "Assets/translations"); - - GlobalMessenger.AddListener("DialogueConditionChanged", OnDialogueConditionChanged); } public static void OnDestroy() diff --git a/NewHorizons/AchievementsPlus/AchievementInfo.cs b/NewHorizons/OtherMods/AchievementsPlus/AchievementInfo.cs similarity index 98% rename from NewHorizons/AchievementsPlus/AchievementInfo.cs rename to NewHorizons/OtherMods/AchievementsPlus/AchievementInfo.cs index d1789a75..9246b3d9 100644 --- a/NewHorizons/AchievementsPlus/AchievementInfo.cs +++ b/NewHorizons/OtherMods/AchievementsPlus/AchievementInfo.cs @@ -2,7 +2,7 @@ using NewHorizons.Builder.Props; using Newtonsoft.Json; using System.Linq; -namespace NewHorizons.AchievementsPlus +namespace NewHorizons.OtherMods.AchievementsPlus { /// /// Info for an achievement to be used with the Achievements+ mod. diff --git a/NewHorizons/AchievementsPlus/IAchievements.cs b/NewHorizons/OtherMods/AchievementsPlus/IAchievements.cs similarity index 90% rename from NewHorizons/AchievementsPlus/IAchievements.cs rename to NewHorizons/OtherMods/AchievementsPlus/IAchievements.cs index 8505624d..9572ca1e 100644 --- a/NewHorizons/AchievementsPlus/IAchievements.cs +++ b/NewHorizons/OtherMods/AchievementsPlus/IAchievements.cs @@ -1,6 +1,6 @@ using OWML.ModHelper; -namespace NewHorizons.AchievementsPlus +namespace NewHorizons.OtherMods.AchievementsPlus { public interface IAchievements { diff --git a/NewHorizons/AchievementsPlus/NH/EatenOutsideBrambleAchievement.cs b/NewHorizons/OtherMods/AchievementsPlus/NH/EatenOutsideBrambleAchievement.cs similarity index 92% rename from NewHorizons/AchievementsPlus/NH/EatenOutsideBrambleAchievement.cs rename to NewHorizons/OtherMods/AchievementsPlus/NH/EatenOutsideBrambleAchievement.cs index 8df509ce..67f189bc 100644 --- a/NewHorizons/AchievementsPlus/NH/EatenOutsideBrambleAchievement.cs +++ b/NewHorizons/OtherMods/AchievementsPlus/NH/EatenOutsideBrambleAchievement.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace NewHorizons.AchievementsPlus.NH +namespace NewHorizons.OtherMods.AchievementsPlus.NH { public static class EatenOutsideBrambleAchievement { diff --git a/NewHorizons/AchievementsPlus/NH/MultipleSystemAchievement.cs b/NewHorizons/OtherMods/AchievementsPlus/NH/MultipleSystemAchievement.cs similarity index 95% rename from NewHorizons/AchievementsPlus/NH/MultipleSystemAchievement.cs rename to NewHorizons/OtherMods/AchievementsPlus/NH/MultipleSystemAchievement.cs index f2ae29c5..1d7e6d3f 100644 --- a/NewHorizons/AchievementsPlus/NH/MultipleSystemAchievement.cs +++ b/NewHorizons/OtherMods/AchievementsPlus/NH/MultipleSystemAchievement.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace NewHorizons.AchievementsPlus.NH +namespace NewHorizons.OtherMods.AchievementsPlus.NH { public static class MultipleSystemAchievement { diff --git a/NewHorizons/AchievementsPlus/NH/NewFrequencyAchievement.cs b/NewHorizons/OtherMods/AchievementsPlus/NH/NewFrequencyAchievement.cs similarity index 90% rename from NewHorizons/AchievementsPlus/NH/NewFrequencyAchievement.cs rename to NewHorizons/OtherMods/AchievementsPlus/NH/NewFrequencyAchievement.cs index 7cde8861..6a2ff325 100644 --- a/NewHorizons/AchievementsPlus/NH/NewFrequencyAchievement.cs +++ b/NewHorizons/OtherMods/AchievementsPlus/NH/NewFrequencyAchievement.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace NewHorizons.AchievementsPlus.NH +namespace NewHorizons.OtherMods.AchievementsPlus.NH { public static class NewFrequencyAchievement { diff --git a/NewHorizons/AchievementsPlus/NH/ProbeLostAchievement.cs b/NewHorizons/OtherMods/AchievementsPlus/NH/ProbeLostAchievement.cs similarity index 90% rename from NewHorizons/AchievementsPlus/NH/ProbeLostAchievement.cs rename to NewHorizons/OtherMods/AchievementsPlus/NH/ProbeLostAchievement.cs index 9ddef4b8..b99a58cc 100644 --- a/NewHorizons/AchievementsPlus/NH/ProbeLostAchievement.cs +++ b/NewHorizons/OtherMods/AchievementsPlus/NH/ProbeLostAchievement.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace NewHorizons.AchievementsPlus.NH +namespace NewHorizons.OtherMods.AchievementsPlus.NH { public static class ProbeLostAchievement { diff --git a/NewHorizons/AchievementsPlus/NH/VesselWarpAchievement.cs b/NewHorizons/OtherMods/AchievementsPlus/NH/VesselWarpAchievement.cs similarity index 92% rename from NewHorizons/AchievementsPlus/NH/VesselWarpAchievement.cs rename to NewHorizons/OtherMods/AchievementsPlus/NH/VesselWarpAchievement.cs index 2cffa8ae..3f1115dd 100644 --- a/NewHorizons/AchievementsPlus/NH/VesselWarpAchievement.cs +++ b/NewHorizons/OtherMods/AchievementsPlus/NH/VesselWarpAchievement.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace NewHorizons.AchievementsPlus.NH +namespace NewHorizons.OtherMods.AchievementsPlus.NH { public static class VesselWarpAchievement { diff --git a/NewHorizons/AchievementsPlus/NH/WarpDriveAchievement.cs b/NewHorizons/OtherMods/AchievementsPlus/NH/WarpDriveAchievement.cs similarity index 92% rename from NewHorizons/AchievementsPlus/NH/WarpDriveAchievement.cs rename to NewHorizons/OtherMods/AchievementsPlus/NH/WarpDriveAchievement.cs index ee0747b7..1a05ed89 100644 --- a/NewHorizons/AchievementsPlus/NH/WarpDriveAchievement.cs +++ b/NewHorizons/OtherMods/AchievementsPlus/NH/WarpDriveAchievement.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace NewHorizons.AchievementsPlus.NH +namespace NewHorizons.OtherMods.AchievementsPlus.NH { public static class WarpDriveAchievement { diff --git a/NewHorizons/OtherMods/OWRichPresence/IRichPresenceAPI.cs b/NewHorizons/OtherMods/OWRichPresence/IRichPresenceAPI.cs new file mode 100644 index 00000000..e2132b89 --- /dev/null +++ b/NewHorizons/OtherMods/OWRichPresence/IRichPresenceAPI.cs @@ -0,0 +1,14 @@ +using UnityEngine; + +namespace NewHorizons.OtherMods.OWRichPresence +{ + public interface IRichPresenceAPI + { + public void SetRichPresence(string message, int imageKey); + public void SetRichPresence(string message, string imageKey); + 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 void SetCurrentRootPresence(string message, string imageKey); + } +} diff --git a/NewHorizons/OtherMods/OWRichPresence/RichPresenceHandler.cs b/NewHorizons/OtherMods/OWRichPresence/RichPresenceHandler.cs new file mode 100644 index 00000000..eab39d4c --- /dev/null +++ b/NewHorizons/OtherMods/OWRichPresence/RichPresenceHandler.cs @@ -0,0 +1,71 @@ +using NewHorizons.Components; +using NewHorizons.Handlers; +using NewHorizons.Utility; +using System; +using System.IO; +using System.Linq; +using UnityEngine; +using UnityEngine.SceneManagement; +using Logger = NewHorizons.Utility.Logger; + +namespace NewHorizons.OtherMods.OWRichPresence +{ + public class RichPresenceHandler + { + public static bool Enabled { get; private set; } + + private static IRichPresenceAPI API; + + public static void Init() + { + try + { + API = Main.Instance.ModHelper.Interaction.TryGetModApi("MegaPiggy.OWRichPresence"); + + if (API == null) + { + Logger.LogVerbose("OWRichPresence isn't installed"); + Enabled = false; + return; + } + + Enabled = true; + } + catch(Exception ex) + { + Logger.LogError($"OWRichPresence handler failed to initialize: {ex}"); + Enabled = false; + } + } + + public static void SetUpPlanet(string name, GameObject go, Sector sector) + { + if (!Enabled) return; + + Logger.LogVerbose($"Registering {go.name} to 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("'", "").ToLowerInvariant()); + } + + public static void OnStarSystemLoaded(string name) + { + if (name == "SolarSystem") return; + + var localizedName = ShipLogStarChartMode.UniqueIDToName(name); + var message = TranslationHandler.GetTranslation("RICH_PRESENCE_EXPLORING", TranslationHandler.TextType.UI).Replace("{0}", localizedName); + + API.SetCurrentRootPresence(message, "sun"); + } + + public static void OnChangeStarSystem(string destination) + { + var localizedName = ShipLogStarChartMode.UniqueIDToName(destination); + var message = TranslationHandler.GetTranslation("RICH_PRESENCE_WARPING", TranslationHandler.TextType.UI).Replace("{0}", localizedName); + + API.SetRichPresence(message, "newhorizons"); + } + } +} diff --git a/NewHorizons/VoiceActing/IVoiceMod.cs b/NewHorizons/OtherMods/VoiceActing/IVoiceMod.cs similarity index 68% rename from NewHorizons/VoiceActing/IVoiceMod.cs rename to NewHorizons/OtherMods/VoiceActing/IVoiceMod.cs index d9b12384..b47c3c71 100644 --- a/NewHorizons/VoiceActing/IVoiceMod.cs +++ b/NewHorizons/OtherMods/VoiceActing/IVoiceMod.cs @@ -1,4 +1,4 @@ -namespace NewHorizons.VoiceActing +namespace NewHorizons.OtherMods.VoiceActing { public interface IVoiceMod { diff --git a/NewHorizons/VoiceActing/VoiceHandler.cs b/NewHorizons/OtherMods/VoiceActing/VoiceHandler.cs similarity index 66% rename from NewHorizons/VoiceActing/VoiceHandler.cs rename to NewHorizons/OtherMods/VoiceActing/VoiceHandler.cs index 576c2ad3..65f66b79 100644 --- a/NewHorizons/VoiceActing/VoiceHandler.cs +++ b/NewHorizons/OtherMods/VoiceActing/VoiceHandler.cs @@ -1,8 +1,9 @@ using NewHorizons.Utility; +using System; using System.IO; using System.Linq; -namespace NewHorizons.VoiceActing +namespace NewHorizons.OtherMods.VoiceActing { public static class VoiceHandler { @@ -12,17 +13,29 @@ namespace NewHorizons.VoiceActing public static void Init() { - API = Main.Instance.ModHelper.Interaction.TryGetModApi("Krevace.VoiceMod"); - - if (API == null) + try { - Logger.LogVerbose("VoiceMod isn't installed"); - Enabled = false; - return; + API = Main.Instance.ModHelper.Interaction.TryGetModApi("Krevace.VoiceMod"); + + if (API == null) + { + Logger.LogVerbose("VoiceMod isn't installed"); + return; + } + + Enabled = true; + + SetUp(); } + catch (Exception ex) + { + Logger.LogError($"VoiceMod handler failed to initialize: {ex}"); + Enabled = false; + } + } - Enabled = true; - + private static void SetUp() + { foreach (var mod in Main.Instance.GetDependants().Append(Main.Instance)) { var folder = $"{mod.ModHelper.Manifest.ModFolderPath}voicemod"; diff --git a/NewHorizons/Patches/PlayerDataPatches.cs b/NewHorizons/Patches/PlayerDataPatches.cs index b2c7f423..8f4476c3 100644 --- a/NewHorizons/Patches/PlayerDataPatches.cs +++ b/NewHorizons/Patches/PlayerDataPatches.cs @@ -1,6 +1,6 @@ using HarmonyLib; -using NewHorizons.AchievementsPlus; -using NewHorizons.AchievementsPlus.NH; +using NewHorizons.OtherMods.AchievementsPlus; +using NewHorizons.OtherMods.AchievementsPlus.NH; using NewHorizons.Builder.Props; using NewHorizons.External; using NewHorizons.Handlers; diff --git a/NewHorizons/Patches/ShipLogPatches.cs b/NewHorizons/Patches/ShipLogPatches.cs index 7901dc87..ba588f12 100644 --- a/NewHorizons/Patches/ShipLogPatches.cs +++ b/NewHorizons/Patches/ShipLogPatches.cs @@ -1,5 +1,5 @@ using HarmonyLib; -using NewHorizons.AchievementsPlus; +using NewHorizons.OtherMods.AchievementsPlus; using NewHorizons.Builder.ShipLog; using NewHorizons.Components; using NewHorizons.Handlers;