Merge branch 'dev' into scatter-optimization

This commit is contained in:
JohnCorby 2022-09-04 19:30:21 -07:00
commit 01f3224a8a
17 changed files with 230 additions and 79 deletions

Binary file not shown.

View File

@ -1,14 +1,16 @@
ManifestFileVersion: 0 ManifestFileVersion: 0
CRC: 1014555239 CRC: 2022446871
Hashes: Hashes:
AssetFileHash: AssetFileHash:
serializedVersion: 2 serializedVersion: 2
Hash: 45fa3430ee7bea1e8384e57927fc0f76 Hash: 083882699617744b8fc49234bb8cb795
TypeTreeHash: TypeTreeHash:
serializedVersion: 2 serializedVersion: 2
Hash: 55d48f4ad9c3b13330b9eb5ee5686477 Hash: 10a6a558690295dadb3dd990eda0821a
HashAppended: 0 HashAppended: 0
ClassTypes: ClassTypes:
- Class: 21
Script: {instanceID: 0}
- Class: 48 - Class: 48
Script: {instanceID: 0} Script: {instanceID: 0}
SerializeReferenceClassIdentifiers: [] SerializeReferenceClassIdentifiers: []
@ -18,6 +20,7 @@ Assets:
- Assets/Shaders/SphereTextureWrapperNormal.shader - Assets/Shaders/SphereTextureWrapperNormal.shader
- Assets/Shaders/UnlitRing1Pixel.shader - Assets/Shaders/UnlitRing1Pixel.shader
- Assets/Shaders/UnlitTransparent.shader - Assets/Shaders/UnlitTransparent.shader
- Assets/Resources/TransparentCloud.mat
- Assets/Shaders/StandardCullOFF.shader - Assets/Shaders/StandardCullOFF.shader
- Assets/Shaders/Ring1Pixel.shader - Assets/Shaders/Ring1Pixel.shader
Dependencies: [] Dependencies: []

View File

@ -59,7 +59,7 @@ namespace NewHorizons.Builder.Atmosphere
} }
} }
material.SetFloat(InnerRadius, atmosphereModule.clouds != null ? atmosphereModule.size : surfaceSize); material.SetFloat(InnerRadius, (atmosphereModule.clouds != null && atmosphereModule.clouds.cloudsPrefab != CloudPrefabType.Transparent) ? atmosphereModule.size : surfaceSize);
material.SetFloat(OuterRadius, atmosphereModule.size * 1.2f); material.SetFloat(OuterRadius, atmosphereModule.size * 1.2f);
if (atmosphereModule.atmosphereTint != null) material.SetColor(SkyColor, atmosphereModule.atmosphereTint.ToColor()); if (atmosphereModule.atmosphereTint != null) material.SetColor(SkyColor, atmosphereModule.atmosphereTint.ToColor());

View File

