fixed merge conflict with dev

This commit is contained in:
FreezeDriedMangoes 2022-06-10 17:26:40 -04:00
commit e25fdb2de8
70 changed files with 1063 additions and 542 deletions

View File

@ -26,7 +26,7 @@ body:
- Epic Games - Epic Games
- Xbox Game Pass - Xbox Game Pass
validations: validations:
required: true required: false
- type: textarea - type: textarea
id: mods id: mods
attributes: attributes:
@ -34,7 +34,7 @@ body:
description: Please define which mods you had enabled when the problem occurred. description: Please define which mods you had enabled when the problem occurred.
render: Markdown render: Markdown
validations: validations:
required: true required: false
- type: textarea - type: textarea
id: logs id: logs
attributes: attributes:

View File

@ -1,4 +1,5 @@
using NewHorizons.External.Modules; using NewHorizons.External.Modules;
using NewHorizons.Utility;
using UnityEngine; using UnityEngine;
namespace NewHorizons.Builder.Atmosphere namespace NewHorizons.Builder.Atmosphere
{ {
@ -16,7 +17,7 @@ namespace NewHorizons.Builder.Atmosphere
if (atmosphereModule.useAtmosphereShader) if (atmosphereModule.useAtmosphereShader)
{ {
GameObject atmo = GameObject.Instantiate(GameObject.Find("TimberHearth_Body/Atmosphere_TH/AtmoSphere"), atmoGO.transform, true); GameObject atmo = GameObject.Instantiate(SearchUtilities.Find("TimberHearth_Body/Atmosphere_TH/AtmoSphere"), atmoGO.transform, true);
atmo.transform.position = planetGO.transform.TransformPoint(Vector3.zero); atmo.transform.position = planetGO.transform.TransformPoint(Vector3.zero);
atmo.transform.localScale = Vector3.one * atmosphereModule.size * 1.2f; atmo.transform.localScale = Vector3.one * atmosphereModule.size * 1.2f;
foreach (var meshRenderer in atmo.GetComponentsInChildren<MeshRenderer>()) foreach (var meshRenderer in atmo.GetComponentsInChildren<MeshRenderer>())

View File

@ -1,224 +1,227 @@
using NewHorizons.External.Modules; using NewHorizons.External.Modules;
using NewHorizons.Utility; using NewHorizons.Utility;
using OWML.Common; using OWML.Common;
using System; using System;
using UnityEngine; using UnityEngine;
using Logger = NewHorizons.Utility.Logger; using Logger = NewHorizons.Utility.Logger;
namespace NewHorizons.Builder.Atmosphere namespace NewHorizons.Builder.Atmosphere
{ {
public static class CloudsBuilder public static class CloudsBuilder
{ {
private static Shader _sphereShader = null; private static Shader _sphereShader = null;
private static Material[] _gdCloudMaterials; private static Material[] _gdCloudMaterials;
private static GameObject _lightningPrefab; private static Material[] _qmCloudMaterials;
private static Texture2D _colorRamp; private static GameObject _lightningPrefab;
private static readonly int Color1 = Shader.PropertyToID("_Color"); private static Texture2D _colorRamp;
private static readonly int TintColor = Shader.PropertyToID("_TintColor"); private static readonly int Color1 = Shader.PropertyToID("_Color");
private static readonly int MainTex = Shader.PropertyToID("_MainTex"); private static readonly int TintColor = Shader.PropertyToID("_TintColor");
private static readonly int RampTex = Shader.PropertyToID("_RampTex"); private static readonly int MainTex = Shader.PropertyToID("_MainTex");
private static readonly int CapTex = Shader.PropertyToID("_CapTex"); private static readonly int RampTex = Shader.PropertyToID("_RampTex");
private static readonly int ColorRamp = Shader.PropertyToID("_ColorRamp"); private static readonly int CapTex = Shader.PropertyToID("_CapTex");
private static readonly int ColorRamp = Shader.PropertyToID("_ColorRamp");
public static void Make(GameObject planetGO, Sector sector, AtmosphereModule atmo, IModBehaviour mod)
{ public static void Make(GameObject planetGO, Sector sector, AtmosphereModule atmo, IModBehaviour mod)
if (_lightningPrefab == null) _lightningPrefab = GameObject.Find("GiantsDeep_Body/Sector_GD/Clouds_GD/LightningGenerator_GD"); {
if (_colorRamp == null) _colorRamp = ImageUtilities.GetTexture(Main.Instance, "AssetBundle/textures/Clouds_Bottom_ramp.png"); if (_lightningPrefab == null) _lightningPrefab = SearchUtilities.Find("GiantsDeep_Body/Sector_GD/Clouds_GD/LightningGenerator_GD");
if (_colorRamp == null) _colorRamp = ImageUtilities.GetTexture(Main.Instance, "AssetBundle/textures/Clouds_Bottom_ramp.png");
GameObject cloudsMainGO = new GameObject("Clouds");
cloudsMainGO.SetActive(false); GameObject cloudsMainGO = new GameObject("Clouds");
cloudsMainGO.transform.parent = sector?.transform ?? planetGO.transform; cloudsMainGO.SetActive(false);
cloudsMainGO.transform.parent = sector?.transform ?? planetGO.transform;
MakeTopClouds(cloudsMainGO, atmo, mod);
MakeTopClouds(cloudsMainGO, atmo, mod);
GameObject cloudsBottomGO = new GameObject("BottomClouds");
cloudsBottomGO.SetActive(false); GameObject cloudsBottomGO = new GameObject("BottomClouds");
cloudsBottomGO.transform.parent = cloudsMainGO.transform; cloudsBottomGO.SetActive(false);
cloudsBottomGO.transform.localScale = Vector3.one * atmo.clouds.innerCloudRadius; cloudsBottomGO.transform.parent = cloudsMainGO.transform;
cloudsBottomGO.transform.localScale = Vector3.one * atmo.clouds.innerCloudRadius;
TessellatedSphereRenderer bottomTSR = cloudsBottomGO.AddComponent<TessellatedSphereRenderer>();
bottomTSR.tessellationMeshGroup = GameObject.Find("CloudsBottomLayer_QM").GetComponent<TessellatedSphereRenderer>().tessellationMeshGroup; TessellatedSphereRenderer bottomTSR = cloudsBottomGO.AddComponent<TessellatedSphereRenderer>();
var bottomTSRMaterials = GameObject.Find("CloudsBottomLayer_QM").GetComponent<TessellatedSphereRenderer>().sharedMaterials; bottomTSR.tessellationMeshGroup = SearchUtilities.Find("CloudsBottomLayer_QM").GetComponent<TessellatedSphereRenderer>().tessellationMeshGroup;
var bottomTSRMaterials = SearchUtilities.Find("CloudsBottomLayer_QM").GetComponent<TessellatedSphereRenderer>().sharedMaterials;
// If they set a colour apply it to all the materials else keep the default QM one
if (atmo.clouds.tint != null) // If they set a colour apply it to all the materials else keep the default QM one
{ if (atmo.clouds.tint != null)
var bottomColor = atmo.clouds.tint.ToColor(); {
var bottomColor = atmo.clouds.tint.ToColor();
var bottomTSRTempArray = new Material[2];
var bottomTSRTempArray = new Material[2];
bottomTSRTempArray[0] = new Material(bottomTSRMaterials[0]);
bottomTSRTempArray[0].SetColor(Color1, bottomColor); bottomTSRTempArray[0] = new Material(bottomTSRMaterials[0]);
bottomTSRTempArray[0].SetColor(TintColor, bottomColor); bottomTSRTempArray[0].SetColor(Color1, bottomColor);
bottomTSRTempArray[0].SetTexture(ColorRamp, ImageUtilities.TintImage(_colorRamp, bottomColor)); bottomTSRTempArray[0].SetColor(TintColor, bottomColor);
bottomTSRTempArray[0].SetTexture(ColorRamp, ImageUtilities.TintImage(_colorRamp, bottomColor));
bottomTSRTempArray[1] = new Material(bottomTSRMaterials[1]);
bottomTSRTempArray[1] = new Material(bottomTSRMaterials[1]);
bottomTSR.sharedMaterials = bottomTSRTempArray;
} bottomTSR.sharedMaterials = bottomTSRTempArray;
else }
{ else
bottomTSR.sharedMaterials = bottomTSRMaterials; {
} bottomTSR.sharedMaterials = bottomTSRMaterials;
}
bottomTSR.maxLOD = 6;
bottomTSR.LODBias = 0; bottomTSR.maxLOD = 6;
bottomTSR.LODRadius = 1f; bottomTSR.LODBias = 0;
bottomTSR.LODRadius = 1f;
TessSphereSectorToggle bottomTSST = cloudsBottomGO.AddComponent<TessSphereSectorToggle>();
bottomTSST._sector = sector; TessSphereSectorToggle bottomTSST = cloudsBottomGO.AddComponent<TessSphereSectorToggle>();
bottomTSST._sector = sector;
GameObject cloudsFluidGO = new GameObject("CloudsFluid");
cloudsFluidGO.SetActive(false); GameObject cloudsFluidGO = new GameObject("CloudsFluid");
cloudsFluidGO.layer = 17; cloudsFluidGO.SetActive(false);
cloudsFluidGO.transform.parent = cloudsMainGO.transform; cloudsFluidGO.layer = 17;
cloudsFluidGO.transform.parent = cloudsMainGO.transform;
SphereCollider fluidSC = cloudsFluidGO.AddComponent<SphereCollider>();
fluidSC.isTrigger = true; SphereCollider fluidSC = cloudsFluidGO.AddComponent<SphereCollider>();
fluidSC.radius = atmo.size; fluidSC.isTrigger = true;
fluidSC.radius = atmo.size;
OWShellCollider fluidOWSC = cloudsFluidGO.AddComponent<OWShellCollider>();
fluidOWSC._innerRadius = atmo.size * 0.9f; OWShellCollider fluidOWSC = cloudsFluidGO.AddComponent<OWShellCollider>();
fluidOWSC._innerRadius = atmo.size * 0.9f;
CloudLayerFluidVolume fluidCLFV = cloudsFluidGO.AddComponent<CloudLayerFluidVolume>();
fluidCLFV._layer = 5; CloudLayerFluidVolume fluidCLFV = cloudsFluidGO.AddComponent<CloudLayerFluidVolume>();
fluidCLFV._priority = 1; fluidCLFV._layer = 5;
fluidCLFV._density = 1.2f; fluidCLFV._priority = 1;
fluidCLFV._density = 1.2f;
var fluidType = FluidVolume.Type.CLOUD;
var fluidType = FluidVolume.Type.CLOUD;
try
{ try
fluidType = (FluidVolume.Type)Enum.Parse(typeof(FluidVolume.Type), Enum.GetName(typeof(CloudFluidType), atmo.clouds.fluidType).ToUpper()); {
} fluidType = (FluidVolume.Type)Enum.Parse(typeof(FluidVolume.Type), Enum.GetName(typeof(CloudFluidType), atmo.clouds.fluidType).ToUpper());
catch (Exception ex) }
{ catch (Exception ex)
Logger.LogError($"Couldn't parse fluid volume type [{atmo.clouds.fluidType}]: {ex.Message}, {ex.StackTrace}"); {
} Logger.LogError($"Couldn't parse fluid volume type [{atmo.clouds.fluidType}]: {ex.Message}, {ex.StackTrace}");
}
fluidCLFV._fluidType = fluidType;
fluidCLFV._allowShipAutoroll = true; fluidCLFV._fluidType = fluidType;
fluidCLFV._disableOnStart = false; fluidCLFV._allowShipAutoroll = true;
fluidCLFV._disableOnStart = false;
// Fix the rotations once the rest is done
cloudsMainGO.transform.rotation = planetGO.transform.TransformRotation(Quaternion.Euler(0, 0, 0)); // Fix the rotations once the rest is done
// For the base shader it has to be rotated idk cloudsMainGO.transform.rotation = planetGO.transform.TransformRotation(Quaternion.Euler(0, 0, 0));
if (atmo.clouds.useBasicCloudShader) cloudsMainGO.transform.rotation = planetGO.transform.TransformRotation(Quaternion.Euler(90, 0, 0)); // For the base shader it has to be rotated idk
if (atmo.clouds.cloudsPrefab == CloudPrefabType.Basic) cloudsMainGO.transform.rotation = planetGO.transform.TransformRotation(Quaternion.Euler(90, 0, 0));
// Lightning
if (atmo.clouds.hasLightning) // Lightning
{ if (atmo.clouds.hasLightning)
var lightning = _lightningPrefab.InstantiateInactive(); {
lightning.transform.parent = cloudsMainGO.transform; var lightning = _lightningPrefab.InstantiateInactive();
lightning.transform.localPosition = Vector3.zero; lightning.transform.parent = cloudsMainGO.transform;
lightning.transform.localPosition = Vector3.zero;
var lightningGenerator = lightning.GetComponent<CloudLightningGenerator>();
lightningGenerator._altitude = (atmo.clouds.outerCloudRadius + atmo.clouds.innerCloudRadius) / 2f; var lightningGenerator = lightning.GetComponent<CloudLightningGenerator>();
lightningGenerator._audioSector = sector; lightningGenerator._altitude = (atmo.clouds.outerCloudRadius + atmo.clouds.innerCloudRadius) / 2f;
if (atmo.clouds.lightningGradient != null) lightningGenerator._audioSector = sector;
{ if (atmo.clouds.lightningGradient != null)
var gradient = new GradientColorKey[atmo.clouds.lightningGradient.Length]; {
var gradient = new GradientColorKey[atmo.clouds.lightningGradient.Length];
for(int i = 0; i < atmo.clouds.lightningGradient.Length; i++)
{ for(int i = 0; i < atmo.clouds.lightningGradient.Length; i++)
var pair = atmo.clouds.lightningGradient[i]; {
gradient[i] = new GradientColorKey(pair.tint.ToColor(), pair.time); var pair = atmo.clouds.lightningGradient[i];
} gradient[i] = new GradientColorKey(pair.tint.ToColor(), pair.time);
}
lightningGenerator._lightColor.colorKeys = gradient;
} lightningGenerator._lightColor.colorKeys = gradient;
lightning.SetActive(true); }
} lightning.SetActive(true);
}
cloudsMainGO.transform.position = planetGO.transform.TransformPoint(Vector3.zero);
cloudsBottomGO.transform.position = planetGO.transform.TransformPoint(Vector3.zero); cloudsMainGO.transform.position = planetGO.transform.TransformPoint(Vector3.zero);
cloudsFluidGO.transform.position = planetGO.transform.TransformPoint(Vector3.zero); cloudsBottomGO.transform.position = planetGO.transform.TransformPoint(Vector3.zero);
cloudsFluidGO.transform.position = planetGO.transform.TransformPoint(Vector3.zero);
cloudsBottomGO.SetActive(true);
cloudsFluidGO.SetActive(true); cloudsBottomGO.SetActive(true);
cloudsMainGO.SetActive(true); cloudsFluidGO.SetActive(true);
} cloudsMainGO.SetActive(true);
}
public static GameObject MakeTopClouds(GameObject rootObject, AtmosphereModule atmo, IModBehaviour mod)
{ public static GameObject MakeTopClouds(GameObject rootObject, AtmosphereModule atmo, IModBehaviour mod)
Color cloudTint = atmo.clouds.tint?.ToColor() ?? Color.white; {
Color cloudTint = atmo.clouds.tint?.ToColor() ?? Color.white;
Texture2D image, cap, ramp;
Texture2D image, cap, ramp;
try
{ try
image = ImageUtilities.GetTexture(mod, atmo.clouds.texturePath); {
image = ImageUtilities.GetTexture(mod, atmo.clouds.texturePath);
if (atmo.clouds.capPath == null) cap = ImageUtilities.ClearTexture(128, 128);
else cap = ImageUtilities.GetTexture(mod, atmo.clouds.capPath); if (atmo.clouds.capPath == null) cap = ImageUtilities.ClearTexture(128, 128);
if (atmo.clouds.rampPath == null) ramp = ImageUtilities.CanvasScaled(image, 1, image.height); else cap = ImageUtilities.GetTexture(mod, atmo.clouds.capPath);
else ramp = ImageUtilities.GetTexture(mod, atmo.clouds.rampPath); if (atmo.clouds.rampPath == null) ramp = ImageUtilities.CanvasScaled(image, 1, image.height);
} else ramp = ImageUtilities.GetTexture(mod, atmo.clouds.rampPath);
catch (Exception e) }
{ catch (Exception e)
Logger.LogError($"Couldn't load Cloud textures for [{rootObject.name}], {e.Message}, {e.StackTrace}"); {
return null; Logger.LogError($"Couldn't load Cloud textures for [{rootObject.name}], {e.Message}, {e.StackTrace}");
} return null;
}
GameObject cloudsTopGO = new GameObject("TopClouds");
cloudsTopGO.SetActive(false); GameObject cloudsTopGO = new GameObject("TopClouds");
cloudsTopGO.transform.parent = rootObject.transform; cloudsTopGO.SetActive(false);
cloudsTopGO.transform.localScale = Vector3.one * atmo.clouds.outerCloudRadius; cloudsTopGO.transform.parent = rootObject.transform;
cloudsTopGO.transform.localScale = Vector3.one * atmo.clouds.outerCloudRadius;
MeshFilter topMF = cloudsTopGO.AddComponent<MeshFilter>();
topMF.mesh = GameObject.Find("CloudsTopLayer_GD").GetComponent<MeshFilter>().mesh; MeshFilter topMF = cloudsTopGO.AddComponent<MeshFilter>();
topMF.mesh = SearchUtilities.Find("CloudsTopLayer_GD").GetComponent<MeshFilter>().mesh;
MeshRenderer topMR = cloudsTopGO.AddComponent<MeshRenderer>();
MeshRenderer topMR = cloudsTopGO.AddComponent<MeshRenderer>();
if (_sphereShader == null) _sphereShader = Main.NHAssetBundle.LoadAsset<Shader>("Assets/Shaders/SphereTextureWrapper.shader");
if (_gdCloudMaterials == null) _gdCloudMaterials = GameObject.Find("CloudsTopLayer_GD").GetComponent<MeshRenderer>().sharedMaterials; if (_sphereShader == null) _sphereShader = Main.NHAssetBundle.LoadAsset<Shader>("Assets/Shaders/SphereTextureWrapper.shader");
var tempArray = new Material[2]; if (_gdCloudMaterials == null) _gdCloudMaterials = SearchUtilities.Find("CloudsTopLayer_GD").GetComponent<MeshRenderer>().sharedMaterials;
if (_qmCloudMaterials == null) _qmCloudMaterials = SearchUtilities.Find("CloudsTopLayer_QM").GetComponent<MeshRenderer>().sharedMaterials;
if (atmo.clouds.useBasicCloudShader) Material[] prefabMaterials = atmo.clouds.cloudsPrefab == CloudPrefabType.GiantsDeep ? _gdCloudMaterials : _qmCloudMaterials;
{ var tempArray = new Material[2];
var material = new Material(_sphereShader);
if (atmo.clouds.unlit) material.renderQueue = 2550; if (atmo.clouds.cloudsPrefab == CloudPrefabType.Basic)
material.name = atmo.clouds.unlit ? "BasicCloud" : "BasicShadowCloud"; {
var material = new Material(_sphereShader);
tempArray[0] = material; if (atmo.clouds.unlit) material.renderQueue = 2550;
} material.name = atmo.clouds.unlit ? "BasicCloud" : "BasicShadowCloud";
else
{ tempArray[0] = material;
var material = new Material(_gdCloudMaterials[0]); }
if (atmo.clouds.unlit) material.renderQueue = 2550; else
material.name = atmo.clouds.unlit ? "AdvancedCloud" : "AdvancedShadowCloud"; {
tempArray[0] = material; var material = new Material(prefabMaterials[0]);
} if (atmo.clouds.unlit) material.renderQueue = 2550;
material.name = atmo.clouds.unlit ? "AdvancedCloud" : "AdvancedShadowCloud";
// This is the stencil material for the fog under the clouds tempArray[0] = material;
tempArray[1] = new Material(_gdCloudMaterials[1]); }
topMR.sharedMaterials = tempArray;
// This is the stencil material for the fog under the clouds
foreach (var material in topMR.sharedMaterials) tempArray[1] = new Material(prefabMaterials[1]);
{ topMR.sharedMaterials = tempArray;
material.SetColor(Color1, cloudTint);
material.SetColor(TintColor, cloudTint); foreach (var material in topMR.sharedMaterials)
{
material.SetTexture(MainTex, image); material.SetColor(Color1, cloudTint);
material.SetTexture(RampTex, ramp); material.SetColor(TintColor, cloudTint);
material.SetTexture(CapTex, cap);
} material.SetTexture(MainTex, image);
material.SetTexture(RampTex, ramp);
if (atmo.clouds.unlit) material.SetTexture(CapTex, cap);
{ }
cloudsTopGO.layer = LayerMask.NameToLayer("IgnoreSun");
} if (atmo.clouds.unlit)
{
RotateTransform topRT = cloudsTopGO.AddComponent<RotateTransform>(); cloudsTopGO.layer = LayerMask.NameToLayer("IgnoreSun");
// Idk why but the axis is weird }
topRT._localAxis = atmo.clouds.useBasicCloudShader ? Vector3.forward : Vector3.up;
topRT._degreesPerSecond = 10; RotateTransform topRT = cloudsTopGO.AddComponent<RotateTransform>();
topRT._randomizeRotationRate = false; // Idk why but the axis is weird
topRT._localAxis = atmo.clouds.cloudsPrefab == CloudPrefabType.Basic ? Vector3.forward : Vector3.up;
cloudsTopGO.transform.localPosition = Vector3.zero; topRT._degreesPerSecond = 10;
topRT._randomizeRotationRate = false;
cloudsTopGO.SetActive(true);
cloudsTopGO.transform.localPosition = Vector3.zero;
return cloudsTopGO;
} cloudsTopGO.SetActive(true);
}
} return cloudsTopGO;
}
}
}

View File

@ -17,9 +17,9 @@ namespace NewHorizons.Builder.Atmosphere
fogGO.transform.localScale = Vector3.one; fogGO.transform.localScale = Vector3.one;
// Going to copy from dark bramble // Going to copy from dark bramble
var dbFog = GameObject.Find("DarkBramble_Body/Atmosphere_DB/FogLOD"); var dbFog = SearchUtilities.Find("DarkBramble_Body/Atmosphere_DB/FogLOD");
var dbPlanetaryFogController = GameObject.Find("DarkBramble_Body/Atmosphere_DB/FogSphere_DB").GetComponent<PlanetaryFogController>(); var dbPlanetaryFogController = SearchUtilities.Find("DarkBramble_Body/Atmosphere_DB/FogSphere_DB").GetComponent<PlanetaryFogController>();
var brambleLODFog = GameObject.Find("DarkBramble_Body/Sector_DB/Proxy_DB/LOD_DB_VolumeticFog"); var brambleLODFog = SearchUtilities.Find("DarkBramble_Body/Sector_DB/Proxy_DB/LOD_DB_VolumeticFog");
MeshFilter MF = fogGO.AddComponent<MeshFilter>(); MeshFilter MF = fogGO.AddComponent<MeshFilter>();
MF.mesh = dbFog.GetComponent<MeshFilter>().mesh; MF.mesh = dbFog.GetComponent<MeshFilter>().mesh;

View File

@ -1,4 +1,5 @@
using NewHorizons.External.Configs; using NewHorizons.External.Configs;
using NewHorizons.Utility;
using UnityEngine; using UnityEngine;
namespace NewHorizons.Builder.Atmosphere namespace NewHorizons.Builder.Atmosphere
{ {
@ -6,7 +7,7 @@ namespace NewHorizons.Builder.Atmosphere
{ {
private static readonly int FogColor = Shader.PropertyToID("_FogColor"); private static readonly int FogColor = Shader.PropertyToID("_FogColor");
public static void Make(GameObject planetGO, PlanetConfig config, float sphereOfInfluence) public static void Make(GameObject planetGO, OWRigidbody owrb, PlanetConfig config, float sphereOfInfluence)
{ {
var innerRadius = config.Base.surfaceSize; var innerRadius = config.Base.surfaceSize;
@ -37,7 +38,7 @@ namespace NewHorizons.Builder.Atmosphere
EffectRuleset ER = rulesetGO.AddComponent<EffectRuleset>(); EffectRuleset ER = rulesetGO.AddComponent<EffectRuleset>();
ER._type = EffectRuleset.BubbleType.Underwater; ER._type = EffectRuleset.BubbleType.Underwater;
var gdRuleset = GameObject.Find("GiantsDeep_Body/Sector_GD/Volumes_GD/RulesetVolumes_GD").GetComponent<EffectRuleset>(); var gdRuleset = SearchUtilities.Find("GiantsDeep_Body/Sector_GD/Volumes_GD/RulesetVolumes_GD").GetComponent<EffectRuleset>();
ER._material = gdRuleset._material; ER._material = gdRuleset._material;
@ -48,6 +49,32 @@ namespace NewHorizons.Builder.Atmosphere
} }
ER._cloudMaterial = cloudMaterial; ER._cloudMaterial = cloudMaterial;
if (config.Base.zeroGravityRadius != 0)
{
var zeroGObject = new GameObject("ZeroGVolume");
zeroGObject.transform.parent = volumesGO.transform;
zeroGObject.transform.localPosition = Vector3.zero;
zeroGObject.transform.localScale = Vector3.one * config.Base.zeroGravityRadius;
zeroGObject.layer = LayerMask.NameToLayer("BasicEffectVolume");
var sphereCollider = zeroGObject.AddComponent<SphereCollider>();
sphereCollider.radius = 1;
sphereCollider.isTrigger = true;
var owCollider = zeroGObject.AddComponent<OWCollider>();
owCollider._parentBody = owrb;
owCollider._collider = sphereCollider;
var triggerVolume = zeroGObject.AddComponent<OWTriggerVolume>();
triggerVolume._owCollider = owCollider;
var zeroGVolume = zeroGObject.AddComponent<ZeroGVolume>();
zeroGVolume._attachedBody = owrb;
zeroGVolume._triggerVolume = triggerVolume;
zeroGVolume._inheritable = true;
zeroGVolume._priority = 1;
}
volumesGO.transform.position = planetGO.transform.position; volumesGO.transform.position = planetGO.transform.position;
rulesetGO.SetActive(true); rulesetGO.SetActive(true);
volumesGO.SetActive(true); volumesGO.SetActive(true);

View File

@ -1,4 +1,4 @@
using NewHorizons.External.Configs; using NewHorizons.External.Configs;
using NewHorizons.External.Modules; using NewHorizons.External.Modules;
using NewHorizons.Handlers; using NewHorizons.Handlers;
using NewHorizons.Utility; using NewHorizons.Utility;
@ -34,7 +34,6 @@ namespace NewHorizons.Builder.Body
hasMapMarker = false, hasMapMarker = false,
surfaceGravity = 1, surfaceGravity = 1,
surfaceSize = size, surfaceSize = size,
hasReferenceFrame = false,
gravityFallOff = GravityFallOff.InverseSquared gravityFallOff = GravityFallOff.InverseSquared
}; };
@ -49,6 +48,11 @@ namespace NewHorizons.Builder.Body
showOrbitLine = false showOrbitLine = false
}; };
config.ReferenceFrame = new ReferenceFrameModule()
{
hideInMap = true
};
config.ProcGen = belt.procGen; config.ProcGen = belt.procGen;
if (config.ProcGen == null) if (config.ProcGen == null)
{ {

View File

@ -1,12 +1,30 @@
using NewHorizons.Components; using NewHorizons.Components;
using NewHorizons.External.Modules;
using NewHorizons.Utility; using NewHorizons.Utility;
using OWML.Common;
using UnityEngine; using UnityEngine;
namespace NewHorizons.Builder.Body namespace NewHorizons.Builder.Body
{ {
public static class CloakBuilder public static class CloakBuilder
{ {
public static void Make(GameObject planetGO, Sector sector, OWRigidbody OWRB, float radius) public static void Make(GameObject planetGO, Sector sector, OWRigidbody OWRB, CloakModule module, bool keepReferenceFrame, IModBehaviour mod)
{ {
var radius = module.radius;
AudioClip clip = null;
if (module.audioClip != null) clip = SearchUtilities.FindResourceOfTypeAndName<AudioClip>(module.audioClip);
else if (module.audioFilePath != null)
{
try
{
clip = AudioUtilities.LoadAudio(mod.ModHelper.Manifest.ModFolderPath + "/" + module.audioFilePath);
}
catch (System.Exception e)
{
Utility.Logger.LogError($"Couldn't load audio file {module.audioFilePath} : {e.Message}");
}
}
var cloak = SearchUtilities.Find("RingWorld_Body/CloakingField_IP"); var cloak = SearchUtilities.Find("RingWorld_Body/CloakingField_IP");
var newCloak = GameObject.Instantiate(cloak, sector?.transform ?? planetGO.transform); var newCloak = GameObject.Instantiate(cloak, sector?.transform ?? planetGO.transform);
@ -29,11 +47,23 @@ namespace NewHorizons.Builder.Body
var cloakSectorController = newCloak.AddComponent<CloakSectorController>(); var cloakSectorController = newCloak.AddComponent<CloakSectorController>();
cloakSectorController.Init(newCloak.GetComponent<CloakFieldController>(), planetGO); cloakSectorController.Init(newCloak.GetComponent<CloakFieldController>(), planetGO);
var cloakAudioSource = newCloak.GetComponentInChildren<OWAudioSource>();
cloakAudioSource._audioSource = cloakAudioSource.GetComponent<AudioSource>();
cloakAudioSource._audioLibraryClip = AudioType.None;
cloakAudioSource._clipArrayIndex = 0;
cloakAudioSource._clipArrayLength = 0;
cloakAudioSource._clipSelectionOnPlay = OWAudioSource.ClipSelectionOnPlay.MANUAL;
cloakAudioSource.clip = clip;
newCloak.SetActive(true); newCloak.SetActive(true);
cloakFieldController.enabled = true; cloakFieldController.enabled = true;
cloakSectorController.EnableCloak();
// To cloak from the start // To cloak from the start
Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(cloakSectorController.OnPlayerExit); Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(cloakSectorController.OnPlayerExit);
Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(clip != null ? cloakSectorController.TurnOnMusic : cloakSectorController.TurnOffMusic);
Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(keepReferenceFrame ? cloakSectorController.EnableReferenceFrameVolume : cloakSectorController.DisableReferenceFrameVolume);
} }
} }
} }

View File

@ -1,4 +1,5 @@
using NewHorizons.External.Configs; using NewHorizons.External.Configs;
using NewHorizons.Utility;
using UnityEngine; using UnityEngine;
namespace NewHorizons.Builder.Body namespace NewHorizons.Builder.Body
{ {
@ -6,7 +7,7 @@ namespace NewHorizons.Builder.Body
{ {
public static void Make(GameObject planetGO, Sector sector, PlanetConfig config) public static void Make(GameObject planetGO, Sector sector, PlanetConfig config)
{ {
var cometTail = GameObject.Instantiate(GameObject.Find("Comet_Body/Sector_CO/Effects_CO/Effects_CO_TailMeshes"), sector?.transform ?? planetGO.transform); var cometTail = GameObject.Instantiate(SearchUtilities.Find("Comet_Body/Sector_CO/Effects_CO/Effects_CO_TailMeshes"), sector?.transform ?? planetGO.transform);
cometTail.transform.position = planetGO.transform.position; cometTail.transform.position = planetGO.transform.position;
cometTail.name = "CometTail"; cometTail.name = "CometTail";
cometTail.transform.localScale = Vector3.one * config.Base.surfaceSize / 110; cometTail.transform.localScale = Vector3.one * config.Base.surfaceSize / 110;

View File

@ -1,4 +1,4 @@
using System.Runtime.Serialization; using System.Runtime.Serialization;
using NewHorizons.Components; using NewHorizons.Components;
using NewHorizons.Utility; using NewHorizons.Utility;
using UnityEngine; using UnityEngine;
@ -43,13 +43,13 @@ namespace NewHorizons.Builder.Body
scaleRoot.transform.localPosition = Vector3.zero; scaleRoot.transform.localPosition = Vector3.zero;
scaleRoot.transform.localScale = new Vector3(1, 1, 1); scaleRoot.transform.localScale = new Vector3(1, 1, 1);
var proxyGO = GameObject.Instantiate(GameObject.Find("SandFunnel_Body/ScaleRoot/Proxy_SandFunnel"), scaleRoot.transform); var proxyGO = GameObject.Instantiate(SearchUtilities.Find("SandFunnel_Body/ScaleRoot/Proxy_SandFunnel"), scaleRoot.transform);
proxyGO.name = "Proxy_Funnel"; proxyGO.name = "Proxy_Funnel";
var geoGO = GameObject.Instantiate(GameObject.Find("SandFunnel_Body/ScaleRoot/Geo_SandFunnel"), scaleRoot.transform); var geoGO = GameObject.Instantiate(SearchUtilities.Find("SandFunnel_Body/ScaleRoot/Geo_SandFunnel"), scaleRoot.transform);
geoGO.name = "Geo_Funnel"; geoGO.name = "Geo_Funnel";
var volumesGO = GameObject.Instantiate(GameObject.Find("SandFunnel_Body/ScaleRoot/Volumes_SandFunnel"), scaleRoot.transform); var volumesGO = GameObject.Instantiate(SearchUtilities.Find("SandFunnel_Body/ScaleRoot/Volumes_SandFunnel"), scaleRoot.transform);
volumesGO.name = "Volumes_Funnel"; volumesGO.name = "Volumes_Funnel";
var sfv = volumesGO.GetComponentInChildren<SimpleFluidVolume>(); var sfv = volumesGO.GetComponentInChildren<SimpleFluidVolume>();
var fluidVolume = sfv.gameObject; var fluidVolume = sfv.gameObject;
@ -63,7 +63,7 @@ namespace NewHorizons.Builder.Body
GameObject.Destroy(geoGO.transform.Find("Effects_HT_SandColumn/SandColumn_Interior").gameObject); GameObject.Destroy(geoGO.transform.Find("Effects_HT_SandColumn/SandColumn_Interior").gameObject);
var waterMaterials = GameObject.Find("TimberHearth_Body/Sector_TH/Geometry_TH/Terrain_TH_Water_v3/Village_Upper_Water/Village_Upper_Water_Geo").GetComponent<MeshRenderer>().materials; var waterMaterials = SearchUtilities.Find("TimberHearth_Body/Sector_TH/Geometry_TH/Terrain_TH_Water_v3/Village_Upper_Water/Village_Upper_Water_Geo").GetComponent<MeshRenderer>().materials;
var materials = new Material[waterMaterials.Length]; var materials = new Material[waterMaterials.Length];
for (int i = 0; i < waterMaterials.Length; i++) for (int i = 0; i < waterMaterials.Length; i++)
{ {
@ -111,7 +111,7 @@ namespace NewHorizons.Builder.Body
GameObject.Destroy(geoGO.transform.Find("Effects_HT_SandColumn/SandColumn_Interior").gameObject); GameObject.Destroy(geoGO.transform.Find("Effects_HT_SandColumn/SandColumn_Interior").gameObject);
var lavaMaterial = new Material(GameObject.Find("VolcanicMoon_Body/MoltenCore_VM/LavaSphere").GetComponent<MeshRenderer>().material); var lavaMaterial = new Material(SearchUtilities.Find("VolcanicMoon_Body/MoltenCore_VM/LavaSphere").GetComponent<MeshRenderer>().material);
lavaMaterial.mainTextureOffset = new Vector2(0.1f, 0.2f); lavaMaterial.mainTextureOffset = new Vector2(0.1f, 0.2f);
lavaMaterial.mainTextureScale = new Vector2(1f, 3f); lavaMaterial.mainTextureScale = new Vector2(1f, 3f);

View File

@ -1,4 +1,5 @@
using UnityEngine; using UnityEngine;
using NewHorizons.Utility;
namespace NewHorizons.Builder.Body namespace NewHorizons.Builder.Body
{ {
public static class GeometryBuilder public static class GeometryBuilder
@ -9,7 +10,7 @@ namespace NewHorizons.Builder.Body
groundGO.transform.parent = sector?.transform ?? planetGO.transform; groundGO.transform.parent = sector?.transform ?? planetGO.transform;
groundGO.transform.localScale = new Vector3(groundScale, groundScale, groundScale); groundGO.transform.localScale = new Vector3(groundScale, groundScale, groundScale);
groundGO.transform.position = planetGO.transform.position; groundGO.transform.position = planetGO.transform.position;
groundGO.GetComponent<MeshFilter>().mesh = GameObject.Find("CloudsTopLayer_GD").GetComponent<MeshFilter>().mesh; groundGO.GetComponent<MeshFilter>().mesh = SearchUtilities.Find("CloudsTopLayer_GD").GetComponent<MeshFilter>().mesh;
groundGO.GetComponent<SphereCollider>().radius = 1f; groundGO.GetComponent<SphereCollider>().radius = 1f;
groundGO.SetActive(true); groundGO.SetActive(true);
} }

View File

@ -1,4 +1,4 @@
using NewHorizons.Builder.Body.Geometry; using NewHorizons.Builder.Body.Geometry;
using NewHorizons.External.Modules; using NewHorizons.External.Modules;
using NewHorizons.Utility; using NewHorizons.Utility;
using OWML.Common; using OWML.Common;
@ -57,7 +57,8 @@ namespace NewHorizons.Builder.Body
var cubeSphereMC = cubeSphere.AddComponent<MeshCollider>(); var cubeSphereMC = cubeSphere.AddComponent<MeshCollider>();
cubeSphereMC.sharedMesh = mesh; cubeSphereMC.sharedMesh = mesh;
if (planetGO.GetComponent<ProxyShadowCasterSuperGroup>() != null) cubeSphere.AddComponent<ProxyShadowCaster>(); var superGroup = planetGO.GetComponent<ProxyShadowCasterSuperGroup>();
if (superGroup != null) cubeSphere.AddComponent<ProxyShadowCaster>()._superGroup = superGroup;
// Fix rotation in the end // Fix rotation in the end
cubeSphere.transform.rotation = planetGO.transform.TransformRotation(Quaternion.Euler(90, 0, 0)); cubeSphere.transform.rotation = planetGO.transform.TransformRotation(Quaternion.Euler(90, 0, 0));

View File

@ -1,5 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using NewHorizons.Utility;
using NewHorizons.External.Modules.VariableSize; using NewHorizons.External.Modules.VariableSize;
namespace NewHorizons.Builder.Body namespace NewHorizons.Builder.Body
@ -28,7 +29,7 @@ namespace NewHorizons.Builder.Body
moltenCore.transform.position = planetGO.transform.position; moltenCore.transform.position = planetGO.transform.position;
moltenCore.transform.localScale = Vector3.one * module.size; moltenCore.transform.localScale = Vector3.one * module.size;
var lavaSphere = GameObject.Instantiate(GameObject.Find("VolcanicMoon_Body/MoltenCore_VM/LavaSphere"), moltenCore.transform); var lavaSphere = GameObject.Instantiate(SearchUtilities.Find("VolcanicMoon_Body/MoltenCore_VM/LavaSphere"), moltenCore.transform);
lavaSphere.transform.localScale = Vector3.one; lavaSphere.transform.localScale = Vector3.one;
lavaSphere.transform.name = "LavaSphere"; lavaSphere.transform.name = "LavaSphere";
lavaSphere.GetComponent<MeshRenderer>().material.SetFloat(HeightScale, heightScale); lavaSphere.GetComponent<MeshRenderer>().material.SetFloat(HeightScale, heightScale);
@ -37,7 +38,7 @@ namespace NewHorizons.Builder.Body
var sectorCullGroup = lavaSphere.GetComponent<SectorCullGroup>(); var sectorCullGroup = lavaSphere.GetComponent<SectorCullGroup>();
sectorCullGroup.SetSector(sector); sectorCullGroup.SetSector(sector);
var moltenCoreProxy = GameObject.Instantiate(GameObject.Find("VolcanicMoon_Body/MoltenCore_VM/MoltenCore_Proxy"), moltenCore.transform); ; var moltenCoreProxy = GameObject.Instantiate(SearchUtilities.Find("VolcanicMoon_Body/MoltenCore_VM/MoltenCore_Proxy"), moltenCore.transform); ;
moltenCoreProxy.name = "MoltenCore_Proxy"; moltenCoreProxy.name = "MoltenCore_Proxy";
var proxyLavaSphere = moltenCoreProxy.transform.Find("LavaSphere (1)"); var proxyLavaSphere = moltenCoreProxy.transform.Find("LavaSphere (1)");
@ -50,7 +51,7 @@ namespace NewHorizons.Builder.Body
sectorProxy._renderers = new List<Renderer> { proxyLavaSphere.GetComponent<MeshRenderer>() }; sectorProxy._renderers = new List<Renderer> { proxyLavaSphere.GetComponent<MeshRenderer>() };
sectorProxy.SetSector(sector); sectorProxy.SetSector(sector);
var destructionVolume = GameObject.Instantiate(GameObject.Find("VolcanicMoon_Body/MoltenCore_VM/DestructionVolume"), moltenCore.transform); var destructionVolume = GameObject.Instantiate(SearchUtilities.Find("VolcanicMoon_Body/MoltenCore_VM/DestructionVolume"), moltenCore.transform);
destructionVolume.GetComponent<SphereCollider>().radius = 1; destructionVolume.GetComponent<SphereCollider>().radius = 1;
destructionVolume.SetActive(true); destructionVolume.SetActive(true);

View File

@ -1,4 +1,4 @@
using NewHorizons.Builder.Body.Geometry; using NewHorizons.Builder.Body.Geometry;
using NewHorizons.External.Modules; using NewHorizons.External.Modules;
using NewHorizons.Utility; using NewHorizons.Utility;
using UnityEngine; using UnityEngine;
@ -16,14 +16,14 @@ namespace NewHorizons.Builder.Body
GameObject icosphere = new GameObject("Icosphere"); GameObject icosphere = new GameObject("Icosphere");
icosphere.SetActive(false);
icosphere.transform.parent = sector?.transform ?? planetGO.transform; icosphere.transform.parent = sector?.transform ?? planetGO.transform;
icosphere.transform.rotation = Quaternion.Euler(90, 0, 0); icosphere.transform.rotation = Quaternion.Euler(90, 0, 0);
icosphere.transform.position = planetGO.transform.position; icosphere.transform.position = planetGO.transform.position;
Mesh mesh = Icosphere.Build(4, module.scale, module.scale * 1.2f); Mesh mesh = Icosphere.Build(4, module.scale, module.scale * 1.2f);
icosphere.AddComponent<MeshFilter>(); icosphere.AddComponent<MeshFilter>().mesh = mesh;
icosphere.GetComponent<MeshFilter>().mesh = mesh;
var cubeSphereMR = icosphere.AddComponent<MeshRenderer>(); var cubeSphereMR = icosphere.AddComponent<MeshRenderer>();
cubeSphereMR.material = new Material(Shader.Find("Standard")); cubeSphereMR.material = new Material(Shader.Find("Standard"));
@ -33,7 +33,10 @@ namespace NewHorizons.Builder.Body
cubeSphereMC.sharedMesh = mesh; cubeSphereMC.sharedMesh = mesh;
icosphere.transform.rotation = planetGO.transform.TransformRotation(Quaternion.Euler(90, 0, 0)); icosphere.transform.rotation = planetGO.transform.TransformRotation(Quaternion.Euler(90, 0, 0));
icosphere.AddComponent<ProxyShadowCaster>(); var superGroup = planetGO.GetComponent<ProxyShadowCasterSuperGroup>();
if (superGroup != null) icosphere.AddComponent<ProxyShadowCaster>()._superGroup = superGroup;
icosphere.SetActive(true);
} }
} }
} }

View File

@ -1,4 +1,4 @@
using NewHorizons.Builder.Atmosphere; using NewHorizons.Builder.Atmosphere;
using NewHorizons.Builder.Props; using NewHorizons.Builder.Props;
using NewHorizons.Components; using NewHorizons.Components;
using NewHorizons.Components.SizeControllers; using NewHorizons.Components.SizeControllers;
@ -176,7 +176,7 @@ namespace NewHorizons.Builder.Body
private static void MakeBlackHole(GameObject rootObject, float size) private static void MakeBlackHole(GameObject rootObject, float size)
{ {
if (_blackHolePrefab == null) _blackHolePrefab = GameObject.Find(_blackHolePath); if (_blackHolePrefab == null) _blackHolePrefab = SearchUtilities.Find(_blackHolePath);
var blackHoleShader = _blackHolePrefab.GetComponent<MeshRenderer>().material.shader; var blackHoleShader = _blackHolePrefab.GetComponent<MeshRenderer>().material.shader;
if (blackHoleShader == null) blackHoleShader = _blackHolePrefab.GetComponent<MeshRenderer>().sharedMaterial.shader; if (blackHoleShader == null) blackHoleShader = _blackHolePrefab.GetComponent<MeshRenderer>().sharedMaterial.shader;
@ -201,7 +201,7 @@ namespace NewHorizons.Builder.Body
private static void MakeWhiteHole(GameObject rootObject, float size) private static void MakeWhiteHole(GameObject rootObject, float size)
{ {
if (_whiteHolePrefab == null) _whiteHolePrefab = GameObject.Find(_whiteHolePath); if (_whiteHolePrefab == null) _whiteHolePrefab = SearchUtilities.Find(_whiteHolePath);
var whiteHoleShader = _whiteHolePrefab.GetComponent<MeshRenderer>().material.shader; var whiteHoleShader = _whiteHolePrefab.GetComponent<MeshRenderer>().material.shader;
if (whiteHoleShader == null) whiteHoleShader = _whiteHolePrefab.GetComponent<MeshRenderer>().sharedMaterial.shader; if (whiteHoleShader == null) whiteHoleShader = _whiteHolePrefab.GetComponent<MeshRenderer>().sharedMaterial.shader;

View File

@ -1,4 +1,4 @@
using NewHorizons.Utility; using NewHorizons.Utility;
using UnityEngine; using UnityEngine;
using NewHorizons.External.Modules.VariableSize; using NewHorizons.External.Modules.VariableSize;
@ -11,7 +11,7 @@ namespace NewHorizons.Builder.Body
var sandGO = new GameObject("Sand"); var sandGO = new GameObject("Sand");
sandGO.SetActive(false); sandGO.SetActive(false);
var sandSphere = GameObject.Instantiate(GameObject.Find("TowerTwin_Body/SandSphere_Draining/SandSphere"), sandGO.transform); var sandSphere = GameObject.Instantiate(SearchUtilities.Find("TowerTwin_Body/SandSphere_Draining/SandSphere"), sandGO.transform);
if (module.tint != null) if (module.tint != null)
{ {
var oldMR = sandSphere.GetComponent<TessellatedSphereRenderer>(); var oldMR = sandSphere.GetComponent<TessellatedSphereRenderer>();
@ -28,13 +28,13 @@ namespace NewHorizons.Builder.Body
sandMR.sharedMaterials[1].color = module.tint.ToColor(); sandMR.sharedMaterials[1].color = module.tint.ToColor();
} }
var collider = GameObject.Instantiate(GameObject.Find("TowerTwin_Body/SandSphere_Draining/Collider"), sandGO.transform); var collider = GameObject.Instantiate(SearchUtilities.Find("TowerTwin_Body/SandSphere_Draining/Collider"), sandGO.transform);
var sphereCollider = collider.GetComponent<SphereCollider>(); var sphereCollider = collider.GetComponent<SphereCollider>();
collider.SetActive(true); collider.SetActive(true);
var occlusionSphere = GameObject.Instantiate(GameObject.Find("TowerTwin_Body/SandSphere_Draining/OcclusionSphere"), sandGO.transform); var occlusionSphere = GameObject.Instantiate(SearchUtilities.Find("TowerTwin_Body/SandSphere_Draining/OcclusionSphere"), sandGO.transform);
var proxyShadowCasterGO = GameObject.Instantiate(GameObject.Find("TowerTwin_Body/SandSphere_Draining/ProxyShadowCaster"), sandGO.transform); var proxyShadowCasterGO = GameObject.Instantiate(SearchUtilities.Find("TowerTwin_Body/SandSphere_Draining/ProxyShadowCaster"), sandGO.transform);
var proxyShadowCaster = proxyShadowCasterGO.GetComponent<ProxyShadowCaster>(); var proxyShadowCaster = proxyShadowCasterGO.GetComponent<ProxyShadowCaster>();
proxyShadowCaster.SetSuperGroup(sandGO.GetComponent<ProxyShadowCasterSuperGroup>()); proxyShadowCaster.SetSuperGroup(sandGO.GetComponent<ProxyShadowCasterSuperGroup>());

View File

@ -1,4 +1,4 @@
using NewHorizons.Components; using NewHorizons.Components;
using NewHorizons.External.Configs; using NewHorizons.External.Configs;
using NewHorizons.Utility; using NewHorizons.Utility;
using System; using System;
@ -88,10 +88,10 @@ namespace NewHorizons.Builder.Body
blackHoleRender.transform.localScale = Vector3.one * size; blackHoleRender.transform.localScale = Vector3.one * size;
var meshFilter = blackHoleRender.AddComponent<MeshFilter>(); var meshFilter = blackHoleRender.AddComponent<MeshFilter>();
meshFilter.mesh = GameObject.Find("BrittleHollow_Body/BlackHole_BH/BlackHoleRenderer").GetComponent<MeshFilter>().mesh; meshFilter.mesh = SearchUtilities.Find("BrittleHollow_Body/BlackHole_BH/BlackHoleRenderer").GetComponent<MeshFilter>().mesh;
var meshRenderer = blackHoleRender.AddComponent<MeshRenderer>(); var meshRenderer = blackHoleRender.AddComponent<MeshRenderer>();
if (blackHoleShader == null) blackHoleShader = GameObject.Find("BrittleHollow_Body/BlackHole_BH/BlackHoleRenderer").GetComponent<MeshRenderer>().sharedMaterial.shader; if (blackHoleShader == null) blackHoleShader = SearchUtilities.Find("BrittleHollow_Body/BlackHole_BH/BlackHoleRenderer").GetComponent<MeshRenderer>().sharedMaterial.shader;
meshRenderer.material = new Material(blackHoleShader); meshRenderer.material = new Material(blackHoleShader);
meshRenderer.material.SetFloat(Radius, size * 0.4f); meshRenderer.material.SetFloat(Radius, size * 0.4f);
meshRenderer.material.SetFloat(MaxDistortRadius, size * 0.95f); meshRenderer.material.SetFloat(MaxDistortRadius, size * 0.95f);
@ -100,7 +100,7 @@ namespace NewHorizons.Builder.Body
if (makeAudio) if (makeAudio)
{ {
var blackHoleAmbience = GameObject.Instantiate(GameObject.Find("BrittleHollow_Body/BlackHole_BH/BlackHoleAmbience"), blackHole.transform); var blackHoleAmbience = GameObject.Instantiate(SearchUtilities.Find("BrittleHollow_Body/BlackHole_BH/BlackHoleAmbience"), blackHole.transform);
blackHoleAmbience.name = "BlackHoleAmbience"; blackHoleAmbience.name = "BlackHoleAmbience";
blackHoleAmbience.GetComponent<SectorAudioGroup>().SetSector(sector); blackHoleAmbience.GetComponent<SectorAudioGroup>().SetSector(sector);
@ -109,7 +109,7 @@ namespace NewHorizons.Builder.Body
blackHoleAudioSource.minDistance = size * 0.4f; blackHoleAudioSource.minDistance = size * 0.4f;
blackHoleAmbience.transform.localPosition = Vector3.zero; blackHoleAmbience.transform.localPosition = Vector3.zero;
var blackHoleOneShot = GameObject.Instantiate(GameObject.Find("BrittleHollow_Body/BlackHole_BH/BlackHoleEmissionOneShot"), blackHole.transform); var blackHoleOneShot = GameObject.Instantiate(SearchUtilities.Find("BrittleHollow_Body/BlackHole_BH/BlackHoleEmissionOneShot"), blackHole.transform);
var oneShotAudioSource = blackHoleOneShot.GetComponent<AudioSource>(); var oneShotAudioSource = blackHoleOneShot.GetComponent<AudioSource>();
oneShotAudioSource.maxDistance = size * 3f; oneShotAudioSource.maxDistance = size * 3f;
oneShotAudioSource.minDistance = size * 0.4f; oneShotAudioSource.minDistance = size * 0.4f;
@ -137,7 +137,7 @@ namespace NewHorizons.Builder.Body
} }
else else
{ {
var blackHoleVolume = GameObject.Instantiate(GameObject.Find("BrittleHollow_Body/BlackHole_BH/BlackHoleVolume"), blackHole.transform); var blackHoleVolume = GameObject.Instantiate(SearchUtilities.Find("BrittleHollow_Body/BlackHole_BH/BlackHoleVolume"), blackHole.transform);
blackHoleVolume.name = "BlackHoleVolume"; blackHoleVolume.name = "BlackHoleVolume";
blackHoleVolume.GetComponent<SphereCollider>().radius = size * 0.4f; blackHoleVolume.GetComponent<SphereCollider>().radius = size * 0.4f;
} }
@ -159,10 +159,10 @@ namespace NewHorizons.Builder.Body
whiteHoleRenderer.transform.localScale = Vector3.one * size * 2.8f; whiteHoleRenderer.transform.localScale = Vector3.one * size * 2.8f;
var meshFilter = whiteHoleRenderer.AddComponent<MeshFilter>(); var meshFilter = whiteHoleRenderer.AddComponent<MeshFilter>();
meshFilter.mesh = GameObject.Find("WhiteHole_Body/WhiteHoleVisuals/Singularity").GetComponent<MeshFilter>().mesh; meshFilter.mesh = SearchUtilities.Find("WhiteHole_Body/WhiteHoleVisuals/Singularity").GetComponent<MeshFilter>().mesh;
var meshRenderer = whiteHoleRenderer.AddComponent<MeshRenderer>(); var meshRenderer = whiteHoleRenderer.AddComponent<MeshRenderer>();
if (whiteHoleShader == null) whiteHoleShader = GameObject.Find("WhiteHole_Body/WhiteHoleVisuals/Singularity").GetComponent<MeshRenderer>().sharedMaterial.shader; if (whiteHoleShader == null) whiteHoleShader = SearchUtilities.Find("WhiteHole_Body/WhiteHoleVisuals/Singularity").GetComponent<MeshRenderer>().sharedMaterial.shader;
meshRenderer.material = new Material(whiteHoleShader); meshRenderer.material = new Material(whiteHoleShader);
meshRenderer.sharedMaterial.SetFloat(Radius, size * 0.4f); meshRenderer.sharedMaterial.SetFloat(Radius, size * 0.4f);
meshRenderer.sharedMaterial.SetFloat(DistortFadeDist, size); meshRenderer.sharedMaterial.SetFloat(DistortFadeDist, size);
@ -170,14 +170,14 @@ namespace NewHorizons.Builder.Body
meshRenderer.sharedMaterial.SetFloat(MassScale, -1); meshRenderer.sharedMaterial.SetFloat(MassScale, -1);
meshRenderer.sharedMaterial.SetColor(Color1, new Color(1.88f, 1.88f, 1.88f, 1f)); meshRenderer.sharedMaterial.SetColor(Color1, new Color(1.88f, 1.88f, 1.88f, 1f));
var ambientLight = GameObject.Instantiate(GameObject.Find("WhiteHole_Body/WhiteHoleVisuals/AmbientLight_WH")); var ambientLight = GameObject.Instantiate(SearchUtilities.Find("WhiteHole_Body/WhiteHoleVisuals/AmbientLight_WH"));
ambientLight.transform.parent = whiteHole.transform; ambientLight.transform.parent = whiteHole.transform;
ambientLight.transform.localScale = Vector3.one; ambientLight.transform.localScale = Vector3.one;
ambientLight.transform.localPosition = Vector3.zero; ambientLight.transform.localPosition = Vector3.zero;
ambientLight.name = "AmbientLight"; ambientLight.name = "AmbientLight";
ambientLight.GetComponent<Light>().range = size * 7f; ambientLight.GetComponent<Light>().range = size * 7f;
GameObject whiteHoleVolumeGO = GameObject.Instantiate(GameObject.Find("WhiteHole_Body/WhiteHoleVolume")); GameObject whiteHoleVolumeGO = GameObject.Instantiate(SearchUtilities.Find("WhiteHole_Body/WhiteHoleVolume"));
whiteHoleVolumeGO.transform.parent = whiteHole.transform; whiteHoleVolumeGO.transform.parent = whiteHole.transform;
whiteHoleVolumeGO.transform.localPosition = Vector3.zero; whiteHoleVolumeGO.transform.localPosition = Vector3.zero;
whiteHoleVolumeGO.transform.localScale = Vector3.one; whiteHoleVolumeGO.transform.localScale = Vector3.one;
@ -205,13 +205,13 @@ namespace NewHorizons.Builder.Body
if (makeZeroGVolume) if (makeZeroGVolume)
{ {
var zeroGVolume = GameObject.Instantiate(GameObject.Find("WhiteHole_Body/ZeroGVolume"), whiteHole.transform); var zeroGVolume = GameObject.Instantiate(SearchUtilities.Find("WhiteHole_Body/ZeroGVolume"), whiteHole.transform);
zeroGVolume.name = "ZeroGVolume"; zeroGVolume.name = "ZeroGVolume";
zeroGVolume.transform.localPosition = Vector3.zero; zeroGVolume.transform.localPosition = Vector3.zero;
zeroGVolume.GetComponent<SphereCollider>().radius = size * 10f; zeroGVolume.GetComponent<SphereCollider>().radius = size * 10f;
zeroGVolume.GetComponent<ZeroGVolume>()._attachedBody = OWRB; zeroGVolume.GetComponent<ZeroGVolume>()._attachedBody = OWRB;
var rulesetVolume = GameObject.Instantiate(GameObject.Find("WhiteHole_Body/Sector_WhiteHole/RulesetVolumes_WhiteHole"), planetGO.transform); var rulesetVolume = GameObject.Instantiate(SearchUtilities.Find("WhiteHole_Body/Sector_WhiteHole/RulesetVolumes_WhiteHole"), planetGO.transform);
rulesetVolume.name = "RulesetVolume"; rulesetVolume.name = "RulesetVolume";
rulesetVolume.transform.localPosition = Vector3.zero; rulesetVolume.transform.localPosition = Vector3.zero;
rulesetVolume.transform.localScale = Vector3.one * size / 100f; rulesetVolume.transform.localScale = Vector3.one * size / 100f;

View File

@ -23,7 +23,7 @@ namespace NewHorizons.Builder.Body
{ {
var starGO = MakeStarGraphics(planetGO, sector, starModule); var starGO = MakeStarGraphics(planetGO, sector, starModule);
var sunAudio = Object.Instantiate(GameObject.Find("Sun_Body/Sector_SUN/Audio_SUN"), starGO.transform); var sunAudio = Object.Instantiate(SearchUtilities.Find("Sun_Body/Sector_SUN/Audio_SUN"), starGO.transform);
sunAudio.transform.localPosition = Vector3.zero; sunAudio.transform.localPosition = Vector3.zero;
sunAudio.transform.localScale = Vector3.one; sunAudio.transform.localScale = Vector3.one;
sunAudio.transform.Find("SurfaceAudio_Sun").GetComponent<AudioSource>().maxDistance = starModule.size * 2f; sunAudio.transform.Find("SurfaceAudio_Sun").GetComponent<AudioSource>().maxDistance = starModule.size * 2f;
@ -36,7 +36,7 @@ namespace NewHorizons.Builder.Body
GameObject sunAtmosphere = null; GameObject sunAtmosphere = null;
if (starModule.hasAtmosphere) if (starModule.hasAtmosphere)
{ {
sunAtmosphere = Object.Instantiate(GameObject.Find("Sun_Body/Atmosphere_SUN"), starGO.transform); sunAtmosphere = Object.Instantiate(SearchUtilities.Find("Sun_Body/Atmosphere_SUN"), starGO.transform);
sunAtmosphere.transform.position = planetGO.transform.position; sunAtmosphere.transform.position = planetGO.transform.position;
sunAtmosphere.transform.localScale = Vector3.one * OuterRadiusRatio; sunAtmosphere.transform.localScale = Vector3.one * OuterRadiusRatio;
sunAtmosphere.name = "Atmosphere_Star"; sunAtmosphere.name = "Atmosphere_Star";
@ -59,17 +59,17 @@ namespace NewHorizons.Builder.Body
fog.lodFadeDistance = fog.fogRadius * (StarBuilder.OuterRadiusRatio - 1f); fog.lodFadeDistance = fog.fogRadius * (StarBuilder.OuterRadiusRatio - 1f);
} }
var ambientLightGO = Object.Instantiate(GameObject.Find("Sun_Body/AmbientLight_SUN"), starGO.transform); var ambientLightGO = Object.Instantiate(SearchUtilities.Find("Sun_Body/AmbientLight_SUN"), starGO.transform);
ambientLightGO.transform.localPosition = Vector3.zero; ambientLightGO.transform.localPosition = Vector3.zero;
ambientLightGO.name = "AmbientLight_Star"; ambientLightGO.name = "AmbientLight_Star";
var heatVolume = Object.Instantiate(GameObject.Find("Sun_Body/Sector_SUN/Volumes_SUN/HeatVolume"), starGO.transform); var heatVolume = Object.Instantiate(SearchUtilities.Find("Sun_Body/Sector_SUN/Volumes_SUN/HeatVolume"), starGO.transform);
heatVolume.transform.localPosition = Vector3.zero; heatVolume.transform.localPosition = Vector3.zero;
heatVolume.transform.localScale = Vector3.one; heatVolume.transform.localScale = Vector3.one;
heatVolume.GetComponent<SphereShape>().radius = 1f; heatVolume.GetComponent<SphereShape>().radius = 1f;
heatVolume.name = "HeatVolume"; heatVolume.name = "HeatVolume";
var deathVolume = Object.Instantiate(GameObject.Find("Sun_Body/Sector_SUN/Volumes_SUN/ScaledVolumesRoot/DestructionFluidVolume"), starGO.transform); var deathVolume = Object.Instantiate(SearchUtilities.Find("Sun_Body/Sector_SUN/Volumes_SUN/ScaledVolumesRoot/DestructionFluidVolume"), starGO.transform);
deathVolume.transform.localPosition = Vector3.zero; deathVolume.transform.localPosition = Vector3.zero;
deathVolume.transform.localScale = Vector3.one; deathVolume.transform.localScale = Vector3.one;
deathVolume.GetComponent<SphereCollider>().radius = 1f; deathVolume.GetComponent<SphereCollider>().radius = 1f;
@ -85,8 +85,9 @@ namespace NewHorizons.Builder.Body
sunLight.transform.localScale = Vector3.one; sunLight.transform.localScale = Vector3.one;
var light = sunLight.AddComponent<Light>(); var light = sunLight.AddComponent<Light>();
light.CopyPropertiesFrom(GameObject.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent<Light>()); light.CopyPropertiesFrom(SearchUtilities.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent<Light>());
light.intensity *= starModule.solarLuminosity; light.intensity *= starModule.solarLuminosity;
light.range = starModule.lightRadius;
light.range *= Mathf.Sqrt(starModule.solarLuminosity); light.range *= Mathf.Sqrt(starModule.solarLuminosity);
Color lightColour = light.color; Color lightColour = light.color;
@ -96,12 +97,12 @@ namespace NewHorizons.Builder.Body
ambientLight.color = lightColour; ambientLight.color = lightColour;
var faceActiveCamera = sunLight.AddComponent<FaceActiveCamera>(); var faceActiveCamera = sunLight.AddComponent<FaceActiveCamera>();
faceActiveCamera.CopyPropertiesFrom(GameObject.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent<FaceActiveCamera>()); faceActiveCamera.CopyPropertiesFrom(SearchUtilities.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent<FaceActiveCamera>());
var csmTextureCacher = sunLight.AddComponent<CSMTextureCacher>(); var csmTextureCacher = sunLight.AddComponent<CSMTextureCacher>();
csmTextureCacher.CopyPropertiesFrom(GameObject.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent<CSMTextureCacher>()); csmTextureCacher.CopyPropertiesFrom(SearchUtilities.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent<CSMTextureCacher>());
csmTextureCacher._light = light; csmTextureCacher._light = light;
var proxyShadowLight = sunLight.AddComponent<ProxyShadowLight>(); var proxyShadowLight = sunLight.AddComponent<ProxyShadowLight>();
proxyShadowLight.CopyPropertiesFrom(GameObject.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent<ProxyShadowLight>()); proxyShadowLight.CopyPropertiesFrom(SearchUtilities.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent<ProxyShadowLight>());
proxyShadowLight._light = light; proxyShadowLight._light = light;
StarController starController = null; StarController starController = null;
@ -133,11 +134,12 @@ namespace NewHorizons.Builder.Body
// It fucking insists on this existing and its really annoying // It fucking insists on this existing and its really annoying
var supernovaVolume = new GameObject("SupernovaVolumePlaceholder"); var supernovaVolume = new GameObject("SupernovaVolumePlaceholder");
supernovaVolume.transform.SetParent(starGO.transform); supernovaVolume.transform.SetParent(starGO.transform);
supernova._supernovaVolume = supernovaVolume.AddComponent<SupernovaDestructionVolume>(); supernovaVolume.layer = LayerMask.NameToLayer("BasicEffectVolume");
var sphere = supernovaVolume.AddComponent<SphereCollider>(); var sphere = supernovaVolume.AddComponent<SphereCollider>();
sphere.radius = 0f; sphere.radius = 0f;
sphere.isTrigger = true; sphere.isTrigger = true;
supernovaVolume.AddComponent<OWCollider>(); supernovaVolume.AddComponent<OWCollider>();
supernova._supernovaVolume = supernovaVolume.AddComponent<SupernovaDestructionVolume>();
return starController; return starController;
} }
@ -148,6 +150,8 @@ namespace NewHorizons.Builder.Body
var supernova = MakeSupernova(starGO, starModule); var supernova = MakeSupernova(starGO, starModule);
supernova._belongsToProxySun = true;
starGO.SetActive(false); starGO.SetActive(false);
var controller = starGO.AddComponent<StarEvolutionController>(); var controller = starGO.AddComponent<StarEvolutionController>();
if (starModule.curve != null) controller.scaleCurve = starModule.GetAnimationCurve(); if (starModule.curve != null) controller.scaleCurve = starModule.GetAnimationCurve();
@ -170,12 +174,12 @@ namespace NewHorizons.Builder.Body
var starGO = new GameObject("Star"); var starGO = new GameObject("Star");
starGO.transform.parent = sector?.transform ?? rootObject.transform; starGO.transform.parent = sector?.transform ?? rootObject.transform;
var sunSurface = Object.Instantiate(GameObject.Find("Sun_Body/Sector_SUN/Geometry_SUN/Surface"), starGO.transform); var sunSurface = Object.Instantiate(SearchUtilities.Find("Sun_Body/Sector_SUN/Geometry_SUN/Surface"), starGO.transform);
sunSurface.transform.position = rootObject.transform.position; sunSurface.transform.position = rootObject.transform.position;
sunSurface.transform.localScale = Vector3.one; sunSurface.transform.localScale = Vector3.one;
sunSurface.name = "Surface"; sunSurface.name = "Surface";
var solarFlareEmitter = Object.Instantiate(GameObject.Find("Sun_Body/Sector_SUN/Effects_SUN/SolarFlareEmitter"), starGO.transform); var solarFlareEmitter = Object.Instantiate(SearchUtilities.Find("Sun_Body/Sector_SUN/Effects_SUN/SolarFlareEmitter"), starGO.transform);
solarFlareEmitter.transform.localPosition = Vector3.zero; solarFlareEmitter.transform.localPosition = Vector3.zero;
solarFlareEmitter.transform.localScale = Vector3.one; solarFlareEmitter.transform.localScale = Vector3.one;
solarFlareEmitter.name = "SolarFlareEmitter"; solarFlareEmitter.name = "SolarFlareEmitter";
@ -202,7 +206,7 @@ namespace NewHorizons.Builder.Body
var colour = starModule.tint.ToColor(); var colour = starModule.tint.ToColor();
var sun = GameObject.Find("Sun_Body"); var sun = SearchUtilities.Find("Sun_Body");
var mainSequenceMaterial = sun.GetComponent<SunController>()._startSurfaceMaterial; var mainSequenceMaterial = sun.GetComponent<SunController>()._startSurfaceMaterial;
var giantMaterial = sun.GetComponent<SunController>()._endSurfaceMaterial; var giantMaterial = sun.GetComponent<SunController>()._endSurfaceMaterial;
@ -228,7 +232,7 @@ namespace NewHorizons.Builder.Body
private static SupernovaEffectController MakeSupernova(GameObject starGO, StarModule starModule) private static SupernovaEffectController MakeSupernova(GameObject starGO, StarModule starModule)
{ {
var supernovaGO = GameObject.Find("Sun_Body/Sector_SUN/Effects_SUN/Supernova").InstantiateInactive(); var supernovaGO = SearchUtilities.Find("Sun_Body/Sector_SUN/Effects_SUN/Supernova").InstantiateInactive();
supernovaGO.transform.SetParent(starGO.transform); supernovaGO.transform.SetParent(starGO.transform);
supernovaGO.transform.localPosition = Vector3.zero; supernovaGO.transform.localPosition = Vector3.zero;

View File

@ -1,4 +1,4 @@
using NewHorizons.Components; using NewHorizons.Components;
using NewHorizons.Components.SizeControllers; using NewHorizons.Components.SizeControllers;
using NewHorizons.Utility; using NewHorizons.Utility;
using UnityEngine; using UnityEngine;
@ -19,7 +19,7 @@ namespace NewHorizons.Builder.Body
waterGO.transform.parent = sector?.transform ?? planetGO.transform; waterGO.transform.parent = sector?.transform ?? planetGO.transform;
waterGO.transform.localScale = new Vector3(waterSize, waterSize, waterSize); waterGO.transform.localScale = new Vector3(waterSize, waterSize, waterSize);
var GDTSR = GameObject.Find("Ocean_GD").GetComponent<TessellatedSphereRenderer>(); var GDTSR = SearchUtilities.Find("Ocean_GD").GetComponent<TessellatedSphereRenderer>();
TessellatedSphereRenderer TSR = waterGO.AddComponent<TessellatedSphereRenderer>(); TessellatedSphereRenderer TSR = waterGO.AddComponent<TessellatedSphereRenderer>();
TSR.tessellationMeshGroup = ScriptableObject.CreateInstance<MeshGroup>(); TSR.tessellationMeshGroup = ScriptableObject.CreateInstance<MeshGroup>();
@ -30,7 +30,7 @@ namespace NewHorizons.Builder.Body
TSR.tessellationMeshGroup.variants[i] = mesh; TSR.tessellationMeshGroup.variants[i] = mesh;
} }
var GDSharedMaterials = GameObject.Find("Ocean_GD").GetComponent<TessellatedSphereLOD>()._lowAltitudeMaterials; var GDSharedMaterials = SearchUtilities.Find("Ocean_GD").GetComponent<TessellatedSphereLOD>()._lowAltitudeMaterials;
var tempArray = new Material[GDSharedMaterials.Length]; var tempArray = new Material[GDSharedMaterials.Length];
for (int i = 0; i < GDSharedMaterials.Length; i++) for (int i = 0; i < GDSharedMaterials.Length; i++)
{ {
@ -87,7 +87,7 @@ namespace NewHorizons.Builder.Body
fluidVolume._radius = waterSize; fluidVolume._radius = waterSize;
fluidVolume._layer = LayerMask.NameToLayer("BasicEffectVolume"); fluidVolume._layer = LayerMask.NameToLayer("BasicEffectVolume");
var fogGO = GameObject.Instantiate(GameObject.Find("GiantsDeep_Body/Sector_GD/Sector_GDInterior/Effects_GDInterior/OceanFog"), waterGO.transform); var fogGO = GameObject.Instantiate(SearchUtilities.Find("GiantsDeep_Body/Sector_GD/Sector_GDInterior/Effects_GDInterior/OceanFog"), waterGO.transform);
fogGO.name = "OceanFog"; fogGO.name = "OceanFog";
fogGO.transform.localPosition = Vector3.zero; fogGO.transform.localPosition = Vector3.zero;
fogGO.transform.localScale = Vector3.one; fogGO.transform.localScale = Vector3.one;

View File

@ -1,11 +1,12 @@
using UnityEngine; using UnityEngine;
using NewHorizons.Utility;
namespace NewHorizons.Builder.General namespace NewHorizons.Builder.General
{ {
public static class AmbientLightBuilder public static class AmbientLightBuilder
{ {
public static void Make(GameObject planetGO, Sector sector, float scale, float intensity) public static void Make(GameObject planetGO, Sector sector, float scale, float intensity)
{ {
GameObject lightGO = GameObject.Instantiate(GameObject.Find("BrittleHollow_Body/AmbientLight_BH_Surface"), sector?.transform ?? planetGO.transform); GameObject lightGO = GameObject.Instantiate(SearchUtilities.Find("BrittleHollow_Body/AmbientLight_BH_Surface"), sector?.transform ?? planetGO.transform);
lightGO.transform.position = planetGO.transform.position; lightGO.transform.position = planetGO.transform.position;
lightGO.name = "Light"; lightGO.name = "Light";

View File

@ -1,4 +1,4 @@
using NewHorizons.Components.Orbital; using NewHorizons.Components.Orbital;
using NewHorizons.External.Configs; using NewHorizons.External.Configs;
using UnityEngine; using UnityEngine;
using Logger = NewHorizons.Utility.Logger; using Logger = NewHorizons.Utility.Logger;
@ -31,6 +31,8 @@ namespace NewHorizons.Builder.General
fluidDetector._collider = sphereCollider; fluidDetector._collider = sphereCollider;
OWRB.RegisterAttachedFluidDetector(fluidDetector);
// Could copy the splash from the interloper as well some day // Could copy the splash from the interloper as well some day
} }

View File

@ -1,4 +1,4 @@
using NewHorizons.External.Configs; using NewHorizons.External.Configs;
using NewHorizons.External.Modules; using NewHorizons.External.Modules;
using UnityEngine; using UnityEngine;
using Logger = NewHorizons.Utility.Logger; using Logger = NewHorizons.Utility.Logger;
@ -6,7 +6,7 @@ namespace NewHorizons.Builder.General
{ {
public static class GravityBuilder public static class GravityBuilder
{ {
public static GravityVolume Make(GameObject planetGO, AstroObject ao, PlanetConfig config) public static GravityVolume Make(GameObject planetGO, AstroObject ao, OWRigidbody owrb, PlanetConfig config)
{ {
var exponent = config.Base.gravityFallOff == GravityFallOff.Linear ? 1f : 2f; var exponent = config.Base.gravityFallOff == GravityFallOff.Linear ? 1f : 2f;
var GM = config.Base.surfaceGravity * Mathf.Pow(config.Base.surfaceSize, exponent); var GM = config.Base.surfaceGravity * Mathf.Pow(config.Base.surfaceSize, exponent);
@ -60,6 +60,7 @@ namespace NewHorizons.Builder.General
gravityGO.SetActive(true); gravityGO.SetActive(true);
ao._gravityVolume = gravityVolume; ao._gravityVolume = gravityVolume;
owrb.RegisterAttachedGravityVolume(gravityVolume);
return gravityVolume; return gravityVolume;
} }

View File

@ -1,10 +1,11 @@
using NewHorizons.External.Configs; using NewHorizons.External.Configs;
using NewHorizons.External.Modules;
using UnityEngine; using UnityEngine;
namespace NewHorizons.Builder.General namespace NewHorizons.Builder.General
{ {
public static class RFVolumeBuilder public static class RFVolumeBuilder
{ {
public static void Make(GameObject planetGO, OWRigidbody owRigidBody, float sphereOfInfluence) public static void Make(GameObject planetGO, OWRigidbody owrb, float sphereOfInfluence, ReferenceFrameModule module)
{ {
var rfGO = new GameObject("RFVolume"); var rfGO = new GameObject("RFVolume");
rfGO.transform.parent = planetGO.transform; rfGO.transform.parent = planetGO.transform;
@ -18,8 +19,10 @@ namespace NewHorizons.Builder.General
var RFV = rfGO.AddComponent<ReferenceFrameVolume>(); var RFV = rfGO.AddComponent<ReferenceFrameVolume>();
var RV = new ReferenceFrame(owRigidBody); var minTargetDistance = module.targetWhenClose ? 0 : sphereOfInfluence;
RV._minSuitTargetDistance = sphereOfInfluence;
var RV = new ReferenceFrame(owrb);
RV._minSuitTargetDistance = minTargetDistance;
RV._maxTargetDistance = 0; RV._maxTargetDistance = 0;
RV._autopilotArrivalDistance = 2.0f * sphereOfInfluence; RV._autopilotArrivalDistance = 2.0f * sphereOfInfluence;
RV._autoAlignmentDistance = sphereOfInfluence * 1.5f; RV._autoAlignmentDistance = sphereOfInfluence * 1.5f;
@ -28,15 +31,17 @@ namespace NewHorizons.Builder.General
RV._matchAngularVelocity = true; RV._matchAngularVelocity = true;
RV._minMatchAngularVelocityDistance = 70; RV._minMatchAngularVelocityDistance = 70;
RV._maxMatchAngularVelocityDistance = 400; RV._maxMatchAngularVelocityDistance = 400;
RV._bracketsRadius = sphereOfInfluence; RV._bracketsRadius = module.bracketRadius > -1 ? module.bracketRadius : sphereOfInfluence;
RFV._referenceFrame = RV; RFV._referenceFrame = RV;
RFV._minColliderRadius = sphereOfInfluence; RFV._minColliderRadius = minTargetDistance;
RFV._maxColliderRadius = sphereOfInfluence * 2f; RFV._maxColliderRadius = module.maxTargetDistance > -1 ? module.maxTargetDistance : sphereOfInfluence * 2f;
RFV._isPrimaryVolume = true; RFV._isPrimaryVolume = true;
RFV._isCloseRangeVolume = false; RFV._isCloseRangeVolume = false;
rfGO.SetActive(true); owrb.SetAttachedReferenceFrameVolume(RFV);
rfGO.SetActive(!module.hideInMap);
} }
} }
} }

View File

@ -1,4 +1,5 @@
using NewHorizons.External.Configs; using NewHorizons.External.Configs;
using NewHorizons.Utility;
using UnityEngine; using UnityEngine;
namespace NewHorizons.Builder.General namespace NewHorizons.Builder.General
{ {
@ -18,7 +19,6 @@ namespace NewHorizons.Builder.General
rigidBody.collisionDetectionMode = CollisionDetectionMode.Discrete; rigidBody.collisionDetectionMode = CollisionDetectionMode.Discrete;
KinematicRigidbody kinematicRigidBody = body.AddComponent<KinematicRigidbody>(); KinematicRigidbody kinematicRigidBody = body.AddComponent<KinematicRigidbody>();
kinematicRigidBody.centerOfMass = Vector3.zero;
OWRigidbody owRigidBody = body.AddComponent<OWRigidbody>(); OWRigidbody owRigidBody = body.AddComponent<OWRigidbody>();
owRigidBody._kinematicSimulation = true; owRigidBody._kinematicSimulation = true;
@ -27,7 +27,7 @@ namespace NewHorizons.Builder.General
owRigidBody._maintainOriginalCenterOfMass = true; owRigidBody._maintainOriginalCenterOfMass = true;
owRigidBody._rigidbody = rigidBody; owRigidBody._rigidbody = rigidBody;
owRigidBody._kinematicRigidbody = kinematicRigidBody; owRigidBody._kinematicRigidbody = kinematicRigidBody;
owRigidBody._origParent = GameObject.Find("SolarSystemRoot").transform; owRigidBody._origParent = SearchUtilities.Find("SolarSystemRoot").transform;
owRigidBody.EnableKinematicSimulation(); owRigidBody.EnableKinematicSimulation();
owRigidBody.MakeKinematic(); owRigidBody.MakeKinematic();

View File

@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
namespace NewHorizons.Builder.General namespace NewHorizons.Builder.General
{ {
@ -27,6 +27,7 @@ namespace NewHorizons.Builder.General
S._subsectors = new List<Sector>(); S._subsectors = new List<Sector>();
sectorGO.SetActive(true); sectorGO.SetActive(true);
S.enabled = true;
return S; return S;
} }

View File

@ -1,4 +1,5 @@
using NewHorizons.External.Modules; using NewHorizons.External.Modules;
using NewHorizons.Utility;
using UnityEngine; using UnityEngine;
using Logger = NewHorizons.Utility.Logger; using Logger = NewHorizons.Utility.Logger;
namespace NewHorizons.Builder.General namespace NewHorizons.Builder.General
@ -18,8 +19,9 @@ namespace NewHorizons.Builder.General
spawnGO.transform.localPosition = module.playerSpawnPoint; spawnGO.transform.localPosition = module.playerSpawnPoint;
playerSpawn = spawnGO.AddComponent<SpawnPoint>(); playerSpawn = spawnGO.AddComponent<SpawnPoint>();
playerSpawn._triggerVolumes = new OWTriggerVolume[0];
if(module.playerSpawnRotation != null)
if (module.playerSpawnRotation != null)
{ {
spawnGO.transform.rotation = Quaternion.Euler(module.playerSpawnRotation); spawnGO.transform.rotation = Quaternion.Euler(module.playerSpawnRotation);
} }
@ -40,8 +42,9 @@ namespace NewHorizons.Builder.General
var spawnPoint = spawnGO.AddComponent<SpawnPoint>(); var spawnPoint = spawnGO.AddComponent<SpawnPoint>();
spawnPoint._isShipSpawn = true; spawnPoint._isShipSpawn = true;
spawnPoint._triggerVolumes = new OWTriggerVolume[0];
var ship = GameObject.Find("Ship_Body"); var ship = SearchUtilities.Find("Ship_Body");
ship.transform.position = spawnPoint.transform.position; ship.transform.position = spawnPoint.transform.position;
if(module.shipSpawnRotation != null) if(module.shipSpawnRotation != null)
@ -67,6 +70,7 @@ namespace NewHorizons.Builder.General
playerSpawnGO.transform.localPosition = new Vector3(0, 0, 0); playerSpawnGO.transform.localPosition = new Vector3(0, 0, 0);
playerSpawn = playerSpawnGO.AddComponent<SpawnPoint>(); playerSpawn = playerSpawnGO.AddComponent<SpawnPoint>();
playerSpawn._triggerVolumes = new OWTriggerVolume[0];
playerSpawnGO.transform.localRotation = Quaternion.Euler(0, 0, 0); playerSpawnGO.transform.localRotation = Quaternion.Euler(0, 0, 0);
} }
} }
@ -89,7 +93,7 @@ namespace NewHorizons.Builder.General
Locator.GetPlayerTransform().GetComponent<PlayerSpacesuit>().SuitUp(false, true, true); Locator.GetPlayerTransform().GetComponent<PlayerSpacesuit>().SuitUp(false, true, true);
// Make the ship act as if the player took the suit // Make the ship act as if the player took the suit
var spv = GameObject.Find("Ship_Body/Module_Supplies/Systems_Supplies/ExpeditionGear")?.GetComponent<SuitPickupVolume>(); var spv = SearchUtilities.Find("Ship_Body/Module_Supplies/Systems_Supplies/ExpeditionGear")?.GetComponent<SuitPickupVolume>();
if (spv == null) return; if (spv == null) return;

View File

@ -1,4 +1,4 @@
using NewHorizons.Components.Orbital; using NewHorizons.Components.Orbital;
using NewHorizons.External.Configs; using NewHorizons.External.Configs;
using NewHorizons.External.Modules; using NewHorizons.External.Modules;
using NewHorizons.Handlers; using NewHorizons.Handlers;
@ -59,7 +59,7 @@ namespace NewHorizons.Builder.Orbital
fakeMassConfig.name = config.name + "_FakeBarycenterMass"; fakeMassConfig.name = config.name + "_FakeBarycenterMass";
fakeMassConfig.Base.sphereOfInfluence = 0; fakeMassConfig.Base.sphereOfInfluence = 0;
fakeMassConfig.Base.hasMapMarker = false; fakeMassConfig.Base.hasMapMarker = false;
fakeMassConfig.Base.hasReferenceFrame = false; fakeMassConfig.ReferenceFrame.hideInMap = true;
fakeMassConfig.Orbit = new OrbitModule(); fakeMassConfig.Orbit = new OrbitModule();
fakeMassConfig.Orbit.CopyPropertiesFrom(config.Orbit); fakeMassConfig.Orbit.CopyPropertiesFrom(config.Orbit);

View File

@ -62,6 +62,11 @@ namespace NewHorizons.Builder.Props
detailGO = newDetailGO; detailGO = newDetailGO;
} }
if (detail.rename != null)
{
detailGO.name = detail.rename;
}
detailInfoToCorrespondingSpawnedGameObject[detail] = detailGO; detailInfoToCorrespondingSpawnedGameObject[detail] = detailGO;
} }
@ -145,7 +150,7 @@ namespace NewHorizons.Builder.Props
{ {
torchItem.enabled = true; torchItem.enabled = true;
torchItem.mindProjectorTrigger.enabled = true; torchItem.mindProjectorTrigger.enabled = true;
torchItem.mindSlideProjector._mindProjectorImageEffect = GameObject.Find("Player_Body/PlayerCamera").GetComponent<MindProjectorImageEffect>(); torchItem.mindSlideProjector._mindProjectorImageEffect = SearchUtilities.Find("Player_Body/PlayerCamera").GetComponent<MindProjectorImageEffect>();
} }
// fix campfires // fix campfires
@ -178,6 +183,7 @@ namespace NewHorizons.Builder.Props
{ {
try try
{ {
if (component == null) return;
if (component is Animator animator) animator.enabled = true; if (component is Animator animator) animator.enabled = true;
else if (component is Collider collider) collider.enabled = true; else if (component is Collider collider) collider.enabled = true;
else if (component is Renderer renderer) renderer.enabled = true; else if (component is Renderer renderer) renderer.enabled = true;
@ -200,7 +206,7 @@ namespace NewHorizons.Builder.Props
} }
catch (Exception e) catch (Exception e)
{ {
Logger.LogWarning($"Exception when modifying component [{component.GetType().Name}] on [{planetGO.name}] : {e.Message}, {e.StackTrace}"); Logger.LogWarning($"Exception when modifying component [{component.GetType().Name}] on [{planetGO.name}] for prop [{prefab.name}] : {e.GetType().FullName} {e.Message} {e.StackTrace}");
} }
}); });
} }

View File

@ -1,4 +1,4 @@
using NewHorizons.External.Modules; using NewHorizons.External.Modules;
using NewHorizons.Utility; using NewHorizons.Utility;
using UnityEngine; using UnityEngine;
namespace NewHorizons.Builder.Props namespace NewHorizons.Builder.Props
@ -7,7 +7,7 @@ namespace NewHorizons.Builder.Props
{ {
public static void Make(GameObject planetGO, Sector sector, PropModule.GeyserInfo info) public static void Make(GameObject planetGO, Sector sector, PropModule.GeyserInfo info)
{ {
var original = GameObject.Find("TimberHearth_Body/Sector_TH/Interactables_TH/Geysers/Geyser_Village"); var original = SearchUtilities.Find("TimberHearth_Body/Sector_TH/Interactables_TH/Geysers/Geyser_Village");
GameObject geyserGO = original.InstantiateInactive(); GameObject geyserGO = original.InstantiateInactive();
geyserGO.transform.parent = sector?.transform ?? planetGO.transform; geyserGO.transform.parent = sector?.transform ?? planetGO.transform;
geyserGO.name = "Geyser"; geyserGO.name = "Geyser";

View File

@ -67,18 +67,18 @@ namespace NewHorizons.Builder.Props
_ghostArcPrefabs.Add(arc); _ghostArcPrefabs.Add(arc);
} }
_scrollPrefab = GameObject.Find("BrittleHollow_Body/Sector_BH/Sector_NorthHemisphere/Sector_NorthPole/Sector_HangingCity/Sector_HangingCity_District2/Interactables_HangingCity_District2/Prefab_NOM_Scroll").InstantiateInactive(); _scrollPrefab = SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_NorthHemisphere/Sector_NorthPole/Sector_HangingCity/Sector_HangingCity_District2/Interactables_HangingCity_District2/Prefab_NOM_Scroll").InstantiateInactive();
_scrollPrefab.name = "Prefab_NOM_Scroll"; _scrollPrefab.name = "Prefab_NOM_Scroll";
_computerPrefab = GameObject.Find("VolcanicMoon_Body/Sector_VM/Interactables_VM/Prefab_NOM_Computer").InstantiateInactive(); _computerPrefab = SearchUtilities.Find("VolcanicMoon_Body/Sector_VM/Interactables_VM/Prefab_NOM_Computer").InstantiateInactive();
_computerPrefab.name = "Prefab_NOM_Computer"; _computerPrefab.name = "Prefab_NOM_Computer";
_computerPrefab.transform.rotation = Quaternion.identity; _computerPrefab.transform.rotation = Quaternion.identity;
_cairnPrefab = GameObject.Find("BrittleHollow_Body/Sector_BH/Sector_Crossroads/Interactables_Crossroads/Trailmarkers/Prefab_NOM_BH_Cairn_Arc (1)").InstantiateInactive(); _cairnPrefab = SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_Crossroads/Interactables_Crossroads/Trailmarkers/Prefab_NOM_BH_Cairn_Arc (1)").InstantiateInactive();
_cairnPrefab.name = "Prefab_NOM_Cairn"; _cairnPrefab.name = "Prefab_NOM_Cairn";
_cairnPrefab.transform.rotation = Quaternion.identity; _cairnPrefab.transform.rotation = Quaternion.identity;
_recorderPrefab = GameObject.Find("Comet_Body/Prefab_NOM_Shuttle/Sector_NomaiShuttleInterior/Interactibles_NomaiShuttleInterior/Prefab_NOM_Recorder").InstantiateInactive(); _recorderPrefab = SearchUtilities.Find("Comet_Body/Prefab_NOM_Shuttle/Sector_NomaiShuttleInterior/Interactibles_NomaiShuttleInterior/Prefab_NOM_Recorder").InstantiateInactive();
_recorderPrefab.name = "Prefab_NOM_Recorder"; _recorderPrefab.name = "Prefab_NOM_Recorder";
_recorderPrefab.transform.rotation = Quaternion.identity; _recorderPrefab.transform.rotation = Quaternion.identity;
} }

View File

@ -41,7 +41,7 @@ namespace NewHorizons.Builder.Props
{ {
if (_slideReelPrefab == null) if (_slideReelPrefab == null)
{ {
_slideReelPrefab = GameObject.Find("RingWorld_Body/Sector_RingInterior/Sector_Zone1/Sector_SlideBurningRoom_Zone1/Interactables_SlideBurningRoom_Zone1/Prefab_IP_SecretAlcove/RotationPivot/SlideReelSocket/Prefab_IP_Reel_1_LibraryPath")?.gameObject?.InstantiateInactive(); _slideReelPrefab = SearchUtilities.Find("RingWorld_Body/Sector_RingInterior/Sector_Zone1/Sector_SlideBurningRoom_Zone1/Interactables_SlideBurningRoom_Zone1/Prefab_IP_SecretAlcove/RotationPivot/SlideReelSocket/Prefab_IP_Reel_1_LibraryPath")?.gameObject?.InstantiateInactive();
if (_slideReelPrefab == null) if (_slideReelPrefab == null)
{ {
Logger.LogWarning($"Tried to make a slide reel but couldn't. Do you have the DLC installed?"); Logger.LogWarning($"Tried to make a slide reel but couldn't. Do you have the DLC installed?");
@ -139,7 +139,7 @@ namespace NewHorizons.Builder.Props
{ {
if (_autoPrefab == null) if (_autoPrefab == null)
{ {
_autoPrefab = GameObject.Find("RingWorld_Body/Sector_RingInterior/Sector_Zone4/Sector_BlightedShore/Sector_JammingControlRoom_Zone4/Interactables_JammingControlRoom_Zone4/AutoProjector_SignalJammer/Prefab_IP_AutoProjector_SignalJammer")?.gameObject?.InstantiateInactive(); _autoPrefab = SearchUtilities.Find("RingWorld_Body/Sector_RingInterior/Sector_Zone4/Sector_BlightedShore/Sector_JammingControlRoom_Zone4/Interactables_JammingControlRoom_Zone4/AutoProjector_SignalJammer/Prefab_IP_AutoProjector_SignalJammer")?.gameObject?.InstantiateInactive();
if (_autoPrefab == null) if (_autoPrefab == null)
{ {
Logger.LogWarning($"Tried to make a auto projector but couldn't. Do you have the DLC installed?"); Logger.LogWarning($"Tried to make a auto projector but couldn't. Do you have the DLC installed?");
@ -261,7 +261,7 @@ namespace NewHorizons.Builder.Props
// //
var mindSlideProjector = standingTorch.GetComponent<MindSlideProjector>(); var mindSlideProjector = standingTorch.GetComponent<MindSlideProjector>();
mindSlideProjector._mindProjectorImageEffect = GameObject.Find("Player_Body/PlayerCamera").GetComponent<MindProjectorImageEffect>(); mindSlideProjector._mindProjectorImageEffect = SearchUtilities.Find("Player_Body/PlayerCamera").GetComponent<MindProjectorImageEffect>();
// setup for visually supporting async texture loading // setup for visually supporting async texture loading
mindSlideProjector.enabled = false; mindSlideProjector.enabled = false;

View File

@ -1,4 +1,4 @@
using NewHorizons.External.Configs; using NewHorizons.External.Configs;
using NewHorizons.External.Modules; using NewHorizons.External.Modules;
using NewHorizons.Utility; using NewHorizons.Utility;
using OWML.Common; using OWML.Common;
@ -44,7 +44,7 @@ namespace NewHorizons.Builder.Props
GameObject prefab; GameObject prefab;
if (propInfo.assetBundle != null) prefab = AssetBundleUtilities.LoadPrefab(propInfo.assetBundle, propInfo.path, mod); if (propInfo.assetBundle != null) prefab = AssetBundleUtilities.LoadPrefab(propInfo.assetBundle, propInfo.path, mod);
else prefab = GameObject.Find(propInfo.path); else prefab = SearchUtilities.Find(propInfo.path);
for (int i = 0; i < propInfo.count; i++) for (int i = 0; i < propInfo.count; i++)
{ {
var randomInd = (int)Random.Range(0, points.Count - 1); var randomInd = (int)Random.Range(0, points.Count - 1);

View File

@ -1,4 +1,4 @@
using NewHorizons.Components; using NewHorizons.Components;
using NewHorizons.External.Modules; using NewHorizons.External.Modules;
using NewHorizons.Utility; using NewHorizons.Utility;
using OWML.Common; using OWML.Common;
@ -192,7 +192,7 @@ namespace NewHorizons.Builder.Props
source.rolloffMode = AudioRolloffMode.Custom; source.rolloffMode = AudioRolloffMode.Custom;
if (_customCurve == null) if (_customCurve == null)
_customCurve = GameObject.Find("Moon_Body/Sector_THM/Characters_THM/Villager_HEA_Esker/Signal_Whistling").GetComponent<AudioSource>().GetCustomCurve(AudioSourceCurveType.CustomRolloff); _customCurve = SearchUtilities.Find("Moon_Body/Sector_THM/Characters_THM/Villager_HEA_Esker/Signal_Whistling").GetComponent<AudioSource>().GetCustomCurve(AudioSourceCurveType.CustomRolloff);
source.SetCustomCurve(AudioSourceCurveType.CustomRolloff, _customCurve); source.SetCustomCurve(AudioSourceCurveType.CustomRolloff, _customCurve);
// If it can be heard regularly then we play it immediately // If it can be heard regularly then we play it immediately

View File

@ -26,17 +26,17 @@ namespace NewHorizons.Builder.Props
{ {
if (_upPrefab == null) if (_upPrefab == null)
{ {
_upPrefab = GameObject.Find("BrittleHollow_Body/Sector_BH/Sector_SouthHemisphere/Sector_SouthPole/Sector_Observatory/Interactables_Observatory/MockUpTornado").InstantiateInactive(); _upPrefab = SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_SouthHemisphere/Sector_SouthPole/Sector_Observatory/Interactables_Observatory/MockUpTornado").InstantiateInactive();
_upPrefab.name = "Tornado_Up_Prefab"; _upPrefab.name = "Tornado_Up_Prefab";
} }
if (_downPrefab == null) if (_downPrefab == null)
{ {
_downPrefab = GameObject.Find("BrittleHollow_Body/Sector_BH/Sector_SouthHemisphere/Sector_SouthPole/Sector_Observatory/Interactables_Observatory/MockDownTornado").InstantiateInactive(); _downPrefab = SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_SouthHemisphere/Sector_SouthPole/Sector_Observatory/Interactables_Observatory/MockDownTornado").InstantiateInactive();
_downPrefab.name = "Tornado_Down_Prefab"; _downPrefab.name = "Tornado_Down_Prefab";
} }
if (_hurricanePrefab == null) if (_hurricanePrefab == null)
{ {
_hurricanePrefab = GameObject.Find("GiantsDeep_Body/Sector_GD/Sector_GDInterior/Tornadoes_GDInterior/Hurricane/").InstantiateInactive(); _hurricanePrefab = SearchUtilities.Find("GiantsDeep_Body/Sector_GD/Sector_GDInterior/Tornadoes_GDInterior/Hurricane/").InstantiateInactive();
// For some reason they put the hurricane at the origin and offset all its children (450) // For some reason they put the hurricane at the origin and offset all its children (450)
// Increasing by 40 will keep the bottom above the ground // Increasing by 40 will keep the bottom above the ground
foreach (Transform child in _hurricanePrefab.transform) foreach (Transform child in _hurricanePrefab.transform)
@ -50,7 +50,7 @@ namespace NewHorizons.Builder.Props
} }
if (_soundPrefab == null) if (_soundPrefab == null)
{ {
_soundPrefab = GameObject.Find("GiantsDeep_Body/Sector_GD/Sector_GDInterior/Tornadoes_GDInterior/SouthernTornadoes/DownTornado_Pivot/DownTornado/AudioRail").InstantiateInactive(); _soundPrefab = SearchUtilities.Find("GiantsDeep_Body/Sector_GD/Sector_GDInterior/Tornadoes_GDInterior/SouthernTornadoes/DownTornado_Pivot/DownTornado/AudioRail").InstantiateInactive();
_soundPrefab.name = "AudioRail_Prefab"; _soundPrefab.name = "AudioRail_Prefab";
} }
if (_mainTexture == null) if (_mainTexture == null)

View File

@ -1,4 +1,4 @@
using NewHorizons.External.Modules; using NewHorizons.External.Modules;
using NewHorizons.Utility; using NewHorizons.Utility;
using UnityEngine; using UnityEngine;
namespace NewHorizons.Builder.Props namespace NewHorizons.Builder.Props
@ -12,7 +12,7 @@ namespace NewHorizons.Builder.Props
public static void Make(GameObject planetGO, Sector sector, PropModule.VolcanoInfo info) public static void Make(GameObject planetGO, Sector sector, PropModule.VolcanoInfo info)
{ {
var prefab = GameObject.Find("VolcanicMoon_Body/Sector_VM/Effects_VM/VolcanoPivot (2)/MeteorLauncher"); var prefab = SearchUtilities.Find("VolcanicMoon_Body/Sector_VM/Effects_VM/VolcanoPivot (2)/MeteorLauncher");
var launcherGO = prefab.InstantiateInactive(); var launcherGO = prefab.InstantiateInactive();
launcherGO.transform.parent = sector.transform; launcherGO.transform.parent = sector.transform;

View File

@ -1,4 +1,4 @@
using NewHorizons.Components; using NewHorizons.Components;
using NewHorizons.External.Modules; using NewHorizons.External.Modules;
using NewHorizons.Handlers; using NewHorizons.Handlers;
using NewHorizons.Utility; using NewHorizons.Utility;
@ -16,7 +16,7 @@ namespace NewHorizons.Builder.ShipLog
#region General #region General
public static ShipLogAstroObject[][] ConstructMapMode(string systemName, GameObject transformParent, ShipLogAstroObject[][] currentNav, int layer) public static ShipLogAstroObject[][] ConstructMapMode(string systemName, GameObject transformParent, ShipLogAstroObject[][] currentNav, int layer)
{ {
Material greyScaleMaterial = GameObject.Find(ShipLogHandler.PAN_ROOT_PATH + "/TimberHearth/Sprite").GetComponent<Image>().material; Material greyScaleMaterial = SearchUtilities.Find(ShipLogHandler.PAN_ROOT_PATH + "/TimberHearth/Sprite").GetComponent<Image>().material;
List<NewHorizonsBody> bodies = Main.BodyDict[systemName].Where( List<NewHorizonsBody> bodies = Main.BodyDict[systemName].Where(
b => !(b.Config.ShipLog?.mapMode?.remove ?? false) && !b.Config.isQuantumState b => !(b.Config.ShipLog?.mapMode?.remove ?? false) && !b.Config.isQuantumState
).ToList(); ).ToList();
@ -99,6 +99,8 @@ namespace NewHorizons.Builder.ShipLog
{ {
const float unviewedIconOffset = 15; const float unviewedIconOffset = 15;
Logger.Log($"Adding ship log astro object for {body.Config.name}");
GameObject unviewedReference = SearchUtilities.CachedFind(ShipLogHandler.PAN_ROOT_PATH + "/TimberHearth/UnviewedIcon"); GameObject unviewedReference = SearchUtilities.CachedFind(ShipLogHandler.PAN_ROOT_PATH + "/TimberHearth/UnviewedIcon");
ShipLogAstroObject astroObject = gameObject.AddComponent<ShipLogAstroObject>(); ShipLogAstroObject astroObject = gameObject.AddComponent<ShipLogAstroObject>();
@ -235,6 +237,12 @@ namespace NewHorizons.Builder.ShipLog
{ {
GameObject newMapModeGO = CreateMapModeGameObject(body, transformParent, layer, body.Config.ShipLog?.mapMode?.manualPosition); GameObject newMapModeGO = CreateMapModeGameObject(body, transformParent, layer, body.Config.ShipLog?.mapMode?.manualPosition);
ShipLogAstroObject newAstroObject = AddShipLogAstroObject(newMapModeGO, body, greyScaleMaterial, layer); ShipLogAstroObject newAstroObject = AddShipLogAstroObject(newMapModeGO, body, greyScaleMaterial, layer);
if (body.Config.FocalPoint != null)
{
newAstroObject._imageObj.GetComponent<Image>().enabled = false;
newAstroObject._outlineObj.GetComponent<Image>().enabled = false;
newAstroObject._unviewedObj.GetComponent<Image>().enabled = false;
}
MakeDetails(body, newMapModeGO.transform, greyScaleMaterial); MakeDetails(body, newMapModeGO.transform, greyScaleMaterial);
Vector2 navigationPosition = body.Config.ShipLog?.mapMode?.manualNavigationPosition; Vector2 navigationPosition = body.Config.ShipLog?.mapMode?.manualNavigationPosition;
navMatrix[(int)navigationPosition.y][(int)navigationPosition.x] = newAstroObject; navMatrix[(int)navigationPosition.y][(int)navigationPosition.x] = newAstroObject;
@ -251,12 +259,12 @@ namespace NewHorizons.Builder.ShipLog
navMatrix[navIndex[0]][navIndex[1]] = null; navMatrix[navIndex[0]][navIndex[1]] = null;
if (astroObject.GetID() == "CAVE_TWIN" || astroObject.GetID() == "TOWER_TWIN") if (astroObject.GetID() == "CAVE_TWIN" || astroObject.GetID() == "TOWER_TWIN")
{ {
GameObject.Find(ShipLogHandler.PAN_ROOT_PATH + "/" + "SandFunnel").SetActive(false); SearchUtilities.Find(ShipLogHandler.PAN_ROOT_PATH + "/" + "SandFunnel").SetActive(false);
} }
} }
else if (name == "SandFunnel") else if (name == "SandFunnel")
{ {
GameObject.Find(ShipLogHandler.PAN_ROOT_PATH + "/" + "SandFunnel").SetActive(false); SearchUtilities.Find(ShipLogHandler.PAN_ROOT_PATH + "/" + "SandFunnel").SetActive(false);
} }
gameObject.SetActive(false); gameObject.SetActive(false);
} }
@ -380,7 +388,7 @@ namespace NewHorizons.Builder.ShipLog
return new MapModeObject(); return new MapModeObject();
} }
private static List<MapModeObject> ConstructChildrenNodes(MapModeObject parent, List<NewHorizonsBody> searchList, string secondaryName = "") private static List<MapModeObject> ConstructChildrenNodes(MapModeObject parent, List<NewHorizonsBody> searchList, string secondaryName = "", string focalPointName = "")
{ {
List<MapModeObject> children = new List<MapModeObject>(); List<MapModeObject> children = new List<MapModeObject>();
int newX = parent.x; int newX = parent.x;
@ -388,7 +396,7 @@ namespace NewHorizons.Builder.ShipLog
int newLevel = parent.level + 1; int newLevel = parent.level + 1;
MapModeObject lastSibling = parent; MapModeObject lastSibling = parent;
foreach (NewHorizonsBody body in searchList.Where(b => b.Config.Orbit.primaryBody == parent.mainBody.Config.name || b.Config.name == secondaryName)) foreach (NewHorizonsBody body in searchList.Where(b => b.Config.Orbit.primaryBody == parent.mainBody.Config.name || (b.Config.Orbit.primaryBody == focalPointName && b.Config.name != parent.mainBody.Config.name) || b.Config.name == secondaryName))
{ {
bool even = newLevel % 2 == 0; bool even = newLevel % 2 == 0;
newX = even ? newX : newX + 1; newX = even ? newX : newX + 1;
@ -403,13 +411,15 @@ namespace NewHorizons.Builder.ShipLog
lastSibling = lastSibling lastSibling = lastSibling
}; };
string newSecondaryName = ""; string newSecondaryName = "";
string newFocalPointName = "";
if (body.Config.FocalPoint != null) if (body.Config.FocalPoint != null)
{ {
newFocalPointName = body.Config.name;
newNode.mainBody = searchList.Find(b => b.Config.name == body.Config.FocalPoint.primary); newNode.mainBody = searchList.Find(b => b.Config.name == body.Config.FocalPoint.primary);
newSecondaryName = searchList.Find(b => b.Config.name == body.Config.FocalPoint.secondary).Config.name; newSecondaryName = searchList.Find(b => b.Config.name == body.Config.FocalPoint.secondary).Config.name;
} }
newNode.children = ConstructChildrenNodes(newNode, searchList, newSecondaryName); newNode.children = ConstructChildrenNodes(newNode, searchList, newSecondaryName, newFocalPointName);
if (even) if (even)
{ {
newY += newNode.branch_height; newY += newNode.branch_height;
@ -481,7 +491,7 @@ namespace NewHorizons.Builder.ShipLog
GameObject newNodeGO = CreateMapModeGameObject(node.mainBody, parent, layer, position); GameObject newNodeGO = CreateMapModeGameObject(node.mainBody, parent, layer, position);
ShipLogAstroObject astroObject = AddShipLogAstroObject(newNodeGO, node.mainBody, greyScaleMaterial, layer); ShipLogAstroObject astroObject = AddShipLogAstroObject(newNodeGO, node.mainBody, greyScaleMaterial, layer);
if (node.mainBody.Config.FocalPoint != null) if (node.mainBody.Config.FocalPoint != null)
{ {
astroObject._imageObj.GetComponent<Image>().enabled = false; astroObject._imageObj.GetComponent<Image>().enabled = false;
astroObject._outlineObj.GetComponent<Image>().enabled = false; astroObject._outlineObj.GetComponent<Image>().enabled = false;
astroObject._unviewedObj.GetComponent<Image>().enabled = false; astroObject._unviewedObj.GetComponent<Image>().enabled = false;

View File

@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using UnityEngine; using UnityEngine;
namespace NewHorizons.Components namespace NewHorizons.Components
@ -12,6 +12,10 @@ namespace NewHorizons.Components
private List<Renderer> _renderers = null; private List<Renderer> _renderers = null;
internal static bool isPlayerInside = false;
internal static bool isProbeInside = false;
internal static bool isShipInside = false;
public void Init(CloakFieldController cloak, GameObject root) public void Init(CloakFieldController cloak, GameObject root)
{ {
_cloak = cloak; _cloak = cloak;
@ -20,9 +24,17 @@ namespace NewHorizons.Components
// Lets just clear these off idc // Lets just clear these off idc
_cloak.OnPlayerEnter = new OWEvent(); _cloak.OnPlayerEnter = new OWEvent();
_cloak.OnPlayerExit = new OWEvent(); _cloak.OnPlayerExit = new OWEvent();
_cloak.OnProbeEnter = new OWEvent();
_cloak.OnProbeExit = new OWEvent();
_cloak.OnShipEnter = new OWEvent();
_cloak.OnShipExit = new OWEvent();
_cloak.OnPlayerEnter += OnPlayerEnter; _cloak.OnPlayerEnter += OnPlayerEnter;
_cloak.OnPlayerExit += OnPlayerExit; _cloak.OnPlayerExit += OnPlayerExit;
_cloak.OnProbeEnter += OnProbeEnter;
_cloak.OnProbeExit += OnProbeExit;
_cloak.OnShipEnter += OnShipEnter;
_cloak.OnShipExit += OnShipExit;
_isInitialized = true; _isInitialized = true;
} }
@ -49,6 +61,9 @@ namespace NewHorizons.Components
{ {
renderer.forceRenderingOff = false; renderer.forceRenderingOff = false;
} }
isPlayerInside = true;
GlobalMessenger.FireEvent("PlayerEnterCloakField");
} }
public void OnPlayerExit() public void OnPlayerExit()
@ -59,6 +74,56 @@ namespace NewHorizons.Components
{ {
renderer.forceRenderingOff = true; renderer.forceRenderingOff = true;
} }
isPlayerInside = false;
GlobalMessenger.FireEvent("PlayerExitCloakField");
} }
public void OnProbeEnter()
{
isProbeInside = true;
GlobalMessenger.FireEvent("ProbeEnterCloakField");
}
public void OnProbeExit()
{
isProbeInside = false;
GlobalMessenger.FireEvent("ProbeExitCloakField");
}
public void OnShipEnter()
{
isShipInside = true;
GlobalMessenger.FireEvent("ShipEnterCloakField");
}
public void OnShipExit()
{
isShipInside = false;
GlobalMessenger.FireEvent("ShipExitCloakField");
}
public void EnableCloak()
{
SunLightController.RegisterSunOverrider(_cloak, 900);
_cloak._cloakSphereRenderer.SetActivation(true);
Shader.EnableKeyword("_CLOAKINGFIELDENABLED");
_cloak._cloakVisualsEnabled = true;
}
public void DisableCloak()
{
SunLightController.UnregisterSunOverrider(_cloak);
_cloak._cloakSphereRenderer.SetActivation(false);
Shader.DisableKeyword("_CLOAKINGFIELDENABLED");
_cloak._cloakVisualsEnabled = false;
}
public void SetReferenceFrameVolumeActive(bool active) => _cloak._referenceFrameVolume.gameObject.SetActive(active);
public void EnableReferenceFrameVolume() => SetReferenceFrameVolumeActive(true);
public void DisableReferenceFrameVolume() => SetReferenceFrameVolumeActive(false);
public void TurnOnMusic() => _cloak._hasTriggeredMusic = false;
public void TurnOffMusic() => _cloak._hasTriggeredMusic = true;
} }
} }

View File

@ -1,4 +1,4 @@
using NewHorizons.Handlers; using NewHorizons.Handlers;
using NewHorizons.Utility; using NewHorizons.Utility;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -99,7 +99,7 @@ namespace NewHorizons.Components
{ {
if (_cardTemplate == null) if (_cardTemplate == null)
{ {
var panRoot = GameObject.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/ShipLogPivot/ShipLogCanvas/DetectiveMode/ScaleRoot/PanRoot"); var panRoot = SearchUtilities.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/ShipLogPivot/ShipLogCanvas/DetectiveMode/ScaleRoot/PanRoot");
_cardTemplate = GameObject.Instantiate(panRoot.GetComponentInChildren<ShipLogEntryCard>().gameObject); _cardTemplate = GameObject.Instantiate(panRoot.GetComponentInChildren<ShipLogEntryCard>().gameObject);
_cardTemplate.SetActive(false); _cardTemplate.SetActive(false);
} }

View File

@ -1,4 +1,5 @@
using NewHorizons.Builder.General; using NewHorizons.Builder.General;
using NewHorizons.Utility;
using UnityEngine; using UnityEngine;
using Logger = NewHorizons.Utility.Logger; using Logger = NewHorizons.Utility.Logger;
namespace NewHorizons.Components namespace NewHorizons.Components
@ -26,8 +27,8 @@ namespace NewHorizons.Components
public void Init() public void Init()
{ {
_blackHolePrefab = GameObject.Find(_blackHolePath); _blackHolePrefab = SearchUtilities.Find(_blackHolePath);
_whiteHolePrefab = GameObject.Find(_whiteHolePath); _whiteHolePrefab = SearchUtilities.Find(_whiteHolePath);
} }
public void Start() public void Start()
@ -36,8 +37,9 @@ namespace NewHorizons.Components
MakeWhiteHole(); MakeWhiteHole();
_isWarpingIn = false; _isWarpingIn = false;
_oneShotSource = base.gameObject.AddComponent<OWAudioSource>(); _oneShotSource = gameObject.AddComponent<OWAudioSource>();
_oneShotSource._track = OWAudioMixer.TrackName.Ship;
GlobalMessenger.AddListener("FinishOpenEyes", new Callback(OnFinishOpenEyes)); GlobalMessenger.AddListener("FinishOpenEyes", new Callback(OnFinishOpenEyes));
} }
@ -183,7 +185,7 @@ namespace NewHorizons.Components
// For some reason warping into the ship makes you suffocate while in the ship // For some reason warping into the ship makes you suffocate while in the ship
if (_wearingSuit) resources.OnSuitUp(); if (_wearingSuit) resources.OnSuitUp();
var o2Volume = Locator.GetShipBody().GetComponent<OxygenVolume>(); var o2Volume = Locator.GetShipBody().GetComponent<OxygenVolume>();
var atmoVolume = GameObject.Find("Ship_Body/Volumes/ShipAtmosphereVolume").GetComponent<SimpleFluidVolume>(); var atmoVolume = SearchUtilities.Find("Ship_Body/Volumes/ShipAtmosphereVolume").GetComponent<SimpleFluidVolume>();
resources._cameraFluidDetector.AddVolume(atmoVolume); resources._cameraFluidDetector.AddVolume(atmoVolume);
resources._cameraFluidDetector.OnVolumeAdded(atmoVolume); resources._cameraFluidDetector.OnVolumeAdded(atmoVolume);

View File

@ -199,8 +199,8 @@ namespace NewHorizons.Components.SizeControllers
supernova.enabled = true; supernova.enabled = true;
_isSupernova = true; _isSupernova = true;
_supernovaStartTime = Time.time; _supernovaStartTime = Time.time;
atmosphere.SetActive(false); if (atmosphere != null) atmosphere.SetActive(false);
_destructionVolume._deathType = DeathType.Supernova; if (_destructionVolume != null) _destructionVolume._deathType = DeathType.Supernova;
return; return;
} }
} }

View File

@ -1,4 +1,4 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using NewHorizons.External.Modules; using NewHorizons.External.Modules;
@ -45,6 +45,11 @@ namespace NewHorizons.External.Configs
#endregion Obsolete #endregion Obsolete
/// <summary>
/// Add a cloaking field to this planet
/// </summary>
public CloakModule Cloak;
/// <summary> /// <summary>
/// `true` if you want to delete this planet /// `true` if you want to delete this planet
/// </summary> /// </summary>
@ -96,6 +101,11 @@ namespace NewHorizons.External.Configs
/// </summary> /// </summary>
public PropModule Props; public PropModule Props;
/// <summary>
/// Reference frame properties of this body
/// </summary>
public ReferenceFrameModule ReferenceFrame;
/// <summary> /// <summary>
/// A list of paths to child GameObjects to destroy on this planet /// A list of paths to child GameObjects to destroy on this planet
/// </summary> /// </summary>
@ -157,6 +167,7 @@ namespace NewHorizons.External.Configs
if (Base == null) Base = new BaseModule(); if (Base == null) Base = new BaseModule();
if (Orbit == null) Orbit = new OrbitModule(); if (Orbit == null) Orbit = new OrbitModule();
if (ShipLog == null) ShipLog = new ShipLogModule(); if (ShipLog == null) ShipLog = new ShipLogModule();
if (ReferenceFrame == null) ReferenceFrame = new ReferenceFrameModule();
} }
public void MigrateAndValidate() public void MigrateAndValidate()
@ -190,8 +201,16 @@ namespace NewHorizons.External.Configs
if (Base.isSatellite) Base.showMinimap = false; if (Base.isSatellite) Base.showMinimap = false;
if (!Base.hasReferenceFrame) ReferenceFrame.hideInMap = true;
if (childrenToDestroy != null) removeChildren = childrenToDestroy; if (childrenToDestroy != null) removeChildren = childrenToDestroy;
if (Base.cloakRadius != 0)
Cloak = new CloakModule
{
radius = Base.cloakRadius
};
if (Base.hasAmbientLight) Base.ambientLight = 0.5f; if (Base.hasAmbientLight) Base.ambientLight = 0.5f;
if (Atmosphere != null) if (Atmosphere != null)
@ -215,7 +234,11 @@ namespace NewHorizons.External.Configs
// Former is obsolete, latter is to validate // Former is obsolete, latter is to validate
if (Atmosphere.hasAtmosphere || Atmosphere.atmosphereTint != null) if (Atmosphere.hasAtmosphere || Atmosphere.atmosphereTint != null)
Atmosphere.useAtmosphereShader = true; Atmosphere.useAtmosphereShader = true;
// useBasicCloudShader is obsolete
if (Atmosphere.clouds != null && Atmosphere.clouds.useBasicCloudShader)
Atmosphere.clouds.cloudsPrefab = CloudPrefabType.Basic;
} }
if (Props?.tornados != null) if (Props?.tornados != null)

View File

@ -51,6 +51,16 @@ namespace NewHorizons.External.Configs
/// </summary> /// </summary>
public bool startHere; public bool startHere;
/// <summary>
/// Name of an existing AudioClip in the game that will play when travelling in space.
/// </summary>
public string travelAudioClip;
/// <summary>
/// Relative filepath to the .wav file to use as the audio. Mutually exclusive with travelAudioClip.
/// </summary>
public string travelAudioFilePath;
public class NomaiCoordinates public class NomaiCoordinates
{ {
public int[] x; public int[] x;

View File

@ -1,4 +1,4 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization; using System.Runtime.Serialization;
@ -20,6 +20,16 @@ namespace NewHorizons.External.Modules
[EnumMember(Value = @"sand")] Sand = 3, [EnumMember(Value = @"sand")] Sand = 3,
[EnumMember(Value = @"plasma")] Plasma = 4 [EnumMember(Value = @"plasma")] Plasma = 4
}
[JsonConverter(typeof(StringEnumConverter))]
public enum CloudPrefabType
{
[EnumMember(Value = @"giantsDeep")] GiantsDeep = 0,
[EnumMember(Value = @"quantumMoon")] QuantumMoon = 1,
[EnumMember(Value = @"basic")] Basic = 2,
} }
[JsonObject] [JsonObject]
@ -88,6 +98,11 @@ namespace NewHorizons.External.Modules
[JsonObject] [JsonObject]
public class CloudInfo public class CloudInfo
{ {
/// <summary>
/// Should these clouds be based on Giant's Deep's banded clouds, or the Quantum Moon's non-banded clouds?
/// </summary>
public CloudPrefabType cloudsPrefab;
/// <summary> /// <summary>
/// Relative filepath to the cloud cap texture, if the planet has clouds. /// Relative filepath to the cloud cap texture, if the planet has clouds.
/// </summary> /// </summary>
@ -138,11 +153,19 @@ namespace NewHorizons.External.Modules
/// If the top layer shouldn't have shadows. Set to true if you're making a brown dwarf for example. /// If the top layer shouldn't have shadows. Set to true if you're making a brown dwarf for example.
/// </summary> /// </summary>
public bool unlit; public bool unlit;
#region Obsolete
/// <summary> /// <summary>
/// Set to `false` in order to use Giant's Deep's shader. Set to `true` to just apply the cloud texture as is. /// Set to `false` in order to use Giant's Deep's shader. Set to `true` to just apply the cloud texture as is.
/// </summary> /// </summary>
[Obsolete("useBasicCloudShader is deprecated, please use cloudsPrefab=\"basic\" instead")]
public bool useBasicCloudShader; public bool useBasicCloudShader;
#endregion Obsolete
} }

View File

@ -1,4 +1,4 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using NewHorizons.Utility; using NewHorizons.Utility;
@ -30,12 +30,6 @@ namespace NewHorizons.External.Modules
/// </summary> /// </summary>
public bool centerOfSolarSystem; public bool centerOfSolarSystem;
/// <summary>
/// Radius of the cloaking field around the planet. It's a bit finicky so experiment with different values. If you
/// don't want a cloak, leave this as 0.
/// </summary>
public float cloakRadius;
/// <summary> /// <summary>
/// If it has a comet tail, it'll be oriented according to these Euler angles. /// If it has a comet tail, it'll be oriented according to these Euler angles.
/// </summary> /// </summary>
@ -62,11 +56,6 @@ namespace NewHorizons.External.Modules
/// </summary> /// </summary>
public bool hasMapMarker; public bool hasMapMarker;
/// <summary>
/// Allows the object to be targeted on the map.
/// </summary>
[DefaultValue(true)] public bool hasReferenceFrame = true;
/// <summary> /// <summary>
/// Can this planet survive entering a star? /// Can this planet survive entering a star?
/// </summary> /// </summary>
@ -92,6 +81,11 @@ namespace NewHorizons.External.Modules
/// </summary> /// </summary>
public float surfaceSize; public float surfaceSize;
/// <summary>
/// Radius of the zero gravity volume. This will make it so no gravity from any planet will affect you. Useful for satellites.
/// </summary>
public float zeroGravityRadius;
#region Obsolete #region Obsolete
[Obsolete("IsSatellite is deprecated, please use ShowMinimap instead")] [Obsolete("IsSatellite is deprecated, please use ShowMinimap instead")]
@ -112,6 +106,12 @@ namespace NewHorizons.External.Modules
[Obsolete("HasAmbientLight is deprecated, please use AmbientLight instead")] [Obsolete("HasAmbientLight is deprecated, please use AmbientLight instead")]
public bool hasAmbientLight; public bool hasAmbientLight;
[Obsolete("HasReferenceFrame is deprecated, please use ReferenceModule instead")]
[DefaultValue(true)] public bool hasReferenceFrame = true;
[Obsolete("CloakRadius is deprecated, please use CloakModule instead")]
public float cloakRadius;
#endregion Obsolete #endregion Obsolete
} }
} }

View File

@ -0,0 +1,29 @@
using System;
using System.ComponentModel;
using System.Runtime.Serialization;
using NewHorizons.Utility;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace NewHorizons.External.Modules
{
[JsonObject]
public class CloakModule
{
/// <summary>
/// Radius of the cloaking field around the planet. It's a bit finicky so experiment with different values. If you
/// don't want a cloak, leave this as 0.
/// </summary>
public float radius;
/// <summary>
/// Name of an existing AudioClip in the game that will play when entering the cloaking field.
/// </summary>
public string audioClip;
/// <summary>
/// Relative filepath to the .wav file to use as the audio. Mutually exclusive with audioClip.
/// </summary>
public string audioFilePath;
}
}

View File

@ -16,10 +16,6 @@ namespace NewHorizons.External.Modules
/// </summary> /// </summary>
public DetailInfo[] details; public DetailInfo[] details;
public QuantumSocketGroupInfo[] quantumSocketGroups;
class QuantumSocketGroupInfo { string id; QuantumSocketInfo[] sockets; }
class QuantumSocketInfo { MVector3 position; MVector3 rotation; float probability; }
/// <summary> /// <summary>
/// Add dialogue triggers to this planet /// Add dialogue triggers to this planet
/// </summary> /// </summary>
@ -117,6 +113,11 @@ namespace NewHorizons.External.Modules
[JsonObject] [JsonObject]
public class DetailInfo public class DetailInfo
{ {
/// <summary>
/// An optional rename of the detail
/// </summary>
public string rename;
/// <summary> /// <summary>
/// Do we override rotation and try to automatically align this object to stand upright on the body's surface? /// Do we override rotation and try to automatically align this object to stand upright on the body's surface?
/// </summary> /// </summary>

View File

@ -0,0 +1,33 @@
using System;
using System.ComponentModel;
using System.Runtime.Serialization;
using NewHorizons.Utility;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace NewHorizons.External.Modules
{
[JsonObject]
public class ReferenceFrameModule
{
/// <summary>
/// Stop the object from being targeted on the map.
/// </summary>
public bool hideInMap;
/// <summary>
/// Radius of the brackets that show up when you target this. Defaults to the sphereOfInfluence.
/// </summary>
[DefaultValue(-1)] public float bracketRadius = -1;
/// <summary>
/// If it should be targetable even when super close.
/// </summary>
public bool targetWhenClose;
/// <summary>
/// The maximum distance that the reference frame can be targeted from. Defaults to double the sphereOfInfluence.
/// </summary>
[DefaultValue(-1)] public float maxTargetDistance = -1;
}
}

View File

@ -1,4 +1,4 @@
using System.ComponentModel; using System.ComponentModel;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using NewHorizons.Utility; using NewHorizons.Utility;
using Newtonsoft.Json; using Newtonsoft.Json;
@ -55,5 +55,11 @@ namespace NewHorizons.External.Modules.VariableSize
/// Colour of the star. /// Colour of the star.
/// </summary> /// </summary>
public MColor tint; public MColor tint;
/// <summary>
/// How far the light from the star can reach.
/// </summary>
[DefaultValue(50000f)] [Range(0f, double.MaxValue)]
public float lightRadius = 50000f;
} }
} }

View File

@ -1,4 +1,4 @@
using NewHorizons.Builder.Atmosphere; using NewHorizons.Builder.Atmosphere;
using NewHorizons.Builder.Body; using NewHorizons.Builder.Body;
using NewHorizons.Builder.General; using NewHorizons.Builder.General;
using NewHorizons.Builder.Orbital; using NewHorizons.Builder.Orbital;
@ -33,13 +33,13 @@ namespace NewHorizons.Handlers
// Set up stars // Set up stars
// Need to manage this when there are multiple stars // Need to manage this when there are multiple stars
var sun = GameObject.Find("Sun_Body"); var sun = SearchUtilities.Find("Sun_Body");
var starController = sun.AddComponent<StarController>(); var starController = sun.AddComponent<StarController>();
starController.Light = GameObject.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent<Light>(); starController.Light = SearchUtilities.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent<Light>();
starController.AmbientLight = GameObject.Find("Sun_Body/AmbientLight_SUN").GetComponent<Light>(); starController.AmbientLight = SearchUtilities.Find("Sun_Body/AmbientLight_SUN").GetComponent<Light>();
starController.FaceActiveCamera = GameObject.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent<FaceActiveCamera>(); starController.FaceActiveCamera = SearchUtilities.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent<FaceActiveCamera>();
starController.CSMTextureCacher = GameObject.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent<CSMTextureCacher>(); starController.CSMTextureCacher = SearchUtilities.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent<CSMTextureCacher>();
starController.ProxyShadowLight = GameObject.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent<ProxyShadowLight>(); starController.ProxyShadowLight = SearchUtilities.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent<ProxyShadowLight>();
starController.Intensity = 0.9859f; starController.Intensity = 0.9859f;
starController.SunColor = new Color(1f, 0.8845f, 0.6677f, 1f); starController.SunColor = new Color(1f, 0.8845f, 0.6677f, 1f);
@ -137,7 +137,7 @@ namespace NewHorizons.Handlers
catch (Exception) catch (Exception)
{ {
if (body?.Config?.name == null) Logger.LogError($"How is there no name for {body}"); if (body?.Config?.name == null) Logger.LogError($"How is there no name for {body}");
else existingPlanet = GameObject.Find(body.Config.name.Replace(" ", "") + "_Body"); else existingPlanet = SearchUtilities.Find(body.Config.name.Replace(" ", "") + "_Body", false);
} }
if (existingPlanet != null) if (existingPlanet != null)
@ -252,7 +252,7 @@ namespace NewHorizons.Handlers
{ {
foreach (var child in body.Config.removeChildren) foreach (var child in body.Config.removeChildren)
{ {
Main.Instance.ModHelper.Events.Unity.FireInNUpdates(() => GameObject.Find(go.name + "/" + child)?.SetActive(false), 2); Main.Instance.ModHelper.Events.Unity.FireInNUpdates(() => SearchUtilities.Find(go.name + "/" + child)?.SetActive(false), 2);
} }
} }
@ -303,20 +303,17 @@ namespace NewHorizons.Handlers
if (body.Config.Base.surfaceGravity != 0) if (body.Config.Base.surfaceGravity != 0)
{ {
GravityBuilder.Make(go, ao, body.Config); GravityBuilder.Make(go, ao, owRigidBody, body.Config);
} }
if (body.Config.Base.hasReferenceFrame) RFVolumeBuilder.Make(go, owRigidBody, sphereOfInfluence, body.Config.ReferenceFrame);
{
RFVolumeBuilder.Make(go, owRigidBody, sphereOfInfluence);
}
if (body.Config.Base.hasMapMarker) if (body.Config.Base.hasMapMarker)
{ {
MarkerBuilder.Make(go, body.Config.name, body.Config); MarkerBuilder.Make(go, body.Config.name, body.Config);
} }
VolumesBuilder.Make(go, body.Config, sphereOfInfluence); VolumesBuilder.Make(go, owRigidBody, body.Config, sphereOfInfluence);
if (body.Config.FocalPoint != null) if (body.Config.FocalPoint != null)
{ {
@ -483,9 +480,9 @@ namespace NewHorizons.Handlers
} }
// Has to go last probably // Has to go last probably
if (body.Config.Base.cloakRadius != 0f) if (body.Config.Cloak != null && body.Config.Cloak.radius != 0f)
{ {
CloakBuilder.Make(go, sector, rb, body.Config.Base.cloakRadius); CloakBuilder.Make(go, sector, rb, body.Config.Cloak, !body.Config.ReferenceFrame.hideInMap, body.Mod);
} }
return go; return go;

View File

@ -1,4 +1,4 @@
using NewHorizons.Components; using NewHorizons.Components;
using NewHorizons.Utility; using NewHorizons.Utility;
using OWML.Utils; using OWML.Utils;
using System; using System;
@ -33,7 +33,7 @@ namespace NewHorizons.Handlers
public static void RemoveSolarSystem() public static void RemoveSolarSystem()
{ {
// Stop the sun from killing the player // Stop the sun from killing the player
var sunVolumes = GameObject.Find("Sun_Body/Sector_SUN/Volumes_SUN"); var sunVolumes = SearchUtilities.Find("Sun_Body/Sector_SUN/Volumes_SUN");
sunVolumes.SetActive(false); sunVolumes.SetActive(false);
foreach (var name in _solarSystemBodies) foreach (var name in _solarSystemBodies)
@ -82,11 +82,11 @@ namespace NewHorizons.Handlers
break; break;
case AstroObject.Name.CaveTwin: case AstroObject.Name.CaveTwin:
case AstroObject.Name.TowerTwin: case AstroObject.Name.TowerTwin:
DisableBody(GameObject.Find("FocalBody"), delete); DisableBody(SearchUtilities.Find("FocalBody"), delete);
DisableBody(GameObject.Find("SandFunnel_Body"), delete); DisableBody(SearchUtilities.Find("SandFunnel_Body"), delete);
break; break;
case AstroObject.Name.MapSatellite: case AstroObject.Name.MapSatellite:
DisableBody(GameObject.Find("MapSatellite_Body"), delete); DisableBody(SearchUtilities.Find("MapSatellite_Body"), delete);
break; break;
case AstroObject.Name.GiantsDeep: case AstroObject.Name.GiantsDeep:
// Might prevent leftover jellyfish from existing // Might prevent leftover jellyfish from existing
@ -100,7 +100,7 @@ namespace NewHorizons.Handlers
break; break;
case AstroObject.Name.TimberHearth: case AstroObject.Name.TimberHearth:
// Always just fucking kill this one to stop THE WARP BUG!!! // Always just fucking kill this one to stop THE WARP BUG!!!
DisableBody(GameObject.Find("StreamingGroup_TH"), true); DisableBody(SearchUtilities.Find("StreamingGroup_TH"), true);
foreach (var obj in GameObject.FindObjectsOfType<DayNightTracker>()) foreach (var obj in GameObject.FindObjectsOfType<DayNightTracker>())
{ {
@ -229,8 +229,8 @@ namespace NewHorizons.Handlers
{ {
if (name.Equals("TowerTwin")) name = "AshTwin"; if (name.Equals("TowerTwin")) name = "AshTwin";
if (name.Equals("CaveTwin")) name = "EmberTwin"; if (name.Equals("CaveTwin")) name = "EmberTwin";
var distantProxy = GameObject.Find(name + "_DistantProxy"); var distantProxy = SearchUtilities.Find(name + "_DistantProxy", false);
var distantProxyClone = GameObject.Find(name + "_DistantProxy(Clone)"); var distantProxyClone = SearchUtilities.Find(name + "_DistantProxy(Clone)", false);
if (distantProxy != null) GameObject.Destroy(distantProxy.gameObject); if (distantProxy != null) GameObject.Destroy(distantProxy.gameObject);
if (distantProxyClone != null) GameObject.Destroy(distantProxyClone.gameObject); if (distantProxyClone != null) GameObject.Destroy(distantProxyClone.gameObject);

View File

@ -26,7 +26,7 @@ namespace NewHorizons.Handlers
_entryIDsToNHBody = new Dictionary<string, NewHorizonsBody>(); _entryIDsToNHBody = new Dictionary<string, NewHorizonsBody>();
_nhBodyToAstroIDs = new Dictionary<NewHorizonsBody, string>(); _nhBodyToAstroIDs = new Dictionary<NewHorizonsBody, string>();
List<GameObject> gameObjects = SearchUtilities.GetAllChildren(GameObject.Find(PAN_ROOT_PATH)); List<GameObject> gameObjects = SearchUtilities.GetAllChildren(SearchUtilities.Find(PAN_ROOT_PATH));
_vanillaBodies = gameObjects.ConvertAll(g => g.name).ToArray(); _vanillaBodies = gameObjects.ConvertAll(g => g.name).ToArray();
_vanillaBodyIDs = gameObjects.ConvertAll(g => g.GetComponent<ShipLogAstroObject>()?.GetID()).ToArray(); _vanillaBodyIDs = gameObjects.ConvertAll(g => g.GetComponent<ShipLogAstroObject>()?.GetID()).ToArray();
} }

View File

@ -1,4 +1,4 @@
using NewHorizons.Components; using NewHorizons.Components;
using NewHorizons.Utility; using NewHorizons.Utility;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
@ -18,7 +18,7 @@ namespace NewHorizons.Handlers
{ {
_systems = systems; _systems = systems;
var shipLogRoot = GameObject.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/ShipLogPivot/ShipLogCanvas"); var shipLogRoot = SearchUtilities.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/ShipLogPivot/ShipLogCanvas");
var starChartLog = new GameObject("StarChartMode"); var starChartLog = new GameObject("StarChartMode");
starChartLog.SetActive(false); starChartLog.SetActive(false);
@ -29,7 +29,7 @@ namespace NewHorizons.Handlers
ShipLogStarChartMode = starChartLog.AddComponent<ShipLogStarChartMode>(); ShipLogStarChartMode = starChartLog.AddComponent<ShipLogStarChartMode>();
var reticleImage = GameObject.Instantiate(GameObject.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/ShipLogPivot/ShipLogCanvas/DetectiveMode/ReticleImage (1)/"), starChartLog.transform); var reticleImage = GameObject.Instantiate(SearchUtilities.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/ShipLogPivot/ShipLogCanvas/DetectiveMode/ReticleImage (1)/"), starChartLog.transform);
var scaleRoot = new GameObject("ScaleRoot"); var scaleRoot = new GameObject("ScaleRoot");
scaleRoot.transform.parent = starChartLog.transform; scaleRoot.transform.parent = starChartLog.transform;
@ -45,7 +45,7 @@ namespace NewHorizons.Handlers
var centerPromptList = shipLogRoot.transform.Find("ScreenPromptListScaleRoot/ScreenPromptList_Center")?.GetComponent<ScreenPromptList>(); var centerPromptList = shipLogRoot.transform.Find("ScreenPromptListScaleRoot/ScreenPromptList_Center")?.GetComponent<ScreenPromptList>();
var upperRightPromptList = shipLogRoot.transform.Find("ScreenPromptListScaleRoot/ScreenPromptList_UpperRight")?.GetComponent<ScreenPromptList>(); var upperRightPromptList = shipLogRoot.transform.Find("ScreenPromptListScaleRoot/ScreenPromptList_UpperRight")?.GetComponent<ScreenPromptList>();
var oneShotSource = GameObject.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/OneShotAudio_ShipLog")?.GetComponent<OWAudioSource>(); var oneShotSource = SearchUtilities.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/OneShotAudio_ShipLog")?.GetComponent<OWAudioSource>();
_starSystemToFactID = new Dictionary<string, string>(); _starSystemToFactID = new Dictionary<string, string>();
_factIDToStarSystem = new Dictionary<string, string>(); _factIDToStarSystem = new Dictionary<string, string>();

View File

@ -1,4 +1,4 @@
using NewHorizons.Builder.StarSystem; using NewHorizons.Builder.StarSystem;
using NewHorizons.Components; using NewHorizons.Components;
using NewHorizons.Utility; using NewHorizons.Utility;
using UnityEngine; using UnityEngine;
@ -9,7 +9,7 @@ namespace NewHorizons.Handlers
{ {
public static void LoadSystem(NewHorizonsSystem system) public static void LoadSystem(NewHorizonsSystem system)
{ {
var skybox = GameObject.Find("Skybox/Starfield"); var skybox = SearchUtilities.Find("Skybox/Starfield");
if (system.Config.skybox?.destroyStarField ?? false) if (system.Config.skybox?.destroyStarField ?? false)
{ {
@ -26,6 +26,30 @@ namespace NewHorizons.Handlers
var timeLoopController = new GameObject("TimeLoopController"); var timeLoopController = new GameObject("TimeLoopController");
timeLoopController.AddComponent<TimeLoopController>(); timeLoopController.AddComponent<TimeLoopController>();
} }
AudioClip clip = null;
if (system.Config.travelAudioClip != null) clip = SearchUtilities.FindResourceOfTypeAndName<AudioClip>(system.Config.travelAudioClip);
else if (system.Config.travelAudioFilePath != null)
{
try
{
clip = AudioUtilities.LoadAudio(system.Mod.ModHelper.Manifest.ModFolderPath + "/" + system.Config.travelAudioFilePath);
}
catch (System.Exception e)
{
Utility.Logger.LogError($"Couldn't load audio file {system.Config.travelAudioFilePath} : {e.Message}");
}
}
if (clip != null)
{
var travelSource = Locator.GetGlobalMusicController()._travelSource;
travelSource._audioLibraryClip = AudioType.None;
travelSource._clipArrayIndex = 0;
travelSource._clipArrayLength = 0;
travelSource._clipSelectionOnPlay = OWAudioSource.ClipSelectionOnPlay.MANUAL;
travelSource.clip = clip;
}
} }
} }
} }

View File

@ -13,7 +13,7 @@ namespace NewHorizons.Handlers
{ {
public static void InitSubtitles() public static void InitSubtitles()
{ {
GameObject subtitleContainer = GameObject.Find("TitleMenu/TitleCanvas/TitleLayoutGroup/Logo_EchoesOfTheEye"); GameObject subtitleContainer = SearchUtilities.Find("TitleMenu/TitleCanvas/TitleLayoutGroup/Logo_EchoesOfTheEye");
if (subtitleContainer == null) if (subtitleContainer == null)
{ {
@ -60,11 +60,11 @@ namespace NewHorizons.Handlers
body3.transform.localRotation = Quaternion.Euler(10f, 0f, 0f); body3.transform.localRotation = Quaternion.Euler(10f, 0f, 0f);
} }
GameObject.Find("Scene/Background/PlanetPivot/Prefab_HEA_Campfire").SetActive(false); SearchUtilities.Find("Scene/Background/PlanetPivot/Prefab_HEA_Campfire").SetActive(false);
GameObject.Find("Scene/Background/PlanetPivot/PlanetRoot").SetActive(false); SearchUtilities.Find("Scene/Background/PlanetPivot/PlanetRoot").SetActive(false);
var lightGO = new GameObject("Light"); var lightGO = new GameObject("Light");
lightGO.transform.parent = GameObject.Find("Scene/Background").transform; lightGO.transform.parent = SearchUtilities.Find("Scene/Background").transform;
lightGO.transform.localPosition = new Vector3(-47.9203f, 145.7596f, 43.1802f); lightGO.transform.localPosition = new Vector3(-47.9203f, 145.7596f, 43.1802f);
var light = lightGO.AddComponent<Light>(); var light = lightGO.AddComponent<Light>();
light.color = new Color(1f, 1f, 1f, 1f); light.color = new Color(1f, 1f, 1f, 1f);
@ -98,7 +98,7 @@ namespace NewHorizons.Handlers
HeightMapBuilder.Make(titleScreenGO, null, heightMap, body.Mod); HeightMapBuilder.Make(titleScreenGO, null, heightMap, body.Mod);
GameObject pivot = GameObject.Instantiate(GameObject.Find("Scene/Background/PlanetPivot"), GameObject.Find("Scene/Background").transform); GameObject pivot = GameObject.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)
{ {

View File

@ -159,7 +159,14 @@ namespace NewHorizons
private static void OnWakeUp() private static void OnWakeUp()
{ {
IsSystemReady = true; IsSystemReady = true;
Instance.OnStarSystemLoaded?.Invoke(Instance.CurrentStarSystem); try
{
Instance.OnStarSystemLoaded?.Invoke(Instance.CurrentStarSystem);
}
catch (Exception e)
{
Logger.LogError($"Exception thrown when invoking star system loaded event with parameter [{Instance.CurrentStarSystem}] : {e.GetType().FullName} {e.Message} {e.StackTrace}");
}
} }
private void OnSceneUnloaded(Scene scene) private void OnSceneUnloaded(Scene scene)
@ -190,7 +197,7 @@ namespace NewHorizons
} }
launchController.enabled = false; launchController.enabled = false;
} }
var nomaiProbe = GameObject.Find("NomaiProbe_Body"); var nomaiProbe = SearchUtilities.Find("NomaiProbe_Body");
if (nomaiProbe != null) nomaiProbe.gameObject.SetActive(false); if (nomaiProbe != null) nomaiProbe.gameObject.SetActive(false);
} }
@ -221,7 +228,7 @@ namespace NewHorizons
if (_ship != null) if (_ship != null)
{ {
_ship = GameObject.Find("Ship_Body").InstantiateInactive(); _ship = SearchUtilities.Find("Ship_Body").InstantiateInactive();
DontDestroyOnLoad(_ship); DontDestroyOnLoad(_ship);
} }
@ -238,7 +245,7 @@ namespace NewHorizons
// Warp drive // Warp drive
StarChartHandler.Init(SystemDict.Values.ToArray()); StarChartHandler.Init(SystemDict.Values.ToArray());
HasWarpDrive = StarChartHandler.CanWarp(); HasWarpDrive = StarChartHandler.CanWarp();
_shipWarpController = GameObject.Find("Ship_Body").AddComponent<ShipWarpController>(); _shipWarpController = SearchUtilities.Find("Ship_Body").AddComponent<ShipWarpController>();
_shipWarpController.Init(); _shipWarpController.Init();
if (HasWarpDrive == true) EnableWarpDrive(); if (HasWarpDrive == true) EnableWarpDrive();
@ -251,7 +258,7 @@ namespace NewHorizons
if (map != null) map._maxPanDistance = FurthestOrbit * 1.5f; if (map != null) map._maxPanDistance = FurthestOrbit * 1.5f;
// Fix the map satellite // Fix the map satellite
GameObject.Find("HearthianMapSatellite_Body").AddComponent<MapSatelliteOrbitFix>(); SearchUtilities.Find("HearthianMapSatellite_Body", false).AddComponent<MapSatelliteOrbitFix>();
} }
else else
{ {

View File

@ -0,0 +1,63 @@
using HarmonyLib;
namespace NewHorizons.Patches
{
[HarmonyPatch]
public static class HUDPatches
{
[HarmonyPostfix]
[HarmonyPatch(typeof(HUDMarker), nameof(HUDMarker.Awake))]
public static void HUDMarker_Awake(HUDMarker __instance)
{
GlobalMessenger.AddListener("PlayerEnterCloakField", __instance.OnPlayerEnterCloakField);
GlobalMessenger.AddListener("PlayerExitCloakField", __instance.OnPlayerExitCloakField);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(HUDMarker), nameof(HUDMarker.OnDestroy))]
public static void HUDMarker_OnDestroy(HUDMarker __instance)
{
GlobalMessenger.RemoveListener("PlayerEnterCloakField", __instance.OnPlayerEnterCloakField);
GlobalMessenger.RemoveListener("PlayerExitCloakField", __instance.OnPlayerExitCloakField);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(ProbeHUDMarker), nameof(ProbeHUDMarker.Awake))]
public static void ProbeHUDMarker_Awake(ProbeHUDMarker __instance)
{
GlobalMessenger.AddListener("ProbeEnterCloakField", __instance.RefreshOwnVisibility);
GlobalMessenger.AddListener("ProbeExitCloakField", __instance.RefreshOwnVisibility);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(ProbeHUDMarker), nameof(ProbeHUDMarker.OnDestroy))]
public static void ProbeHUDMarker_OnDestroy(ProbeHUDMarker __instance)
{
GlobalMessenger.RemoveListener("ProbeEnterCloakField", __instance.RefreshOwnVisibility);
GlobalMessenger.RemoveListener("ProbeExitCloakField", __instance.RefreshOwnVisibility);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(ShipHUDMarker), nameof(ShipHUDMarker.Awake))]
public static void ShipHUDMarker_Awake(ShipHUDMarker __instance)
{
GlobalMessenger.AddListener("ShipEnterCloakField", __instance.RefreshOwnVisibility);
GlobalMessenger.AddListener("ShipExitCloakField", __instance.RefreshOwnVisibility);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(ShipHUDMarker), nameof(ShipHUDMarker.OnDestroy))]
public static void ShipHUDMarker_OnDestroy(ShipHUDMarker __instance)
{
GlobalMessenger.RemoveListener("ShipEnterCloakField", __instance.RefreshOwnVisibility);
GlobalMessenger.RemoveListener("ShipExitCloakField", __instance.RefreshOwnVisibility);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(ProbeCamera), nameof(ProbeCamera.HasInterference))]
public static void ProbeCamera_HasInterference(ProbeCamera __instance, ref bool __result)
{
__result = __result || Components.CloakSectorController.isPlayerInside != Components.CloakSectorController.isProbeInside;
}
}
}

View File

@ -1,4 +1,4 @@
using HarmonyLib; using HarmonyLib;
namespace NewHorizons.Patches namespace NewHorizons.Patches
{ {
[HarmonyPatch] [HarmonyPatch]
@ -10,5 +10,26 @@ namespace NewHorizons.Patches
{ {
return Locator._cloakFieldController == null; return Locator._cloakFieldController == null;
} }
[HarmonyPostfix]
[HarmonyPatch(typeof(CloakFieldController), nameof(CloakFieldController.isPlayerInsideCloak), MethodType.Getter)]
public static void CloakFieldController_isPlayerInsideCloak(CloakFieldController __instance, ref bool __result)
{
__result = __result || Components.CloakSectorController.isPlayerInside;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(CloakFieldController), nameof(CloakFieldController.isProbeInsideCloak), MethodType.Getter)]
public static void CloakFieldController_isProbeInsideCloak(CloakFieldController __instance, ref bool __result)
{
__result = __result || Components.CloakSectorController.isProbeInside;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(CloakFieldController), nameof(CloakFieldController.isShipInsideCloak), MethodType.Getter)]
public static void CloakFieldController_isShipInsideCloak(CloakFieldController __instance, ref bool __result)
{
__result = __result || Components.CloakSectorController.isShipInside;
}
} }
} }

View File

@ -1,4 +1,4 @@
using HarmonyLib; using HarmonyLib;
using UnityEngine.SceneManagement; using UnityEngine.SceneManagement;
namespace NewHorizons.Patches namespace NewHorizons.Patches
@ -43,5 +43,12 @@ namespace NewHorizons.Patches
return true; return true;
} }
[HarmonyPrefix]
[HarmonyPatch(typeof(ReferenceFrameTracker), nameof(ReferenceFrameTracker.UntargetReferenceFrame), new System.Type[] { typeof(bool) })]
public static bool ReferenceFrameTracker_UntargetReferenceFrame(ReferenceFrameTracker __instance, bool playAudio)
{
return __instance != null && __instance._hasTarget && __instance._currentReferenceFrame != null;
}
} }
} }

