Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.15.0 #712

Merged
merged 36 commits into from
Aug 26, 2023
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
7124015
Vection fields (#219)
MegaPiggy Jul 22, 2023
7ddacf0
Updated Schemas
Bwc9876 Jul 22, 2023
34a27f8
uhguhjjuhuh
MegaPiggy Jul 22, 2023
6c4d8a3
Make methods for following up on destruction
xen-42 Aug 14, 2023
880dffd
Remove RemoveAllProxies method
xen-42 Aug 14, 2023
6895732
Always update the sun light effects controller to be safe
xen-42 Aug 14, 2023
eef5323
Cache root objects
xen-42 Aug 24, 2023
588995b
Only clear asset bundle cache when changing star system
xen-42 Aug 24, 2023
734f6e1
Clean up destruction, do proxies better
xen-42 Aug 24, 2023
fe8d088
Giants deep killing method
xen-42 Aug 24, 2023
21d7b36
Only destroy daynight/villagemusic on TH
xen-42 Aug 24, 2023
0720116
Destroy better (#699)
xen-42 Aug 24, 2023
acadcc8
Don't make hasRain obsolete
xen-42 Aug 24, 2023
c3634ed
Updated Schemas
Bwc9876 Aug 24, 2023
98f3cda
Rename Hearthian System to The Outer Wilds
xen-42 Aug 24, 2023
b912593
Fix defaultPrimaryToSun
xen-42 Aug 24, 2023
4550680
Fix ship spawning separately from player #677
xen-42 Aug 24, 2023
330b1b1
Fix null keys
xen-42 Aug 24, 2023
d2b10d3
use type prefab
MegaPiggy Aug 24, 2023
7320e51
use prefab name
MegaPiggy Aug 24, 2023
ca7e0f2
rename to Particle Fields
MegaPiggy Aug 24, 2023
24d7a13
Updated Schemas
Bwc9876 Aug 24, 2023
d1072e1
Particle/Vection Fields (#665)
MegaPiggy Aug 24, 2023
72e984f
Ship spawn (#711)
xen-42 Aug 26, 2023
601acec
Just call it clear cache sure
xen-42 Aug 26, 2023
4c9c353
Only clear certain caches on star system changed
xen-42 Aug 26, 2023
8465472
Fix goofy stuff
xen-42 Aug 26, 2023
5b2480c
Fix guys not being removed, maybe caches are good now
xen-42 Aug 26, 2023
9f2ff4b
Fix proxies but not really
xen-42 Aug 26, 2023
8422066
Logs
xen-42 Aug 26, 2023
8a9c5b1
Update manifest.json
xen-42 Aug 26, 2023
cb12b46
Fix distant colour of Bramble nodes. Fixes #372
xen-42 Aug 26, 2023
553e48e
teehee
JohnCorby Aug 26, 2023
2d452fe
this shit has been bothering me for a month lol
JohnCorby Aug 26, 2023
6596c7c
Optimizations (#710)
xen-42 Aug 26, 2023
6d3aa84
Funny typo
xen-42 Aug 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 72 additions & 37 deletions NewHorizons/Builder/Atmosphere/EffectsBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NewHorizons.External.Configs;
using NewHorizons.External.Modules;
using NewHorizons.Utility;
using UnityEngine;
namespace NewHorizons.Builder.Atmosphere
Expand All @@ -7,6 +8,21 @@ public static class EffectsBuilder
{
private static GameObject _rainEmitterPrefab;
private static GameObject _snowEmitterPrefab;
private static GameObject _snowLightEmitterPrefab;
private static GameObject _emberEmitterPrefab;
private static GameObject _leafEmitterPrefab;
private static GameObject _planktonEmitterPrefab;
private static GameObject _bubbleEmitterPrefab;
private static GameObject _currentEmitterPrefab;
private static GameObject _cloudEmitterPrefab;
private static GameObject _crawliesEmitterPrefab;
private static GameObject _firefliesEmitterPrefab;
private static GameObject _pollenEmitterPrefab;
private static GameObject _iceMoteEmitterPrefab;
private static GameObject _rockMoteEmitterPrefab;
private static GameObject _crystalMoteEmitterPrefab;
private static GameObject _sandMoteEmitterPrefab;
private static GameObject _fogEmitterPrefab;

private static bool _isInit;

Expand All @@ -18,9 +34,24 @@ internal static void InitPrefabs()

if (_rainEmitterPrefab == null) _rainEmitterPrefab = SearchUtilities.Find("GiantsDeep_Body/Sector_GD/Sector_GDInterior/Effects_GDInterior/Effects_GD_Rain").InstantiateInactive().Rename("Prefab_Effects_Rain").DontDestroyOnLoad();
if (_snowEmitterPrefab == null) _snowEmitterPrefab = SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Effects_BH/Effects_BH_Snowflakes").InstantiateInactive().Rename("Prefab_Effects_Snowflakes").DontDestroyOnLoad();
if (_snowLightEmitterPrefab == null) _snowLightEmitterPrefab = SearchUtilities.Find("TimberHearth_Body/Sector_TH/Effects_TH/Effects_TH_Snowflakes").InstantiateInactive().Rename("Prefab_Effects_SnowflakesLight").DontDestroyOnLoad();
if (_emberEmitterPrefab == null) _emberEmitterPrefab = SearchUtilities.Find("VolcanicMoon_Body/Sector_VM/Effects_VM/Effects_VM_Embers").InstantiateInactive().Rename("Prefab_Effects_Embers").DontDestroyOnLoad();
if (_leafEmitterPrefab == null) _leafEmitterPrefab = SearchUtilities.Find("GiantsDeep_Body/Sector_GD/Sector_GDInterior/Effects_GDInterior/Effects_GD_Leaves").InstantiateInactive().Rename("Prefab_Effects_Leaves").DontDestroyOnLoad();
if (_planktonEmitterPrefab == null) _planktonEmitterPrefab = SearchUtilities.Find("GiantsDeep_Body/Sector_GD/Sector_GDInterior/Effects_GDInterior/Effects_GD_Plankton").InstantiateInactive().Rename("Prefab_Effects_Plankton").DontDestroyOnLoad();
if (_bubbleEmitterPrefab == null) _bubbleEmitterPrefab = SearchUtilities.Find("GiantsDeep_Body/Sector_GD/Sector_GDInterior/Effects_GDInterior/Effects_GD_Bubbles").InstantiateInactive().Rename("Prefab_Effects_Bubbles").DontDestroyOnLoad();
if (_currentEmitterPrefab == null) _currentEmitterPrefab = SearchUtilities.Find("GiantsDeep_Body/Sector_GD/Sector_GDInterior/Effects_GDInterior/Effects_GD_RadialCurrent").InstantiateInactive().Rename("Prefab_Effects_Current").DontDestroyOnLoad();
if (_cloudEmitterPrefab == null) _cloudEmitterPrefab = SearchUtilities.Find("GiantsDeep_Body/Sector_GD/Effects_GD/Effects_GD_Clouds").InstantiateInactive().Rename("Prefab_Effects_Clouds").DontDestroyOnLoad();
if (_crawliesEmitterPrefab == null) _crawliesEmitterPrefab = SearchUtilities.Find("DB_EscapePodDimension_Body/Sector_EscapePodDimension/Effects_EscapePodDimension/Effects_DB_Crawlies (1)").InstantiateInactive().Rename("Prefab_Effects_Crawlies").DontDestroyOnLoad();
if (_firefliesEmitterPrefab == null) _firefliesEmitterPrefab = SearchUtilities.Find("TimberHearth_Body/Sector_TH/Effects_TH/Effects_TH_Fireflies").InstantiateInactive().Rename("Prefab_Effects_Fireflies").DontDestroyOnLoad();
if (_pollenEmitterPrefab == null) _pollenEmitterPrefab = SearchUtilities.Find("TimberHearth_Body/Sector_TH/Effects_TH/Effects_TH_SurfacePollen").InstantiateInactive().Rename("Prefab_Effects_Pollen").DontDestroyOnLoad();
if (_iceMoteEmitterPrefab == null) _iceMoteEmitterPrefab = SearchUtilities.Find("DarkBramble_Body/Effects_DB/Effects_DB_IceMotes").InstantiateInactive().Rename("Prefab_Effects_IceMotes").DontDestroyOnLoad();
if (_rockMoteEmitterPrefab == null) _rockMoteEmitterPrefab = SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Effects_BH/Effects_BH_RockMotes").InstantiateInactive().Rename("Prefab_Effects_RockMotes").DontDestroyOnLoad();
if (_crystalMoteEmitterPrefab == null) _crystalMoteEmitterPrefab = SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Effects_BH/Effects_BH_CrystalMotes").InstantiateInactive().Rename("Prefab_Effects_CrystalMotes").DontDestroyOnLoad();
if (_sandMoteEmitterPrefab == null) _sandMoteEmitterPrefab = SearchUtilities.Find("CaveTwin_Body/Sector_CaveTwin/Effects_CaveTwin/Effects_HGT_SandMotes").InstantiateInactive().Rename("Prefab_Effects_SandMotes").DontDestroyOnLoad();
if (_fogEmitterPrefab == null) _fogEmitterPrefab = SearchUtilities.Find("DB_EscapePodDimension_Body/Sector_EscapePodDimension/Effects_EscapePodDimension/Effects_DB_Fog (1)").InstantiateInactive().Rename("Prefab_Effects_Fog").DontDestroyOnLoad();
}

public static void Make(GameObject planetGO, Sector sector, PlanetConfig config, float surfaceSize)
public static void Make(GameObject planetGO, Sector sector, PlanetConfig config)
{
InitPrefabs();

Expand All @@ -36,7 +67,7 @@ public static void Make(GameObject planetGO, Sector sector, PlanetConfig config,
SCG._dynamicCullingBounds = false;
SCG._waitForStreaming = false;

var minHeight = surfaceSize;
var minHeight = config.Base.surfaceSize;
if (config.HeightMap?.minHeight != null)
{
if (config.Water?.size >= config.HeightMap.minHeight) minHeight = config.Water.size; // use sea level if its higher
Expand All @@ -48,52 +79,56 @@ public static void Make(GameObject planetGO, Sector sector, PlanetConfig config,
var maxHeight = config.Atmosphere.size;
if (config.Atmosphere.clouds?.outerCloudRadius != null) maxHeight = config.Atmosphere.clouds.outerCloudRadius;

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

var pvc = rainGO.GetComponent<PlanetaryVectionController>();
pvc._densityByHeight = new AnimationCurve(new Keyframe[]
var prefab = GetPrefabByType(particleField.type);
var emitter = Object.Instantiate(prefab, effectsGO.transform);
emitter.name = !string.IsNullOrWhiteSpace(particleField.rename) ? particleField.rename : prefab.name.Replace("Prefab_", "");
emitter.transform.position = planetGO.transform.position;

var vfe = emitter.GetComponent<VectionFieldEmitter>();
var pvc = emitter.GetComponent<PlanetaryVectionController>();
pvc._vectionFieldEmitter = vfe;
pvc._densityByHeight = particleField.densityByHeightCurve != null ? particleField.densityByHeightCurve.ToAnimationCurve() : new AnimationCurve(new Keyframe[]
{
new Keyframe(minHeight - 0.5f, 0),
new Keyframe(minHeight, 10f),
new Keyframe(maxHeight, 0f)
});
pvc._followTarget = particleField.followTarget == ParticleFieldModule.FollowTarget.Probe ? PlanetaryVectionController.FollowTarget.Probe : PlanetaryVectionController.FollowTarget.Player;
pvc._activeInSector = sector;
pvc._exclusionSectors = new Sector[] { };

rainGO.GetComponent<PlanetaryVectionController>()._activeInSector = sector;
rainGO.GetComponent<PlanetaryVectionController>()._exclusionSectors = new Sector[] { };
rainGO.SetActive(true);
}

if (config.Atmosphere.hasSnow)
{
var snowGO = new GameObject("SnowEffects");
snowGO.transform.parent = effectsGO.transform;
snowGO.transform.position = planetGO.transform.position;
for (int i = 0; i < 5; i++)
{
var snowEmitter = Object.Instantiate(_snowEmitterPrefab, snowGO.transform);
snowEmitter.name = "SnowEmitter";
snowEmitter.transform.position = planetGO.transform.position;

var pvc = snowEmitter.GetComponent<PlanetaryVectionController>();
pvc._densityByHeight = new AnimationCurve(new Keyframe[]
{
new Keyframe(minHeight - 0.5f, 0),
new Keyframe(minHeight, 10f),
new Keyframe(maxHeight, 0f)
});

snowEmitter.GetComponent<PlanetaryVectionController>()._activeInSector = sector;
snowEmitter.GetComponent<PlanetaryVectionController>()._exclusionSectors = new Sector[] { };
snowEmitter.SetActive(true);
}
emitter.SetActive(true);
}

effectsGO.transform.position = planetGO.transform.position;
effectsGO.SetActive(true);
}

public static GameObject GetPrefabByType(ParticleFieldModule.ParticleFieldType type)
{
return type switch
{
ParticleFieldModule.ParticleFieldType.Rain => _rainEmitterPrefab,
ParticleFieldModule.ParticleFieldType.SnowflakesHeavy => _snowEmitterPrefab,
ParticleFieldModule.ParticleFieldType.SnowflakesLight => _snowLightEmitterPrefab,
ParticleFieldModule.ParticleFieldType.Embers => _emberEmitterPrefab,
ParticleFieldModule.ParticleFieldType.Clouds => _cloudEmitterPrefab,
ParticleFieldModule.ParticleFieldType.Leaves => _leafEmitterPrefab,
ParticleFieldModule.ParticleFieldType.Bubbles => _bubbleEmitterPrefab,
ParticleFieldModule.ParticleFieldType.Fog => _fogEmitterPrefab,
ParticleFieldModule.ParticleFieldType.CrystalMotes => _crystalMoteEmitterPrefab,
ParticleFieldModule.ParticleFieldType.RockMotes => _rockMoteEmitterPrefab,
ParticleFieldModule.ParticleFieldType.IceMotes => _iceMoteEmitterPrefab,
ParticleFieldModule.ParticleFieldType.SandMotes => _sandMoteEmitterPrefab,
ParticleFieldModule.ParticleFieldType.Crawlies => _crawliesEmitterPrefab,
ParticleFieldModule.ParticleFieldType.Fireflies => _firefliesEmitterPrefab,
ParticleFieldModule.ParticleFieldType.Plankton => _planktonEmitterPrefab,
ParticleFieldModule.ParticleFieldType.Pollen => _pollenEmitterPrefab,
ParticleFieldModule.ParticleFieldType.Current => _currentEmitterPrefab,
_ => null,
};
}
}
}
2 changes: 1 addition & 1 deletion NewHorizons/Components/ShipLog/ShipLogStarChartMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public static string UniqueIDToName(string uniqueID)
if (!name.Equals(uniqueID)) return name;

// Else we return a default name
if (uniqueID.Equals("SolarSystem")) return "Hearthian System";
if (uniqueID.Equals("SolarSystem")) return "The Outer Wilds";

var splitString = uniqueID.Split('.');
if (splitString.Length > 1) splitString = splitString.Skip(1).ToArray();
Expand Down
30 changes: 30 additions & 0 deletions NewHorizons/External/Configs/PlanetConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using UnityEngine;

namespace NewHorizons.External.Configs
{
Expand Down Expand Up @@ -167,6 +168,12 @@ public class PlanetConfig
/// </summary>
public WaterModule Water;

/// <summary>
/// Add particle effects in a field around the planet.
/// Also known as Vection Fields.
/// </summary>
public ParticleFieldModule[] ParticleFields;

/// <summary>
/// Add various volumes on this body
/// </summary>
Expand Down Expand Up @@ -341,6 +348,29 @@ public void Migrate()
// useBasicCloudShader is obsolete
if (Atmosphere.clouds != null && Atmosphere.clouds.useBasicCloudShader)
Atmosphere.clouds.cloudsPrefab = CloudPrefabType.Basic;

if (Atmosphere.hasRain)
{
if (ParticleFields == null) ParticleFields = new ParticleFieldModule[0];
ParticleFields = ParticleFields.Append(new ParticleFieldModule
{
type = ParticleFieldModule.ParticleFieldType.Rain,
rename = "RainEmitter"
}).ToArray();
}

if (Atmosphere.hasSnow)
{
if (ParticleFields == null) ParticleFields = new ParticleFieldModule[0];
for (int i = 0; i < 5; i++)
{
ParticleFields = ParticleFields.Append(new ParticleFieldModule
{
type = ParticleFieldModule.ParticleFieldType.SnowflakesHeavy,
rename = "SnowEmitter"
}).ToArray();
}
}
}

if (Props?.tornados != null)
Expand Down
17 changes: 8 additions & 9 deletions NewHorizons/External/Modules/AtmosphereModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class AtmosphereModule
/// Colour of fog on the planet, if you put fog.
/// </summary>
public MColor fogTint;

/// <summary>
/// Relative filepath to the fog color ramp texture, if you put fog.
/// x axis is angle to sun (left at midnight, right at noon), y axis is distance to camera (close at bottom, far at top).
Expand All @@ -75,15 +75,12 @@ public class AtmosphereModule
public bool hasTrees;

/// <summary>
/// Does this planet have rain?
/// Does this planet have rain?
/// This is equivalent to effects of setting a rain particle/vection field, rain audio volume, and visor effect volume, combined for convenience.
/// For more control over the rain, use those individual components.
/// </summary>
public bool hasRain;

/// <summary>
/// Does this planet have snow?
/// </summary>
public bool hasSnow;

/// <summary>
/// Scale height of the atmosphere
/// </summary>
Expand Down Expand Up @@ -174,7 +171,6 @@ public class CloudInfo
/// </summary>
[DefaultValue(0f)] public float rotationSpeed = 0f;


#region Obsolete

/// <summary>
Expand All @@ -189,6 +185,8 @@ public class CloudInfo


#region Obsolete
[Obsolete("HasSnow is deprecated, please use ParticleFields instead")]
public bool hasSnow;

[Obsolete("CloudTint is deprecated, please use CloudInfo instead")]
public MColor cloudTint;
Expand All @@ -208,7 +206,8 @@ public class CloudInfo
[Obsolete("UseBasicCloudShader is deprecated, please use CloudInfo instead")]
public bool useBasicCloudShader;

[DefaultValue(true)] [Obsolete("ShadowsOnClouds is deprecated, please use CloudInfo instead")]
[DefaultValue(true)]
[Obsolete("ShadowsOnClouds is deprecated, please use CloudInfo instead")]
public bool shadowsOnClouds = true;

[Obsolete("HasAtmosphere is deprecated, please use UseAtmosphereShader instead")]
Expand Down
79 changes: 79 additions & 0 deletions NewHorizons/External/Modules/VectionFieldModule.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
using NewHorizons.External.Modules.VariableSize;
using NewHorizons.External.SerializableData;
using NewHorizons.External.SerializableEnums;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.ComponentModel;
using System.Runtime.Serialization;

namespace NewHorizons.External.Modules
{
[JsonObject]
public class ParticleFieldModule
{
/// <summary>
/// Particle type for this vection field.
/// </summary>
public ParticleFieldType type;

/// <summary>
/// What the particle field activates based on.
/// </summary>
[DefaultValue("player")] public FollowTarget followTarget = FollowTarget.Player;

/// <summary>
/// Density by height curve. Determines how many particles are emitted at different heights.
/// Defaults to a curve based on minimum and maximum heights of various other modules.
/// </summary>
public HeightDensityPair[] densityByHeightCurve;

/// <summary>
/// An optional rename of this object
/// </summary>
public string rename;

[JsonObject]
public class HeightDensityPair
{
/// <summary>
/// A specific radius
/// </summary>
public float height;

/// <summary>
/// The particle count for this radius.
/// </summary>
public float density;
}

[JsonConverter(typeof(StringEnumConverter))]
public enum ParticleFieldType
{
[EnumMember(Value = @"rain")] Rain,
[EnumMember(Value = @"snowflakesHeavy")] SnowflakesHeavy,
[EnumMember(Value = @"snowflakesLight")] SnowflakesLight,
[EnumMember(Value = @"embers")] Embers,
[EnumMember(Value = @"clouds")] Clouds,
[EnumMember(Value = @"leaves")] Leaves,
[EnumMember(Value = @"bubbles")] Bubbles,
[EnumMember(Value = @"fog")] Fog,
[EnumMember(Value = @"crystalMotes")] CrystalMotes,
[EnumMember(Value = @"rockMotes")] RockMotes,
[EnumMember(Value = @"iceMotes")] IceMotes,
[EnumMember(Value = @"sandMotes")] SandMotes,
[EnumMember(Value = @"crawlies")] Crawlies,
[EnumMember(Value = @"fireflies")] Fireflies,
[EnumMember(Value = @"plankton")] Plankton,
[EnumMember(Value = @"pollen")] Pollen,
[EnumMember(Value = @"current")] Current
}

[JsonConverter(typeof(StringEnumConverter))]
public enum FollowTarget
{
[EnumMember(Value = @"player")] Player,
[EnumMember(Value = @"probe")] Probe
}
}
}
Loading
Loading