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.Atmosphere;
using NewHorizons.Builder.Props;
using NewHorizons.Components; using NewHorizons.Components;
using NewHorizons.Components.SizeControllers; using NewHorizons.Components.SizeControllers;
using NewHorizons.External.VariableSize; using NewHorizons.External.VariableSize;
@ -23,7 +24,7 @@ namespace NewHorizons.Builder.Body
public static void Make(GameObject gameObject, NewHorizonsBody 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"; 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 // Could improve this to actually use the proper renders and materials
if (body.Config.Singularity != null) if (body.Config.Singularity != null)
{ {
if(body.Config.Singularity.Type == "BlackHole") if (body.Config.Singularity.Type == "BlackHole")
{ {
MakeBlackHole(newProxy, body.Config.Singularity.Size); MakeBlackHole(newProxy, body.Config.Singularity.Size);
} }
@ -106,6 +107,13 @@ namespace NewHorizons.Builder.Body
{ {
CometTailBuilder.Make(newProxy, null, body.Config); 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 // Remove all collisions if there are any
foreach (var col in newProxy.GetComponentsInChildren<Collider>()) foreach (var col in newProxy.GetComponentsInChildren<Collider>())

View File

@ -33,7 +33,7 @@ namespace NewHorizons.Builder.Body
sunAudio.name = "Audio_Star"; sunAudio.name = "Audio_Star";
if(starModule.HasAtmosphere) if (starModule.HasAtmosphere)
{ {
var sunAtmosphere = GameObject.Instantiate(GameObject.Find("Sun_Body/Atmosphere_SUN"), planetGO.transform); var sunAtmosphere = GameObject.Instantiate(GameObject.Find("Sun_Body/Atmosphere_SUN"), planetGO.transform);
sunAtmosphere.transform.position = planetGO.transform.position; sunAtmosphere.transform.position = planetGO.transform.position;

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); 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); var childObj = detailGO.transform.Find(childPath);
if (childObj != null) childObj.gameObject.SetActive(false); 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 // Just swap all the children to a new game object
var newDetailGO = new GameObject(detailGO.name); var newDetailGO = new GameObject(detailGO.name);
@ -60,11 +60,11 @@ namespace NewHorizons.Builder.Props
newDetailGO.transform.parent = detailGO.transform.parent; newDetailGO.transform.parent = detailGO.transform.parent;
// Can't modify parents while looping through children bc idk // Can't modify parents while looping through children bc idk
var children = new List<Transform>(); var children = new List<Transform>();
foreach(Transform child in detailGO.transform) foreach (Transform child in detailGO.transform)
{ {
children.Add(child); children.Add(child);
} }
foreach(var child in children) foreach (var child in children)
{ {
child.parent = newDetailGO.transform; child.parent = newDetailGO.transform;
} }
@ -87,7 +87,7 @@ namespace NewHorizons.Builder.Props
GameObject prop = GameObject.Instantiate(prefab, sector.transform); GameObject prop = GameObject.Instantiate(prefab, sector.transform);
prop.SetActive(false); 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); OWAssetHandler.LoadObject(prop);
foreach (var component in prop.GetComponents<Component>().Concat(prop.GetComponentsInChildren<Component>())) foreach (var component in prop.GetComponents<Component>().Concat(prop.GetComponentsInChildren<Component>()))
@ -96,7 +96,10 @@ namespace NewHorizons.Builder.Props
var enabledField = component?.GetType()?.GetField("enabled"); var enabledField = component?.GetType()?.GetField("enabled");
if (enabledField != null && enabledField.FieldType == typeof(bool)) Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => enabledField.SetValue(component, true)); 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)
{
if (component is Sector)
{ {
(component as Sector)._parentSector = sector; (component as Sector)._parentSector = sector;
} }
@ -105,7 +108,7 @@ namespace NewHorizons.Builder.Props
if (component is GhostIK) (component as GhostIK).enabled = false; if (component is GhostIK) (component as GhostIK).enabled = false;
if (component is GhostEffects) (component as GhostEffects).enabled = false; if (component is GhostEffects) (component as GhostEffects).enabled = false;
if(component is DarkMatterVolume) if (component is DarkMatterVolume)
{ {
var probeVisuals = component.gameObject.transform.Find("ProbeVisuals"); var probeVisuals = component.gameObject.transform.Find("ProbeVisuals");
if (probeVisuals != null) probeVisuals.gameObject.SetActive(true); if (probeVisuals != null) probeVisuals.gameObject.SetActive(true);
@ -134,15 +137,16 @@ namespace NewHorizons.Builder.Props
} }
// Fix slide reel // Fix slide reel
if(component is SlideCollectionContainer) if (component is SlideCollectionContainer)
{ {
sector.OnOccupantEnterSector.AddListener((_) => (component as SlideCollectionContainer).LoadStreamingTextures()); sector.OnOccupantEnterSector.AddListener((_) => (component as SlideCollectionContainer).LoadStreamingTextures());
} }
if(component is OWItemSocket) if (component is OWItemSocket)
{ {
(component as OWItemSocket)._sector = sector; (component as OWItemSocket)._sector = sector;
} }
}
// Fix a bunch of stuff when done loading // Fix a bunch of stuff when done loading
Main.Instance.ModHelper.Events.Unity.RunWhen(() => Main.IsSystemReady, () => Main.Instance.ModHelper.Events.Unity.RunWhen(() => Main.IsSystemReady, () =>

View File

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

View File

@ -112,6 +112,48 @@
"description": "Colour of the terrain." "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", "title": "Body",
@ -633,46 +675,7 @@
"details": { "details": {
"type": "array", "type": "array",
"items": { "items": {
"type": "object", "$ref": "#/$defs/detail"
"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
}
}
} }
}, },
"dialogue": { "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"
}
} }
} }
}, },