@ -11,6 +11,7 @@ namespace NewHorizons.Builder.Atmosphere
{ {
private static Material[] _gdCloudMaterials; private static Material[] _gdCloudMaterials;
private static Material[] _qmCloudMaterials; private static Material[] _qmCloudMaterials;
private static Material _transparentCloud;
private static GameObject _lightningPrefab; private static GameObject _lightningPrefab;
private static Texture2D _colorRamp; private static Texture2D _colorRamp;
private static readonly int Color = Shader.PropertyToID("_Color"); private static readonly int Color = Shader.PropertyToID("_Color");
@ -18,6 +19,7 @@ namespace NewHorizons.Builder.Atmosphere
private static readonly int MainTex = Shader.PropertyToID("_MainTex"); private static readonly int MainTex = Shader.PropertyToID("_MainTex");
private static readonly int RampTex = Shader.PropertyToID("_RampTex"); private static readonly int RampTex = Shader.PropertyToID("_RampTex");
private static readonly int CapTex = Shader.PropertyToID("_CapTex"); private static readonly int CapTex = Shader.PropertyToID("_CapTex");
private static readonly int Smoothness = Shader.PropertyToID("_Glossiness");
public static void Make(GameObject planetGO, Sector sector, AtmosphereModule atmo, bool cloaked, IModBehaviour mod) public static void Make(GameObject planetGO, Sector sector, AtmosphereModule atmo, bool cloaked, IModBehaviour mod)
{ {
@ -28,7 +30,15 @@ namespace NewHorizons.Builder.Atmosphere
cloudsMainGO.SetActive(false); cloudsMainGO.SetActive(false);
cloudsMainGO.transform.parent = sector?.transform ?? planetGO.transform; cloudsMainGO.transform.parent = sector?.transform ?? planetGO.transform;
MakeTopClouds(cloudsMainGO, atmo, mod); if (atmo.clouds.cloudsPrefab != CloudPrefabType.Transparent) MakeTopClouds(cloudsMainGO, atmo, mod);
else
{
MakeTransparentClouds(cloudsMainGO, atmo, mod);
if (atmo.clouds.hasLightning) MakeLightning(cloudsMainGO, sector, atmo);
cloudsMainGO.transform.position = planetGO.transform.TransformPoint(Vector3.zero);
cloudsMainGO.SetActive(true);
return;
}
GameObject cloudsBottomGO = new GameObject("BottomClouds"); GameObject cloudsBottomGO = new GameObject("BottomClouds");
cloudsBottomGO.SetActive(false); cloudsBottomGO.SetActive(false);
@ -114,7 +124,7 @@ namespace NewHorizons.Builder.Atmosphere
lightning.transform.localPosition = Vector3.zero; lightning.transform.localPosition = Vector3.zero;
var lightningGenerator = lightning.GetComponent<CloudLightningGenerator>(); var lightningGenerator = lightning.GetComponent<CloudLightningGenerator>();
lightningGenerator._altitude = (atmo.clouds.outerCloudRadius + atmo.clouds.innerCloudRadius) / 2f; lightningGenerator._altitude = atmo.clouds.cloudsPrefab != CloudPrefabType.Transparent ? (atmo.clouds.outerCloudRadius + atmo.clouds.innerCloudRadius) / 2f : atmo.clouds.outerCloudRadius;
if (noAudio) if (noAudio)
{ {
lightningGenerator._audioPrefab = null; lightningGenerator._audioPrefab = null;
@ -177,7 +187,7 @@ namespace NewHorizons.Builder.Atmosphere
var material = new Material(Shader.Find("Standard")); var material = new Material(Shader.Find("Standard"));
if (atmo.clouds.unlit) material.renderQueue = 3000; if (atmo.clouds.unlit) material.renderQueue = 3000;
material.name = atmo.clouds.unlit ? "BasicCloud" : "BasicShadowCloud"; material.name = atmo.clouds.unlit ? "BasicCloud" : "BasicShadowCloud";
material.SetFloat(279, 0f); // smoothness material.SetFloat(Smoothness, 0f);
tempArray[0] = material; tempArray[0] = material;
} }
else else
@ -218,5 +228,65 @@ namespace NewHorizons.Builder.Atmosphere
return cloudsTopGO; return cloudsTopGO;
} }
public static GameObject MakeTransparentClouds(GameObject rootObject, AtmosphereModule atmo, IModBehaviour mod, bool isProxy = false)
{
Texture2D image;
try
{
image = ImageUtilities.GetTexture(mod, atmo.clouds.texturePath);
}
catch (Exception e)
{
Logger.LogError($"Couldn't load Cloud texture for [{atmo.clouds.texturePath}]:\n{e}");
return null;
}
GameObject cloudsTransparentGO = new GameObject("TransparentClouds");
cloudsTransparentGO.SetActive(false);
cloudsTransparentGO.transform.parent = rootObject.transform;
cloudsTransparentGO.transform.localScale = Vector3.one * atmo.clouds.outerCloudRadius;
MeshFilter filter = cloudsTransparentGO.AddComponent<MeshFilter>();
filter.mesh = SearchUtilities.Find("CloudsTopLayer_GD").GetComponent<MeshFilter>().mesh;
MeshRenderer renderer = cloudsTransparentGO.AddComponent<MeshRenderer>();
if (_transparentCloud == null) _transparentCloud = Main.NHAssetBundle.LoadAsset<Material>("Assets/Resources/TransparentCloud.mat");
var material = new Material(_transparentCloud);
material.name = "TransparentClouds_" + image.name;
material.SetTexture(MainTex, image);
renderer.sharedMaterial = material;
if (!isProxy)
{
GameObject tcrqcGO = new GameObject("TransparentCloudRenderQueueController");
tcrqcGO.transform.SetParent(cloudsTransparentGO.transform, false);
tcrqcGO.layer = LayerMask.NameToLayer("BasicEffectVolume");
var shape = tcrqcGO.AddComponent<SphereShape>();
shape.radius = 1;
var owTriggerVolume = tcrqcGO.AddComponent<OWTriggerVolume>();
owTriggerVolume._shape = shape;
TransparentCloudRenderQueueController tcrqc = tcrqcGO.AddComponent<TransparentCloudRenderQueueController>();
tcrqc.renderer = renderer;
}
if (atmo.clouds.rotationSpeed != 0f)
{
var rt = cloudsTransparentGO.AddComponent<RotateTransform>();
rt._localAxis = Vector3.up;
rt._degreesPerSecond = atmo.clouds.rotationSpeed;
rt._randomizeRotationRate = false;
}
cloudsTransparentGO.transform.localPosition = Vector3.zero;
cloudsTransparentGO.SetActive(true);
return cloudsTransparentGO;
}
} }
} }

