Skip to content

Commit

Permalink
1.11.0 (#576)
Browse files Browse the repository at this point in the history
## Major features
- Heightmap overhaul!
  - Normal maps (bump maps)
  - Smoothness (gloss) and metallic maps
- Tiling versions of texture/normal/smoothness/metallic maps for finer
up-close detail
- Blend map that uses the red, green, blue, and alpha channels to
control the distribution of 4 tiles respectively, plus a fifth "base"
tile that appears where the others are absent.
  - Stretch has changed to proper unity coordinates, where y is up.

## Minor features
- New `CometTail` module replacing the `hasCometTail` field. Allows
customizing the colour and scale-over-time of a comet tail.

## Improvements
- Patched forget frequency method so it will work for those using it on
custom signals
- Added `teenager` arc type to translator text. This is a mix between
child and adult. It uses the adult mesh but the child texture.
Originally used at the window text on Giant's Deep's statue island.
- Generated textures are now cached. this should reduce memory usage
(resolves #581)
- Textures are named by file path and then the effects applied to them,
for example `[path] > invert > tint [color]`
- Physics details splash in water like the probe and have the probe's
buoyancy.

## Bug fixes
- Fixed NullReferenceException when spawning vessels with physics
- Fixed SpawnDialogue API method always creating a remote trigger
- Physics details are now affected by tornadoes (resolves #580)
- Stretch now behaves more intuitively (does not divide min/max height
by the largest stretch axis) (resolves #551)
- Fix spamming logs with "Fact ID Not Found" on system change (resolves
#586)
  • Loading branch information
JohnCorby committed May 7, 2023
2 parents a7d60a4 + f3fd47d commit 0e0f345
Show file tree
Hide file tree
Showing 94 changed files with 1,121 additions and 526 deletions.
Binary file modified NewHorizons/Assets/newhorizons_public
Binary file not shown.
6 changes: 3 additions & 3 deletions NewHorizons/Assets/newhorizons_public.manifest
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
ManifestFileVersion: 0
CRC: 1013046168
CRC: 1613957014
Hashes:
AssetFileHash:
serializedVersion: 2
Hash: 0123e044c220152b98ceaf0975b8cadd
Hash: 9b2f376d4639a3fa789eadaf132f9889
TypeTreeHash:
serializedVersion: 2
Hash: 10a6a558690295dadb3dd990eda0821a
Expand All @@ -17,7 +17,7 @@ SerializeReferenceClassIdentifiers: []
Assets:
- Assets/Shaders/SphereTextureWrapper.shader
- Assets/Shaders/Ring.shader
- Assets/Shaders/SphereTextureWrapperNormal.shader
- Assets/Shaders/SphereTextureWrapperTriplanar.shader
- Assets/Shaders/UnlitRing1Pixel.shader
- Assets/Shaders/UnlitTransparent.shader
- Assets/Resources/TransparentCloud.mat
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added NewHorizons/Assets/textures/Effects_CO_GasTail_d.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions NewHorizons/Builder/Atmosphere/AtmosphereBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ internal static void InitPrefabs()
_isInit = true;

if (_atmospherePrefab == null) _atmospherePrefab = SearchUtilities.Find("TimberHearth_Body/Atmosphere_TH/AtmoSphere").InstantiateInactive().Rename("Atmosphere").DontDestroyOnLoad();
if (_proxyAtmospherePrefab == null) _proxyAtmospherePrefab = GameObject.FindObjectOfType<DistantProxyManager>()._proxies.FirstOrDefault(apt => apt.astroName == AstroObject.Name.TimberHearth).proxyPrefab.FindChild("Atmosphere_TH/Atmosphere_LOD3").InstantiateInactive().Rename("ProxyAtmosphere").DontDestroyOnLoad();
if (_proxyAtmospherePrefab == null) _proxyAtmospherePrefab = Object.FindObjectOfType<DistantProxyManager>()._proxies.FirstOrDefault(apt => apt.astroName == AstroObject.Name.TimberHearth).proxyPrefab.FindChild("Atmosphere_TH/Atmosphere_LOD3").InstantiateInactive().Rename("ProxyAtmosphere").DontDestroyOnLoad();
}

public static GameObject Make(GameObject planetGO, Sector sector, AtmosphereModule atmosphereModule, float surfaceSize, bool proxy = false)
Expand All @@ -48,7 +48,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, AtmosphereModu

if (prefab != null)
{
GameObject atmo = GameObject.Instantiate(prefab, atmoGO.transform);
GameObject atmo = Object.Instantiate(prefab, atmoGO.transform);
atmo.name = "Atmosphere";
atmo.transform.localPosition = Vector3.zero;
atmo.transform.localEulerAngles = Vector3.zero;
Expand Down
1 change: 1 addition & 0 deletions NewHorizons/Builder/Atmosphere/CloudsBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NewHorizons.Components;
using NewHorizons.Components.Sectored;
using NewHorizons.External.Modules;
using NewHorizons.Utility;
using NewHorizons.Utility.Files;
Expand Down
4 changes: 2 additions & 2 deletions NewHorizons/Builder/Atmosphere/EffectsBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static void Make(GameObject planetGO, Sector sector, PlanetConfig config,

if (config.Atmosphere.hasRain)
{
var rainGO = GameObject.Instantiate(_rainEmitterPrefab, effectsGO.transform);
var rainGO = Object.Instantiate(_rainEmitterPrefab, effectsGO.transform);
rainGO.name = "RainEmitter";
rainGO.transform.position = planetGO.transform.position;

Expand All @@ -74,7 +74,7 @@ public static void Make(GameObject planetGO, Sector sector, PlanetConfig config,
snowGO.transform.position = planetGO.transform.position;
for (int i = 0; i < 5; i++)
{
var snowEmitter = GameObject.Instantiate(_snowEmitterPrefab, snowGO.transform);
var snowEmitter = Object.Instantiate(_snowEmitterPrefab, snowGO.transform);
snowEmitter.name = "SnowEmitter";
snowEmitter.transform.position = planetGO.transform.position;

Expand Down
6 changes: 3 additions & 3 deletions NewHorizons/Builder/Body/BrambleDimensionBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using NewHorizons.Builder.Props;
using NewHorizons.Components;
using NewHorizons.Components.Orbital;
using NewHorizons.Components.Sectored;
using NewHorizons.External;
using NewHorizons.External.Modules;
using NewHorizons.External.Modules.Props;
Expand Down Expand Up @@ -134,11 +134,11 @@ public static GameObject Make(NewHorizonsBody body, GameObject go, NHAstroObject
if (config.vinePrefab == VinePrefabType.None)
{
// Replace batched collision with our own if removing vines
GameObject.Destroy(geometry.FindChild("BatchedGroup"));
Object.Destroy(geometry.FindChild("BatchedGroup"));
var geoOtherComponentsGroup = geometry.FindChild("OtherComponentsGroup");
var dimensionWalls = geoOtherComponentsGroup.FindChild("Terrain_DB_BrambleSphere_Outer_v2");
dimensionWalls.transform.parent = geometry.transform;
GameObject.Destroy(geoOtherComponentsGroup);
Object.Destroy(geoOtherComponentsGroup);

var newCollider = _wallCollision.InstantiateInactive();
newCollider.transform.parent = dimensionWalls.transform;
Expand Down
6 changes: 3 additions & 3 deletions NewHorizons/Builder/Body/CloakBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using NewHorizons.Components;
using NewHorizons.Components.Sectored;
using NewHorizons.External.Modules;
using NewHorizons.Utility;
using NewHorizons.Utility.Files;
Expand Down Expand Up @@ -36,12 +36,12 @@ public static void Make(GameObject planetGO, Sector sector, OWRigidbody OWRB, Cl

var radius = module.radius;

var newCloak = GameObject.Instantiate(_prefab, sector?.transform ?? planetGO.transform);
var newCloak = Object.Instantiate(_prefab, sector?.transform ?? planetGO.transform);
newCloak.transform.position = planetGO.transform.position;
newCloak.transform.name = "CloakingField";
newCloak.transform.localScale = Vector3.one * radius;

GameObject.Destroy(newCloak.GetComponent<PlayerCloakEntryRedirector>());
Object.Destroy(newCloak.GetComponent<PlayerCloakEntryRedirector>());

var cloakFieldController = newCloak.GetComponent<CloakFieldController>();
cloakFieldController._cloakScaleDist = radius * 2000 / 3000f;
Expand Down
120 changes: 108 additions & 12 deletions NewHorizons/Builder/Body/CometTailBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,32 +1,128 @@
using NewHorizons.Components.SizeControllers;
using NewHorizons.External.Configs;
using NewHorizons.External.Modules;
using NewHorizons.Utility;
using NewHorizons.Utility.Files;
using NewHorizons.Utility.OuterWilds;
using NewHorizons.Utility.OWML;
using UnityEngine;

namespace NewHorizons.Builder.Body
{
public static class CometTailBuilder
{
private static GameObject _tailPrefab;
private static GameObject _dustPrefab;
private static GameObject _gasPrefab;

internal static void InitPrefab()
{
if (_tailPrefab == null) _tailPrefab = SearchUtilities.Find("Comet_Body/Sector_CO/Effects_CO/Effects_CO_TailMeshes").InstantiateInactive().Rename("Prefab_CO_Tail").DontDestroyOnLoad();
if (_dustPrefab == null)
{
_dustPrefab = new GameObject("Prefab_CO_Dust").DontDestroyOnLoad();

var dust1 = SearchUtilities.Find("Comet_Body/Sector_CO/Effects_CO/Effects_CO_TailMeshes/Effects_CO_DustTail").Instantiate();
dust1.transform.parent = _dustPrefab.transform;
dust1.transform.localPosition = Vector3.zero;
dust1.transform.localRotation = Quaternion.Euler(0, 270, 0);

var dust2 = SearchUtilities.Find("Comet_Body/Sector_CO/Effects_CO/Effects_CO_TailMeshes/Effects_CO_DustTail (1)").Instantiate();
dust2.transform.parent = _dustPrefab.transform;
dust2.transform.localPosition = Vector3.zero;
dust2.transform.localRotation = Quaternion.Euler(0, 270, 0);

var dust3 = SearchUtilities.Find("Comet_Body/Sector_CO/Effects_CO/Effects_CO_TailMeshes/Effects_CO_DustTail (2)").Instantiate();
dust3.transform.parent = _dustPrefab.transform;
dust3.transform.localPosition = Vector3.zero;
dust3.transform.localRotation = Quaternion.Euler(0, 270, 0);

_dustPrefab.SetActive(false);
}
if (_gasPrefab == null)
{
_gasPrefab = new GameObject("Prefab_CO_Gas").DontDestroyOnLoad();

var gas1 = SearchUtilities.Find("Comet_Body/Sector_CO/Effects_CO/Effects_CO_TailMeshes/Effects_CO_GasTail").Instantiate();
gas1.transform.parent = _gasPrefab.transform;
gas1.transform.localPosition = Vector3.zero;
gas1.transform.localRotation = Quaternion.Euler(0, 270, 0);

var gas2 = SearchUtilities.Find("Comet_Body/Sector_CO/Effects_CO/Effects_CO_TailMeshes/Effects_CO_GasTail (1)").Instantiate();
gas2.transform.parent = _gasPrefab.transform;
gas2.transform.localPosition = Vector3.zero;
gas2.transform.localRotation = Quaternion.Euler(0, 270, 0);

var gas3 = SearchUtilities.Find("Comet_Body/Sector_CO/Effects_CO/Effects_CO_TailMeshes/Effects_CO_GasTail (2)").Instantiate();
gas3.transform.parent = _gasPrefab.transform;
gas3.transform.localPosition = Vector3.zero;
gas3.transform.localRotation = Quaternion.Euler(0, 270, 0);

_gasPrefab.SetActive(false);
}
}

public static void Make(GameObject planetGO, Sector sector, PlanetConfig config)
public static void Make(GameObject planetGO, Sector sector, CometTailModule cometTailModule, PlanetConfig config)
{
InitPrefab();
if (config.Orbit.primaryBody == null)
{
NHLogger.LogError($"Comet {planetGO.name} does not orbit anything. That makes no sense");
return;
}

var rootObj = new GameObject("CometRoot");
rootObj.SetActive(false);
rootObj.transform.parent = sector?.transform ?? planetGO.transform;
rootObj.transform.localPosition = Vector3.zero;

var controller = rootObj.AddComponent<CometTailController>();

controller.size = (cometTailModule.innerRadius ?? config.Base.surfaceSize) / 110;

if (cometTailModule.rotationOverride != null) controller.SetRotationOverride(cometTailModule.rotationOverride);

if (string.IsNullOrEmpty(cometTailModule.primaryBody)) cometTailModule.primaryBody = config.Orbit.primaryBody;

Delay.FireOnNextUpdate(() =>
{
controller.SetPrimaryBody(
AstroObjectLocator.GetAstroObject(cometTailModule.primaryBody).transform,
AstroObjectLocator.GetAstroObject(config.Orbit.primaryBody).GetAttachedOWRigidbody()
);
});

controller.SetScaleCurve(cometTailModule.curve);

var dustTail = Object.Instantiate(_dustPrefab, rootObj.transform).Rename("DustTail");
dustTail.transform.localPosition = Vector3.zero;
dustTail.transform.localRotation = Quaternion.Euler(90, 90, 0);
dustTail.SetActive(true);
controller.dustTail = dustTail;

var cometTail = GameObject.Instantiate(_tailPrefab, sector?.transform ?? planetGO.transform);
cometTail.transform.position = planetGO.transform.position;
cometTail.name = "CometTail";
cometTail.transform.localScale = Vector3.one * config.Base.surfaceSize / 110;
var gasTail = Object.Instantiate(_gasPrefab, rootObj.transform).Rename("GasTail");
gasTail.transform.localPosition = Vector3.zero;
gasTail.transform.localRotation = Quaternion.Euler(90, 90, 0);
gasTail.SetActive(true);
controller.gasTail = gasTail;

Vector3 alignment = new Vector3(0, 270, 90);
if (config.Base.cometTailRotation != null) alignment = config.Base.cometTailRotation;
if (cometTailModule.dustTint != null)
{
foreach (var dust in dustTail.GetComponentsInChildren<MeshRenderer>())
{
var untintedDust = ImageUtilities.GetTexture(Main.Instance, "Assets/textures/Effects_CO_DustTail_d.png");
dust.material.mainTexture = ImageUtilities.TintImage(untintedDust, cometTailModule.dustTint.ToColor());
}
}

cometTail.transform.rotation = Quaternion.Euler(alignment);
if (cometTailModule.gasTint != null)
{
foreach (var gas in gasTail.GetComponentsInChildren<MeshRenderer>())
{
var untintedGas = ImageUtilities.GetTexture(Main.Instance, "Assets/textures/Effects_CO_GasTail_d.png");
gas.material.mainTexture = untintedGas;
gas.material.color = cometTailModule.gasTint.ToColor();
}
}

cometTail.SetActive(true);
rootObj.SetActive(true);
}
}
}
10 changes: 5 additions & 5 deletions NewHorizons/Builder/Body/FunnelBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ public static void Make(GameObject planetGO, Sector sector, OWRigidbody rigidbod
scaleRoot.transform.localPosition = Vector3.zero;
scaleRoot.transform.localScale = new Vector3(1, 1, 1);

var proxyGO = GameObject.Instantiate(_proxySandFunnel, scaleRoot.transform);
var proxyGO = Object.Instantiate(_proxySandFunnel, scaleRoot.transform);
proxyGO.name = "Proxy_Funnel";
proxyGO.SetActive(true);

var geoGO = GameObject.Instantiate(_geoSandFunnel, scaleRoot.transform);
var geoGO = Object.Instantiate(_geoSandFunnel, scaleRoot.transform);
geoGO.name = "Geo_Funnel";
geoGO.SetActive(true);

var volumesGO = GameObject.Instantiate(_volumesSandFunnel, scaleRoot.transform);
var volumesGO = Object.Instantiate(_volumesSandFunnel, scaleRoot.transform);
volumesGO.name = "Volumes_Funnel";
volumesGO.SetActive(true);
var sfv = volumesGO.GetComponentInChildren<SimpleFluidVolume>();
Expand All @@ -90,7 +90,7 @@ public static void Make(GameObject planetGO, Sector sector, OWRigidbody rigidbod
case FunnelType.Water:
sfv._fluidType = FluidVolume.Type.WATER;

GameObject.Destroy(geoGO.transform.Find("Effects_HT_SandColumn/SandColumn_Interior").gameObject);
Object.Destroy(geoGO.transform.Find("Effects_HT_SandColumn/SandColumn_Interior").gameObject);

var waterMaterials = _waterMaterials;
var materials = new Material[waterMaterials.Length];
Expand Down Expand Up @@ -138,7 +138,7 @@ public static void Make(GameObject planetGO, Sector sector, OWRigidbody rigidbod
case FunnelType.Star:
sfv._fluidType = FluidVolume.Type.PLASMA;

GameObject.Destroy(geoGO.transform.Find("Effects_HT_SandColumn/SandColumn_Interior").gameObject);
Object.Destroy(geoGO.transform.Find("Effects_HT_SandColumn/SandColumn_Interior").gameObject);

var lavaMaterial = new Material(_lavaMaterial);
lavaMaterial.mainTextureOffset = new Vector2(0.1f, 0.2f);
Expand Down
19 changes: 1 addition & 18 deletions NewHorizons/Builder/Body/Geometry/CubeSphere.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,6 @@ public static Mesh Build(int resolution, Texture2D heightMap, float minHeight, f
Mesh mesh = new Mesh();
mesh.name = "CubeSphere";

float max = 1;
if (stretch.x > stretch.y && stretch.x > stretch.z)
max = stretch.x;
else if (stretch.y > stretch.x && stretch.y > stretch.z)
max = stretch.y;
else if (stretch.z > stretch.x && stretch.z > stretch.y)
max = stretch.z;
else if (stretch.y == stretch.z && stretch.x > stretch.y)
max = stretch.x;
else if (stretch.x == stretch.z && stretch.y > stretch.x)
max = stretch.y;
else if (stretch.x == stretch.y && stretch.z > stretch.x)
max = stretch.z;
minHeight /= max;
maxHeight /= max;

CreateVertices(mesh, resolution, heightMap, minHeight, maxHeight);
StretchVertices(mesh, stretch);
CreateTriangles(mesh, resolution);
Expand Down Expand Up @@ -124,8 +108,7 @@ private static void SetVertex(Vector3[] vertices, Vector3[] normals, Vector2[] u
v.y = v2.y * Mathf.Sqrt(1f - x2 / 2f - z2 / 2f + x2 * z2 / 3f);
v.z = v2.z * Mathf.Sqrt(1f - x2 / 2f - y2 / 2f + x2 * y2 / 3f);

// The shader uses real coords
var sphericals = CoordinateUtilities.CartesianToSpherical(v, false);
var sphericals = CoordinateUtilities.CartesianToSpherical(v, true);
float longitude = sphericals.x;
float latitude = sphericals.y;

Expand Down

0 comments on commit 0e0f345

Please sign in to comment.