View File

@ -1,4 +1,4 @@
using HarmonyLib; using HarmonyLib;
using Logger = NewHorizons.Utility.Logger; using Logger = NewHorizons.Utility.Logger;
namespace NewHorizons.Patches namespace NewHorizons.Patches
{ {

View File

@ -1,4 +1,4 @@
using HarmonyLib; using HarmonyLib;
using NewHorizons.Builder.ShipLog; using NewHorizons.Builder.ShipLog;
using NewHorizons.Components; using NewHorizons.Components;
using NewHorizons.Handlers; using NewHorizons.Handlers;
@ -135,8 +135,8 @@ namespace NewHorizons.Patches
[HarmonyPatch(typeof(ShipLogMapMode), nameof(ShipLogMapMode.Initialize))] [HarmonyPatch(typeof(ShipLogMapMode), nameof(ShipLogMapMode.Initialize))]
public static void ShipLogMapMode_Initialize(ShipLogMapMode __instance) public static void ShipLogMapMode_Initialize(ShipLogMapMode __instance)
{ {
GameObject panRoot = GameObject.Find(ShipLogHandler.PAN_ROOT_PATH); GameObject panRoot = SearchUtilities.Find(ShipLogHandler.PAN_ROOT_PATH);
GameObject sunObject = GameObject.Find(ShipLogHandler.PAN_ROOT_PATH + "/Sun"); GameObject sunObject = SearchUtilities.Find(ShipLogHandler.PAN_ROOT_PATH + "/Sun");
ShipLogAstroObject[][] navMatrix = MapModeBuilder.ConstructMapMode(Main.Instance.CurrentStarSystem, panRoot, __instance._astroObjects, sunObject.layer); ShipLogAstroObject[][] navMatrix = MapModeBuilder.ConstructMapMode(Main.Instance.CurrentStarSystem, panRoot, __instance._astroObjects, sunObject.layer);
if (navMatrix == null || navMatrix.Length <= 1) if (navMatrix == null || navMatrix.Length <= 1)
{ {
@ -151,9 +151,9 @@ namespace NewHorizons.Patches
List<GameObject> delete = SearchUtilities.GetAllChildren(panRoot).Where(g => g.name.Contains("_ShipLog") == false).ToList(); List<GameObject> delete = SearchUtilities.GetAllChildren(panRoot).Where(g => g.name.Contains("_ShipLog") == false).ToList();
foreach (GameObject gameObject in delete) foreach (GameObject gameObject in delete)
{ {
Object.Destroy(GameObject.Find(ShipLogHandler.PAN_ROOT_PATH + "/" + gameObject.name)); Object.Destroy(SearchUtilities.Find(ShipLogHandler.PAN_ROOT_PATH + "/" + gameObject.name));
} }
if (GameObject.Find(ShipLogHandler.PAN_ROOT_PATH + "/" + "SandFunnel") == null) if (SearchUtilities.Find(ShipLogHandler.PAN_ROOT_PATH + "/" + "SandFunnel") == null)
{ {
__instance._sandFunnel = __instance.gameObject.AddComponent<ShipLogSandFunnel>(); __instance._sandFunnel = __instance.gameObject.AddComponent<ShipLogSandFunnel>();
} }

View File

@ -1,4 +1,4 @@
using HarmonyLib; using HarmonyLib;
using UnityEngine; using UnityEngine;
namespace NewHorizons.Patches namespace NewHorizons.Patches
{ {
@ -40,5 +40,26 @@ namespace NewHorizons.Patches
__instance._audioSource.SetLocalVolume(num * num * __instance._fade); __instance._audioSource.SetLocalVolume(num * num * __instance._fade);
return false; return false;
} }
[HarmonyPrefix]
[HarmonyPatch(typeof(SunProxyEffectController), nameof(SunProxyEffectController.UpdateScales))]
public static bool SunProxyEffectController_UpdateScales(SunProxyEffectController __instance)
{
return __instance != null && __instance._surface != null && __instance._fog != null && __instance._fogMaterial != null && __instance._solarFlareEmitter != null && __instance._atmosphere != null;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(SunProxyEffectController), nameof(SunProxyEffectController.UpdateAtmosphereRadii))]
public static bool SunProxyEffectController_UpdateAtmosphereRadii(SunProxyEffectController __instance)
{
return __instance != null && __instance.transform != null && __instance.transform.parent != null && __instance._atmosphereMaterial != null;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(VanishVolume), nameof(VanishVolume.Shrink))]
public static bool VanishVolume_Shrink(VanishVolume __instance, OWRigidbody bodyToShrink)
{
return __instance != null && __instance.transform != null && __instance._shrinkingBodies != null && __instance._shrinkingBodyLocationData != null && bodyToShrink != null;
}
} }
} }