View File

@ -21,7 +21,6 @@ namespace NewHorizons.Builder.Atmosphere
SCG._waitForStreaming = false; SCG._waitForStreaming = false;
var minHeight = surfaceSize; var minHeight = surfaceSize;
var maxHeight = config.Atmosphere.size;
if (config.HeightMap?.minHeight != null) if (config.HeightMap?.minHeight != null)
{ {
if (config.Water?.size >= config.HeightMap.minHeight) minHeight = config.Water.size; // use sea level if its higher if (config.Water?.size >= config.HeightMap.minHeight) minHeight = config.Water.size; // use sea level if its higher
@ -30,6 +29,9 @@ namespace NewHorizons.Builder.Atmosphere
else if (config.Water?.size != null) minHeight = config.Water.size; else if (config.Water?.size != null) minHeight = config.Water.size;
else if (config.Lava?.size != null) minHeight = config.Lava.size; else if (config.Lava?.size != null) minHeight = config.Lava.size;
var maxHeight = config.Atmosphere.size;
if (config.Atmosphere.clouds?.outerCloudRadius != null) maxHeight = config.Atmosphere.clouds.outerCloudRadius;
if (config.Atmosphere.hasRain) if (config.Atmosphere.hasRain)
{ {
var rainGO = GameObject.Instantiate(SearchUtilities.Find("GiantsDeep_Body/Sector_GD/Sector_GDInterior/Effects_GDInterior/Effects_GD_Rain"), effectsGO.transform); var rainGO = GameObject.Instantiate(SearchUtilities.Find("GiantsDeep_Body/Sector_GD/Sector_GDInterior/Effects_GDInterior/Effects_GD_Rain"), effectsGO.transform);

View File

@ -111,7 +111,8 @@ namespace NewHorizons.Builder.Body
if (body.Config.Atmosphere.clouds != null) if (body.Config.Atmosphere.clouds != null)
{ {
topClouds = CloudsBuilder.MakeTopClouds(proxy, body.Config.Atmosphere, body.Mod).GetComponent<MeshRenderer>(); if (body.Config.Atmosphere.clouds.cloudsPrefab != External.Modules.CloudPrefabType.Transparent) topClouds = CloudsBuilder.MakeTopClouds(proxy, body.Config.Atmosphere, body.Mod).GetComponent<MeshRenderer>();
else topClouds = CloudsBuilder.MakeTransparentClouds(proxy, body.Config.Atmosphere, body.Mod, true).GetAddComponent<MeshRenderer>();
if (body.Config.Atmosphere.clouds.hasLightning) lightningGenerator = CloudsBuilder.MakeLightning(proxy, null, body.Config.Atmosphere, true); if (body.Config.Atmosphere.clouds.hasLightning) lightningGenerator = CloudsBuilder.MakeLightning(proxy, null, body.Config.Atmosphere, true);

View File

@ -1,5 +1,7 @@
using NewHorizons.External.Modules; using NewHorizons.External.Modules;
using NewHorizons.Utility; using NewHorizons.Utility;
using System;
using System.Reflection;
using UnityEngine; using UnityEngine;
using Logger = NewHorizons.Utility.Logger; using Logger = NewHorizons.Utility.Logger;
namespace NewHorizons.Builder.General namespace NewHorizons.Builder.General
@ -89,38 +91,28 @@ namespace NewHorizons.Builder.General
public static void SuitUp() public static void SuitUp()
{ {
suitUpQueued = false; suitUpQueued = false;
if (Locator.GetPlayerController()._isWearingSuit) return; if (!Locator.GetPlayerController()._isWearingSuit)
{
Locator.GetPlayerTransform().GetComponent<PlayerSpacesuit>().SuitUp(false, true, true); var spv = SearchUtilities.Find("Ship_Body/Module_Supplies/Systems_Supplies/ExpeditionGear")?.GetComponent<SuitPickupVolume>();
if (spv != null)
{
var command = spv._interactVolume.GetInteractionAt(spv._pickupSuitCommandIndex).inputCommand;
// Make the ship act as if the player took the suit // Make the ship act as if the player took the suit
var spv = SearchUtilities.Find("Ship_Body/Module_Supplies/Systems_Supplies/ExpeditionGear")?.GetComponent<SuitPickupVolume>(); var eventDelegate = (MulticastDelegate)typeof(MultipleInteractionVolume).GetField(
nameof(MultipleInteractionVolume.OnPressInteract),
if (spv == null) return; BindingFlags.Instance | BindingFlags.NonPublic)
.GetValue(spv._interactVolume);
spv._containsSuit = false; foreach (var handler in eventDelegate.GetInvocationList())
if (spv._allowSuitReturn)
{ {
spv._interactVolume.ChangePrompt(UITextType.ReturnSuitPrompt, spv._pickupSuitCommandIndex); handler.Method.Invoke(handler.Target, new object[] { command });
}
} }
else else
{ {
spv._interactVolume.EnableSingleInteraction(false, spv._pickupSuitCommandIndex); Locator.GetPlayerTransform().GetComponent<PlayerSpacesuit>().SuitUp(false, true, true);
}
} }
spv._timer = 0f;
spv._index = 0;
spv.OnSuitUp();
GameObject suitGeometry = spv._suitGeometry;
if (suitGeometry != null) suitGeometry.SetActive(false);
OWCollider suitOWCollider = spv._suitOWCollider;
if (suitOWCollider != null) suitOWCollider.SetActivation(false);
spv.enabled = true;
} }
} }
} }

View File

@ -99,7 +99,7 @@ namespace NewHorizons.Builder.Props
_preCrashRecorderPrefab.name = "Prefab_NOM_Recorder_Vessel"; _preCrashRecorderPrefab.name = "Prefab_NOM_Recorder_Vessel";
_preCrashRecorderPrefab.transform.rotation = Quaternion.identity; _preCrashRecorderPrefab.transform.rotation = Quaternion.identity;
_trailmarkerPrefab = SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_NorthHemisphere/Sector_NorthPole/Sector_HangingCity/Sector_HangingCity_District2/Interactables_HangingCity_District2/Prefab_NOM_Sign"); _trailmarkerPrefab = SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_NorthHemisphere/Sector_NorthPole/Sector_HangingCity/Sector_HangingCity_District2/Interactables_HangingCity_District2/Prefab_NOM_Sign").InstantiateInactive();
_trailmarkerPrefab.name = "Prefab_NOM_Trailmarker"; _trailmarkerPrefab.name = "Prefab_NOM_Trailmarker";
_trailmarkerPrefab.transform.rotation = Quaternion.identity; _trailmarkerPrefab.transform.rotation = Quaternion.identity;
} }
@ -492,6 +492,9 @@ namespace NewHorizons.Builder.Props
trailmarkerObject.transform.position = planetGO.transform.TransformPoint(info?.position ?? Vector3.zero); trailmarkerObject.transform.position = planetGO.transform.TransformPoint(info?.position ?? Vector3.zero);
// shrink because that is what mobius does on all trailmarkers or else they are the size of the player
trailmarkerObject.transform.localScale = Vector3.one * 0.75f;
if (info.rotation != null) if (info.rotation != null)
{ {
trailmarkerObject.transform.rotation = planetGO.transform.TransformRotation(Quaternion.Euler(info.rotation)); trailmarkerObject.transform.rotation = planetGO.transform.TransformRotation(Quaternion.Euler(info.rotation));

View File

@ -1,4 +1,4 @@
using NewHorizons.External.Modules; using NewHorizons.External.Modules;
using OWML.Common; using OWML.Common;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
@ -15,6 +15,7 @@ namespace NewHorizons.Builder.ShipLog
entryLocationGameObject.transform.position = go.transform.TransformPoint(info.position ?? Vector3.zero); entryLocationGameObject.transform.position = go.transform.TransformPoint(info.position ?? Vector3.zero);
ShipLogEntryLocation newLocation = entryLocationGameObject.AddComponent<ShipLogEntryLocation>(); ShipLogEntryLocation newLocation = entryLocationGameObject.AddComponent<ShipLogEntryLocation>();
newLocation._entryID = info.id; newLocation._entryID = info.id;
newLocation._outerFogWarpVolume = go.GetComponentInChildren<OuterFogWarpVolume>();
newLocation._isWithinCloakField = info.cloaked; newLocation._isWithinCloakField = info.cloaked;
_locationsToInitialize.Add(newLocation); _locationsToInitialize.Add(newLocation);
entryLocationGameObject.SetActive(true); entryLocationGameObject.SetActive(true);

View File

@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
namespace NewHorizons.Components
{
[RequireComponent(typeof(OWTriggerVolume))]
public class TransparentCloudRenderQueueController : MonoBehaviour
{
public int insideQueue = 3001;
public int outsideQueue = 2999;
private OWTriggerVolume _triggerVolume;
public Renderer renderer;
public void Awake()
{
_triggerVolume = this.GetRequiredComponent<OWTriggerVolume>();
if (_triggerVolume == null) return;
_triggerVolume.OnEntry += OnTriggerVolumeEntry;
_triggerVolume.OnExit += OnTriggerVolumeExit;
}
public void OnDestroy()
{
if (_triggerVolume == null) return;
_triggerVolume.OnEntry -= OnTriggerVolumeEntry;
_triggerVolume.OnExit -= OnTriggerVolumeExit;
}
public void OnTriggerVolumeEntry(GameObject hitObj)
{
if (hitObj.CompareTag("PlayerDetector")) SetQueueToInside();
}
public void OnTriggerVolumeExit(GameObject hitObj)
{
if (hitObj.CompareTag("PlayerDetector")) SetQueueToOutside();
}
public void SetQueueToInside()
{
if (renderer == null) return;
renderer.sharedMaterial.renderQueue = insideQueue;
}
public void SetQueueToOutside()
{
if (renderer == null) return;
renderer.sharedMaterial.renderQueue = outsideQueue;
}
}
}

View File

@ -30,6 +30,8 @@ namespace NewHorizons.External.Modules
[EnumMember(Value = @"quantumMoon")] QuantumMoon = 1, [EnumMember(Value = @"quantumMoon")] QuantumMoon = 1,
[EnumMember(Value = @"basic")] Basic = 2, [EnumMember(Value = @"basic")] Basic = 2,
[EnumMember(Value = @"transparent")] Transparent = 3,
} }
[JsonObject] [JsonObject]

