using System;
using System.Collections;
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 Empress_ShopLoaderAPI;
using ExitGames.Client.Photon;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;
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("Omniscye")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+7caf00520587bc4705fdf22c05a4ce546279ff19")]
[assembly: AssemblyProduct("EmpressCustomShop2")]
[assembly: AssemblyTitle("EmpressCustomShop2")]
[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.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 CustomShopMod
{
[BepInPlugin("com.Omniscye.KermitShop", "Kermit Shop", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class MyShopPlugin : BaseUnityPlugin
{
private void Awake()
{
AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "shop2"));
if ((Object)(object)val != (Object)null)
{
GameObject val2 = val.LoadAsset<GameObject>("Module - Shop - N - Omni2");
if ((Object)(object)val2 != (Object)null)
{
ShopAPI.RegisterShop(val2, "Omniscye/KermitShop");
((BaseUnityPlugin)this).Logger.LogInfo((object)"Kermit Shop registered successfully via Empress ShopAPI.");
}
else
{
((BaseUnityPlugin)this).Logger.LogError((object)"Kermit Shop: Prefab 'Module - Shop - N - Omni2' not found in bundle!");
}
}
else
{
((BaseUnityPlugin)this).Logger.LogError((object)"Kermit Shop: Failed to load AssetBundle 'shop2'!");
}
}
}
public class KermitTalker : MonoBehaviour, IOnEventCallback
{
public float interactionDistance = 3f;
public float rotationSpeed = 5f;
public float textTypeSpeed = 0.05f;
public AudioClip soundOpenDialog;
public AudioClip soundCloseDialog;
public AudioClip soundPurchase;
private AudioSource _a;
private bool _b;
private bool _shopOpen;
private GameObject _p;
private Text _t;
private string _c = "";
private Quaternion _o;
private Coroutine _r;
private List<Item> _shopItems = new List<Item>();
private int _selIndex;
private Transform _targetPlayer;
private const byte KermitShopBuyEvent = 142;
private List<string> _l = new List<string> { "Hi-ho, Kermit the Frog here.", "It's not easy being green... having to recycle all this scrap.", "Yaaay! A customer! flail", "This transaction is brought to you by the letter M, for Money.", "Have you seen Miss Piggy? She said she was looking for a 'Grand Prize'.", "I heard there are rainbow connections in the sewers. Or maybe that's just toxic sludge.", "If you need supplies, you've come to the right frog.", "Keep moving forward, that's the only way.", "A little song, a little dance, a little seltzer down your pants.", "Do be careful out there." };
private void OnEnable()
{
PhotonNetwork.AddCallbackTarget((object)this);
}
private void OnDisable()
{
PhotonNetwork.RemoveCallbackTarget((object)this);
}
private void Start()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
_o = ((Component)this).transform.rotation;
_a = ((Component)this).gameObject.AddComponent<AudioSource>();
_a.spatialBlend = 1f;
_a.minDistance = 1f;
_a.maxDistance = 10f;
U();
GenerateShopList();
}
private void GenerateShopList()
{
_shopItems.Clear();
foreach (Item value in StatsManager.instance.itemDictionary.Values)
{
if (!value.disabled && value.physicalItem && value.value.valueMax > 0f && !((Object)value).name.Contains("Upgrade"))
{
_shopItems.Add(value);
}
}
_shopItems = _shopItems.OrderBy((Item x) => x.value.valueMax).ToList();
}
private void Update()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: 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)
if (!_b)
{
((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, _o, Time.deltaTime * rotationSpeed);
}
if (!Object.op_Implicit((Object)(object)PlayerAvatar.instance))
{
return;
}
float num = Vector3.Distance(((Component)this).transform.position, ((Component)PlayerAvatar.instance).transform.position);
if (num <= interactionDistance)
{
if (!_b)
{
if (InputManager.instance.KeyDown((InputKey)2) || Input.GetKeyDown((KeyCode)101))
{
S();
}
}
else if (!_shopOpen && (Input.GetKeyDown((KeyCode)101) || Input.GetKeyDown((KeyCode)13) || Input.GetKeyDown((KeyCode)271)))
{
OpenShop();
return;
}
}
else if (_b && num > interactionDistance)
{
E();
}
if (_b)
{
H();
if (_shopOpen)
{
UpdateShopInput();
}
}
}
private void UpdateShopInput()
{
if (Input.GetKeyDown((KeyCode)273) || Input.GetKeyDown((KeyCode)119))
{
_selIndex--;
if (_selIndex < 0)
{
_selIndex = _shopItems.Count - 1;
}
UpdateShopUI();
}
if (Input.GetKeyDown((KeyCode)274) || Input.GetKeyDown((KeyCode)115))
{
_selIndex++;
if (_selIndex >= _shopItems.Count)
{
_selIndex = 0;
}
UpdateShopUI();
}
if (Input.GetKeyDown((KeyCode)101) || Input.GetKeyDown((KeyCode)13) || Input.GetKeyDown((KeyCode)271))
{
BuyItem();
}
if (Input.GetKeyDown((KeyCode)27) || InputManager.instance.KeyDown((InputKey)18))
{
E();
}
}
private int GetPrice(Item item)
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Invalid comparison between Unknown and I4
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Invalid comparison between Unknown and I4
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Invalid comparison between Unknown and I4
float num = item.value.valueMax / 1000f * 4f;
if (Object.op_Implicit((Object)(object)ShopManager.instance))
{
if ((int)item.itemType == 3)
{
num = ShopManager.instance.UpgradeValueGet(num, item);
}
else if ((int)item.itemType == 8)
{
num = ShopManager.instance.HealthPackValueGet(num);
}
else if ((int)item.itemType == 5)
{
num = ShopManager.instance.CrystalValueGet(num);
}
}
return Mathf.CeilToInt(num);
}
private void BuyItem()
{
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Expected O, but got Unknown
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
if (_shopItems.Count == 0)
{
return;
}
Item val = _shopItems[_selIndex];
int price = GetPrice(val);
int num = SemiFunc.StatGetRunCurrency();
if (num >= price)
{
if (PhotonNetwork.IsMasterClient)
{
SemiFunc.StatSetRunCurrency(num - price);
StatsManager.instance.ItemPurchase(((Object)val).name);
}
else
{
object[] array = new object[2]
{
price,
((Object)val).name
};
RaiseEventOptions val2 = new RaiseEventOptions
{
Receivers = (ReceiverGroup)2
};
PhotonNetwork.RaiseEvent((byte)142, (object)array, val2, SendOptions.SendReliable);
}
if (Object.op_Implicit((Object)(object)soundPurchase))
{
_a.PlayOneShot(soundPurchase);
}
else if (Object.op_Implicit((Object)(object)soundOpenDialog))
{
_a.PlayOneShot(soundOpenDialog);
}
UpdateShopUI();
}
else if (Object.op_Implicit((Object)(object)soundCloseDialog))
{
_a.PlayOneShot(soundCloseDialog);
}
}
public void OnEvent(EventData photonEvent)
{
if (photonEvent.Code == 142 && !((Object)(object)this != (Object)(object)Object.FindObjectOfType<KermitTalker>()) && PhotonNetwork.IsMasterClient)
{
object[] obj = (object[])photonEvent.CustomData;
int num = (int)obj[0];
string text = (string)obj[1];
int num2 = SemiFunc.StatGetRunCurrency();
if (num2 >= num)
{
SemiFunc.StatSetRunCurrency(num2 - num);
StatsManager.instance.ItemPurchase(text);
}
}
}
private void UpdateShopUI()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)_t))
{
return;
}
RectTransform component = _p.GetComponent<RectTransform>();
component.anchorMin = new Vector2(0.1f, 0.1f);
component.anchorMax = new Vector2(0.9f, 0.8f);
string text = "<size=20><b>KERMIT'S SHOP</b></size>\n\n";
int num = 9;
int num2 = 0;
int num3 = _shopItems.Count;
if (_shopItems.Count > num)
{
num2 = _selIndex - num / 2;
if (num2 < 0)
{
num2 = 0;
}
if (num2 + num > _shopItems.Count)
{
num2 = _shopItems.Count - num;
}
num3 = num2 + num;
}
for (int i = num2; i < num3; i++)
{
Item val = _shopItems[i];
string text2 = ((i == _selIndex) ? "> <color=green>" : " ");
string text3 = ((i == _selIndex) ? "</color>" : "");
text += $"{text2}{val.itemName} - ${GetPrice(val)}{text3}\n";
}
text += $"\n<b>Money: ${SemiFunc.StatGetRunCurrency()}</b>\n[E] Buy [Esc] Exit";
_t.text = text;
}
private void OpenShop()
{
if (_r != null)
{
((MonoBehaviour)this).StopCoroutine(_r);
}
_shopOpen = true;
_selIndex = 0;
UpdateShopUI();
}
private void H()
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: 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)
if (Object.op_Implicit((Object)(object)PlayerController.instance))
{
PlayerController.instance.InputDisable(0.1f);
PlayerController.instance.rb.velocity = Vector3.zero;
}
if (Object.op_Implicit((Object)(object)_targetPlayer))
{
Vector3 position = _targetPlayer.position;
position.y = ((Component)this).transform.position.y;
if (position - ((Component)this).transform.position != Vector3.zero)
{
((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, Quaternion.LookRotation(position - ((Component)this).transform.position), Time.deltaTime * rotationSpeed);
}
}
}
private void S()
{
//IL_0040: 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)
_b = true;
_shopOpen = false;
if (Object.op_Implicit((Object)(object)PlayerAvatar.instance))
{
_targetPlayer = ((Component)PlayerAvatar.instance).transform;
}
RectTransform component = _p.GetComponent<RectTransform>();
component.anchorMin = new Vector2(0.1f, 0.1f);
component.anchorMax = new Vector2(0.9f, 0.3f);
_c = _l[Random.Range(0, _l.Count)];
if (Object.op_Implicit((Object)(object)_p))
{
_p.SetActive(true);
}
if (Object.op_Implicit((Object)(object)soundOpenDialog))
{
_a.PlayOneShot(soundOpenDialog);
}
if (_r != null)
{
((MonoBehaviour)this).StopCoroutine(_r);
}
_r = ((MonoBehaviour)this).StartCoroutine(T(_c));
}
private void E()
{
_b = false;
_shopOpen = false;
_targetPlayer = null;
if (Object.op_Implicit((Object)(object)_p))
{
_p.SetActive(false);
}
if (Object.op_Implicit((Object)(object)soundCloseDialog))
{
_a.PlayOneShot(soundCloseDialog);
}
if (_r != null)
{
((MonoBehaviour)this).StopCoroutine(_r);
}
if (Object.op_Implicit((Object)(object)_t))
{
_t.text = "";
}
}
private IEnumerator T(string l)
{
_t.text = "";
foreach (char c in l)
{
Text t = _t;
t.text += c;
yield return (object)new WaitForSeconds(textTypeSpeed);
}
}
private void U()
{
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Expected O, but got Unknown
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: 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_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_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Expected O, but got Unknown
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: 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: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
Transform val = (Object.op_Implicit((Object)(object)HUDCanvas.instance) ? ((Component)HUDCanvas.instance).transform : null);
if (!Object.op_Implicit((Object)(object)val))
{
GameObject val2 = new GameObject("KermitDialogCanvas");
Canvas obj = val2.AddComponent<Canvas>();
obj.renderMode = (RenderMode)0;
obj.sortingOrder = 999;
val2.AddComponent<CanvasScaler>();
val2.AddComponent<GraphicRaycaster>();
val = val2.transform;
}
_p = new GameObject("KermitPanel");
_p.transform.SetParent(val, false);
((Graphic)_p.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.8f);
RectTransform component = _p.GetComponent<RectTransform>();
component.anchorMin = new Vector2(0.1f, 0.1f);
component.anchorMax = new Vector2(0.9f, 0.3f);
Vector2 offsetMin = (component.offsetMax = Vector2.zero);
component.offsetMin = offsetMin;
GameObject val3 = new GameObject("KermitText");
val3.transform.SetParent(_p.transform, false);
_t = val3.AddComponent<Text>();
Font font = ((IEnumerable<Font>)Resources.FindObjectsOfTypeAll<Font>()).FirstOrDefault((Func<Font, bool>)((Font x) => ((Object)x).name == "Arial")) ?? Resources.FindObjectsOfTypeAll<Font>().FirstOrDefault() ?? Font.CreateDynamicFontFromOSFont("Arial", 16);
_t.font = font;
((Graphic)_t).color = Color.white;
_t.alignment = (TextAnchor)0;
_t.resizeTextForBestFit = true;
_t.resizeTextMinSize = 14;
_t.resizeTextMaxSize = 35;
_t.verticalOverflow = (VerticalWrapMode)0;
RectTransform component2 = val3.GetComponent<RectTransform>();
component2.anchorMin = new Vector2(0.02f, 0.05f);
component2.anchorMax = new Vector2(0.98f, 0.95f);
offsetMin = (component2.offsetMax = Vector2.zero);
component2.offsetMin = offsetMin;
_p.SetActive(false);
}
private void OnDestroy()
{
if (Object.op_Implicit((Object)(object)_p))
{
Object.Destroy((Object)(object)_p);
}
}
}
}