View File

@ -1,5 +1,6 @@
using HarmonyLib; using HarmonyLib;
using NewHorizons.Handlers; using NewHorizons.Handlers;
using NewHorizons.Utility;
using UnityEngine; using UnityEngine;
namespace NewHorizons.Patches namespace NewHorizons.Patches
{ {

View File

@ -30,6 +30,10 @@
"type": "boolean", "type": "boolean",
"description": "Should this planet ever be shown on the title screen?" "description": "Should this planet ever be shown on the title screen?"
}, },
"Cloak": {
"description": "Add a cloaking field to this planet",
"$ref": "#/definitions/CloakModule"
},
"destroy": { "destroy": {
"type": "boolean", "type": "boolean",
"description": "`true` if you want to delete this planet" "description": "`true` if you want to delete this planet"
@ -71,6 +75,10 @@
"description": "Spawn various objects on this body", "description": "Spawn various objects on this body",
"$ref": "#/definitions/PropModule" "$ref": "#/definitions/PropModule"
}, },
"ReferenceFrame": {
"description": "Reference frame properties of this body",
"$ref": "#/definitions/ReferenceFrameModule"
},
"removeChildren": { "removeChildren": {
"type": "array", "type": "array",
"description": "A list of paths to child GameObjects to destroy on this planet", "description": "A list of paths to child GameObjects to destroy on this planet",
@ -289,6 +297,10 @@
"type": "object", "type": "object",
"additionalProperties": false, "additionalProperties": false,
"properties": { "properties": {
"cloudsPrefab": {
"description": "Should these clouds be based on Giant's Deep's banded clouds, or the Quantum Moon's non-banded clouds?",
"$ref": "#/definitions/CloudPrefabType"
},
"capPath": { "capPath": {
"type": "string", "type": "string",
"description": "Relative filepath to the cloud cap texture, if the planet has clouds." "description": "Relative filepath to the cloud cap texture, if the planet has clouds."
@ -333,13 +345,23 @@
"unlit": { "unlit": {
"type": "boolean", "type": "boolean",
"description": "If the top layer shouldn't have shadows. Set to true if you're making a brown dwarf for example." "description": "If the top layer shouldn't have shadows. Set to true if you're making a brown dwarf for example."
},
"useBasicCloudShader": {
"type": "boolean",
"description": "Set to `false` in order to use Giant's Deep's shader. Set to `true` to just apply the cloud texture as is."
} }
} }
}, },
"CloudPrefabType": {
"type": "string",
"description": "",
"x-enumNames": [
"GiantsDeep",
"QuantumMoon",
"Basic"
],
"enum": [
"giantsDeep",
"quantumMoon",
"basic"
]
},
"CloudFluidType": { "CloudFluidType": {
"type": "string", "type": "string",
"description": "", "description": "",
@ -384,11 +406,6 @@
"type": "boolean", "type": "boolean",
"description": "Set this to true if you are replacing the sun with a different body. Only one object in a star system should ever\nhave this set to true." "description": "Set this to true if you are replacing the sun with a different body. Only one object in a star system should ever\nhave this set to true."
}, },
"cloakRadius": {
"type": "number",
"description": "Radius of the cloaking field around the planet. It's a bit finicky so experiment with different values. If you\ndon't want a cloak, leave this as 0.",
"format": "float"
},
"cometTailRotation": { "cometTailRotation": {
"description": "If it has a comet tail, it'll be oriented according to these Euler angles.", "description": "If it has a comet tail, it'll be oriented according to these Euler angles.",
"$ref": "#/definitions/MVector3" "$ref": "#/definitions/MVector3"
@ -410,11 +427,6 @@
"type": "boolean", "type": "boolean",
"description": "If the body should have a marker on the map screen." "description": "If the body should have a marker on the map screen."
}, },
"hasReferenceFrame": {
"type": "boolean",
"description": "Allows the object to be targeted on the map.",
"default": true
},
"invulnerableToSun": { "invulnerableToSun": {
"type": "boolean", "type": "boolean",
"description": "Can this planet survive entering a star?" "description": "Can this planet survive entering a star?"
@ -438,6 +450,11 @@
"type": "number", "type": "number",
"description": "A scale height used for a number of things. Should be the approximate radius of the body.", "description": "A scale height used for a number of things. Should be the approximate radius of the body.",
"format": "float" "format": "float"
},
"zeroGravityRadius": {
"type": "number",
"description": "Radius of the zero gravity volume. This will make it so no gravity from any planet will affect you. Useful for satellites.",
"format": "float"
} }
} }
}, },
@ -471,6 +488,25 @@
"inverseSquared" "inverseSquared"
] ]
}, },
"CloakModule": {
"type": "object",
"additionalProperties": false,
"properties": {
"radius": {
"type": "number",
"description": "Radius of the cloaking field around the planet. It's a bit finicky so experiment with different values. If you\ndon't want a cloak, leave this as 0.",
"format": "float"
},
"audioClip": {
"type": "string",
"description": "Name of an existing AudioClip in the game that will play when entering the cloaking field."
},
"audioFilePath": {
"type": "string",
"description": "Relative filepath to the .wav file to use as the audio. Mutually exclusive with audioClip."
}
}
},
"FocalPointModule": { "FocalPointModule": {
"type": "object", "type": "object",
"additionalProperties": false, "additionalProperties": false,
@ -775,6 +811,10 @@
"type": "object", "type": "object",
"additionalProperties": false, "additionalProperties": false,
"properties": { "properties": {
"rename": {
"type": "string",
"description": "An optional rename of the detail"
},
"alignToNormal": { "alignToNormal": {
"type": "boolean", "type": "boolean",
"description": "Do we override rotation and try to automatically align this object to stand upright on the body's surface?" "description": "Do we override rotation and try to automatically align this object to stand upright on the body's surface?"
@ -1301,6 +1341,32 @@
} }
} }
}, },
"ReferenceFrameModule": {
"type": "object",
"additionalProperties": false,
"properties": {
"hideInMap": {
"type": "boolean",
"description": "Stop the object from being targeted on the map."
},
"bracketRadius": {
"type": "number",
"description": "Radius of the brackets that show up when you target this. Defaults to the sphereOfInfluence.",
"format": "float",
"default": -1
},
"targetWhenClose": {
"type": "boolean",
"description": "If it should be targetable even when super close."
},
"maxTargetDistance": {
"type": "number",
"description": "The maximum distance that the reference frame can be targeted from. Defaults to double the sphereOfInfluence.",
"format": "float",
"default": -1
}
}
},
"RingModule": { "RingModule": {
"type": "object", "type": "object",
"additionalProperties": false, "additionalProperties": false,
@ -1730,6 +1796,13 @@
"tint": { "tint": {
"description": "Colour of the star.", "description": "Colour of the star.",
"$ref": "#/definitions/MColor" "$ref": "#/definitions/MColor"
},
"lightRadius": {
"type": "number",
"description": "How far the light from the star can reach.",
"format": "float",
"default": 50000.0,
"minimum": 0.0
} }
} }
}, },

