using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LibCopyUI;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Localization.Components;
using UnityEngine.UI;
[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("Tavern_Rush")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("3.0.0.0")]
[assembly: AssemblyInformationalVersion("3.0.0+96343be1b79b9068c82b873c1e5081137da0e847")]
[assembly: AssemblyProduct("Tavern_Rush")]
[assembly: AssemblyTitle("Tavern_Rush")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("3.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 Tavern_Rush
{
[BepInPlugin("Tavern_Rush", "Tavern_Rush", "3.0.0")]
public class Plugin : BaseUnityPlugin
{
public static ManualLogSource Logger1;
internal static ConfigEntry<string> prices;
internal static ConfigEntry<string> disableObjects;
internal static ConfigEntry<ulong> moneyDrop;
internal static ConfigEntry<KeyboardShortcut> mainScreenBind;
private void SyncConfig()
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
mainScreenBind = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Keybinds", "Mod Screen key", new KeyboardShortcut((KeyCode)114, (KeyCode[])(object)new KeyCode[1] { (KeyCode)304 }), "Keyboard Shortcut for Mod Screen");
}
private void Start()
{
Harmony.CreateAndPatchAll(typeof(Plugin), (string)null);
Logger1 = ((BaseUnityPlugin)this).Logger;
SyncConfig();
Logger1.LogInfo((object)"Plugin Tavern_Rush : Version 3.0.0 is loaded!");
}
[HarmonyPostfix]
[HarmonyPatch(typeof(MainMenu), "Awake")]
private static void RemoveBarrel()
{
GameObject.Find("Props_BarrelStack_03").SetActive(false);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(Game), "Update")]
private static void Update()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
KeyboardShortcut value = mainScreenBind.Value;
if (((KeyboardShortcut)(ref value)).IsDown())
{
GameObject gameObject = ((Component)GameObject.Find("Common").transform.Find("GameCanvas")).gameObject;
Transform obj = gameObject.transform.Find("Tavern Rush Screen");
GameObject val = ((obj != null) ? ((Component)obj).gameObject : null);
if (!Object.op_Implicit((Object)(object)val))
{
PluginUI.createWithLibCopyUI().SetActive(false);
val = ((Component)gameObject.transform.Find("Tavern Rush Screen")).gameObject;
}
if (!val.activeSelf)
{
GameMenu.Instance.ShowMenuHome();
}
else
{
GameMenu.Instance.ShowGame();
}
val.SetActive(!val.activeSelf);
}
if (Input.GetKeyDown((KeyCode)27))
{
GameObject gameObject2 = ((Component)GameObject.Find("Common").transform.Find("GameCanvas")).gameObject;
GameObject gameObject3 = ((Component)gameObject2.transform.Find("Tavern Rush Screen")).gameObject;
gameObject3.SetActive(false);
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(PlayerManager), "Start")]
private static void ChangePrices()
{
if (!((Object)(object)Object.FindFirstObjectByType<Game>() != (Object)null) || !((NetworkBehaviour)Object.FindFirstObjectByType<Game>()).IsServer)
{
return;
}
ItemData[] array = Resources.FindObjectsOfTypeAll<ItemData>();
string[] array2 = prices.Value.Split(",");
Dictionary<string, ushort> dictionary = new Dictionary<string, ushort>();
string[] array3 = array2;
foreach (string text in array3)
{
dictionary.Add(text.Split(":")[0], ushort.Parse(text.Split(":")[1]));
}
ItemData[] array4 = array;
foreach (ItemData val in array4)
{
if (dictionary.ContainsKey(val.name))
{
val.price = dictionary[val.name];
}
}
}
}
public class PluginUI
{
public static UIObject panel0;
public static UIObject container0;
public static UIObject container1;
public static UIObject button0;
public static UIObject label0;
public static GameObject createWithLibCopyUI()
{
//IL_019d: Unknown result type (might be due to invalid IL or missing references)
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
LibCopy.setup(GameObject.Find("Common/GameCanvas").transform, Templates.AleAndTale);
panel0 = LibCopy.makePanel("Tavern Rush Screen");
panel0.setSize(1200f, 1000f);
container0 = LibCopy.makeContainer(null, panel0.gameObject);
container0.setSize(500f, 800f);
container0.offsetPosition(-275f, 0f, 0f);
container1 = LibCopy.makeContainer(null, panel0.gameObject);
container1.setSize(500f, 800f);
container1.offsetPosition(275f, 0f, 0f);
label0 = LibCopy.makeLabel("Tavern Rush Mod", panel0.gameObject);
label0.setSize(400f, 50f);
label0.centerToParentY();
label0.offsetPosition(0f, -15f, 0f);
button0 = LibCopy.makeButton("Close", delegate
{
panel0.gameObject.SetActive(false);
GameMenu.Instance.ShowGame();
}, panel0.gameObject);
button0.setSize(170f, 60f);
button0.centerToParentX();
UIObject uIObject = button0;
float num = (0f - button0.parentHeight) / 2f;
Rect rect = button0.rectTransform.rect;
uIObject.offsetPosition(100f, num + ((Rect)(ref rect)).height - 20f, 0f);
foreach (KeyValuePair<string, Dictionary<string, Action>> cat in RushMenu.modOptions)
{
UIObject uIObject2 = LibCopy.makeButton(cat.Key, delegate
{
((Component)container1.gameObject.GetComponentInChildren<VerticalLayoutGroup>()).gameObject.transform.DestroyChildren();
foreach (KeyValuePair<string, Action> option in cat.Value)
{
UIObject uIObject3 = LibCopy.makeButton(option.Key, delegate
{
option.Value();
}, ((Component)container1.gameObject.GetComponentInChildren<VerticalLayoutGroup>()).gameObject);
}
}, ((Component)container0.gameObject.GetComponentInChildren<VerticalLayoutGroup>()).gameObject);
}
return panel0.gameObject;
}
}
public class RushMenu
{
public static Dictionary<string, Dictionary<string, Action>> modOptions = new Dictionary<string, Dictionary<string, Action>>
{
{
"General",
new Dictionary<string, Action>
{
{
"Money Add",
delegate
{
Object.FindFirstObjectByType<GameStatus>().AddMoneyServerRpc(1000uL);
}
},
{
"XP Add",
delegate
{
Object.FindFirstObjectByType<GameStatus>().AddExp(1000u);
}
},
{
"Level",
delegate
{
NetworkVariable<byte> level = Object.FindFirstObjectByType<GameStatus>().level;
level.Value += 1;
}
}
}
},
{
"World",
new Dictionary<string, Action>
{
{
"Hide Posters",
delegate
{
DisableObjectsHavingName(new string[1] { "Poster" });
}
},
{
"Hide Scarecrow",
delegate
{
DisableObjectsHavingName(new string[1] { "Scarecrow" });
}
}
}
},
{
"Tavern",
new Dictionary<string, Action>
{
{
"Make Clean",
delegate
{
Object.FindFirstObjectByType<GameStatus>().cleanliness.Value = 100;
}
},
{
"Make Reputed",
delegate
{
Object.FindFirstObjectByType<GameStatus>().reputation.Value = 100;
}
},
{
"Complete Current Quest",
delegate
{
Object.FindFirstObjectByType<QuestManager>().CompleteCurrentQuest();
}
}
}
},
{
"Items",
new Dictionary<string, Action> { { "Spawn", SpawnItems } }
}
};
public static void DisableObjectsHavingName(string[] target)
{
GameObject[] array = Object.FindObjectsOfType<GameObject>();
foreach (GameObject val in array)
{
foreach (string value in target)
{
if (((Object)val).name.Contains(value))
{
val.SetActive(false);
}
}
}
}
private static void SpawnItems()
{
((Component)PluginUI.container1.gameObject.GetComponentInChildren<VerticalLayoutGroup>()).gameObject.transform.DestroyChildren();
ItemData[] array = Resources.FindObjectsOfTypeAll<ItemData>();
ItemData[] array2 = array;
foreach (ItemData item in array2)
{
UIObject uIObject = LibCopy.makeButton(item.name.Replace("ItemDataName", "").Replace("_Title", ""), delegate
{
Object.FindFirstObjectByType<GameCommands>().SpawnItem(item.id);
}, ((Component)PluginUI.container1.gameObject.GetComponentInChildren<VerticalLayoutGroup>()).gameObject);
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "Tavern_Rush";
public const string PLUGIN_NAME = "Tavern_Rush";
public const string PLUGIN_VERSION = "3.0.0";
}
}
namespace LibCopyUI
{
public static class LibCopy
{
public static Transform canvas;
private static bool ready;
private static Dictionary<string, string> templates;
public static void setup(Transform UI, Dictionary<string, string> temps)
{
if (!Object.op_Implicit((Object)(object)UI) || temps == null)
{
throw new Exception("Arguments cannot be null, run setup again");
}
canvas = UI;
templates = temps;
ready = true;
}
public static UIObject copyElement(string template, GameObject cnvs = null, bool active = true, string name = null)
{
if (!ready)
{
throw new Exception("Run setup once before using lib");
}
if (!Object.op_Implicit((Object)(object)cnvs))
{
cnvs = ((Component)canvas).gameObject;
}
GameObject val = GameObject.Find(templates[template]);
if (!Object.op_Implicit((Object)(object)val))
{
throw new Exception(template + " template reference cannot be found");
}
if (name == null)
{
name = template;
}
return new UIObject(val, cnvs, name, active);
}
public static UIObject makeContainer(string name = null, GameObject cnvs = null, bool active = true)
{
return copyElement("container", cnvs, active, name);
}
public static UIObject makePanel(string name = null, GameObject cnvs = null, bool active = true)
{
UIObject uIObject = copyElement("panel", cnvs, active, name);
uIObject.gameObject.transform.DestroyChildren();
return uIObject;
}
public static UIObject makeLabel(string name = null, GameObject cnvs = null, bool active = true)
{
UIObject uIObject = copyElement("label", cnvs, active, name);
uIObject.gameObject.transform.DestroyChildren();
((TMP_Text)uIObject.gameObject.GetComponentInChildren<TextMeshProUGUI>()).SetText(name, true);
return uIObject;
}
public static UIObject makeButton(string name = null, Action<GameObject> listener = null, GameObject cnvs = null, bool active = true)
{
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Expected O, but got Unknown
UIObject ret = copyElement("button", cnvs, active, name);
((UnityEventBase)ret.gameObject.GetComponent<Button>().onClick).RemoveAllListeners();
if (listener != null)
{
((UnityEvent)ret.gameObject.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
{
listener(ret.gameObject);
});
}
Object.Destroy((Object)(object)ret.gameObject.GetComponentInChildren<LocalizeStringEvent>());
if (name == null)
{
name = "button";
}
((TMP_Text)ret.gameObject.GetComponentInChildren<TextMeshProUGUI>()).SetText(name, true);
return ret;
}
}
public class Templates
{
public static Dictionary<string, string> AleAndTale = new Dictionary<string, string>
{
{ "button", "Common/GameCanvas/Quest Board Screen/Panel/TaskListPanel/ButtonFollow" },
{ "container", "Common/GameCanvas/Craft Screen/Craft/RecipeListPanel/Scroll View" },
{ "label", "Common/GameCanvas/Quest Board Screen/Panel/TaskListPanel/Panel/Text (TMP)" },
{ "panel", "Common/GameCanvas/Quest Board Screen/Panel" }
};
}
public class UIObject
{
public GameObject gameObject;
public RectTransform rectTransform;
public Vector3 position;
public float parentWidth;
public float parentHeight;
public UIObject(GameObject template, GameObject Canvas = null, string name = null, bool active = true)
{
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
if (Object.op_Implicit((Object)(object)Canvas))
{
gameObject = Object.Instantiate<GameObject>(template, Canvas.transform);
}
else
{
gameObject = Object.Instantiate<GameObject>(template, template.transform.parent);
}
if (name != null)
{
((Object)gameObject).name = name;
}
rectTransform = gameObject.GetComponentInChildren<RectTransform>();
position = new Vector3(0f, 0f, 0f);
((Transform)rectTransform).localPosition = position;
Rect rect = ((Component)gameObject.transform.parent).GetComponent<RectTransform>().rect;
parentWidth = ((Rect)(ref rect)).width;
rect = ((Component)gameObject.transform.parent).GetComponent<RectTransform>().rect;
parentHeight = ((Rect)(ref rect)).height;
gameObject.SetActive(active);
}
public void setSize(float preferredWidth, float preferredHeight)
{
rectTransform.SetSizeWithCurrentAnchors((Axis)0, preferredWidth);
rectTransform.SetSizeWithCurrentAnchors((Axis)1, preferredHeight);
}
public void offsetPosition(float x, float y, float z)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: 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)
((Transform)rectTransform).localPosition = new Vector3(((Transform)rectTransform).localPosition.x + x, ((Transform)rectTransform).localPosition.y + y, ((Transform)rectTransform).localPosition.z + z);
position = ((Transform)rectTransform).localPosition;
}
public void centerToParentX()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
RectTransform component = ((Component)gameObject.transform.parent).GetComponent<RectTransform>();
Rect rect = component.rect;
float num = ((Rect)(ref rect)).width / 2f;
rect = rectTransform.rect;
float num2 = num - ((Rect)(ref rect)).width;
((Transform)rectTransform).localPosition = new Vector3(num2, ((Transform)rectTransform).localPosition.y, ((Transform)rectTransform).localPosition.z);
}
public void centerToParentY()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
RectTransform component = ((Component)gameObject.transform.parent).GetComponent<RectTransform>();
Rect rect = component.rect;
float num = ((Rect)(ref rect)).height / 2f;
rect = rectTransform.rect;
float num2 = num - ((Rect)(ref rect)).height;
((Transform)rectTransform).localPosition = new Vector3(((Transform)rectTransform).localPosition.x, num2, ((Transform)rectTransform).localPosition.z);
}
}
public static class Utils
{
public static void DestroyChildren(this Transform parent)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
foreach (Transform item in parent)
{
Transform val = item;
Object.Destroy((Object)(object)((Component)val).gameObject);
}
}
public static void DestroyChildrenExcept(this Transform parent, List<Transform> excludes)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
foreach (Transform item in parent)
{
Transform val = item;
if (!excludes.Contains(val))
{
Object.Destroy((Object)(object)((Component)val).gameObject);
}
}
}
public static void DestroyChildrenExcept(this Transform parent, Transform exclude)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
foreach (Transform item in parent)
{
Transform val = item;
if ((Object)(object)val != (Object)(object)exclude)
{
Object.Destroy((Object)(object)((Component)val).gameObject);
}
}
}
}
}