using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("MoonPhaseConfig")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MoonPhaseConfig")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("20dc016f-4ecd-46b5-905c-40cb2673eb3a")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MoonPhaseConfig;
[BepInPlugin("yazirushi.MoonPhaseConfig", "MoonPhaseConfig", "1.0.0")]
public class MoonPhaseConfig : BaseUnityPlugin
{
private readonly Harmony harmony = new Harmony("yazirushi.MoonPhaseConfig");
internal static ManualLogSource mls;
public static ConfigEntry<int> Moon_Lv1;
public static ConfigEntry<int> Moon_Lv2;
public static ConfigEntry<int> Moon_Lv3;
public static ConfigEntry<int> Moon_Lv4;
public static ConfigEntry<bool> EnableLogging;
private void Awake()
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected O, but got Unknown
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Expected O, but got Unknown
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Expected O, but got Unknown
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Expected O, but got Unknown
Moon_Lv1 = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Crescent Moon", 2, new ConfigDescription("三日月までに必要なレベル数", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000), Array.Empty<object>()));
Moon_Lv2 = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Half Moon", 3, new ConfigDescription("三日月から半月までに必要なレベル数", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000), Array.Empty<object>()));
Moon_Lv3 = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Full Moon", 4, new ConfigDescription("半月から満月までに必要なレベル数", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000), Array.Empty<object>()));
Moon_Lv4 = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Super Moon", 5, new ConfigDescription("満月からスーパームーンまでに必要なレベル数", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000), Array.Empty<object>()));
EnableLogging = ((BaseUnityPlugin)this).Config.Bind<bool>("ConsoleLog", "EnableLogging", false, "ログの有効化");
mls = ((BaseUnityPlugin)this).Logger;
mls.LogInfo((object)"MoonPhaseConfigが起動しました!");
mls.LogInfo((object)$"MoonPhaseConfig:Config:Crescent Moon = {Moon_Lv1.Value}");
mls.LogInfo((object)$"MoonPhaseConfig:Config:Half Moon = {Moon_Lv2.Value}");
mls.LogInfo((object)$"MoonPhaseConfig:Config:Full Moon = {Moon_Lv3.Value}");
mls.LogInfo((object)$"MoonPhaseConfig:Config:Super Moon = {Moon_Lv4.Value}");
mls.LogInfo((object)$"MoonPhaseConfig:Config:EnableLogging = {EnableLogging.Value}");
harmony.PatchAll();
}
}
[HarmonyPatch(typeof(RunManager), "CalculateMoonLevel")]
public class MoonPhasePatch
{
private static bool Prefix(ref int __result, int _levelsCompleted)
{
int value = MoonPhaseConfig.Moon_Lv1.Value;
int value2 = MoonPhaseConfig.Moon_Lv2.Value;
int value3 = MoonPhaseConfig.Moon_Lv3.Value;
int value4 = MoonPhaseConfig.Moon_Lv4.Value;
int num = _levelsCompleted + 1;
int num2 = 0;
if (num >= value)
{
num2++;
num -= value;
if (MoonPhaseConfig.EnableLogging.Value)
{
MoonPhaseConfig.mls.LogInfo((object)"MoonPhaseConfig:moonlv1");
}
if (num >= value2)
{
num2++;
num -= value2;
if (MoonPhaseConfig.EnableLogging.Value)
{
MoonPhaseConfig.mls.LogInfo((object)"MoonPhaseConfig:moonlv2");
}
if (num >= value3)
{
num2++;
num -= value3;
if (MoonPhaseConfig.EnableLogging.Value)
{
MoonPhaseConfig.mls.LogInfo((object)"MoonPhaseConfig:moonlv3");
}
if (num >= value4)
{
num2++;
num -= value4;
if (MoonPhaseConfig.EnableLogging.Value)
{
MoonPhaseConfig.mls.LogInfo((object)"MoonPhaseConfig:moonlv4");
}
}
}
}
}
__result = num2;
if (MoonPhaseConfig.EnableLogging.Value)
{
MoonPhaseConfig.mls.LogInfo((object)$"MoonPhaseConfig:resultmoonlv = {__result}");
}
return false;
}
}