View File

@ -590,7 +590,7 @@ namespace NewHorizons.Handlers
if (!string.IsNullOrEmpty(body.Config.Atmosphere?.clouds?.texturePath)) if (!string.IsNullOrEmpty(body.Config.Atmosphere?.clouds?.texturePath))
{ {
CloudsBuilder.Make(go, sector, body.Config.Atmosphere, willHaveCloak, body.Mod); CloudsBuilder.Make(go, sector, body.Config.Atmosphere, willHaveCloak, body.Mod);
SunOverrideBuilder.Make(go, sector, body.Config.Atmosphere, body.Config.Water, surfaceSize); if (body.Config.Atmosphere.clouds.cloudsPrefab != External.Modules.CloudPrefabType.Transparent) SunOverrideBuilder.Make(go, sector, body.Config.Atmosphere, body.Config.Water, surfaceSize);
} }
if (body.Config.Atmosphere.hasRain || body.Config.Atmosphere.hasSnow) if (body.Config.Atmosphere.hasRain || body.Config.Atmosphere.hasSnow)

View File

@ -89,7 +89,7 @@ namespace NewHorizons.Handlers
heightMap.minHeight = body.Config.HeightMap.minHeight * size / body.Config.HeightMap.maxHeight; heightMap.minHeight = body.Config.HeightMap.minHeight * size / body.Config.HeightMap.maxHeight;
heightMap.stretch = body.Config.HeightMap.stretch; heightMap.stretch = body.Config.HeightMap.stretch;
} }
if (body.Config.Atmosphere?.clouds?.texturePath != null) if (body.Config.Atmosphere?.clouds?.texturePath != null && body.Config.Atmosphere?.clouds?.cloudsPrefab != CloudPrefabType.Transparent)
{ {
// Hacky but whatever I just want a sphere // Hacky but whatever I just want a sphere
size = Mathf.Clamp(body.Config.Atmosphere.size / 10, minSize, maxSize); size = Mathf.Clamp(body.Config.Atmosphere.size / 10, minSize, maxSize);

View File

@ -66,9 +66,10 @@ namespace NewHorizons.Handlers
foreach (var originalKey in config.ShipLogDictionary.Keys) foreach (var originalKey in config.ShipLogDictionary.Keys)
{ {
var key = originalKey.Replace("&lt;", "<").Replace("&gt;", ">").Replace("<![CDATA[", "").Replace("]]>", ""); var key = originalKey.Replace("&lt;", "<").Replace("&gt;", ">").Replace("<![CDATA[", "").Replace("]]>", "");
var value = config.ShipLogDictionary[originalKey].Replace("&lt;", "<").Replace("&gt;", ">").Replace("<![CDATA[", "").Replace("]]>", "");
if (!_shipLogTranslationDictionary[language].ContainsKey(key)) _shipLogTranslationDictionary[language].Add(key, config.ShipLogDictionary[originalKey]); if (!_shipLogTranslationDictionary[language].ContainsKey(key)) _shipLogTranslationDictionary[language].Add(key, value);
else _shipLogTranslationDictionary[language][key] = config.ShipLogDictionary[originalKey]; else _shipLogTranslationDictionary[language][key] = value;
} }
} }
@ -78,9 +79,10 @@ namespace NewHorizons.Handlers
foreach (var originalKey in config.DialogueDictionary.Keys) foreach (var originalKey in config.DialogueDictionary.Keys)
{ {
var key = originalKey.Replace("&lt;", "<").Replace("&gt;", ">").Replace("<![CDATA[", "").Replace("]]>", ""); var key = originalKey.Replace("&lt;", "<").Replace("&gt;", ">").Replace("<![CDATA[", "").Replace("]]>", "");
var value = config.DialogueDictionary[originalKey].Replace("&lt;", "<").Replace("&gt;", ">").Replace("<![CDATA[", "").Replace("]]>", "");
if (!_dialogueTranslationDictionary[language].ContainsKey(key)) _dialogueTranslationDictionary[language].Add(key, config.DialogueDictionary[originalKey]); if (!_dialogueTranslationDictionary[language].ContainsKey(key)) _dialogueTranslationDictionary[language].Add(key, value);
else _dialogueTranslationDictionary[language][key] = config.DialogueDictionary[originalKey]; else _dialogueTranslationDictionary[language][key] = value;
} }
} }
@ -90,9 +92,10 @@ namespace NewHorizons.Handlers
foreach (var originalKey in config.UIDictionary.Keys) foreach (var originalKey in config.UIDictionary.Keys)
{ {
var key = originalKey.Replace("&lt;", "<").Replace("&gt;", ">").Replace("<![CDATA[", "").Replace("]]>", ""); var key = originalKey.Replace("&lt;", "<").Replace("&gt;", ">").Replace("<![CDATA[", "").Replace("]]>", "");
var value = config.UIDictionary[originalKey].Replace("&lt;", "<").Replace("&gt;", ">").Replace("<![CDATA[", "").Replace("]]>", "");
if (!_uiTranslationDictionary[language].ContainsKey(key)) _uiTranslationDictionary[language].Add(key, config.UIDictionary[originalKey]); if (!_uiTranslationDictionary[language].ContainsKey(key)) _uiTranslationDictionary[language].Add(key, value);
else _uiTranslationDictionary[language][key] = config.UIDictionary[originalKey]; else _uiTranslationDictionary[language][key] = value;
} }
} }
} }

