using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using ChangeMoons.Functions;
using ChangeMoons.GUI;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ChangeChallenge")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+50a820beea3d238ccf7e7bd7c052ea214c860435")]
[assembly: AssemblyProduct("ChangeChallenge")]
[assembly: AssemblyTitle("ChangeChallenge")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
namespace ChangeMoons
{
[BepInPlugin("ChangeChallenge", "ChangeChallenge", "1.0.0")]
public class Loader : BaseUnityPlugin
{
private const string GUID = "ChangeChallenge";
private const string NAME = "ChangeChallenge";
private const string VERSION = "1.0.0";
private readonly Harmony harmony = new Harmony("ChangeChallenge");
private static Loader Instance;
public static ManualLogSource mls;
public static ChangeMoonGUI myGUI;
private void Awake()
{
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Expected O, but got Unknown
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("ChangeChallenge");
mls.LogInfo((object)"[+] ChangeChallenge 1.0.0 loaded!");
harmony.PatchAll();
harmony.PatchAll(typeof(PatchChallengeWeek));
GameObject val = new GameObject("ChangeMoons GUI");
Object.DontDestroyOnLoad((Object)(object)val);
((Object)val).hideFlags = (HideFlags)61;
val.AddComponent<ChangeMoonGUI>();
myGUI = (ChangeMoonGUI)(object)val.GetComponent("ChangeMoons GUI");
}
}
public class PatchChallengeWeek : MonoBehaviour
{
[HarmonyPatch(typeof(GameNetworkManager), "GetWeekNumber")]
private static bool Prefix(GameNetworkManager __instance, ref int __result)
{
DateTime dateTime = new DateTime(2023, 12, 11);
try
{
DateTime utcNow = DateTime.UtcNow;
}
catch (Exception arg)
{
Debug.LogError((object)$"Unable to get UTC time; defaulting to system date time; {arg}");
DateTime utcNow = DateTime.Today;
}
__result = ChangeMoonGUI.selectedMoon;
return false;
}
}
}
namespace ChangeMoons.GUI
{
public class ChangeMoonGUI : MonoBehaviour
{
public static bool showMenu = false;
public static bool lockedCursor = false;
private const int GUI_WIDTH = 250;
private const int GUI_HEIGHT = 300;
private static float GUI_X_POS = Screen.width / 2 - 125;
private static float GUI_T_POS = Screen.height / 2 - 150;
private Rect MAIN_WINDOW = new Rect((float)(Screen.width / 2), (float)(Screen.height / 2), 250f, 225f);
private float scrollPos = 0f;
private Vector2 scrollPosition = Vector2.zero;
private Rect scrollViewRect = new Rect(5f, 45f, 230f, 155f);
public static int selectedMoon = ChangeMoons.Functions.Functions.GetWeekNumber();
private static string weekNumText = "Challenge week number";
private void Awake()
{
Loader.mls.LogInfo((object)"[+] GUI Loaded!");
}
private void Update()
{
if (((ButtonControl)Keyboard.current[(Key)70]).wasPressedThisFrame)
{
showMenu = !showMenu;
Cursor.visible = showMenu;
Cursor.lockState = (CursorLockMode)2;
QuickMenuManager val = Object.FindObjectOfType<QuickMenuManager>();
if (!((Object)(object)val == (Object)null))
{
val.isMenuOpen = showMenu;
}
}
}
private void OnGUI()
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Expected O, but got Unknown
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
if (showMenu)
{
MAIN_WINDOW = GUI.Window(0, MAIN_WINDOW, new WindowFunction(doWindow), "Challenge Moon Selector");
}
}
private void doWindow(int windowID)
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
scrollPos = GUI.VerticalScrollbar(new Rect(230f, 20f, 250f, 135f), scrollPos, 50f, 1f, 1300f);
scrollPosition = GUILayout.BeginScrollView(scrollPosition, (GUILayoutOption[])(object)new GUILayoutOption[2]
{
GUILayout.Width(((Rect)(ref scrollViewRect)).width),
GUILayout.Height(((Rect)(ref scrollViewRect)).height)
});
GUI.Box(new Rect(5f, 20f, 220f, 135f), "Upcoming moons: ");
float num = 0f;
GUILayout.BeginArea(scrollViewRect);
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
if ((Object)(object)GameNetworkManager.Instance != (Object)null)
{
int weekNumber = ChangeMoons.Functions.Functions.GetWeekNumber();
for (int i = weekNumber; i <= 50; i++)
{
string nameForWeekNumber = GameNetworkManager.Instance.GetNameForWeekNumber(i);
string text = ChangeMoons.Functions.Functions.GetWeekNumber().ToString();
if (GUI.Button(new Rect(5f, num - scrollPos, 210f, 30f), i + ": " + nameForWeekNumber))
{
selectedMoon = i;
}
num += 30f;
}
}
GUILayout.EndArea();
GUILayout.EndVertical();
GUILayout.EndScrollView();
weekNumText = GUI.TextField(new Rect(5f, 160f, 240f, 25f), weekNumText);
if (GUI.Button(new Rect(5f, 190f, 240f, 30f), "Send"))
{
if (int.Parse(weekNumText) > int.MaxValue)
{
return;
}
try
{
selectedMoon = int.Parse(weekNumText);
}
catch (FormatException)
{
return;
}
}
GUILayout.EndVertical();
GUI.DragWindow();
}
}
}
namespace ChangeMoons.Functions
{
public class Functions : MonoBehaviour
{
public static int GetWeekNumber()
{
DateTime dateTime = new DateTime(2023, 12, 11);
DateTime dateTime2;
try
{
dateTime2 = DateTime.UtcNow;
}
catch (Exception)
{
dateTime2 = DateTime.Today;
}
return (int)((dateTime2 - dateTime).TotalDays / 7.0);
}
}
}