Merge branch 'dev' into eye-of-the-universe

This commit is contained in:
Noah Pilarski 2022-09-10 15:13:36 -04:00
commit e688939e8c
16 changed files with 156 additions and 37 deletions

View File

@ -17,6 +17,11 @@
"RICH_PRESENCE_WARPING": "Warping to {0}.", "RICH_PRESENCE_WARPING": "Warping to {0}.",
"OUTDATED_VERSION_WARNING": "WARNING\n\nNew Horizons only works on version {0} or higher. You're on version {1}.\n\nPlease update your game or uninstall NH.", "OUTDATED_VERSION_WARNING": "WARNING\n\nNew Horizons only works on version {0} or higher. You're on version {1}.\n\nPlease update your game or uninstall NH.",
"JSON_FAILED_TO_LOAD": "Invalid file(s): {0}", "JSON_FAILED_TO_LOAD": "Invalid file(s): {0}",
"DEBUG_RAYCAST": "Raycast",
"DEBUG_PLACE": "Place Object",
"DEBUG_PLACE_TEXT": "Place Nomai Text",
"DEBUG_UNDO": "Undo",
"DEBUG_REDO": "Redo",
"Vessel": "Vessel", "Vessel": "Vessel",
"VESSEL": "VESSEL" "VESSEL": "VESSEL"
}, },

View File

@ -120,10 +120,13 @@ namespace NewHorizons.Builder.Body
} }
} }
if (body.Config.Ring != null) if (body.Config.Rings != null)
{ {
RingBuilder.MakeRingGraphics(proxy, null, body.Config.Ring, body.Mod); foreach (var ring in body.Config.Rings)
if (realSize < body.Config.Ring.outerRadius) realSize = body.Config.Ring.outerRadius; {
RingBuilder.MakeRingGraphics(proxy, null, ring, body.Mod);
if (realSize < ring.outerRadius) realSize = ring.outerRadius;
}
} }
Renderer starAtmosphere = null; Renderer starAtmosphere = null;

View File

@ -73,7 +73,7 @@ namespace NewHorizons.Builder.Body
return null; return null;
} }
var ringGO = new GameObject("Ring"); var ringGO = new GameObject(!string.IsNullOrEmpty(ring.rename) ? ring.rename : "Ring");
ringGO.transform.parent = sector?.transform ?? rootObject.transform; ringGO.transform.parent = sector?.transform ?? rootObject.transform;
ringGO.transform.position = rootObject.transform.position; ringGO.transform.position = rootObject.transform.position;
ringGO.transform.rotation = rootObject.transform.rotation; ringGO.transform.rotation = rootObject.transform.rotation;

View File

@ -207,19 +207,21 @@ namespace NewHorizons.Builder.Props
var name = xmlNode2.SelectSingleNode("Name").InnerText; var name = xmlNode2.SelectSingleNode("Name").InnerText;
XmlNodeList xmlText = xmlNode2.SelectNodes("Dialogue/Page"); XmlNodeList xmlText = xmlNode2.SelectNodes("Dialogue/Page");
foreach (object Page in xmlText) foreach (object page in xmlText)
{ {
XmlNode pageData = (XmlNode)Page; XmlNode pageData = (XmlNode)page;
var text = pageData.InnerText; var text = pageData.InnerText;
TranslationHandler.AddDialogue(text, name); // The text is trimmed in DialogueText constructor (_listTextBlocks), so we also need to trim it for the key
TranslationHandler.AddDialogue(text, true, name);
} }
xmlText = xmlNode2.SelectNodes("DialogueOptionsList/DialogueOption/Text"); xmlText = xmlNode2.SelectNodes("DialogueOptionsList/DialogueOption/Text");
foreach (object Page in xmlText) foreach (object option in xmlText)
{ {
XmlNode pageData = (XmlNode)Page; XmlNode optionData = (XmlNode)option;
var text = pageData.InnerText; var text = optionData.InnerText;
TranslationHandler.AddDialogue(text, characterName, name); // The text is trimmed in CharacterDialogueTree.LoadXml, so we also need to trim it for the key
TranslationHandler.AddDialogue(text, true, characterName, name);
} }
} }
} }

