Allow creation of more than one ring (#374)

Because extinction
This commit is contained in:
Nick 2022-09-10 13:32:23 -04:00 committed by GitHub
commit ccb823dfaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 54 additions and 19 deletions

View File

@ -120,10 +120,13 @@ namespace NewHorizons.Builder.Body
}
}
if (body.Config.Ring != null)
if (body.Config.Rings != null)
{
RingBuilder.MakeRingGraphics(proxy, null, body.Config.Ring, body.Mod);
if (realSize < body.Config.Ring.outerRadius) realSize = body.Config.Ring.outerRadius;
foreach (var ring in body.Config.Rings)
{
RingBuilder.MakeRingGraphics(proxy, null, ring, body.Mod);
if (realSize < ring.outerRadius) realSize = ring.outerRadius;
}
}
Renderer starAtmosphere = null;

View File

@ -73,7 +73,7 @@ namespace NewHorizons.Builder.Body
return null;
}
var ringGO = new GameObject("Ring");
var ringGO = new GameObject(!string.IsNullOrEmpty(ring.rename) ? ring.rename : "Ring");
ringGO.transform.parent = sector?.transform ?? rootObject.transform;
ringGO.transform.position = rootObject.transform.position;
ringGO.transform.rotation = rootObject.transform.rotation;

View File

@ -67,6 +67,10 @@ namespace NewHorizons.External.Configs
[Obsolete("Signal is deprecated, please use Props->signals")]
public SignalModule Signal;
[Obsolete("Ring is deprecated, please use Rings")]
public RingModule Ring;
#endregion Obsolete
/// <summary>
@ -135,9 +139,9 @@ namespace NewHorizons.External.Configs
public string[] removeChildren;
/// <summary>
/// Creates a ring around the planet
/// Create rings around the planet
/// </summary>
public RingModule Ring;
public RingModule[] Rings;
/// <summary>
/// Add sand to this planet
@ -401,10 +405,20 @@ namespace NewHorizons.External.Configs
if (!string.IsNullOrEmpty(Cloak.audioFilePath)) Cloak.audio = Cloak.audioFilePath;
}
// Rings are no longer variable size module
// Ring is now a list so you can have many per planet
if (Ring != null)
{
if (Ring.curve != null) Ring.scaleCurve = Ring.curve;
if (Rings == null) Rings = new RingModule[0];
Rings = Rings.Append(Ring).ToArray();
}
// Rings are no longer variable size module
if (Rings != null)
{
foreach (var ring in Rings)
{
if (ring.curve != null) ring.scaleCurve = ring.curve;
}
}
}
}

View File

@ -62,5 +62,10 @@ namespace NewHorizons.External.Modules
/// Fade rings in/out over time. Optional. Value between 0-1, time is in minutes.
/// </summary>
public TimeValuePair[] opacityCurve;
/// <summary>
/// An optional rename of this object
/// </summary>
public string rename;
}
}

View File

@ -547,9 +547,12 @@ namespace NewHorizons.Handlers
}
}
if (body.Config.Ring != null)
if (body.Config.Rings != null)
{
RingBuilder.Make(go, sector, body.Config.Ring, body.Mod);
foreach (var ring in body.Config.Rings)
{
RingBuilder.Make(go, sector, ring, body.Mod);
}
}
if (body.Config.AsteroidBelt != null)

View File

@ -107,13 +107,16 @@ namespace NewHorizons.Handlers
}
pivot.name = "Pivot";
if (body.Config.Ring != null)
if (body.Config.Rings != null && body.Config.Rings.Length > 0)
{
RingModule newRing = new RingModule();
newRing.innerRadius = size * 1.2f;
newRing.outerRadius = size * 2f;
newRing.texture = body.Config.Ring.texture;
var ring = RingBuilder.Make(titleScreenGO, null, newRing, body.Mod);
foreach (var ring in body.Config.Rings)
{
RingModule newRing = new RingModule();
newRing.innerRadius = size * 1.2f;
newRing.outerRadius = size * 2f;
newRing.texture = ring.texture;
RingBuilder.Make(titleScreenGO, null, newRing, body.Mod);
}
titleScreenGO.transform.localScale = Vector3.one * 0.8f;
}

View File

@ -100,9 +100,12 @@
"type": "string"
}
},
"Ring": {
"description": "Creates a ring around the planet",
"$ref": "#/definitions/RingModule"
"Rings": {
"type": "array",
"description": "Create rings around the planet",
"items": {
"$ref": "#/definitions/RingModule"
}
},
"Sand": {
"description": "Add sand to this planet",
@ -2062,6 +2065,10 @@
"items": {
"$ref": "#/definitions/TimeValuePair"
}
},
"rename": {
"type": "string",
"description": "An optional rename of this object"
}
}
},