using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
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.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using NeedyCats;
using ReservedAnimalSlot.Config;
using ReservedItemSlotCore.Config;
using ReservedItemSlotCore.Data;
using TooManyEmotes;
using TooManyEmotes.Networking;
using UnityEngine;
[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("ReservedAnimalSlot")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.3.0")]
[assembly: AssemblyInformationalVersion("1.1.3+24783f7cf8304e0af2f3bc626fe63a1bd94153ee")]
[assembly: AssemblyProduct("ReservedAnimalSlot")]
[assembly: AssemblyTitle("ReservedAnimalSlot")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.3.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.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;
}
}
[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 ReservedAnimalSlot
{
[BepInPlugin("ReservedAnimalSlot", "ReservedAnimalSlot", "1.1.3")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class ReservedAnimalSlot : BaseUnityPlugin
{
public static ReservedItemSlotData animalSlotData;
public static ReservedItemData catData;
public static ReservedItemData parrotData;
public static ReservedItemData goldFinchData;
public static ReservedItemData crowData;
public static ReservedItemData robinData;
public static ReservedItemData cardinalData;
public static ReservedItemData littleBirdData;
public static ReservedItemData blueJayData;
public static ReservedItemData sparrowData;
public static List<ReservedItemData> additionalItemData = new List<ReservedItemData>();
public static ReservedAnimalSlot Instance { get; private set; } = null;
internal static ManualLogSource Logger { get; private set; } = null;
internal static Harmony? Harmony { get; set; }
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Instance = this;
ConfigSettings.BindConfigSettings();
CreateReservedItemSlots();
CreateAdditionalReservedItemSlots();
Patch();
Logger.LogInfo((object)"ReservedAnimalSlot v1.1.3 has loaded!");
}
private void CreateReservedItemSlots()
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Expected O, but got Unknown
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Expected O, but got Unknown
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Expected O, but got Unknown
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Expected O, but got Unknown
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Expected O, but got Unknown
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
//IL_01b0: Expected O, but got Unknown
//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
//IL_01f3: Expected O, but got Unknown
//IL_0213: Unknown result type (might be due to invalid IL or missing references)
//IL_0227: Unknown result type (might be due to invalid IL or missing references)
//IL_022c: Unknown result type (might be due to invalid IL or missing references)
//IL_0236: Expected O, but got Unknown
//IL_0256: Unknown result type (might be due to invalid IL or missing references)
//IL_026a: Unknown result type (might be due to invalid IL or missing references)
//IL_026f: Unknown result type (might be due to invalid IL or missing references)
//IL_0279: Expected O, but got Unknown
animalSlotData = ReservedItemSlotData.CreateReservedItemSlotData("cat", ConfigSettings.overrideItemSlotPriority.Value, ConfigSettings.overridePurchasePrice.Value);
catData = animalSlotData.AddItemToReservedItemSlot(new ReservedItemData("Cat", (PlayerBone)11, new Vector3(-0.2f, 0.25f, 0f), new Vector3(0f, 90f, 90f)));
parrotData = animalSlotData.AddItemToReservedItemSlot(new ReservedItemData("Parrot", (PlayerBone)11, new Vector3(0f, 0.2f, 0f), new Vector3(90f, 0f, 0f)));
crowData = animalSlotData.AddItemToReservedItemSlot(new ReservedItemData("Crow", (PlayerBone)11, new Vector3(0f, 0.2f, 0f), new Vector3(0f, 90f, 90f)));
robinData = animalSlotData.AddItemToReservedItemSlot(new ReservedItemData("Robin", (PlayerBone)11, new Vector3(0f, 0.2f, 0f), new Vector3(0f, 90f, 90f)));
sparrowData = animalSlotData.AddItemToReservedItemSlot(new ReservedItemData("Sparrow", (PlayerBone)11, new Vector3(0f, 0.2f, 0f), new Vector3(0f, 90f, 90f)));
goldFinchData = animalSlotData.AddItemToReservedItemSlot(new ReservedItemData("Gold Finch", (PlayerBone)11, new Vector3(0f, 0.2f, 0f), new Vector3(0f, 90f, 90f)));
cardinalData = animalSlotData.AddItemToReservedItemSlot(new ReservedItemData("cardinal", (PlayerBone)11, new Vector3(0f, 0.2f, 0f), new Vector3(0f, 90f, 90f)));
littleBirdData = animalSlotData.AddItemToReservedItemSlot(new ReservedItemData("Little bird", (PlayerBone)11, new Vector3(0f, 0.2f, 0f), new Vector3(0f, 90f, 90f)));
blueJayData = animalSlotData.AddItemToReservedItemSlot(new ReservedItemData("Blue bird", (PlayerBone)11, new Vector3(0f, 0.2f, 0f), new Vector3(0f, 90f, 90f)));
}
private void CreateAdditionalReservedItemSlots()
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Expected O, but got Unknown
string[] array = ConfigSettings.ParseAdditionalItems();
string[] array2 = array;
foreach (string text in array2)
{
if (!animalSlotData.ContainsItem(text))
{
LogWarning("Adding additional item to reserved item slot. Item: " + text);
ReservedItemData val = new ReservedItemData(text, (PlayerBone)0, default(Vector3), default(Vector3));
additionalItemData.Add(val);
animalSlotData.AddItemToReservedItemSlot(val);
}
}
}
internal static void Patch()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
if (Harmony == null)
{
Harmony = new Harmony("ReservedAnimalSlot");
}
Harmony.PatchAll();
}
public static void Log(string message)
{
Logger.LogInfo((object)message);
}
public static void LogError(string message)
{
Logger.LogError((object)message);
}
public static void LogWarning(string message)
{
Logger.LogWarning((object)message);
}
public static bool IsModLoaded(string guid)
{
return Chainloader.PluginInfos.ContainsKey(guid);
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "ReservedAnimalSlot";
public const string PLUGIN_NAME = "ReservedAnimalSlot";
public const string PLUGIN_VERSION = "1.1.3";
}
}
namespace ReservedAnimalSlot.Patches
{
[HarmonyPatch]
internal class CatPatch
{
[HarmonyPatch(typeof(NeedyCatsBase), "AddNeedyCatsToAllLevels")]
[HarmonyPostfix]
public static void ChangeNeedyCatTwoHandedState(NeedyCatsBase __instance)
{
Item item = Assets.MainAssetBundle.LoadAsset<Item>("CatItem");
SelectableLevel[] levels = StartOfRound.Instance.levels;
foreach (SelectableLevel val in levels)
{
IEnumerable<SpawnableItemWithRarity> spawnableScrap = val.spawnableScrap;
spawnableScrap.Where((SpawnableItemWithRarity scrap) => (Object)(object)scrap.spawnableItem == (Object)(object)item).First().spawnableItem.twoHanded = false;
}
}
}
}
namespace ReservedAnimalSlot.Config
{
public static class ConfigSettings
{
public static ConfigEntry<int> overrideItemSlotPriority;
public static ConfigEntry<int> overridePurchasePrice;
public static ConfigEntry<string> additionalItemsInSlot;
public static Dictionary<string, ConfigEntryBase> currentConfigEntries = new Dictionary<string, ConfigEntryBase>();
public static void BindConfigSettings()
{
ReservedAnimalSlot.Log("BindingConfigs");
overrideItemSlotPriority = AddConfigEntry<int>(((BaseUnityPlugin)ReservedAnimalSlot.Instance).Config.Bind<int>("Server-side", "CatSlotPriorityOverride", 100, "[Host only] Manually set the priority for this item slot. Higher priority slots will come first in the reserved item slots, which will appear below the other slots. Negative priority items will appear on the left side of the screen, this is disabled in the core mod's config."));
overridePurchasePrice = AddConfigEntry<int>(((BaseUnityPlugin)ReservedAnimalSlot.Instance).Config.Bind<int>("Server-side", "CatSlotPriceOverride", 200, "[Host only] Manually set the price for this item in the store. Setting 0 will force this item to be unlocked immediately after the game starts."));
additionalItemsInSlot = AddConfigEntry<string>(((BaseUnityPlugin)ReservedAnimalSlot.Instance).Config.Bind<string>("Server-side", "AdditionalItemsInSlot", "", "[Host only] Syntax: \"Item1,Item name2\" (without quotes). When adding items, use the item's name as it appears in game. Include spaces if there are spaces in the item name. Adding items that do not exist, or that are from a mod which is not enabled will not cause any problems.\nNOTE: IF YOU ARE USING A TRANSLATION MOD, YOU MAY NEED TO ADD THE TRANSLATED NAME OF ANY ITEM YOU WANT IN THIS SLOT."));
additionalItemsInSlot.Value = additionalItemsInSlot.Value.Replace(", ", ",");
TryRemoveOldConfigSettings();
}
public static ConfigEntry<T> AddConfigEntry<T>(ConfigEntry<T> configEntry)
{
currentConfigEntries.Add(((ConfigEntryBase)configEntry).Definition.Key, (ConfigEntryBase)(object)configEntry);
return configEntry;
}
public static string[] ParseAdditionalItems()
{
return ConfigSettings.ParseItemNames(additionalItemsInSlot.Value);
}
public static void TryRemoveOldConfigSettings()
{
HashSet<string> hashSet = new HashSet<string>();
HashSet<string> hashSet2 = new HashSet<string>();
foreach (ConfigEntryBase value in currentConfigEntries.Values)
{
hashSet.Add(value.Definition.Section);
hashSet2.Add(value.Definition.Key);
}
try
{
ConfigFile config = ((BaseUnityPlugin)ReservedAnimalSlot.Instance).Config;
string configFilePath = config.ConfigFilePath;
if (!File.Exists(configFilePath))
{
return;
}
string text = File.ReadAllText(configFilePath);
string[] array = File.ReadAllLines(configFilePath);
string text2 = "";
for (int i = 0; i < array.Length; i++)
{
array[i] = array[i].Replace("\n", "");
if (array[i].Length <= 0)
{
continue;
}
if (array[i].StartsWith("["))
{
if (text2 != "" && !hashSet.Contains(text2))
{
text2 = "[" + text2 + "]";
int num = text.IndexOf(text2);
int num2 = text.IndexOf(array[i]);
text = text.Remove(num, num2 - num);
}
text2 = array[i].Replace("[", "").Replace("]", "").Trim();
}
else
{
if (!(text2 != ""))
{
continue;
}
if (i <= array.Length - 4 && array[i].StartsWith("##"))
{
int j;
for (j = 1; i + j < array.Length && array[i + j].Length > 3; j++)
{
}
if (hashSet.Contains(text2))
{
int num3 = array[i + j - 1].IndexOf("=");
string item = array[i + j - 1].Substring(0, num3 - 1);
if (!hashSet2.Contains(item))
{
int num4 = text.IndexOf(array[i]);
int num5 = text.IndexOf(array[i + j - 1]) + array[i + j - 1].Length;
text = text.Remove(num4, num5 - num4);
}
}
i += j - 1;
}
else if (array[i].Length > 3)
{
text = text.Replace(array[i], "");
}
}
}
if (!hashSet.Contains(text2))
{
text2 = "[" + text2 + "]";
int num6 = text.IndexOf(text2);
text = text.Remove(num6, text.Length - num6);
}
while (text.Contains("\n\n\n"))
{
text = text.Replace("\n\n\n", "\n\n");
}
File.WriteAllText(configFilePath, text);
config.Reload();
}
catch
{
}
}
}
}
namespace ReservedAnimalSlot.Compatibility
{
internal static class TooManyEmotes_Patcher
{
public static bool Enabled => ReservedAnimalSlot.IsModLoaded("FlipMods.TooManyEmotes");
public static bool IsLocalPlayerPerformingCustomEmote()
{
if ((Object)(object)EmoteControllerPlayer.emoteControllerLocal != (Object)null && ((EmoteController)EmoteControllerPlayer.emoteControllerLocal).IsPerformingCustomEmote())
{
return true;
}
return false;
}
public static bool CanMoveWhileEmoting()
{
if (ConfigSync.instance != null)
{
return ConfigSync.instance.syncEnableMovingWhileEmoting;
}
return false;
}
}
}