View File

@ -67,7 +67,7 @@
<xs:element name="IgnoreMoreToExploreCondition" type="xs:string" minOccurs="0"> <xs:element name="IgnoreMoreToExploreCondition" type="xs:string" minOccurs="0">
<xs:annotation> <xs:annotation>
<xs:documentation> <xs:documentation>
Ignore more to explore if a fact is known Ignore more to explore if a persistent condition is `true`
</xs:documentation> </xs:documentation>
</xs:annotation> </xs:annotation>
</xs:element> </xs:element>
@ -202,4 +202,4 @@
</xs:element> </xs:element>
</xs:sequence> </xs:sequence>
</xs:group> </xs:group>
</xs:schema> </xs:schema>

View File

@ -38,6 +38,14 @@
"type": "boolean", "type": "boolean",
"description": "Set to `true` if you want to spawn here after dying, not Timber Hearth. You can still warp back to the main star\nsystem." "description": "Set to `true` if you want to spawn here after dying, not Timber Hearth. You can still warp back to the main star\nsystem."
}, },
"travelAudioClip": {
"type": "string",
"description": "Name of an existing AudioClip in the game that will play when travelling in space."
},
"travelAudioFilePath": {
"type": "string",
"description": "Relative filepath to the .wav file to use as the audio. Mutually exclusive with travelAudioClip."
},
"$schema": { "$schema": {
"type": "string", "type": "string",
"description": "The schema to validate with" "description": "The schema to validate with"

View File

@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using UnityEngine; using UnityEngine;
namespace NewHorizons.Utility namespace NewHorizons.Utility
@ -97,35 +97,35 @@ namespace NewHorizons.Utility
switch (primary._name) switch (primary._name)
{ {
case AstroObject.Name.TowerTwin: case AstroObject.Name.TowerTwin:
otherChildren.Add(GameObject.Find("TimeLoopRing_Body")); otherChildren.Add(SearchUtilities.Find("TimeLoopRing_Body"));
break; break;
case AstroObject.Name.ProbeCannon: case AstroObject.Name.ProbeCannon:
otherChildren.Add(GameObject.Find("NomaiProbe_Body")); otherChildren.Add(SearchUtilities.Find("NomaiProbe_Body"));
otherChildren.Add(GameObject.Find("CannonMuzzle_Body")); otherChildren.Add(SearchUtilities.Find("CannonMuzzle_Body"));
otherChildren.Add(GameObject.Find("FakeCannonMuzzle_Body (1)")); otherChildren.Add(SearchUtilities.Find("FakeCannonMuzzle_Body (1)"));
otherChildren.Add(GameObject.Find("CannonBarrel_Body")); otherChildren.Add(SearchUtilities.Find("CannonBarrel_Body"));
otherChildren.Add(GameObject.Find("FakeCannonBarrel_Body (1)")); otherChildren.Add(SearchUtilities.Find("FakeCannonBarrel_Body (1)"));
otherChildren.Add(GameObject.Find("Debris_Body (1)")); otherChildren.Add(SearchUtilities.Find("Debris_Body (1)"));
break; break;
case AstroObject.Name.GiantsDeep: case AstroObject.Name.GiantsDeep:
otherChildren.Add(GameObject.Find("BrambleIsland_Body")); otherChildren.Add(SearchUtilities.Find("BrambleIsland_Body"));
otherChildren.Add(GameObject.Find("GabbroIsland_Body")); otherChildren.Add(SearchUtilities.Find("GabbroIsland_Body"));
otherChildren.Add(GameObject.Find("QuantumIsland_Body")); otherChildren.Add(SearchUtilities.Find("QuantumIsland_Body"));
otherChildren.Add(GameObject.Find("StatueIsland_Body")); otherChildren.Add(SearchUtilities.Find("StatueIsland_Body"));
otherChildren.Add(GameObject.Find("ConstructionYardIsland_Body")); otherChildren.Add(SearchUtilities.Find("ConstructionYardIsland_Body"));
otherChildren.Add(GameObject.Find("GabbroShip_Body")); otherChildren.Add(SearchUtilities.Find("GabbroShip_Body"));
break; break;
case AstroObject.Name.WhiteHole: case AstroObject.Name.WhiteHole:
otherChildren.Add(GameObject.Find("WhiteholeStation_Body")); otherChildren.Add(SearchUtilities.Find("WhiteholeStation_Body"));
otherChildren.Add(GameObject.Find("WhiteholeStationSuperstructure_Body")); otherChildren.Add(SearchUtilities.Find("WhiteholeStationSuperstructure_Body"));
break; break;
case AstroObject.Name.TimberHearth: case AstroObject.Name.TimberHearth:
otherChildren.Add(GameObject.Find("MiningRig_Body")); otherChildren.Add(SearchUtilities.Find("MiningRig_Body"));
otherChildren.Add(GameObject.Find("Ship_Body")); otherChildren.Add(SearchUtilities.Find("Ship_Body"));
break; break;
case AstroObject.Name.DreamWorld: case AstroObject.Name.DreamWorld:
otherChildren.Add(GameObject.Find("BackRaft_Body")); otherChildren.Add(SearchUtilities.Find("BackRaft_Body"));
otherChildren.Add(GameObject.Find("SealRaft_Body")); otherChildren.Add(SearchUtilities.Find("SealRaft_Body"));
break; break;
// For some dumb reason the sun station doesn't use AstroObject.Name.SunStation // For some dumb reason the sun station doesn't use AstroObject.Name.SunStation
case AstroObject.Name.CustomString: case AstroObject.Name.CustomString:

View File

@ -1,14 +1,14 @@
using UnityEngine; using UnityEngine;
using UnityEngine.InputSystem; using UnityEngine.InputSystem;
namespace NewHorizons.Utility.DebugUtilities namespace NewHorizons.Utility.DebugUtilities
{ {
[RequireComponent(typeof(OWRigidbody))] [RequireComponent(typeof(OWRigidbody))]
public class DebugRaycaster : MonoBehaviour public class DebugRaycaster : MonoBehaviour
{ {
private OWRigidbody _rb; private OWRigidbody _rb;
private GameObject _surfaceSphere; private GameObject _surfaceSphere;
private GameObject _normalSphere1; private GameObject _normalSphere1;
private GameObject _normalSphere2; private GameObject _normalSphere2;
private GameObject _planeUpRightSphere; private GameObject _planeUpRightSphere;
@ -17,43 +17,44 @@ namespace NewHorizons.Utility.DebugUtilities
private GameObject _planeDownLeftSphere; private GameObject _planeDownLeftSphere;
private void Awake() private void Awake()
{ {
_rb = this.GetRequiredComponent<OWRigidbody>(); _rb = this.GetRequiredComponent<OWRigidbody>();
} }
private void Update()
{
if (!Main.Debug) return;
if (Keyboard.current == null) return;
if (Keyboard.current[Key.P].wasReleasedThisFrame)
{
PrintRaycast();
}
}
internal void PrintRaycast()
{
DebugRaycastData data = Raycast();
var posText = $"{{\"x\": {data.pos.x}, \"y\": {data.pos.y}, \"z\": {data.pos.z}}}";
var normText = $"{{\"x\": {data.norm.x}, \"y\": {data.norm.y}, \"z\": {data.norm.z}}}";
if(_surfaceSphere != null) GameObject.Destroy(_surfaceSphere);
private void Update() if(_normalSphere1 != null) GameObject.Destroy(_normalSphere1);
{ if(_normalSphere2 != null) GameObject.Destroy(_normalSphere2);
if (!Main.Debug) return;
if (Keyboard.current == null) return;
if (Keyboard.current[Key.P].wasReleasedThisFrame)
{
PrintRaycast();
}
}
internal void PrintRaycast()
{
DebugRaycastData data = Raycast();
var posText = $"{{\"x\": {data.pos.x}, \"y\": {data.pos.y}, \"z\": {data.pos.z}}}";
var normText = $"{{\"x\": {data.norm.x}, \"y\": {data.norm.y}, \"z\": {data.norm.z}}}";
if(_surfaceSphere != null) GameObject.Destroy(_surfaceSphere);
if(_normalSphere1 != null) GameObject.Destroy(_normalSphere1);
if(_normalSphere2 != null) GameObject.Destroy(_normalSphere2);
if(_planeUpRightSphere != null) GameObject.Destroy(_planeUpRightSphere ); if(_planeUpRightSphere != null) GameObject.Destroy(_planeUpRightSphere );
if(_planeUpLeftSphere != null) GameObject.Destroy(_planeUpLeftSphere ); if(_planeUpLeftSphere != null) GameObject.Destroy(_planeUpLeftSphere );
if(_planeDownLeftSphere != null) GameObject.Destroy(_planeDownLeftSphere ); if(_planeDownLeftSphere != null) GameObject.Destroy(_planeDownLeftSphere );
if(_planeDownRightSphere != null) GameObject.Destroy(_planeDownRightSphere); if(_planeDownRightSphere != null) GameObject.Destroy(_planeDownRightSphere);
_surfaceSphere = AddDebugShape.AddSphere(data.hitBodyGameObject, 0.1f, Color.green); _surfaceSphere = AddDebugShape.AddSphere(data.hitBodyGameObject, 0.1f, Color.green);
_normalSphere1 = AddDebugShape.AddSphere(data.hitBodyGameObject, 0.01f, Color.red); _normalSphere1 = AddDebugShape.AddSphere(data.hitBodyGameObject, 0.01f, Color.red);
_normalSphere2 = AddDebugShape.AddSphere(data.hitBodyGameObject, 0.01f, Color.red); _normalSphere2 = AddDebugShape.AddSphere(data.hitBodyGameObject, 0.01f, Color.red);
_surfaceSphere.transform.localPosition = data.pos; _surfaceSphere.transform.localPosition = data.pos;
_normalSphere1.transform.localPosition = data.pos + data.norm * 0.5f; _normalSphere1.transform.localPosition = data.pos + data.norm * 0.5f;
_normalSphere2.transform.localPosition = data.pos + data.norm; _normalSphere2.transform.localPosition = data.pos + data.norm;
@ -71,35 +72,35 @@ namespace NewHorizons.Utility.DebugUtilities
_planeDownLeftSphere .transform.localPosition = data.plane.origin + data.plane.u*-1*planeSize + data.plane.v*-1*planeSize; _planeDownLeftSphere .transform.localPosition = data.plane.origin + data.plane.u*-1*planeSize + data.plane.v*-1*planeSize;
_planeDownRightSphere.transform.localPosition = data.plane.origin + data.plane.u*1*planeSize + data.plane.v*-1*planeSize; _planeDownRightSphere.transform.localPosition = data.plane.origin + data.plane.u*1*planeSize + data.plane.v*-1*planeSize;
Logger.Log($"Raycast hit \"position\": {posText}, \"normal\": {normText} on [{data.bodyName}] at [{data.bodyPath}]"); Logger.Log($"Raycast hit \"position\": {posText}, \"normal\": {normText} on [{data.bodyName}] at [{data.bodyPath}]");
} }
internal DebugRaycastData Raycast() internal DebugRaycastData Raycast()
{ {
DebugRaycastData data = new DebugRaycastData(); DebugRaycastData data = new DebugRaycastData();
_rb.DisableCollisionDetection(); _rb.DisableCollisionDetection();
int layerMask = OWLayerMask.physicalMask; int layerMask = OWLayerMask.physicalMask;
var origin = Locator.GetActiveCamera().transform.position; var origin = Locator.GetActiveCamera().transform.position;
var direction = Locator.GetActiveCamera().transform.TransformDirection(Vector3.forward); var direction = Locator.GetActiveCamera().transform.TransformDirection(Vector3.forward);
data.hit = Physics.Raycast(origin, direction, out RaycastHit hitInfo, 100f, layerMask); data.hit = Physics.Raycast(origin, direction, out RaycastHit hitInfo, 100f, layerMask);
if (data.hit) if (data.hit)
{ {
data.pos = hitInfo.transform.InverseTransformPoint(hitInfo.point); data.pos = hitInfo.transform.InverseTransformPoint(hitInfo.point);
data.norm = hitInfo.transform.InverseTransformDirection(hitInfo.normal); data.norm = hitInfo.transform.InverseTransformDirection(hitInfo.normal);
var o = hitInfo.transform.gameObject; var o = hitInfo.transform.gameObject;
var hitAstroObject = o.GetComponent<AstroObject>() ?? o.GetComponentInParent<AstroObject>(); var hitAstroObject = o.GetComponent<AstroObject>() ?? o.GetComponentInParent<AstroObject>();
data.bodyName = o.name; data.bodyName = o.name;
data.bodyPath = SearchUtilities.GetPath(o.transform); data.bodyPath = SearchUtilities.GetPath(o.transform);
data.hitObject = o; data.hitObject = o;
data.hitBodyGameObject = hitAstroObject?.gameObject; data.hitBodyGameObject = hitAstroObject?.gameObject;
data.plane = ConstructPlane(data); data.plane = ConstructPlane(data);
} }
_rb.EnableCollisionDetection(); _rb.EnableCollisionDetection();
return data; return data;
} }
@ -132,5 +133,5 @@ namespace NewHorizons.Utility.DebugUtilities
}; };
return p; return p;
} }
} }
} }

