mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
f53b2a896f
@ -7,13 +7,6 @@ namespace NewHorizons.Builder.Body.Geometry
|
||||
{
|
||||
public static Mesh Build(int resolution, Texture2D heightMap, float minHeight, float maxHeight, Vector3 stretch)
|
||||
{
|
||||
// It breaks if resolution is greater than 100 I don't know why
|
||||
if (resolution > 100)
|
||||
{
|
||||
Logger.LogWarning($"Can't make CubeSphere's with resolution higher than 100 for some reason");
|
||||
resolution = 100;
|
||||
}
|
||||
|
||||
Mesh mesh = new Mesh();
|
||||
mesh.name = "CubeSphere";
|
||||
|
||||
@ -109,6 +102,12 @@ namespace NewHorizons.Builder.Body.Geometry
|
||||
}
|
||||
}
|
||||
|
||||
// Higher than this and we have to use a different indexFormat
|
||||
if (vertices.Length > 65535)
|
||||
{
|
||||
mesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32;
|
||||
}
|
||||
|
||||
mesh.vertices = vertices;
|
||||
mesh.normals = normals;
|
||||
mesh.uv = uvs;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
@ -59,9 +59,9 @@ namespace NewHorizons.Builder.Body.Geometry
|
||||
public static Mesh Build(int subdivisions, float minHeight, float maxHeight)
|
||||
{
|
||||
Mesh mesh = new Mesh();
|
||||
mesh.name = "Icosphere";
|
||||
|
||||
if (vertices.Count <= subdivisions)
|
||||
RefineFaces(subdivisions);
|
||||
if (vertices.Count <= subdivisions) RefineFaces(subdivisions);
|
||||
|
||||
var verticesToCopy = vertices[subdivisions];
|
||||
|
||||
@ -89,6 +89,12 @@ namespace NewHorizons.Builder.Body.Geometry
|
||||
uvs[i] = new Vector2(x, y);
|
||||
}
|
||||
|
||||
// Higher than this and we have to use a different indexFormat
|
||||
if (newVertices.Length > 65535)
|
||||
{
|
||||
mesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32;
|
||||
}
|
||||
|
||||
mesh.vertices = newVertices;
|
||||
mesh.triangles = triangles[subdivisions];
|
||||
mesh.normals = normals;
|
||||
|
||||
@ -5,14 +5,13 @@ using OWML.Common;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using Logger = NewHorizons.Utility.Logger;
|
||||
using Object = UnityEngine.Object;
|
||||
namespace NewHorizons.Builder.Body
|
||||
{
|
||||
public static class HeightMapBuilder
|
||||
{
|
||||
public static Shader PlanetShader;
|
||||
|
||||
public static void Make(GameObject planetGO, Sector sector, HeightMapModule module, IModBehaviour mod, int resolution = 51)
|
||||
public static void Make(GameObject planetGO, Sector sector, HeightMapModule module, IModBehaviour mod, int resolution)
|
||||
{
|
||||
var deleteHeightmapFlag = false;
|
||||
|
||||
|
||||
@ -241,7 +241,7 @@ namespace NewHorizons.Components
|
||||
}
|
||||
}
|
||||
|
||||
public string UniqueIDToName(string uniqueID)
|
||||
public static string UniqueIDToName(string uniqueID)
|
||||
{
|
||||
var name = TranslationHandler.GetTranslation(uniqueID, TranslationHandler.TextType.UI);
|
||||
|
||||
|
||||
@ -387,7 +387,7 @@ namespace NewHorizons.Handlers
|
||||
|
||||
if (body.Config.HeightMap != null)
|
||||
{
|
||||
HeightMapBuilder.Make(go, sector, body.Config.HeightMap, body.Mod);
|
||||
HeightMapBuilder.Make(go, sector, body.Config.HeightMap, body.Mod, 51);
|
||||
}
|
||||
|
||||
if (body.Config.ProcGen != null)
|
||||
|
||||
@ -96,7 +96,7 @@ namespace NewHorizons.Handlers
|
||||
heightMap.textureMap = body.Config.Atmosphere.clouds.texturePath;
|
||||
}
|
||||
|
||||
HeightMapBuilder.Make(titleScreenGO, null, heightMap, body.Mod);
|
||||
HeightMapBuilder.Make(titleScreenGO, null, heightMap, body.Mod, 30);
|
||||
|
||||
GameObject pivot = GameObject.Instantiate(SearchUtilities.Find("Scene/Background/PlanetPivot"), SearchUtilities.Find("Scene/Background").transform);
|
||||
pivot.GetComponent<RotateTransform>()._degreesPerSecond = 10f;
|
||||
|
||||
101
NewHorizons/Handlers/VesselCoordinatePromptHandler.cs
Normal file
101
NewHorizons/Handlers/VesselCoordinatePromptHandler.cs
Normal file
@ -0,0 +1,101 @@
|
||||
using NewHorizons.Components;
|
||||
using NewHorizons.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using UnityEngine;
|
||||
using static NewHorizons.External.Configs.StarSystemConfig;
|
||||
|
||||
namespace NewHorizons.Handlers
|
||||
{
|
||||
public class VesselCoordinatePromptHandler
|
||||
{
|
||||
private static List<Tuple<string, string, ScreenPrompt>> _factSystemIDPrompt;
|
||||
private static List<Texture2D> _textureCache;
|
||||
|
||||
public static void RegisterPrompts(List<NewHorizonsSystem> systems)
|
||||
{
|
||||
// Have to destroy the images we've created if this isn't the first time it has run
|
||||
if (_textureCache != null)
|
||||
{
|
||||
foreach (var texture in _textureCache)
|
||||
{
|
||||
UnityEngine.Object.Destroy(texture);
|
||||
}
|
||||
}
|
||||
|
||||
_textureCache = new List<Texture2D>();
|
||||
_factSystemIDPrompt = new List<Tuple<string, string, ScreenPrompt>>();
|
||||
|
||||
foreach (var system in systems)
|
||||
{
|
||||
var systemName = system.UniqueID;
|
||||
var fact = system.Config.factRequiredForWarp;
|
||||
var nomaiCoords = system.Config.coords;
|
||||
|
||||
if (system.UniqueID == "EyeOfTheUniverse" || nomaiCoords == null) continue;
|
||||
|
||||
RegisterPrompt(systemName, fact, nomaiCoords);
|
||||
}
|
||||
}
|
||||
|
||||
private static void RegisterPrompt(string systemID, string fact, NomaiCoordinates coords)
|
||||
{
|
||||
var texture = MakeTexture(coords.x, coords.y, coords.z);
|
||||
|
||||
_textureCache.Add(texture);
|
||||
|
||||
var sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(texture.width / 2f, texture.height / 2f));
|
||||
|
||||
var name = ShipLogStarChartMode.UniqueIDToName(systemID);
|
||||
|
||||
var prompt = new ScreenPrompt($"{name}: <EYE>", sprite, 0);
|
||||
|
||||
_factSystemIDPrompt.Add(new (fact, systemID, prompt));
|
||||
|
||||
var manager = Locator.GetPromptManager();
|
||||
manager.AddScreenPrompt(prompt, manager.GetScreenPromptList(PromptPosition.LowerLeft), manager.GetTextAnchor(PromptPosition.LowerLeft), -1, false);
|
||||
}
|
||||
|
||||
private static Texture2D MakeTexture(int[] x, int[] y, int[] z)
|
||||
{
|
||||
// Put thing here
|
||||
return new Texture2D(1, 1);
|
||||
}
|
||||
|
||||
// Gets called from the patches
|
||||
public static void SetPromptVisibility(bool visible)
|
||||
{
|
||||
foreach (var pair in _factSystemIDPrompt)
|
||||
{
|
||||
var fact = pair.Item1;
|
||||
var systemID = pair.Item2;
|
||||
var prompt = pair.Item3;
|
||||
|
||||
if (visible)
|
||||
{
|
||||
if (Main.Instance.CurrentStarSystem != systemID && (string.IsNullOrEmpty(fact) || Locator.GetShipLogManager().IsFactRevealed(fact)))
|
||||
{
|
||||
prompt.SetVisibility(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
prompt.SetVisibility(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
prompt.SetVisibility(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -331,6 +331,8 @@ namespace NewHorizons
|
||||
if (shouldWarpInFromShip) _shipWarpController.WarpIn(WearingSuit);
|
||||
else if (shouldWarpInFromVessel) VesselWarpHandler.TeleportToVessel();
|
||||
else FindObjectOfType<PlayerSpawner>().DebugWarp(SystemDict[_currentStarSystem].SpawnPoint);
|
||||
|
||||
VesselCoordinatePromptHandler.RegisterPrompts(SystemDict.Where(system => system.Value.Config.coords != null).Select(x => x.Value).ToList());
|
||||
}
|
||||
|
||||
public void EnableWarpDrive()
|
||||
|
||||
34
NewHorizons/Patches/EyeCoordinatePromptTriggerPatches.cs
Normal file
34
NewHorizons/Patches/EyeCoordinatePromptTriggerPatches.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using HarmonyLib;
|
||||
using NewHorizons.Handlers;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NewHorizons.Patches
|
||||
{
|
||||
[HarmonyPatch]
|
||||
public static class EyeCoordinatePromptTriggerPatches
|
||||
{
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(EyeCoordinatePromptTrigger), nameof(EyeCoordinatePromptTrigger.Update))]
|
||||
public static bool EyeCoordinatePromptTrigger_Update(EyeCoordinatePromptTrigger __instance)
|
||||
{
|
||||
var showPrompts = __instance._warpController.HasPower();
|
||||
|
||||
// In other systems checking if the proper fact is revealed doesn't work, so we just overwrite this function
|
||||
__instance._promptController.SetEyeCoordinatesVisibility(showPrompts && VesselCoordinatePromptHandler.KnowsEyeCoordinates());
|
||||
|
||||
VesselCoordinatePromptHandler.SetPromptVisibility(showPrompts);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(EyeCoordinatePromptTrigger), nameof(EyeCoordinatePromptTrigger.OnExit))]
|
||||
public static void EyeCoordinatePromptTrigger_OnExit(GameObject __0)
|
||||
{
|
||||
if (__0.CompareTag("PlayerDetector"))
|
||||
{
|
||||
VesselCoordinatePromptHandler.SetPromptVisibility(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -125,6 +125,7 @@ namespace NewHorizons.Utility.DebugUtilities
|
||||
}.Select(vIdx => vIdx + topVerts.Length+bottomVerts.Length).ToArray();
|
||||
|
||||
Mesh m = new Mesh();
|
||||
m.name = "DebugArrow";
|
||||
m.vertices = topVerts.Concat(bottomVerts).Concat(sideVerts).ToArray();
|
||||
m.triangles = topTris.Concat(bottomTris).Concat(sideTris).ToArray();
|
||||
m.RecalculateNormals();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user