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

Biome Handler #511

Merged
merged 19 commits into from
Dec 19, 2023
Merged
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
Add CreateSkyPrefab utility method
  • Loading branch information
LeeTwentyThree committed Dec 19, 2023
commit e71688f39c59f46e6d38ede33fd7a810d14f2fb2
37 changes: 35 additions & 2 deletions Nautilus/Utility/BiomeUtils.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using UnityEngine;
using mset;
using UnityEngine;

namespace Nautilus.Utility;

Expand All @@ -7,7 +8,7 @@ namespace Nautilus.Utility;
/// </summary>
public static class BiomeUtils
{
/// <summary>
/// <summary>
/// <para>A shorthand for creating an instance of the <see cref="WaterscapeVolume.Settings"/> class.</para>
/// <para>A list of base game values can be found on this page: https://subnauticamodding.github.io/Nautilus/tutorials/biomes.html</para>
/// </summary>
Expand Down Expand Up @@ -40,4 +41,36 @@ public static WaterscapeVolume.Settings CreateBiomeSettings(Vector3 absorption,
temperature = temperature
};
}

private static GameObject _skyPrefabsParent;

/// <summary>
/// Creates a new basic Sky prefab.
/// </summary>
/// <param name="name">The name of the Sky, can be anything.</param>
/// <param name="specularCube">The texture of the Sky, VERY important in determining reflections.</param>
/// <param name="affectedByDayNightCycle">If true, the Sky will appear darker at night and brighter at day.</param>
/// <param name="outdoors">Whether this sky is outdoors or not (should be false for the interiors of player-made structures).</param>
/// <returns></returns>
public static Sky CreateSkyPrefab(string name, Texture specularCube, bool affectedByDayNightCycle = true, bool outdoors = true)
{
if (_skyPrefabsParent == null)
{
_skyPrefabsParent = new GameObject("SkyPrefabsParent");
_skyPrefabsParent.AddComponent<SceneCleanerPreserve>();
_skyPrefabsParent.SetActive(false);
Object.DontDestroyOnLoad(_skyPrefabsParent);
}

var skyObject = new GameObject(name);
skyObject.transform.parent = _skyPrefabsParent.transform;
skyObject.AddComponent<SceneCleanerPreserve>();

var sky = skyObject.AddComponent<Sky>();
sky.specularCube = specularCube;
sky.affectedByDayNightCycle = affectedByDayNightCycle;
sky.outdoors = outdoors;

return sky;
}
}