View File

@ -1,4 +1,4 @@
using NewHorizons.Handlers; using NewHorizons.Handlers;
using OWML.Common; using OWML.Common;
using OWML.Common.Menus; using OWML.Common.Menus;
using System; using System;
@ -45,7 +45,7 @@ namespace NewHorizons.Utility.DebugUtilities
Logger.LogWarning("Error While Reloading"); Logger.LogWarning("Error While Reloading");
} }
GameObject.Find("/PauseMenu/PauseMenuManagers").GetComponent<PauseMenuManager>().OnSkipToNextTimeLoop(); SearchUtilities.Find("/PauseMenu/PauseMenuManagers").GetComponent<PauseMenuManager>().OnSkipToNextTimeLoop();
Main.Instance.ChangeCurrentStarSystem(Main.Instance.CurrentStarSystem); Main.Instance.ChangeCurrentStarSystem(Main.Instance.CurrentStarSystem);

View File

@ -129,7 +129,7 @@ namespace NewHorizons.Utility
return null; return null;
} }
public static GameObject Find(string path) public static GameObject Find(string path, bool warn = true)
{ {
if (CachedGameObjects.ContainsKey(path)) if (CachedGameObjects.ContainsKey(path))
{ {
@ -150,7 +150,7 @@ namespace NewHorizons.Utility
var t = root?.transform; var t = root?.transform;
if (t == null) if (t == null)
{ {
Logger.LogWarning($"Couldn't find root object in path ({names[0]})"); if (warn) Logger.LogWarning($"Couldn't find root object in path ({names[0]})");
} }
else else
{ {
@ -162,7 +162,7 @@ namespace NewHorizons.Utility
{ {
foreach (Transform c in t.GetComponentsInChildren<Transform>(true)) foreach (Transform c in t.GetComponentsInChildren<Transform>(true))
{ {
if (t.name.Equals(names[i])) if (c.name.Equals(names[i]))
{ {
child = c; child = c;
break; break;
@ -172,7 +172,7 @@ namespace NewHorizons.Utility
if (child == null) if (child == null)
{ {
Logger.LogWarning($"Couldn't find object in path ({names[i]})"); if (warn) Logger.LogWarning($"Couldn't find object in path ({names[i]})");
t = null; t = null;
break; break;
} }
@ -187,7 +187,7 @@ namespace NewHorizons.Utility
if (go == null) if (go == null)
{ {
var name = names.Last(); var name = names.Last();
Logger.LogWarning($"Couldn't find object {path}, will look for potential matches for name {name}"); if (warn) Logger.LogWarning($"Couldn't find object {path}, will look for potential matches for name {name}");
go = FindObjectOfTypeAndName<GameObject>(name); go = FindObjectOfTypeAndName<GameObject>(name);
} }

View File

@ -3,7 +3,7 @@
"author": "xen, Bwc9876, & Book", "author": "xen, Bwc9876, & Book",
"name": "New Horizons", "name": "New Horizons",
"uniqueName": "xen.NewHorizons", "uniqueName": "xen.NewHorizons",
"version": "1.2.2", "version": "1.2.4",
"owmlVersion": "2.3.3", "owmlVersion": "2.3.3",
"conflicts": [ "Raicuparta.QuantumSpaceBuddies", "Vesper.AutoResume", "PacificEngine.OW_Randomizer" ], "conflicts": [ "Raicuparta.QuantumSpaceBuddies", "Vesper.AutoResume", "PacificEngine.OW_Randomizer" ],
"pathsToPreserve": [ "planets", "systems", "translations" ] "pathsToPreserve": [ "planets", "systems", "translations" ]

View File

@ -69,7 +69,7 @@ New Horizons was made with help from:
- And the Outer Wilds modding server. - And the Outer Wilds modding server.
Translation credits: Translation credits:
- Russian: GrayFix and Tlya - Russian: Tlya
- German: Nolram - German: Nolram
- Spanish: Ciborgm9 and Ink - Spanish: Ciborgm9 and Ink