mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Some fixes + load assetbundles for props / audiofiles for signals
This commit is contained in:
parent
6759a4af76
commit
2e0d9093c6
@ -31,6 +31,8 @@ namespace NewHorizons.Atmosphere
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Color cloudTint = atmo.CloudTint == null ? Color.white : (Color)atmo.CloudTint.ToColor32();
|
||||||
|
|
||||||
GameObject cloudsMainGO = new GameObject();
|
GameObject cloudsMainGO = new GameObject();
|
||||||
cloudsMainGO.SetActive(false);
|
cloudsMainGO.SetActive(false);
|
||||||
cloudsMainGO.transform.parent = body.transform;
|
cloudsMainGO.transform.parent = body.transform;
|
||||||
@ -56,8 +58,8 @@ namespace NewHorizons.Atmosphere
|
|||||||
|
|
||||||
foreach (var material in topMR.sharedMaterials)
|
foreach (var material in topMR.sharedMaterials)
|
||||||
{
|
{
|
||||||
material.SetColor("_Color", atmo.CloudTint.ToColor32());
|
material.SetColor("_Color", cloudTint);
|
||||||
material.SetColor("_TintColor", atmo.CloudTint.ToColor32());
|
material.SetColor("_TintColor", cloudTint);
|
||||||
|
|
||||||
material.SetTexture("_MainTex", image);
|
material.SetTexture("_MainTex", image);
|
||||||
material.SetTexture("_RampTex", ramp);
|
material.SetTexture("_RampTex", ramp);
|
||||||
@ -84,7 +86,7 @@ namespace NewHorizons.Atmosphere
|
|||||||
bottomTSR.LODRadius = 1f;
|
bottomTSR.LODRadius = 1f;
|
||||||
|
|
||||||
// It's always more green than expected
|
// It's always more green than expected
|
||||||
var bottomCloudTint = atmo.CloudTint.ToColor32();
|
var bottomCloudTint = cloudTint;
|
||||||
bottomCloudTint.g = (byte)(bottomCloudTint.g * 0.8f);
|
bottomCloudTint.g = (byte)(bottomCloudTint.g * 0.8f);
|
||||||
foreach (Material material in bottomTSR.sharedMaterials)
|
foreach (Material material in bottomTSR.sharedMaterials)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -14,7 +14,7 @@ namespace NewHorizons.Builder.Body
|
|||||||
{
|
{
|
||||||
static class AsteroidBeltBuilder
|
static class AsteroidBeltBuilder
|
||||||
{
|
{
|
||||||
public static void Make(string bodyName, AsteroidBeltModule belt, IModAssets assets)
|
public static void Make(string bodyName, AsteroidBeltModule belt, IModAssets assets, string uniqueName)
|
||||||
{
|
{
|
||||||
var minSize = 20;
|
var minSize = 20;
|
||||||
var maxSize = 50;
|
var maxSize = 50;
|
||||||
@ -59,7 +59,7 @@ namespace NewHorizons.Builder.Body
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var asteroid = new NewHorizonsBody(new PlanetConfig(config), assets);
|
var asteroid = new NewHorizonsBody(new PlanetConfig(config), assets, uniqueName);
|
||||||
Main.NextPassBodies.Add(asteroid);
|
Main.NextPassBodies.Add(asteroid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,6 +33,7 @@ namespace NewHorizons.Builder.Body
|
|||||||
}
|
}
|
||||||
|
|
||||||
GameObject cubeSphere = new GameObject("CubeSphere");
|
GameObject cubeSphere = new GameObject("CubeSphere");
|
||||||
|
cubeSphere.SetActive(false);
|
||||||
cubeSphere.transform.parent = go.transform;
|
cubeSphere.transform.parent = go.transform;
|
||||||
cubeSphere.transform.rotation = Quaternion.Euler(90, 0, 0);
|
cubeSphere.transform.rotation = Quaternion.Euler(90, 0, 0);
|
||||||
|
|
||||||
@ -53,6 +54,8 @@ namespace NewHorizons.Builder.Body
|
|||||||
// Fix rotation in the end
|
// Fix rotation in the end
|
||||||
cubeSphere.transform.localRotation = Quaternion.Euler(90, 0, 0);
|
cubeSphere.transform.localRotation = Quaternion.Euler(90, 0, 0);
|
||||||
cubeSphere.transform.localPosition = Vector3.zero;
|
cubeSphere.transform.localPosition = Vector3.zero;
|
||||||
|
|
||||||
|
cubeSphere.SetActive(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -47,7 +47,7 @@ namespace NewHorizons.Builder.Body
|
|||||||
ringMR.material = mat;
|
ringMR.material = mat;
|
||||||
|
|
||||||
// Make mesh
|
// Make mesh
|
||||||
var segments = (int)Mathf.Clamp(ring.OuterRadius, 20, 20000);
|
var segments = (int)Mathf.Clamp(ring.OuterRadius, 20, 2000);
|
||||||
BuildRingMesh(ringMesh, segments, ring.InnerRadius, ring.OuterRadius);
|
BuildRingMesh(ringMesh, segments, ring.InnerRadius, ring.OuterRadius);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -38,6 +38,7 @@ namespace NewHorizons.Builder.General
|
|||||||
|
|
||||||
var type = AstroObject.Type.Planet;
|
var type = AstroObject.Type.Planet;
|
||||||
if (config.Orbit.IsMoon) type = AstroObject.Type.Moon;
|
if (config.Orbit.IsMoon) type = AstroObject.Type.Moon;
|
||||||
|
else if (config.Base.IsSatellite) type = AstroObject.Type.Satellite;
|
||||||
else if (config.Base.HasCometTail) type = AstroObject.Type.Comet;
|
else if (config.Base.HasCometTail) type = AstroObject.Type.Comet;
|
||||||
else if (config.Star != null) type = AstroObject.Type.Star;
|
else if (config.Star != null) type = AstroObject.Type.Star;
|
||||||
else if (config.FocalPoint != null) type = AstroObject.Type.None;
|
else if (config.FocalPoint != null) type = AstroObject.Type.None;
|
||||||
|
|||||||
@ -13,22 +13,26 @@ namespace NewHorizons.Builder.General
|
|||||||
MapMarker mapMarker = body.AddComponent<MapMarker>();
|
MapMarker mapMarker = body.AddComponent<MapMarker>();
|
||||||
mapMarker.SetValue("_labelID", (UITextType)Utility.AddToUITable.Add(name.ToUpper()));
|
mapMarker.SetValue("_labelID", (UITextType)Utility.AddToUITable.Add(name.ToUpper()));
|
||||||
|
|
||||||
var markerType = "Planet";
|
var markerType = MapMarker.MarkerType.Planet;
|
||||||
|
|
||||||
if (config.Orbit.IsMoon)
|
if (config.Orbit.IsMoon)
|
||||||
{
|
{
|
||||||
markerType = "Moon";
|
markerType = MapMarker.MarkerType.Moon;
|
||||||
}
|
}
|
||||||
else if (config.Star != null)
|
else if (config.Star != null)
|
||||||
{
|
{
|
||||||
markerType = "Sun";
|
markerType = MapMarker.MarkerType.Sun;
|
||||||
}
|
}
|
||||||
else if (config.FocalPoint != null)
|
else if (config.FocalPoint != null)
|
||||||
{
|
{
|
||||||
markerType = "HourglassTwins";
|
markerType = MapMarker.MarkerType.HourglassTwins;
|
||||||
|
}
|
||||||
|
else if(config.Base.IsSatellite)
|
||||||
|
{
|
||||||
|
markerType = MapMarker.MarkerType.Probe;
|
||||||
}
|
}
|
||||||
|
|
||||||
mapMarker.SetValue("_markerType", mapMarker.GetType().GetNestedType("MarkerType", BindingFlags.NonPublic).GetField(markerType).GetValue(mapMarker));
|
mapMarker._markerType = markerType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,10 +38,20 @@ namespace NewHorizons.Builder.Orbital
|
|||||||
else if (config.Base.BlackHoleSize != 0) color = new Color(1f, 0.5f, 1f);
|
else if (config.Base.BlackHoleSize != 0) color = new Color(1f, 0.5f, 1f);
|
||||||
else if (config.Base.WaterSize != 0) color = new Color(0.5f, 0.5f, 1f);
|
else if (config.Base.WaterSize != 0) color = new Color(0.5f, 0.5f, 1f);
|
||||||
else if (config.Base.LavaSize != 0) color = new Color(1f, 0.5f, 0.5f);
|
else if (config.Base.LavaSize != 0) color = new Color(1f, 0.5f, 0.5f);
|
||||||
|
|
||||||
|
var fade = isMoon;
|
||||||
|
if (config.Base.IsSatellite)
|
||||||
|
{
|
||||||
|
if(config.Orbit.Tint != null) color = new Color(0.4082f, 0.516f, 0.4469f, 1f);
|
||||||
|
fade = true;
|
||||||
|
orbitLine._fadeEndDist = 5000;
|
||||||
|
orbitLine._fadeStartDist = 3000;
|
||||||
|
}
|
||||||
|
|
||||||
orbitLine.SetValue("_color", color);
|
orbitLine.SetValue("_color", color);
|
||||||
|
|
||||||
orbitLine.SetValue("_astroObject", astroobject);
|
orbitLine.SetValue("_astroObject", astroobject);
|
||||||
orbitLine.SetValue("_fade", isMoon);
|
orbitLine.SetValue("_fade", fade);
|
||||||
orbitLine.SetValue("_lineWidth", 2f);
|
orbitLine.SetValue("_lineWidth", 2f);
|
||||||
|
|
||||||
Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(() =>
|
Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(() =>
|
||||||
|
|||||||
@ -9,39 +9,86 @@ using Random = UnityEngine.Random;
|
|||||||
using Logger = NewHorizons.Utility.Logger;
|
using Logger = NewHorizons.Utility.Logger;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using NewHorizons.Utility;
|
using NewHorizons.Utility;
|
||||||
|
using OWML.Common;
|
||||||
|
|
||||||
namespace NewHorizons.Builder.Props
|
namespace NewHorizons.Builder.Props
|
||||||
{
|
{
|
||||||
public static class PropBuilder
|
public static class PropBuilder
|
||||||
{
|
{
|
||||||
public static void Make(GameObject go, Sector sector, IPlanetConfig config)
|
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.Scatter(go, config.Props.Scatter, config.Base.SurfaceSize, sector);
|
||||||
if(config.Props.Details != null)
|
if(config.Props.Details != null)
|
||||||
{
|
{
|
||||||
foreach(var detail in config.Props.Details)
|
foreach(var detail in config.Props.Details)
|
||||||
{
|
{
|
||||||
MakeDetail(go, sector, detail.path, detail.position, detail.rotation, detail.scale);
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
MakeDetail(go, sector, prefab, detail.position, detail.rotation, detail.scale, detail.alignToNormal);
|
||||||
|
}
|
||||||
|
else if(detail.objFilePath != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var prefab = assets.Get3DObject(detail.objFilePath, detail.mtlFilePath);
|
||||||
|
prefab.SetActive(false);
|
||||||
|
MakeDetail(go, sector, prefab, detail.position, detail.rotation, detail.scale, detail.alignToNormal);
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
Logger.LogError($"Could not load 3d object {detail.objFilePath} with texture {detail.mtlFilePath} : {e.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else MakeDetail(go, sector, detail.path, detail.position, detail.rotation, detail.scale, detail.alignToNormal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GameObject MakeDetail(GameObject go, Sector sector, string propToClone, MVector3 position, MVector3 rotation, float scale)
|
public static GameObject MakeDetail(GameObject go, Sector sector, string propToClone, MVector3 position, MVector3 rotation, float scale, bool alignWithNormal)
|
||||||
{
|
{
|
||||||
var prefab = GameObject.Find(propToClone);
|
var prefab = GameObject.Find(propToClone);
|
||||||
return MakeDetail(go, sector, prefab, position, rotation, scale);
|
|
||||||
|
//TODO: this is super costly
|
||||||
|
if (prefab == null) prefab = SearchUtilities.FindObjectOfTypeAndName<GameObject>(propToClone.Split(new char[] { '\\', '/' }).Last());
|
||||||
|
if (prefab == null) Logger.LogError($"Couldn't find detail {propToClone}");
|
||||||
|
return MakeDetail(go, sector, prefab, position, rotation, scale, alignWithNormal);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GameObject MakeDetail(GameObject go, Sector sector, GameObject prefab, MVector3 position, MVector3 rotation, float scale, bool alignWithNormal = false)
|
public static GameObject MakeDetail(GameObject go, Sector sector, GameObject prefab, MVector3 position, MVector3 rotation, float scale, bool alignWithNormal, bool snapToSurface = false)
|
||||||
{
|
{
|
||||||
if (prefab == null) return null;
|
if (prefab == null) return null;
|
||||||
|
|
||||||
GameObject prop = GameObject.Instantiate(prefab, sector.transform);
|
GameObject prop = GameObject.Instantiate(prefab, sector.transform);
|
||||||
prop.transform.localPosition = position == null ? prefab.transform.localPosition : (Vector3)position;
|
|
||||||
Quaternion rot = rotation == null ? prefab.transform.localRotation : Quaternion.Euler((Vector3)rotation);
|
|
||||||
if (alignWithNormal) rot = Quaternion.FromToRotation(prop.transform.TransformDirection(Vector3.up), ((Vector3)position).normalized);
|
|
||||||
prop.transform.rotation = rot;
|
|
||||||
prop.transform.localScale = scale != 0 ? Vector3.one * scale : prefab.transform.localScale;
|
|
||||||
prop.SetActive(false);
|
prop.SetActive(false);
|
||||||
|
|
||||||
List<string> assetBundles = new List<string>();
|
List<string> assetBundles = new List<string>();
|
||||||
@ -59,27 +106,34 @@ namespace NewHorizons.Builder.Props
|
|||||||
sector.OnOccupantEnterSector += ((SectorDetector sd) => StreamingManager.LoadStreamingAssets(assetBundle));
|
sector.OnOccupantEnterSector += ((SectorDetector sd) => StreamingManager.LoadStreamingAssets(assetBundle));
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(var component in prop.GetComponentsInChildren<Component>())
|
foreach (var component in prop.GetComponentsInChildren<Component>())
|
||||||
{
|
{
|
||||||
try
|
// TODO: Make this work or smthng
|
||||||
{
|
if (component is GhostIK) (component as GhostIK).enabled = false;
|
||||||
var setSectorMethod = component.GetType().GetMethod("SetSector");
|
if(component is GhostEffects) (component as GhostEffects).enabled = false;
|
||||||
var sectorField = component.GetType().GetField("_sector");
|
|
||||||
|
|
||||||
if (setSectorMethod != null)
|
|
||||||
|
var enabledField = component.GetType().GetField("enabled");
|
||||||
|
if(enabledField != null && enabledField.FieldType == typeof(bool)) enabledField.SetValue(component, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
prop.transform.parent = go.transform;
|
||||||
|
prop.transform.localPosition = position == null ? prefab.transform.localPosition : (Vector3)position;
|
||||||
|
|
||||||
|
Quaternion rot = rotation == null ? prefab.transform.rotation : Quaternion.Euler((Vector3)rotation);
|
||||||
|
prop.transform.rotation = rot;
|
||||||
|
if (alignWithNormal)
|
||||||
{
|
{
|
||||||
Logger.Log($"Found a SetSector method in {prop}.{component}");
|
var up = prop.transform.localPosition.normalized;
|
||||||
setSectorMethod.Invoke(component, new object[] { sector });
|
var front = Vector3.Cross(up, Vector3.left);
|
||||||
}
|
if (front.sqrMagnitude == 0f) front = Vector3.Cross(up, Vector3.forward);
|
||||||
else if (sectorField != null)
|
if (front.sqrMagnitude == 0f) front = Vector3.Cross(up, Vector3.up);
|
||||||
{
|
|
||||||
Logger.Log($"Found a _sector field in {component}");
|
prop.transform.LookAt(prop.transform.position + front, up);
|
||||||
sectorField.SetValue(component, sector);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e) { Logger.Log($"{e.Message}, {e.StackTrace}"); }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prop.transform.localScale = scale != 0 ? Vector3.one * scale : prefab.transform.localScale;
|
||||||
|
|
||||||
prop.SetActive(true);
|
prop.SetActive(true);
|
||||||
|
|
||||||
return prop;
|
return prop;
|
||||||
@ -97,7 +151,7 @@ namespace NewHorizons.Builder.Props
|
|||||||
{
|
{
|
||||||
var randomInd = (int)Random.Range(0, points.Count);
|
var randomInd = (int)Random.Range(0, points.Count);
|
||||||
var point = points[randomInd];
|
var point = points[randomInd];
|
||||||
var prop = MakeDetail(go, sector, prefab, (MVector3)(point.normalized * radius), null, 0f, true);
|
var prop = MakeDetail(go, sector, prefab, (MVector3)(point.normalized * radius), null, 0f, true, true);
|
||||||
if(propInfo.offset != null) prop.transform.localPosition += prop.transform.TransformVector(propInfo.offset);
|
if(propInfo.offset != null) prop.transform.localPosition += prop.transform.TransformVector(propInfo.offset);
|
||||||
if(propInfo.rotation != null) prop.transform.rotation *= Quaternion.Euler(propInfo.rotation);
|
if(propInfo.rotation != null) prop.transform.rotation *= Quaternion.Euler(propInfo.rotation);
|
||||||
points.RemoveAt(randomInd);
|
points.RemoveAt(randomInd);
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
using NewHorizons.Components;
|
using NewHorizons.Components;
|
||||||
using NewHorizons.External;
|
using NewHorizons.External;
|
||||||
using NewHorizons.Utility;
|
using NewHorizons.Utility;
|
||||||
|
using OWML.Common;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -83,20 +84,19 @@ namespace NewHorizons.Builder.Props
|
|||||||
|
|
||||||
public static string GetCustomSignalName(SignalName signalName)
|
public static string GetCustomSignalName(SignalName signalName)
|
||||||
{
|
{
|
||||||
string name = null;
|
_customSignalNames.TryGetValue(signalName, out string name);
|
||||||
_customSignalNames.TryGetValue(signalName, out name);
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Make(GameObject body, Sector sector, SignalModule module)
|
public static void Make(GameObject body, Sector sector, SignalModule module, IModAssets assets)
|
||||||
{
|
{
|
||||||
foreach(var info in module.Signals)
|
foreach(var info in module.Signals)
|
||||||
{
|
{
|
||||||
Make(body, sector, info);
|
Make(body, sector, info, assets);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Make(GameObject body, Sector sector, SignalModule.SignalInfo info)
|
public static void Make(GameObject body, Sector sector, SignalModule.SignalInfo info, IModAssets assets)
|
||||||
{
|
{
|
||||||
var signalGO = new GameObject($"Signal_{info.Name}");
|
var signalGO = new GameObject($"Signal_{info.Name}");
|
||||||
signalGO.SetActive(false);
|
signalGO.SetActive(false);
|
||||||
@ -107,15 +107,32 @@ namespace NewHorizons.Builder.Props
|
|||||||
var source = signalGO.AddComponent<AudioSource>();
|
var source = signalGO.AddComponent<AudioSource>();
|
||||||
var owAudioSource = signalGO.AddComponent<OWAudioSource>();
|
var owAudioSource = signalGO.AddComponent<OWAudioSource>();
|
||||||
|
|
||||||
AudioSignal audioSignal = null;
|
AudioSignal audioSignal;
|
||||||
if (info.InsideCloak) audioSignal = signalGO.AddComponent<CloakedAudioSignal>();
|
if (info.InsideCloak) audioSignal = signalGO.AddComponent<CloakedAudioSignal>();
|
||||||
else audioSignal = signalGO.AddComponent<AudioSignal>();
|
else audioSignal = signalGO.AddComponent<AudioSignal>();
|
||||||
|
|
||||||
var frequency = StringToFrequency(info.Frequency);
|
var frequency = StringToFrequency(info.Frequency);
|
||||||
var name = StringToSignalName(info.Name);
|
var name = StringToSignalName(info.Name);
|
||||||
|
|
||||||
AudioClip clip = SearchUtilities.FindResourceOfTypeAndName<AudioClip>(info.AudioClip);
|
AudioClip clip = null;
|
||||||
if (clip == null) return;
|
if(info.AudioClip != null) clip = SearchUtilities.FindResourceOfTypeAndName<AudioClip>(info.AudioClip);
|
||||||
|
else if (info.AudioFilePath != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
clip = assets.GetAudio(info.AudioFilePath);
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
Logger.LogError($"Couldn't load audio file {info.AudioFilePath} : {e.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (clip == null)
|
||||||
|
{
|
||||||
|
Logger.LogError($"Couldn't find AudioClip {info.AudioClip} or AudioFile {info.AudioFilePath}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
audioSignal.SetSector(sector);
|
audioSignal.SetSector(sector);
|
||||||
audioSignal._frequency = frequency;
|
audioSignal._frequency = frequency;
|
||||||
|
|||||||
1
NewHorizons/External/BaseModule.cs
vendored
1
NewHorizons/External/BaseModule.cs
vendored
@ -20,6 +20,7 @@ namespace NewHorizons.External
|
|||||||
public bool HasCometTail { get; set; }
|
public bool HasCometTail { get; set; }
|
||||||
public bool HasReferenceFrame { get; set; } = true;
|
public bool HasReferenceFrame { get; set; } = true;
|
||||||
public bool CenterOfSolarSystem { get; set; } = false;
|
public bool CenterOfSolarSystem { get; set; } = false;
|
||||||
|
public bool IsSatellite { get; set; }
|
||||||
|
|
||||||
// Old, see SingularityModule instead
|
// Old, see SingularityModule instead
|
||||||
public float BlackHoleSize { get; set; }
|
public float BlackHoleSize { get; set; }
|
||||||
|
|||||||
4
NewHorizons/External/PropModule.cs
vendored
4
NewHorizons/External/PropModule.cs
vendored
@ -24,9 +24,13 @@ namespace NewHorizons.External
|
|||||||
public class DetailInfo
|
public class DetailInfo
|
||||||
{
|
{
|
||||||
public string path;
|
public string path;
|
||||||
|
public string objFilePath;
|
||||||
|
public string mtlFilePath;
|
||||||
|
public string assetBundle;
|
||||||
public MVector3 position;
|
public MVector3 position;
|
||||||
public MVector3 rotation;
|
public MVector3 rotation;
|
||||||
public float scale;
|
public float scale;
|
||||||
|
public bool alignToNormal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
3
NewHorizons/External/SignalModule.cs
vendored
3
NewHorizons/External/SignalModule.cs
vendored
@ -16,7 +16,8 @@ namespace NewHorizons.External
|
|||||||
public MVector3 Position;
|
public MVector3 Position;
|
||||||
public string Frequency;
|
public string Frequency;
|
||||||
public string Name;
|
public string Name;
|
||||||
public string AudioClip;
|
public string AudioClip = null;
|
||||||
|
public string AudioFilePath = null;
|
||||||
public float SourceRadius = 1f;
|
public float SourceRadius = 1f;
|
||||||
public float DetectionRadius = 0f;
|
public float DetectionRadius = 0f;
|
||||||
public float IdentificationRadius = 10f;
|
public float IdentificationRadius = 10f;
|
||||||
|
|||||||
@ -30,6 +30,8 @@ namespace NewHorizons
|
|||||||
public static List<NewHorizonsBody> BodyList = new List<NewHorizonsBody>();
|
public static List<NewHorizonsBody> BodyList = new List<NewHorizonsBody>();
|
||||||
public static List<NewHorizonsBody> NextPassBodies = 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 static float FurthestOrbit { get; set; } = 50000f;
|
||||||
|
|
||||||
public StarLightController StarLightController { get; private set; }
|
public StarLightController StarLightController { get; private set; }
|
||||||
@ -236,7 +238,7 @@ namespace NewHorizons
|
|||||||
{
|
{
|
||||||
var config = mod.ModHelper.Storage.Load<PlanetConfig>(file.Replace(folder, ""));
|
var config = mod.ModHelper.Storage.Load<PlanetConfig>(file.Replace(folder, ""));
|
||||||
Logger.Log($"Loaded {config.Name}");
|
Logger.Log($"Loaded {config.Name}");
|
||||||
BodyList.Add(new NewHorizonsBody(config, mod.ModHelper.Assets));
|
BodyList.Add(new NewHorizonsBody(config, mod.ModHelper.Assets, mod.ModHelper.Manifest.UniqueName));
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@ -289,7 +291,7 @@ namespace NewHorizons
|
|||||||
if (body.Config.Base.GroundSize != 0) GeometryBuilder.Make(go, body.Config.Base.GroundSize);
|
if (body.Config.Base.GroundSize != 0) GeometryBuilder.Make(go, body.Config.Base.GroundSize);
|
||||||
|
|
||||||
var atmoSize = body.Config.Atmosphere != null ? body.Config.Atmosphere.Size : 0f;
|
var atmoSize = body.Config.Atmosphere != null ? body.Config.Atmosphere.Size : 0f;
|
||||||
float sphereOfInfluence = Mathf.Max(atmoSize, body.Config.Base.SurfaceSize * 2f);
|
float sphereOfInfluence = Mathf.Max(Mathf.Max(atmoSize, 50), body.Config.Base.SurfaceSize * 2f);
|
||||||
|
|
||||||
var outputTuple = BaseBuilder.Make(go, primaryBody, body.Config);
|
var outputTuple = BaseBuilder.Make(go, primaryBody, body.Config);
|
||||||
var ao = (AstroObject)outputTuple.Item1;
|
var ao = (AstroObject)outputTuple.Item1;
|
||||||
@ -366,7 +368,7 @@ namespace NewHorizons
|
|||||||
RingBuilder.Make(go, body.Config.Ring, body.Assets);
|
RingBuilder.Make(go, body.Config.Ring, body.Assets);
|
||||||
|
|
||||||
if (body.Config.AsteroidBelt != null)
|
if (body.Config.AsteroidBelt != null)
|
||||||
AsteroidBeltBuilder.Make(body.Config.Name, body.Config.AsteroidBelt, body.Assets);
|
AsteroidBeltBuilder.Make(body.Config.Name, body.Config.AsteroidBelt, body.Assets, body.ModUniqueName);
|
||||||
|
|
||||||
if (body.Config.Base.HasCometTail)
|
if (body.Config.Base.HasCometTail)
|
||||||
CometTailBuilder.Make(go, body.Config.Base, go.GetComponent<AstroObject>().GetPrimaryBody());
|
CometTailBuilder.Make(go, body.Config.Base, go.GetComponent<AstroObject>().GetPrimaryBody());
|
||||||
@ -396,10 +398,10 @@ namespace NewHorizons
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (body.Config.Props != null)
|
if (body.Config.Props != null)
|
||||||
PropBuilder.Make(go, sector, body.Config);
|
PropBuilder.Make(go, sector, body.Config, body.Assets, body.ModUniqueName);
|
||||||
|
|
||||||
if (body.Config.Signal != null)
|
if (body.Config.Signal != null)
|
||||||
SignalBuilder.Make(go, sector, body.Config.Signal);
|
SignalBuilder.Make(go, sector, body.Config.Signal, body.Assets);
|
||||||
|
|
||||||
return go;
|
return go;
|
||||||
}
|
}
|
||||||
@ -418,7 +420,7 @@ namespace NewHorizons
|
|||||||
Logger.Log("Recieved API request to create planet " + (string)config["Name"], Logger.LogType.Log);
|
Logger.Log("Recieved API request to create planet " + (string)config["Name"], Logger.LogType.Log);
|
||||||
var planetConfig = new PlanetConfig(config);
|
var planetConfig = new PlanetConfig(config);
|
||||||
|
|
||||||
var body = new NewHorizonsBody(planetConfig, mod != null ? mod.ModHelper.Assets : Main.Instance.ModHelper.Assets);
|
var body = new NewHorizonsBody(planetConfig, mod != null ? mod.ModHelper.Assets : Main.Instance.ModHelper.Assets, mod.ModHelper.Manifest.UniqueName);
|
||||||
|
|
||||||
Main.BodyList.Add(body);
|
Main.BodyList.Add(body);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,14 +6,16 @@ namespace NewHorizons.Utility
|
|||||||
{
|
{
|
||||||
public class NewHorizonsBody
|
public class NewHorizonsBody
|
||||||
{
|
{
|
||||||
public NewHorizonsBody(IPlanetConfig config, IModAssets assets)
|
public NewHorizonsBody(IPlanetConfig config, IModAssets assets, string modUniqueName)
|
||||||
{
|
{
|
||||||
Config = config;
|
Config = config;
|
||||||
Assets = assets;
|
Assets = assets;
|
||||||
|
ModUniqueName = modUniqueName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IPlanetConfig Config;
|
public IPlanetConfig Config;
|
||||||
public IModAssets Assets;
|
public IModAssets Assets;
|
||||||
|
public string ModUniqueName;
|
||||||
|
|
||||||
public GameObject Object;
|
public GameObject Object;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,7 @@ namespace NewHorizons.Utility
|
|||||||
{
|
{
|
||||||
public static class SearchUtilities
|
public static class SearchUtilities
|
||||||
{
|
{
|
||||||
public static List<T> FindObjectsOfTypeAndName<T>(string name) where T : MonoBehaviour
|
public static List<T> FindObjectsOfTypeAndName<T>(string name) where T : Object
|
||||||
{
|
{
|
||||||
T[] firstList = GameObject.FindObjectsOfType<T>();
|
T[] firstList = GameObject.FindObjectsOfType<T>();
|
||||||
List<T> finalList = new List<T>();
|
List<T> finalList = new List<T>();
|
||||||
@ -26,6 +26,22 @@ namespace NewHorizons.Utility
|
|||||||
return finalList;
|
return finalList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static T FindObjectOfTypeAndName<T>(string name) where T : Object
|
||||||
|
{
|
||||||
|
T[] firstList = GameObject.FindObjectsOfType<T>();
|
||||||
|
List<T> finalList = new List<T>();
|
||||||
|
|
||||||
|
for (var i = 0; i < firstList.Length; i++)
|
||||||
|
{
|
||||||
|
if (firstList[i].name == name)
|
||||||
|
{
|
||||||
|
return firstList[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public static List<T> FindResourcesOfTypeAndName<T>(string name) where T : Object
|
public static List<T> FindResourcesOfTypeAndName<T>(string name) where T : Object
|
||||||
{
|
{
|
||||||
T[] firstList = Resources.FindObjectsOfTypeAll<T>();
|
T[] firstList = Resources.FindObjectsOfTypeAll<T>();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user