View File

@ -230,5 +230,20 @@ namespace NewHorizons.Patches
AchievementHandler.OnRevealFact(); AchievementHandler.OnRevealFact();
} }
[HarmonyPrefix]
[HarmonyPatch(typeof(ShipLogFact), nameof(ShipLogFact.GetText))]
public static bool ShipLogFact_GetText(ShipLogFact __instance, ref string __result)
{
if (ShipLogHandler.IsModdedFact(__instance.GetID()))
{
__result = TranslationHandler.GetTranslation(__instance._text, TranslationHandler.TextType.SHIPLOG);
return false;
}
else
{
return true;
}
}
} }
} }

View File

@ -400,12 +400,14 @@
"x-enumNames": [ "x-enumNames": [
"GiantsDeep", "GiantsDeep",
"QuantumMoon", "QuantumMoon",
"Basic" "Basic",
"Transparent"
], ],
"enum": [ "enum": [
"giantsDeep", "giantsDeep",
"quantumMoon", "quantumMoon",
"basic" "basic",
"transparent"
] ]
}, },
"FluidType": { "FluidType": {

View File

@ -95,40 +95,43 @@ namespace NewHorizons.Utility
{ {
if (CachedGameObjects.TryGetValue(path, out var go)) return go; if (CachedGameObjects.TryGetValue(path, out var go)) return go;
// 1: normal find
go = GameObject.Find(path); go = GameObject.Find(path);
if (go == null) if (go)
{ {
// find inactive use root + transform.find
var names = path.Split('/');
var rootName = names[0];
var root = SceneManager.GetActiveScene().GetRootGameObjects().FirstOrDefault(x => x.name == rootName);
if (root == null)
{
if (warn) Logger.LogWarning($"Couldn't find root object in path {path}");
return null;
}
var childPath = string.Join("/", names.Skip(1));
go = root.FindChild(childPath);
if (go == null)
{
var name = names.Last();
if (warn) Logger.LogWarning($"Couldn't find object in path {path}, will look for potential matches for name {name}");
// find resource to include inactive objects
// also includes prefabs but hopefully thats okay
go = FindResourceOfTypeAndName<GameObject>(name);
if (go == null)
{
if (warn) Logger.LogWarning($"Couldn't find object with name {name}");
return null;
}
}
}
CachedGameObjects.Add(path, go); CachedGameObjects.Add(path, go);
return go; return go;
} }
// 2: find inactive using root + transform.find
var names = path.Split('/');
var rootName = names[0];
var root = SceneManager.GetActiveScene().GetRootGameObjects().FirstOrDefault(x => x.name == rootName);
var childPath = string.Join("/", names.Skip(1));
go = root ? root.FindChild(childPath) : null;
if (go)
{
CachedGameObjects.Add(path, go);
return go;
}
var name = names.Last();
if (warn) Logger.LogWarning($"Couldn't find object in path {path}, will look for potential matches for name {name}");
// 3: find resource to include inactive objects (but skip prefabs
go = Resources.FindObjectsOfTypeAll<GameObject>()
.FirstOrDefault(x => x.name == name && x.scene.name != null);
if (go)
{
CachedGameObjects.Add(path, go);
return go;
}
if (warn) Logger.LogWarning($"Couldn't find object with name {name}");
return null;
}
public static List<GameObject> GetAllChildren(this GameObject parent) public static List<GameObject> GetAllChildren(this GameObject parent)
{ {
var children = new List<GameObject>(); var children = new List<GameObject>();