View File

@ -67,6 +67,10 @@ namespace NewHorizons.External.Configs
[Obsolete("Signal is deprecated, please use Props->signals")] [Obsolete("Signal is deprecated, please use Props->signals")]
public SignalModule Signal; public SignalModule Signal;
[Obsolete("Ring is deprecated, please use Rings")]
public RingModule Ring;
#endregion Obsolete #endregion Obsolete
/// <summary> /// <summary>
@ -135,9 +139,9 @@ namespace NewHorizons.External.Configs
public string[] removeChildren; public string[] removeChildren;
/// <summary> /// <summary>
/// Creates a ring around the planet /// Create rings around the planet
/// </summary> /// </summary>
public RingModule Ring; public RingModule[] Rings;
/// <summary> /// <summary>
/// Add sand to this planet /// Add sand to this planet
@ -401,10 +405,20 @@ namespace NewHorizons.External.Configs
if (!string.IsNullOrEmpty(Cloak.audioFilePath)) Cloak.audio = Cloak.audioFilePath; if (!string.IsNullOrEmpty(Cloak.audioFilePath)) Cloak.audio = Cloak.audioFilePath;
} }
// Rings are no longer variable size module // Ring is now a list so you can have many per planet
if (Ring != null) if (Ring != null)
{ {
if (Ring.curve != null) Ring.scaleCurve = Ring.curve; if (Rings == null) Rings = new RingModule[0];
Rings = Rings.Append(Ring).ToArray();
}
// Rings are no longer variable size module
if (Rings != null)
{
foreach (var ring in Rings)
{
if (ring.curve != null) ring.scaleCurve = ring.curve;
}
} }
} }
} }

View File

@ -62,5 +62,10 @@ namespace NewHorizons.External.Modules
/// Fade rings in/out over time. Optional. Value between 0-1, time is in minutes. /// Fade rings in/out over time. Optional. Value between 0-1, time is in minutes.
/// </summary> /// </summary>
public TimeValuePair[] opacityCurve; public TimeValuePair[] opacityCurve;
/// <summary>
/// An optional rename of this object
/// </summary>
public string rename;
} }
} }

View File

@ -563,9 +563,12 @@ namespace NewHorizons.Handlers
} }
} }
if (body.Config.Ring != null) if (body.Config.Rings != null)
{ {
RingBuilder.Make(go, sector, body.Config.Ring, body.Mod); foreach (var ring in body.Config.Rings)
{
RingBuilder.Make(go, sector, ring, body.Mod);
}
} }
if (body.Config.AsteroidBelt != null) if (body.Config.AsteroidBelt != null)

View File

@ -107,13 +107,16 @@ namespace NewHorizons.Handlers
} }
pivot.name = "Pivot"; pivot.name = "Pivot";
if (body.Config.Ring != null) if (body.Config.Rings != null && body.Config.Rings.Length > 0)
{ {
RingModule newRing = new RingModule(); foreach (var ring in body.Config.Rings)
newRing.innerRadius = size * 1.2f; {
newRing.outerRadius = size * 2f; RingModule newRing = new RingModule();
newRing.texture = body.Config.Ring.texture; newRing.innerRadius = size * 1.2f;
var ring = RingBuilder.Make(titleScreenGO, null, newRing, body.Mod); newRing.outerRadius = size * 2f;
newRing.texture = ring.texture;
RingBuilder.Make(titleScreenGO, null, newRing, body.Mod);
}
titleScreenGO.transform.localScale = Vector3.one * 0.8f; titleScreenGO.transform.localScale = Vector3.one * 0.8f;
} }

View File

