This commit is contained in:
xen-42 2025-01-05 23:19:37 -05:00
commit 1390e79345
4 changed files with 84 additions and 19 deletions

View File

@ -1,6 +1,7 @@
using NewHorizons.External; using NewHorizons.External;
using NewHorizons.External.Configs; using NewHorizons.External.Configs;
using NewHorizons.External.Modules; using NewHorizons.External.Modules;
using NewHorizons.External.Modules.Props;
using NewHorizons.External.SerializableData; using NewHorizons.External.SerializableData;
using NewHorizons.Handlers; using NewHorizons.Handlers;
using NewHorizons.Utility.OWML; using NewHorizons.Utility.OWML;
@ -36,7 +37,7 @@ namespace NewHorizons.Builder.Body
config.Base = new BaseModule() config.Base = new BaseModule()
{ {
surfaceGravity = 1, surfaceGravity = belt.gravity,
surfaceSize = size, surfaceSize = size,
gravityFallOff = GravityFallOff.InverseSquared gravityFallOff = GravityFallOff.InverseSquared
}; };
@ -49,7 +50,8 @@ namespace NewHorizons.Builder.Body
trueAnomaly = 360f * (i + Random.Range(-0.2f, 0.2f)) / (float)count, trueAnomaly = 360f * (i + Random.Range(-0.2f, 0.2f)) / (float)count,
primaryBody = bodyName, primaryBody = bodyName,
semiMajorAxis = Random.Range(belt.innerRadius, belt.outerRadius), semiMajorAxis = Random.Range(belt.innerRadius, belt.outerRadius),
showOrbitLine = false showOrbitLine = false,
isTidallyLocked = true
}; };
config.ReferenceFrame = new ReferenceFrameModule() config.ReferenceFrame = new ReferenceFrameModule()
@ -62,8 +64,30 @@ namespace NewHorizons.Builder.Body
enabled = false enabled = false
}; };
if (!string.IsNullOrEmpty(belt.assetBundle) || !string.IsNullOrEmpty(belt.path))
{
config.Props = new PropModule()
{
details = new DetailInfo[1]
{
new DetailInfo()
{
assetBundle = belt.assetBundle,
path = belt.path,
scale = size,
rotation = belt.randomOrientation ? Random.rotation.eulerAngles : Vector3.zero,
keepLoaded = true
}
}
};
}
else if (belt.procGen != null)
{
config.ProcGen = belt.procGen; config.ProcGen = belt.procGen;
if (config.ProcGen == null) config.ProcGen.scale = size;
}
else
{ {
config.ProcGen = new ProcGenModule() config.ProcGen = new ProcGenModule()
{ {
@ -71,11 +95,6 @@ namespace NewHorizons.Builder.Body
color = new MColor(126, 94, 73) color = new MColor(126, 94, 73)
}; };
} }
else
{
// Still update the size
config.ProcGen.scale = size;
}
var asteroid = new NewHorizonsBody(config, mod); var asteroid = new NewHorizonsBody(config, mod);
PlanetCreationHandler.GenerateBody(asteroid); PlanetCreationHandler.GenerateBody(asteroid);

View File

@ -91,14 +91,15 @@ namespace NewHorizons.Builder.Body
level2.name += "1"; level2.name += "1";
LODGroup.RecalculateBounds(); LODGroup.RecalculateBounds();
// do this only for LOD because only the main body uses LOD, while title screen and proxies dont
var superGroup = planetGO.GetComponent<ProxyShadowCasterSuperGroup>();
if (superGroup != null) level2.gameObject.AddComponent<ProxyShadowCaster>()._superGroup = superGroup;
} }
var cubeSphereSC = cubeSphere.AddComponent<SphereCollider>(); var cubeSphereSC = cubeSphere.AddComponent<SphereCollider>();
cubeSphereSC.radius = Mathf.Min(module.minHeight, module.maxHeight) * Mathf.Min(stretch.x, stretch.y, stretch.z); cubeSphereSC.radius = Mathf.Min(module.minHeight, module.maxHeight) * Mathf.Min(stretch.x, stretch.y, stretch.z);
var superGroup = planetGO.GetComponent<ProxyShadowCasterSuperGroup>();
if (superGroup != null) cubeSphere.AddComponent<ProxyShadowCaster>()._superGroup = superGroup;
cubeSphere.SetActive(true); cubeSphere.SetActive(true);
// Now that we've made the mesh we can delete the heightmap texture // Now that we've made the mesh we can delete the heightmap texture

View File

