SHA256
Add Planet Color Config
This commit is contained in:
6 files changed
+291
-43
No files matched your search
@@ -18,4 +18,20 @@ public static class PersistencePatch
|
||||
__result = SkipIntroBehavior.Off;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch("GetPlayerColor")]
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public static void OverridePlayerColor(bool red, ref PlanetColor __result)
|
||||
{
|
||||
if (!RenderManager.Instance || RenderManager.Instance.stage == RenderStage.None) return;
|
||||
var advConf = RenderManager.Instance.Configuration.AdvancedConfig;
|
||||
|
||||
__result = red switch
|
||||
{
|
||||
true when advConf.firePlanetColor.HasValue => new PlanetColor(advConf.firePlanetColor.Value),
|
||||
false when advConf.icePlanetColor.HasValue => new PlanetColor(advConf.icePlanetColor.Value),
|
||||
_ => __result
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
using ADOFAIRenderer.Core;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ADOFAIRenderer.Patch.Game;
|
||||
|
||||
[HarmonyPatch(typeof(PlanetRenderer))]
|
||||
public static class PlanetRendererPatch
|
||||
{
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch("SetColor")]
|
||||
// ReSharper disable once InconsistentNaming
|
||||
private static void OverrideColor(PlanetRenderer __instance, ref PlanetColor planetColor)
|
||||
{
|
||||
if (RenderManager.Instance.stage == RenderStage.None) return;
|
||||
|
||||
var advConf = RenderManager.Instance.Configuration.AdvancedConfig;
|
||||
ApplyColor(ref planetColor, scrController.instance.planetRed, advConf.firePlanetColor);
|
||||
ApplyColor(ref planetColor, scrController.instance.planetBlue, advConf.icePlanetColor);
|
||||
ApplyColor(ref planetColor, scrController.instance.planetGreen, advConf.windPlanetColor);
|
||||
|
||||
return;
|
||||
|
||||
void ApplyColor(ref PlanetColor planetColor, scrPlanet? targetPlanet, Color? customColor)
|
||||
{
|
||||
if (targetPlanet != null && __instance == targetPlanet.planetRenderer && customColor != null)
|
||||
planetColor = new PlanetColor(customColor.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using ADOFAIRenderer.Core;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace ADOFAIRenderer.Patch.Game;
|
||||
|
||||
[HarmonyPatch(typeof(PlanetarySystem))]
|
||||
public static class PlanetarySystemPatch
|
||||
{
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch("Init")]
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public static void OnInit(PlanetarySystem __instance)
|
||||
{
|
||||
ApplyWindPlanetColor(__instance);
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch("ApplyMultiplanetColors")]
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public static void OnApplyMultiplanetColors(PlanetarySystem __instance)
|
||||
{
|
||||
ApplyWindPlanetColor(__instance);
|
||||
}
|
||||
|
||||
private static void ApplyWindPlanetColor(PlanetarySystem planetarySystem)
|
||||
{
|
||||
if (RenderManager.Instance == null || RenderManager.Instance.stage == RenderStage.None) return;
|
||||
|
||||
var advConf = RenderManager.Instance.Configuration.AdvancedConfig;
|
||||
if (advConf.windPlanetColor.HasValue && planetarySystem.planetGreen)
|
||||
{
|
||||
planetarySystem.planetGreen.planetRenderer.SetColor(new PlanetColor(advConf.windPlanetColor.Value));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user