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}.",
"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}",
"DEBUG_RAYCAST": "Raycast",
"DEBUG_PLACE": "Place Object",
"DEBUG_PLACE_TEXT": "Place Nomai Text",
"DEBUG_UNDO": "Undo",
"DEBUG_REDO": "Redo",
"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);
if (realSize < body.Config.Ring.outerRadius) realSize = body.Config.Ring.outerRadius;
foreach (var ring in body.Config.Rings)
{
RingBuilder.MakeRingGraphics(proxy, null, ring, body.Mod);
if (realSize < ring.outerRadius) realSize = ring.outerRadius;
}
}
Renderer starAtmosphere = null;

View File

@ -73,7 +73,7 @@ namespace NewHorizons.Builder.Body
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.position = rootObject.transform.position;
ringGO.transform.rotation = rootObject.transform.rotation;

View File

@ -207,19 +207,21 @@ namespace NewHorizons.Builder.Props
var name = xmlNode2.SelectSingleNode("Name").InnerText;
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;
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");
foreach (object Page in xmlText)
foreach (object option in xmlText)
{
XmlNode pageData = (XmlNode)Page;
var text = pageData.InnerText;
TranslationHandler.AddDialogue(text, characterName, name);
XmlNode optionData = (XmlNode)option;
var text = optionData.InnerText;
// 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")]
public SignalModule Signal;
[Obsolete("Ring is deprecated, please use Rings")]
public RingModule Ring;
#endregion Obsolete
/// <summary>
@ -135,9 +139,9 @@ namespace NewHorizons.External.Configs
public string[] removeChildren;
/// <summary>
/// Creates a ring around the planet
/// Create rings around the planet
/// </summary>
public RingModule Ring;
public RingModule[] Rings;
/// <summary>
/// Add sand to this planet
@ -401,10 +405,20 @@ namespace NewHorizons.External.Configs
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.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.
/// </summary>
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)

View File

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

View File

@ -3,19 +3,24 @@ using HarmonyLib;
namespace NewHorizons.Patches;
[HarmonyPatch]
internal class CharacterDialogueTreePatches
internal static class CharacterDialogueTreePatches
{
[HarmonyPrefix]
[HarmonyPatch(typeof(CharacterDialogueTree), nameof(CharacterDialogueTree.Awake))]
private static void CharacterDialogueTree_Awake(CharacterDialogueTree __instance)
{
GlobalMessenger<OWRigidbody>.AddListener("AttachPlayerToPoint", (_) => __instance.EndConversation());
GlobalMessenger<OWRigidbody>.AddListener("AttachPlayerToPoint", __instance.OnAttachPlayerToPoint);
}
[HarmonyPrefix]
[HarmonyPatch(typeof(CharacterDialogueTree), nameof(CharacterDialogueTree.OnDestroy))]
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"
}
},
"Ring": {
"description": "Creates a ring around the planet",
"$ref": "#/definitions/RingModule"
"Rings": {
"type": "array",
"description": "Create rings around the planet",
"items": {
"$ref": "#/definitions/RingModule"
}
},
"Sand": {
"description": "Add sand to this planet",
@ -2062,6 +2065,10 @@
"items": {
"$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.Collections.Generic;
using System.Linq;
@ -15,13 +16,24 @@ namespace NewHorizons.Utility.DebugUtilities
private DebugRaycaster _rc;
private ScreenPrompt _placePrompt;
private void Awake()
{
_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 (!active) return;
@ -31,5 +43,10 @@ namespace NewHorizons.Utility.DebugUtilities
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.External.Configs;
using NewHorizons.External.Modules;
using NewHorizons.Handlers;
using System.Collections.Generic;
using System.Linq;
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 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()
{
_rc = this.GetRequiredComponent<DebugRaycaster>();
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()
{
UpdatePromptVisibility();
if (!Main.Debug) 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)
{
currentObject = s;

View File

@ -1,4 +1,4 @@
using NewHorizons.Components.Orbital;
using NewHorizons.Handlers;
using UnityEngine;
using UnityEngine.InputSystem;
@ -17,15 +17,25 @@ namespace NewHorizons.Utility.DebugUtilities
private GameObject _planeDownRightSphere;
private GameObject _planeDownLeftSphere;
private ScreenPrompt _raycastPrompt;
private void Awake()
{
_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()
{
UpdatePromptVisibility();
if (!Main.Debug) return;
if (Keyboard.current == null) return;
@ -36,6 +46,11 @@ namespace NewHorizons.Utility.DebugUtilities
}
public void UpdatePromptVisibility()
{
_raycastPrompt.SetVisibility(!OWTime.IsPaused() && Main.Debug);
}
internal void PrintRaycast()
{

View File

@ -352,6 +352,15 @@ namespace NewHorizons.Utility
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
public class AsyncImageLoader : MonoBehaviour
{

View File

@ -46,14 +46,14 @@
faq(
"ui-program",
"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(
"when-version-1",
"When will New Horizons get to version 1.0.0.",
"Soon/eventually/never/yesterday."
"It already did **BOZO**!!!!!"
)
}}
{{