Add proxy details

This commit is contained in:
Nick 2022-05-15 00:28:51 -04:00
parent c04626b4b0
commit b6e2c1906f
5 changed files with 114 additions and 91 deletions

View File

@ -1,4 +1,5 @@
using NewHorizons.Builder.Atmosphere;
using NewHorizons.Builder.Props;
using NewHorizons.Components;
using NewHorizons.Components.SizeControllers;
using NewHorizons.External.VariableSize;
@ -13,7 +14,7 @@ namespace NewHorizons.Builder.Body
public static class ProxyBuilder
{
private static Material lavaMaterial;
private static GameObject _blackHolePrefab;
private static GameObject _whiteHolePrefab;
@ -23,7 +24,7 @@ namespace NewHorizons.Builder.Body
public static void Make(GameObject gameObject, NewHorizonsBody body)
{
if(lavaMaterial == null) lavaMaterial = SearchUtilities.FindObjectOfTypeAndName<ProxyOrbiter>("VolcanicMoon_Body").transform.Find("LavaSphere").GetComponent<MeshRenderer>().material;
if (lavaMaterial == null) lavaMaterial = SearchUtilities.FindObjectOfTypeAndName<ProxyOrbiter>("VolcanicMoon_Body").transform.Find("LavaSphere").GetComponent<MeshRenderer>().material;
var proxyName = $"{body.Config.Name}_Proxy";
@ -91,7 +92,7 @@ namespace NewHorizons.Builder.Body
// Could improve this to actually use the proper renders and materials
if (body.Config.Singularity != null)
{
if(body.Config.Singularity.Type == "BlackHole")
if (body.Config.Singularity.Type == "BlackHole")
{
MakeBlackHole(newProxy, body.Config.Singularity.Size);
}
@ -106,6 +107,13 @@ namespace NewHorizons.Builder.Body
{
CometTailBuilder.Make(newProxy, null, body.Config);
}
if (body.Config.Props?.ProxyDetails != null)
{
foreach (var detailInfo in body.Config.Props.ProxyDetails)
{
DetailBuilder.Make(newProxy, null, body.Config, body.Mod, body.Mod.ModHelper.Manifest.UniqueName, detailInfo);
}
}
// Remove all collisions if there are any
foreach (var col in newProxy.GetComponentsInChildren<Collider>())

View File

@ -33,7 +33,7 @@ namespace NewHorizons.Builder.Body
sunAudio.name = "Audio_Star";
if(starModule.HasAtmosphere)
if (starModule.HasAtmosphere)
{
var sunAtmosphere = GameObject.Instantiate(GameObject.Find("Sun_Body/Atmosphere_SUN"), planetGO.transform);
sunAtmosphere.transform.position = planetGO.transform.position;
@ -70,8 +70,8 @@ namespace NewHorizons.Builder.Body
heatVolume.transform.localPosition = Vector3.zero;
heatVolume.transform.localScale = Vector3.one;
heatVolume.GetComponent<SphereShape>().radius = 1f;
heatVolume.name = "HeatVolume";
heatVolume.name = "HeatVolume";
var deathVolume = GameObject.Instantiate(GameObject.Find("Sun_Body/Sector_SUN/Volumes_SUN/ScaledVolumesRoot/DestructionFluidVolume"), starGO.transform);
deathVolume.transform.localPosition = Vector3.zero;
deathVolume.transform.localScale = Vector3.one;

View File

@ -42,9 +42,9 @@ namespace NewHorizons.Builder.Props
}
else detailGO = MakeDetail(go, sector, detail.path, detail.position, detail.rotation, detail.scale, detail.alignToNormal);
if(detailGO != null && detail.removeChildren != null)
if (detailGO != null && detail.removeChildren != null)
{
foreach(var childPath in detail.removeChildren)
foreach (var childPath in detail.removeChildren)
{
var childObj = detailGO.transform.Find(childPath);
if (childObj != null) childObj.gameObject.SetActive(false);
@ -52,7 +52,7 @@ namespace NewHorizons.Builder.Props
}
}
if(detailGO != null && detail.removeComponents)
if (detailGO != null && detail.removeComponents)
{
// Just swap all the children to a new game object
var newDetailGO = new GameObject(detailGO.name);
@ -60,11 +60,11 @@ namespace NewHorizons.Builder.Props
newDetailGO.transform.parent = detailGO.transform.parent;
// Can't modify parents while looping through children bc idk
var children = new List<Transform>();
foreach(Transform child in detailGO.transform)
foreach (Transform child in detailGO.transform)
{
children.Add(child);
}
foreach(var child in children)
foreach (var child in children)
{
child.parent = newDetailGO.transform;
}
@ -87,7 +87,7 @@ namespace NewHorizons.Builder.Props
GameObject prop = GameObject.Instantiate(prefab, sector.transform);
prop.SetActive(false);
sector.OnOccupantEnterSector += (SectorDetector sd) => OWAssetHandler.OnOccupantEnterSector(prop, sd, sector);
if (sector != null) sector.OnOccupantEnterSector += (SectorDetector sd) => OWAssetHandler.OnOccupantEnterSector(prop, sd, sector);
OWAssetHandler.LoadObject(prop);
foreach (var component in prop.GetComponents<Component>().Concat(prop.GetComponentsInChildren<Component>()))
@ -96,52 +96,56 @@ namespace NewHorizons.Builder.Props
var enabledField = component?.GetType()?.GetField("enabled");
if (enabledField != null && enabledField.FieldType == typeof(bool)) Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => enabledField.SetValue(component, true));
if(component is Sector)
// Fix a bunch of sector stuff
if (sector != null)
{
(component as Sector)._parentSector = sector;
}
// TODO: Make this work or smthng
if (component is GhostIK) (component as GhostIK).enabled = false;
if (component is GhostEffects) (component as GhostEffects).enabled = false;
if(component is DarkMatterVolume)
{
var probeVisuals = component.gameObject.transform.Find("ProbeVisuals");
if (probeVisuals != null) probeVisuals.gameObject.SetActive(true);
}
if (component is SectoredMonoBehaviour)
{
(component as SectoredMonoBehaviour).SetSector(sector);
}
else
{
var sectorField = component?.GetType()?.GetField("_sector");
if (sectorField != null && sectorField.FieldType == typeof(Sector)) Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => sectorField.SetValue(component, sector));
}
if (component is AnglerfishController)
{
try
if (component is Sector)
{
(component as AnglerfishController)._chaseSpeed += OWPhysics.CalculateOrbitVelocity(planetGO.GetAttachedOWRigidbody(), planetGO.GetComponent<AstroObject>().GetPrimaryBody().GetAttachedOWRigidbody()).magnitude;
(component as Sector)._parentSector = sector;
}
catch (Exception e)
// TODO: Make this work or smthng
if (component is GhostIK) (component as GhostIK).enabled = false;
if (component is GhostEffects) (component as GhostEffects).enabled = false;
if (component is DarkMatterVolume)
{
Logger.LogError($"Couldn't update AnglerFish chase speed: {e.Message}");
var probeVisuals = component.gameObject.transform.Find("ProbeVisuals");
if (probeVisuals != null) probeVisuals.gameObject.SetActive(true);
}
}
// Fix slide reel
if(component is SlideCollectionContainer)
{
sector.OnOccupantEnterSector.AddListener((_) => (component as SlideCollectionContainer).LoadStreamingTextures());
}
if (component is SectoredMonoBehaviour)
{
(component as SectoredMonoBehaviour).SetSector(sector);
}
else
{
var sectorField = component?.GetType()?.GetField("_sector");
if (sectorField != null && sectorField.FieldType == typeof(Sector)) Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => sectorField.SetValue(component, sector));
}
if(component is OWItemSocket)
{
(component as OWItemSocket)._sector = sector;
if (component is AnglerfishController)
{
try
{
(component as AnglerfishController)._chaseSpeed += OWPhysics.CalculateOrbitVelocity(planetGO.GetAttachedOWRigidbody(), planetGO.GetComponent<AstroObject>().GetPrimaryBody().GetAttachedOWRigidbody()).magnitude;
}
catch (Exception e)
{
Logger.LogError($"Couldn't update AnglerFish chase speed: {e.Message}");
}
}
// Fix slide reel
if (component is SlideCollectionContainer)
{
sector.OnOccupantEnterSector.AddListener((_) => (component as SlideCollectionContainer).LoadStreamingTextures());
}
if (component is OWItemSocket)
{
(component as OWItemSocket)._sector = sector;
}
}
// Fix a bunch of stuff when done loading

View File

@ -20,6 +20,7 @@ namespace NewHorizons.External
public EntryLocationInfo[] EntryLocation;
public NomaiTextInfo[] NomaiText;
public ProjectionInfo[] SlideShows;
public DetailInfo[] ProxyDetails;
public class ScatterInfo
{

View File

@ -112,6 +112,48 @@
"description": "Colour of the terrain."
}
}
},
"detail": {
"type": "object",
"additionalProperties": false,
"properties": {
"path": {
"type": "string",
"description": "Either the path in the scene hierarchy of the item to copy or the path to the object in the supplied asset bundle"
},
"assetBundle": {
"type": "string",
"description": "Relative filepath to an asset-bundle"
},
"position": {
"$ref": "#/$defs/vector3"
},
"rotation": {
"$ref": "#/$defs/vector3",
"description": "Euler angle degrees"
},
"scale": {
"type": "number",
"default": 1
},
"alignToNormal": {
"type": "boolean",
"description": "Do we override rotation and try to automatically align this object to stand upright on the body's surface?",
"default": false
},
"removeChildren": {
"type": "array",
"description": "A list of children to remove from this detail",
"items": {
"type": "string"
}
},
"removeComponents": {
"type": "boolean",
"description": "Do we reset all the components on this object? Useful for certain props that have dialogue components attached to them.",
"default": false
}
}
}
},
"title": "Body",
@ -633,46 +675,7 @@
"details": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"properties": {
"path": {
"type": "string",
"description": "Either the path in the scene hierarchy of the item to copy or the path to the object in the supplied asset bundle"
},
"assetBundle": {
"type": "string",
"description": "Relative filepath to an asset-bundle"
},
"position": {
"$ref": "#/$defs/vector3"
},
"rotation": {
"$ref": "#/$defs/vector3",
"description": "Euler angle degrees"
},
"scale": {
"type": "number",
"default": 1
},
"alignToNormal": {
"type": "boolean",
"description": "Do we override rotation and try to automatically align this object to stand upright on the body's surface?",
"default": false
},
"removeChildren": {
"type": "array",
"description": "A list of children to remove from this detail",
"items": {
"type": "string"
}
},
"removeComponents": {
"type": "boolean",
"description": "Do we reset all the components on this object? Useful for certain props that have dialogue components attached to them.",
"default": false
}
}
"$ref": "#/$defs/detail"
}
},
"dialogue": {
@ -1065,6 +1068,13 @@
}
}
}
},
"proxyDetails": {
"type": "array",
"description": "Details which will be shown from 50km away. Meant to be lower resolution.",
"items": {
"$ref": "#/$defs/detail"
}
}
}
},