using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Atomicrops.Core.SoDb2;
using Atomicrops.Core.Upgrades;
using Atomicrops.Crops;
using Atomicrops.Game.Data;
using Atomicrops.Game.ParamsSystem;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using SharedLib;
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(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("CustomTimeCapsule")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CustomTimeCapsule")]
[assembly: AssemblyTitle("CustomTimeCapsule")]
[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 Template
{
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "CustomTimeCapsule";
public const string PLUGIN_NAME = "CustomTimeCapsule";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace CustomTimeCapsule
{
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "pauli.plugin.customtimecapsule";
public const string PLUGIN_NAME = "CustomTimeCapsule";
public const string PLUGIN_VERSION = "1.0.0";
}
[BepInPlugin("pauli.plugin.customtimecapsule", "CustomTimeCapsule", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
public static ManualLogSource Log;
private void Awake()
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
Log = ((BaseUnityPlugin)this).Logger;
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin pauli.plugin.customtimecapsule is loaded!");
new Harmony("pauli.plugin.customtimecapsule").PatchAll();
}
}
[HarmonyPatch(typeof(MetaPrevRunRewardUtils), "GenerateRewardModelAndClearPorfileFlag")]
public static class MetaPrevRunRewardUtilsPatch
{
private static List<UpgradeDef> NewGetUpgrades(List<int> upgradeIds)
{
List<UpgradeDef> list = new List<UpgradeDef>();
foreach (int upgradeId in upgradeIds)
{
UpgradeDef item = SoDb2Utils.GetItem<UpgradeDef>(upgradeId);
if ((Object)(object)item != (Object)null)
{
list.Add(item);
Plugin.Log.LogInfo((object)$"Upgrade Exists: {upgradeId}");
if (SingletonScriptableObject<GameData>.I.MainLootCollection.Contains(upgradeId))
{
SingletonScriptableObject<GameData>.I.MainLootCollection.Remove(upgradeId);
}
else if (SingletonScriptableObject<GameData>.I.SpecialLootCollection.Contains(upgradeId))
{
SingletonScriptableObject<GameData>.I.SpecialLootCollection.Remove(upgradeId);
}
else if (SingletonScriptableObject<GameData>.I.DeerShopLootCollection.Contains(upgradeId))
{
SingletonScriptableObject<GameData>.I.DeerShopLootCollection.Remove(upgradeId);
}
else if (SingletonScriptableObject<GameData>.I.GoldenChestLootCollection.Contains(upgradeId))
{
SingletonScriptableObject<GameData>.I.GoldenChestLootCollection.Remove(upgradeId);
}
else if (SingletonScriptableObject<GameData>.I.TreeUpgradeCollection.Contains(upgradeId) && !LiveParams.Meta.IsCrow)
{
SingletonScriptableObject<GameData>.I.TreeUpgradeCollection.Remove(upgradeId);
}
}
}
return list;
}
private static bool Prefix(ref MetaPrevRunRewardsModel __result)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
Plugin.Log.LogInfo((object)"GenerateRewardModelAndClearProfileFlag method of MetaPrevRunRewardUtils was called");
ProfileModel val = SingletonSceneScopeAutoLoad<ProfileModelController>.I.Get();
MetaPrevRunRewardsModel val2 = new MetaPrevRunRewardsModel();
List<int> list = new List<int>();
string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "upgradeIds.txt");
if (File.Exists(text))
{
string[] array = File.ReadAllLines(text);
string[] array2 = array;
foreach (string s in array2)
{
if (int.TryParse(s, out var result))
{
list.Add(result);
}
}
}
else
{
Plugin.Log.LogInfo((object)("File " + text + " not found. Make sure it exists in the correct directory."));
}
val2.Upgrades = NewGetUpgrades(list);
val2.HeartPieces = LiveParams.Meta.TimeCapSummerHeartPieces;
val2.Friends = new List<FriendDef>();
List<FriendDef> farmAnimalsLevel = SingletonScriptableObject<ConfigGame>.I.Friends.FarmAnimalsLevel1;
val2.Friends.Add(farmAnimalsLevel[Random.Range(0, farmAnimalsLevel.Count)]);
val2.Fertilizer = 30;
val2.Seeds = new List<CropDef>();
int num = 10;
for (int j = 0; j < num; j++)
{
List<CropDef> cropsByValue = CropDefLoader.GetCropsByValue((ValueTierEnum)0);
val2.Seeds.Add(cropsByValue[Random.Range(0, cropsByValue.Count)]);
}
val.SeasonReachedOnPreviousRun = 0;
val.PreviousUpgrades = null;
SingletonSceneScopeAutoLoad<ProfileModelController>.I.SetDirty();
__result = val2;
return false;
}
}
}