diff --git a/NewHorizons/AssetBundle/translations/english.json b/NewHorizons/AssetBundle/translations/english.json index 5de572c5..ddd88a5b 100644 --- a/NewHorizons/AssetBundle/translations/english.json +++ b/NewHorizons/AssetBundle/translations/english.json @@ -1,5 +1,5 @@ { - "$schema": "https://raw.githubusercontent.com/xen-42/outer-wilds-new-horizons/master/NewHorizons/translation_schema.json", + "$schema": "https://raw.githubusercontent.com/xen-42/outer-wilds-new-horizons/main/NewHorizons/Schemas/translation_schema.json", "DialogueDictionary": { "NEW_HORIZONS_WARP_DRIVE_DIALOGUE_1" : "Your ship is now equiped with a warp drive!", @@ -11,6 +11,8 @@ "INTERSTELLAR_MODE" : "Interstellar Mode", "FREQ_STATUE" : "Nomai Statue", "FREQ_WARP_CORE" : "Anti-Graviton Flux", - "FREQ_UNKNOWN" : "???" + "FREQ_UNKNOWN" : "???", + "ENGAGE_WARP_PROMPT" : "Engage Warp To {0}", + "WARP_LOCKED" : "AUTOPILOT LOCKED TO:\n{0}" } } \ No newline at end of file diff --git a/NewHorizons/AssetBundle/translations/russian.json b/NewHorizons/AssetBundle/translations/russian.json index 55537fed..e3decd66 100644 --- a/NewHorizons/AssetBundle/translations/russian.json +++ b/NewHorizons/AssetBundle/translations/russian.json @@ -11,6 +11,8 @@ "INTERSTELLAR_MODE" : "Режим Interstellar", "FREQ_STATUE" : "Статуя Номаи", "FREQ_WARP_CORE" : "Гиперядро", - "FREQ_UNKNOWN" : "???" + "FREQ_UNKNOWN" : "???", + "ENGAGE_WARP_PROMPT" : "Телепортироваться к {0}", + "WARP_LOCKED" : "АВТОПИЛОТ ЗАКРЕПЛЁН НА:\n{0}" } -} \ No newline at end of file +} diff --git a/NewHorizons/Builder/Body/HeightMapBuilder.cs b/NewHorizons/Builder/Body/HeightMapBuilder.cs index 50d7c93a..31caa3c7 100644 --- a/NewHorizons/Builder/Body/HeightMapBuilder.cs +++ b/NewHorizons/Builder/Body/HeightMapBuilder.cs @@ -14,18 +14,33 @@ namespace NewHorizons.Builder.Body public static void Make(GameObject planetGO, Sector sector, HeightMapModule module, IModBehaviour mod, int resolution = 51) { + var deleteHeightmapFlag = false; + Texture2D heightMap, textureMap; try { - if (module.heightMap == null) heightMap = Texture2D.whiteTexture; + if (module.heightMap == null) + { + heightMap = Texture2D.whiteTexture; + } else { + // If we've loaded a new heightmap we'll delete the texture after heightMap = ImageUtilities.GetTexture(mod, module.heightMap); - // defer remove texture to next frame - Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => Object.Destroy(heightMap)); + deleteHeightmapFlag = true; } - if (module.textureMap == null) textureMap = Texture2D.whiteTexture; - else textureMap = ImageUtilities.GetTexture(mod, module.textureMap); + + if (module.textureMap == null) + { + textureMap = Texture2D.whiteTexture; + } + else + { + textureMap = ImageUtilities.GetTexture(mod, module.textureMap); + } + + // If the texturemap is the same as the heightmap don't delete it #176 + if (textureMap == heightMap) deleteHeightmapFlag = false; } catch (Exception e) { @@ -45,11 +60,9 @@ namespace NewHorizons.Builder.Body cubeSphere.GetComponent().mesh = mesh; if (PlanetShader == null) PlanetShader = Main.NHAssetBundle.LoadAsset("Assets/Shaders/SphereTextureWrapper.shader"); - //if (PlanetShader == null) PlanetShader = Shader.Find("Standard"); var cubeSphereMR = cubeSphere.AddComponent(); - var material = cubeSphereMR.material; - material = new Material(PlanetShader); + var material = new Material(PlanetShader); cubeSphereMR.material = material; material.name = textureMap.name; material.mainTexture = textureMap; @@ -65,6 +78,9 @@ namespace NewHorizons.Builder.Body cubeSphere.transform.position = planetGO.transform.position; cubeSphere.SetActive(true); + + // Now that we've made the mesh we can delete the heightmap texture + if (deleteHeightmapFlag) ImageUtilities.DeleteTexture(mod, module.heightMap, heightMap); } } } diff --git a/NewHorizons/Builder/Body/StarBuilder.cs b/NewHorizons/Builder/Body/StarBuilder.cs index d50ae5c7..b722e6fe 100644 --- a/NewHorizons/Builder/Body/StarBuilder.cs +++ b/NewHorizons/Builder/Body/StarBuilder.cs @@ -73,10 +73,18 @@ namespace NewHorizons.Builder.Body deathVolume.transform.localPosition = Vector3.zero; deathVolume.transform.localScale = Vector3.one; deathVolume.GetComponent().radius = 1f; - deathVolume.GetComponent()._onlyAffectsPlayerAndShip = false; + deathVolume.GetComponent()._onlyAffectsPlayerAndShip = true; deathVolume.GetComponent()._shrinkBodies = true; deathVolume.name = "DestructionVolume"; + var planetDestructionVolume = Object.Instantiate(deathVolume, starGO.transform); + planetDestructionVolume.transform.localPosition = Vector3.zero; + planetDestructionVolume.transform.localScale = Vector3.one; + planetDestructionVolume.GetComponent().radius = 0.75f; + planetDestructionVolume.GetComponent()._onlyAffectsPlayerAndShip = false; + planetDestructionVolume.GetComponent()._shrinkBodies = true; + planetDestructionVolume.name = "PlanetDestructionVolume"; + Light ambientLight = ambientLightGO.GetComponent(); var sunLight = new GameObject("StarLight"); diff --git a/NewHorizons/Builder/Orbital/OrbitlineBuilder.cs b/NewHorizons/Builder/Orbital/OrbitlineBuilder.cs index 4cd2b3bf..e6ad0a53 100644 --- a/NewHorizons/Builder/Orbital/OrbitlineBuilder.cs +++ b/NewHorizons/Builder/Orbital/OrbitlineBuilder.cs @@ -45,15 +45,7 @@ namespace NewHorizons.Builder.Orbital { orbitLine = orbitGO.AddComponent(); - var a = astroObject.semiMajorAxis; - var e = astroObject.eccentricity; - var b = a * Mathf.Sqrt(1f - (e * e)); - var l = astroObject.longitudeOfAscendingNode; - var p = astroObject.argumentOfPeriapsis; - var i = astroObject.inclination; - - (orbitLine as NHOrbitLine).SemiMajorAxis = a * OrbitalParameters.Rotate(Vector3.left, l, i, p); - (orbitLine as NHOrbitLine).SemiMinorAxis = b * OrbitalParameters.Rotate(Vector3.forward, l, i, p); + (orbitLine as NHOrbitLine).SetFromParameters(astroObject); } var color = Color.white; diff --git a/NewHorizons/Builder/Props/NomaiTextBuilder.cs b/NewHorizons/Builder/Props/NomaiTextBuilder.cs index cd05045e..d0267e5a 100644 --- a/NewHorizons/Builder/Props/NomaiTextBuilder.cs +++ b/NewHorizons/Builder/Props/NomaiTextBuilder.cs @@ -19,6 +19,7 @@ namespace NewHorizons.Builder.Props private static GameObject _computerPrefab; private static GameObject _cairnPrefab; private static GameObject _recorderPrefab; + private static GameObject _preCrashRecorderPrefab; private static Dictionary arcInfoToCorrespondingSpawnedGameObject = new Dictionary(); public static GameObject GetSpawnedGameObjectByNomaiTextArcInfo(PropModule.NomaiTextArcInfo arc) @@ -81,6 +82,10 @@ namespace NewHorizons.Builder.Props _recorderPrefab = SearchUtilities.Find("Comet_Body/Prefab_NOM_Shuttle/Sector_NomaiShuttleInterior/Interactibles_NomaiShuttleInterior/Prefab_NOM_Recorder").InstantiateInactive(); _recorderPrefab.name = "Prefab_NOM_Recorder"; _recorderPrefab.transform.rotation = Quaternion.identity; + + _preCrashRecorderPrefab = SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_EscapePodCrashSite/Sector_CrashFragment/Interactables_CrashFragment/Prefab_NOM_Recorder").InstantiateInactive(); + _preCrashRecorderPrefab.name = "Prefab_NOM_Recorder_Vessel"; + _preCrashRecorderPrefab.transform.rotation = Quaternion.identity; } public static void Make(GameObject planetGO, Sector sector, PropModule.NomaiTextInfo info, IModBehaviour mod) @@ -242,9 +247,10 @@ namespace NewHorizons.Builder.Props conversationInfoToCorrespondingSpawnedGameObject[info] = cairnObject; break; } + case PropModule.NomaiTextInfo.NomaiTextType.PreCrashRecorder: case PropModule.NomaiTextInfo.NomaiTextType.Recorder: { - var recorderObject = _recorderPrefab.InstantiateInactive(); + var recorderObject = (info.type == PropModule.NomaiTextInfo.NomaiTextType.PreCrashRecorder? _preCrashRecorderPrefab : _recorderPrefab).InstantiateInactive(); recorderObject.transform.parent = sector?.transform ?? planetGO.transform; recorderObject.transform.position = planetGO.transform.TransformPoint(info?.position ?? Vector3.zero); diff --git a/NewHorizons/Builder/Props/ProjectionBuilder.cs b/NewHorizons/Builder/Props/ProjectionBuilder.cs index 4a9f1bb7..05eff66f 100644 --- a/NewHorizons/Builder/Props/ProjectionBuilder.cs +++ b/NewHorizons/Builder/Props/ProjectionBuilder.cs @@ -96,7 +96,7 @@ namespace NewHorizons.Builder.Props imageLoader.imageLoadedEvent.AddListener( (Texture2D tex, int index) => { - slideCollection.slides[index].textureOverride = ImageUtilities.Invert(tex); + slideCollection.slides[index]._image = ImageUtilities.Invert(tex); // Track the first 15 to put on the slide reel object if (index < 15) @@ -176,7 +176,7 @@ namespace NewHorizons.Builder.Props slideCollection.slides[i] = slide; } - imageLoader.imageLoadedEvent.AddListener((Texture2D tex, int index) => { slideCollection.slides[index].textureOverride = ImageUtilities.Invert(tex); }); + imageLoader.imageLoadedEvent.AddListener((Texture2D tex, int index) => { slideCollection.slides[index]._image = ImageUtilities.Invert(tex); }); slideCollectionContainer.slideCollection = slideCollection; @@ -185,8 +185,8 @@ namespace NewHorizons.Builder.Props // Change the picture on the lens var lens = projectorObj.transform.Find("Spotlight/Prop_IP_SingleSlideProjector/Projector_Lens").GetComponent(); - lens.materials[1].mainTexture = slideCollection.slides[0]._textureOverride; - lens.materials[1].SetTexture(EmissionMap, slideCollection.slides[0]._textureOverride); + lens.materials[1].mainTexture = slideCollection.slides[0]._image; + lens.materials[1].SetTexture(EmissionMap, slideCollection.slides[0]._image); projectorObj.SetActive(true); } @@ -224,7 +224,7 @@ namespace NewHorizons.Builder.Props slideCollection.slides[i] = slide; } - imageLoader.imageLoadedEvent.AddListener((Texture2D tex, int index) => { slideCollection.slides[index].textureOverride = tex; }); + imageLoader.imageLoadedEvent.AddListener((Texture2D tex, int index) => { slideCollection.slides[index]._image = tex; }); // attatch a component to store all the data for the slides that play when a vision torch scans this target @@ -298,7 +298,7 @@ namespace NewHorizons.Builder.Props imageLoader.imageLoadedEvent.AddListener( (Texture2D tex, int index) => { - slideCollection.slides[index].textureOverride = tex; + slideCollection.slides[index]._image = tex; displaySlidesLoaded++; // threading moment if (displaySlidesLoaded >= slides.Length) @@ -380,7 +380,7 @@ namespace NewHorizons.Builder.Props public class VisionTorchTarget : MonoBehaviour { public MindSlideCollection slideCollection; - public SlideCollectionContainer slideCollectionContainer; + public SlideCollectionContainer slideCollectionContainer; public OWEvent.OWCallback onSlidesComplete; } } diff --git a/NewHorizons/Builder/Props/TornadoBuilder.cs b/NewHorizons/Builder/Props/TornadoBuilder.cs index 34c21494..843923c9 100644 --- a/NewHorizons/Builder/Props/TornadoBuilder.cs +++ b/NewHorizons/Builder/Props/TornadoBuilder.cs @@ -116,7 +116,9 @@ namespace NewHorizons.Builder.Props tornadoGO.transform.localScale = Vector3.one * scale; // Resize the distance it can be heard from to match roughly with the size - audioSource.maxDistance = 100 * scale; + var maxDistance = info.audioDistance == 0 ? 10 * scale : info.audioDistance; + audioSource.maxDistance = maxDistance; + audioSource.minDistance = maxDistance / 10f; var controller = tornadoGO.GetComponent(); controller.SetSector(sector); diff --git a/NewHorizons/Components/CloakSectorController.cs b/NewHorizons/Components/CloakSectorController.cs index e7d8e9b0..e7322cdd 100644 --- a/NewHorizons/Components/CloakSectorController.cs +++ b/NewHorizons/Components/CloakSectorController.cs @@ -12,9 +12,9 @@ namespace NewHorizons.Components private List _renderers = null; - internal static bool isPlayerInside = false; - internal static bool isProbeInside = false; - internal static bool isShipInside = false; + public static bool isPlayerInside = false; + public static bool isProbeInside = false; + public static bool isShipInside = false; public void Init(CloakFieldController cloak, GameObject root) { diff --git a/NewHorizons/Components/Orbital/NHOrbitLine.cs b/NewHorizons/Components/Orbital/NHOrbitLine.cs index bf894e77..f58d5e92 100644 --- a/NewHorizons/Components/Orbital/NHOrbitLine.cs +++ b/NewHorizons/Components/Orbital/NHOrbitLine.cs @@ -1,20 +1,17 @@ -using System; +using System; using UnityEngine; using Logger = NewHorizons.Utility.Logger; namespace NewHorizons.Components.Orbital { public class NHOrbitLine : OrbitLine { - public Vector3 SemiMajorAxis { get; set; } - public Vector3 SemiMinorAxis { get; set; } + private Vector3 _semiMajorAxis; + private Vector3 _semiMinorAxis; private Vector3 _upAxis; private float _fociDistance; private Vector3[] _verts; - private float semiMajorAxis; - private float semiMinorAxis; - public override void InitializeLineRenderer() { base.GetComponent().positionCount = this._numVerts; @@ -36,10 +33,10 @@ namespace NewHorizons.Components.Orbital { base.Start(); - var a = SemiMajorAxis.magnitude; - var b = SemiMinorAxis.magnitude; + var a = _semiMajorAxis.magnitude; + var b = _semiMinorAxis.magnitude; - _upAxis = Vector3.Cross(SemiMajorAxis.normalized, SemiMinorAxis.normalized); + _upAxis = Vector3.Cross(_semiMajorAxis.normalized, _semiMinorAxis.normalized); _fociDistance = Mathf.Sqrt(a * a - b * b); if (float.IsNaN(_fociDistance)) _fociDistance = 0f; @@ -48,9 +45,6 @@ namespace NewHorizons.Components.Orbital transform.localRotation = Quaternion.Euler(270, 90, 0); - semiMajorAxis = SemiMajorAxis.magnitude; - semiMinorAxis = SemiMinorAxis.magnitude; - base.enabled = false; } @@ -67,22 +61,22 @@ namespace NewHorizons.Components.Orbital return; } - Vector3 origin = primary.transform.position + SemiMajorAxis.normalized * _fociDistance; + Vector3 origin = primary.transform.position + _semiMajorAxis.normalized * _fociDistance; - float num = CalcProjectedAngleToCenter(origin, SemiMajorAxis, SemiMinorAxis, _astroObject.transform.position); + float num = CalcProjectedAngleToCenter(origin, _semiMajorAxis, _semiMinorAxis, _astroObject.transform.position); for (int i = 0; i < _numVerts; i++) { var stepSize = 2f * Mathf.PI / (float)(_numVerts - 1); float f = num + stepSize * i; - _verts[i] = SemiMajorAxis * Mathf.Cos(f) + SemiMinorAxis * Mathf.Sin(f); + _verts[i] = _semiMajorAxis * Mathf.Cos(f) + _semiMinorAxis * Mathf.Sin(f); } _lineRenderer.SetPositions(_verts); transform.position = origin; transform.rotation = Quaternion.Euler(0, 0, 0); //Quaternion.LookRotation(-SemiMajorAxis, _upAxis); - float num2 = DistanceToEllipticalOrbitLine(origin, SemiMajorAxis, SemiMinorAxis, _upAxis, Locator.GetActiveCamera().transform.position); + float num2 = DistanceToEllipticalOrbitLine(origin, _semiMajorAxis, _semiMinorAxis, _upAxis, Locator.GetActiveCamera().transform.position); float widthMultiplier = Mathf.Min(num2 * (_lineWidth / 1000f), _maxLineWidth); float num3 = _fade ? (1f - Mathf.Clamp01((num2 - _fadeStartDist) / (_fadeEndDist - _fadeStartDist))) : 1f; @@ -96,6 +90,19 @@ namespace NewHorizons.Components.Orbital } } + public void SetFromParameters(IOrbitalParameters parameters) + { + var a = parameters.semiMajorAxis; + var e = parameters.eccentricity; + var b = a * Mathf.Sqrt(1f - (e * e)); + var l = parameters.longitudeOfAscendingNode; + var p = parameters.argumentOfPeriapsis; + var i = parameters.inclination; + + _semiMajorAxis = a * OrbitalParameters.Rotate(Vector3.left, l, i, p); + _semiMinorAxis = b * OrbitalParameters.Rotate(Vector3.forward, l, i, p); + } + private float CalcProjectedAngleToCenter(Vector3 foci, Vector3 semiMajorAxis, Vector3 semiMinorAxis, Vector3 point) { Vector3 lhs = point - foci; @@ -107,7 +114,7 @@ namespace NewHorizons.Components.Orbital private float DistanceToEllipticalOrbitLine(Vector3 foci, Vector3 semiMajorAxis, Vector3 semiMinorAxis, Vector3 upAxis, Vector3 point) { float f = CalcProjectedAngleToCenter(foci, semiMajorAxis, semiMinorAxis, point); - Vector3 b = foci + SemiMajorAxis * Mathf.Cos(f) + SemiMinorAxis * Mathf.Sin(f); + Vector3 b = foci + _semiMajorAxis * Mathf.Cos(f) + _semiMinorAxis * Mathf.Sin(f); return Vector3.Distance(point, b); } } diff --git a/NewHorizons/Components/QuantumPlanet.cs b/NewHorizons/Components/QuantumPlanet.cs index 68763c74..58c7d716 100644 --- a/NewHorizons/Components/QuantumPlanet.cs +++ b/NewHorizons/Components/QuantumPlanet.cs @@ -1,4 +1,4 @@ -using NewHorizons.Builder.General; +using NewHorizons.Builder.General; using NewHorizons.Builder.Orbital; using NewHorizons.Components.Orbital; using NewHorizons.External.Modules; @@ -20,6 +20,9 @@ namespace NewHorizons.Components private ConstantForceDetector _detector; private AlignWithTargetBody _alignment; private OWRigidbody _rb; + private OrbitLine _orbitLine; + + public int CurrentIndex { get { return _currentIndex; } } public override void Awake() { @@ -29,6 +32,7 @@ namespace NewHorizons.Components _detector = GetComponentInChildren(); _alignment = GetComponent(); _rb = GetComponent(); + _orbitLine = GetComponent(); GlobalMessenger.AddListener("PlayerBlink", new Callback(OnPlayerBlink)); @@ -141,6 +145,16 @@ namespace NewHorizons.Components } _rb.SetVelocity(orbitalParameters.InitialVelocity + primaryBody.GetAttachedOWRigidbody().GetVelocity()); + + if (_orbitLine is NHOrbitLine nhOrbitLine) + { + nhOrbitLine.SetFromParameters(orbitalParameters); + } + + if (_orbitLine is TrackingOrbitLine trackingOrbitLine) + { + trackingOrbitLine.Reset(); + } } private void OnPlayerBlink() diff --git a/NewHorizons/Components/ShipLogStarChartMode.cs b/NewHorizons/Components/ShipLogStarChartMode.cs index 70a6e48f..1b25d99b 100644 --- a/NewHorizons/Components/ShipLogStarChartMode.cs +++ b/NewHorizons/Components/ShipLogStarChartMode.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; using UnityEngine; +using UnityEngine.UI; using Logger = NewHorizons.Utility.Logger; namespace NewHorizons.Components { @@ -105,12 +106,15 @@ namespace NewHorizons.Components } var newCard = GameObject.Instantiate(_cardTemplate, parent); - var textComponent = newCard.transform.Find("EntryCardRoot/NameBackground/Name").GetComponent(); + var textComponent = newCard.transform.Find("EntryCardRoot/NameBackground/Name").GetComponent(); var name = UniqueIDToName(uniqueID); textComponent.text = name; if (name.Length > 17) textComponent.fontSize = 10; + // Do it next frame + var fontPath = "Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/ShipLogPivot/ShipLogCanvas/DetectiveMode/ScaleRoot/PanRoot/TH_VILLAGE/EntryCardRoot/NameBackground/Name"; + Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => textComponent.font = SearchUtilities.Find(fontPath).GetComponent().font); newCard.SetActive(true); newCard.transform.name = uniqueID; @@ -273,16 +277,20 @@ namespace NewHorizons.Components private void SetWarpTarget(ShipLogEntryCard shipLogEntryCard) { RemoveWarpTarget(false); - _oneShotSource.PlayOneShot(global::AudioType.ShipLogUnmarkLocation, 1f); + _oneShotSource.PlayOneShot(AudioType.ShipLogUnmarkLocation, 1f); _target = shipLogEntryCard; _target.SetMarkedOnHUD(true); Locator._rfTracker.UntargetReferenceFrame(); - GlobalMessenger.FireEvent("UntargetReferenceFrame"); - _warpNotificationData = new NotificationData($"AUTOPILOT LOCKED TO:\n{UniqueIDToName(shipLogEntryCard.name).ToUpper()}"); + + var name = UniqueIDToName(shipLogEntryCard.name); + + var warpNotificationDataText = TranslationHandler.GetTranslation("WARP_LOCKED", TranslationHandler.TextType.UI).Replace("{0}", name.ToUpper()); + _warpNotificationData = new NotificationData(warpNotificationDataText); NotificationManager.SharedInstance.PostNotification(_warpNotificationData, true); - _warpPrompt.SetText($" Engage Warp To {UniqueIDToName(shipLogEntryCard.name)}"); + var warpPromptText = " " + TranslationHandler.GetTranslation("ENGAGE_WARP_PROMPT", TranslationHandler.TextType.UI).Replace("{0}", name); + _warpPrompt.SetText(warpPromptText); } private void RemoveWarpTarget(bool playSound = false) diff --git a/NewHorizons/External/Configs/StarSystemConfig.cs b/NewHorizons/External/Configs/StarSystemConfig.cs index 86cc9c2b..5d5cdc75 100644 --- a/NewHorizons/External/Configs/StarSystemConfig.cs +++ b/NewHorizons/External/Configs/StarSystemConfig.cs @@ -14,11 +14,6 @@ namespace NewHorizons.External.Configs /// public bool canEnterViaWarpDrive = true; - /// - /// [DEPRECATED] Not implemented - /// - public NomaiCoordinates coords; - /// /// Do you want a clean slate for this star system? Or will it be a modified version of the original. /// diff --git a/NewHorizons/External/Modules/PropModule.cs b/NewHorizons/External/Modules/PropModule.cs index b00e244a..5f50a8ec 100644 --- a/NewHorizons/External/Modules/PropModule.cs +++ b/NewHorizons/External/Modules/PropModule.cs @@ -5,6 +5,7 @@ using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using Newtonsoft.Json; using Newtonsoft.Json.Converters; +using System; namespace NewHorizons.External.Modules { @@ -205,10 +206,7 @@ namespace NewHorizons.External.Modules [EnumMember(Value = @"hurricane")] Hurricane = 2 } - /// - /// [DEPRECATED] Should this tornado shoot you down instead of up? - /// - public bool downwards; + [Obsolete("Downwards is deprecated. Use Type instead.")] public bool downwards; /// /// Alternative to setting the position. Will choose a random place at this elevation. @@ -250,6 +248,11 @@ namespace NewHorizons.External.Modules /// 0.1. /// public float wanderRate; + + /// + /// The maximum distance at which you'll hear the sounds of the cyclone. If not set it will scale relative to the size of the cyclone. + /// + public float audioDistance; } [JsonObject] @@ -421,7 +424,9 @@ namespace NewHorizons.External.Modules [EnumMember(Value = @"cairn")] Cairn = 3, - [EnumMember(Value = @"recorder")] Recorder = 4 + [EnumMember(Value = @"recorder")] Recorder = 4, + + [EnumMember(Value = @"preCrashRecorder")] PreCrashRecorder = 5 } /// diff --git a/NewHorizons/Handlers/TranslationHandler.cs b/NewHorizons/Handlers/TranslationHandler.cs index 9987fb96..634bbe4d 100644 --- a/NewHorizons/Handlers/TranslationHandler.cs +++ b/NewHorizons/Handlers/TranslationHandler.cs @@ -1,4 +1,4 @@ -using NewHorizons.External.Configs; +using NewHorizons.External.Configs; using System; using System.Collections.Generic; using System.Linq; @@ -18,6 +18,11 @@ 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; @@ -34,6 +39,7 @@ namespace NewHorizons.Handlers dictionary = _uiTranslationDictionary; break; default: + translatedLanguage = TextTranslation.Language.UNKNOWN; return text; } @@ -41,6 +47,7 @@ namespace NewHorizons.Handlers { if (table.TryGetValue(text, out var translatedText)) { + translatedLanguage = language; return translatedText; } } @@ -51,11 +58,13 @@ namespace NewHorizons.Handlers if (englishTable.TryGetValue(text, out var englishText)) { + translatedLanguage = TextTranslation.Language.ENGLISH; return englishText; } } // Default to the key + translatedLanguage = TextTranslation.Language.UNKNOWN; return text; } diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index 9309b9a5..92988022 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -81,6 +81,9 @@ namespace NewHorizons _defaultSystemOverride = config.GetSettingsValue("Default System Override"); + // Else it doesn't get set idk + if (SceneManager.GetActiveScene().name == "TitleScreen") _currentStarSystem = _defaultSystemOverride; + var wasUsingCustomTitleScreen = _useCustomTitleScreen; _useCustomTitleScreen = config.GetSettingsValue("Custom title screen"); // Reload the title screen if this was updated on it diff --git a/NewHorizons/Patches/AutoSlideProjectorPatches.cs b/NewHorizons/Patches/AutoSlideProjectorPatches.cs new file mode 100644 index 00000000..7d045635 --- /dev/null +++ b/NewHorizons/Patches/AutoSlideProjectorPatches.cs @@ -0,0 +1,14 @@ +using HarmonyLib; + +namespace NewHorizons.Patches; + +[HarmonyPatch] +public class AutoSlideProjectorPatches +{ + [HarmonyPostfix] + [HarmonyPatch(typeof(AutoSlideProjector), nameof(AutoSlideProjector.Play))] + public static void AutoSlideProjector_Play(ref SlideCollectionContainer ____slideCollectionItem) + { + ____slideCollectionItem.enabled = true; + } +} diff --git a/NewHorizons/Patches/DestructionVolumePatches.cs b/NewHorizons/Patches/DestructionVolumePatches.cs new file mode 100644 index 00000000..23221daa --- /dev/null +++ b/NewHorizons/Patches/DestructionVolumePatches.cs @@ -0,0 +1,35 @@ +using HarmonyLib; +using NewHorizons.Components; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace NewHorizons.Patches +{ + [HarmonyPatch] + public static class DestructionVolumePatches + { + [HarmonyPrefix] + [HarmonyPatch(typeof(DestructionVolume), nameof(DestructionVolume.Vanish))] + public static bool DestructionVolume_Vanish(OWRigidbody __0) + { + var quantumPlanet = __0.gameObject.GetComponent(); + + if (quantumPlanet == null) return true; + + // Allow it to vanish if this is the only state + if (quantumPlanet.states.Count <= 1) return true; + + // Force it to change states but if it can't, remove it + var oldIndex = quantumPlanet.CurrentIndex; + quantumPlanet.ChangeQuantumState(true); + if (quantumPlanet.CurrentIndex == oldIndex) return true; + + quantumPlanet.states.RemoveAt(oldIndex); + + return false; + } + } +} diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index 00b268c8..fff468c4 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -1018,14 +1018,16 @@ "Scroll", "Computer", "Cairn", - "Recorder" + "Recorder", + "PreCrashRecorder" ], "enum": [ "wall", "scroll", "computer", "cairn", - "recorder" + "recorder", + "preCrashRecorder" ] }, "RaftInfo": { @@ -1238,10 +1240,6 @@ "type": "object", "additionalProperties": false, "properties": { - "downwards": { - "type": "boolean", - "description": "[DEPRECATED] Should this tornado shoot you down instead of up?" - }, "elevation": { "type": "number", "description": "Alternative to setting the position. Will choose a random place at this elevation.", @@ -1281,6 +1279,11 @@ "type": "number", "description": "The rate at which the tornado will wander around the planet. Set to 0 for it to be stationary. Should be around\n0.1.", "format": "float" + }, + "audioDistance": { + "type": "number", + "description": "The maximum distance at which you'll hear the sounds of the cyclone. If not set it will scale relative to the size of the cyclone.", + "format": "float" } } }, diff --git a/NewHorizons/Schemas/star_system_schema.json b/NewHorizons/Schemas/star_system_schema.json index 1a4076a5..1e937325 100644 --- a/NewHorizons/Schemas/star_system_schema.json +++ b/NewHorizons/Schemas/star_system_schema.json @@ -9,10 +9,6 @@ "type": "boolean", "description": "Whether this system can be warped to via the warp drive" }, - "coords": { - "description": "[DEPRECATED] Not implemented", - "$ref": "#/definitions/NomaiCoordinates" - }, "destroyStockPlanets": { "type": "boolean", "description": "Do you want a clean slate for this star system? Or will it be a modified version of the original." @@ -52,33 +48,6 @@ } }, "definitions": { - "NomaiCoordinates": { - "type": "object", - "additionalProperties": false, - "properties": { - "x": { - "type": "array", - "items": { - "type": "integer", - "format": "int32" - } - }, - "y": { - "type": "array", - "items": { - "type": "integer", - "format": "int32" - } - }, - "z": { - "type": "array", - "items": { - "type": "integer", - "format": "int32" - } - } - } - }, "SkyboxConfig": { "type": "object", "additionalProperties": false, diff --git a/NewHorizons/Utility/ImageUtilities.cs b/NewHorizons/Utility/ImageUtilities.cs index ffde01f1..67985004 100644 --- a/NewHorizons/Utility/ImageUtilities.cs +++ b/NewHorizons/Utility/ImageUtilities.cs @@ -42,9 +42,24 @@ namespace NewHorizons.Utility } } + public static void DeleteTexture(IModBehaviour mod, string filename, Texture2D texture) + { + var path = mod.ModHelper.Manifest.ModFolderPath + filename; + if (_loadedTextures.ContainsKey(path)) + { + if (_loadedTextures[path] == texture) + { + _loadedTextures.Remove(path); + UnityEngine.Object.Destroy(texture); + } + } + + UnityEngine.Object.Destroy(texture); + } + public static void ClearCache() { - Logger.Log("Cleaing image cache"); + Logger.Log("Clearing image cache"); foreach (var texture in _loadedTextures.Values) { diff --git a/NewHorizons/manifest.json b/NewHorizons/manifest.json index 45398176..129a60c2 100644 --- a/NewHorizons/manifest.json +++ b/NewHorizons/manifest.json @@ -3,7 +3,7 @@ "author": "xen, Bwc9876, & Book", "name": "New Horizons", "uniqueName": "xen.NewHorizons", - "version": "1.2.4", + "version": "1.2.5", "owmlVersion": "2.3.3", "conflicts": [ "Raicuparta.QuantumSpaceBuddies", "Vesper.AutoResume", "PacificEngine.OW_Randomizer" ], "pathsToPreserve": [ "planets", "systems", "translations" ]