This commit is contained in:
Noah Pilarski 2025-01-25 07:12:52 -05:00
parent 9e97e59934
commit dd917ade85
3 changed files with 56 additions and 33 deletions

View File

@ -50,9 +50,9 @@ namespace NewHorizons.External.Configs
public string ambience; public string ambience;
/// <summary> /// <summary>
/// Changes the speed the main menu planet and the skybox rotates. /// Changes the speed the main menu planet and the skybox rotates. This is in degrees per second.
/// </summary> /// </summary>
public float rotationSpeed; public float rotationSpeed = 1;
/// <summary> /// <summary>
/// Edit properties of the main menu planet /// Edit properties of the main menu planet
@ -76,6 +76,11 @@ namespace NewHorizons.External.Configs
/// A list of DetailInfos to populate the main menu planet with. /// A list of DetailInfos to populate the main menu planet with.
/// </summary> /// </summary>
public SimplifiedDetailInfo[] details; public SimplifiedDetailInfo[] details;
/// <summary>
/// Changes the speed the main menu planet. This is in degrees per second.
/// </summary>
public float rotationSpeed = 2;
} }
/// <summary> /// <summary>

View File

@ -1,4 +1,6 @@
using Epic.OnlineServices.Presence;
using NewHorizons.Builder.Body; using NewHorizons.Builder.Body;
using NewHorizons.Builder.Props;
using NewHorizons.Builder.StarSystem; using NewHorizons.Builder.StarSystem;
using NewHorizons.External; using NewHorizons.External;
using NewHorizons.External.Configs; using NewHorizons.External.Configs;
@ -8,6 +10,7 @@ using NewHorizons.Handlers.TitleScreen;
using NewHorizons.Utility; using NewHorizons.Utility;
using NewHorizons.Utility.OWML; using NewHorizons.Utility.OWML;
using OWML.Common; using OWML.Common;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using UnityEngine; using UnityEngine;
@ -17,6 +20,21 @@ namespace NewHorizons.Handlers
{ {
public static class TitleSceneHandler public static class TitleSceneHandler
{ {
public static void Init()
{
var planetRoot = SearchUtilities.Find("Scene/Background/PlanetPivot/PlanetRoot");
var campfire = SearchUtilities.Find("Scene/Background/PlanetPivot/Prefab_HEA_Campfire");
campfire.transform.SetParent(planetRoot.transform, true);
var ambientLight = SearchUtilities.Find("Scene/Background/PlanetPivot/AmbientLight_CaveTwin");
ambientLight.transform.SetParent(planetRoot.transform, true);
TitleSceneHandler.InitSubtitles();
// TODO: Select one title screen and if it has shareTitleScreen set to true do all the other ones that have it true too.
var (mod, config) = Main.TitleScreenConfigs.FirstOrDefault(kvp => kvp.Value.KnowsFact() && kvp.Value.HasCondition());
TitleSceneHandler.SetUp(mod, config);
}
public static void InitSubtitles() public static void InitSubtitles()
{ {
GameObject subtitleContainer = SearchUtilities.Find("TitleMenu/TitleCanvas/TitleLayoutGroup/Logo_EchoesOfTheEye"); GameObject subtitleContainer = SearchUtilities.Find("TitleMenu/TitleCanvas/TitleLayoutGroup/Logo_EchoesOfTheEye");
@ -33,6 +51,18 @@ namespace NewHorizons.Handlers
public static void SetUp(IModBehaviour mod, TitleScreenConfig config) public static void SetUp(IModBehaviour mod, TitleScreenConfig config)
{ {
if (!config.disableNHPlanets)
{
try
{
TitleSceneHandler.DisplayBodyOnTitleScreen(Main.BodyDict.Values.ToList().SelectMany(x => x).ToList());
}
catch (Exception e)
{
NHLogger.LogError($"Failed to make title screen bodies: {e}");
}
}
if (config.menuTextTint != null) if (config.menuTextTint != null)
{ {
TitleScreenColourHandler.SetColour(config.menuTextTint.ToColor()); TitleScreenColourHandler.SetColour(config.menuTextTint.ToColor());
@ -40,7 +70,7 @@ namespace NewHorizons.Handlers
if (config.Skybox?.destroyStarField ?? false) if (config.Skybox?.destroyStarField ?? false)
{ {
Object.Destroy(SearchUtilities.Find("Skybox/Starfield")); UnityEngine.Object.Destroy(SearchUtilities.Find("Skybox/Starfield"));
} }
if (config.Skybox?.rightPath != null || if (config.Skybox?.rightPath != null ||
@ -67,27 +97,33 @@ namespace NewHorizons.Handlers
Delay.FireOnNextUpdate(() => ambienceSource.AssignAudioLibraryClip(audioType)); Delay.FireOnNextUpdate(() => ambienceSource.AssignAudioLibraryClip(audioType));
} }
SearchUtilities.Find("Scene/Background").GetComponent<RotateTransform>()._degreesPerSecond = config.rotationSpeed;
if (config.MenuPlanet != null) if (config.MenuPlanet != null)
{ {
if (config.MenuPlanet.destroyMenuPlanet) var menuPlanet = SearchUtilities.Find("Scene/Background/PlanetPivot/PlanetRoot");
{
//TODO: Implement
}
if (config.MenuPlanet.removeChildren != null) if (config.MenuPlanet.removeChildren != null)
{ {
//TODO: Implement RemoveChildren(menuPlanet, config.MenuPlanet.removeChildren);
//RemoveChildren(null, config.MenuPlanet.removeChildren);
} }
if (config.MenuPlanet.details != null) if (config.MenuPlanet.details != null)
{ {
foreach (var simplifiedDetail in config.MenuPlanet.details) foreach (var simplifiedDetail in config.MenuPlanet.details)
{ {
var detail = new DetailInfo(simplifiedDetail); DetailBuilder.Make(menuPlanet, null, mod, new DetailInfo(simplifiedDetail));
//TODO: Implement
} }
} }
var rotator = SearchUtilities.Find("Scene/Background/PlanetPivot").GetComponent<RotateTransform>();
rotator._localAxis = Vector3.up;
rotator._degreesPerSecond = config.MenuPlanet.rotationSpeed;
if (config.MenuPlanet.destroyMenuPlanet)
{
menuPlanet.SetActive(false);
}
} }
} }
@ -156,12 +192,7 @@ namespace NewHorizons.Handlers
planetSizes.Add(bodyInfo3); planetSizes.Add(bodyInfo3);
} }
var planetRoot = SearchUtilities.Find("Scene/Background/PlanetPivot/PlanetRoot"); SearchUtilities.Find("Scene/Background/PlanetPivot/PlanetRoot").SetActive(false);
var campfire = SearchUtilities.Find("Scene/Background/PlanetPivot/Prefab_HEA_Campfire");
campfire.transform.SetParent(planetRoot.transform, true);
var ambientLight = SearchUtilities.Find("Scene/Background/PlanetPivot/AmbientLight_CaveTwin");
ambientLight.transform.SetParent(planetRoot.transform, true);
planetRoot.SetActive(false);
var lightGO = new GameObject("Light"); var lightGO = new GameObject("Light");
lightGO.transform.parent = SearchUtilities.Find("Scene/Background").transform; lightGO.transform.parent = SearchUtilities.Find("Scene/Background").transform;
@ -250,11 +281,11 @@ namespace NewHorizons.Handlers
} }
} }
var pivot = Object.Instantiate(SearchUtilities.Find("Scene/Background/PlanetPivot"), SearchUtilities.Find("Scene/Background").transform); var pivot = UnityEngine.Object.Instantiate(SearchUtilities.Find("Scene/Background/PlanetPivot"), SearchUtilities.Find("Scene/Background").transform);
pivot.GetComponent<RotateTransform>()._degreesPerSecond = 10f; pivot.GetComponent<RotateTransform>()._degreesPerSecond = 10f;
foreach (Transform child in pivot.transform) foreach (Transform child in pivot.transform)
{ {
Object.Destroy(child.gameObject); UnityEngine.Object.Destroy(child.gameObject);
} }
pivot.name = "Pivot"; pivot.name = "Pivot";

View File

@ -423,20 +423,7 @@ namespace NewHorizons
if (isTitleScreen && CustomTitleScreen) if (isTitleScreen && CustomTitleScreen)
{ {
AudioTypeHandler.Init(true); AudioTypeHandler.Init(true);
TitleSceneHandler.Init();
try
{
TitleSceneHandler.DisplayBodyOnTitleScreen(BodyDict.Values.ToList().SelectMany(x => x).ToList());
}
catch (Exception e)
{
NHLogger.LogError($"Failed to make title screen bodies: {e}");
}
TitleSceneHandler.InitSubtitles();
// TODO: Select one title screen and if it has shareTitleScreen set to true do all the other ones that have it true too.
var (mod, config) = Main.TitleScreenConfigs.FirstOrDefault(kvp => kvp.Value.KnowsFact() && kvp.Value.HasCondition());
TitleSceneHandler.SetUp(mod, config);
} }
// EOTU fixes // EOTU fixes