using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using TMPro;
using UnityEngine;
using Zorro.Core;
[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("peak-shop")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+bf3a9d1ad086c53e55ef25c5603a92d9b6cc84b1")]
[assembly: AssemblyProduct("peak-shop")]
[assembly: AssemblyTitle("peak-shop")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 PeakShop
{
internal static class CoinHUD
{
private const int Width = 180;
private const int Height = 56;
private const int MarginX = 24;
private const int MarginY = 24;
private static GUIStyle? _coinStyle;
private static GUIStyle? _hintStyle;
public static void Draw()
{
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: 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_00d0: 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)
if (!ShopWindow.IsOpen && !((Object)(object)Character.localCharacter == (Object)null))
{
ShopStyle.EnsureInitialized();
EnsureLocalStyles();
Rect val = default(Rect);
((Rect)(ref val))..ctor((float)(Screen.width - 180 - 24), 24f, 180f, 56f);
if ((Object)(object)ShopStyle.BlueTex != (Object)null)
{
GUI.DrawTexture(val, (Texture)(object)ShopStyle.BlueTex);
}
ShopStyle.DrawBorder(val, 2f, ShopStyle.White);
GUI.Label(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y + 4f, ((Rect)(ref val)).width, 28f), $"{EconomyManager.Coins} COINS", _coinStyle);
GUI.Label(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y + 32f, ((Rect)(ref val)).width, 18f), "find a shop kiosk", _hintStyle);
}
}
private static void EnsureLocalStyles()
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_0040: 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_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Expected O, but got Unknown
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
if (_coinStyle == null || _hintStyle == null)
{
_coinStyle = new GUIStyle
{
fontSize = 20,
fontStyle = (FontStyle)1,
alignment = (TextAnchor)4,
richText = true
};
_coinStyle.normal.textColor = ShopStyle.Yellow;
if ((Object)(object)ShopStyle.GameFont != (Object)null)
{
_coinStyle.font = ShopStyle.GameFont;
}
_hintStyle = new GUIStyle
{
fontSize = 11,
alignment = (TextAnchor)4,
richText = true
};
_hintStyle.normal.textColor = new Color(1f, 1f, 1f, 0.78f);
if ((Object)(object)ShopStyle.GameFont != (Object)null)
{
_hintStyle.font = ShopStyle.GameFont;
}
}
}
}
internal static class EconomyManager
{
private static int _coins;
public static int Coins => _coins;
public static void Reset()
{
_coins = 0;
}
public static void AddCoins(int amount, string? source = null)
{
if (amount > 0)
{
_coins += amount;
if (source != null)
{
Plugin.Log.LogInfo((object)$"+{amount} coins ({source}) → {_coins} total");
}
else
{
Plugin.Log.LogInfo((object)$"+{amount} coins → {_coins} total");
}
}
}
public static bool TrySpend(int amount)
{
if (amount <= 0)
{
return true;
}
if (_coins < amount)
{
return false;
}
_coins -= amount;
Plugin.Log.LogInfo((object)$"-{amount} coins → {_coins} total");
return true;
}
public static int LuggageReward(Luggage luggage)
{
return Random.Range(8, 19);
}
}
[HarmonyPatch(typeof(CharacterInput), "Sample")]
internal static class CharacterInput_Sample_Patch
{
private static void Prefix(ref bool playerMovementActive)
{
if (ShopWindow.IsOpen)
{
playerMovementActive = false;
}
}
}
[HarmonyPatch(typeof(Luggage), "OpenLuggageRPC")]
internal static class Luggage_OpenLuggageRPC_Patch
{
private static readonly HashSet<int> _rewarded = new HashSet<int>();
private static void Postfix(Luggage __instance, bool spawnItems)
{
if (spawnItems && !((Object)(object)__instance == (Object)null))
{
int instanceID = ((Object)__instance).GetInstanceID();
if (_rewarded.Add(instanceID))
{
EconomyManager.AddCoins(EconomyManager.LuggageReward(__instance), "luggage");
}
}
}
}
[HarmonyPatch(typeof(Campfire), "Awake")]
internal static class Campfire_Awake_Patch
{
private static readonly HashSet<int> _spawnedFor = new HashSet<int>();
private static void Postfix(Campfire __instance)
{
//IL_0027: 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_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: 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_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: 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_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: 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)
if ((Object)(object)__instance == (Object)null)
{
return;
}
int instanceID = ((Object)__instance).GetInstanceID();
if (!_spawnedFor.Add(instanceID))
{
return;
}
try
{
Transform transform = ((Component)__instance).transform;
Vector3 val = transform.right * 2.5f + Vector3.up * 0f;
Vector3 val2 = transform.position + val;
RaycastHit val3 = default(RaycastHit);
if (Physics.Raycast(val2 + Vector3.up * 4f, Vector3.down, ref val3, 12f))
{
val2.y = ((RaycastHit)(ref val3)).point.y;
}
Quaternion rotation = Quaternion.LookRotation(transform.position - val2, Vector3.up);
ShopKiosk.Build(val2, rotation);
Plugin.Log.LogDebug((object)$"ShopKiosk spawned next to campfire at {val2}.");
}
catch (Exception arg)
{
Plugin.Log.LogError((object)$"Failed to spawn ShopKiosk for campfire: {arg}");
}
}
}
[BepInPlugin("com.altumus.peakshop", "peak-shop", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
public const string PluginGuid = "com.altumus.peakshop";
public const string PluginName = "peak-shop";
public const string PluginVersion = "1.0.0";
public static ManualLogSource Log;
private void Awake()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
Log = ((BaseUnityPlugin)this).Logger;
new Harmony("com.altumus.peakshop").PatchAll();
Log.LogInfo((object)"peak-shop v1.0.0 loaded. Interact with the shop kiosk next to a campfire.");
}
private void Update()
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
if (ShopWindow.IsOpen && Input.GetKeyDown((KeyCode)27))
{
ShopWindow.IsOpen = false;
}
if (ShopWindow.IsOpen)
{
if ((int)Cursor.lockState != 0)
{
Cursor.lockState = (CursorLockMode)0;
}
if (!Cursor.visible)
{
Cursor.visible = true;
}
}
}
private void OnGUI()
{
if (ShopWindow.IsOpen)
{
Cursor.lockState = (CursorLockMode)0;
Cursor.visible = true;
}
CoinHUD.Draw();
ShopWindow.Draw();
}
}
internal static class Prices
{
private static readonly Dictionary<string, int> _exact = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase)
{
{ "Marshmallow", 16 },
{ "Lollipop", 20 },
{ "Airplane Food", 11 },
{ "Granola Bar", 7 },
{ "ScoutCookies", 12 },
{ "TrailMix", 5 },
{ "Bandages", 8 },
{ "Heat Pack", 11 },
{ "Antidote", 23 },
{ "FirstAidKit", 30 },
{ "Cure-All", 65 },
{ "ScoutEffigy", 75 },
{ "Cure-Some", 25 },
{ "EnergyElixir", 32 },
{ "Energy Drink", 15 },
{ "Sports Drink", 10 },
{ "Napberry", 9 },
{ "Flare", 6 },
{ "Lantern", 25 },
{ "Compass", 20 },
{ "Bugle", 18 },
{ "PortableStovetopItem", 45 },
{ "RopeShooter", 38 },
{ "RopeSpool", 22 },
{ "Anti-Rope Spool", 22 },
{ "RopeShooterAnti", 42 },
{ "ChainShooter", 40 },
{ "Piton", 20 },
{ "ShelfShroom", 5 },
{ "Backpack", 60 },
{ "Binoculars", 15 },
{ "Parasol", 18 },
{ "Megaphone", 12 },
{ "Bugle_Magic", 88 },
{ "Lantern_Faerie", 70 },
{ "PandorasBox", 125 },
{ "HealingDart Variant", 35 },
{ "Cursed Skull", 100 },
{ "Pirate Compass", 80 },
{ "Bugle_Scoutmaster Variant", 45 },
{ "MagicBean", 40 },
{ "Strange Gem", 50 },
{ "BounceShroom", 8 },
{ "Warp Compass", 75 },
{ "Frisbee", 3 },
{ "BingBong", 250 }
};
public const int FallbackPrice = 35;
public static int GetPrice(string prefabName, string displayName)
{
if (_exact.TryGetValue(prefabName, out var value))
{
return value;
}
if (_exact.TryGetValue(displayName, out value))
{
return value;
}
return GuessPrice(prefabName);
}
private static int GuessPrice(string prefabName)
{
string text = prefabName.ToLowerInvariant();
if (text.Contains("berry") || text.Contains("nana") || text.Contains("shroom") || text.Contains("apple") || text.Contains("kingberry"))
{
return 6;
}
if (text.Contains("idol") || text.Contains("totem") || text.Contains("relic") || text.Contains("ancient"))
{
return 90;
}
if (text.Contains("dart") || text.Contains("aid") || text.Contains("bandage") || text.Contains("pack"))
{
return 25;
}
if (text.Contains("rope") || text.Contains("hook") || text.Contains("piton") || text.Contains("chain"))
{
return 30;
}
if (text.Contains("lantern") || text.Contains("flare") || text.Contains("torch"))
{
return 18;
}
if (text.Contains("magic") || text.Contains("faerie") || text.Contains("cursed") || text.Contains("warp"))
{
return 70;
}
if (text.Contains("bishop") || text.Contains("king") || text.Contains("queen") || text.Contains("pawn"))
{
return 40;
}
return 35;
}
}
public class ShopKiosk : MonoBehaviour, IInteractibleConstant, IInteractible
{
private const float InteractTime = 0.4f;
private static Material? _kioskMaterial;
private static Material? _signMaterial;
public bool holdOnFinish => false;
public static GameObject Build(Vector3 position, Quaternion rotation)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: 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_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Expected O, but got Unknown
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("HookGun_ShopKiosk");
val.transform.SetPositionAndRotation(position, rotation);
GameObject obj = GameObject.CreatePrimitive((PrimitiveType)3);
((Object)obj).name = "Body";
obj.transform.SetParent(val.transform, false);
obj.transform.localPosition = new Vector3(0f, 0.6f, 0f);
obj.transform.localScale = new Vector3(1f, 1.2f, 1f);
ApplyMaterial(obj, GetKioskMaterial());
GameObject obj2 = GameObject.CreatePrimitive((PrimitiveType)3);
((Object)obj2).name = "Top";
obj2.transform.SetParent(val.transform, false);
obj2.transform.localPosition = new Vector3(0f, 1.32f, 0f);
obj2.transform.localScale = new Vector3(1.15f, 0.12f, 1.15f);
ApplyMaterial(obj2, GetSignMaterial());
GameObject val2 = new GameObject("Sign");
val2.transform.SetParent(val.transform, false);
val2.transform.localPosition = new Vector3(0f, 1.95f, 0f);
val2.transform.localScale = Vector3.one;
TextMesh obj3 = val2.AddComponent<TextMesh>();
obj3.text = "SHOP";
obj3.fontSize = 64;
obj3.characterSize = 0.06f;
obj3.anchor = (TextAnchor)4;
obj3.alignment = (TextAlignment)1;
obj3.color = Color.white;
obj3.fontStyle = (FontStyle)1;
val2.AddComponent<Billboard>().mesh = val2;
Collider[] componentsInChildren = val.GetComponentsInChildren<Collider>();
for (int i = 0; i < componentsInChildren.Length; i++)
{
Object.Destroy((Object)(object)componentsInChildren[i]);
}
BoxCollider obj4 = val.AddComponent<BoxCollider>();
obj4.center = new Vector3(0f, 0.7f, 0f);
obj4.size = new Vector3(1.3f, 1.6f, 1.3f);
val.AddComponent<ShopKiosk>();
return val;
}
private static void ApplyMaterial(GameObject go, Material mat)
{
Renderer component = go.GetComponent<Renderer>();
if ((Object)(object)component != (Object)null)
{
component.sharedMaterial = mat;
}
}
private static Material GetKioskMaterial()
{
//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_0028: 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_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Expected O, but got Unknown
//IL_004e: Expected O, but got Unknown
if ((Object)(object)_kioskMaterial != (Object)null)
{
return _kioskMaterial;
}
Material val = new Material(FindUsableShader())
{
name = "HookGun_KioskMat",
color = new Color(0.118f, 0.384f, 0.847f, 1f)
};
_kioskMaterial = val;
return val;
}
private static Material GetSignMaterial()
{
//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_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Expected O, but got Unknown
//IL_003a: Expected O, but got Unknown
if ((Object)(object)_signMaterial != (Object)null)
{
return _signMaterial;
}
Material val = new Material(FindUsableShader())
{
name = "HookGun_KioskSignMat",
color = Color.white
};
_signMaterial = val;
return val;
}
private static Shader FindUsableShader()
{
return Shader.Find("Universal Render Pipeline/Lit") ?? Shader.Find("Standard") ?? Shader.Find("Sprites/Default");
}
public bool IsInteractible(Character interactor)
{
return !ShopWindow.IsOpen;
}
public bool IsConstantlyInteractable(Character interactor)
{
return !ShopWindow.IsOpen;
}
public float GetInteractTime(Character interactor)
{
return 0.4f;
}
public void Interact(Character interactor)
{
}
public void Interact_CastFinished(Character interactor)
{
if (!ShopWindow.IsOpen)
{
ShopWindow.Toggle();
Plugin.Log.LogInfo((object)"Shop opened via kiosk interaction.");
}
}
public void CancelCast(Character interactor)
{
}
public void ReleaseInteract(Character interactor)
{
}
public void HoverEnter()
{
}
public void HoverExit()
{
}
public Vector3 Center()
{
//IL_0006: 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_001f: Unknown result type (might be due to invalid IL or missing references)
return ((Component)this).transform.position + new Vector3(0f, 0.7f, 0f);
}
public Transform GetTransform()
{
return ((Component)this).transform;
}
public string GetInteractionText()
{
return "Open shop";
}
public string GetName()
{
return "SHOP";
}
}
internal class Billboard : MonoBehaviour
{
public GameObject? mesh;
private void LateUpdate()
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: 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)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
Camera main = Camera.main;
if (!((Object)(object)main == (Object)null) && !((Object)(object)mesh == (Object)null))
{
Vector3 val = mesh.transform.position - ((Component)main).transform.position;
val.y = 0f;
if (!(((Vector3)(ref val)).sqrMagnitude < 0.0001f))
{
mesh.transform.rotation = Quaternion.LookRotation(((Vector3)(ref val)).normalized);
}
}
}
}
internal static class ShopStyle
{
public static readonly Color Backdrop = new Color(0f, 0f, 0f, 0.55f);
public static readonly Color Blue = new Color(0.118f, 0.384f, 0.847f, 1f);
public static readonly Color BlueDark = new Color(0.078f, 0.275f, 0.659f, 1f);
public static readonly Color BlueDeep = new Color(0.063f, 0.196f, 0.471f, 1f);
public static readonly Color Paper = new Color(0.91f, 0.949f, 0.886f, 1f);
public static readonly Color PaperDim = new Color(0.835f, 0.89f, 0.808f, 1f);
public static readonly Color White = Color.white;
public static readonly Color Yellow = new Color(0.961f, 0.847f, 0.357f, 1f);
public static readonly Color TextOnBlue = Color.white;
public static readonly Color TextOnPaper = new Color(0.078f, 0.275f, 0.659f, 1f);
private static Texture2D? _backdropTex;
private static Texture2D? _blueTex;
private static Texture2D? _blueDarkTex;
private static Texture2D? _blueDeepTex;
private static Texture2D? _paperTex;
private static Texture2D? _paperDimTex;
private static Texture2D? _whiteTex;
private static Texture2D? _yellowTex;
public static GUIStyle? Window;
public static GUIStyle? TitleHuge;
public static GUIStyle? TitleSmall;
public static GUIStyle? Label;
public static GUIStyle? LabelDim;
public static GUIStyle? Button;
public static GUIStyle? TextField;
public static GUIStyle? Tile;
public static GUIStyle? TileLabel;
public static GUIStyle? PriceLabel;
public static GUIStyle? PriceLabelMissing;
public static GUIStyle? CoinLabel;
public static GUIStyle? Invisible;
private static bool _initialized;
private static Font? _gameFont;
public static Font? GameFont => _gameFont;
public static Texture2D? PaperTex => _paperTex;
public static Texture2D? PaperDimTex => _paperDimTex;
public static Texture2D? BlueTex => _blueTex;
public static Texture2D? BlueDarkTex => _blueDarkTex;
public static Texture2D? WhiteTex => _whiteTex;
public static Texture2D? YellowTex => _yellowTex;
public static void EnsureInitialized()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Expected O, but got Unknown
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Expected O, but got Unknown
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Expected O, but got Unknown
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: 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_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Expected O, but got Unknown
//IL_0107: Expected O, but got Unknown
//IL_0111: 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_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Expected O, but got Unknown
//IL_014a: Expected O, but got Unknown
//IL_0168: 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_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Unknown result type (might be due to invalid IL or missing references)
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_0195: Expected O, but got Unknown
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Expected O, but got Unknown
//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: Expected O, but got Unknown
//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0201: Unknown result type (might be due to invalid IL or missing references)
//IL_0208: Unknown result type (might be due to invalid IL or missing references)
//IL_020f: Unknown result type (might be due to invalid IL or missing references)
//IL_0216: Unknown result type (might be due to invalid IL or missing references)
//IL_0220: Expected O, but got Unknown
//IL_0220: Unknown result type (might be due to invalid IL or missing references)
//IL_0225: Unknown result type (might be due to invalid IL or missing references)
//IL_022f: Expected O, but got Unknown
//IL_022f: Unknown result type (might be due to invalid IL or missing references)
//IL_023b: Expected O, but got Unknown
//IL_0295: Unknown result type (might be due to invalid IL or missing references)
//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
//IL_02db: Unknown result type (might be due to invalid IL or missing references)
//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
//IL_02f9: Expected O, but got Unknown
//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0308: Expected O, but got Unknown
//IL_0308: Unknown result type (might be due to invalid IL or missing references)
//IL_0314: Expected O, but got Unknown
//IL_035a: Unknown result type (might be due to invalid IL or missing references)
//IL_036e: Unknown result type (might be due to invalid IL or missing references)
//IL_0382: Unknown result type (might be due to invalid IL or missing references)
//IL_038c: Unknown result type (might be due to invalid IL or missing references)
//IL_0391: Unknown result type (might be due to invalid IL or missing references)
//IL_0396: Unknown result type (might be due to invalid IL or missing references)
//IL_03a0: Expected O, but got Unknown
//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
//IL_03af: Expected O, but got Unknown
//IL_03af: Unknown result type (might be due to invalid IL or missing references)
//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
//IL_03be: Expected O, but got Unknown
//IL_03c3: Expected O, but got Unknown
//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
//IL_03dc: Unknown result type (might be due to invalid IL or missing references)
//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
//IL_03eb: Unknown result type (might be due to invalid IL or missing references)
//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0401: Expected O, but got Unknown
//IL_0401: Unknown result type (might be due to invalid IL or missing references)
//IL_0408: Unknown result type (might be due to invalid IL or missing references)
//IL_0414: Expected O, but got Unknown
//IL_041e: Unknown result type (might be due to invalid IL or missing references)
//IL_0428: Unknown result type (might be due to invalid IL or missing references)
//IL_042d: Unknown result type (might be due to invalid IL or missing references)
//IL_0435: Unknown result type (might be due to invalid IL or missing references)
//IL_043c: Unknown result type (might be due to invalid IL or missing references)
//IL_0443: Unknown result type (might be due to invalid IL or missing references)
//IL_0448: Unknown result type (might be due to invalid IL or missing references)
//IL_0452: Expected O, but got Unknown
//IL_0452: Unknown result type (might be due to invalid IL or missing references)
//IL_045e: Expected O, but got Unknown
//IL_047c: Unknown result type (might be due to invalid IL or missing references)
//IL_048b: Unknown result type (might be due to invalid IL or missing references)
//IL_0495: Expected O, but got Unknown
//IL_04b3: Unknown result type (might be due to invalid IL or missing references)
//IL_04bd: Unknown result type (might be due to invalid IL or missing references)
//IL_04c2: Unknown result type (might be due to invalid IL or missing references)
//IL_04ca: Unknown result type (might be due to invalid IL or missing references)
//IL_04d1: Unknown result type (might be due to invalid IL or missing references)
//IL_04d8: Unknown result type (might be due to invalid IL or missing references)
//IL_04e4: Expected O, but got Unknown
//IL_04ee: Unknown result type (might be due to invalid IL or missing references)
//IL_04f8: Unknown result type (might be due to invalid IL or missing references)
//IL_04fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0502: Unknown result type (might be due to invalid IL or missing references)
//IL_050c: Expected O, but got Unknown
//IL_050c: Unknown result type (might be due to invalid IL or missing references)
//IL_0511: Unknown result type (might be due to invalid IL or missing references)
//IL_051b: Expected O, but got Unknown
//IL_051b: Unknown result type (might be due to invalid IL or missing references)
//IL_0520: Unknown result type (might be due to invalid IL or missing references)
//IL_052a: Expected O, but got Unknown
//IL_052f: Expected O, but got Unknown
if (!_initialized)
{
_backdropTex = MakeTex(Backdrop);
_blueTex = MakeTex(Blue);
_blueDarkTex = MakeTex(BlueDark);
_blueDeepTex = MakeTex(BlueDeep);
_paperTex = MakeTex(Paper);
_paperDimTex = MakeTex(PaperDim);
_whiteTex = MakeTex(White);
_yellowTex = MakeTex(Yellow);
_gameFont = TryResolveGameFont();
Window = new GUIStyle
{
padding = new RectOffset(24, 24, 22, 22),
margin = new RectOffset(0, 0, 0, 0),
richText = true
};
Window.normal.background = _blueTex;
TitleHuge = new GUIStyle
{
fontSize = 30,
fontStyle = (FontStyle)1,
alignment = (TextAnchor)4,
richText = true,
padding = new RectOffset(0, 0, 4, 4)
};
TitleHuge.normal.textColor = TextOnBlue;
TitleSmall = new GUIStyle
{
fontSize = 12,
alignment = (TextAnchor)4,
richText = true,
padding = new RectOffset(0, 0, 0, 6)
};
TitleSmall.normal.textColor = new Color(1f, 1f, 1f, 0.7f);
Label = new GUIStyle
{
fontSize = 13,
alignment = (TextAnchor)3,
padding = new RectOffset(8, 8, 4, 4),
richText = true
};
Label.normal.textColor = TextOnBlue;
LabelDim = new GUIStyle(Label)
{
fontSize = 11
};
LabelDim.normal.textColor = new Color(1f, 1f, 1f, 0.7f);
Button = new GUIStyle
{
fontSize = 14,
fontStyle = (FontStyle)1,
alignment = (TextAnchor)4,
padding = new RectOffset(14, 14, 8, 8),
border = new RectOffset(2, 2, 2, 2),
richText = true
};
Button.normal.background = _blueDarkTex;
Button.hover.background = _whiteTex;
Button.active.background = _yellowTex;
Button.focused.background = _blueDarkTex;
Button.normal.textColor = TextOnBlue;
Button.hover.textColor = TextOnPaper;
Button.active.textColor = TextOnPaper;
Button.focused.textColor = TextOnBlue;
TextField = new GUIStyle
{
fontSize = 13,
padding = new RectOffset(10, 10, 6, 6),
border = new RectOffset(1, 1, 1, 1),
alignment = (TextAnchor)3
};
TextField.normal.background = _whiteTex;
TextField.hover.background = _whiteTex;
TextField.focused.background = _whiteTex;
TextField.normal.textColor = TextOnPaper;
TextField.hover.textColor = TextOnPaper;
TextField.focused.textColor = TextOnPaper;
Tile = new GUIStyle
{
border = new RectOffset(2, 2, 2, 2),
padding = new RectOffset(8, 8, 8, 8),
margin = new RectOffset(0, 0, 0, 0)
};
Tile.normal.background = _paperTex;
TileLabel = new GUIStyle
{
fontSize = 12,
fontStyle = (FontStyle)1,
alignment = (TextAnchor)4,
padding = new RectOffset(2, 2, 2, 2),
wordWrap = true,
richText = true
};
TileLabel.normal.textColor = TextOnPaper;
PriceLabel = new GUIStyle
{
fontSize = 12,
fontStyle = (FontStyle)1,
alignment = (TextAnchor)4,
padding = new RectOffset(2, 2, 2, 2),
richText = true
};
PriceLabel.normal.textColor = new Color(0.078f, 0.275f, 0.659f, 1f);
PriceLabelMissing = new GUIStyle(PriceLabel);
PriceLabelMissing.normal.textColor = new Color(0.65f, 0.18f, 0.18f, 1f);
CoinLabel = new GUIStyle
{
fontSize = 18,
fontStyle = (FontStyle)1,
alignment = (TextAnchor)4,
richText = true
};
CoinLabel.normal.textColor = Yellow;
Invisible = new GUIStyle
{
border = new RectOffset(0, 0, 0, 0),
padding = new RectOffset(0, 0, 0, 0),
margin = new RectOffset(0, 0, 0, 0)
};
Invisible.normal.background = null;
ApplyGameFont();
_initialized = true;
}
}
private static Font? TryResolveGameFont()
{
try
{
TMP_FontAsset[] array = Resources.FindObjectsOfTypeAll<TMP_FontAsset>();
Font val = null;
int num = -1;
string text = "";
TMP_FontAsset[] array2 = array;
foreach (TMP_FontAsset val2 in array2)
{
if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2.sourceFontFile == (Object)null))
{
string text2 = ((Object)val2).name ?? string.Empty;
int num2 = val2.atlasWidth;
if (text2.IndexOf("Daggersquare", StringComparison.OrdinalIgnoreCase) >= 0)
{
num2 += 10000;
}
if (text2.IndexOf("Bone", StringComparison.OrdinalIgnoreCase) >= 0)
{
num2 += 8000;
}
if (text2.IndexOf("Trajan", StringComparison.OrdinalIgnoreCase) >= 0)
{
num2 += 6000;
}
if (text2.IndexOf("Title", StringComparison.OrdinalIgnoreCase) >= 0)
{
num2 += 2000;
}
if (num2 > num)
{
num = num2;
val = val2.sourceFontFile;
text = text2;
}
}
}
if ((Object)(object)val != (Object)null)
{
Plugin.Log.LogInfo((object)("Using game font: TMP='" + text + "' → Font='" + ((Object)val).name + "'"));
}
else
{
Plugin.Log.LogWarning((object)"No usable TMP_FontAsset.sourceFontFile found; falling back to default IMGUI font.");
}
return val;
}
catch (Exception arg)
{
Plugin.Log.LogError((object)$"TryResolveGameFont failed: {arg}");
return null;
}
}
private static void ApplyGameFont()
{
if ((Object)(object)_gameFont == (Object)null)
{
return;
}
GUIStyle[] array = (GUIStyle[])(object)new GUIStyle[13]
{
Window, TitleHuge, TitleSmall, Label, LabelDim, Button, TextField, Tile, TileLabel, PriceLabel,
PriceLabelMissing, CoinLabel, Invisible
};
foreach (GUIStyle val in array)
{
if (val != null)
{
val.font = _gameFont;
}
}
}
public static void DrawBackdrop()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)_backdropTex == (Object)null))
{
GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)_backdropTex);
}
}
public static void DrawSolid(Rect rect, Color color)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
Texture2D val = MakeTex(color);
GUI.DrawTexture(rect, (Texture)(object)val);
}
public static void DrawBorder(Rect rect, float thickness, Color color)
{
//IL_0000: 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_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: 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)
Texture2D val = MakeTex(color);
GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width, thickness), (Texture)(object)val);
GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).yMax - thickness, ((Rect)(ref rect)).width, thickness), (Texture)(object)val);
GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, thickness, ((Rect)(ref rect)).height), (Texture)(object)val);
GUI.DrawTexture(new Rect(((Rect)(ref rect)).xMax - thickness, ((Rect)(ref rect)).y, thickness, ((Rect)(ref rect)).height), (Texture)(object)val);
}
public static void DrawHorizontalLine(float x, float y, float width, Color color)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
Texture2D val = MakeTex(color);
GUI.DrawTexture(new Rect(x, y, width, 1f), (Texture)(object)val);
}
private static Texture2D MakeTex(Color color)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: 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_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: 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_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: 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)
Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false)
{
hideFlags = (HideFlags)61,
filterMode = (FilterMode)0,
wrapMode = (TextureWrapMode)1
};
Color[] pixels = (Color[])(object)new Color[4] { color, color, color, color };
val.SetPixels(pixels);
val.Apply();
return val;
}
}
internal static class ShopWindow
{
private readonly struct ItemEntry
{
public readonly Item Item;
public readonly string PrefabName;
public readonly string DisplayName;
public readonly Texture2D? Icon;
public readonly int Price;
public ItemEntry(Item item, string prefabName, string displayName, Texture2D? icon, int price)
{
Item = item;
PrefabName = prefabName;
DisplayName = displayName;
Icon = icon;
Price = price;
}
}
[CompilerGenerated]
private static class <>O
{
public static WindowFunction <0>__DrawWindowContents;
}
public static bool IsOpen;
private const int WindowId = 1213157195;
private const int WindowWidth = 920;
private const int WindowHeight = 720;
private const int Columns = 5;
private const int TileSize = 150;
private const int TileGap = 10;
private static Rect _windowRect;
private static Vector2 _scroll;
private static string _filter = string.Empty;
private static List<ItemEntry>? _cachedItems;
public static void Toggle()
{
//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)
IsOpen = !IsOpen;
if (IsOpen)
{
_windowRect = new Rect((float)(Screen.width - 920) * 0.5f, (float)(Screen.height - 720) * 0.5f, 920f, 720f);
RefreshCatalog();
}
}
public static void Draw()
{
//IL_0017: 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_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Invalid comparison between Unknown and I4
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Invalid comparison between Unknown and I4
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: 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_007d: Expected O, but got Unknown
if (IsOpen)
{
ShopStyle.EnsureInitialized();
ShopStyle.DrawBackdrop();
if (((int)Event.current.type == 0 || (int)Event.current.type == 1 || (int)Event.current.type == 6) && !((Rect)(ref _windowRect)).Contains(Event.current.mousePosition))
{
Event.current.Use();
}
Rect windowRect = _windowRect;
object obj = <>O.<0>__DrawWindowContents;
if (obj == null)
{
WindowFunction val = DrawWindowContents;
<>O.<0>__DrawWindowContents = val;
obj = (object)val;
}
_windowRect = GUI.Window(1213157195, windowRect, (WindowFunction)obj, GUIContent.none, ShopStyle.Window);
ShopStyle.DrawBorder(_windowRect, 3f, ShopStyle.White);
}
}
private static void DrawWindowContents(int id)
{
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
DrawHeader();
GUILayout.Space(8f);
DrawSearchBar();
GUILayout.Space(8f);
DrawSeparator();
GUILayout.Space(8f);
DrawItemGrid();
GUILayout.Space(8f);
DrawSeparator();
GUILayout.Space(8f);
DrawFooter();
GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref _windowRect)).width, 70f));
}
private static void DrawHeader()
{
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
GUILayout.FlexibleSpace();
GUILayout.Label("ITEM SHOP", ShopStyle.TitleHuge, Array.Empty<GUILayoutOption>());
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
if ((Object)(object)Character.localCharacter != (Object)null)
{
_ = PhotonNetwork.IsConnected;
}
else
_ = 0;
int num = _cachedItems?.Count ?? 0;
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
GUILayout.Label($"{num} items", ShopStyle.LabelDim, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) });
GUILayout.FlexibleSpace();
GUILayout.Label($"<b>{EconomyManager.Coins}</b> coins", ShopStyle.CoinLabel ?? ShopStyle.Label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(180f) });
GUILayout.FlexibleSpace();
GUILayout.Label("ESC to close", ShopStyle.LabelDim, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(160f) });
GUILayout.EndHorizontal();
}
private static void DrawSearchBar()
{
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
GUILayout.Label("SEARCH", ShopStyle.LabelDim, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) });
_filter = GUILayout.TextField(_filter ?? string.Empty, ShopStyle.TextField, (GUILayoutOption[])(object)new GUILayoutOption[2]
{
GUILayout.ExpandWidth(true),
GUILayout.Height(30f)
});
if (GUILayout.Button("CLEAR", ShopStyle.Button, (GUILayoutOption[])(object)new GUILayoutOption[2]
{
GUILayout.Width(100f),
GUILayout.Height(30f)
}))
{
_filter = string.Empty;
}
GUILayout.EndHorizontal();
}
private static void DrawSeparator()
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: 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)
Rect rect = GUILayoutUtility.GetRect(1f, 1f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
ShopStyle.DrawHorizontalLine(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width, new Color(1f, 1f, 1f, 0.4f));
}
private static void DrawItemGrid()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
Character localCharacter = Character.localCharacter;
bool canSpawn = (Object)(object)localCharacter != (Object)null && PhotonNetwork.IsConnected;
_scroll = GUILayout.BeginScrollView(_scroll, Array.Empty<GUILayoutOption>());
if (_cachedItems == null || _cachedItems.Count == 0)
{
GUILayout.Space(12f);
GUILayout.Label("No items loaded yet — try Refresh after entering a run.", ShopStyle.LabelDim, Array.Empty<GUILayoutOption>());
GUILayout.EndScrollView();
return;
}
string text = _filter?.Trim() ?? string.Empty;
List<ItemEntry> list = new List<ItemEntry>();
foreach (ItemEntry cachedItem in _cachedItems)
{
if (text.Length <= 0 || cachedItem.DisplayName.IndexOf(text, StringComparison.OrdinalIgnoreCase) >= 0 || cachedItem.PrefabName.IndexOf(text, StringComparison.OrdinalIgnoreCase) >= 0)
{
list.Add(cachedItem);
}
}
if (list.Count == 0)
{
GUILayout.Space(8f);
GUILayout.Label("No items match \"" + text + "\".", ShopStyle.LabelDim, Array.Empty<GUILayoutOption>());
GUILayout.EndScrollView();
return;
}
for (int i = 0; i < (list.Count + 5 - 1) / 5; i++)
{
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
for (int j = 0; j < 5; j++)
{
int num = i * 5 + j;
if (num >= list.Count)
{
GUILayout.Space(160f);
continue;
}
DrawTile(list[num], localCharacter, canSpawn);
if (j < 4)
{
GUILayout.Space(10f);
}
}
GUILayout.EndHorizontal();
GUILayout.Space(10f);
}
GUILayout.EndScrollView();
}
private static void DrawTile(ItemEntry entry, Character? character, bool canSpawn)
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: 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_0081: 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)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Expected O, but got Unknown
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
//IL_020f: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_028f: Unknown result type (might be due to invalid IL or missing references)
//IL_0294: Unknown result type (might be due to invalid IL or missing references)
//IL_027f: Unknown result type (might be due to invalid IL or missing references)
//IL_0284: Unknown result type (might be due to invalid IL or missing references)
//IL_029d: Unknown result type (might be due to invalid IL or missing references)
//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
Rect rect = GUILayoutUtility.GetRect(150f, 150f, (GUILayoutOption[])(object)new GUILayoutOption[2]
{
GUILayout.Width(150f),
GUILayout.Height(150f)
});
bool flag = ((Rect)(ref rect)).Contains(Event.current.mousePosition);
bool flag2 = EconomyManager.Coins >= entry.Price;
bool flag3 = canSpawn && flag2;
if (!flag2 && (Object)(object)ShopStyle.PaperDimTex != (Object)null)
{
GUI.DrawTexture(rect, (Texture)(object)ShopStyle.PaperDimTex);
}
else if ((Object)(object)ShopStyle.PaperTex != (Object)null)
{
GUI.DrawTexture(rect, (Texture)(object)ShopStyle.PaperTex);
}
Rect val = default(Rect);
((Rect)(ref val))..ctor(((Rect)(ref rect)).x + 8f, ((Rect)(ref rect)).y + 8f, ((Rect)(ref rect)).width - 16f, ((Rect)(ref rect)).height - 16f - 28f - 22f);
if ((Object)(object)entry.Icon != (Object)null)
{
Color color = GUI.color;
if (!flag2)
{
GUI.color = new Color(1f, 1f, 1f, 0.45f);
}
GUI.DrawTexture(val, (Texture)(object)entry.Icon, (ScaleMode)2, true);
GUI.color = color;
}
else
{
ShopStyle.DrawSolid(val, new Color(0.78f, 0.85f, 0.76f, 1f));
GUIStyle val2 = new GUIStyle(ShopStyle.TileLabel)
{
fontSize = 32,
fontStyle = (FontStyle)1
};
val2.normal.textColor = new Color(0.5f, 0.6f, 0.5f, 1f);
GUI.Label(val, "?", val2);
}
GUI.Label(new Rect(((Rect)(ref rect)).x + 4f, ((Rect)(ref rect)).yMax - 28f - 22f - 2f, ((Rect)(ref rect)).width - 8f, 28f), entry.DisplayName.ToUpperInvariant(), ShopStyle.TileLabel);
Rect val3 = new Rect(((Rect)(ref rect)).x + 4f, ((Rect)(ref rect)).yMax - 22f - 2f, ((Rect)(ref rect)).width - 8f, 22f);
GUIStyle val4 = (flag2 ? (ShopStyle.PriceLabel ?? ShopStyle.TileLabel) : (ShopStyle.PriceLabelMissing ?? ShopStyle.TileLabel));
GUI.Label(val3, $"{entry.Price} coins", val4);
Color color2 = default(Color);
float thickness;
if (!flag2)
{
((Color)(ref color2))..ctor(0.55f, 0.6f, 0.55f, 1f);
thickness = 2f;
}
else if (flag && flag3)
{
color2 = ShopStyle.Yellow;
thickness = 3f;
}
else
{
color2 = ShopStyle.Blue;
thickness = 2f;
}
ShopStyle.DrawBorder(rect, thickness, color2);
GUI.enabled = flag3;
if (GUI.Button(rect, GUIContent.none, ShopStyle.Invisible))
{
TryPurchase(entry, character);
}
GUI.enabled = true;
}
private static void DrawFooter()
{
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
if (GUILayout.Button("REFRESH", ShopStyle.Button, (GUILayoutOption[])(object)new GUILayoutOption[2]
{
GUILayout.Width(140f),
GUILayout.Height(34f)
}))
{
RefreshCatalog();
}
GUILayout.FlexibleSpace();
if (GUILayout.Button("CLOSE", ShopStyle.Button, (GUILayoutOption[])(object)new GUILayoutOption[2]
{
GUILayout.Width(140f),
GUILayout.Height(34f)
}))
{
IsOpen = false;
}
GUILayout.EndHorizontal();
}
private static void RefreshCatalog()
{
try
{
ItemDatabase instance = SingletonAsset<ItemDatabase>.Instance;
if ((Object)(object)instance == (Object)null)
{
Plugin.Log.LogWarning((object)"ItemDatabase singleton is null.");
_cachedItems = new List<ItemEntry>();
return;
}
HashSet<string> seen = new HashSet<string>();
List<ItemEntry> list = new List<ItemEntry>();
if (((DatabaseAsset<ItemDatabase, Item>)(object)instance).Objects != null)
{
foreach (Item @object in ((DatabaseAsset<ItemDatabase, Item>)(object)instance).Objects)
{
Consider(@object);
}
}
if (instance.itemLookup != null)
{
foreach (KeyValuePair<ushort, Item> item in instance.itemLookup)
{
Consider(item.Value);
}
}
_cachedItems = list.OrderBy<ItemEntry, string>((ItemEntry e) => e.DisplayName, StringComparer.CurrentCultureIgnoreCase).ToList();
Plugin.Log.LogInfo((object)$"Shop catalog refreshed: {_cachedItems.Count} items.");
void Consider(Item? item)
{
if (!((Object)(object)item == (Object)null) && !((Object)(object)((Component)item).gameObject == (Object)null))
{
string name = ((Object)((Component)item).gameObject).name;
if (seen.Add(name))
{
string displayName = TryGetLocalizedName(item, name);
Texture2D icon = TryGetIcon(item);
int price = Prices.GetPrice(name, displayName);
list.Add(new ItemEntry(item, name, displayName, icon, price));
}
}
}
}
catch (Exception arg)
{
Plugin.Log.LogError((object)$"RefreshCatalog failed: {arg}");
_cachedItems = new List<ItemEntry>();
}
}
private static string TryGetLocalizedName(Item item, string fallback)
{
try
{
string name = item.GetName();
if (!string.IsNullOrWhiteSpace(name))
{
return name;
}
}
catch
{
}
return fallback;
}
private static Texture2D? TryGetIcon(Item item)
{
try
{
if (item.UIData == null)
{
return null;
}
Texture2D icon = item.UIData.GetIcon();
if ((Object)(object)icon == (Object)null)
{
icon = item.UIData.icon;
}
return icon;
}
catch
{
return null;
}
}
private static void TryPurchase(ItemEntry entry, Character character)
{
//IL_0046: 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_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
if (!EconomyManager.TrySpend(entry.Price))
{
Plugin.Log.LogInfo((object)$"Cannot afford '{entry.DisplayName}' (need {entry.Price}, have {EconomyManager.Coins}).");
return;
}
try
{
Transform transform = ((Component)character).transform;
Vector3 val = transform.position + transform.forward * 1f + Vector3.up * 0.8f;
GameObject val2 = PhotonNetwork.Instantiate("0_Items/" + entry.PrefabName, val, Quaternion.identity, (byte)0, (object[])null);
if ((Object)(object)val2 == (Object)null)
{
Plugin.Log.LogError((object)("Failed to spawn '" + entry.PrefabName + "' — refunding."));
EconomyManager.AddCoins(entry.Price, "refund");
return;
}
Item component = val2.GetComponent<Item>();
if ((Object)(object)component != (Object)null)
{
component.RequestPickup(((Component)character).GetComponent<PhotonView>());
}
Plugin.Log.LogInfo((object)$"Bought '{entry.DisplayName}' ({entry.PrefabName}) for {entry.Price}.");
}
catch (Exception arg)
{
Plugin.Log.LogError((object)$"Purchase '{entry.PrefabName}' failed: {arg} — refunding.");
EconomyManager.AddCoins(entry.Price, "refund");
}
}
}
}