Merge branch 'dev' into height-map-resolution

This commit is contained in:
Nick 2022-07-14 20:26:42 -04:00
commit 94ca87b871
5 changed files with 61 additions and 21 deletions

View File

@ -18,6 +18,8 @@ namespace NewHorizons.Builder.Body
private static readonly int SkyColor = Shader.PropertyToID("_SkyColor"); private static readonly int SkyColor = Shader.PropertyToID("_SkyColor");
private static readonly int AtmosFar = Shader.PropertyToID("_AtmosFar"); private static readonly int AtmosFar = Shader.PropertyToID("_AtmosFar");
private static readonly int AtmosNear = Shader.PropertyToID("_AtmosNear"); private static readonly int AtmosNear = Shader.PropertyToID("_AtmosNear");
private static readonly int Tint = Shader.PropertyToID("_Tint");
private static readonly int Radius = Shader.PropertyToID("_Radius");
private static readonly int InnerRadius = Shader.PropertyToID("_InnerRadius"); private static readonly int InnerRadius = Shader.PropertyToID("_InnerRadius");
private static readonly int OuterRadius = Shader.PropertyToID("_OuterRadius"); private static readonly int OuterRadius = Shader.PropertyToID("_OuterRadius");
@ -47,6 +49,7 @@ namespace NewHorizons.Builder.Body
if (starModule.tint != null) if (starModule.tint != null)
{ {
fog.fogTint = starModule.tint.ToColor(); fog.fogTint = starModule.tint.ToColor();
fog.fogImpostor.material.SetColor(Tint, starModule.tint.ToColor());
sunAtmosphere.transform.Find("AtmoSphere").transform.localScale = Vector3.one; sunAtmosphere.transform.Find("AtmoSphere").transform.localScale = Vector3.one;
foreach (var lod in sunAtmosphere.transform.Find("AtmoSphere").GetComponentsInChildren<MeshRenderer>()) foreach (var lod in sunAtmosphere.transform.Find("AtmoSphere").GetComponentsInChildren<MeshRenderer>())
{ {
@ -60,6 +63,7 @@ namespace NewHorizons.Builder.Body
fog.transform.localScale = Vector3.one; fog.transform.localScale = Vector3.one;
fog.fogRadius = starModule.size * OuterRadiusRatio; fog.fogRadius = starModule.size * OuterRadiusRatio;
fog.lodFadeDistance = fog.fogRadius * (StarBuilder.OuterRadiusRatio - 1f); fog.lodFadeDistance = fog.fogRadius * (StarBuilder.OuterRadiusRatio - 1f);
fog.fogImpostor.material.SetFloat(Radius, starModule.size * OuterRadiusRatio);
} }
var ambientLightGO = Object.Instantiate(SearchUtilities.Find("Sun_Body/AmbientLight_SUN"), starGO.transform); var ambientLightGO = Object.Instantiate(SearchUtilities.Find("Sun_Body/AmbientLight_SUN"), starGO.transform);
@ -140,6 +144,16 @@ namespace NewHorizons.Builder.Body
controller.StartColour = starModule.tint; controller.StartColour = starModule.tint;
controller.EndColour = starModule.endTint; controller.EndColour = starModule.endTint;
controller.WillExplode = starModule.goSupernova; controller.WillExplode = starModule.goSupernova;
if (!string.IsNullOrEmpty(starModule.starRampTexture))
{
var ramp = ImageUtilities.GetTexture(mod, starModule.starRampTexture);
controller.normalRamp = ramp;
}
if (!string.IsNullOrEmpty(starModule.starCollapseRampTexture))
{
var ramp = ImageUtilities.GetTexture(mod, starModule.starCollapseRampTexture);
controller.collapseRamp = ramp;
}
surfaceAudio.SetStarEvolutionController(controller); surfaceAudio.SetStarEvolutionController(controller);
starGO.SetActive(true); starGO.SetActive(true);
@ -212,7 +226,7 @@ namespace NewHorizons.Builder.Body
foreach (var controller in solarFlareEmitter.GetComponentsInChildren<SolarFlareController>()) foreach (var controller in solarFlareEmitter.GetComponentsInChildren<SolarFlareController>())
{ {
// It multiplies color by tint but wants something very bright idk // It multiplies color by tint but wants something very bright idk
controller._color = new Color(11, 11, 11); controller._color = new Color(1, 1, 1);
controller.GetComponent<MeshRenderer>().sharedMaterial.SetColor("_Color", controller._color); controller.GetComponent<MeshRenderer>().sharedMaterial.SetColor("_Color", controller._color);
controller._tint = flareTint; controller._tint = flareTint;
} }

View File

@ -365,43 +365,42 @@ namespace NewHorizons.Builder.Props
{ {
GameObject arc; GameObject arc;
var type = arcInfo != null ? arcInfo.type : PropModule.NomaiTextArcInfo.NomaiTextArcType.Adult; var type = arcInfo != null ? arcInfo.type : PropModule.NomaiTextArcInfo.NomaiTextArcType.Adult;
var variation = arcInfo.variation; var variation = arcInfo == null ? arcInfo.variation : -1;
switch (type) switch (type)
{ {
case PropModule.NomaiTextArcInfo.NomaiTextArcType.Child: case PropModule.NomaiTextArcInfo.NomaiTextArcType.Child:
variation = arcInfo.variation < 0 variation = variation < 0
? Random.Range(0, _childArcPrefabs.Count()) ? Random.Range(0, _childArcPrefabs.Count())
: (arcInfo.variation % _childArcPrefabs.Count()); : (variation % _childArcPrefabs.Count());
arc = _childArcPrefabs[variation].InstantiateInactive(); arc = _childArcPrefabs[variation].InstantiateInactive();
break; break;
case PropModule.NomaiTextArcInfo.NomaiTextArcType.Stranger when _ghostArcPrefabs.Any(): case PropModule.NomaiTextArcInfo.NomaiTextArcType.Stranger when _ghostArcPrefabs.Any():
variation = arcInfo.variation < 0 variation = variation < 0
? Random.Range(0, _ghostArcPrefabs.Count()) ? Random.Range(0, _ghostArcPrefabs.Count())
: (arcInfo.variation % _ghostArcPrefabs.Count()); : (variation % _ghostArcPrefabs.Count());
arc = _ghostArcPrefabs[variation].InstantiateInactive(); arc = _ghostArcPrefabs[variation].InstantiateInactive();
break; break;
case PropModule.NomaiTextArcInfo.NomaiTextArcType.Adult: case PropModule.NomaiTextArcInfo.NomaiTextArcType.Adult:
default: default:
variation = arcInfo.variation < 0 variation = variation < 0
? Random.Range(0, _arcPrefabs.Count()) ? Random.Range(0, _arcPrefabs.Count())
: (arcInfo.variation % _arcPrefabs.Count()); : (variation % _arcPrefabs.Count());
arc = _arcPrefabs[variation].InstantiateInactive(); arc = _arcPrefabs[variation].InstantiateInactive();
break; break;
} }
arcInfo.variation = variation;
arc.transform.parent = conversationZone.transform; arc.transform.parent = conversationZone.transform;
arc.GetComponent<NomaiTextLine>()._prebuilt = false; arc.GetComponent<NomaiTextLine>()._prebuilt = false;
if (arcInfo != null) if (arcInfo != null)
{ {
var a = arcInfo; arcInfo.variation = variation;
if (a.position == null) arc.transform.localPosition = Vector3.zero; if (arcInfo.position == null) arc.transform.localPosition = Vector3.zero;
else arc.transform.localPosition = new Vector3(a.position.x, a.position.y, 0); else arc.transform.localPosition = new Vector3(arcInfo.position.x, arcInfo.position.y, 0);
arc.transform.localRotation = Quaternion.Euler(0, 0, a.zRotation); arc.transform.localRotation = Quaternion.Euler(0, 0, arcInfo.zRotation);
if (a.mirror) arc.transform.localScale = new Vector3(-1, 1, 1); if (arcInfo.mirror) arc.transform.localScale = new Vector3(-1, 1, 1);
} }
// Try auto I guess // Try auto I guess
else else
@ -425,7 +424,7 @@ namespace NewHorizons.Builder.Props
arc.SetActive(true); arc.SetActive(true);
arcInfoToCorrespondingSpawnedGameObject[arcInfo] = arc; if (arcInfo != null) arcInfoToCorrespondingSpawnedGameObject[arcInfo] = arc;
return arc; return arc;
} }

View File

@ -18,6 +18,8 @@ namespace NewHorizons.Components.SizeControllers
public bool WillExplode { get; set; } public bool WillExplode { get; set; }
public MColor StartColour { get; set; } public MColor StartColour { get; set; }
public MColor EndColour { get; set; } public MColor EndColour { get; set; }
public Texture normalRamp;
public Texture collapseRamp;
private Color _startColour; private Color _startColour;
private Color _endColour; private Color _endColour;
@ -43,6 +45,8 @@ namespace NewHorizons.Components.SizeControllers
private Material _collapseEndSurfaceMaterial; private Material _collapseEndSurfaceMaterial;
private Material _startSurfaceMaterial; private Material _startSurfaceMaterial;
private Material _endSurfaceMaterial; private Material _endSurfaceMaterial;
private Texture _normalRamp;
private Texture _collapseRamp;
private StarEvolutionController _proxy; private StarEvolutionController _proxy;
@ -59,13 +63,26 @@ namespace NewHorizons.Components.SizeControllers
_startSurfaceMaterial = new Material(sun._startSurfaceMaterial); _startSurfaceMaterial = new Material(sun._startSurfaceMaterial);
_endSurfaceMaterial = new Material(sun._endSurfaceMaterial); _endSurfaceMaterial = new Material(sun._endSurfaceMaterial);
var supernovaSurfaceColorRamp = supernova._surface.sharedMaterial.GetTexture(ColorRamp); if (normalRamp == null)
{
_normalRamp = sun._startSurfaceMaterial.GetTexture(ColorRamp);
} else
{
_normalRamp = normalRamp;
}
if (collapseRamp == null)
{
_collapseRamp = sun._collapseStartSurfaceMaterial.GetTexture(ColorRamp);
} else
{
_collapseRamp = collapseRamp;
}
// Copy over the material that was set in star builder // Copy over the material that was set in star builder
_collapseStartSurfaceMaterial.SetTexture(ColorRamp, supernovaSurfaceColorRamp); _collapseStartSurfaceMaterial.SetTexture(ColorRamp, _collapseRamp);
_collapseEndSurfaceMaterial.SetTexture(ColorRamp, supernovaSurfaceColorRamp); _collapseEndSurfaceMaterial.SetTexture(ColorRamp, _collapseRamp);
_startSurfaceMaterial.SetTexture(ColorRamp, supernovaSurfaceColorRamp); _startSurfaceMaterial.SetTexture(ColorRamp, _normalRamp);
_endSurfaceMaterial.SetTexture(ColorRamp, supernovaSurfaceColorRamp); _endSurfaceMaterial.SetTexture(ColorRamp, _normalRamp);
if (StartColour == null) if (StartColour == null)
{ {
@ -85,7 +102,7 @@ namespace NewHorizons.Components.SizeControllers
else else
{ {
_endColour = EndColour.ToColor(); _endColour = EndColour.ToColor();
_endSurfaceMaterial.color = _endColour; _endSurfaceMaterial.color = _startColour * 4.5948f;
} }
_heatVolume = GetComponentInChildren<HeatHazardVolume>(); _heatVolume = GetComponentInChildren<HeatHazardVolume>();
@ -129,6 +146,7 @@ namespace NewHorizons.Components.SizeControllers
_isCollapsing = true; _isCollapsing = true;
_collapseStartSize = CurrentScale; _collapseStartSize = CurrentScale;
_collapseTimer = 0f; _collapseTimer = 0f;
supernova._surface._materials[0].CopyPropertiesFromMaterial(_collapseStartSurfaceMaterial);
if (_proxy != null) _proxy.Die(); if (_proxy != null) _proxy.Die();
} }

View File

@ -61,6 +61,11 @@ namespace NewHorizons.External.Modules.VariableSize
/// </summary> /// </summary>
public string starRampTexture; public string starRampTexture;
/// <summary>
/// Path to the texture to put as the star ramp while it is collapsing. Optional.
/// </summary>
public string starCollapseRampTexture;
/// <summary> /// <summary>
/// How far the light from the star can reach. /// How far the light from the star can reach.
/// </summary> /// </summary>

View File

@ -1976,6 +1976,10 @@
"type": "string", "type": "string",
"description": "Path to the texture to put as the star ramp. Optional." "description": "Path to the texture to put as the star ramp. Optional."
}, },
"starCollapseRampTexture": {
"type": "string",
"description": "Path to the texture to put as the star ramp while it is collapsing. Optional."
},
"lightRadius": { "lightRadius": {
"type": "number", "type": "number",
"description": "How far the light from the star can reach.", "description": "How far the light from the star can reach.",