using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using LBoL.Base;
using LBoL.Core.Units;
using LBoL.EntityLib.PlayerUnits;
using LBoL.Presentation.I10N;
using LBoL.Presentation.UI.Panels;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("DailySeed")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+0a8b13fd044ce7efdf78cf07f1731933ea974f71")]
[assembly: AssemblyProduct("DailySeed")]
[assembly: AssemblyTitle("DailySeed")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace DailySeed
{
[BepInPlugin("emisocks.lbol.dailyseed", "Daily Seed", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Logger;
private static bool dailyRunSelected;
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Harmony.CreateAndPatchAll(typeof(Plugin), (string)null);
}
[HarmonyPatch(typeof(StartGamePanel), "Awake")]
[HarmonyPostfix]
private static void AfterAwake(StartGamePanel __instance)
{
//IL_0067: 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_0076: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Expected O, but got Unknown
Transform val = ((Component)__instance).transform.Find("CharacterPanel/TopRoot");
GameObject nextButton = ((Component)val.Find("NextButton")).gameObject;
GameObject obj = Object.Instantiate<GameObject>(nextButton, val);
((Object)obj).name = "DailyRunButton";
((Behaviour)obj.GetComponentInChildren<LocalizedText>()).enabled = false;
((TMP_Text)obj.GetComponentInChildren<TextMeshProUGUI>()).text = "Daily Run";
Transform transform = obj.transform;
transform.position += Vector3.upVector * 0.9f;
Button component = obj.GetComponent<Button>();
((UnityEventBase)component.onClick).RemoveAllListeners();
((UnityEvent)component.onClick).AddListener((UnityAction)delegate
{
dailyRunSelected = true;
((UnityEvent)nextButton.GetComponent<Button>().onClick).Invoke();
});
}
[HarmonyPatch(typeof(StartGamePanel), "ConfirmSelectCharacter")]
[HarmonyPrefix]
private static void BeforeConfirmSelectCharacter(StartGamePanel __instance)
{
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
TMP_InputField value = Traverse.Create((object)__instance).Field("seedInputText").GetValue<TMP_InputField>();
if (dailyRunSelected)
{
dailyRunSelected = false;
long num = ((DateTimeOffset)DateTime.UtcNow.Date).ToUnixTimeSeconds();
Random random = new Random((int)num);
List<PlayerUnit> value2 = Traverse.Create((object)__instance).Field("_players").GetValue<List<PlayerUnit>>();
List<PlayerUnit> list = value2.Where((PlayerUnit unit) => unit is Reimu || unit is Marisa || unit is Sakuya || unit is Cirno || unit is Koishi).ToList();
PlayerUnit item = list[random.Next(list.Count())];
int num2 = value2.IndexOf(item);
Traverse.Create((object)__instance).Method("SelectPlayer", new object[2] { num2, false }).GetValue(new object[2] { num2, false });
int num3 = random.Next(2);
Traverse.Create((object)__instance).Method("SelectType", new object[1] { num3 }).GetValue(new object[1] { num3 });
string text2 = (value.text = RandomGen.SeedToString(new RandomGen((ulong)num).NextULong()));
Traverse.Create((object)__instance).Method("OnSeedConfirmButtonClicked", Array.Empty<object>()).GetValue();
Logger.LogInfo((object)"Daily run selected");
Logger.LogInfo((object)$"Date timestamp: {num}");
Logger.LogInfo((object)$"Random character: {num2}");
Logger.LogInfo((object)$"Random type: {num3}");
Logger.LogInfo((object)("Random seed: " + text2));
}
else
{
value.text = "";
Traverse.Create((object)__instance).Method("OnSeedConfirmButtonClicked", Array.Empty<object>()).GetValue();
}
}
}
public static class PluginInfo
{
public const string GUID = "emisocks.lbol.dailyseed";
public const string NAME = "Daily Seed";
public const string VERSION = "1.0.0";
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "DailySeed";
public const string PLUGIN_NAME = "DailySeed";
public const string PLUGIN_VERSION = "1.0.0";
}
}