mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Wormholes between systems + planets on title screen
This commit is contained in:
parent
d737d4af0e
commit
a365f74760
@ -14,8 +14,10 @@ namespace NewHorizons.Builder.Body
|
||||
{
|
||||
static class AsteroidBeltBuilder
|
||||
{
|
||||
public static void Make(string bodyName, AsteroidBeltModule belt, IModAssets assets, string uniqueName)
|
||||
public static void Make(string bodyName, IPlanetConfig parentConfig, IModAssets assets, string uniqueName)
|
||||
{
|
||||
var belt = parentConfig.AsteroidBelt;
|
||||
|
||||
var minSize = 20;
|
||||
var maxSize = 50;
|
||||
int count = (int)(2f * Mathf.PI * belt.InnerRadius / (10f * maxSize));
|
||||
@ -31,6 +33,7 @@ namespace NewHorizons.Builder.Body
|
||||
var config = new Dictionary<string, object>()
|
||||
{
|
||||
{"Name", $"{bodyName} Asteroid {i}"},
|
||||
{"StarSystem", parentConfig.StarSystem },
|
||||
{"Base", new Dictionary<string, object>()
|
||||
{
|
||||
{"HasMapMarker", false },
|
||||
|
||||
@ -51,7 +51,7 @@ namespace NewHorizons.Builder.Body
|
||||
var cubeSphereMC = cubeSphere.AddComponent<MeshCollider>();
|
||||
cubeSphereMC.sharedMesh = mesh;
|
||||
|
||||
cubeSphere.AddComponent<ProxyShadowCaster>();
|
||||
if(go.GetComponent<ProxyShadowCasterSuperGroup>() != null) cubeSphere.AddComponent<ProxyShadowCaster>();
|
||||
|
||||
// Fix rotation in the end
|
||||
cubeSphere.transform.localRotation = Quaternion.Euler(90, 0, 0);
|
||||
|
||||
@ -38,16 +38,19 @@ namespace NewHorizons.Builder.Body
|
||||
polarity = Polarity.WhiteHole;
|
||||
}
|
||||
}
|
||||
bool hasHazardVolume = pairedSingularity == null;
|
||||
bool isWormHole = config.Singularity.TargetStarSystem != null;
|
||||
bool hasHazardVolume = !isWormHole && (pairedSingularity == null);
|
||||
|
||||
Vector3 localPosition = config.Singularity.Position == null ? Vector3.zero : (Vector3)config.Singularity.Position;
|
||||
|
||||
GameObject newSingularity = null;
|
||||
switch (polarity)
|
||||
{
|
||||
case Polarity.BlackHole:
|
||||
newSingularity = MakeBlackHole(body, sector, size, hasHazardVolume);
|
||||
newSingularity = MakeBlackHole(body, sector, localPosition, size, hasHazardVolume, config.Singularity.TargetStarSystem);
|
||||
break;
|
||||
case Polarity.WhiteHole:
|
||||
newSingularity = MakeWhiteHole(body, sector, OWRB, size);
|
||||
newSingularity = MakeWhiteHole(body, sector, OWRB, localPosition, size);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -57,33 +60,38 @@ namespace NewHorizons.Builder.Body
|
||||
var pairedSingularityAO = AstroObjectLocator.GetAstroObject(pairedSingularity);
|
||||
if(pairedSingularityAO != null)
|
||||
{
|
||||
Logger.Log($"Pairing singularities {pairedSingularity}, {config.Name}");
|
||||
try
|
||||
switch (polarity)
|
||||
{
|
||||
switch (polarity)
|
||||
{
|
||||
case Polarity.BlackHole:
|
||||
newSingularity.GetComponentInChildren<BlackHoleVolume>()._whiteHole = pairedSingularityAO.GetComponentInChildren<WhiteHoleVolume>();
|
||||
break;
|
||||
case Polarity.WhiteHole:
|
||||
pairedSingularityAO.GetComponentInChildren<BlackHoleVolume>()._whiteHole = newSingularity.GetComponentInChildren<WhiteHoleVolume>();
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch(Exception)
|
||||
{
|
||||
Logger.LogError($"Couldn't pair singularities {pairedSingularity}, {config.Name}");
|
||||
case Polarity.BlackHole:
|
||||
PairSingularities(newSingularity, pairedSingularityAO.gameObject);
|
||||
break;
|
||||
case Polarity.WhiteHole:
|
||||
PairSingularities(pairedSingularityAO.gameObject, newSingularity);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static GameObject MakeBlackHole(GameObject body, Sector sector, float size, bool hasDestructionVolume)
|
||||
public static void PairSingularities(GameObject blackHole, GameObject whiteHole)
|
||||
{
|
||||
Logger.Log($"Pairing singularities {blackHole?.name}, {whiteHole?.name}");
|
||||
try
|
||||
{
|
||||
blackHole.GetComponentInChildren<BlackHoleVolume>()._whiteHole = whiteHole.GetComponentInChildren<WhiteHoleVolume>();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Logger.LogError($"Couldn't pair singularities");
|
||||
}
|
||||
}
|
||||
|
||||
public static GameObject MakeBlackHole(GameObject body, 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.localPosition = Vector3.zero;
|
||||
blackHole.transform.localPosition = localPosition;
|
||||
|
||||
var blackHoleRender = new GameObject("BlackHoleRender");
|
||||
blackHoleRender.transform.parent = blackHole.transform;
|
||||
@ -101,7 +109,25 @@ namespace NewHorizons.Builder.Body
|
||||
meshRenderer.material.SetFloat("_MassScale", 1);
|
||||
meshRenderer.material.SetFloat("_DistortFadeDist", size * 0.55f);
|
||||
|
||||
if(hasDestructionVolume)
|
||||
if(makeAudio)
|
||||
{
|
||||
var blackHoleAmbience = GameObject.Instantiate(GameObject.Find("BrittleHollow_Body/BlackHole_BH/BlackHoleAmbience"), blackHole.transform);
|
||||
blackHoleAmbience.name = "BlackHoleAmbience";
|
||||
blackHoleAmbience.GetComponent<SectorAudioGroup>().SetSector(sector);
|
||||
|
||||
var blackHoleAudioSource = blackHoleAmbience.GetComponent<AudioSource>();
|
||||
blackHoleAudioSource.maxDistance = size * 2.5f;
|
||||
blackHoleAudioSource.minDistance = size * 0.4f;
|
||||
blackHoleAmbience.transform.localPosition = Vector3.zero;
|
||||
|
||||
var blackHoleOneShot = GameObject.Instantiate(GameObject.Find("BrittleHollow_Body/BlackHole_BH/BlackHoleEmissionOneShot"), blackHole.transform);
|
||||
var oneShotAudioSource = blackHoleOneShot.GetComponent<AudioSource>();
|
||||
oneShotAudioSource.maxDistance = size * 3f;
|
||||
oneShotAudioSource.minDistance = size * 0.4f;
|
||||
}
|
||||
|
||||
|
||||
if (hasDestructionVolume || targetSolarSystem != null)
|
||||
{
|
||||
var destructionVolumeGO = new GameObject("DestructionVolume");
|
||||
destructionVolumeGO.layer = LayerMask.NameToLayer("BasicEffectVolume");
|
||||
@ -113,7 +139,12 @@ namespace NewHorizons.Builder.Body
|
||||
sphereCollider.radius = size * 0.4f;
|
||||
sphereCollider.isTrigger = true;
|
||||
|
||||
destructionVolumeGO.AddComponent<BlackHoleDestructionVolume>();
|
||||
if (hasDestructionVolume) destructionVolumeGO.AddComponent<BlackHoleDestructionVolume>();
|
||||
else if (targetSolarSystem != null)
|
||||
{
|
||||
var wormholeVolume = destructionVolumeGO.AddComponent<ChangeStarSystemVolume>();
|
||||
wormholeVolume.TargetSolarSystem = targetSolarSystem;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -126,12 +157,12 @@ namespace NewHorizons.Builder.Body
|
||||
return blackHole;
|
||||
}
|
||||
|
||||
private static GameObject MakeWhiteHole(GameObject body, Sector sector, OWRigidbody OWRB, float size)
|
||||
public static GameObject MakeWhiteHole(GameObject body, Sector sector, OWRigidbody OWRB, Vector3 localPosition, float size, bool makeZeroGVolume = true)
|
||||
{
|
||||
var whiteHole = new GameObject("WhiteHole");
|
||||
whiteHole.SetActive(false);
|
||||
whiteHole.transform.parent = body.transform;
|
||||
whiteHole.transform.localPosition = Vector3.zero;
|
||||
whiteHole.transform.localPosition = localPosition;
|
||||
|
||||
var whiteHoleRenderer = new GameObject("WhiteHoleRenderer");
|
||||
whiteHoleRenderer.transform.parent = whiteHole.transform;
|
||||
@ -156,11 +187,7 @@ namespace NewHorizons.Builder.Body
|
||||
ambientLight.name = "AmbientLight";
|
||||
ambientLight.GetComponent<Light>().range = size * 7f;
|
||||
|
||||
var proxyShadow = sector.gameObject.AddComponent<ProxyShadowCasterSuperGroup>();
|
||||
|
||||
// it's going to complain
|
||||
GameObject whiteHoleVolumeGO = GameObject.Instantiate(GameObject.Find("WhiteHole_Body/WhiteHoleVolume"));
|
||||
|
||||
whiteHoleVolumeGO.transform.parent = whiteHole.transform;
|
||||
whiteHoleVolumeGO.transform.localPosition = Vector3.zero;
|
||||
whiteHoleVolumeGO.transform.localScale = Vector3.one;
|
||||
@ -178,23 +205,27 @@ namespace NewHorizons.Builder.Body
|
||||
whiteHoleVolume._whiteHoleSector = sector;
|
||||
whiteHoleVolume._fluidVolume = whiteHoleFluidVolume;
|
||||
whiteHoleVolume._whiteHoleBody = OWRB;
|
||||
whiteHoleVolume._whiteHoleProxyShadowSuperGroup = proxyShadow;
|
||||
whiteHoleVolume._whiteHoleProxyShadowSuperGroup = body.GetComponent<ProxyShadowCasterSuperGroup>();
|
||||
|
||||
whiteHoleVolumeGO.GetComponent<SphereCollider>().radius = size;
|
||||
|
||||
whiteHoleVolume.enabled = true;
|
||||
whiteHoleFluidVolume.enabled = true;
|
||||
|
||||
var zeroGVolume = GameObject.Instantiate(GameObject.Find("WhiteHole_Body/ZeroGVolume"), whiteHole.transform);
|
||||
zeroGVolume.name = "ZeroGVolume";
|
||||
zeroGVolume.GetComponent<SphereCollider>().radius = size * 10f;
|
||||
zeroGVolume.GetComponent<ZeroGVolume>()._attachedBody = OWRB;
|
||||
if(makeZeroGVolume)
|
||||
{
|
||||
var zeroGVolume = GameObject.Instantiate(GameObject.Find("WhiteHole_Body/ZeroGVolume"), whiteHole.transform);
|
||||
zeroGVolume.name = "ZeroGVolume";
|
||||
zeroGVolume.transform.localPosition = Vector3.zero;
|
||||
zeroGVolume.GetComponent<SphereCollider>().radius = size * 10f;
|
||||
zeroGVolume.GetComponent<ZeroGVolume>()._attachedBody = OWRB;
|
||||
|
||||
var rulesetVolume = GameObject.Instantiate(GameObject.Find("WhiteHole_Body/Sector_WhiteHole/RulesetVolumes_WhiteHole"), sector.transform);
|
||||
rulesetVolume.name = "RulesetVolume";
|
||||
rulesetVolume.transform.localPosition = Vector3.zero;
|
||||
rulesetVolume.transform.localScale = Vector3.one * size / 100f;
|
||||
rulesetVolume.GetComponent<SphereShape>().enabled = true;
|
||||
var rulesetVolume = GameObject.Instantiate(GameObject.Find("WhiteHole_Body/Sector_WhiteHole/RulesetVolumes_WhiteHole"), body.transform);
|
||||
rulesetVolume.name = "RulesetVolume";
|
||||
rulesetVolume.transform.localPosition = Vector3.zero;
|
||||
rulesetVolume.transform.localScale = Vector3.one * size / 100f;
|
||||
rulesetVolume.GetComponent<SphereShape>().enabled = true;
|
||||
}
|
||||
|
||||
whiteHole.SetActive(true);
|
||||
return whiteHole;
|
||||
|
||||
38
NewHorizons/Builder/General/ShipLogBuilder.cs
Normal file
38
NewHorizons/Builder/General/ShipLogBuilder.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NewHorizons.Builder.General
|
||||
{
|
||||
public static class ShipLogBuilder
|
||||
{
|
||||
public static ShipLogDetectiveMode StarChartMode;
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
var shipLogRoot = GameObject.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/ShipLogPivot/ShipLogCanvas");
|
||||
var starChartLog = GameObject.Instantiate(shipLogRoot.transform.Find("DetectiveMode"), shipLogRoot.transform);
|
||||
starChartLog.transform.name = "StarChartMode";
|
||||
|
||||
var cardRoot = starChartLog.transform.Find("ScaleRoot").Find("PanRoot");
|
||||
foreach(Transform child in cardRoot)
|
||||
{
|
||||
GameObject.Destroy(child.gameObject);
|
||||
}
|
||||
|
||||
var cardPrefab = GameObject.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/ShipLogPivot/ShipLogCanvas/DetectiveMode/ScaleRoot/PanRoot/TH_VILLAGE");
|
||||
|
||||
var detectiveMode = GameObject.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/ShipLogPivot/ShipLogCanvas/DetectiveMode/");
|
||||
var mapMode = GameObject.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/ShipLogPivot/ShipLogCanvas/MapMode/");
|
||||
|
||||
StarChartMode = starChartLog.GetComponent<ShipLogDetectiveMode>();
|
||||
|
||||
StarChartMode._cardDict = new Dictionary<string, ShipLogEntryCard>();
|
||||
StarChartMode._cardList = new List<ShipLogEntryCard>();
|
||||
StarChartMode._centerPromptList = detectiveMode.GetComponent<ShipLogDetectiveMode>()._centerPromptList;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -17,43 +17,17 @@ namespace NewHorizons.Builder.Props
|
||||
{
|
||||
public static void Make(GameObject go, Sector sector, IPlanetConfig config, IModAssets assets, string uniqueModName)
|
||||
{
|
||||
if (config.Props.Scatter != null) PropBuilder.Scatter(go, config.Props.Scatter, config.Base.SurfaceSize, sector);
|
||||
if (config.Props.Scatter != null)
|
||||
{
|
||||
PropBuilder.MakeScatter(go, config.Props.Scatter, config.Base.SurfaceSize, sector, assets, uniqueModName);
|
||||
}
|
||||
if(config.Props.Details != null)
|
||||
{
|
||||
foreach(var detail in config.Props.Details)
|
||||
{
|
||||
if(detail.assetBundle != null)
|
||||
{
|
||||
string key = uniqueModName + "." + detail.assetBundle;
|
||||
AssetBundle bundle;
|
||||
GameObject prefab;
|
||||
|
||||
try
|
||||
{
|
||||
if (Main.AssetBundles.ContainsKey(key)) bundle = Main.AssetBundles[key];
|
||||
else
|
||||
{
|
||||
bundle = assets.LoadBundle(detail.assetBundle);
|
||||
Main.AssetBundles[key] = bundle;
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Logger.Log($"Couldn't load AssetBundle {detail.assetBundle} : {e.Message}");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
prefab = bundle.LoadAsset<GameObject>(detail.path);
|
||||
prefab.SetActive(false);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Logger.Log($"Couldn't load asset {detail.path} from AssetBundle {detail.assetBundle} : {e.Message}");
|
||||
return;
|
||||
}
|
||||
|
||||
var prefab = LoadPrefab(detail.assetBundle, detail.path, uniqueModName, assets);
|
||||
MakeDetail(go, sector, prefab, detail.position, detail.rotation, detail.scale, detail.alignToNormal);
|
||||
}
|
||||
else if(detail.objFilePath != null)
|
||||
@ -139,19 +113,21 @@ namespace NewHorizons.Builder.Props
|
||||
return prop;
|
||||
}
|
||||
|
||||
private static void Scatter(GameObject go, PropModule.ScatterInfo[] scatterInfo, float radius, Sector sector)
|
||||
private static void MakeScatter(GameObject go, PropModule.ScatterInfo[] scatterInfo, float radius, Sector sector, IModAssets assets, string uniqueModName)
|
||||
{
|
||||
var area = 4f * Mathf.PI * radius * radius;
|
||||
var points = FibonacciSphere((int)area);
|
||||
|
||||
foreach (var propInfo in scatterInfo)
|
||||
{
|
||||
var prefab = GameObject.Find(propInfo.path);
|
||||
GameObject prefab;
|
||||
if (propInfo.assetBundle != null) prefab = LoadPrefab(propInfo.assetBundle, propInfo.path, uniqueModName, assets);
|
||||
else prefab = GameObject.Find(propInfo.path);
|
||||
for(int i = 0; i < propInfo.count; i++)
|
||||
{
|
||||
var randomInd = (int)Random.Range(0, points.Count);
|
||||
var point = points[randomInd];
|
||||
var prop = MakeDetail(go, sector, prefab, (MVector3)(point.normalized * radius), null, 0f, true, true);
|
||||
var prop = MakeDetail(go, sector, prefab, (MVector3)(point.normalized * radius), null, propInfo.scale, true, true);
|
||||
if(propInfo.offset != null) prop.transform.localPosition += prop.transform.TransformVector(propInfo.offset);
|
||||
if(propInfo.rotation != null) prop.transform.rotation *= Quaternion.Euler(propInfo.rotation);
|
||||
points.RemoveAt(randomInd);
|
||||
@ -180,5 +156,40 @@ namespace NewHorizons.Builder.Props
|
||||
}
|
||||
return points;
|
||||
}
|
||||
|
||||
private static GameObject LoadPrefab(string assetBundle, string path, string uniqueModName, IModAssets assets)
|
||||
{
|
||||
string key = uniqueModName + "." + assetBundle;
|
||||
AssetBundle bundle;
|
||||
GameObject prefab;
|
||||
|
||||
try
|
||||
{
|
||||
if (Main.AssetBundles.ContainsKey(key)) bundle = Main.AssetBundles[key];
|
||||
else
|
||||
{
|
||||
bundle = assets.LoadBundle(assetBundle);
|
||||
Main.AssetBundles[key] = bundle;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError($"Couldn't load AssetBundle {assetBundle} : {e.Message}");
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
prefab = bundle.LoadAsset<GameObject>(path);
|
||||
prefab.SetActive(false);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Log($"Couldn't load asset {path} from AssetBundle {assetBundle} : {e.Message}");
|
||||
return null;
|
||||
}
|
||||
|
||||
return prefab;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,7 +17,6 @@ namespace NewHorizons.Components
|
||||
|
||||
public override void VanishProbe(OWRigidbody probeBody, RelativeLocationData entryLocation)
|
||||
{
|
||||
Logger.Log($"Uh oh you shot your probe into a black hole");
|
||||
SurveyorProbe requiredComponent = probeBody.GetRequiredComponent<SurveyorProbe>();
|
||||
if (requiredComponent.IsLaunched())
|
||||
{
|
||||
|
||||
18
NewHorizons/Components/ChangeStarSystemVolume.cs
Normal file
18
NewHorizons/Components/ChangeStarSystemVolume.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NewHorizons.Components
|
||||
{
|
||||
public class ChangeStarSystemVolume : BlackHoleDestructionVolume
|
||||
{
|
||||
public string TargetSolarSystem { get; set; }
|
||||
|
||||
public override void VanishPlayer(OWRigidbody playerBody, RelativeLocationData entryLocation)
|
||||
{
|
||||
Main.Instance.ChangeCurrentStarSystem(TargetSolarSystem);
|
||||
}
|
||||
}
|
||||
}
|
||||
1
NewHorizons/External/IPlanetConfig.cs
vendored
1
NewHorizons/External/IPlanetConfig.cs
vendored
@ -5,6 +5,7 @@ namespace NewHorizons.External
|
||||
public interface IPlanetConfig
|
||||
{
|
||||
string Name { get; }
|
||||
string StarSystem { get; }
|
||||
bool Destroy { get; }
|
||||
int BuildPriority { get; }
|
||||
BaseModule Base {get;}
|
||||
|
||||
1
NewHorizons/External/PlanetConfig.cs
vendored
1
NewHorizons/External/PlanetConfig.cs
vendored
@ -8,6 +8,7 @@ namespace NewHorizons.External
|
||||
public class PlanetConfig : IPlanetConfig
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string StarSystem { get; set; } = "SolarSystem";
|
||||
public bool Destroy { get; set; }
|
||||
public int BuildPriority { get; set; } = -1;
|
||||
public MVector3 SpawnPoint { get; set; }
|
||||
|
||||
6
NewHorizons/External/PropModule.cs
vendored
6
NewHorizons/External/PropModule.cs
vendored
@ -15,10 +15,12 @@ namespace NewHorizons.External
|
||||
|
||||
public class ScatterInfo
|
||||
{
|
||||
public string path;
|
||||
public int count;
|
||||
public string path;
|
||||
public string assetBundle;
|
||||
public MVector3 offset;
|
||||
public MVector3 rotation;
|
||||
public float scale { get; set; } = 1f;
|
||||
}
|
||||
|
||||
public class DetailInfo
|
||||
@ -29,7 +31,7 @@ namespace NewHorizons.External
|
||||
public string assetBundle;
|
||||
public MVector3 position;
|
||||
public MVector3 rotation;
|
||||
public float scale;
|
||||
public float scale { get; set; } = 1f;
|
||||
public bool alignToNormal;
|
||||
}
|
||||
}
|
||||
|
||||
5
NewHorizons/External/SingularityModule.cs
vendored
5
NewHorizons/External/SingularityModule.cs
vendored
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using NewHorizons.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -10,6 +11,8 @@ namespace NewHorizons.External
|
||||
{
|
||||
public float Size;
|
||||
public string PairedSingularity;
|
||||
public string TargetStarSystem;
|
||||
public string Type; //BlackHole or WhiteHole
|
||||
public MVector3 Position;
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,6 +17,7 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
using Logger = NewHorizons.Utility.Logger;
|
||||
|
||||
namespace NewHorizons
|
||||
@ -29,13 +30,12 @@ namespace NewHorizons
|
||||
|
||||
public static List<NewHorizonsBody> BodyList = new List<NewHorizonsBody>();
|
||||
public static List<NewHorizonsBody> NextPassBodies = new List<NewHorizonsBody>();
|
||||
|
||||
public static Dictionary<string, AssetBundle> AssetBundles = new Dictionary<string, AssetBundle>();
|
||||
|
||||
public static float FurthestOrbit { get; set; } = 50000f;
|
||||
|
||||
public StarLightController StarLightController { get; private set; }
|
||||
|
||||
private static string _currentStarSystem = "SolarSystem";
|
||||
|
||||
public override object GetApi()
|
||||
{
|
||||
return new NewHorizonsApi();
|
||||
@ -59,6 +59,9 @@ namespace NewHorizons
|
||||
{
|
||||
Logger.LogWarning("Couldn't find planets folder");
|
||||
}
|
||||
|
||||
//UnityEngine.Random.InitState();
|
||||
Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => OnSceneLoaded(SceneManager.GetActiveScene(), LoadSceneMode.Single));
|
||||
}
|
||||
|
||||
public void OnDestroy()
|
||||
@ -71,10 +74,14 @@ namespace NewHorizons
|
||||
{
|
||||
Logger.Log($"Scene Loaded: {scene.name} {mode}");
|
||||
|
||||
if (scene.name != "SolarSystem") { return; }
|
||||
if (scene.name.Equals("TitleScreen")) DisplayBodyOnTitleScreen();
|
||||
|
||||
if (scene.name != "SolarSystem") return;
|
||||
|
||||
NewHorizonsData.Load();
|
||||
|
||||
Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => ShipLogBuilder.Init());
|
||||
|
||||
// Need to manage this when there are multiple stars
|
||||
var sun = GameObject.Find("Sun_Body");
|
||||
var starController = sun.AddComponent<StarController>();
|
||||
@ -115,8 +122,10 @@ namespace NewHorizons
|
||||
AstroObjectLocator.AddAstroObject(ao);
|
||||
}
|
||||
|
||||
// Stars then planets then moons (not necessary but probably speeds things up, maybe)
|
||||
var toLoad = BodyList.OrderBy(b =>
|
||||
// Order by stars then planets then moons (not necessary but probably speeds things up, maybe) ALSO only include current star system
|
||||
var toLoad = BodyList
|
||||
.Where(b => b.Config.StarSystem.Equals(_currentStarSystem))
|
||||
.OrderBy(b =>
|
||||
(b.Config.BuildPriority != -1 ? b.Config.BuildPriority :
|
||||
(b.Config.FocalPoint != null ? 0 :
|
||||
(b.Config.Star != null) ? 0 :
|
||||
@ -174,6 +183,69 @@ namespace NewHorizons
|
||||
*/
|
||||
}
|
||||
|
||||
public void DisplayBodyOnTitleScreen()
|
||||
{
|
||||
//Try loading one planet why not
|
||||
GameObject titleScreenGO = new GameObject("TitleScreenPlanet");
|
||||
var eligible = BodyList.Where(b => b.Config.Ring != null && (b.Config.HeightMap != null || (b.Config.Atmosphere?.Cloud != null))).ToArray();
|
||||
var body = eligible[UnityEngine.Random.Range(0, eligible.Count())];
|
||||
|
||||
Logger.Log($"Displaying {body.Config.Name} on the title screen");
|
||||
|
||||
var flag = false;
|
||||
HeightMapModule heightMap = new HeightMapModule();
|
||||
var minSize = 20;
|
||||
var maxSize = 35;
|
||||
if (body.Config.HeightMap != null)
|
||||
{
|
||||
var size = Mathf.Clamp(body.Config.HeightMap.MaxHeight / 10, minSize, maxSize);
|
||||
heightMap.TextureMap = body.Config.HeightMap.TextureMap;
|
||||
heightMap.HeightMap = body.Config.HeightMap.HeightMap;
|
||||
heightMap.MaxHeight = size;
|
||||
heightMap.MinHeight = body.Config.HeightMap.MinHeight * size / body.Config.HeightMap.MaxHeight;
|
||||
flag = true;
|
||||
}
|
||||
if (body.Config.Atmosphere != null && body.Config.Atmosphere.Cloud != null)
|
||||
{
|
||||
// Hacky but whatever I just want a sphere
|
||||
var size = Mathf.Clamp(body.Config.Atmosphere.Size / 10, minSize, maxSize);
|
||||
heightMap.MaxHeight = heightMap.MinHeight = size+1;
|
||||
heightMap.TextureMap = body.Config.Atmosphere.Cloud;
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
HeightMapBuilder.Make(titleScreenGO, heightMap, body.Assets);
|
||||
if (body.Config.Ring != null)
|
||||
{
|
||||
RingModule newRing = new RingModule();
|
||||
newRing.InnerRadius = maxSize * 1.2f;
|
||||
newRing.OuterRadius = maxSize * 2f;
|
||||
newRing.Texture = body.Config.Ring.Texture;
|
||||
RingBuilder.Make(titleScreenGO, newRing, body.Assets);
|
||||
titleScreenGO.transform.localScale = Vector3.one * 0.8f;
|
||||
}
|
||||
GameObject.Find("Scene/Background/PlanetPivot/Prefab_HEA_Campfire").SetActive(false);
|
||||
GameObject.Find("Scene/Background/PlanetPivot/PlanetRoot").SetActive(false);
|
||||
titleScreenGO.transform.parent = GameObject.Find("Scene/Background/PlanetPivot/").transform;
|
||||
titleScreenGO.transform.localPosition = Vector3.zero;
|
||||
|
||||
var lightGO = new GameObject("Light");
|
||||
lightGO.transform.parent = titleScreenGO.transform.parent.parent;
|
||||
lightGO.transform.localPosition = new Vector3(-47.9203f, 145.7596f, 43.1802f);
|
||||
var light = lightGO.AddComponent<Light>();
|
||||
light.color = new Color(1f, 1f, 1f, 1f);
|
||||
light.range = 100;
|
||||
light.intensity = 0.8f;
|
||||
}
|
||||
|
||||
var img = GameObject.Instantiate(GameObject.Find("TitleMenu/TitleCanvas/TitleLayoutGroup/Logo_EchoesOfTheEye").GetComponent<Image>());
|
||||
var texture = Main.Instance.ModHelper.Assets.GetTexture("AssetBundle/logo.png");
|
||||
img.sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(texture.width / 2f, texture.height / 2f));
|
||||
img.transform.parent = GameObject.Find("TitleMenu").transform;
|
||||
}
|
||||
|
||||
private bool LoadBody(NewHorizonsBody body, bool defaultPrimaryToSun = false)
|
||||
{
|
||||
var stringID = body.Config.Name.ToUpper().Replace(" ", "_").Replace("'", "");
|
||||
@ -365,7 +437,7 @@ namespace NewHorizons
|
||||
RingBuilder.Make(go, body.Config.Ring, body.Assets);
|
||||
|
||||
if (body.Config.AsteroidBelt != null)
|
||||
AsteroidBeltBuilder.Make(body.Config.Name, body.Config.AsteroidBelt, body.Assets, body.ModUniqueName);
|
||||
AsteroidBeltBuilder.Make(body.Config.Name, body.Config, body.Assets, body.ModUniqueName);
|
||||
|
||||
if (body.Config.Base.HasCometTail)
|
||||
CometTailBuilder.Make(go, body.Config.Base, go.GetComponent<AstroObject>().GetPrimaryBody());
|
||||
@ -405,6 +477,12 @@ namespace NewHorizons
|
||||
|
||||
return go;
|
||||
}
|
||||
|
||||
public void ChangeCurrentStarSystem(string newStarSystem)
|
||||
{
|
||||
_currentStarSystem = newStarSystem;
|
||||
LoadManager.LoadSceneAsync(OWScene.SolarSystem, true, LoadManager.FadeType.ToBlack, 0.1f, true);
|
||||
}
|
||||
}
|
||||
|
||||
public class NewHorizonsApi
|
||||
|
||||
@ -25,6 +25,9 @@
|
||||
</None>
|
||||
<None Include="manifest.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="AssetBundle\**">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using NewHorizons.Builder.Body;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -13,6 +14,9 @@ namespace NewHorizons.Utility
|
||||
{
|
||||
private OWRigidbody _rb;
|
||||
|
||||
private GameObject blackHole;
|
||||
private GameObject whiteHole;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_rb = this.GetRequiredComponent<OWRigidbody>();
|
||||
@ -34,6 +38,48 @@ namespace NewHorizons.Utility
|
||||
}
|
||||
_rb.EnableCollisionDetection();
|
||||
}
|
||||
|
||||
/*
|
||||
// Portal Gun:
|
||||
if (Keyboard.current == null) return;
|
||||
var fireBlackHole = Keyboard.current[Key.B].wasReleasedThisFrame;
|
||||
var fireWhiteHole = Keyboard.current[Key.N].wasReleasedThisFrame;
|
||||
if (fireBlackHole || fireWhiteHole)
|
||||
{
|
||||
// Raycast
|
||||
_rb.DisableCollisionDetection();
|
||||
int layerMask = OWLayerMask.physicalMask;
|
||||
var origin = Locator.GetActiveCamera().transform.position;
|
||||
var direction = Locator.GetActiveCamera().transform.TransformDirection(Vector3.forward);
|
||||
if (Physics.Raycast(origin, direction, out RaycastHit hitInfo, Mathf.Infinity, OWLayerMask.physicalMask))
|
||||
{
|
||||
var pos = hitInfo.transform.InverseTransformPoint(hitInfo.point + hitInfo.normal);
|
||||
var hitBody = hitInfo.transform.gameObject;
|
||||
var sector = hitBody.GetComponent<AstroObject>()?.GetRootSector();
|
||||
|
||||
if (hitBody == null || sector == null) return;
|
||||
Logger.Log($"{hitBody}");
|
||||
if (fireBlackHole)
|
||||
{
|
||||
if (blackHole != null) GameObject.Destroy(blackHole);
|
||||
blackHole = SingularityBuilder.MakeBlackHole(hitBody, sector, pos, 2, false, null, false);
|
||||
Logger.Log("Make black hole");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (whiteHole != null) GameObject.Destroy(whiteHole);
|
||||
whiteHole = SingularityBuilder.MakeWhiteHole(hitBody, sector, hitBody.GetAttachedOWRigidbody(), pos, 2, false);
|
||||
Logger.Log("Make white hole");
|
||||
}
|
||||
|
||||
if(blackHole && whiteHole)
|
||||
{
|
||||
SingularityBuilder.PairSingularities(blackHole, whiteHole);
|
||||
}
|
||||
}
|
||||
_rb.EnableCollisionDetection();
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using NewHorizons.Builder.Props;
|
||||
using NewHorizons.Builder.General;
|
||||
using NewHorizons.Builder.Props;
|
||||
using NewHorizons.Components;
|
||||
using NewHorizons.External;
|
||||
using OWML.Common;
|
||||
@ -47,6 +48,8 @@ namespace NewHorizons.Utility
|
||||
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<WhiteHoleVolume>("Awake", typeof(Patches), nameof(Patches.OnWhiteHoleVolumeAwake));
|
||||
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<ProbeLauncher>("UpdateOrbitalLaunchValues", typeof(Patches), nameof(Patches.OnProbeLauncherUpdateOrbitalLaunchValues));
|
||||
|
||||
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<ShipLogController>("Update", typeof(Patches), nameof(Patches.OnShipLogControllerUpdate));
|
||||
|
||||
// Postfixes
|
||||
Main.Instance.ModHelper.HarmonyHelper.AddPostfix<MapController>("Awake", typeof(Patches), nameof(Patches.OnMapControllerAwake));
|
||||
Main.Instance.ModHelper.HarmonyHelper.AddPostfix<OWCamera>("Awake", typeof(Patches), nameof(Patches.OnOWCameraAwake));
|
||||
@ -335,5 +338,50 @@ namespace NewHorizons.Utility
|
||||
{
|
||||
return (Locator.GetPlayerRulesetDetector()?.GetPlanetoidRuleset()?.GetGravityVolume() != null);
|
||||
}
|
||||
|
||||
// Replacing the entire method
|
||||
public static bool OnShipLogControllerUpdate(ShipLogController __instance)
|
||||
{
|
||||
if (__instance._exiting)
|
||||
{
|
||||
if (__instance._canvasAnimator.IsComplete())
|
||||
{
|
||||
__instance.enabled = false;
|
||||
__instance._shipLogCanvas.gameObject.SetActive(false);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (OWInput.GetInputMode() != InputMode.ShipComputer)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
__instance._exitPrompt.SetVisibility(__instance._currentMode.AllowCancelInput());
|
||||
if (__instance._currentMode.AllowCancelInput() && OWInput.IsNewlyPressed(InputLibrary.cancel, InputMode.All))
|
||||
{
|
||||
__instance.ExitShipComputer();
|
||||
return false;
|
||||
}
|
||||
__instance._currentMode.UpdateMode();
|
||||
if (__instance._currentMode.AllowModeSwap() && OWInput.IsNewlyPressed(InputLibrary.swapShipLogMode, InputMode.All))
|
||||
{
|
||||
ShipLogMode currentMode = __instance._currentMode;
|
||||
string focusedEntryID = currentMode.GetFocusedEntryID();
|
||||
bool flag = currentMode.Equals(__instance._mapMode);
|
||||
__instance._currentMode = (flag ? __instance._detectiveMode : __instance._mapMode);
|
||||
|
||||
if (currentMode.Equals(__instance._mapMode))
|
||||
__instance._currentMode = ShipLogBuilder.StarChartMode;
|
||||
else if (currentMode.Equals(ShipLogBuilder.StarChartMode))
|
||||
__instance._currentMode = __instance._detectiveMode;
|
||||
else
|
||||
__instance._currentMode = __instance._mapMode;
|
||||
|
||||
currentMode.ExitMode();
|
||||
__instance._currentMode.EnterMode(focusedEntryID, null);
|
||||
__instance._oneShotSource.PlayOneShot(flag ? global::AudioType.ShipLogEnterDetectiveMode : global::AudioType.ShipLogEnterMapMode, 1f);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user