@ -1,4 +1,4 @@
using System.ComponentModel; using System.ComponentModel;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Newtonsoft.Json; using Newtonsoft.Json;
@ -13,7 +13,7 @@ namespace NewHorizons.External.Modules
[Range(-1, 200)] [DefaultValue(-1)] public int amount = -1; [Range(-1, 200)] [DefaultValue(-1)] public int amount = -1;
/// <summary> /// <summary>
/// Angle between the rings and the equatorial plane of the planet. /// Angle between the belt and the equatorial plane of the planet.
/// </summary> /// </summary>
public float inclination; public float inclination;
@ -23,7 +23,7 @@ namespace NewHorizons.External.Modules
[Range(0f, double.MaxValue)] public float innerRadius; [Range(0f, double.MaxValue)] public float innerRadius;
/// <summary> /// <summary>
/// Angle defining the point where the rings rise up from the planet's equatorial plane if inclination is nonzero. /// Angle defining the point where the belt rises up from the planet's equatorial plane if inclination is nonzero.
/// </summary> /// </summary>
public float longitudeOfAscendingNode; public float longitudeOfAscendingNode;
@ -45,7 +45,7 @@ namespace NewHorizons.External.Modules
[Range(0f, double.MaxValue)] public float outerRadius; [Range(0f, double.MaxValue)] public float outerRadius;
/// <summary> /// <summary>
/// How the asteroids are generated /// How the asteroids are generated, unless you supply a detail yourself using "assetBundle" and "path"
/// </summary> /// </summary>
public ProcGenModule procGen; public ProcGenModule procGen;
@ -53,5 +53,30 @@ namespace NewHorizons.External.Modules
/// Number used to randomize asteroid positions /// Number used to randomize asteroid positions
/// </summary> /// </summary>
public int randomSeed; public int randomSeed;
/// <summary>
/// You can use this to load a custom asset or ingame object, instead of using ProcGen. It will be scaled by "minSize" and "maxSize", so ideally it should be near a 1 meter radius.
/// This is a relative filepath to an asset-bundle to load the prefab defined in `path` from.
/// </summary>
public string assetBundle;
/// <summary>
/// You can use this to load a custom asset or ingame object, instead of using ProcGen. It will be scaled by "minSize" and "maxSize", so ideally it should be near a 1 meter radius.
/// This is either the path in the scene hierarchy of the item to copy or the path to the object in the supplied asset bundle.
/// </summary>
public string path;
/// <summary>
/// Surface gravity of the asteroids.
/// </summary>
[Range(0f, double.MaxValue)]
[DefaultValue(1)]
public float gravity = 1f;
/// <summary>
/// Should the detail of the asteroid be randomly oriented, or should it point towards the center.
/// </summary>
[DefaultValue(true)]
public bool randomOrientation = true;
} }
} }

View File

@ -280,7 +280,7 @@
}, },
"inclination": { "inclination": {
"type": "number", "type": "number",
"description": "Angle between the rings and the equatorial plane of the planet.", "description": "Angle between the belt and the equatorial plane of the planet.",
"format": "float" "format": "float"
}, },
"innerRadius": { "innerRadius": {
@ -291,7 +291,7 @@
}, },
"longitudeOfAscendingNode": { "longitudeOfAscendingNode": {
"type": "number", "type": "number",
"description": "Angle defining the point where the rings rise up from the planet's equatorial plane if inclination is nonzero.", "description": "Angle defining the point where the belt rises up from the planet's equatorial plane if inclination is nonzero.",
"format": "float" "format": "float"
}, },
"maxSize": { "maxSize": {
@ -315,13 +315,33 @@
"minimum": 0.0 "minimum": 0.0
}, },
"procGen": { "procGen": {
"description": "How the asteroids are generated", "description": "How the asteroids are generated, unless you supply a detail yourself using \"assetBundle\" and \"path\"",
"$ref": "#/definitions/ProcGenModule" "$ref": "#/definitions/ProcGenModule"
}, },
"randomSeed": { "randomSeed": {
"type": "integer", "type": "integer",
"description": "Number used to randomize asteroid positions", "description": "Number used to randomize asteroid positions",
"format": "int32" "format": "int32"
},
"assetBundle": {
"type": "string",
"description": "You can use this to load a custom asset or ingame object, instead of using ProcGen. It will be scaled by \"minSize\" and \"maxSize\", so ideally it should be near a 1 meter radius.\nThis is a relative filepath to an asset-bundle to load the prefab defined in `path` from."
},
"path": {
"type": "string",
"description": "You can use this to load a custom asset or ingame object, instead of using ProcGen. It will be scaled by \"minSize\" and \"maxSize\", so ideally it should be near a 1 meter radius.\nThis is either the path in the scene hierarchy of the item to copy or the path to the object in the supplied asset bundle. "
},
"gravity": {
"type": "number",
"description": "Surface gravity of the asteroids.",
"format": "float",
"default": 1,
"minimum": 0.0
},
"randomOrientation": {
"type": "boolean",
"description": "Should the detail of the asteroid be randomly oriented, or should it point towards the center.",
"default": true
} }
} }
}, },