diff --git a/NewHorizons/AchievementsPlus/AchievementInfo.cs b/NewHorizons/AchievementsPlus/AchievementInfo.cs index d1789a75..98e6e5dc 100644 --- a/NewHorizons/AchievementsPlus/AchievementInfo.cs +++ b/NewHorizons/AchievementsPlus/AchievementInfo.cs @@ -1,4 +1,5 @@ using NewHorizons.Builder.Props; +using NewHorizons.Handlers; using Newtonsoft.Json; using System.Linq; @@ -61,7 +62,7 @@ namespace NewHorizons.AchievementsPlus { foreach (var fact in factIDs) { - if (!Locator.GetShipLogManager().IsFactRevealed(fact)) return false; + if (!ShipLogHandler.KnowsFact(fact)) return false; } } diff --git a/NewHorizons/Assets/eye symbol.png b/NewHorizons/Assets/eye symbol.png new file mode 100644 index 00000000..3634a28d Binary files /dev/null and b/NewHorizons/Assets/eye symbol.png differ diff --git a/NewHorizons/Assets/translations/chinese_simple.json b/NewHorizons/Assets/translations/chinese_simple.json new file mode 100644 index 00000000..74470395 --- /dev/null +++ b/NewHorizons/Assets/translations/chinese_simple.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://raw.githubusercontent.com/xen-42/outer-wilds-new-horizons/main/NewHorizons/Schemas/translation_schema.json", + "UIDictionary": { + "Vessel": "飞船" + } +} \ No newline at end of file diff --git a/NewHorizons/Assets/translations/english.json b/NewHorizons/Assets/translations/english.json index 62c8b150..82798871 100644 --- a/NewHorizons/Assets/translations/english.json +++ b/NewHorizons/Assets/translations/english.json @@ -11,7 +11,8 @@ "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}", + "Vessel": "Vessel" }, "AchievementTranslations": { "NH_EATEN_OUTSIDE_BRAMBLE": { diff --git a/NewHorizons/Assets/translations/french.json b/NewHorizons/Assets/translations/french.json index 15099fc0..1fd08442 100644 --- a/NewHorizons/Assets/translations/french.json +++ b/NewHorizons/Assets/translations/french.json @@ -9,6 +9,7 @@ "INTERSTELLAR_MODE": "Mode Interstellaire", "FREQ_STATUE": "Statue Nomaï", "FREQ_WARP_CORE": "Flux Anti-Gravitonique", - "FREQ_UNKNOWN": "???" + "FREQ_UNKNOWN": "???", + "Vessel": "Vaisseau" } } \ No newline at end of file diff --git a/NewHorizons/Assets/translations/german.json b/NewHorizons/Assets/translations/german.json index 460adc9f..0edde904 100644 --- a/NewHorizons/Assets/translations/german.json +++ b/NewHorizons/Assets/translations/german.json @@ -9,6 +9,7 @@ "INTERSTELLAR_MODE": "Interstellar Modus", "FREQ_STATUE": "Nomai-Statue", "FREQ_WARP_CORE": "Anti-Gravitations Flux", - "FREQ_UNKNOWN": "???" + "FREQ_UNKNOWN": "???", + "Vessel": "Gefährts" } } \ No newline at end of file diff --git a/NewHorizons/Assets/translations/italian.json b/NewHorizons/Assets/translations/italian.json new file mode 100644 index 00000000..5ed2e16c --- /dev/null +++ b/NewHorizons/Assets/translations/italian.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://raw.githubusercontent.com/xen-42/outer-wilds-new-horizons/main/NewHorizons/Schemas/translation_schema.json", + "UIDictionary": { + "Vessel": "Vascello" + } +} \ No newline at end of file diff --git a/NewHorizons/Assets/translations/japanese.json b/NewHorizons/Assets/translations/japanese.json new file mode 100644 index 00000000..b67fb1fe --- /dev/null +++ b/NewHorizons/Assets/translations/japanese.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://raw.githubusercontent.com/xen-42/outer-wilds-new-horizons/main/NewHorizons/Schemas/translation_schema.json", + "UIDictionary": { + "Vessel": "船" + } +} \ No newline at end of file diff --git a/NewHorizons/Assets/translations/korean.json b/NewHorizons/Assets/translations/korean.json new file mode 100644 index 00000000..6e23b0fd --- /dev/null +++ b/NewHorizons/Assets/translations/korean.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://raw.githubusercontent.com/xen-42/outer-wilds-new-horizons/main/NewHorizons/Schemas/translation_schema.json", + "UIDictionary": { + "Vessel": "함선" + } +} \ No newline at end of file diff --git a/NewHorizons/Assets/translations/polish.json b/NewHorizons/Assets/translations/polish.json new file mode 100644 index 00000000..d3d9bcda --- /dev/null +++ b/NewHorizons/Assets/translations/polish.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://raw.githubusercontent.com/xen-42/outer-wilds-new-horizons/main/NewHorizons/Schemas/translation_schema.json", + "UIDictionary": { + "Vessel": "Statku" + } +} \ No newline at end of file diff --git a/NewHorizons/Assets/translations/portuguese_br.json b/NewHorizons/Assets/translations/portuguese_br.json new file mode 100644 index 00000000..cac86858 --- /dev/null +++ b/NewHorizons/Assets/translations/portuguese_br.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://raw.githubusercontent.com/xen-42/outer-wilds-new-horizons/main/NewHorizons/Schemas/translation_schema.json", + "UIDictionary": { + "Vessel": "Hospedeiro" + } +} \ No newline at end of file diff --git a/NewHorizons/Assets/translations/russian.json b/NewHorizons/Assets/translations/russian.json index 7063f448..f5e22023 100644 --- a/NewHorizons/Assets/translations/russian.json +++ b/NewHorizons/Assets/translations/russian.json @@ -11,6 +11,7 @@ "FREQ_WARP_CORE": "Гиперядро", "FREQ_UNKNOWN": "???", "ENGAGE_WARP_PROMPT": "Телепортироваться к {0}", - "WARP_LOCKED": "АВТОПИЛОТ ЗАКРЕПЛЁН НА:\n{0}" + "WARP_LOCKED": "АВТОПИЛОТ ЗАКРЕПЛЁН НА:\n{0}", + "Vessel": "«Звездолёта»" } } diff --git a/NewHorizons/Assets/translations/spanish_la.json b/NewHorizons/Assets/translations/spanish_la.json index 787342ba..5a65346a 100644 --- a/NewHorizons/Assets/translations/spanish_la.json +++ b/NewHorizons/Assets/translations/spanish_la.json @@ -11,7 +11,8 @@ "FREQ_WARP_CORE": "Flujo De Anti-Gravitones", "FREQ_UNKNOWN": "???", "ENGAGE_WARP_PROMPT": "Iniciar teletransporte a {0}", - "WARP_LOCKED": "Piloto automático fijado en:\n{0}" + "WARP_LOCKED": "Piloto automático fijado en:\n{0}", + "Vessel": "Nave" }, "AchievementTranslations": { "NH_EATEN_OUTSIDE_BRAMBLE": { diff --git a/NewHorizons/Assets/translations/turkish.json b/NewHorizons/Assets/translations/turkish.json new file mode 100644 index 00000000..7b82267a --- /dev/null +++ b/NewHorizons/Assets/translations/turkish.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://raw.githubusercontent.com/xen-42/outer-wilds-new-horizons/main/NewHorizons/Schemas/translation_schema.json", + "UIDictionary": { + "Vessel": "Tekne" + } +} \ No newline at end of file diff --git a/NewHorizons/Builder/Atmosphere/VolumesBuilder.cs b/NewHorizons/Builder/Atmosphere/VolumesBuilder.cs index cba3845d..01445351 100644 --- a/NewHorizons/Builder/Atmosphere/VolumesBuilder.cs +++ b/NewHorizons/Builder/Atmosphere/VolumesBuilder.cs @@ -36,18 +36,21 @@ namespace NewHorizons.Builder.Atmosphere rulesetGO.AddComponent(); - EffectRuleset ER = rulesetGO.AddComponent(); - ER._type = EffectRuleset.BubbleType.Underwater; - var gdRuleset = SearchUtilities.Find("GiantsDeep_Body/Sector_GD/Volumes_GD/RulesetVolumes_GD").GetComponent(); - - ER._material = gdRuleset._material; - - var cloudMaterial = new Material(gdRuleset._cloudMaterial); - if (config.Atmosphere?.clouds?.tint != null) + var gdRuleset = SearchUtilities.Find("GiantsDeep_Body/Sector_GD/Volumes_GD/RulesetVolumes_GD")?.GetComponent(); + if (gdRuleset != null) { - cloudMaterial.SetColor(FogColor, config.Atmosphere.clouds.tint.ToColor()); + EffectRuleset ER = rulesetGO.AddComponent(); + ER._type = EffectRuleset.BubbleType.Underwater; + + ER._material = gdRuleset._material; + + var cloudMaterial = new Material(gdRuleset._cloudMaterial); + if (config.Atmosphere?.clouds?.tint != null) + { + cloudMaterial.SetColor(FogColor, config.Atmosphere.clouds.tint.ToColor()); + } + ER._cloudMaterial = cloudMaterial; } - ER._cloudMaterial = cloudMaterial; if (config.Base.zeroGravityRadius != 0) { diff --git a/NewHorizons/Builder/Body/ProxyBuilder.cs b/NewHorizons/Builder/Body/ProxyBuilder.cs index 629e7570..efc2c70b 100644 --- a/NewHorizons/Builder/Body/ProxyBuilder.cs +++ b/NewHorizons/Builder/Body/ProxyBuilder.cs @@ -29,7 +29,7 @@ namespace NewHorizons.Builder.Body public static void Make(GameObject planetGO, NewHorizonsBody body) { - if (lavaMaterial == null) lavaMaterial = SearchUtilities.FindObjectOfTypeAndName("VolcanicMoon_Body").transform.Find("LavaSphere").GetComponent().material; + if (lavaMaterial == null) lavaMaterial = SearchUtilities.FindObjectOfTypeAndName("VolcanicMoon_Body")?.transform.Find("LavaSphere").GetComponent().material; var proxyName = $"{body.Config.name}_Proxy"; diff --git a/NewHorizons/Builder/General/AmbientLightBuilder.cs b/NewHorizons/Builder/General/AmbientLightBuilder.cs index c51f90c0..617b3942 100644 --- a/NewHorizons/Builder/General/AmbientLightBuilder.cs +++ b/NewHorizons/Builder/General/AmbientLightBuilder.cs @@ -6,7 +6,10 @@ namespace NewHorizons.Builder.General { public static void Make(GameObject planetGO, Sector sector, float scale, float intensity) { - GameObject lightGO = GameObject.Instantiate(SearchUtilities.Find("BrittleHollow_Body/AmbientLight_BH_Surface"), sector?.transform ?? planetGO.transform); + var bhAmbientLight = SearchUtilities.Find("BrittleHollow_Body/AmbientLight_BH_Surface"); + if (bhAmbientLight == null) return; + + GameObject lightGO = GameObject.Instantiate(bhAmbientLight, sector?.transform ?? planetGO.transform); lightGO.transform.position = planetGO.transform.position; lightGO.name = "Light"; diff --git a/NewHorizons/Components/EyeAstroObject.cs b/NewHorizons/Components/EyeAstroObject.cs new file mode 100644 index 00000000..6b78ddb4 --- /dev/null +++ b/NewHorizons/Components/EyeAstroObject.cs @@ -0,0 +1,17 @@ +using NewHorizons.Utility; + +namespace NewHorizons.Components.Orbital +{ + public class EyeAstroObject : AstroObject + { + public new void Awake() + { + _owRigidbody = GetComponent(); + } + + public void Register() + { + Locator.RegisterAstroObject(this); + } + } +} diff --git a/NewHorizons/Components/ShipLogStarChartMode.cs b/NewHorizons/Components/ShipLogStarChartMode.cs index 2496bc01..5778ebd5 100644 --- a/NewHorizons/Components/ShipLogStarChartMode.cs +++ b/NewHorizons/Components/ShipLogStarChartMode.cs @@ -63,6 +63,7 @@ namespace NewHorizons.Components // Conditions to allow warping into that system (either no planets (stock system) or has a ship spawn point) var flag = false; if (starSystem.Equals("SolarSystem")) flag = true; + else if (starSystem.Equals("EyeOfTheUniverse")) flag = false; else if (config.Spawn?.shipSpawnPoint != null) flag = true; if (!StarChartHandler.HasUnlockedSystem(starSystem)) continue; @@ -73,10 +74,8 @@ namespace NewHorizons.Components } } - //AddSystemCard("EyeOfTheUniverse"); - - /* Ship log manager isnt initiatiized yet - if(Locator.GetShipLogManager().IsFactRevealed("OPC_EYE_COORDINATES_X1")) + /* + if(VesselCoordinatePromptHandler.KnowsEyeCoordinates()) { AddSystemCard("EyeOfTheUniverse"); } @@ -130,6 +129,10 @@ namespace NewHorizons.Components { texture = ImageUtilities.GetTexture(Main.Instance, "Assets/hearthian system.png"); } + else if (uniqueID.Equals("EyeOfTheUniverse")) + { + texture = ImageUtilities.GetTexture(Main.Instance, "Assets/eye symbol.png"); + } else { var path = $"planets/{uniqueID}.png"; diff --git a/NewHorizons/Components/ShipWarpController.cs b/NewHorizons/Components/ShipWarpController.cs index ed08e79e..3ff96a3a 100644 --- a/NewHorizons/Components/ShipWarpController.cs +++ b/NewHorizons/Components/ShipWarpController.cs @@ -29,22 +29,24 @@ namespace NewHorizons.Components { _blackHolePrefab = SearchUtilities.Find(_blackHolePath); _whiteHolePrefab = SearchUtilities.Find(_whiteHolePath); + + MakeBlackHole(); + MakeWhiteHole(); + + if (_oneShotSource == null) + { + var audioObject = new GameObject("WarpOneShot"); + audioObject.transform.parent = transform; + audioObject.SetActive(false); + _oneShotSource = audioObject.AddComponent(); + _oneShotSource._track = OWAudioMixer.TrackName.Ship; + audioObject.SetActive(true); + } } public void Start() { - MakeBlackHole(); - MakeWhiteHole(); - _isWarpingIn = false; - - var audioObject = new GameObject("WarpOneShot"); - audioObject.transform.parent = transform; - audioObject.SetActive(false); - _oneShotSource = audioObject.AddComponent(); - _oneShotSource._track = OWAudioMixer.TrackName.Ship; - audioObject.SetActive(true); - GlobalMessenger.AddListener("FinishOpenEyes", new Callback(OnFinishOpenEyes)); } @@ -55,6 +57,9 @@ namespace NewHorizons.Components private void MakeBlackHole() { + if (_blackhole != null) return; + if (_blackHolePrefab == null) return; + var blackHoleShader = _blackHolePrefab.GetComponent().material.shader; if (blackHoleShader == null) blackHoleShader = _blackHolePrefab.GetComponent().sharedMaterial.shader; @@ -79,6 +84,9 @@ namespace NewHorizons.Components private void MakeWhiteHole() { + if (_whitehole != null) return; + if (_whiteHolePrefab == null) return; + var whiteHoleShader = _whiteHolePrefab.GetComponent().material.shader; if (whiteHoleShader == null) whiteHoleShader = _whiteHolePrefab.GetComponent().sharedMaterial.shader; diff --git a/NewHorizons/Handlers/PlanetCreationHandler.cs b/NewHorizons/Handlers/PlanetCreationHandler.cs index bffe3fea..b0e45432 100644 --- a/NewHorizons/Handlers/PlanetCreationHandler.cs +++ b/NewHorizons/Handlers/PlanetCreationHandler.cs @@ -32,33 +32,36 @@ namespace NewHorizons.Handlers _existingBodyDict = new(); _customBodyDict = new(); - // Set up stars - // Need to manage this when there are multiple stars - var sun = SearchUtilities.Find("Sun_Body"); - var starController = sun.AddComponent(); - starController.Light = SearchUtilities.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent(); - starController.AmbientLight = SearchUtilities.Find("Sun_Body/AmbientLight_SUN").GetComponent(); - starController.FaceActiveCamera = SearchUtilities.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent(); - starController.CSMTextureCacher = SearchUtilities.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent(); - starController.ProxyShadowLight = SearchUtilities.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent(); - starController.Intensity = 0.9859f; - starController.SunColor = new Color(1f, 0.8845f, 0.6677f, 1f); - - var starLightGO = GameObject.Instantiate(sun.GetComponentInChildren().gameObject); - foreach (var comp in starLightGO.GetComponents()) + if (Main.Instance.CurrentStarSystem != "EyeOfTheUniverse") { - if (!(comp is SunLightController) && !(comp is SunLightParamUpdater) && !(comp is Light) && !(comp is Transform)) + // Set up stars + // Need to manage this when there are multiple stars + var sun = SearchUtilities.Find("Sun_Body"); + var starController = sun.AddComponent(); + starController.Light = SearchUtilities.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent(); + starController.AmbientLight = SearchUtilities.Find("Sun_Body/AmbientLight_SUN").GetComponent(); + starController.FaceActiveCamera = SearchUtilities.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent(); + starController.CSMTextureCacher = SearchUtilities.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent(); + starController.ProxyShadowLight = SearchUtilities.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent(); + starController.Intensity = 0.9859f; + starController.SunColor = new Color(1f, 0.8845f, 0.6677f, 1f); + + var starLightGO = GameObject.Instantiate(sun.GetComponentInChildren().gameObject); + foreach (var comp in starLightGO.GetComponents()) { - GameObject.Destroy(comp); + if (!(comp is SunLightController) && !(comp is SunLightParamUpdater) && !(comp is Light) && !(comp is Transform)) + { + GameObject.Destroy(comp); + } } + GameObject.Destroy(starLightGO.GetComponent()); + starLightGO.name = "StarLightController"; + + starLightGO.AddComponent(); + StarLightController.AddStar(starController); + + starLightGO.SetActive(true); } - GameObject.Destroy(starLightGO.GetComponent()); - starLightGO.name = "StarLightController"; - - starLightGO.AddComponent(); - StarLightController.AddStar(starController); - - starLightGO.SetActive(true); // Load all planets var toLoad = bodies.ToList(); @@ -124,7 +127,7 @@ namespace NewHorizons.Handlers // Events.FireOnNextUpdate(PlanetDestroyer.RemoveAllProxies); - if (Main.SystemDict[Main.Instance.CurrentStarSystem].Config.destroyStockPlanets) PlanetDestructionHandler.RemoveSolarSystem(); + if (Main.SystemDict[Main.Instance.CurrentStarSystem].Config.destroyStockPlanets) PlanetDestructionHandler.RemoveStockPlanets(); } public static bool LoadBody(NewHorizonsBody body, bool defaultPrimaryToSun = false) diff --git a/NewHorizons/Handlers/PlanetDestructionHandler.cs b/NewHorizons/Handlers/PlanetDestructionHandler.cs index 4d60a271..7649194a 100644 --- a/NewHorizons/Handlers/PlanetDestructionHandler.cs +++ b/NewHorizons/Handlers/PlanetDestructionHandler.cs @@ -31,12 +31,26 @@ namespace NewHorizons.Handlers "White Hole" }; + private static readonly string[] _eyeOfTheUniverseBodies = new string[] + { + "Eye Of The Universe", + "Vessel" + }; + private static readonly string[] _suspendBlacklist = new string[] { "Player_Body", "Ship_Body" }; + public static void RemoveStockPlanets() + { + if (Main.Instance.CurrentStarSystem == "EyeOfTheUniverse") + RemoveEyeOfTheUniverse(); + else + RemoveSolarSystem(); + } + public static void RemoveSolarSystem() { // Stop the sun from killing the player @@ -54,6 +68,16 @@ namespace NewHorizons.Handlers Delay.FireInNUpdates(() => { if (Locator.GetAstroObject(AstroObject.Name.Sun).gameObject.activeInHierarchy) { sunVolumes.SetActive(true); } }, 3); } + public static void RemoveEyeOfTheUniverse() + { + foreach (var name in _eyeOfTheUniverseBodies) + { + var ao = AstroObjectLocator.GetAstroObject(name); + if (ao != null) Delay.FireInNUpdates(() => RemoveBody(ao, false), 2); + else Logger.LogError($"Couldn't find [{name}]"); + } + } + public static void RemoveBody(AstroObject ao, bool delete = false, List toDestroy = null) { Logger.LogVerbose($"Removing [{ao.name}]"); diff --git a/NewHorizons/Handlers/PlanetGraphHandler.cs b/NewHorizons/Handlers/PlanetGraphHandler.cs index 20b87cb4..b31535d2 100644 --- a/NewHorizons/Handlers/PlanetGraphHandler.cs +++ b/NewHorizons/Handlers/PlanetGraphHandler.cs @@ -40,6 +40,12 @@ namespace NewHorizons.Handlers SunConfig.name = "Sun"; _rootNode = ConstructGraph(new NewHorizonsBody(SunConfig, Main.Instance), bodies); } + else if (centers.Length == 0 && Main.Instance.CurrentStarSystem == "EyeOfTheUniverse") + { + var EyeConfig = new PlanetConfig(); + EyeConfig.name = "Eye Of The Universe"; + _rootNode = ConstructGraph(new NewHorizonsBody(EyeConfig, Main.Instance), bodies); + } else { Logger.LogError($"There must be one and only one centerOfSolarSystem! Found [{centers.Length}]"); diff --git a/NewHorizons/Handlers/ShipLogHandler.cs b/NewHorizons/Handlers/ShipLogHandler.cs index 3d3a3f6b..11f5d2d2 100644 --- a/NewHorizons/Handlers/ShipLogHandler.cs +++ b/NewHorizons/Handlers/ShipLogHandler.cs @@ -108,5 +108,13 @@ namespace NewHorizons.Handlers { return _nhBodyToAstroIDs.ContainsKey(body) && _nhBodyToAstroIDs[body].Length > 0; } + + public static bool KnowsFact(string fact) + { + // Works normally in the main system, else check save data directly + var shipLogManager = Locator.GetShipLogManager(); + if (Main.Instance.CurrentStarSystem == "SolarSystem" && shipLogManager != null) return shipLogManager.IsFactRevealed(fact); + else return PlayerData._currentGameSave.shipLogFactSaves.ContainsKey(fact) && PlayerData._currentGameSave.shipLogFactSaves[fact].revealOrder > -1; + } } } diff --git a/NewHorizons/Handlers/SystemCreationHandler.cs b/NewHorizons/Handlers/SystemCreationHandler.cs index 16df0230..98e99ae3 100644 --- a/NewHorizons/Handlers/SystemCreationHandler.cs +++ b/NewHorizons/Handlers/SystemCreationHandler.cs @@ -25,6 +25,9 @@ namespace NewHorizons.Handlers SkyboxBuilder.Make(system.Config.Skybox, system.Mod); } + + if (Main.Instance.CurrentStarSystem == "EyeOfTheUniverse") return; + if (system.Config.enableTimeLoop) { var timeLoopController = new GameObject("TimeLoopController"); diff --git a/NewHorizons/Handlers/VesselCoordinatePromptHandler.cs b/NewHorizons/Handlers/VesselCoordinatePromptHandler.cs index 636de907..7cd1da78 100644 --- a/NewHorizons/Handlers/VesselCoordinatePromptHandler.cs +++ b/NewHorizons/Handlers/VesselCoordinatePromptHandler.cs @@ -43,7 +43,8 @@ namespace NewHorizons.Handlers private static void RegisterPrompt(string systemID, string fact, NomaiCoordinates coords) { var texture = MakeTexture(coords.x, coords.y, coords.z); - + + if (_textureCache == null) _textureCache = new List(); _textureCache.Add(texture); var sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(texture.width / 2f, texture.height / 2f)); @@ -61,27 +62,31 @@ namespace NewHorizons.Handlers // Gets called from the patches public static void SetPromptVisibility(bool visible) { + if (_factSystemIDPrompt == null) return; foreach (var pair in _factSystemIDPrompt) { var fact = pair.Item1; var systemID = pair.Item2; var prompt = pair.Item3; - if (visible) + if (prompt != null) { - if (Main.Instance.CurrentStarSystem != systemID && (string.IsNullOrEmpty(fact) || Locator.GetShipLogManager().IsFactRevealed(fact))) + if (visible) { - prompt.SetVisibility(true); + if (Main.Instance.CurrentStarSystem != systemID && (string.IsNullOrEmpty(fact) || ShipLogHandler.KnowsFact(fact))) + { + prompt.SetVisibility(true); + } + else + { + prompt.SetVisibility(false); + } } else { prompt.SetVisibility(false); } } - else - { - prompt.SetVisibility(false); - } } } @@ -190,12 +195,7 @@ namespace NewHorizons.Handlers } } } - - public static bool KnowsEyeCoordinates() - { - // Works normally in the main system, else check save data directly - if (Main.Instance.CurrentStarSystem == "SolarSystem") return Locator.GetShipLogManager().IsFactRevealed("OPC_EYE_COORDINATES_X1"); - else return PlayerData._currentGameSave.shipLogFactSaves.ContainsKey("OPC_EYE_COORDINATES_X1") && PlayerData._currentGameSave.shipLogFactSaves["OPC_EYE_COORDINATES_X1"].revealOrder > -1; - } + + public static bool KnowsEyeCoordinates() => ShipLogHandler.KnowsFact("OPC_EYE_COORDINATES_X1"); } } diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index aeacc748..1af5e4a7 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -4,6 +4,7 @@ using NewHorizons.Builder.Atmosphere; using NewHorizons.Builder.Body; using NewHorizons.Builder.Props; using NewHorizons.Components; +using NewHorizons.Components.Orbital; using NewHorizons.External; using NewHorizons.External.Configs; using NewHorizons.Handlers; @@ -58,7 +59,7 @@ namespace NewHorizons public static bool HasWarpDrive { get; private set; } = false; private string _defaultStarSystem = "SolarSystem"; - private string _currentStarSystem = "SolarSystem"; + internal string _currentStarSystem = "SolarSystem"; private bool _firstLoad = true; private ShipWarpController _shipWarpController; @@ -144,13 +145,15 @@ namespace NewHorizons { Config = { + destroyStockPlanets = false, + factRequiredForWarp = "OPC_EYE_COORDINATES_X1", Vessel = new StarSystemConfig.VesselModule() { coords = new StarSystemConfig.NomaiCoordinates { - x = new int[3]{ 1,5,4 }, - y = new int[4]{ 3,0,1,4 }, - z = new int[6]{ 1,2,3,0,5,4 } + x = new int[3] { 1, 5, 4 }, + y = new int[4] { 3, 0, 1, 4 }, + z = new int[6] { 1, 2, 3, 0, 5, 4 } } } } @@ -231,6 +234,7 @@ namespace NewHorizons var isTitleScreen = scene.name == "TitleScreen"; var isSolarSystem = scene.name == "SolarSystem"; var isEyeOfTheUniverse = scene.name == "EyeOfTheUniverse"; + if (isEyeOfTheUniverse) _currentStarSystem = scene.name; if (!SystemDict.ContainsKey(_currentStarSystem) || !BodyDict.ContainsKey(_currentStarSystem)) { @@ -268,24 +272,55 @@ namespace NewHorizons TitleSceneHandler.InitSubtitles(); } - if (isEyeOfTheUniverse && IsWarpingFromShip) + if (isSolarSystem && _ship == null) { - if (_ship != null) + var ship = SearchUtilities.Find("Ship_Body", false); + if (ship != null) { - SceneManager.MoveGameObjectToScene(_ship, SceneManager.GetActiveScene()); - _ship.transform.position = new Vector3(50, 0, 0); - _ship.SetActive(true); + _ship = ship.InstantiateInactive(); + _ship.name = ship.name; + _ship.AddComponent().Init(); + DontDestroyOnLoad(_ship); + } + } + + if (isEyeOfTheUniverse) + { + var eyeOfTheUniverse = SearchUtilities.Find("EyeOfTheUniverse_Body"); + var eyeSector = eyeOfTheUniverse.FindChild("Sector_EyeOfTheUniverse").GetComponent(); + var eyeAO = eyeOfTheUniverse.AddComponent(); + eyeAO._owRigidbody = eyeOfTheUniverse.GetAttachedOWRigidbody(); + eyeAO._rootSector = eyeSector; + eyeAO._gravityVolume = eyeSector.GetComponentInChildren(); + eyeAO._customName = "Eye Of The Universe"; + eyeAO._name = AstroObject.Name.Eye; + eyeAO._type = AstroObject.Type.None; + eyeAO.Register(); + + var vessel = SearchUtilities.Find("Vessel_Body"); + var vesselSector = vessel.FindChild("Sector_VesselBridge").GetComponent(); + var vesselAO = vessel.AddComponent(); + vesselAO._owRigidbody = vessel.GetAttachedOWRigidbody(); + vesselAO._primaryBody = eyeAO; + eyeAO._satellite = vesselAO; + vesselAO._rootSector = vesselSector; + vesselAO._customName = "Vessel"; + vesselAO._name = AstroObject.Name.CustomString; + vesselAO._type = AstroObject.Type.SpaceStation; + vesselAO.Register(); + + if (IsWarpingFromShip && _ship != null) + { + var eyeShip = GameObject.Instantiate(_ship); + eyeShip.name = "Ship_Body"; + _shipWarpController = eyeShip.GetComponent(); + SceneManager.MoveGameObjectToScene(eyeShip, scene); + eyeShip.SetActive(true); } } if (isSolarSystem || isEyeOfTheUniverse) { - if (_ship != null) - { - _ship = SearchUtilities.Find("Ship_Body").InstantiateInactive(); - DontDestroyOnLoad(_ship); - } - IsSystemReady = false; NewHorizonsData.Load(); @@ -300,13 +335,9 @@ namespace NewHorizons AtmosphereBuilder.Init(); BrambleNodeBuilder.Init(BodyDict[CurrentStarSystem].Select(x => x.Config).Where(x => x.Bramble?.dimension != null).ToArray()); - if (isSolarSystem) - { - PlanetCreationHandler.Init(BodyDict[CurrentStarSystem]); - - VesselWarpHandler.LoadVessel(); - SystemCreationHandler.LoadSystem(SystemDict[CurrentStarSystem]); - } + PlanetCreationHandler.Init(BodyDict[CurrentStarSystem]); + if (isSolarSystem) VesselWarpHandler.LoadVessel(); + SystemCreationHandler.LoadSystem(SystemDict[CurrentStarSystem]); LoadTranslations(ModHelper.Manifest.ModFolderPath + "Assets/", this); @@ -315,8 +346,11 @@ namespace NewHorizons { // Warp drive HasWarpDrive = StarChartHandler.CanWarp(); - _shipWarpController = SearchUtilities.Find("Ship_Body").AddComponent(); - _shipWarpController.Init(); + if (_shipWarpController == null) + { + _shipWarpController = SearchUtilities.Find("Ship_Body").AddComponent(); + _shipWarpController.Init(); + } if (HasWarpDrive == true) EnableWarpDrive(); var shouldWarpInFromShip = IsWarpingFromShip && _shipWarpController != null; @@ -380,6 +414,16 @@ namespace NewHorizons var remoteViewer = SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_NorthHemisphere/Sector_NorthPole/Sector_NorthPoleSurface/Interactables_NorthPoleSurface/LowBuilding/Prefab_NOM_RemoteViewer").GetComponent(); remoteViewer._visualSector = northPoleSurface; } + else if (isEyeOfTheUniverse) + { + Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => + { + IsSystemReady = true; + OnSystemReady(false, false); + }); + IsWarpingFromShip = false; + IsWarpingFromVessel = false; + } //Stop starfield from disappearing when there is no lights var playerBody = SearchUtilities.Find("Player_Body"); @@ -629,6 +673,8 @@ namespace NewHorizons } else { + PlayerData.SaveEyeCompletion(); + if (SystemDict[_currentStarSystem].Config.enableTimeLoop) SecondsElapsedInLoop = TimeLoop.GetSecondsElapsed(); else SecondsElapsedInLoop = -1; diff --git a/NewHorizons/Patches/EyeOfTheUniversePatches.cs b/NewHorizons/Patches/EyeOfTheUniversePatches.cs index bde6a789..00bb84d2 100644 --- a/NewHorizons/Patches/EyeOfTheUniversePatches.cs +++ b/NewHorizons/Patches/EyeOfTheUniversePatches.cs @@ -1,4 +1,4 @@ -using HarmonyLib; +using HarmonyLib; using UnityEngine; namespace NewHorizons.Patches { @@ -13,6 +13,13 @@ namespace NewHorizons.Patches return (Main.Instance.CurrentStarSystem != "EyeOfTheUniverse"); } + [HarmonyPrefix] + [HarmonyPatch(typeof(SubmitActionLoadScene), nameof(SubmitActionLoadScene.ConfirmSubmit))] + public static void SubmitActionLoadScene_ConfirmSubmit(SubmitActionLoadScene __instance) + { + if (__instance._sceneToLoad == SubmitActionLoadScene.LoadableScenes.EYE) Main.Instance._currentStarSystem = "EyeOfTheUniverse"; + } + [HarmonyPrefix] [HarmonyPatch(typeof(ShipThrusterController), nameof(ShipThrusterController.ReadTranslationalInput))] public static bool ShipThrusterController_ReadTranslationalInput(ShipThrusterController __instance, ref Vector3 __result) diff --git a/NewHorizons/Patches/LocatorPatches.cs b/NewHorizons/Patches/LocatorPatches.cs index 30c76cf2..5bc61cce 100644 --- a/NewHorizons/Patches/LocatorPatches.cs +++ b/NewHorizons/Patches/LocatorPatches.cs @@ -1,9 +1,13 @@ using HarmonyLib; +using NewHorizons.Components; + namespace NewHorizons.Patches { [HarmonyPatch] public static class LocatorPatches { + public static AstroObject _eye; + [HarmonyPrefix] [HarmonyPatch(typeof(Locator), nameof(Locator.RegisterCloakFieldController))] public static bool Locator_RegisterCloakFieldController() @@ -31,5 +35,36 @@ namespace NewHorizons.Patches { __result = __result || Components.CloakSectorController.isShipInside; } + + [HarmonyPrefix] + [HarmonyPatch(typeof(Locator), nameof(Locator.GetAstroObject))] + public static bool Locator_GetAstroObject(AstroObject.Name astroObjectName, ref AstroObject __result) + { + if (astroObjectName == AstroObject.Name.Eye && _eye != null) + { + __result = _eye; + return false; + } + return true; + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(Locator), nameof(Locator.RegisterAstroObject))] + public static bool Locator_RegisterAstroObject(AstroObject astroObject) + { + if (astroObject._name == AstroObject.Name.Eye) + { + _eye = astroObject; + return false; + } + return true; + } + + [HarmonyPostfix] + [HarmonyPatch(typeof(Locator), nameof(Locator.ClearReferences))] + public static void Locator_ClearReferences() + { + _eye = null; + } } } diff --git a/NewHorizons/Patches/NomaiCoordinatePatches.cs b/NewHorizons/Patches/NomaiCoordinatePatches.cs index 98f39af2..dc0e7bb8 100644 --- a/NewHorizons/Patches/NomaiCoordinatePatches.cs +++ b/NewHorizons/Patches/NomaiCoordinatePatches.cs @@ -48,7 +48,7 @@ namespace NewHorizons.Patches { bool canWarpToEye = __instance._coordinateInterface.CheckEyeCoordinates(); bool canWarpToStarSystem = __instance._coordinateInterface.CheckAllCoordinates(out string targetSystem); - if (slot == __instance._warpVesselSlot && __instance._hasPower && (canWarpToEye || (canWarpToStarSystem && targetSystem != Main.Instance.CurrentStarSystem)) && __instance._blackHole.GetState() == SingularityController.State.Collapsed && LoadManager.GetCurrentScene() != OWScene.EyeOfTheUniverse) + if (slot == __instance._warpVesselSlot && __instance._hasPower && ((canWarpToEye && Main.Instance.CurrentStarSystem != "EyeOfTheUniverse") || (canWarpToStarSystem && targetSystem != Main.Instance.CurrentStarSystem)) && __instance._blackHole.GetState() == SingularityController.State.Collapsed) { __instance._blackHole.Create(); RumbleManager.StartVesselWarp(); @@ -56,7 +56,10 @@ namespace NewHorizons.Patches __instance.enabled = true; Locator.GetPauseCommandListener().AddPauseCommandLock(); if (canWarpToEye || (canWarpToStarSystem && targetSystem == "EyeOfTheUniverse")) + { + Main.Instance._currentStarSystem = "EyeOfTheUniverse"; LoadManager.LoadSceneAsync(OWScene.EyeOfTheUniverse, false, LoadManager.FadeType.ToWhite); + } else if (canWarpToStarSystem) Main.Instance.ChangeCurrentStarSystem(targetSystem, false, true); __instance._blackHoleOneShot.PlayOneShot(AudioType.VesselSingularityCreate); diff --git a/NewHorizons/Patches/TranslationPatches.cs b/NewHorizons/Patches/TranslationPatches.cs index b938e8f6..87bb031f 100644 --- a/NewHorizons/Patches/TranslationPatches.cs +++ b/NewHorizons/Patches/TranslationPatches.cs @@ -1,4 +1,4 @@ -using HarmonyLib; +using HarmonyLib; using NewHorizons.Components.Orbital; using NewHorizons.Handlers; using System; @@ -16,14 +16,18 @@ namespace NewHorizons.Patches if (ao == null || ao._name != AstroObject.Name.CustomString) return true; - if (ao is NHAstroObject) + __result = string.Empty; + + if (ao is NHAstroObject nhao && nhao.HideDisplayName) return false; + + var customName = ao.GetCustomName(); + + if (!string.IsNullOrWhiteSpace(customName)) { - if ((ao as NHAstroObject).HideDisplayName) __result = ""; - else __result = TranslationHandler.GetTranslation(ao.GetCustomName(), TranslationHandler.TextType.UI); - return false; + __result = TranslationHandler.GetTranslation(customName, TranslationHandler.TextType.UI); } - return true; + return false; } [HarmonyPostfix] diff --git a/NewHorizons/Utility/AstroObjectLocator.cs b/NewHorizons/Utility/AstroObjectLocator.cs index d28b225e..e3ab7bee 100644 --- a/NewHorizons/Utility/AstroObjectLocator.cs +++ b/NewHorizons/Utility/AstroObjectLocator.cs @@ -35,6 +35,7 @@ namespace NewHorizons.Utility if (stringID.Equals("ASH_TWIN")) stringID = "TOWER_TWIN"; if (stringID.Equals("EMBER_TWIN")) stringID = "CAVE_TWIN"; if (stringID.Equals("INTERLOPER")) stringID = "COMET"; + if (stringID.Equals("EYE")) stringID = "EYE_OF_THE_UNIVERSE"; string key; if (stringID.ToUpper().Replace("_", "").Equals("MAPSATELLITE"))