@ -100,9 +100,9 @@ namespace NewHorizons.Handlers
} }
} }
public static void AddDialogue(string rawText, params string[] rawPreText) public static void AddDialogue(string rawText, bool trimRawTextForKey = false, params string[] rawPreText)
{ {
var key = string.Join(string.Empty, rawPreText) + rawText; var key = string.Join(string.Empty, rawPreText) + (trimRawTextForKey? rawText.Trim() : rawText);
var text = GetTranslation(rawText, TextType.DIALOGUE); var text = GetTranslation(rawText, TextType.DIALOGUE);

View File

@ -3,19 +3,24 @@ using HarmonyLib;
namespace NewHorizons.Patches; namespace NewHorizons.Patches;
[HarmonyPatch] [HarmonyPatch]
internal class CharacterDialogueTreePatches internal static class CharacterDialogueTreePatches
{ {
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(CharacterDialogueTree), nameof(CharacterDialogueTree.Awake))] [HarmonyPatch(typeof(CharacterDialogueTree), nameof(CharacterDialogueTree.Awake))]
private static void CharacterDialogueTree_Awake(CharacterDialogueTree __instance) private static void CharacterDialogueTree_Awake(CharacterDialogueTree __instance)
{ {
GlobalMessenger<OWRigidbody>.AddListener("AttachPlayerToPoint", (_) => __instance.EndConversation()); GlobalMessenger<OWRigidbody>.AddListener("AttachPlayerToPoint", __instance.OnAttachPlayerToPoint);
} }
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(CharacterDialogueTree), nameof(CharacterDialogueTree.OnDestroy))] [HarmonyPatch(typeof(CharacterDialogueTree), nameof(CharacterDialogueTree.OnDestroy))]
private static void CharacterDialogueTree_OnDestroy(CharacterDialogueTree __instance) private static void CharacterDialogueTree_OnDestroy(CharacterDialogueTree __instance)
{ {
GlobalMessenger<OWRigidbody>.RemoveListener("AttachPlayerToPoint", (_) => __instance.EndConversation()); GlobalMessenger<OWRigidbody>.RemoveListener("AttachPlayerToPoint", __instance.OnAttachPlayerToPoint);
}
private static void OnAttachPlayerToPoint(this CharacterDialogueTree characterDialogueTree, OWRigidbody rigidbody)
{
characterDialogueTree.EndConversation();
} }
} }

View File

@ -100,9 +100,12 @@
"type": "string" "type": "string"
} }
}, },
"Ring": { "Rings": {
"description": "Creates a ring around the planet", "type": "array",
"$ref": "#/definitions/RingModule" "description": "Create rings around the planet",
"items": {
"$ref": "#/definitions/RingModule"
}
}, },
"Sand": { "Sand": {
"description": "Add sand to this planet", "description": "Add sand to this planet",
@ -2062,6 +2065,10 @@
"items": { "items": {
"$ref": "#/definitions/TimeValuePair" "$ref": "#/definitions/TimeValuePair"
} }
},
"rename": {
"type": "string",
"description": "An optional rename of this object"
} }
} }
}, },

View File

@ -1,3 +1,4 @@
using NewHorizons.Handlers;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -15,13 +16,24 @@ namespace NewHorizons.Utility.DebugUtilities
private DebugRaycaster _rc; private DebugRaycaster _rc;
private ScreenPrompt _placePrompt;
private void Awake() private void Awake()
{ {
_rc = this.GetComponent<DebugRaycaster>(); _rc = this.GetComponent<DebugRaycaster>();
_placePrompt = new ScreenPrompt(TranslationHandler.GetTranslation("DEBUG_PLACE_TEXT", TranslationHandler.TextType.UI) + " <CMD>", ImageUtilities.GetButtonSprite(KeyCode.G));
Locator.GetPromptManager().AddScreenPrompt(_placePrompt, PromptPosition.UpperRight, false);
} }
void Update() private void OnDestroy()
{ {
Locator.GetPromptManager()?.RemoveScreenPrompt(_placePrompt, PromptPosition.UpperRight);
}
private void Update()
{
UpdatePromptVisibility();
if (!Main.Debug) return; if (!Main.Debug) return;
if (!active) return; if (!active) return;
@ -31,5 +43,10 @@ namespace NewHorizons.Utility.DebugUtilities
if (onRaycast != null) onRaycast.Invoke(data); if (onRaycast != null) onRaycast.Invoke(data);
} }
} }
public void UpdatePromptVisibility()
{
_placePrompt.SetVisibility(!OWTime.IsPaused() && Main.Debug && active);
}
} }
} }

