mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
commit
a61d4043ea
@ -1,21 +1,22 @@
|
||||
using OWML.Utils;
|
||||
using NewHorizons.External;
|
||||
using OWML.Utils;
|
||||
using UnityEngine;
|
||||
using Logger = NewHorizons.Utility.Logger;
|
||||
|
||||
namespace NewHorizons.Builder.Atmosphere
|
||||
{
|
||||
static class AirBuilder
|
||||
public static class AirBuilder
|
||||
{
|
||||
public static void Make(GameObject body, float airScale, bool isRaining, bool hasOxygen)
|
||||
public static void Make(GameObject body, Sector sector, AtmosphereModule.AirInfo info)
|
||||
{
|
||||
GameObject airGO = new GameObject("Air");
|
||||
airGO.SetActive(false);
|
||||
airGO.layer = 17;
|
||||
airGO.transform.parent = body.transform;
|
||||
airGO.transform.parent = sector?.transform ?? body.transform;
|
||||
|
||||
SphereCollider SC = airGO.AddComponent<SphereCollider>();
|
||||
SC.isTrigger = true;
|
||||
SC.radius = airScale;
|
||||
SC.radius = info.Scale;
|
||||
|
||||
SimpleFluidVolume SFV = airGO.AddComponent<SimpleFluidVolume>();
|
||||
SFV._layer = 5;
|
||||
@ -25,12 +26,12 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
SFV._allowShipAutoroll = true;
|
||||
SFV._disableOnStart = false;
|
||||
|
||||
if(hasOxygen)
|
||||
if(info.HasOxygen)
|
||||
{
|
||||
airGO.AddComponent<OxygenVolume>();
|
||||
}
|
||||
|
||||
if (isRaining)
|
||||
if (info.IsRaining)
|
||||
{
|
||||
VisorRainEffectVolume VREF = airGO.AddComponent<VisorRainEffectVolume>();
|
||||
VREF._rainDirection = VisorRainEffectVolume.RainDirection.Radial;
|
||||
|
||||
@ -4,13 +4,13 @@ using Logger = NewHorizons.Utility.Logger;
|
||||
|
||||
namespace NewHorizons.Builder.Atmosphere
|
||||
{
|
||||
static class AtmosphereBuilder
|
||||
public static class AtmosphereBuilder
|
||||
{
|
||||
public static void Make(GameObject body, AtmosphereModule atmosphereModule, float surfaceSize)
|
||||
public static void Make(GameObject body, Sector sector, AtmosphereModule atmosphereModule, float surfaceSize)
|
||||
{
|
||||
GameObject atmoGO = new GameObject("Atmosphere");
|
||||
atmoGO.SetActive(false);
|
||||
atmoGO.transform.parent = body.transform;
|
||||
atmoGO.transform.parent = sector?.transform ?? body.transform;
|
||||
|
||||
if (atmosphereModule.HasAtmosphere)
|
||||
{
|
||||
|
||||
@ -8,7 +8,7 @@ using Logger = NewHorizons.Utility.Logger;
|
||||
|
||||
namespace NewHorizons.Builder.Atmosphere
|
||||
{
|
||||
static class CloudsBuilder
|
||||
public static class CloudsBuilder
|
||||
{
|
||||
private static Shader _sphereShader = null;
|
||||
public static void Make(GameObject body, Sector sector, AtmosphereModule atmo, IModBehaviour mod)
|
||||
@ -34,7 +34,7 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
|
||||
GameObject cloudsMainGO = new GameObject("Clouds");
|
||||
cloudsMainGO.SetActive(false);
|
||||
cloudsMainGO.transform.parent = body.transform;
|
||||
cloudsMainGO.transform.parent = sector?.transform ?? body.transform;
|
||||
|
||||
GameObject cloudsTopGO = new GameObject("TopClouds");
|
||||
cloudsTopGO.SetActive(false);
|
||||
|
||||
@ -1,17 +1,18 @@
|
||||
using NewHorizons.Utility;
|
||||
using NewHorizons.External;
|
||||
using NewHorizons.Utility;
|
||||
using OWML.Utils;
|
||||
using UnityEngine;
|
||||
using Logger = NewHorizons.Utility.Logger;
|
||||
|
||||
namespace NewHorizons.Builder.Atmosphere
|
||||
{
|
||||
static class EffectsBuilder
|
||||
public static class EffectsBuilder
|
||||
{
|
||||
public static void Make(GameObject body, Sector sector, float surfaceSize, float atmoSize, bool hasRain, bool hasSnow)
|
||||
public static void Make(GameObject body, Sector sector, AtmosphereModule.AirInfo info, float surfaceSize)
|
||||
{
|
||||
GameObject effectsGO = new GameObject("Effects");
|
||||
effectsGO.SetActive(false);
|
||||
effectsGO.transform.parent = body.transform;
|
||||
effectsGO.transform.parent = sector?.transform ?? body.transform;
|
||||
effectsGO.transform.localPosition = Vector3.zero;
|
||||
|
||||
SectorCullGroup SCG = effectsGO.AddComponent<SectorCullGroup>();
|
||||
@ -21,7 +22,7 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
SCG._dynamicCullingBounds = false;
|
||||
SCG._waitForStreaming = false;
|
||||
|
||||
if(hasRain)
|
||||
if(info.IsRaining)
|
||||
{
|
||||
var rainGO = GameObject.Instantiate(SearchUtilities.CachedFind("/GiantsDeep_Body/Sector_GD/Sector_GDInterior/Effects_GDInterior/Effects_GD_Rain"), effectsGO.transform);
|
||||
rainGO.transform.localPosition = Vector3.zero;
|
||||
@ -31,7 +32,7 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
{
|
||||
new Keyframe(surfaceSize - 0.5f, 0),
|
||||
new Keyframe(surfaceSize, 10f),
|
||||
new Keyframe(atmoSize, 0f)
|
||||
new Keyframe(info.Scale, 0f)
|
||||
});
|
||||
|
||||
rainGO.GetComponent<PlanetaryVectionController>()._activeInSector = sector;
|
||||
@ -39,7 +40,7 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
rainGO.SetActive(true);
|
||||
}
|
||||
|
||||
if(hasSnow)
|
||||
if(info.IsSnowing)
|
||||
{
|
||||
var snowGO = new GameObject("SnowEffects");
|
||||
snowGO.transform.parent = effectsGO.transform;
|
||||
@ -55,7 +56,7 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
{
|
||||
new Keyframe(surfaceSize - 0.5f, 0),
|
||||
new Keyframe(surfaceSize, 10f),
|
||||
new Keyframe(atmoSize, 0f)
|
||||
new Keyframe(info.Scale, 0f)
|
||||
});
|
||||
|
||||
snowEmitter.GetComponent<PlanetaryVectionController>()._activeInSector = sector;
|
||||
|
||||
@ -10,13 +10,13 @@ using Logger = NewHorizons.Utility.Logger;
|
||||
|
||||
namespace NewHorizons.Builder.Atmosphere
|
||||
{
|
||||
static class FogBuilder
|
||||
public static class FogBuilder
|
||||
{
|
||||
public static void Make(GameObject body, Sector sector, AtmosphereModule atmo)
|
||||
{
|
||||
GameObject fogGO = new GameObject("FogSphere");
|
||||
fogGO.SetActive(false);
|
||||
fogGO.transform.parent = body.transform;
|
||||
fogGO.transform.parent = sector?.transform ?? body.transform;
|
||||
fogGO.transform.localScale = Vector3.one;
|
||||
|
||||
// Going to copy from dark bramble
|
||||
|
||||
@ -5,13 +5,13 @@ using Logger = NewHorizons.Utility.Logger;
|
||||
|
||||
namespace NewHorizons.Builder.Atmosphere
|
||||
{
|
||||
static class SunOverrideBuilder
|
||||
public static class SunOverrideBuilder
|
||||
{
|
||||
public static void Make(GameObject body, Sector sector, float surfaceSize, AtmosphereModule atmo)
|
||||
public static void Make(GameObject body, Sector sector, AtmosphereModule atmo, float surfaceSize)
|
||||
{
|
||||
GameObject overrideGO = new GameObject("SunOverride");
|
||||
overrideGO.SetActive(false);
|
||||
overrideGO.transform.parent = body.transform;
|
||||
overrideGO.transform.parent = sector?.transform ?? body.transform;
|
||||
|
||||
GiantsDeepSunOverrideVolume GDSOV = overrideGO.AddComponent<GiantsDeepSunOverrideVolume>();
|
||||
GDSOV._sector = sector;
|
||||
|
||||
@ -6,9 +6,9 @@ using Logger = NewHorizons.Utility.Logger;
|
||||
|
||||
namespace NewHorizons.Builder.Atmosphere
|
||||
{
|
||||
static class VolumesBuilder
|
||||
public static class VolumesBuilder
|
||||
{
|
||||
public static void Make(GameObject body, float innerRadius, float outerRadius, IPlanetConfig config)
|
||||
public static void Make(GameObject body, float innerRadius, float outerRadius, bool useMiniMap)
|
||||
{
|
||||
GameObject volumesGO = new GameObject("Volumes");
|
||||
volumesGO.SetActive(false);
|
||||
@ -30,8 +30,8 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
PlanetoidRuleset PR = rulesetGO.AddComponent<PlanetoidRuleset>();
|
||||
PR._altitudeFloor = innerRadius;
|
||||
PR._altitudeCeiling = outerRadius;
|
||||
PR._useMinimap = !config.Base.IsSatellite;
|
||||
PR._useAltimeter = !config.Base.IsSatellite;
|
||||
PR._useMinimap = useMiniMap;
|
||||
PR._useAltimeter = useMiniMap;
|
||||
|
||||
EffectRuleset ER = rulesetGO.AddComponent<EffectRuleset>();
|
||||
ER._type = EffectRuleset.BubbleType.Underwater;
|
||||
|
||||
@ -14,7 +14,7 @@ using NewHorizons.Handlers;
|
||||
|
||||
namespace NewHorizons.Builder.Body
|
||||
{
|
||||
static class AsteroidBeltBuilder
|
||||
public static class AsteroidBeltBuilder
|
||||
{
|
||||
public static void Make(string bodyName, IPlanetConfig parentConfig, IModBehaviour mod)
|
||||
{
|
||||
|
||||
@ -9,7 +9,7 @@ using UnityEngine;
|
||||
|
||||
namespace NewHorizons.Builder.Body
|
||||
{
|
||||
static class CloakBuilder
|
||||
public static class CloakBuilder
|
||||
{
|
||||
public static void Make(GameObject body, Sector sector, float radius)
|
||||
{
|
||||
|
||||
@ -12,9 +12,9 @@ namespace NewHorizons.Builder.Body
|
||||
{
|
||||
public static class CometTailBuilder
|
||||
{
|
||||
public static void Make(GameObject go, IPlanetConfig config, AstroObject primary)
|
||||
public static void Make(GameObject go, Sector sector, IPlanetConfig config, AstroObject primary)
|
||||
{
|
||||
var cometTail = GameObject.Instantiate(GameObject.Find("Comet_Body/Sector_CO/Effects_CO/Effects_CO_TailMeshes"), go.transform);
|
||||
var cometTail = GameObject.Instantiate(GameObject.Find("Comet_Body/Sector_CO/Effects_CO/Effects_CO_TailMeshes"), sector?.transform ?? go.transform);
|
||||
cometTail.transform.localPosition = Vector3.zero;
|
||||
cometTail.name = "CometTail";
|
||||
cometTail.transform.localScale = Vector3.one * config.Base.SurfaceSize / 110;
|
||||
|
||||
@ -8,7 +8,7 @@ using Random = UnityEngine.Random;
|
||||
|
||||
namespace NewHorizons.Builder.Body.Geometry
|
||||
{
|
||||
static class Icosphere
|
||||
public static class Icosphere
|
||||
{
|
||||
private static readonly float t = (1f + Mathf.Sqrt(5f)) / 2f;
|
||||
// By subdivisions, will add to this to memoize computation of icospheres
|
||||
|
||||
@ -3,12 +3,12 @@ using Logger = NewHorizons.Utility.Logger;
|
||||
|
||||
namespace NewHorizons.Builder.Body
|
||||
{
|
||||
static class GeometryBuilder
|
||||
public static class GeometryBuilder
|
||||
{
|
||||
public static void Make(GameObject body, float groundScale)
|
||||
public static void Make(GameObject body, Sector sector, float groundScale)
|
||||
{
|
||||
GameObject groundGO = GameObject.CreatePrimitive(PrimitiveType.Sphere);
|
||||
groundGO.transform.parent = body.transform;
|
||||
groundGO.transform.parent = sector?.transform ?? body.transform;
|
||||
groundGO.transform.localScale = new Vector3(groundScale, groundScale, groundScale);
|
||||
groundGO.transform.localPosition = Vector3.zero;
|
||||
groundGO.GetComponent<MeshFilter>().mesh = GameObject.Find("CloudsTopLayer_GD").GetComponent<MeshFilter>().mesh;
|
||||
|
||||
@ -13,11 +13,11 @@ using Logger = NewHorizons.Utility.Logger;
|
||||
|
||||
namespace NewHorizons.Builder.Body
|
||||
{
|
||||
static class HeightMapBuilder
|
||||
public static class HeightMapBuilder
|
||||
{
|
||||
public static Shader PlanetShader;
|
||||
|
||||
public static void Make(GameObject go, HeightMapModule module, IModBehaviour mod)
|
||||
public static void Make(GameObject go, Sector sector, HeightMapModule module, IModBehaviour mod)
|
||||
{
|
||||
Texture2D heightMap, textureMap;
|
||||
try
|
||||
@ -35,7 +35,7 @@ namespace NewHorizons.Builder.Body
|
||||
|
||||
GameObject cubeSphere = new GameObject("CubeSphere");
|
||||
cubeSphere.SetActive(false);
|
||||
cubeSphere.transform.parent = go.transform;
|
||||
cubeSphere.transform.parent = sector?.transform ?? go.transform;
|
||||
cubeSphere.transform.rotation = Quaternion.Euler(90, 0, 0);
|
||||
|
||||
Mesh mesh = CubeSphere.Build(51, heightMap, module.MinHeight, module.MaxHeight, module.Stretch);
|
||||
|
||||
@ -10,9 +10,9 @@ using Logger = NewHorizons.Utility.Logger;
|
||||
|
||||
namespace NewHorizons.Builder.Body
|
||||
{
|
||||
static class LavaBuilder
|
||||
public static class LavaBuilder
|
||||
{
|
||||
public static void Make(GameObject body, Sector sector, OWRigidbody rb, LavaModule module)
|
||||
public static void Make(GameObject go, Sector sector, OWRigidbody rb, LavaModule module)
|
||||
{
|
||||
var heightScale = module.Size;
|
||||
if(module.Curve != null)
|
||||
@ -27,7 +27,7 @@ namespace NewHorizons.Builder.Body
|
||||
|
||||
var moltenCore = new GameObject("MoltenCore");
|
||||
moltenCore.SetActive(false);
|
||||
moltenCore.transform.parent = body.transform;
|
||||
moltenCore.transform.parent = sector?.transform ?? go.transform;
|
||||
moltenCore.transform.localPosition = Vector3.zero;
|
||||
moltenCore.transform.localScale = Vector3.one * module.Size;
|
||||
|
||||
|
||||
@ -9,12 +9,12 @@ using UnityEngine;
|
||||
|
||||
namespace NewHorizons.Builder.Body
|
||||
{
|
||||
static class ProcGenBuilder
|
||||
public static class ProcGenBuilder
|
||||
{
|
||||
public static void Make(GameObject go, ProcGenModule module)
|
||||
public static void Make(GameObject go, Sector sector, ProcGenModule module)
|
||||
{
|
||||
GameObject icosphere = new GameObject("Icosphere");
|
||||
icosphere.transform.parent = go.transform;
|
||||
icosphere.transform.parent = sector?.transform ?? go.transform;
|
||||
icosphere.transform.rotation = Quaternion.Euler(90, 0, 0);
|
||||
icosphere.transform.localPosition = Vector3.zero;
|
||||
|
||||
|
||||
@ -14,242 +14,242 @@ using NewHorizons.Components.SizeControllers;
|
||||
|
||||
namespace NewHorizons.Builder.Body
|
||||
{
|
||||
static class RingBuilder
|
||||
public static class RingBuilder
|
||||
{
|
||||
public static Shader RingShader;
|
||||
public static Shader RingShader1Pixel;
|
||||
public static Shader UnlitRingShader;
|
||||
public static Shader UnlitRingShader1Pixel;
|
||||
public static Shader RingShader;
|
||||
public static Shader RingShader1Pixel;
|
||||
public static Shader UnlitRingShader;
|
||||
public static Shader UnlitRingShader1Pixel;
|
||||
|
||||
public static GameObject Make(GameObject body, RingModule ring, IModBehaviour mod)
|
||||
public static GameObject Make(GameObject body, Sector sector, RingModule ring, IModBehaviour mod)
|
||||
{
|
||||
// Properly lit shader doesnt work yet
|
||||
ring.Unlit = true;
|
||||
// Properly lit shader doesnt work yet
|
||||
ring.Unlit = true;
|
||||
|
||||
Texture2D ringTexture;
|
||||
try
|
||||
{
|
||||
ringTexture = ImageUtilities.GetTexture(mod, ring.Texture);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError($"Couldn't load Ring texture, {e.Message}, {e.StackTrace}");
|
||||
return null;
|
||||
}
|
||||
Texture2D ringTexture;
|
||||
try
|
||||
{
|
||||
ringTexture = ImageUtilities.GetTexture(mod, ring.Texture);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError($"Couldn't load Ring texture, {e.Message}, {e.StackTrace}");
|
||||
return null;
|
||||
}
|
||||
|
||||
var ringGO = new GameObject("Ring");
|
||||
ringGO.transform.parent = body.transform;
|
||||
ringGO.transform.localPosition = Vector3.zero;
|
||||
ringGO.transform.localRotation = Quaternion.Euler(0, 0, 0);
|
||||
ringGO.transform.Rotate(ringGO.transform.TransformDirection(Vector3.up), ring.LongitudeOfAscendingNode);
|
||||
ringGO.transform.Rotate(ringGO.transform.TransformDirection(Vector3.right), ring.Inclination);
|
||||
var ringGO = new GameObject("Ring");
|
||||
ringGO.transform.parent = sector?.transform ?? body.transform;
|
||||
ringGO.transform.localPosition = Vector3.zero;
|
||||
ringGO.transform.localRotation = Quaternion.Euler(0, 0, 0);
|
||||
ringGO.transform.Rotate(ringGO.transform.TransformDirection(Vector3.up), ring.LongitudeOfAscendingNode);
|
||||
ringGO.transform.Rotate(ringGO.transform.TransformDirection(Vector3.right), ring.Inclination);
|
||||
|
||||
var ringMF = ringGO.AddComponent<MeshFilter>();
|
||||
var ringMesh = ringMF.mesh;
|
||||
var ringMR = ringGO.AddComponent<MeshRenderer>();
|
||||
var texture = ringTexture;
|
||||
var texture = ringTexture;
|
||||
|
||||
if (RingShader == null) RingShader = Main.ShaderBundle.LoadAsset<Shader>("Assets/Shaders/Ring.shader");
|
||||
if (UnlitRingShader == null) UnlitRingShader = Main.ShaderBundle.LoadAsset<Shader>("Assets/Shaders/UnlitTransparent.shader");
|
||||
if (RingShader1Pixel == null) RingShader1Pixel = Main.ShaderBundle.LoadAsset<Shader>("Assets/Shaders/Ring1Pixel.shader");
|
||||
if (UnlitRingShader1Pixel == null) UnlitRingShader1Pixel = Main.ShaderBundle.LoadAsset<Shader>("Assets/Shaders/UnlitRing1Pixel.shader");
|
||||
if (RingShader == null) RingShader = Main.ShaderBundle.LoadAsset<Shader>("Assets/Shaders/Ring.shader");
|
||||
if (UnlitRingShader == null) UnlitRingShader = Main.ShaderBundle.LoadAsset<Shader>("Assets/Shaders/UnlitTransparent.shader");
|
||||
if (RingShader1Pixel == null) RingShader1Pixel = Main.ShaderBundle.LoadAsset<Shader>("Assets/Shaders/Ring1Pixel.shader");
|
||||
if (UnlitRingShader1Pixel == null) UnlitRingShader1Pixel = Main.ShaderBundle.LoadAsset<Shader>("Assets/Shaders/UnlitRing1Pixel.shader");
|
||||
|
||||
var mat = new Material(ring.Unlit ? UnlitRingShader : RingShader);
|
||||
if(texture.width == 1)
|
||||
var mat = new Material(ring.Unlit ? UnlitRingShader : RingShader);
|
||||
if (texture.width == 1)
|
||||
{
|
||||
mat = new Material(ring.Unlit ? UnlitRingShader1Pixel : RingShader1Pixel);
|
||||
mat.SetFloat("_InnerRadius", 0);
|
||||
mat = new Material(ring.Unlit ? UnlitRingShader1Pixel : RingShader1Pixel);
|
||||
mat.SetFloat("_InnerRadius", 0);
|
||||
}
|
||||
ringMR.receiveShadows = !ring.Unlit;
|
||||
ringMR.receiveShadows = !ring.Unlit;
|
||||
|
||||
mat.mainTexture = texture;
|
||||
mat.renderQueue = 3000;
|
||||
ringMR.material = mat;
|
||||
mat.mainTexture = texture;
|
||||
mat.renderQueue = 3000;
|
||||
ringMR.material = mat;
|
||||
|
||||
// Make mesh
|
||||
var segments = (int)Mathf.Clamp(ring.OuterRadius, 20, 2000);
|
||||
BuildRingMesh(ringMesh, segments, ring.InnerRadius, ring.OuterRadius);
|
||||
// Make mesh
|
||||
var segments = (int)Mathf.Clamp(ring.OuterRadius, 20, 2000);
|
||||
BuildRingMesh(ringMesh, segments, ring.InnerRadius, ring.OuterRadius);
|
||||
|
||||
if(ring.RotationSpeed != 0)
|
||||
if (ring.RotationSpeed != 0)
|
||||
{
|
||||
var rot = ringGO.AddComponent<RotateTransform>();
|
||||
rot._degreesPerSecond = ring.RotationSpeed;
|
||||
rot._localAxis = Vector3.down;
|
||||
var rot = ringGO.AddComponent<RotateTransform>();
|
||||
rot._degreesPerSecond = ring.RotationSpeed;
|
||||
rot._localAxis = Vector3.down;
|
||||
}
|
||||
|
||||
// Funny collider thing
|
||||
var ringVolume = new GameObject("RingVolume");
|
||||
ringVolume.SetActive(false);
|
||||
ringVolume.transform.parent = ringGO.transform;
|
||||
ringVolume.transform.localPosition = Vector3.zero;
|
||||
ringVolume.transform.localScale = Vector3.one;
|
||||
ringVolume.transform.localRotation = Quaternion.identity;
|
||||
ringVolume.layer = LayerMask.NameToLayer("BasicEffectVolume");
|
||||
// Funny collider thing
|
||||
var ringVolume = new GameObject("RingVolume");
|
||||
ringVolume.SetActive(false);
|
||||
ringVolume.transform.parent = ringGO.transform;
|
||||
ringVolume.transform.localPosition = Vector3.zero;
|
||||
ringVolume.transform.localScale = Vector3.one;
|
||||
ringVolume.transform.localRotation = Quaternion.identity;
|
||||
ringVolume.layer = LayerMask.NameToLayer("BasicEffectVolume");
|
||||
|
||||
var ringShape = ringVolume.AddComponent<RingShape>();
|
||||
ringShape.innerRadius = ring.InnerRadius;
|
||||
ringShape.outerRadius = ring.OuterRadius;
|
||||
ringShape.height = 2f;
|
||||
ringShape.center = Vector3.zero;
|
||||
ringShape.SetCollisionMode(Shape.CollisionMode.Volume);
|
||||
ringShape.SetLayer(Shape.Layer.Default);
|
||||
ringShape.layerMask = -1;
|
||||
ringShape.pointChecksOnly = true;
|
||||
|
||||
var trigger = ringVolume.AddComponent<OWTriggerVolume>();
|
||||
trigger._shape = ringShape;
|
||||
var ringShape = ringVolume.AddComponent<RingShape>();
|
||||
ringShape.innerRadius = ring.InnerRadius;
|
||||
ringShape.outerRadius = ring.OuterRadius;
|
||||
ringShape.height = 2f;
|
||||
ringShape.center = Vector3.zero;
|
||||
ringShape.SetCollisionMode(Shape.CollisionMode.Volume);
|
||||
ringShape.SetLayer(Shape.Layer.Default);
|
||||
ringShape.layerMask = -1;
|
||||
ringShape.pointChecksOnly = true;
|
||||
|
||||
var sfv = ringVolume.AddComponent<SimpleFluidVolume>();
|
||||
var fluidType = FluidVolume.Type.NONE;
|
||||
var trigger = ringVolume.AddComponent<OWTriggerVolume>();
|
||||
trigger._shape = ringShape;
|
||||
|
||||
if(!string.IsNullOrEmpty(ring.FluidType))
|
||||
var sfv = ringVolume.AddComponent<SimpleFluidVolume>();
|
||||
var fluidType = FluidVolume.Type.NONE;
|
||||
|
||||
if (!string.IsNullOrEmpty(ring.FluidType))
|
||||
{
|
||||
try
|
||||
{
|
||||
fluidType = (FluidVolume.Type)Enum.Parse(typeof(FluidVolume.Type), ring.FluidType.ToUpper());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError($"Couldn't parse fluid volume type [{ring.FluidType}]: {ex.Message}, {ex.StackTrace}");
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
fluidType = (FluidVolume.Type)Enum.Parse(typeof(FluidVolume.Type), ring.FluidType.ToUpper());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError($"Couldn't parse fluid volume type [{ring.FluidType}]: {ex.Message}, {ex.StackTrace}");
|
||||
}
|
||||
}
|
||||
|
||||
sfv._fluidType = fluidType;
|
||||
sfv._density = 1f;
|
||||
sfv._fluidType = fluidType;
|
||||
sfv._density = 1f;
|
||||
|
||||
ringVolume.SetActive(true);
|
||||
ringVolume.SetActive(true);
|
||||
|
||||
if (ring.Curve != null)
|
||||
{
|
||||
var levelController = ringGO.AddComponent<SizeController>();
|
||||
var curve = new AnimationCurve();
|
||||
foreach (var pair in ring.Curve)
|
||||
{
|
||||
curve.AddKey(new Keyframe(pair.Time, pair.Value));
|
||||
}
|
||||
levelController.scaleCurve = curve;
|
||||
}
|
||||
if (ring.Curve != null)
|
||||
{
|
||||
var levelController = ringGO.AddComponent<SizeController>();
|
||||
var curve = new AnimationCurve();
|
||||
foreach (var pair in ring.Curve)
|
||||
{
|
||||
curve.AddKey(new Keyframe(pair.Time, pair.Value));
|
||||
}
|
||||
levelController.scaleCurve = curve;
|
||||
}
|
||||
|
||||
return ringGO;
|
||||
}
|
||||
return ringGO;
|
||||
}
|
||||
|
||||
public static void BuildQuadMesh(Mesh mesh, float width)
|
||||
public static void BuildQuadMesh(Mesh mesh, float width)
|
||||
{
|
||||
Vector3[] vertices;
|
||||
int[] tri;
|
||||
Vector3[] normals;
|
||||
Vector2[] uv;
|
||||
Vector3[] vertices;
|
||||
int[] tri;
|
||||
Vector3[] normals;
|
||||
Vector2[] uv;
|
||||
|
||||
vertices = new Vector3[4];
|
||||
tri = new int[6];
|
||||
normals = new Vector3[4];
|
||||
uv = new Vector2[4];
|
||||
vertices = new Vector3[4];
|
||||
tri = new int[6];
|
||||
normals = new Vector3[4];
|
||||
uv = new Vector2[4];
|
||||
|
||||
vertices[0] = new Vector3(-width / 2, 0, -width / 2);
|
||||
vertices[1] = new Vector3(width / 2, 0, -width / 2);
|
||||
vertices[2] = new Vector3(-width / 2, 0, width / 2);
|
||||
vertices[3] = new Vector3(width / 2, 0, width / 2);
|
||||
vertices[0] = new Vector3(-width / 2, 0, -width / 2);
|
||||
vertices[1] = new Vector3(width / 2, 0, -width / 2);
|
||||
vertices[2] = new Vector3(-width / 2, 0, width / 2);
|
||||
vertices[3] = new Vector3(width / 2, 0, width / 2);
|
||||
|
||||
tri[0] = 0;
|
||||
tri[1] = 2;
|
||||
tri[2] = 1;
|
||||
tri[0] = 0;
|
||||
tri[1] = 2;
|
||||
tri[2] = 1;
|
||||
|
||||
tri[3] = 2;
|
||||
tri[4] = 3;
|
||||
tri[5] = 1;
|
||||
tri[3] = 2;
|
||||
tri[4] = 3;
|
||||
tri[5] = 1;
|
||||
|
||||
normals[0] = Vector3.up;
|
||||
normals[1] = Vector3.up;
|
||||
normals[2] = Vector3.up;
|
||||
normals[3] = Vector3.up;
|
||||
normals[0] = Vector3.up;
|
||||
normals[1] = Vector3.up;
|
||||
normals[2] = Vector3.up;
|
||||
normals[3] = Vector3.up;
|
||||
|
||||
uv[0] = new Vector2(0, 0);
|
||||
uv[1] = new Vector2(1, 0);
|
||||
uv[2] = new Vector2(0, 1);
|
||||
uv[3] = new Vector2(1, 1);
|
||||
uv[0] = new Vector2(0, 0);
|
||||
uv[1] = new Vector2(1, 0);
|
||||
uv[2] = new Vector2(0, 1);
|
||||
uv[3] = new Vector2(1, 1);
|
||||
|
||||
mesh.vertices = vertices;
|
||||
mesh.triangles = tri;
|
||||
mesh.normals = normals;
|
||||
mesh.uv = uv;
|
||||
}
|
||||
mesh.vertices = vertices;
|
||||
mesh.triangles = tri;
|
||||
mesh.normals = normals;
|
||||
mesh.uv = uv;
|
||||
}
|
||||
|
||||
// Thank you https://github.com/boardtobits/planet-ring-mesh/blob/master/PlanetRing.cs
|
||||
public static void BuildRingMesh(Mesh ringMesh, int segments, float innerRadius, float outerRadius)
|
||||
// Thank you https://github.com/boardtobits/planet-ring-mesh/blob/master/PlanetRing.cs
|
||||
public static void BuildRingMesh(Mesh ringMesh, int segments, float innerRadius, float outerRadius)
|
||||
{
|
||||
Vector3[] vertices = new Vector3[(segments + 1) * 2 * 2];
|
||||
int[] triangles = new int[segments * 6 * 2];
|
||||
Vector2[] uv = new Vector2[(segments + 1) * 2 * 2];
|
||||
int halfway = (segments + 1) * 2;
|
||||
Vector3[] vertices = new Vector3[(segments + 1) * 2 * 2];
|
||||
int[] triangles = new int[segments * 6 * 2];
|
||||
Vector2[] uv = new Vector2[(segments + 1) * 2 * 2];
|
||||
int halfway = (segments + 1) * 2;
|
||||
|
||||
for (int i = 0; i < segments + 1; i++)
|
||||
{
|
||||
float progress = (float)i / (float)segments;
|
||||
float angle = progress * 2 * Mathf.PI;
|
||||
float x = Mathf.Sin(angle);
|
||||
float z = Mathf.Cos(angle);
|
||||
for (int i = 0; i < segments + 1; i++)
|
||||
{
|
||||
float progress = (float)i / (float)segments;
|
||||
float angle = progress * 2 * Mathf.PI;
|
||||
float x = Mathf.Sin(angle);
|
||||
float z = Mathf.Cos(angle);
|
||||
|
||||
vertices[i * 2] = vertices[i * 2 + halfway] = new Vector3(x, 0f, z) * outerRadius;
|
||||
vertices[i * 2 + 1] = vertices[i * 2 + 1 + halfway] = new Vector3(x, 0f, z) * innerRadius;
|
||||
//uv[i * 2] = uv[i * 2 + halfway] = new Vector2(progress, 0f);
|
||||
//uv[i * 2 + 1] = uv[i * 2 + 1 + halfway] = new Vector2(progress, 1f);
|
||||
uv[i * 2] = uv[i * 2 + halfway] = (new Vector2(x, z) / 2f) + Vector2.one * 0.5f;
|
||||
uv[i * 2 + 1] = uv[i * 2 + 1 + halfway] = new Vector2(0.5f, 0.5f);
|
||||
vertices[i * 2] = vertices[i * 2 + halfway] = new Vector3(x, 0f, z) * outerRadius;
|
||||
vertices[i * 2 + 1] = vertices[i * 2 + 1 + halfway] = new Vector3(x, 0f, z) * innerRadius;
|
||||
//uv[i * 2] = uv[i * 2 + halfway] = new Vector2(progress, 0f);
|
||||
//uv[i * 2 + 1] = uv[i * 2 + 1 + halfway] = new Vector2(progress, 1f);
|
||||
uv[i * 2] = uv[i * 2 + halfway] = (new Vector2(x, z) / 2f) + Vector2.one * 0.5f;
|
||||
uv[i * 2 + 1] = uv[i * 2 + 1 + halfway] = new Vector2(0.5f, 0.5f);
|
||||
|
||||
if (i != segments)
|
||||
{
|
||||
triangles[i * 12] = i * 2;
|
||||
triangles[i * 12 + 1] = triangles[i * 12 + 4] = (i + 1) * 2;
|
||||
triangles[i * 12 + 2] = triangles[i * 12 + 3] = i * 2 + 1;
|
||||
triangles[i * 12 + 5] = (i + 1) * 2 + 1;
|
||||
if (i != segments)
|
||||
{
|
||||
triangles[i * 12] = i * 2;
|
||||
triangles[i * 12 + 1] = triangles[i * 12 + 4] = (i + 1) * 2;
|
||||
triangles[i * 12 + 2] = triangles[i * 12 + 3] = i * 2 + 1;
|
||||
triangles[i * 12 + 5] = (i + 1) * 2 + 1;
|
||||
|
||||
triangles[i * 12 + 6] = i * 2 + halfway;
|
||||
triangles[i * 12 + 7] = triangles[i * 12 + 10] = i * 2 + 1 + halfway;
|
||||
triangles[i * 12 + 8] = triangles[i * 12 + 9] = (i + 1) * 2 + halfway;
|
||||
triangles[i * 12 + 11] = (i + 1) * 2 + 1 + halfway;
|
||||
}
|
||||
triangles[i * 12 + 6] = i * 2 + halfway;
|
||||
triangles[i * 12 + 7] = triangles[i * 12 + 10] = i * 2 + 1 + halfway;
|
||||
triangles[i * 12 + 8] = triangles[i * 12 + 9] = (i + 1) * 2 + halfway;
|
||||
triangles[i * 12 + 11] = (i + 1) * 2 + 1 + halfway;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
ringMesh.vertices = vertices;
|
||||
ringMesh.triangles = triangles;
|
||||
ringMesh.uv = uv;
|
||||
ringMesh.RecalculateNormals();
|
||||
}
|
||||
ringMesh.vertices = vertices;
|
||||
ringMesh.triangles = triangles;
|
||||
ringMesh.uv = uv;
|
||||
ringMesh.RecalculateNormals();
|
||||
}
|
||||
|
||||
public static void BuildCircleMesh(Mesh mesh, int segments, float outerRadius)
|
||||
{
|
||||
float angleStep = 360.0f / (float)segments;
|
||||
List<Vector3> vertexList = new List<Vector3>();
|
||||
List<int> triangleList = new List<int>();
|
||||
List<Vector2> uv = new List<Vector2>();
|
||||
Quaternion quaternion = Quaternion.Euler(0.0f, angleStep, 0f);
|
||||
// Make first triangle.
|
||||
vertexList.Add(new Vector3(0.0f, 0.0f, 0.0f)); // 1. Circle center.
|
||||
vertexList.Add(new Vector3(0.0f, 0f, outerRadius)); // 2. First vertex on circle outline (radius = 0.5f)
|
||||
vertexList.Add(quaternion * vertexList[1]); // 3. First vertex on circle outline rotated by angle)
|
||||
// Add triangle indices.
|
||||
uv.Add(new Vector2(0.5f, 0.5f));
|
||||
uv.Add(new Vector2(0.5f, 1f));
|
||||
uv.Add(quaternion * uv[1]);
|
||||
public static void BuildCircleMesh(Mesh mesh, int segments, float outerRadius)
|
||||
{
|
||||
float angleStep = 360.0f / (float)segments;
|
||||
List<Vector3> vertexList = new List<Vector3>();
|
||||
List<int> triangleList = new List<int>();
|
||||
List<Vector2> uv = new List<Vector2>();
|
||||
Quaternion quaternion = Quaternion.Euler(0.0f, angleStep, 0f);
|
||||
// Make first triangle.
|
||||
vertexList.Add(new Vector3(0.0f, 0.0f, 0.0f)); // 1. Circle center.
|
||||
vertexList.Add(new Vector3(0.0f, 0f, outerRadius)); // 2. First vertex on circle outline (radius = 0.5f)
|
||||
vertexList.Add(quaternion * vertexList[1]); // 3. First vertex on circle outline rotated by angle)
|
||||
// Add triangle indices.
|
||||
uv.Add(new Vector2(0.5f, 0.5f));
|
||||
uv.Add(new Vector2(0.5f, 1f));
|
||||
uv.Add(quaternion * uv[1]);
|
||||
|
||||
triangleList.Add(0);
|
||||
triangleList.Add(1);
|
||||
triangleList.Add(2);
|
||||
for (int i = 0; i < segments - 1; i++)
|
||||
{
|
||||
triangleList.Add(0); // Index of circle center.
|
||||
triangleList.Add(vertexList.Count - 1);
|
||||
triangleList.Add(vertexList.Count);
|
||||
vertexList.Add(quaternion * vertexList[vertexList.Count - 1]);
|
||||
uv.Add(quaternion * (uv[uv.Count - 1] - Vector2.one * 0.5f) + Vector3.one * 0.5f);
|
||||
}
|
||||
triangleList.Add(0);
|
||||
triangleList.Add(1);
|
||||
triangleList.Add(2);
|
||||
for (int i = 0; i < segments - 1; i++)
|
||||
{
|
||||
triangleList.Add(0); // Index of circle center.
|
||||
triangleList.Add(vertexList.Count - 1);
|
||||
triangleList.Add(vertexList.Count);
|
||||
vertexList.Add(quaternion * vertexList[vertexList.Count - 1]);
|
||||
uv.Add(quaternion * (uv[uv.Count - 1] - Vector2.one * 0.5f) + Vector3.one * 0.5f);
|
||||
}
|
||||
|
||||
mesh.vertices = vertexList.ToArray();
|
||||
mesh.triangles = triangleList.ToArray();
|
||||
mesh.uv = uv.ToArray();
|
||||
mesh.RecalculateNormals();
|
||||
mesh.vertices = vertexList.ToArray();
|
||||
mesh.triangles = triangleList.ToArray();
|
||||
mesh.uv = uv.ToArray();
|
||||
mesh.RecalculateNormals();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@ using UnityEngine;
|
||||
|
||||
namespace NewHorizons.Builder.Body
|
||||
{
|
||||
static class SandBuilder
|
||||
public static class SandBuilder
|
||||
{
|
||||
public static void Make(GameObject go, Sector sector, OWRigidbody rb, SandModule module)
|
||||
{
|
||||
@ -17,7 +17,7 @@ namespace NewHorizons.Builder.Body
|
||||
sandGO.SetActive(false);
|
||||
|
||||
var sandSphere = GameObject.Instantiate(GameObject.Find("TowerTwin_Body/SandSphere_Draining/SandSphere"), sandGO.transform);
|
||||
if(module.Tint != null)
|
||||
if (module.Tint != null)
|
||||
{
|
||||
var oldMR = sandSphere.GetComponent<TessellatedSphereRenderer>();
|
||||
var sandMaterials = oldMR.sharedMaterials;
|
||||
@ -38,25 +38,25 @@ namespace NewHorizons.Builder.Body
|
||||
collider.SetActive(true);
|
||||
|
||||
var occlusionSphere = GameObject.Instantiate(GameObject.Find("TowerTwin_Body/SandSphere_Draining/OcclusionSphere"), sandGO.transform);
|
||||
|
||||
|
||||
var proxyShadowCasterGO = GameObject.Instantiate(GameObject.Find("TowerTwin_Body/SandSphere_Draining/ProxyShadowCaster"), sandGO.transform);
|
||||
var proxyShadowCaster = proxyShadowCasterGO.GetComponent<ProxyShadowCaster>();
|
||||
proxyShadowCaster.SetSuperGroup(sandGO.GetComponent<ProxyShadowCasterSuperGroup>());
|
||||
|
||||
sandSphere.AddComponent<ChildColliderSettings>();
|
||||
|
||||
if(module.Curve != null)
|
||||
if (module.Curve != null)
|
||||
{
|
||||
var levelController = sandGO.AddComponent<SandLevelController>();
|
||||
var curve = new AnimationCurve();
|
||||
foreach(var pair in module.Curve)
|
||||
foreach (var pair in module.Curve)
|
||||
{
|
||||
curve.AddKey(new Keyframe(pair.Time, 2f * module.Size * pair.Value));
|
||||
}
|
||||
levelController._scaleCurve = curve;
|
||||
}
|
||||
|
||||
sandGO.transform.parent = go.transform;
|
||||
sandGO.transform.parent = sector?.transform ?? go.transform;
|
||||
sandGO.transform.localPosition = Vector3.zero;
|
||||
sandGO.transform.localScale = Vector3.one * module.Size * 2f;
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@ using Logger = NewHorizons.Utility.Logger;
|
||||
|
||||
namespace NewHorizons.Builder.Body
|
||||
{
|
||||
static class SingularityBuilder
|
||||
public static class SingularityBuilder
|
||||
{
|
||||
enum Polarity
|
||||
{
|
||||
@ -23,14 +23,14 @@ namespace NewHorizons.Builder.Body
|
||||
private static Shader blackHoleShader = null;
|
||||
private static Shader whiteHoleShader = null;
|
||||
|
||||
public static void Make(GameObject body, Sector sector, OWRigidbody OWRB, IPlanetConfig config)
|
||||
public static void Make(GameObject go, Sector sector, OWRigidbody OWRB, IPlanetConfig config)
|
||||
{
|
||||
// Backwards compatibility
|
||||
if(config.Singularity == null)
|
||||
{
|
||||
if(config.Base.BlackHoleSize != 0)
|
||||
{
|
||||
MakeBlackHole(body, sector, Vector3.zero, config.Base.BlackHoleSize, true, null);
|
||||
MakeBlackHole(go, sector, Vector3.zero, config.Base.BlackHoleSize, true, null);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -47,16 +47,18 @@ namespace NewHorizons.Builder.Body
|
||||
bool isWormHole = config.Singularity?.TargetStarSystem != null;
|
||||
bool hasHazardVolume = !isWormHole && (pairedSingularity == null);
|
||||
|
||||
bool makeZeroGVolume = config.Singularity == null ? true : config.Singularity.MakeZeroGVolume;
|
||||
|
||||
Vector3 localPosition = config.Singularity?.Position == null ? Vector3.zero : (Vector3)config.Singularity.Position;
|
||||
|
||||
GameObject newSingularity = null;
|
||||
switch (polarity)
|
||||
{
|
||||
case Polarity.BlackHole:
|
||||
newSingularity = MakeBlackHole(body, sector, localPosition, size, hasHazardVolume, config.Singularity.TargetStarSystem);
|
||||
newSingularity = MakeBlackHole(go, sector, localPosition, size, hasHazardVolume, config.Singularity.TargetStarSystem);
|
||||
break;
|
||||
case Polarity.WhiteHole:
|
||||
newSingularity = MakeWhiteHole(body, sector, OWRB, localPosition, size);
|
||||
newSingularity = MakeWhiteHole(go, sector, OWRB, localPosition, size, makeZeroGVolume);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -92,11 +94,11 @@ namespace NewHorizons.Builder.Body
|
||||
}
|
||||
}
|
||||
|
||||
public static GameObject MakeBlackHole(GameObject body, Sector sector, Vector3 localPosition, float size, bool hasDestructionVolume, string targetSolarSystem, bool makeAudio = true)
|
||||
public static GameObject MakeBlackHole(GameObject go, Sector sector, Vector3 localPosition, float size, bool hasDestructionVolume, string targetSolarSystem, bool makeAudio = true)
|
||||
{
|
||||
var blackHole = new GameObject("BlackHole");
|
||||
blackHole.SetActive(false);
|
||||
blackHole.transform.parent = body.transform;
|
||||
blackHole.transform.parent = sector?.transform ?? go.transform;
|
||||
blackHole.transform.localPosition = localPosition;
|
||||
|
||||
var blackHoleRender = new GameObject("BlackHoleRender");
|
||||
@ -167,7 +169,7 @@ namespace NewHorizons.Builder.Body
|
||||
{
|
||||
var whiteHole = new GameObject("WhiteHole");
|
||||
whiteHole.SetActive(false);
|
||||
whiteHole.transform.parent = body.transform;
|
||||
whiteHole.transform.parent = sector?.transform ?? body.transform;
|
||||
whiteHole.transform.localPosition = localPosition;
|
||||
|
||||
var whiteHoleRenderer = new GameObject("WhiteHoleRenderer");
|
||||
|
||||
@ -14,17 +14,17 @@ using NewHorizons.Components.SizeControllers;
|
||||
|
||||
namespace NewHorizons.Builder.Body
|
||||
{
|
||||
static class StarBuilder
|
||||
public static class StarBuilder
|
||||
{
|
||||
public const float OuterRadiusRatio = 1.5f;
|
||||
|
||||
private static Texture2D _colorOverTime;
|
||||
public static StarController Make(GameObject body, Sector sector, StarModule starModule)
|
||||
|
||||
public static StarController Make(GameObject go, Sector sector, StarModule starModule)
|
||||
{
|
||||
if (_colorOverTime == null) _colorOverTime = ImageUtilities.GetTexture(Main.Instance, "AssetBundle/StarColorOverTime.png");
|
||||
|
||||
var starGO = new GameObject("Star");
|
||||
starGO.transform.parent = body.transform;
|
||||
starGO.transform.parent = sector?.transform ?? go.transform;
|
||||
|
||||
var sunSurface = GameObject.Instantiate(GameObject.Find("Sun_Body/Sector_SUN/Geometry_SUN/Surface"), starGO.transform);
|
||||
sunSurface.transform.localPosition = Vector3.zero;
|
||||
@ -67,7 +67,7 @@ namespace NewHorizons.Builder.Body
|
||||
|
||||
if(starModule.HasAtmosphere)
|
||||
{
|
||||
var sunAtmosphere = GameObject.Instantiate(GameObject.Find("Sun_Body/Atmosphere_SUN"), body.transform);
|
||||
var sunAtmosphere = GameObject.Instantiate(GameObject.Find("Sun_Body/Atmosphere_SUN"), go.transform);
|
||||
sunAtmosphere.transform.localPosition = Vector3.zero;
|
||||
sunAtmosphere.transform.localScale = Vector3.one;
|
||||
sunAtmosphere.name = "Atmosphere_Star";
|
||||
@ -157,7 +157,7 @@ namespace NewHorizons.Builder.Body
|
||||
StarController starController = null;
|
||||
if (starModule.SolarLuminosity != 0)
|
||||
{
|
||||
starController = body.AddComponent<StarController>();
|
||||
starController = go.AddComponent<StarController>();
|
||||
starController.Light = light;
|
||||
starController.AmbientLight = ambientLight;
|
||||
starController.FaceActiveCamera = faceActiveCamera;
|
||||
|
||||
@ -9,16 +9,16 @@ using NewHorizons.Components.SizeControllers;
|
||||
|
||||
namespace NewHorizons.Builder.Body
|
||||
{
|
||||
static class WaterBuilder
|
||||
public static class WaterBuilder
|
||||
{
|
||||
public static void Make(GameObject body, Sector sector, OWRigidbody rb, WaterModule module)
|
||||
public static void Make(GameObject go, Sector sector, OWRigidbody rb, WaterModule module)
|
||||
{
|
||||
var waterSize = module.Size;
|
||||
|
||||
GameObject waterGO = new GameObject("Water");
|
||||
waterGO.SetActive(false);
|
||||
waterGO.layer = 15;
|
||||
waterGO.transform.parent = body.transform;
|
||||
waterGO.transform.parent = sector?.transform ?? go.transform;
|
||||
waterGO.transform.localScale = new Vector3(waterSize, waterSize, waterSize);
|
||||
|
||||
var GDTSR = GameObject.Find("Ocean_GD").GetComponent<TessellatedSphereRenderer>();
|
||||
|
||||
@ -6,11 +6,11 @@ using Logger = NewHorizons.Utility.Logger;
|
||||
|
||||
namespace NewHorizons.Builder.General
|
||||
{
|
||||
static class AmbientLightBuilder
|
||||
public static class AmbientLightBuilder
|
||||
{
|
||||
public static void Make(GameObject body, float scale)
|
||||
public static void Make(GameObject body, Sector sector, float scale)
|
||||
{
|
||||
GameObject lightGO = GameObject.Instantiate(GameObject.Find("BrittleHollow_Body/AmbientLight_BH_Surface"), body.transform);
|
||||
GameObject lightGO = GameObject.Instantiate(GameObject.Find("BrittleHollow_Body/AmbientLight_BH_Surface"), sector?.transform ?? body.transform);
|
||||
lightGO.transform.localPosition = Vector3.zero;
|
||||
lightGO.name = "Light";
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ using NewHorizons.Components.Orbital;
|
||||
|
||||
namespace NewHorizons.Builder.General
|
||||
{
|
||||
static class AstroObjectBuilder
|
||||
public static class AstroObjectBuilder
|
||||
{
|
||||
public static NHAstroObject Make(GameObject body, AstroObject primaryBody, IPlanetConfig config)
|
||||
{
|
||||
|
||||
@ -12,7 +12,7 @@ using NewHorizons.External.Configs;
|
||||
|
||||
namespace NewHorizons.Builder.General
|
||||
{
|
||||
static class DetectorBuilder
|
||||
public static class DetectorBuilder
|
||||
{
|
||||
public static GameObject Make(GameObject body, OWRigidbody OWRB, AstroObject primaryBody, AstroObject astroObject, IPlanetConfig config)
|
||||
{
|
||||
|
||||
@ -9,7 +9,7 @@ using Logger = NewHorizons.Utility.Logger;
|
||||
|
||||
namespace NewHorizons.Builder.General
|
||||
{
|
||||
static class GravityBuilder
|
||||
public static class GravityBuilder
|
||||
{
|
||||
public static GravityVolume Make(GameObject body, AstroObject ao, IPlanetConfig config)
|
||||
{
|
||||
|
||||
@ -5,7 +5,7 @@ using Logger = NewHorizons.Utility.Logger;
|
||||
|
||||
namespace NewHorizons.Builder.General
|
||||
{
|
||||
static class RFVolumeBuilder
|
||||
public static class RFVolumeBuilder
|
||||
{
|
||||
public static void Make(GameObject body, OWRigidbody rigidbody, float sphereOfInfluence)
|
||||
{
|
||||
|
||||
@ -6,7 +6,7 @@ using Logger = NewHorizons.Utility.Logger;
|
||||
|
||||
namespace NewHorizons.Builder.General
|
||||
{
|
||||
static class MakeSector
|
||||
public static class MakeSector
|
||||
{
|
||||
public static Sector Make(GameObject body, OWRigidbody rigidbody, float sphereOfInfluence)
|
||||
{
|
||||
|
||||
@ -7,7 +7,7 @@ using Logger = NewHorizons.Utility.Logger;
|
||||
|
||||
namespace NewHorizons.Builder.General
|
||||
{
|
||||
static class SpawnPointBuilder
|
||||
public static class SpawnPointBuilder
|
||||
{
|
||||
private static bool suitUpQueued = false;
|
||||
public static SpawnPoint Make(GameObject body, SpawnModule module, OWRigidbody rb)
|
||||
|
||||
@ -15,7 +15,7 @@ using Logger = NewHorizons.Utility.Logger;
|
||||
|
||||
namespace NewHorizons.Builder.Orbital
|
||||
{
|
||||
static class FocalPointBuilder
|
||||
public static class FocalPointBuilder
|
||||
{
|
||||
public static void Make(GameObject go, AstroObject ao, IPlanetConfig config, IModBehaviour mod)
|
||||
{
|
||||
|
||||
@ -13,7 +13,7 @@ using NewHorizons.Components.Orbital;
|
||||
|
||||
namespace NewHorizons.Builder.Orbital
|
||||
{
|
||||
static class InitialMotionBuilder
|
||||
public static class InitialMotionBuilder
|
||||
{
|
||||
public static InitialMotion Make(GameObject body, AstroObject primaryBody, AstroObject secondaryBody, OWRigidbody OWRB, OrbitModule orbit)
|
||||
{
|
||||
@ -73,12 +73,12 @@ namespace NewHorizons.Builder.Orbital
|
||||
{
|
||||
// It's a circumbinary moon/planet
|
||||
var fakePrimaryBody = focalPoint.FakeMassBody.GetComponent<AstroObject>();
|
||||
SetMotionFromPrimary(fakePrimaryBody, secondaryBody as NHAstroObject, initialMotion);
|
||||
SetMotionFromPrimary(fakePrimaryBody, secondaryBody, secondaryBody as NHAstroObject, initialMotion);
|
||||
}
|
||||
}
|
||||
else if (primaryBody.GetGravityVolume())
|
||||
{
|
||||
SetMotionFromPrimary(primaryBody, secondaryBody as NHAstroObject, initialMotion);
|
||||
SetMotionFromPrimary(primaryBody, secondaryBody, secondaryBody as NHAstroObject, initialMotion);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -86,13 +86,13 @@ namespace NewHorizons.Builder.Orbital
|
||||
}
|
||||
}
|
||||
|
||||
private static void SetMotionFromPrimary(AstroObject primaryBody, NHAstroObject secondaryBody, InitialMotion initialMotion)
|
||||
public static void SetMotionFromPrimary(AstroObject primaryBody, AstroObject secondaryBody, IOrbitalParameters orbit, InitialMotion initialMotion)
|
||||
{
|
||||
initialMotion.SetPrimaryBody(primaryBody.GetAttachedOWRigidbody());
|
||||
|
||||
var primaryGravity = new Gravity(primaryBody.GetGravityVolume());
|
||||
var secondaryGravity = new Gravity(secondaryBody.GetGravityVolume());
|
||||
var velocity = secondaryBody.GetOrbitalParameters(primaryGravity, secondaryGravity).InitialVelocity;
|
||||
var velocity = orbit.GetOrbitalParameters(primaryGravity, secondaryGravity).InitialVelocity;
|
||||
|
||||
var parentVelocity = primaryBody?.GetComponent<InitialMotion>()?.GetInitVelocity() ?? Vector3.zero;
|
||||
initialMotion._cachedInitVelocity = velocity + parentVelocity;
|
||||
|
||||
@ -9,7 +9,7 @@ using System;
|
||||
|
||||
namespace NewHorizons.Builder.Orbital
|
||||
{
|
||||
static class OrbitlineBuilder
|
||||
public static class OrbitlineBuilder
|
||||
{
|
||||
public static OrbitLine Make(GameObject body, NHAstroObject astroObject, bool isMoon, IPlanetConfig config)
|
||||
{
|
||||
|
||||
@ -85,29 +85,6 @@ namespace NewHorizons.Builder.Props
|
||||
if (component is GhostIK) (component as GhostIK).enabled = false;
|
||||
if (component is GhostEffects) (component as GhostEffects).enabled = false;
|
||||
|
||||
// If it's not a moving anglerfish make sure the anim controller is regular
|
||||
if(component is AnglerfishAnimController && component.GetComponentInParent<AnglerfishController>() == null)
|
||||
Main.Instance.ModHelper.Events.Unity.RunWhen(() => Main.IsSystemReady, () =>
|
||||
{
|
||||
Logger.Log("Enabling anglerfish animation");
|
||||
var angler = (component as AnglerfishAnimController);
|
||||
// Remove any reference to its angler
|
||||
if(angler._anglerfishController)
|
||||
{
|
||||
angler._anglerfishController.OnChangeAnglerState -= angler.OnChangeAnglerState;
|
||||
angler._anglerfishController.OnAnglerTurn -= angler.OnAnglerTurn;
|
||||
angler._anglerfishController.OnAnglerSuspended -= angler.OnAnglerSuspended;
|
||||
angler._anglerfishController.OnAnglerUnsuspended -= angler.OnAnglerUnsuspended;
|
||||
}
|
||||
angler.enabled = true;
|
||||
angler.OnChangeAnglerState(AnglerfishController.AnglerState.Lurking);
|
||||
});
|
||||
|
||||
if (component is Animator) Main.Instance.ModHelper.Events.Unity.RunWhen(() => Main.IsSystemReady, () => (component as Animator).enabled = true);
|
||||
if (component is Collider) Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => (component as Collider).enabled = true);
|
||||
|
||||
if(component is Shape) Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => (component as Shape).enabled = true);
|
||||
|
||||
if(component is DarkMatterVolume)
|
||||
{
|
||||
var probeVisuals = component.gameObject.transform.Find("ProbeVisuals");
|
||||
@ -146,16 +123,47 @@ namespace NewHorizons.Builder.Props
|
||||
{
|
||||
(component as OWItemSocket)._sector = sector;
|
||||
}
|
||||
|
||||
// Fix a bunch of stuff when done loading
|
||||
Main.Instance.ModHelper.Events.Unity.RunWhen(() => Main.IsSystemReady, () =>
|
||||
{
|
||||
if (component is Animator) (component as Animator).enabled = true;
|
||||
else if (component is Collider) (component as Collider).enabled = true;
|
||||
else if (component is Renderer) (component as Renderer).enabled = true;
|
||||
else if (component is Shape) (component as Shape).enabled = true;
|
||||
// If it's not a moving anglerfish make sure the anim controller is regular
|
||||
else if (component is AnglerfishAnimController && component.GetComponentInParent<AnglerfishController>() == null)
|
||||
{
|
||||
Logger.Log("Enabling anglerfish animation");
|
||||
var angler = (component as AnglerfishAnimController);
|
||||
// Remove any reference to its angler
|
||||
if (angler._anglerfishController)
|
||||
{
|
||||
angler._anglerfishController.OnChangeAnglerState -= angler.OnChangeAnglerState;
|
||||
angler._anglerfishController.OnAnglerTurn -= angler.OnAnglerTurn;
|
||||
angler._anglerfishController.OnAnglerSuspended -= angler.OnAnglerSuspended;
|
||||
angler._anglerfishController.OnAnglerUnsuspended -= angler.OnAnglerUnsuspended;
|
||||
}
|
||||
angler.enabled = true;
|
||||
angler.OnChangeAnglerState(AnglerfishController.AnglerState.Lurking);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
prop.transform.position = position == null ? go.transform.position : go.transform.TransformPoint((Vector3)position);
|
||||
|
||||
Quaternion rot = rotation == null ? Quaternion.identity : Quaternion.Euler((Vector3)rotation);
|
||||
prop.transform.localRotation = rot;
|
||||
prop.transform.localRotation = Quaternion.identity;
|
||||
if (alignWithNormal)
|
||||
{
|
||||
// Apply the rotation after aligning it with normal
|
||||
var up = prop.transform.localPosition.normalized;
|
||||
prop.transform.rotation = Quaternion.FromToRotation(prop.transform.up, up) * prop.transform.rotation;
|
||||
prop.transform.rotation *= rot;
|
||||
}
|
||||
else
|
||||
{
|
||||
prop.transform.localRotation = rot;
|
||||
}
|
||||
|
||||
prop.transform.localScale = scale != 0 ? Vector3.one * scale : prefab.transform.localScale;
|
||||
|
||||
@ -15,7 +15,7 @@ namespace NewHorizons.Builder.Props
|
||||
{
|
||||
var original = GameObject.Find("TimberHearth_Body/Sector_TH/Interactables_TH/Geysers/Geyser_Village");
|
||||
GameObject geyserGO = original.InstantiateInactive();
|
||||
geyserGO.transform.parent = sector.transform;
|
||||
geyserGO.transform.parent = sector?.transform ?? go.transform;
|
||||
geyserGO.name = "Geyser";
|
||||
|
||||
var pos = ((Vector3)info.position);
|
||||
|
||||
@ -92,7 +92,7 @@ namespace NewHorizons.Builder.Props
|
||||
nomaiWallTextObj.transform.up = up;
|
||||
nomaiWallTextObj.transform.forward = forward;
|
||||
}
|
||||
if(info.rotation != null)
|
||||
if (info.rotation != null)
|
||||
{
|
||||
nomaiWallTextObj.transform.localRotation = Quaternion.Euler(info.rotation);
|
||||
}
|
||||
@ -161,6 +161,7 @@ namespace NewHorizons.Builder.Props
|
||||
computerObject.transform.localPosition = info?.position ?? Vector3.zero;
|
||||
|
||||
var up = computerObject.transform.position - go.transform.position;
|
||||
if (info.normal != null) up = go.transform.TransformDirection(info.normal);
|
||||
computerObject.transform.rotation = Quaternion.FromToRotation(Vector3.up, up) * computerObject.transform.rotation;
|
||||
|
||||
var computer = computerObject.GetComponent<NomaiComputer>();
|
||||
@ -312,7 +313,7 @@ namespace NewHorizons.Builder.Props
|
||||
{
|
||||
arc = _childArcPrefabs[Random.Range(0, _childArcPrefabs.Count())].InstantiateInactive();
|
||||
}
|
||||
else if(type == "stranger" && _ghostArcPrefabs.Count() > 0) // It could be empty if they dont have the DLC
|
||||
else if (type == "stranger" && _ghostArcPrefabs.Count() > 0) // It could be empty if they dont have the DLC
|
||||
{
|
||||
arc = _ghostArcPrefabs[Random.Range(0, _ghostArcPrefabs.Count())].InstantiateInactive();
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ namespace NewHorizons.Builder.Props
|
||||
}
|
||||
|
||||
private static void MakeSlideReel(GameObject go, Sector sector, PropModule.ProjectionInfo info, IModBehaviour mod)
|
||||
{
|
||||
{
|
||||
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();
|
||||
@ -46,7 +46,7 @@ namespace NewHorizons.Builder.Props
|
||||
|
||||
var slideCollectionContainer = slideReelObj.GetRequiredComponent<SlideCollectionContainer>();
|
||||
|
||||
foreach(var renderer in slideReelObj.GetComponentsInChildren<Renderer>())
|
||||
foreach (var renderer in slideReelObj.GetComponentsInChildren<Renderer>())
|
||||
{
|
||||
renderer.enabled = true;
|
||||
}
|
||||
@ -62,7 +62,7 @@ namespace NewHorizons.Builder.Props
|
||||
// The base game ones only have 15 slides max
|
||||
var textures = new Texture2D[slidesCount >= 15 ? 15 : slidesCount];
|
||||
|
||||
for(int i = 0; i < slidesCount; i++)
|
||||
for (int i = 0; i < slidesCount; i++)
|
||||
{
|
||||
var slide = new Slide();
|
||||
var slideInfo = info.slides[i];
|
||||
@ -71,7 +71,7 @@ namespace NewHorizons.Builder.Props
|
||||
slide.textureOverride = ImageUtilities.Invert(texture);
|
||||
|
||||
// Track the first 15 to put on the slide reel object
|
||||
if(i < 15) textures[i] = texture;
|
||||
if (i < 15) textures[i] = texture;
|
||||
|
||||
AddModules(slideInfo, ref slide);
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@ namespace NewHorizons.Builder.Props
|
||||
|
||||
public static void Make(GameObject planetGO, Sector sector, PropModule.RaftInfo info, OWRigidbody planetBody)
|
||||
{
|
||||
if(_prefab == null)
|
||||
if (_prefab == null)
|
||||
{
|
||||
_prefab = GameObject.FindObjectOfType<RaftController>()?.gameObject?.InstantiateInactive();
|
||||
if (_prefab == null)
|
||||
@ -33,7 +33,7 @@ namespace NewHorizons.Builder.Props
|
||||
|
||||
GameObject raftObject = _prefab.InstantiateInactive();
|
||||
raftObject.name = "Raft_Body";
|
||||
raftObject.transform.parent = sector.transform;
|
||||
raftObject.transform.parent = sector?.transform ?? planetGO.transform;
|
||||
raftObject.transform.localPosition = info.position;
|
||||
raftObject.transform.localRotation = Quaternion.identity;
|
||||
|
||||
|
||||
@ -35,7 +35,7 @@ namespace NewHorizons.Builder.Props
|
||||
heightMapTexture = ImageUtilities.GetTexture(mod, heightMap.HeightMap);
|
||||
}
|
||||
catch (Exception) { }
|
||||
if(heightMapTexture == null)
|
||||
if (heightMapTexture == null)
|
||||
{
|
||||
radius = heightMap.MaxHeight;
|
||||
}
|
||||
@ -50,7 +50,7 @@ namespace NewHorizons.Builder.Props
|
||||
else prefab = GameObject.Find(propInfo.path);
|
||||
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);
|
||||
var point = points[randomInd];
|
||||
|
||||
var height = radius;
|
||||
|
||||
@ -30,7 +30,7 @@ namespace NewHorizons.Builder.Props
|
||||
{
|
||||
Logger.Log($"Initializing SignalBuilder");
|
||||
_customSignalNames = new Dictionary<SignalName, string>();
|
||||
_availableSignalNames = new Stack<SignalName> (new SignalName[]
|
||||
_availableSignalNames = new Stack<SignalName>(new SignalName[]
|
||||
{
|
||||
(SignalName)17,
|
||||
(SignalName)18,
|
||||
@ -68,9 +68,9 @@ namespace NewHorizons.Builder.Props
|
||||
SignalName.WhiteHole_GD_Receiver,
|
||||
});
|
||||
_customFrequencyNames = new Dictionary<SignalFrequency, string>() {
|
||||
{ SignalFrequency.Statue, "FREQ_STATUE" },
|
||||
{ SignalFrequency.Default, "FREQ_UNKNOWN" },
|
||||
{ SignalFrequency.WarpCore, "FREQ_WARP_CORE" }
|
||||
{ SignalFrequency.Statue, "FREQ_STATUE" },
|
||||
{ SignalFrequency.Default, "FREQ_UNKNOWN" },
|
||||
{ SignalFrequency.WarpCore, "FREQ_WARP_CORE" }
|
||||
};
|
||||
_nextCustomSignalName = 200;
|
||||
_nextCustomFrequencyName = 256;
|
||||
@ -100,7 +100,7 @@ namespace NewHorizons.Builder.Props
|
||||
NumberOfFrequencies++;
|
||||
|
||||
// This stuff happens after the signalscope is Awake so we have to change the number of frequencies now
|
||||
GameObject.FindObjectOfType<Signalscope>()._strongestSignals = new AudioSignal[NumberOfFrequencies+1];
|
||||
GameObject.FindObjectOfType<Signalscope>()._strongestSignals = new AudioSignal[NumberOfFrequencies + 1];
|
||||
|
||||
return freq;
|
||||
}
|
||||
@ -131,17 +131,17 @@ namespace NewHorizons.Builder.Props
|
||||
|
||||
public static void Make(GameObject body, Sector sector, SignalModule module, IModBehaviour mod)
|
||||
{
|
||||
foreach(var info in module.Signals)
|
||||
foreach (var info in module.Signals)
|
||||
{
|
||||
Make(body, sector, info, mod);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Make(GameObject body, Sector sector, SignalModule.SignalInfo info, IModBehaviour mod)
|
||||
public static void Make(GameObject planetGO, Sector sector, SignalModule.SignalInfo info, IModBehaviour mod)
|
||||
{
|
||||
var signalGO = new GameObject($"Signal_{info.Name}");
|
||||
signalGO.SetActive(false);
|
||||
signalGO.transform.parent = body.transform;
|
||||
signalGO.transform.parent = sector?.transform ?? planetGO.transform;
|
||||
signalGO.transform.localPosition = info.Position != null ? (Vector3)info.Position : Vector3.zero;
|
||||
signalGO.layer = LayerMask.NameToLayer("AdvancedEffectVolume");
|
||||
|
||||
@ -156,14 +156,14 @@ namespace NewHorizons.Builder.Props
|
||||
var name = StringToSignalName(info.Name);
|
||||
|
||||
AudioClip clip = null;
|
||||
if(info.AudioClip != null) clip = SearchUtilities.FindResourceOfTypeAndName<AudioClip>(info.AudioClip);
|
||||
if (info.AudioClip != null) clip = SearchUtilities.FindResourceOfTypeAndName<AudioClip>(info.AudioClip);
|
||||
else if (info.AudioFilePath != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
clip = AudioUtilities.LoadAudio(mod.ModHelper.Manifest.ModFolderPath + "/" + info.AudioFilePath);
|
||||
}
|
||||
catch(Exception e)
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError($"Couldn't load audio file {info.AudioFilePath} : {e.Message}");
|
||||
}
|
||||
@ -177,7 +177,7 @@ namespace NewHorizons.Builder.Props
|
||||
|
||||
audioSignal.SetSector(sector);
|
||||
|
||||
if(name == SignalName.Default) audioSignal._preventIdentification = true;
|
||||
if (name == SignalName.Default) audioSignal._preventIdentification = true;
|
||||
|
||||
audioSignal._frequency = frequency;
|
||||
audioSignal._name = name;
|
||||
@ -194,7 +194,7 @@ namespace NewHorizons.Builder.Props
|
||||
source.velocityUpdateMode = AudioVelocityUpdateMode.Fixed;
|
||||
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);
|
||||
|
||||
source.SetCustomCurve(AudioSourceCurveType.CustomRolloff, _customCurve);
|
||||
@ -210,7 +210,7 @@ namespace NewHorizons.Builder.Props
|
||||
|
||||
var signalDetectionGO = new GameObject($"SignalDetectionTrigger_{info.Name}");
|
||||
signalDetectionGO.SetActive(false);
|
||||
signalDetectionGO.transform.parent = body.transform;
|
||||
signalDetectionGO.transform.parent = sector?.transform ?? planetGO.transform;
|
||||
signalDetectionGO.transform.localPosition = info.Position != null ? (Vector3)info.Position : Vector3.zero;
|
||||
signalDetectionGO.layer = LayerMask.NameToLayer("AdvancedEffectVolume");
|
||||
|
||||
@ -223,12 +223,12 @@ namespace NewHorizons.Builder.Props
|
||||
audioSignalDetectionTrigger._trigger = owTriggerVolume;
|
||||
|
||||
signalGO.SetActive(true);
|
||||
signalDetectionGO.SetActive(true);
|
||||
signalDetectionGO.SetActive(true);
|
||||
}
|
||||
|
||||
private static SignalFrequency StringToFrequency(string str)
|
||||
{
|
||||
foreach(SignalFrequency freq in Enum.GetValues(typeof(SignalFrequency)))
|
||||
foreach (SignalFrequency freq in Enum.GetValues(typeof(SignalFrequency)))
|
||||
{
|
||||
if (str.Equals(freq.ToString())) return freq;
|
||||
}
|
||||
@ -249,6 +249,6 @@ namespace NewHorizons.Builder.Props
|
||||
if (customName == default) customName = AddSignalName(str);
|
||||
|
||||
return customName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,12 +26,12 @@ namespace NewHorizons.Builder.Props
|
||||
upPrefab = GameObject.Find("BrittleHollow_Body/Sector_BH/Sector_SouthHemisphere/Sector_SouthPole/Sector_Observatory/Interactables_Observatory/MockUpTornado").InstantiateInactive();
|
||||
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.name = "Tornado_Down_Prefab";
|
||||
}
|
||||
if(soundPrefab == null)
|
||||
if (soundPrefab == null)
|
||||
{
|
||||
soundPrefab = GameObject.Find("GiantsDeep_Body/Sector_GD/Sector_GDInterior/Tornadoes_GDInterior/SouthernTornadoes/DownTornado_Pivot/DownTornado/AudioRail").InstantiateInactive();
|
||||
soundPrefab.name = "AudioRail_Prefab";
|
||||
@ -39,12 +39,12 @@ namespace NewHorizons.Builder.Props
|
||||
|
||||
float elevation;
|
||||
Vector3 position;
|
||||
if(info.position != null)
|
||||
if (info.position != null)
|
||||
{
|
||||
position = info.position ?? Random.onUnitSphere * info.elevation;
|
||||
elevation = position.magnitude;
|
||||
}
|
||||
else if(info.elevation != 0)
|
||||
else if (info.elevation != 0)
|
||||
{
|
||||
position = Random.onUnitSphere * info.elevation;
|
||||
elevation = info.elevation;
|
||||
@ -102,16 +102,16 @@ namespace NewHorizons.Builder.Props
|
||||
controller._bottomBone.localPosition = controller._bottomStartPos;
|
||||
controller._midBone.localPosition = controller._midStartPos;
|
||||
controller._topBone.localPosition = controller._topStartPos;
|
||||
|
||||
|
||||
OWAssetHandler.LoadObject(tornadoGO);
|
||||
sector.OnOccupantEnterSector += (sd) => OWAssetHandler.LoadObject(tornadoGO);
|
||||
|
||||
tornadoGO.GetComponentInChildren<CapsuleShape>().enabled = true;
|
||||
|
||||
if(info.tint != null)
|
||||
if (info.tint != null)
|
||||
{
|
||||
var colour = info.tint.ToColor();
|
||||
foreach(var renderer in tornadoGO.GetComponentsInChildren<Renderer>())
|
||||
foreach (var renderer in tornadoGO.GetComponentsInChildren<Renderer>())
|
||||
{
|
||||
renderer.material.color = colour;
|
||||
renderer.material.SetColor("_DetailColor", colour);
|
||||
@ -119,7 +119,7 @@ namespace NewHorizons.Builder.Props
|
||||
}
|
||||
}
|
||||
|
||||
if(info.wanderRate != 0)
|
||||
if (info.wanderRate != 0)
|
||||
{
|
||||
var wanderer = tornadoGO.AddComponent<NHTornadoWanderController>();
|
||||
wanderer.wanderRate = info.wanderRate;
|
||||
|
||||
@ -16,7 +16,7 @@ namespace NewHorizons.Builder.Props
|
||||
|
||||
var launcherGO = prefab.InstantiateInactive();
|
||||
launcherGO.transform.parent = sector.transform;
|
||||
launcherGO.transform.localPosition = info.position == null ? Vector3.zero : (Vector3) info.position;
|
||||
launcherGO.transform.localPosition = info.position == null ? Vector3.zero : (Vector3)info.position;
|
||||
launcherGO.transform.rotation = Quaternion.FromToRotation(launcherGO.transform.TransformDirection(Vector3.up), ((Vector3)info.position).normalized).normalized;
|
||||
launcherGO.name = "MeteorLauncher";
|
||||
|
||||
@ -37,7 +37,8 @@ namespace NewHorizons.Builder.Props
|
||||
launcherGO.SetActive(true);
|
||||
|
||||
// Have to null check else it breaks on reload configs
|
||||
Main.Instance.ModHelper.Events.Unity.RunWhen(() => Main.IsSystemReady && meteorLauncher._meteorPool != null, () => {
|
||||
Main.Instance.ModHelper.Events.Unity.RunWhen(() => Main.IsSystemReady && meteorLauncher._meteorPool != null, () =>
|
||||
{
|
||||
foreach (var meteor in meteorLauncher._meteorPool)
|
||||
{
|
||||
FixMeteor(meteor, info);
|
||||
|
||||
@ -21,7 +21,7 @@ namespace NewHorizons.Builder.ShipLog
|
||||
{
|
||||
Material greyScaleMaterial = GameObject.Find(ShipLogHandler.PAN_ROOT_PATH + "/TimberHearth/Sprite").GetComponent<Image>().material;
|
||||
List<NewHorizonsBody> bodies = Main.BodyDict[systemName].Where(
|
||||
b => (b.Config.ShipLog?.mapMode?.remove ?? false) == false
|
||||
b => !(b.Config.ShipLog?.mapMode?.remove ?? false) && !b.Config.IsQuantumState
|
||||
).ToList();
|
||||
bool flagManualPositionUsed = systemName == "SolarSystem";
|
||||
bool flagAutoPositionUsed = false;
|
||||
|
||||
@ -218,9 +218,9 @@ namespace NewHorizons.Builder.ShipLog
|
||||
Vector2 pivot = new Vector2(newTexture.width / 2, newTexture.height / 2);
|
||||
return Sprite.Create(newTexture, rect, pivot);
|
||||
}
|
||||
catch(Exception)
|
||||
catch (Exception)
|
||||
{
|
||||
if(logError) Logger.LogError($"Couldn't load image for {entryId} at {relativePath}");
|
||||
if (logError) Logger.LogError($"Couldn't load image for {entryId} at {relativePath}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,15 +8,15 @@ using Logger = NewHorizons.Utility.Logger;
|
||||
|
||||
namespace NewHorizons.Components.Orbital
|
||||
{
|
||||
public class OrbitalParameters
|
||||
public class OrbitalParameters : IOrbitalParameters
|
||||
{
|
||||
public float Inclination { get; private set; }
|
||||
public float SemiMajorAxis { get; private set; }
|
||||
public float LongitudeOfAscendingNode { get; private set; }
|
||||
public float Eccentricity { get; private set; }
|
||||
public float ArgumentOfPeriapsis { get; private set; }
|
||||
public float TrueAnomaly { get; private set; }
|
||||
public float Period { get; private set; }
|
||||
public float Inclination { get; set; }
|
||||
public float SemiMajorAxis { get; set; }
|
||||
public float LongitudeOfAscendingNode { get; set; }
|
||||
public float Eccentricity { get; set; }
|
||||
public float ArgumentOfPeriapsis { get; set; }
|
||||
public float TrueAnomaly { get; set; }
|
||||
public float Period { get; set; }
|
||||
|
||||
public Vector3 InitialPosition { get; private set; }
|
||||
public Vector3 InitialVelocity { get; private set; }
|
||||
@ -112,5 +112,10 @@ namespace NewHorizons.Components.Orbital
|
||||
|
||||
return R1 * R2 * vector;
|
||||
}
|
||||
|
||||
public OrbitalParameters GetOrbitalParameters(Gravity primaryGravity, Gravity secondaryGravity)
|
||||
{
|
||||
return FromTrueAnomaly(primaryGravity, secondaryGravity, Eccentricity, SemiMajorAxis, Inclination, ArgumentOfPeriapsis, LongitudeOfAscendingNode, TrueAnomaly);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
172
NewHorizons/Components/QuantumPlanet.cs
Normal file
172
NewHorizons/Components/QuantumPlanet.cs
Normal file
@ -0,0 +1,172 @@
|
||||
using NewHorizons.Builder.General;
|
||||
using NewHorizons.Builder.Orbital;
|
||||
using NewHorizons.Components.Orbital;
|
||||
using NewHorizons.External;
|
||||
using NewHorizons.Handlers;
|
||||
using NewHorizons.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
using Logger = NewHorizons.Utility.Logger;
|
||||
|
||||
namespace NewHorizons.Components
|
||||
{
|
||||
public class QuantumPlanet : QuantumObject
|
||||
{
|
||||
public List<State> states = new List<State>();
|
||||
public State groundState;
|
||||
|
||||
private int _currentIndex;
|
||||
private NHAstroObject _astroObject;
|
||||
private ConstantForceDetector _detector;
|
||||
private AlignWithTargetBody _alignment;
|
||||
private OWRigidbody _rb;
|
||||
|
||||
public override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
|
||||
_astroObject = GetComponent<NHAstroObject>();
|
||||
_detector = GetComponentInChildren<ConstantForceDetector>();
|
||||
_alignment = GetComponent<AlignWithTargetBody>();
|
||||
_rb = GetComponent<OWRigidbody>();
|
||||
|
||||
GlobalMessenger.AddListener("PlayerBlink", new Callback(OnPlayerBlink));
|
||||
|
||||
_maxSnapshotLockRange = 300000f;
|
||||
}
|
||||
|
||||
public override void Start()
|
||||
{
|
||||
base.Start();
|
||||
|
||||
foreach (var state in states)
|
||||
{
|
||||
state.sector?.gameObject?.SetActive(false);
|
||||
}
|
||||
|
||||
ChangeQuantumState(true);
|
||||
}
|
||||
|
||||
public override bool ChangeQuantumState(bool skipInstantVisibilityCheck)
|
||||
{
|
||||
Logger.Log($"Trying to change quantum state");
|
||||
|
||||
if (states.Count <= 1) return false;
|
||||
|
||||
// Don't move if we have a picture or if we're on it
|
||||
if (IsLockedByProbeSnapshot() || IsPlayerEntangled()) return false;
|
||||
|
||||
var canChange = false;
|
||||
|
||||
var oldState = states[_currentIndex];
|
||||
|
||||
// This will all get set in the for loop
|
||||
State newState = oldState;
|
||||
int newIndex = _currentIndex;
|
||||
AstroObject primaryBody = null;
|
||||
OrbitalParameters orbitalParams = null;
|
||||
|
||||
// The QM tries to switch 10 times so we'll do that too
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
newIndex = _currentIndex;
|
||||
while (newIndex == _currentIndex)
|
||||
{
|
||||
newIndex = Random.Range(0, states.Count);
|
||||
}
|
||||
|
||||
newState = states[newIndex];
|
||||
|
||||
// Figure out what the new orbit will be if we switch
|
||||
var newOrbit = newState.orbit ?? groundState.orbit;
|
||||
newOrbit.TrueAnomaly = Random.Range(0f, 360f);
|
||||
|
||||
primaryBody = AstroObjectLocator.GetAstroObject(newOrbit.PrimaryBody);
|
||||
var primaryGravity = new Gravity(primaryBody.GetGravityVolume());
|
||||
var secondaryGravity = new Gravity(_astroObject.GetGravityVolume());
|
||||
orbitalParams = newOrbit.GetOrbitalParameters(primaryGravity, secondaryGravity);
|
||||
|
||||
var pos = primaryBody.transform.position + orbitalParams.InitialPosition;
|
||||
|
||||
// See if we can switch, so we move the visibility tracker to the new position
|
||||
_visibilityTrackers[0].transform.position = pos;
|
||||
|
||||
// Only if not seen
|
||||
if (!CheckVisibilityInstantly())
|
||||
{
|
||||
canChange = true;
|
||||
|
||||
// Since we were able to change states we break
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(canChange)
|
||||
{
|
||||
if (newState.sector != null && newState.sector != oldState.sector) SetNewSector(oldState, newState);
|
||||
if (newState.orbit != null && newState.orbit != oldState.orbit) SetNewOrbit(primaryBody, orbitalParams);
|
||||
|
||||
_currentIndex = newIndex;
|
||||
}
|
||||
|
||||
// Be completely sure we move the visibility tracker back to our planet
|
||||
_visibilityTrackers[0].transform.localPosition = Vector3.zero;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void SetNewSector(State oldState, State newState)
|
||||
{
|
||||
oldState.sector.gameObject.SetActive(false);
|
||||
newState.sector.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
private void SetNewOrbit(AstroObject primaryBody, OrbitalParameters orbitalParameters)
|
||||
{
|
||||
|
||||
|
||||
_astroObject._primaryBody = primaryBody;
|
||||
DetectorBuilder.SetDetector(primaryBody, _astroObject, _detector);
|
||||
if (_alignment != null) _alignment.SetTargetBody(primaryBody.GetComponent<OWRigidbody>());
|
||||
|
||||
PlanetCreationHandler.UpdatePosition(gameObject, orbitalParameters, primaryBody, _astroObject);
|
||||
|
||||
if (!Physics.autoSyncTransforms)
|
||||
{
|
||||
Physics.SyncTransforms();
|
||||
}
|
||||
|
||||
_rb.SetVelocity(orbitalParameters.InitialVelocity);
|
||||
}
|
||||
|
||||
private void OnPlayerBlink()
|
||||
{
|
||||
if (base.IsVisible())
|
||||
{
|
||||
base.Collapse(true);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsPlayerEntangled()
|
||||
{
|
||||
return states[_currentIndex].sector.ContainsAnyOccupants(DynamicOccupant.Player);
|
||||
}
|
||||
|
||||
public class State
|
||||
{
|
||||
public Sector sector { get; set; }
|
||||
public OrbitModule orbit { get; set; }
|
||||
|
||||
public State(Sector sector, OrbitModule orbit)
|
||||
{
|
||||
this.sector = sector;
|
||||
this.orbit = orbit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
8
NewHorizons/External/AtmosphereModule.cs
vendored
8
NewHorizons/External/AtmosphereModule.cs
vendored
@ -25,5 +25,13 @@ namespace NewHorizons.External
|
||||
public bool HasOxygen { get; set; }
|
||||
public bool HasAtmosphere { get; set; }
|
||||
public MColor AtmosphereTint { get; set; }
|
||||
|
||||
public class AirInfo
|
||||
{
|
||||
public float Scale { get; set; }
|
||||
public bool HasOxygen { get; set; }
|
||||
public bool IsRaining { get; set; }
|
||||
public bool IsSnowing { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@ namespace NewHorizons.External.Configs
|
||||
string[] ChildrenToDestroy { get; }
|
||||
int BuildPriority { get; }
|
||||
bool CanShowOnTitle { get; }
|
||||
bool IsQuantumState { get; }
|
||||
BaseModule Base { get; }
|
||||
AtmosphereModule Atmosphere { get; }
|
||||
OrbitModule Orbit { get; }
|
||||
|
||||
1
NewHorizons/External/Configs/PlanetConfig.cs
vendored
1
NewHorizons/External/Configs/PlanetConfig.cs
vendored
@ -14,6 +14,7 @@ namespace NewHorizons.External.Configs
|
||||
public string[] ChildrenToDestroy { get; set; }
|
||||
public int BuildPriority { get; set; } = -1;
|
||||
public bool CanShowOnTitle { get; set; } = true;
|
||||
public bool IsQuantumState { get; set; }
|
||||
public BaseModule Base { get; set; }
|
||||
public AtmosphereModule Atmosphere { get; set; }
|
||||
public OrbitModule Orbit { get; set; }
|
||||
|
||||
@ -14,5 +14,6 @@ namespace NewHorizons.External.VariableSize
|
||||
public string TargetStarSystem;
|
||||
public string Type; //BlackHole or WhiteHole
|
||||
public MVector3 Position;
|
||||
public bool MakeZeroGVolume = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ using NewHorizons.Builder.Orbital;
|
||||
using NewHorizons.Builder.Props;
|
||||
using NewHorizons.Components;
|
||||
using NewHorizons.Components.Orbital;
|
||||
using NewHorizons.External;
|
||||
using NewHorizons.External.VariableSize;
|
||||
using NewHorizons.Utility;
|
||||
using System;
|
||||
@ -20,13 +21,18 @@ namespace NewHorizons.Handlers
|
||||
public static class PlanetCreationHandler
|
||||
{
|
||||
public static List<NewHorizonsBody> NextPassBodies = new List<NewHorizonsBody>();
|
||||
|
||||
// I literally forget what this is for
|
||||
private static Dictionary<AstroObject, NewHorizonsBody> ExistingAOConfigs;
|
||||
|
||||
private static Dictionary<NHAstroObject, NewHorizonsBody> _dict;
|
||||
|
||||
public static void Init(List<NewHorizonsBody> bodies)
|
||||
{
|
||||
Main.FurthestOrbit = 30000;
|
||||
|
||||
ExistingAOConfigs = new Dictionary<AstroObject, NewHorizonsBody>();
|
||||
_dict = new Dictionary<NHAstroObject, NewHorizonsBody>();
|
||||
|
||||
// Set up stars
|
||||
// Need to manage this when there are multiple stars
|
||||
@ -119,15 +125,15 @@ namespace NewHorizons.Handlers
|
||||
Logger.Log("Done loading bodies");
|
||||
|
||||
// I don't know what these do but they look really weird from a distance
|
||||
Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(PlanetDestroyer.RemoveAllProxies);
|
||||
Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(PlanetDestructionHandler.RemoveAllProxies);
|
||||
|
||||
if (Main.SystemDict[Main.Instance.CurrentStarSystem].Config.destroyStockPlanets) PlanetDestroyer.RemoveSolarSystem();
|
||||
if (Main.SystemDict[Main.Instance.CurrentStarSystem].Config.destroyStockPlanets) PlanetDestructionHandler.RemoveSolarSystem();
|
||||
}
|
||||
|
||||
public static bool LoadBody(NewHorizonsBody body, bool defaultPrimaryToSun = false)
|
||||
{
|
||||
// I don't remember doing this why is it exceptions what am I doing
|
||||
GameObject existingPlanet = null;
|
||||
GameObject existingPlanet = null;
|
||||
try
|
||||
{
|
||||
existingPlanet = AstroObjectLocator.GetAstroObject(body.Config.Name).gameObject;
|
||||
@ -145,10 +151,52 @@ namespace NewHorizons.Handlers
|
||||
if (body.Config.Destroy)
|
||||
{
|
||||
var ao = existingPlanet.GetComponent<AstroObject>();
|
||||
if (ao != null) Main.Instance.ModHelper.Events.Unity.FireInNUpdates(() => PlanetDestroyer.RemoveBody(ao), 2);
|
||||
if (ao != null) Main.Instance.ModHelper.Events.Unity.FireInNUpdates(() => PlanetDestructionHandler.RemoveBody(ao), 2);
|
||||
else Main.Instance.ModHelper.Events.Unity.FireInNUpdates(() => existingPlanet.SetActive(false), 2);
|
||||
}
|
||||
else UpdateBody(body, existingPlanet);
|
||||
else if (body.Config.IsQuantumState)
|
||||
{
|
||||
var quantumPlanet = existingPlanet.GetComponent<QuantumPlanet>();
|
||||
if (quantumPlanet == null)
|
||||
{
|
||||
// Have to also add the root orbit and sector
|
||||
quantumPlanet = existingPlanet.AddComponent<QuantumPlanet>();
|
||||
var ao = quantumPlanet.GetComponent<NHAstroObject>();
|
||||
|
||||
var rootSector = quantumPlanet.GetComponentInChildren<Sector>();
|
||||
var groundOrbit = _dict[ao].Config.Orbit;
|
||||
|
||||
quantumPlanet.groundState = new QuantumPlanet.State(rootSector, groundOrbit);
|
||||
quantumPlanet.states.Add(quantumPlanet.groundState);
|
||||
|
||||
var visibilityTracker = new GameObject("VisibilityTracker_Sphere");
|
||||
visibilityTracker.transform.parent = existingPlanet.transform;
|
||||
visibilityTracker.transform.localPosition = Vector3.zero;
|
||||
var sphere = visibilityTracker.AddComponent<SphereShape>();
|
||||
sphere.radius = GetSphereOfInfluence(_dict[ao]);
|
||||
var tracker = visibilityTracker.AddComponent<ShapeVisibilityTracker>();
|
||||
quantumPlanet._visibilityTrackers = new VisibilityTracker[] { tracker };
|
||||
}
|
||||
|
||||
var rb = existingPlanet.GetComponent<OWRigidbody>();
|
||||
|
||||
var sector = MakeSector.Make(existingPlanet, rb, GetSphereOfInfluence(body));
|
||||
sector.name = $"Sector-{existingPlanet.GetComponents<Sector>().Count()}";
|
||||
|
||||
SharedGenerateBody(body, existingPlanet, sector, rb);
|
||||
|
||||
// If nothing was generated then forget the sector
|
||||
if (sector.transform.childCount == 0) sector = quantumPlanet.groundState.sector;
|
||||
|
||||
// If semimajor axis is 0 then forget the orbit
|
||||
var orbit = body.Config.Orbit.SemiMajorAxis == 0 ? quantumPlanet.groundState.orbit : body.Config.Orbit;
|
||||
|
||||
quantumPlanet.states.Add(new QuantumPlanet.State(sector, orbit));
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateBody(body, existingPlanet);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -158,16 +206,25 @@ namespace NewHorizons.Handlers
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
if(body.Config.IsQuantumState)
|
||||
{
|
||||
GameObject planetObject = GenerateBody(body, defaultPrimaryToSun);
|
||||
if (planetObject == null) return false;
|
||||
planetObject.SetActive(true);
|
||||
// If the ground state object isn't made yet do it later
|
||||
NextPassBodies.Add(body);
|
||||
}
|
||||
catch (Exception e)
|
||||
else
|
||||
{
|
||||
Logger.LogError($"Couldn't generate body {body.Config?.Name}: {e.Message}, {e.StackTrace}");
|
||||
return false;
|
||||
try
|
||||
{
|
||||
GameObject planetObject = GenerateBody(body, defaultPrimaryToSun);
|
||||
if (planetObject == null) return false;
|
||||
planetObject.SetActive(true);
|
||||
_dict.Add(planetObject.GetComponent<NHAstroObject>(), body);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError($"Couldn't generate body {body.Config?.Name}: {e.Message}, {e.StackTrace}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@ -230,22 +287,19 @@ namespace NewHorizons.Handlers
|
||||
var go = new GameObject(body.Config.Name.Replace(" ", "").Replace("'", "") + "_Body");
|
||||
go.SetActive(false);
|
||||
|
||||
if (body.Config.Base.GroundSize != 0)
|
||||
{
|
||||
GeometryBuilder.Make(go, body.Config.Base.GroundSize);
|
||||
}
|
||||
|
||||
var atmoSize = body.Config.Atmosphere != null ? body.Config.Atmosphere.Size : 0f;
|
||||
float sphereOfInfluence = Mathf.Max(Mathf.Max(atmoSize, 50), body.Config.Base.SurfaceSize * 2f);
|
||||
var overrideSOI = body.Config.Base.SphereOfInfluence;
|
||||
if (overrideSOI != 0)
|
||||
{
|
||||
sphereOfInfluence = overrideSOI;
|
||||
}
|
||||
|
||||
var owRigidBody = RigidBodyBuilder.Make(go, body.Config);
|
||||
var ao = AstroObjectBuilder.Make(go, primaryBody, body.Config);
|
||||
|
||||
var sphereOfInfluence = GetSphereOfInfluence(body);
|
||||
|
||||
var sector = MakeSector.Make(go, owRigidBody, sphereOfInfluence * 2f);
|
||||
ao._rootSector = sector;
|
||||
|
||||
if (body.Config.Base.GroundSize != 0)
|
||||
{
|
||||
GeometryBuilder.Make(go, sector, body.Config.Base.GroundSize);
|
||||
}
|
||||
|
||||
if (body.Config.Base.SurfaceGravity != 0)
|
||||
{
|
||||
GravityBuilder.Make(go, ao, body.Config);
|
||||
@ -263,22 +317,19 @@ namespace NewHorizons.Handlers
|
||||
|
||||
if (body.Config.Base.HasAmbientLight)
|
||||
{
|
||||
AmbientLightBuilder.Make(go, sphereOfInfluence);
|
||||
AmbientLightBuilder.Make(go, sector, sphereOfInfluence);
|
||||
}
|
||||
|
||||
var sector = MakeSector.Make(go, owRigidBody, sphereOfInfluence * 2f);
|
||||
ao._rootSector = sector;
|
||||
|
||||
VolumesBuilder.Make(go, body.Config.Base.SurfaceSize, sphereOfInfluence, body.Config);
|
||||
VolumesBuilder.Make(go, body.Config.Base.SurfaceSize, sphereOfInfluence, !body.Config.Base.IsSatellite);
|
||||
|
||||
if (body.Config.HeightMap != null)
|
||||
{
|
||||
HeightMapBuilder.Make(go, body.Config.HeightMap, body.Mod);
|
||||
HeightMapBuilder.Make(go, sector, body.Config.HeightMap, body.Mod);
|
||||
}
|
||||
|
||||
if (body.Config.ProcGen != null)
|
||||
{
|
||||
ProcGenBuilder.Make(go, body.Config.ProcGen);
|
||||
ProcGenBuilder.Make(go, sector, body.Config.ProcGen);
|
||||
}
|
||||
|
||||
if (body.Config.Star != null)
|
||||
@ -297,7 +348,7 @@ namespace NewHorizons.Handlers
|
||||
body.Object = go;
|
||||
|
||||
// Now that we're done move the planet into place
|
||||
UpdatePosition(go, body, primaryBody, ao);
|
||||
UpdatePosition(go, body.Config.Orbit, primaryBody, ao);
|
||||
|
||||
// Have to do this after setting position
|
||||
var initialMotion = InitialMotionBuilder.Make(go, primaryBody, ao, owRigidBody, body.Config.Orbit);
|
||||
@ -327,16 +378,25 @@ namespace NewHorizons.Handlers
|
||||
return go;
|
||||
}
|
||||
|
||||
private static float GetSphereOfInfluence(NewHorizonsBody body)
|
||||
{
|
||||
var atmoSize = body.Config.Atmosphere != null ? body.Config.Atmosphere.Size : 0f;
|
||||
float sphereOfInfluence = Mathf.Max(Mathf.Max(atmoSize, 50), body.Config.Base.SurfaceSize * 2f);
|
||||
var overrideSOI = body.Config.Base.SphereOfInfluence;
|
||||
if (overrideSOI != 0) sphereOfInfluence = overrideSOI;
|
||||
return sphereOfInfluence;
|
||||
}
|
||||
|
||||
private static GameObject SharedGenerateBody(NewHorizonsBody body, GameObject go, Sector sector, OWRigidbody rb)
|
||||
{
|
||||
if (body.Config.Ring != null)
|
||||
RingBuilder.Make(go, body.Config.Ring, body.Mod);
|
||||
RingBuilder.Make(go, sector, body.Config.Ring, body.Mod);
|
||||
|
||||
if (body.Config.AsteroidBelt != null)
|
||||
AsteroidBeltBuilder.Make(body.Config.Name, body.Config, body.Mod);
|
||||
|
||||
if (body.Config.Base.HasCometTail)
|
||||
CometTailBuilder.Make(go, body.Config, go.GetComponent<AstroObject>().GetPrimaryBody());
|
||||
CometTailBuilder.Make(go, sector, body.Config, go.GetComponent<AstroObject>().GetPrimaryBody());
|
||||
|
||||
// Backwards compatability
|
||||
if (body.Config.Base.LavaSize != 0)
|
||||
@ -366,21 +426,31 @@ namespace NewHorizons.Handlers
|
||||
|
||||
if (body.Config.Atmosphere != null)
|
||||
{
|
||||
AirBuilder.Make(go, body.Config.Atmosphere.Size, body.Config.Atmosphere.HasRain, body.Config.Atmosphere.HasOxygen);
|
||||
var airInfo = new AtmosphereModule.AirInfo()
|
||||
{
|
||||
HasOxygen = body.Config.Atmosphere.HasOxygen,
|
||||
IsRaining = body.Config.Atmosphere.HasRain,
|
||||
IsSnowing = body.Config.Atmosphere.HasSnow,
|
||||
Scale = body.Config.Atmosphere.Size
|
||||
};
|
||||
|
||||
var surfaceSize = body.Config.Base.SurfaceSize;
|
||||
|
||||
AirBuilder.Make(go, sector, airInfo);
|
||||
|
||||
if (body.Config.Atmosphere.Cloud != null)
|
||||
{
|
||||
CloudsBuilder.Make(go, sector, body.Config.Atmosphere, body.Mod);
|
||||
SunOverrideBuilder.Make(go, sector, body.Config.Base.SurfaceSize, body.Config.Atmosphere);
|
||||
SunOverrideBuilder.Make(go, sector, body.Config.Atmosphere, surfaceSize);
|
||||
}
|
||||
|
||||
if (body.Config.Atmosphere.HasRain || body.Config.Atmosphere.HasSnow)
|
||||
EffectsBuilder.Make(go, sector, body.Config.Base.SurfaceSize, body.Config.Atmosphere.Size, body.Config.Atmosphere.HasRain, body.Config.Atmosphere.HasSnow);
|
||||
EffectsBuilder.Make(go, sector, airInfo, surfaceSize);
|
||||
|
||||
if (body.Config.Atmosphere.FogSize != 0)
|
||||
FogBuilder.Make(go, sector, body.Config.Atmosphere);
|
||||
|
||||
AtmosphereBuilder.Make(go, body.Config.Atmosphere, body.Config.Base.SurfaceSize);
|
||||
AtmosphereBuilder.Make(go, sector, body.Config.Atmosphere, surfaceSize);
|
||||
}
|
||||
|
||||
if (body.Config.Props != null)
|
||||
@ -465,7 +535,7 @@ namespace NewHorizons.Handlers
|
||||
}
|
||||
|
||||
// Move the primary
|
||||
UpdatePosition(go, body, primary, newAO);
|
||||
UpdatePosition(go, body.Config.Orbit, primary, newAO);
|
||||
|
||||
for (int i = 0; i < children.Count(); i++)
|
||||
{
|
||||
@ -512,7 +582,7 @@ namespace NewHorizons.Handlers
|
||||
return;
|
||||
}
|
||||
|
||||
private static void UpdatePosition(GameObject go, NewHorizonsBody body, AstroObject primaryBody, AstroObject secondaryBody)
|
||||
public static void UpdatePosition(GameObject go, IOrbitalParameters orbit, AstroObject primaryBody, AstroObject secondaryBody)
|
||||
{
|
||||
Logger.Log($"Placing [{secondaryBody?.name}] around [{primaryBody?.name}]");
|
||||
|
||||
@ -521,9 +591,7 @@ namespace NewHorizons.Handlers
|
||||
if (primaryBody != null)
|
||||
{
|
||||
var primaryGravity = new Gravity(primaryBody.GetGravityVolume());
|
||||
var secondaryGravity = new Gravity(secondaryBody.GetGravityVolume());
|
||||
|
||||
var orbit = body.Config.Orbit;
|
||||
var secondaryGravity = new Gravity(secondaryBody.GetGravityVolume());;
|
||||
|
||||
go.transform.position = orbit.GetOrbitalParameters(primaryGravity, secondaryGravity).InitialPosition + primaryBody.transform.position;
|
||||
}
|
||||
|
||||
@ -9,9 +9,9 @@ using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using Logger = NewHorizons.Utility.Logger;
|
||||
|
||||
namespace NewHorizons.Builder.General
|
||||
namespace NewHorizons.Handlers
|
||||
{
|
||||
static class PlanetDestroyer
|
||||
public static class PlanetDestructionHandler
|
||||
{
|
||||
private static readonly string[] _solarSystemBodies = new string[]
|
||||
{
|
||||
@ -85,7 +85,7 @@ namespace NewHorizons.Handlers
|
||||
heightMap.TextureMap = body.Config.Atmosphere.Cloud;
|
||||
}
|
||||
|
||||
HeightMapBuilder.Make(titleScreenGO, heightMap, body.Mod);
|
||||
HeightMapBuilder.Make(titleScreenGO, null, heightMap, body.Mod);
|
||||
|
||||
GameObject pivot = GameObject.Instantiate(GameObject.Find("Scene/Background/PlanetPivot"), GameObject.Find("Scene/Background").transform);
|
||||
pivot.GetComponent<RotateTransform>()._degreesPerSecond = 10f;
|
||||
@ -101,7 +101,7 @@ namespace NewHorizons.Handlers
|
||||
newRing.InnerRadius = size * 1.2f;
|
||||
newRing.OuterRadius = size * 2f;
|
||||
newRing.Texture = body.Config.Ring.Texture;
|
||||
var ring = RingBuilder.Make(titleScreenGO, newRing, body.Mod);
|
||||
var ring = RingBuilder.Make(titleScreenGO, null, newRing, body.Mod);
|
||||
titleScreenGO.transform.localScale = Vector3.one * 0.8f;
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
namespace NewHorizons.Utility
|
||||
{
|
||||
static class AddDebugShape
|
||||
public static class AddDebugShape
|
||||
{
|
||||
public static GameObject AddSphere(GameObject obj, float radius, Color color)
|
||||
{
|
||||
|
||||
@ -6,7 +6,7 @@ using UnityEngine;
|
||||
|
||||
namespace NewHorizons.Utility
|
||||
{
|
||||
static class ImageUtilities
|
||||
public static class ImageUtilities
|
||||
{
|
||||
private static Dictionary<string, Texture2D> _loadedTextures = new Dictionary<string, Texture2D>();
|
||||
private static List<Texture2D> _generatedTextures = new List<Texture2D>();
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
namespace NewHorizons.Utility
|
||||
{
|
||||
class MakeMeshDoubleFaced : MonoBehaviour
|
||||
public class MakeMeshDoubleFaced : MonoBehaviour
|
||||
{
|
||||
private void Start()
|
||||
{
|
||||
|
||||
@ -936,7 +936,7 @@
|
||||
},
|
||||
"normal": {
|
||||
"$ref": "#/$defs/vector3",
|
||||
"description": "The normal vector for this object. Only used for writing on walls to orient it properly."
|
||||
"description": "The normal vector for this object. Used for writing on walls and positioning computers."
|
||||
},
|
||||
"rotation": {
|
||||
"$ref": "#/$defs/vector3",
|
||||
@ -1166,6 +1166,11 @@
|
||||
},
|
||||
"position": {
|
||||
"$ref": "#/$defs/vector3"
|
||||
},
|
||||
"makeZeroGVolume": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "Only for White Holes. Should this white hole repel the player from it."
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user