using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("UltraNightLight")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Its more than super")]
[assembly: AssemblyFileVersion("2.1.0.0")]
[assembly: AssemblyInformationalVersion("2.1.0")]
[assembly: AssemblyProduct("UltraNightLight")]
[assembly: AssemblyTitle("UltraNightLight")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.1.0.0")]
[module: UnverifiableCode]
[BepInPlugin("UltraNightLight", "Ultra Night Light", "2.1.0")]
[BepInProcess("DSPGAME.exe")]
public class UltraNightLight : BaseUnityPlugin
{
public static ManualLogSource Debug;
public static ConfigEntry<int> Xangle;
public static ConfigEntry<int> Yangle;
public static bool mIsEnable;
public ConfigEntry<KeyboardShortcut> mEnableKey;
private int mPhase;
private AnimationState mSail;
private Light mSunLight;
public ConfigEntry<KeyboardShortcut> mXDecKey;
public ConfigEntry<KeyboardShortcut> mXIncKey;
public ConfigEntry<KeyboardShortcut> mYDecKey;
public ConfigEntry<KeyboardShortcut> mYIncKey;
private void Reset()
{
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
if (mIsEnable)
{
mIsEnable = false;
}
if ((Object)(object)mSunLight != (Object)null)
{
((Component)mSunLight).transform.localEulerAngles = new Vector3(0f, 180f);
mSunLight = null;
}
}
private void Start()
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
Debug = ((BaseUnityPlugin)this).Logger;
((BaseUnityPlugin)this).Logger.LogInfo((object)"Mod Installing.");
mEnableKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Turn On/Off", new KeyboardShortcut((KeyCode)108, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), (ConfigDescription)null);
mXDecKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Decrease Angle X", new KeyboardShortcut((KeyCode)106, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), (ConfigDescription)null);
mXIncKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Increase Angle X", new KeyboardShortcut((KeyCode)107, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), (ConfigDescription)null);
mYDecKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Decrease Angle Y", new KeyboardShortcut((KeyCode)105, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), (ConfigDescription)null);
mYIncKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Increase Angle Y", new KeyboardShortcut((KeyCode)109, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), (ConfigDescription)null);
Xangle = ((BaseUnityPlugin)this).Config.Bind<int>("Variables", "XAngle", 0, "Angle Modifier X Axis");
Yangle = ((BaseUnityPlugin)this).Config.Bind<int>("Variables", "YAngle", 0, "Angle Modifier Y Axis");
mIsEnable = false;
mPhase = 1;
Harmony.CreateAndPatchAll(typeof(UltraNightLight), (string)null);
}
private void LateUpdate()
{
switch (mPhase)
{
case 1:
Ready();
break;
case 2:
Go();
break;
}
}
private void OnDestroy()
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"Mod Uninstalled.");
}
public void InitUI()
{
}
private void Ready()
{
if (GameMain.isRunning && ((Component)GameMain.mainPlayer.controller.model).gameObject.activeInHierarchy)
{
if ((TrackedReference)(object)mSail == (TrackedReference)null)
{
mSail = GameMain.mainPlayer.animator.sails[GameMain.mainPlayer.animator.sailAnimIndex];
}
mPhase = 2;
}
}
private void Go()
{
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
//IL_0249: Unknown result type (might be due to invalid IL or missing references)
//IL_024e: Unknown result type (might be due to invalid IL or missing references)
//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
//IL_030c: Unknown result type (might be due to invalid IL or missing references)
//IL_031c: Unknown result type (might be due to invalid IL or missing references)
//IL_0326: Unknown result type (might be due to invalid IL or missing references)
//IL_032b: Unknown result type (might be due to invalid IL or missing references)
//IL_033a: Unknown result type (might be due to invalid IL or missing references)
//IL_034a: Unknown result type (might be due to invalid IL or missing references)
//IL_0354: Unknown result type (might be due to invalid IL or missing references)
//IL_0359: Unknown result type (might be due to invalid IL or missing references)
//IL_035e: Unknown result type (might be due to invalid IL or missing references)
//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
if (!GameMain.isRunning)
{
End();
return;
}
if (mSail.enabled)
{
if (mIsEnable)
{
Reset();
}
return;
}
KeyboardShortcut value = mXIncKey.Value;
if (((KeyboardShortcut)(ref value)).IsDown())
{
ConfigEntry<int> xangle = Xangle;
int value2 = xangle.Value;
xangle.Value = value2 + 1;
if (Xangle.Value > 30)
{
Xangle.Value = 30;
}
Debug.LogInfo((object)$"Sun X angle: {Xangle}");
((BaseUnityPlugin)this).Config.Save();
}
value = mXDecKey.Value;
if (((KeyboardShortcut)(ref value)).IsDown())
{
ConfigEntry<int> xangle2 = Xangle;
int value2 = xangle2.Value;
xangle2.Value = value2 - 1;
if (Xangle.Value < -30)
{
Xangle.Value = -30;
}
Debug.LogInfo((object)$"Sun X angle: {Xangle.Value}");
((BaseUnityPlugin)this).Config.Save();
}
value = mYIncKey.Value;
if (((KeyboardShortcut)(ref value)).IsDown())
{
ConfigEntry<int> yangle = Yangle;
int value2 = yangle.Value;
yangle.Value = value2 + 1;
if (Yangle.Value > 30)
{
Yangle.Value = 30;
}
Debug.LogInfo((object)$"Sun Y angle: {Yangle.Value}");
((BaseUnityPlugin)this).Config.Save();
}
value = mYDecKey.Value;
if (((KeyboardShortcut)(ref value)).IsDown())
{
ConfigEntry<int> yangle2 = Yangle;
int value2 = yangle2.Value;
yangle2.Value = value2 - 1;
if (Yangle.Value < -30)
{
Yangle.Value = -30;
}
Debug.LogInfo((object)$"Sun Y angle: {Yangle.Value}");
((BaseUnityPlugin)this).Config.Save();
}
value = mEnableKey.Value;
if (((KeyboardShortcut)(ref value)).IsDown())
{
if ((Object)(object)mSunLight == (Object)null)
{
mSunLight = GameMain.universeSimulator.LocalStarSimulator().sunLight;
}
if ((Object)(object)mSunLight != (Object)null)
{
mIsEnable = !mIsEnable;
if (!mIsEnable)
{
((Component)mSunLight).transform.localEulerAngles = new Vector3(0f, 180f);
}
}
}
if (mIsEnable)
{
((Component)mSunLight).transform.rotation = Quaternion.LookRotation(-GameMain.mainPlayer.transform.up + GameMain.mainPlayer.transform.forward * (float)Xangle.Value / 10f + GameMain.mainPlayer.transform.right * (float)Yangle.Value / 10f);
}
}
private void End()
{
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
if (mIsEnable)
{
mIsEnable = false;
}
if ((Object)(object)mSunLight != (Object)null)
{
((Component)mSunLight).transform.localEulerAngles = new Vector3(0f, 180f);
mSunLight = null;
}
if ((TrackedReference)(object)mSail != (TrackedReference)null)
{
mSail = null;
}
if (mPhase != 1)
{
mPhase = 1;
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(StarSimulator), "LateUpdate")]
public static bool SSLateUpdatePatch(ref StarSimulator __instance, Material ___bodyMaterial, Material ___haloMaterial)
{
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_018a: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: Unknown result type (might be due to invalid IL or missing references)
//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0231: Unknown result type (might be due to invalid IL or missing references)
//IL_0237: Invalid comparison between Unknown and I4
((Behaviour)__instance.sunLight).enabled = GameMain.localStar == __instance.starData && !FactoryModel.whiteMode0;
if (GameMain.localStar == __instance.starData)
{
if (!FactoryModel.whiteMode0)
{
Vector3 val = (mIsEnable ? GameMain.mainPlayer.transform.up : ((Component)__instance).transform.forward);
Shader.SetGlobalVector("_Global_SunDir", new Vector4(val.x, val.y, val.z, 0f));
Shader.SetGlobalColor("_Global_SunsetColor0", Color.Lerp(Color.white, __instance.sunsetColor0, __instance.useSunsetColor));
Shader.SetGlobalColor("_Global_SunsetColor1", Color.Lerp(Color.white, __instance.sunsetColor1, __instance.useSunsetColor));
Shader.SetGlobalColor("_Global_SunsetColor2", Color.Lerp(Color.white, __instance.sunsetColor2, __instance.useSunsetColor));
}
else
{
Transform transform = ((Component)GameCamera.instance.camLight).transform;
Vector3 val2 = GameMain.mainPlayer.position * 0.75f - transform.position;
Vector3 normalized = ((Vector3)(ref val2)).normalized;
val2 = transform.position;
transform.rotation = Quaternion.LookRotation(normalized, ((Vector3)(ref val2)).normalized);
Vector3 val3 = -((Component)GameCamera.instance.camLight).transform.forward;
Shader.SetGlobalVector("_Global_SunDir", new Vector4(val3.x, val3.y, val3.z, 0f));
Shader.SetGlobalColor("_Global_SunsetColor0", Color.red);
Shader.SetGlobalColor("_Global_SunsetColor1", Color.red);
Shader.SetGlobalColor("_Global_SunsetColor2", Color.red);
}
}
___bodyMaterial.renderQueue = ((GameMain.localStar == __instance.starData) ? 2981 : 2979);
___haloMaterial.renderQueue = ((GameMain.localStar == __instance.starData) ? 2981 : 2979);
__instance.blackRenderer.enabled = GameMain.localStar == __instance.starData && (int)__instance.starData.type != 4;
__instance.GpuAnalysis();
return false;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(PlanetSimulator), "LateUpdate")]
public static void PSLateUpdatePatch(PlanetSimulator __instance)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
PlanetData localPlanet = GameMain.localPlanet;
if (localPlanet == __instance.planetData && localPlanet != null)
{
Quaternion identity = Quaternion.identity;
Vector3 val3;
if (!mIsEnable)
{
Quaternion val = Quaternion.Inverse(localPlanet.runtimeRotation);
VectorLF3 val2 = __instance.planetData.star.uPosition - __instance.planetData.uPosition;
val3 = val * VectorLF3.op_Implicit(((VectorLF3)(ref val2)).normalized);
}
else
{
val3 = GameMain.mainPlayer.transform.up;
}
Vector3 val4 = val3;
if (FactoryModel.whiteMode0)
{
val4 = -((Component)GameCamera.instance.camLight).transform.forward;
}
if (__instance.surfaceRenderer != null && __instance.surfaceRenderer.Length != 0)
{
__instance.surfaceRenderer[0].sharedMaterial.SetVector("_SunDir", Vector4.op_Implicit(val4));
}
if ((Object)(object)__instance.reformMat0 != (Object)null)
{
__instance.reformMat0.SetVector("_SunDir", Vector4.op_Implicit(val4));
}
if ((Object)(object)__instance.reformMat1 != (Object)null)
{
__instance.reformMat1.SetVector("_SunDir", Vector4.op_Implicit(val4));
}
if ((Object)(object)__instance.atmoMat != (Object)null)
{
__instance.atmoMat.SetVector("_SunDir", Vector4.op_Implicit(val4));
}
}
}
}
namespace GalacticScale;
public static class PluginInfo
{
public const string PLUGIN_GUID = "UltraNightLight";
public const string PLUGIN_NAME = "UltraNightLight";
public const string PLUGIN_VERSION = "2.1.0";
}