View File

@ -1,6 +1,7 @@
using NewHorizons.Builder.Props; using NewHorizons.Builder.Props;
using NewHorizons.External.Configs; using NewHorizons.External.Configs;
using NewHorizons.External.Modules; using NewHorizons.External.Modules;
using NewHorizons.Handlers;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using UnityEngine; using UnityEngine;
@ -39,14 +40,36 @@ namespace NewHorizons.Utility.DebugUtilities
public GameObject mostRecentlyPlacedPropGO { get { return props.Count() <= 0 ? null : props[props.Count() - 1].gameObject; } } public GameObject mostRecentlyPlacedPropGO { get { return props.Count() <= 0 ? null : props[props.Count() - 1].gameObject; } }
public string mostRecentlyPlacedPropPath { get { return props.Count() <= 0 ? "" : props[props.Count() - 1].detailInfo.path; } } public string mostRecentlyPlacedPropPath { get { return props.Count() <= 0 ? "" : props[props.Count() - 1].detailInfo.path; } }
private ScreenPrompt _placePrompt;
private ScreenPrompt _undoPrompt;
private ScreenPrompt _redoPrompt;
private void Awake() private void Awake()
{ {
_rc = this.GetRequiredComponent<DebugRaycaster>(); _rc = this.GetRequiredComponent<DebugRaycaster>();
currentObject = DEFAULT_OBJECT; currentObject = DEFAULT_OBJECT;
_placePrompt = new ScreenPrompt(TranslationHandler.GetTranslation("DEBUG_PLACE", TranslationHandler.TextType.UI) + " <CMD>", ImageUtilities.GetButtonSprite(KeyCode.G));
_undoPrompt = new ScreenPrompt(TranslationHandler.GetTranslation("DEBUG_UNDO", TranslationHandler.TextType.UI) + " <CMD>", ImageUtilities.GetButtonSprite(KeyCode.Minus));
_redoPrompt = new ScreenPrompt(TranslationHandler.GetTranslation("DEBUG_REDO", TranslationHandler.TextType.UI) + " <CMD>", ImageUtilities.GetButtonSprite(KeyCode.Equals));
Locator.GetPromptManager().AddScreenPrompt(_placePrompt, PromptPosition.UpperRight, false);
Locator.GetPromptManager().AddScreenPrompt(_undoPrompt, PromptPosition.UpperRight, false);
Locator.GetPromptManager().AddScreenPrompt(_redoPrompt, PromptPosition.UpperRight, false);
}
private void OnDestroy()
{
var promptManager = Locator.GetPromptManager();
if (promptManager == null) return;
promptManager.RemoveScreenPrompt(_placePrompt, PromptPosition.UpperRight);
promptManager.RemoveScreenPrompt(_undoPrompt, PromptPosition.UpperRight);
promptManager.RemoveScreenPrompt(_redoPrompt, PromptPosition.UpperRight);
} }
private void Update() private void Update()
{ {
UpdatePromptVisibility();
if (!Main.Debug) return; if (!Main.Debug) return;
if (!active) return; if (!active) return;
@ -66,6 +89,14 @@ namespace NewHorizons.Utility.DebugUtilities
} }
} }
public void UpdatePromptVisibility()
{
var visible = !OWTime.IsPaused() && Main.Debug && active;
_placePrompt.SetVisibility(visible);
_undoPrompt.SetVisibility(visible && props.Count > 0);
_redoPrompt.SetVisibility(visible && deletedProps.Count > 0);
}
public void SetCurrentObject(string s) public void SetCurrentObject(string s)
{ {
currentObject = s; currentObject = s;

View File

@ -1,4 +1,4 @@
using NewHorizons.Components.Orbital; using NewHorizons.Handlers;
using UnityEngine; using UnityEngine;
using UnityEngine.InputSystem; using UnityEngine.InputSystem;
@ -17,15 +17,25 @@ namespace NewHorizons.Utility.DebugUtilities
private GameObject _planeDownRightSphere; private GameObject _planeDownRightSphere;
private GameObject _planeDownLeftSphere; private GameObject _planeDownLeftSphere;
private ScreenPrompt _raycastPrompt;
private void Awake() private void Awake()
{ {
_rb = this.GetRequiredComponent<OWRigidbody>(); _rb = this.GetRequiredComponent<OWRigidbody>();
_raycastPrompt = new ScreenPrompt(TranslationHandler.GetTranslation("DEBUG_RAYCAST", TranslationHandler.TextType.UI) + " <CMD>", ImageUtilities.GetButtonSprite(KeyCode.P));
Locator.GetPromptManager().AddScreenPrompt(_raycastPrompt, PromptPosition.UpperRight, false);
} }
private void OnDestroy()
{
Locator.GetPromptManager()?.RemoveScreenPrompt(_raycastPrompt, PromptPosition.UpperRight);
}
private void Update() private void Update()
{ {
UpdatePromptVisibility();
if (!Main.Debug) return; if (!Main.Debug) return;
if (Keyboard.current == null) return; if (Keyboard.current == null) return;
@ -35,7 +45,12 @@ namespace NewHorizons.Utility.DebugUtilities
} }
} }
public void UpdatePromptVisibility()
{
_raycastPrompt.SetVisibility(!OWTime.IsPaused() && Main.Debug);
}
internal void PrintRaycast() internal void PrintRaycast()
{ {

View File

@ -351,7 +351,16 @@ namespace NewHorizons.Utility
newTexture.Apply(); newTexture.Apply();
return newTexture; return newTexture;
} }
public static Sprite GetButtonSprite(JoystickButton button) => GetButtonSprite(ButtonPromptLibrary.SharedInstance.GetButtonTexture(button));
public static Sprite GetButtonSprite(KeyCode key) => GetButtonSprite(ButtonPromptLibrary.SharedInstance.GetButtonTexture(key));
private static Sprite GetButtonSprite(Texture2D texture)
{
var sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f), 100, 0, SpriteMeshType.FullRect, Vector4.zero, false);
sprite.name = texture.name;
return sprite;
}
// Modified from https://stackoverflow.com/a/69141085/9643841 // Modified from https://stackoverflow.com/a/69141085/9643841
public class AsyncImageLoader : MonoBehaviour public class AsyncImageLoader : MonoBehaviour
{ {

View File

@ -46,14 +46,14 @@
faq( faq(
"ui-program", "ui-program",
"Will you make a UI program to generate json files in the future?", "Will you make a UI program to generate json files in the future?",
"Maybe! Will have to wait until New Horizons gets to version 1.0.0." "Yes! It's available [on GitHub](https://github.com/Outer-Wilds-New-Horizons/nh-config-editor){ target='_blank' }."
) )
}} }}
{{ {{
faq( faq(
"when-version-1", "when-version-1",
"When will New Horizons get to version 1.0.0.", "When will New Horizons get to version 1.0.0.",
"Soon/eventually/never/yesterday." "It already did **BOZO**!!!!!"
) )
}} }}
{{ {{