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.Loot;
using Atomicrops.Core.SoDb2;
using Atomicrops.Core.Upgrades;
using Atomicrops.Crops;
using Atomicrops.Game.Data;
using Atomicrops.Game.Loot;
using Atomicrops.Global;
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("CustomParams")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CustomParams")]
[assembly: AssemblyTitle("CustomParams")]
[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 = "CustomParams";
public const string PLUGIN_NAME = "CustomParams";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace CustomParams
{
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "pauli.plugin.CustomParams";
public const string PLUGIN_NAME = "CustomParams";
public const string PLUGIN_VERSION = "2.0.4";
}
public class ActionContainer
{
public Action Function { get; set; }
public Action Cleanup { get; set; }
}
public static class GlobalActions
{
public static Dictionary<string, ActionContainer> Actions;
static GlobalActions()
{
Actions = new Dictionary<string, ActionContainer>();
}
public static void AddAction(string command, Action function, Action cleanup)
{
Actions[command] = new ActionContainer
{
Function = function,
Cleanup = cleanup
};
}
}
[BepInPlugin("pauli.plugin.CustomParams", "CustomParams", "2.0.4")]
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)
//IL_0028: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin pauli.plugin.CustomParams is loaded!");
Harmony val = new Harmony("pauli.plugin.CustomParams");
val.PatchAll();
}
}
[HarmonyPatch(typeof(UpgradeRunner), "ApplyUpgradeList")]
internal class UpgradeRunner_ApplyUpgradeList_Patch
{
private static bool Prefix(Dictionary<UpgradeDef, int> currentUpgradeStacks, object paramsObj)
{
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Invalid comparison between Unknown and I4
//IL_0266: Unknown result type (might be due to invalid IL or missing references)
//IL_026c: Invalid comparison between Unknown and I4
//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
//IL_01b3: Invalid comparison between Unknown and I4
//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
//IL_02b9: Invalid comparison between Unknown and I4
//IL_0204: Unknown result type (might be due to invalid IL or missing references)
//IL_020a: Invalid comparison between Unknown and I4
//IL_0300: Unknown result type (might be due to invalid IL or missing references)
//IL_0306: Invalid comparison between Unknown and I4
foreach (KeyValuePair<UpgradeDef, int> currentUpgradeStack in currentUpgradeStacks)
{
List<UpgradeParam> @params = currentUpgradeStack.Key.GetParams(currentUpgradeStack.Value);
if (@params == null || @params.Count == 0)
{
continue;
}
foreach (UpgradeParam item in @params)
{
if (item.Path.StartsWith("#"))
{
try
{
string path = item.Path;
if (GlobalActions.Actions.TryGetValue(path, out var value))
{
value.Function?.Invoke();
}
else
{
Plugin.Log.LogWarning((object)("No action found for command '" + path + "' in the GlobalActions dictionary."));
}
}
catch (Exception ex)
{
Plugin.Log.LogError((object)("Error processing command '" + item.Path + "': " + ex.Message + "\n" + ex.StackTrace));
}
continue;
}
FieldValueInfoItem fieldInfoAndValue = UpgradeRunner.GetFieldInfoAndValue(item.Path, paramsObj);
if (fieldInfoAndValue.info.FieldType == typeof(int))
{
if ((int)item.Action == 0)
{
fieldInfoAndValue.info.SetValue(fieldInfoAndValue.val, (int)fieldInfoAndValue.info.GetValue(fieldInfoAndValue.val) + Mathf.RoundToInt(item.Value));
}
else if ((int)item.Action == 1)
{
float num = (int)fieldInfoAndValue.info.GetValue(fieldInfoAndValue.val);
fieldInfoAndValue.info.SetValue(fieldInfoAndValue.val, Mathf.RoundToInt(num * item.Value));
}
else if ((int)item.Action == 2)
{
fieldInfoAndValue.info.SetValue(fieldInfoAndValue.val, Mathf.RoundToInt(item.Value));
}
}
else if (fieldInfoAndValue.info.FieldType == typeof(float))
{
if ((int)item.Action == 0)
{
fieldInfoAndValue.info.SetValue(fieldInfoAndValue.val, (float)fieldInfoAndValue.info.GetValue(fieldInfoAndValue.val) + item.Value);
}
else if ((int)item.Action == 1)
{
fieldInfoAndValue.info.SetValue(fieldInfoAndValue.val, (float)fieldInfoAndValue.info.GetValue(fieldInfoAndValue.val) * item.Value);
}
else if ((int)item.Action == 2)
{
fieldInfoAndValue.info.SetValue(fieldInfoAndValue.val, item.Value);
}
}
else if (fieldInfoAndValue.info.FieldType == typeof(bool))
{
fieldInfoAndValue.info.SetValue(fieldInfoAndValue.val, item.Value > 0.5f);
}
}
}
return false;
}
}
[HarmonyPatch(typeof(GameDataPresets), "NewGameData")]
internal class GameDataPresets_NewGameData_Patch
{
private static void Prefix()
{
if (GlobalActions.Actions.Count <= 0)
{
return;
}
foreach (KeyValuePair<string, ActionContainer> action in GlobalActions.Actions)
{
ActionContainer value = action.Value;
value.Cleanup?.Invoke();
}
}
private static void Postfix(GameData data, int seed, bool isDaily, int year, ProfileModel profile)
{
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Expected I4, but got Unknown
Upgrade.OnFriendDefLoaderInitialized();
Upgrade.OnSpouseDefLoaderInitialized();
Upgrade.OnTurretDefLoaderInitialized();
Upgrade.OnInstantApplyLootDefLoaderInitialized();
Upgrade.AllUpgradeDefs.Clear();
foreach (Upgrade allUpgrade in Upgrade.AllUpgrades)
{
UpgradeDef orCreateUpgradeDef = allUpgrade.GetOrCreateUpgradeDef();
if ((Object)(object)orCreateUpgradeDef != (Object)null)
{
Upgrade.AllUpgradeDefs.Add(orCreateUpgradeDef);
}
}
for (int i = 0; i < Upgrade.AllUpgrades.Count; i++)
{
if ((Object)(object)Upgrade.AllUpgradeDefs[i] == (Object)null)
{
continue;
}
LootCollection val = null;
LootCollectionIdsEnum val2 = Upgrade.LootPools[i];
LootCollectionIdsEnum val3 = val2;
LootCollectionIdsEnum val4 = val3;
switch ((int)val4)
{
case 0:
val = data.MainLootCollection;
break;
case 1:
val = data.SpecialLootCollection;
break;
case 2:
val = data.GoldenChestLootCollection;
break;
case 3:
val = data.DeerShopLootCollection;
break;
case 4:
val = data.CrowLootCollection;
break;
case 5:
val = data.CrowOreganoLootCollection;
break;
case 9:
val = data.CrowCropLevelingLootCollection;
break;
case 6:
val = data.PowerSowLootCollection;
break;
case 7:
val = data.GardenBedLootCollection;
break;
case 8:
val = data.TreeUpgradeCollection;
break;
}
if (val != null)
{
FieldInfo field = typeof(LootCollection).GetField("_loots", BindingFlags.Instance | BindingFlags.NonPublic);
List<ILootDef> list = (List<ILootDef>)field.GetValue(val);
if (Upgrade.AllUpgrades[i].DoDebug)
{
list.Insert(0, (ILootDef)(object)Upgrade.AllUpgradeDefs[i]);
}
else
{
Random random = new Random(seed + Upgrade.AllUpgrades[i].Name.GetHashCode());
int index = random.Next(list.Count + 1);
list.Insert(index, (ILootDef)(object)Upgrade.AllUpgradeDefs[i]);
}
field.SetValue(val, list);
}
}
}
}
[HarmonyPatch(typeof(MetaPrevRunRewardUtils), "GenerateRewardModelAndClearPorfileFlag")]
internal class MetaPrevRunRewardUtils_GenerateRewardModelAndClearPorfileFlag_Patch
{
private static bool Prefix(ref MetaPrevRunRewardsModel __result)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
if (Upgrade.DebugPresent)
{
MetaPrevRunRewardsModel val = new MetaPrevRunRewardsModel();
val.Upgrades = new List<UpgradeDef>();
for (int i = 0; i < Upgrade.AllUpgrades.Count; i++)
{
if (Upgrade.AllUpgrades[i].DoDebug)
{
val.Upgrades.Add(Upgrade.AllUpgradeDefs[i]);
}
}
__result = val;
return false;
}
return true;
}
}
public class Upgrade
{
public static List<Upgrade> AllUpgrades = new List<Upgrade>();
public static List<UpgradeDef> AllUpgradeDefs = new List<UpgradeDef>();
private static List<LootCollectionIdsEnum> _lootPools = new List<LootCollectionIdsEnum>();
public UpgradeDef _upgradeDef;
private List<UpgradeParam> _upgradeParams = new List<UpgradeParam>();
private LootDefProperties _lootDefProperties;
public Sprite myCustomSprite;
public static Dictionary<string, FriendDef> FriendDefMap = new Dictionary<string, FriendDef>();
public bool UpgradeAddsFriends = false;
public List<string> FriendsToAddStr = new List<string>();
public List<FriendDef> FriendsToAdd = new List<FriendDef>();
public static Dictionary<string, TurretDef> TurretDefMap = new Dictionary<string, TurretDef>();
public bool UpgradeAddsTurrets = false;
public List<string> TurretsToAddStr = new List<string>();
public List<TurretDef> TurretsToAdd = new List<TurretDef>();
public bool UpgradeAddsLoot = false;
public string UpgradeLootStr = "None";
public int UpgradeLootAmt = 0;
public static Dictionary<string, InstantApplyLootDef> InstantApplyLootDefMap = new Dictionary<string, InstantApplyLootDef>();
public string Name;
public string Description;
public string ImageFilePath;
public Assembly creatorAssembly;
public bool DoDebug = false;
public static bool DebugPresent = false;
private List<(Action actionMethod, Action cleanupMethod)> _pendingCustomParams = new List<(Action, Action)>();
public static List<LootCollectionIdsEnum> LootPools => _lootPools;
public Upgrade(string name, string description, string imageFilePath, Assembly callingAssembly)
{
Name = name;
Description = description;
ImageFilePath = imageFilePath;
creatorAssembly = callingAssembly;
}
public UpgradeDef GetOrCreateUpgradeDef()
{
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_0282: Unknown result type (might be due to invalid IL or missing references)
//IL_02da: Unknown result type (might be due to invalid IL or missing references)
//IL_02e4: Expected O, but got Unknown
//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
//IL_03e8: Unknown result type (might be due to invalid IL or missing references)
//IL_03f2: Expected O, but got Unknown
//IL_042d: Unknown result type (might be due to invalid IL or missing references)
//IL_0439: Unknown result type (might be due to invalid IL or missing references)
//IL_04d9: Unknown result type (might be due to invalid IL or missing references)
//IL_04e3: Expected O, but got Unknown
//IL_04f5: Unknown result type (might be due to invalid IL or missing references)
//IL_04fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0587: Unknown result type (might be due to invalid IL or missing references)
//IL_058c: Unknown result type (might be due to invalid IL or missing references)
//IL_05b6: Unknown result type (might be due to invalid IL or missing references)
//IL_05bc: Expected O, but got Unknown
//IL_060b: Unknown result type (might be due to invalid IL or missing references)
//IL_060d: Unknown result type (might be due to invalid IL or missing references)
//IL_06c0: Unknown result type (might be due to invalid IL or missing references)
//IL_06c5: Unknown result type (might be due to invalid IL or missing references)
//IL_06db: Unknown result type (might be due to invalid IL or missing references)
//IL_06e6: Unknown result type (might be due to invalid IL or missing references)
//IL_06e8: Unknown result type (might be due to invalid IL or missing references)
//IL_06ef: Expected O, but got Unknown
if ((Object)(object)_upgradeDef != (Object)null)
{
return _upgradeDef;
}
if (UpgradeAddsFriends && !FriendDefMap.ContainsKey("pig") && !FriendDefMap.ContainsKey("rue"))
{
Plugin.Log.LogWarning((object)("FriendDefMap not yet initialized for upgrade " + Name + ". Skipping creation."));
return null;
}
if (UpgradeAddsTurrets && TurretDefMap.Count == 0)
{
Plugin.Log.LogWarning((object)("TurretDefMap not yet initialized for upgrade " + Name + ". Skipping creation."));
return null;
}
_addFriends();
_addTurrets();
_upgradeDef = ScriptableObject.CreateInstance<UpgradeDef>();
((Object)_upgradeDef).name = Name;
_upgradeDef.UpgradeType = (UpgradeTypeEnum)0;
_upgradeDef.Disabled = false;
_upgradeDef.MaxStacks = 100;
_upgradeDef.RemoveUpgradesWhenPickedUp = new List<UpgradeDef>();
_upgradeDef.DoAddDependents = false;
_upgradeDef.DependentCollection = (LootCollectionIdsEnum)0;
_upgradeDef.Dependents = new List<UpgradeDef>();
_upgradeDef.DependentsILoot = new List<SoDb2Item>();
_upgradeDef.DoInstantApply = UpgradeAddsLoot;
_upgradeDef.InstantApply = InstantApplyLootDefMap[UpgradeLootStr];
_upgradeDef.InstantApplyAmount = UpgradeLootAmt;
_upgradeDef.DoRandomSelectInstantApply = false;
_upgradeDef.InstantApplyRandomSelect = new List<InstantApplyLootDef>();
_upgradeDef.DoAddSeeds = false;
_upgradeDef.AddSeeds = null;
_upgradeDef.AddSeedsList = new List<CropDef>();
_upgradeDef.AddSeedsCount = 0;
_upgradeDef.AddAloeVeraHeals = 0;
_upgradeDef.DropOnDamage = false;
_upgradeDef.DropFx = null;
_upgradeDef.DropSound = null;
_upgradeDef.IsTomorrowLongerUpgrade = false;
_upgradeDef.DoAddFriends = UpgradeAddsFriends;
_upgradeDef.AddFriendAroundPlayer = UpgradeAddsFriends;
_upgradeDef.AddFriends = FriendsToAdd;
_upgradeDef.DoAddTurrets = UpgradeAddsTurrets;
_upgradeDef.Turrets = TurretsToAdd;
_upgradeDef.RunFunction = (FunctionEnum)0;
_upgradeDef.DoAddGardenBed = false;
_upgradeDef.GardenBeds = new List<GardenBedDef>();
_upgradeDef.AddPowerSowableSeeds = 0;
FieldInfo field = typeof(UpgradeDef).GetField("Params", BindingFlags.Instance | BindingFlags.NonPublic);
field.SetValue(_upgradeDef, _upgradeParams);
_lootDefProperties = new LootDefProperties();
_lootDefProperties.Tag = (TagEnum)0;
_lootDefProperties.Dlc = (Dlcs)0;
_lootDefProperties.Build = "";
_lootDefProperties.DisplayName = Name;
_lootDefProperties.Description = Description;
_lootDefProperties.DisplayNameLocalizationKey = "";
_lootDefProperties.DoNameFormatter = false;
_lootDefProperties.NameFormatterArg1 = "";
_lootDefProperties.DoLocNameFormatterArg1 = false;
_lootDefProperties.DescriptionLocalizationKey = "";
_lootDefProperties.DoDescFormatter = false;
_lootDefProperties.DescFormatterArg1 = "";
_lootDefProperties.DoLocDescFormatterArg1 = false;
_lootDefProperties.DescFormatterArg2 = "";
_lootDefProperties.DoLocDescFormatterArg2 = false;
_lootDefProperties.DescFormatterArg3 = "";
_lootDefProperties.DoLocDescFormatterArg3 = false;
_lootDefProperties.DoAltDescFormattersForCrow = false;
_lootDefProperties.AltDescFormattersForCrow = new DescFormatters();
_lootDefProperties.DoDescComposition = false;
_lootDefProperties.AppendDescComposition = false;
_lootDefProperties.DescCompJoinUseComma = false;
_lootDefProperties.LocElementsForDescComposition = new List<LocElement>();
_lootDefProperties.Rarity = (Rarity_)1;
_lootDefProperties.PrimaryBiome = (Biomes)0;
_lootDefProperties.LuckMult = 0f;
_lootDefProperties.UseCustomCost = false;
_lootDefProperties.CustomCost = 100;
_lootDefProperties.DontSpawnOnLastDay = false;
_lootDefProperties.DoMutuallyExclusive = false;
_lootDefProperties.MutuallyExclusive = null;
_lootDefProperties.InventoryIconAnim = null;
_lootDefProperties.InventoryIconSelected = null;
_lootDefProperties.InventoryIconSelectedAnim = null;
_lootDefProperties.InGameLootSprite = null;
_lootDefProperties.InGameLootClip = null;
_lootDefProperties.DoAltIconsIfCrow = false;
_lootDefProperties.IconsIfCrow = new Icons();
_lootDefProperties.RevealClip = null;
_lootDefProperties.LootSpriteColorMult = Color.white;
_lootDefProperties.InGameLootShadowHeightOffset = 0f;
_lootDefProperties.SetSortOffset = false;
_lootDefProperties.SortOffset = 0f;
_lootDefProperties.SizeForShadow = 1f;
_lootDefProperties.ShowTooltip = true;
_lootDefProperties.Stack = false;
_lootDefProperties.DoHop = true;
_lootDefProperties.Flash = true;
_lootDefProperties.NoToolTipRegion = false;
_lootDefProperties.ToolTipOffset = new Vector2(0f, 0.3f);
string path = Path.Combine(Path.GetDirectoryName(creatorAssembly.Location), ImageFilePath);
byte[] array = File.ReadAllBytes(path);
Texture2D val = new Texture2D(2, 2);
if (ImageConversion.LoadImage(val, array))
{
((Texture)val).filterMode = (FilterMode)0;
Rect val2 = default(Rect);
((Rect)(ref val2))..ctor(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height);
Vector2 val3 = default(Vector2);
((Vector2)(ref val3))..ctor(0.5f, 0.5f);
float num = 32f;
myCustomSprite = Sprite.Create(val, val2, val3, num);
}
else
{
Debug.LogError((object)"Failed to load image.");
}
_lootDefProperties.InventoryIcon = myCustomSprite;
_lootDefProperties.InGameLootSprite = myCustomSprite;
_lootDefProperties.PickupSoundEvent = SoDb2Utils.GetItem<UpgradeDef>(10).LootProperties.PickupSoundEvent;
_lootDefProperties.DropSoundEvent = SoDb2Utils.GetItem<UpgradeDef>(10).LootProperties.DropSoundEvent;
_upgradeDef.LootProperties = _lootDefProperties;
foreach (var pendingCustomParam in _pendingCustomParams)
{
Action item = pendingCustomParam.actionMethod;
Action item2 = pendingCustomParam.cleanupMethod;
UpgradeParam val4 = new UpgradeParam
{
Path = "#" + Name,
Value = 1f,
Action = (Operation)2
};
typeof(UpgradeParam).GetField("ValueMin", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(val4, 0f);
typeof(UpgradeParam).GetField("ValueMax", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(val4, 100f);
_upgradeParams.Add(val4);
GlobalActions.AddAction("#" + Name, item, item2);
}
_pendingCustomParams.Clear();
return _upgradeDef;
}
public void AddVanillaParam(string param, float value, string operation)
{
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Expected O, but got Unknown
//IL_009c: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
if (operation != "Add" && operation != "Set" && operation != "Multiply")
{
Plugin.Log.LogError((object)(((Object)_upgradeDef).name + " Incorrect operation: must be Add, Set, or Multiply"));
return;
}
UpgradeParam val = new UpgradeParam();
val.Path = param;
val.Value = value;
switch (operation)
{
case "Add":
val.Action = (Operation)0;
break;
case "Set":
val.Action = (Operation)2;
break;
case "Multiply":
val.Action = (Operation)1;
break;
}
FieldInfo field = typeof(UpgradeParam).GetField("ValueMin", BindingFlags.Instance | BindingFlags.NonPublic);
if (field != null)
{
field.SetValue(val, value);
}
FieldInfo field2 = typeof(UpgradeParam).GetField("ValueMax", BindingFlags.Instance | BindingFlags.NonPublic);
if (field2 != null)
{
field2.SetValue(val, value);
}
_upgradeParams.Add(val);
}
public void AddVanillaParam(string param, bool value)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
float num = (value ? 1f : 0f);
UpgradeParam val = new UpgradeParam();
val.Path = param;
val.Value = num;
val.Action = (Operation)2;
FieldInfo field = typeof(UpgradeParam).GetField("ValueMin", BindingFlags.Instance | BindingFlags.NonPublic);
if (field != null)
{
field.SetValue(val, num);
}
FieldInfo field2 = typeof(UpgradeParam).GetField("ValueMax", BindingFlags.Instance | BindingFlags.NonPublic);
if (field2 != null)
{
field2.SetValue(val, num);
}
_upgradeParams.Add(val);
}
public void AddCustomParam(Action actionMethod, Action cleanupMethod)
{
_pendingCustomParams.Add((actionMethod, cleanupMethod));
}
public void AddUpgradeToLootPool(string pool)
{
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: 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_0160: Unknown result type (might be due to invalid IL or missing references)
//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
LootCollectionIdsEnum item;
switch (pool)
{
case "Main":
item = (LootCollectionIdsEnum)0;
break;
case "Special":
item = (LootCollectionIdsEnum)1;
break;
case "GoldenChest":
item = (LootCollectionIdsEnum)2;
break;
case "DeerShop":
item = (LootCollectionIdsEnum)3;
break;
case "Crow":
item = (LootCollectionIdsEnum)4;
break;
case "CrowOregano":
item = (LootCollectionIdsEnum)5;
break;
case "PowerSow":
item = (LootCollectionIdsEnum)6;
break;
case "GardenBed":
item = (LootCollectionIdsEnum)7;
break;
case "TreeUpgrades":
item = (LootCollectionIdsEnum)8;
break;
case "CrowCropLeveling":
item = (LootCollectionIdsEnum)9;
break;
default:
Plugin.Log.LogError((object)(((Object)_upgradeDef).name + " pool error: pool must be Main, Special, GoldenChest, DeerShop, Crow, CrowOregano, PowerSow, GardenBed, TreeUpgrades, or CrowCropLeveling"));
return;
}
AllUpgrades.Add(this);
_lootPools.Add(item);
}
public void AddFriends(Dictionary<string, int> friends)
{
UpgradeAddsFriends = true;
foreach (KeyValuePair<string, int> friend in friends)
{
for (int i = 0; i < friend.Value; i++)
{
FriendsToAddStr.Add(friend.Key);
}
}
}
public void _addFriends()
{
foreach (string item in FriendsToAddStr)
{
try
{
FriendsToAdd.Add(FriendDefMap[item]);
}
catch (Exception arg)
{
Plugin.Log.LogError((object)$"{arg}\nFailed to add friend {item}.\nOnly accepted values are bee, bee2, cow, cow2, pig, pig2, chickenweed, chickenweed2, dronerifler, alienpet, rue, borage, norman, waterchris, and furryosa");
break;
}
}
}
public void AddTurrets(Dictionary<string, int> turrets)
{
UpgradeAddsTurrets = true;
foreach (KeyValuePair<string, int> turret in turrets)
{
for (int i = 0; i < turret.Value; i++)
{
TurretsToAddStr.Add(turret.Key);
}
}
}
public void _addTurrets()
{
foreach (string item in TurretsToAddStr)
{
try
{
TurretsToAdd.Add(TurretDefMap[item]);
}
catch (Exception arg)
{
Plugin.Log.LogError((object)$"{arg}\nFailed to add turret {item}.\nOnly accepted values are turret, scarecrow, and curret");
break;
}
}
}
public void AddLoot(string lootType, int amount)
{
if (!UpgradeAddsLoot)
{
UpgradeAddsLoot = true;
UpgradeLootStr = lootType;
UpgradeLootAmt = amount;
}
else
{
Plugin.Log.LogError((object)"Upgrades can only add one type of loot");
}
}
public static void OnFriendDefLoaderInitialized()
{
ConfigFriends friends = SingletonScriptableObject<ConfigGame>.I.Friends;
FriendDefMap["bee"] = friends.FarmAnimalsLevel1[0];
FriendDefMap["chickenweed"] = friends.FarmAnimalsLevel1[1];
FriendDefMap["cow"] = friends.FarmAnimalsLevel1[2];
FriendDefMap["pig"] = friends.FarmAnimalsLevel1[3];
FriendDefMap["bee2"] = friends.FarmAnimalsLevel2[0];
FriendDefMap["chickenweed2"] = friends.FarmAnimalsLevel2[1];
FriendDefMap["cow2"] = friends.FarmAnimalsLevel2[2];
FriendDefMap["pig2"] = friends.FarmAnimalsLevel2[3];
FriendDefMap["alienpet"] = friends.AlienPet;
FriendDefMap["drone"] = SingletonScriptableObject<ConfigGame>.I.Player.Robusta.DefaultFriends[0];
}
public static void OnTurretDefLoaderInitialized()
{
TurretDefLoader i = SingletonScriptableObject<TurretDefLoader>.I;
if (!TurretDefMap.ContainsKey("turret"))
{
TurretDefMap.Add("turret", i.Defs[0]);
}
if (!TurretDefMap.ContainsKey("curret"))
{
TurretDefMap.Add("curret", i.Defs[1]);
}
if (!TurretDefMap.ContainsKey("scarecrow"))
{
TurretDefMap.Add("scarecrow", i.Defs[2]);
}
}
public static void OnSpouseDefLoaderInitialized()
{
EligiblesCollection eligibles = SingletonScriptableObject<GameData>.I.Eligibles;
foreach (FriendDef key2 in eligibles._getall().Keys)
{
string key = key2.Name.ToLower();
if (!FriendDefMap.ContainsKey(key))
{
FriendDefMap[key] = key2;
}
}
}
public static void OnInstantApplyLootDefLoaderInitialized()
{
InstantApplyLootDef[] all = InstantApplyLootDefLoader.GetAll();
InstantApplyLootDef[] array = all;
foreach (InstantApplyLootDef val in array)
{
if ((Object)(object)val != (Object)null && !string.IsNullOrEmpty(((Object)val).name) && !InstantApplyLootDefMap.ContainsKey(((Object)val).name))
{
InstantApplyLootDefMap[((Object)val).name] = val;
}
}
InstantApplyLootDefMap["None"] = null;
}
public void ToggleDebug()
{
DoDebug = true;
DebugPresent = true;
Plugin.Log.LogInfo((object)("Debug for " + Name + " is on!"));
}
}
}