using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Roulette_of_items")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Roulette_of_items")]
[assembly: AssemblyTitle("Roulette_of_items")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace PeakCaseMod;
[HarmonyPatch]
public static class CampfirePatch
{
private static readonly Dictionary<string, ushort> _nameToId = new Dictionary<string, ushort>(StringComparer.OrdinalIgnoreCase);
private static readonly Dictionary<string, Texture2D> _nameToIcon = new Dictionary<string, Texture2D>(StringComparer.OrdinalIgnoreCase);
private static bool _catalogBuilt = false;
private static object _gameUtilsInstance = null;
private static MethodInfo _instantiateAndGrabMethod = null;
private static bool _gameUtilsResolved = false;
public static bool IsCatalogBuilt => _catalogBuilt;
private static void BuildItemCatalog()
{
_nameToId.Clear();
_nameToIcon.Clear();
Item[] array = Resources.FindObjectsOfTypeAll<Item>();
HashSet<int> hashSet = new HashSet<int>();
Item[] array2 = array;
foreach (Item val in array2)
{
if ((Object)(object)val == (Object)null)
{
continue;
}
int instanceID = ((Object)val).GetInstanceID();
if (!hashSet.Add(instanceID))
{
continue;
}
List<string> list = new List<string>();
Texture2D val2 = null;
try
{
if (!string.IsNullOrEmpty(val.GetName()))
{
list.Add(val.GetName());
}
}
catch
{
}
try
{
if (val.UIData != null && !string.IsNullOrEmpty(val.UIData.itemName))
{
list.Add(val.UIData.itemName);
}
}
catch
{
}
try
{
if (!string.IsNullOrEmpty(((Object)((Component)val).gameObject).name))
{
list.Add(((Object)((Component)val).gameObject).name);
}
}
catch
{
}
try
{
if (val.UIData != null)
{
val2 = val.UIData.GetIcon();
}
}
catch
{
}
foreach (string item in list)
{
if (!_nameToId.ContainsKey(item))
{
_nameToId[item] = val.itemID;
if ((Object)(object)val2 != (Object)null && !_nameToIcon.ContainsKey(item))
{
_nameToIcon[item] = val2;
}
}
}
}
LootTable.LoadAllItemsFromCatalog(_nameToId, _nameToIcon);
}
private static bool ResolveGameUtils()
{
if (_gameUtilsResolved)
{
return _gameUtilsInstance != null && _instantiateAndGrabMethod != null;
}
_gameUtilsResolved = true;
try
{
Type type = AccessTools.TypeByName("GameUtils");
if (type == null)
{
CasePlugin.Logger.LogError((object)"[PEAK Case] GameUtils class not found!");
return false;
}
PropertyInfo propertyInfo = AccessTools.Property(type, "instance");
if (propertyInfo != null)
{
_gameUtilsInstance = propertyInfo.GetValue(null);
}
else
{
FieldInfo fieldInfo = AccessTools.Field(type, "instance");
if (fieldInfo != null)
{
_gameUtilsInstance = fieldInfo.GetValue(null);
}
}
if (_gameUtilsInstance == null)
{
CasePlugin.Logger.LogError((object)"[PEAK Case] GameUtils.instance is null!");
return false;
}
_instantiateAndGrabMethod = AccessTools.Method(type, "InstantiateAndGrab", new Type[3]
{
typeof(Item),
typeof(Character),
typeof(int)
}, (Type[])null);
if (_instantiateAndGrabMethod == null)
{
MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
foreach (MethodInfo methodInfo in methods)
{
if (methodInfo.Name == "InstantiateAndGrab")
{
_instantiateAndGrabMethod = methodInfo;
break;
}
}
}
if (_instantiateAndGrabMethod == null)
{
CasePlugin.Logger.LogError((object)"[PEAK Case] InstantiateAndGrab method not found!");
return false;
}
return true;
}
catch (Exception ex)
{
CasePlugin.Logger.LogError((object)("[PEAK Case] Failed to resolve GameUtils: " + ex.Message));
return false;
}
}
private static void GiveItemToPlayerWithSpawn(Player player, string itemName)
{
if (!_nameToId.TryGetValue(itemName, out var value))
{
CasePlugin.Logger.LogError((object)("Item '" + itemName + "' not found!"));
return;
}
Item val = default(Item);
if (!ItemDatabase.TryGetItem(value, ref val) || (Object)(object)val == (Object)null)
{
CasePlugin.Logger.LogError((object)$"Failed to find prefab for '{itemName}' (ID: {value})");
return;
}
if ((Object)(object)Character.localCharacter == (Object)null)
{
CasePlugin.Logger.LogError((object)"[PEAK Case] Character.localCharacter is null!");
return;
}
if (!ResolveGameUtils())
{
CasePlugin.Logger.LogError((object)"[PEAK Case] Cannot spawn item - GameUtils not available");
return;
}
try
{
_instantiateAndGrabMethod.Invoke(_gameUtilsInstance, new object[3]
{
val,
Character.localCharacter,
0
});
}
catch (Exception ex)
{
CasePlugin.Logger.LogError((object)("[PEAK Case] InstantiateAndGrab failed: " + ex.Message));
}
}
public static void BuildCatalogPublic()
{
BuildItemCatalog();
_catalogBuilt = true;
}
public static void GiveItemToPlayerWithSpawnPublic(Player player, string itemName)
{
GiveItemToPlayerWithSpawn(player, itemName);
}
}
[BepInPlugin("com.you.peakcase", "PEAK Case Roulette", "1.0.0")]
public class CasePlugin : BaseUnityPlugin
{
public static CasePlugin Instance;
internal static ManualLogSource Logger;
private Harmony _harmony;
private RouletteTimerHandler _timerHandler;
private void Awake()
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Expected O, but got Unknown
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Expected O, but got Unknown
Instance = this;
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)"[PEAK Case] Mod loaded successfully (Mono)!");
_harmony = new Harmony("com.you.peakcase");
_harmony.PatchAll();
LootTable.Initialize();
GameObject val = new GameObject("PeakCaseRouletteTimer");
Object.DontDestroyOnLoad((Object)(object)val);
_timerHandler = val.AddComponent<RouletteTimerHandler>();
Logger.LogInfo((object)"[PEAK Case] Key F10 for roulette (60s cooldown)");
}
private void OnDestroy()
{
Harmony harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
Logger.LogInfo((object)"[PEAK Case] Mod unloaded");
}
}
public class RouletteTimerHandler : MonoBehaviour
{
private float _lastRouletteTime = -999f;
private const float COOLDOWN_DURATION = 60f;
private const KeyCode ACTIVATION_KEY = (KeyCode)291;
private Font _peakFont = null;
private bool _fontLoaded = false;
private void Update()
{
if (!((Object)(object)Character.localCharacter == (Object)null) && !RouletteUI.Instance.IsActive && Input.GetKeyDown((KeyCode)291))
{
TryActivateRoulette();
}
}
private void LoadPeakFont()
{
if (_fontLoaded)
{
return;
}
_fontLoaded = true;
Font[] array = Resources.FindObjectsOfTypeAll<Font>();
Font[] array2 = array;
foreach (Font val in array2)
{
if (!((Object)(object)val == (Object)null) && ((Object)val).name.Contains("Binggrae"))
{
_peakFont = val;
break;
}
}
if ((Object)(object)_peakFont == (Object)null)
{
Font[] array3 = array;
foreach (Font val2 in array3)
{
if (!((Object)(object)val2 == (Object)null) && ((Object)val2).name.Contains("Pangolin"))
{
_peakFont = val2;
break;
}
}
}
if ((Object)(object)_peakFont == (Object)null && array.Length != 0)
{
_peakFont = array[0];
}
if ((Object)(object)_peakFont == (Object)null)
{
_peakFont = Font.CreateDynamicFontFromOSFont("Arial", 24);
}
}
private void TryActivateRoulette()
{
if (!_fontLoaded)
{
LoadPeakFont();
}
float num = Time.time - _lastRouletteTime;
if (num >= 60f)
{
_lastRouletteTime = Time.time;
TriggerRoulette();
}
else
{
float num2 = 60f - num;
CasePlugin.Logger.LogInfo((object)$"[Timer] Cooldown! {Mathf.CeilToInt(num2)}s remaining");
}
}
private void TriggerRoulette()
{
if ((Object)(object)Character.localCharacter == (Object)null)
{
return;
}
Player player = Character.localCharacter.player;
if (!((Object)(object)player == (Object)null))
{
if (!CampfirePatch.IsCatalogBuilt)
{
CampfirePatch.BuildCatalogPublic();
}
RouletteUI.Instance.ShowRoulette(delegate(LootItem wonItem)
{
CampfirePatch.GiveItemToPlayerWithSpawnPublic(player, wonItem.ItemName);
});
}
}
private void OnGUI()
{
if (!((Object)(object)Character.localCharacter == (Object)null) && !RouletteUI.Instance.IsActive)
{
if (!_fontLoaded)
{
LoadPeakFont();
}
DrawTimer();
}
}
private void DrawTimer()
{
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: 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)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Expected O, but got Unknown
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Expected O, but got Unknown
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
float num = Time.time - _lastRouletteTime;
float num2 = 60f - num;
Color textColor = default(Color);
string text;
if (num2 <= 0f)
{
((Color)(ref textColor))..ctor(0.2f, 1f, 0.2f, 1f);
text = "READY (F10)";
}
else
{
((Color)(ref textColor))..ctor(1f, 0.3f, 0.3f, 1f);
text = $"COOLDOWN: {Mathf.CeilToInt(num2)}s";
}
float num3 = 400f;
float num4 = 40f;
float num5 = ((float)Screen.width - num3) / 2f;
float num6 = 20f;
GUIStyle val = new GUIStyle(GUI.skin.label)
{
font = _peakFont,
fontSize = 24,
alignment = (TextAnchor)4,
fontStyle = (FontStyle)1
};
val.normal.textColor = textColor;
GUIStyle val2 = val;
GUIStyle val3 = new GUIStyle(val2);
val3.normal.textColor = new Color(0f, 0f, 0f, 0.7f);
GUIStyle val4 = val3;
GUI.Label(new Rect(num5 + 2f, num6 + 2f, num3, num4), text, val4);
GUI.Label(new Rect(num5, num6, num3, num4), text, val2);
}
}
public class LootItem
{
public string ItemName;
public float Weight;
public Texture2D Icon;
public LootItem(string name, float weight, Texture2D icon = null)
{
ItemName = name;
Weight = weight;
Icon = icon;
}
}
public static class LootTable
{
private static readonly List<LootItem> _allItems = new List<LootItem>();
private static readonly Random _random = new Random();
private static bool _initialized = false;
public static readonly Color ArrowColor = new Color(1f, 0.84f, 0f);
public static void Initialize()
{
if (!_initialized)
{
_initialized = true;
}
}
public static void LoadAllItemsFromCatalog(Dictionary<string, ushort> nameToId, Dictionary<string, Texture2D> nameToIcon)
{
_allItems.Clear();
HashSet<string> hashSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "King", "Queen", "Bishop", "Knight", "Rook", "Pawn" };
HashSet<string> hashSet2 = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "ClimbingChalk", "Climbing Chalk", "SCOUTMASTERSOUL", "LOC:NAME_CLIMBINGCHALK", "LOC: NAME_CLIMBING CHALK", "Torn Page" };
int num = 0;
int num2 = 0;
int num3 = 0;
int num4 = 0;
foreach (KeyValuePair<string, ushort> item in nameToId)
{
string key = item.Key;
if (key.Contains("(Clone)") || key.StartsWith("Item_"))
{
num4++;
continue;
}
if (ContainsCyrillic(key))
{
num2++;
continue;
}
if (key.StartsWith("C_"))
{
num3++;
continue;
}
if (hashSet.Contains(key))
{
num3++;
continue;
}
if (key.Contains("GuidebookPage"))
{
num3++;
continue;
}
if (hashSet2.Contains(key))
{
num3++;
continue;
}
Texture2D value = null;
nameToIcon.TryGetValue(key, out value);
AddItem(key, 1f, value);
num++;
}
CasePlugin.Logger.LogInfo((object)$"[LootTable] Loaded {num} items (skipped: {num2} cyrillic, {num3} excluded, {num4} duplicates)");
}
private static bool ContainsCyrillic(string text)
{
foreach (char c in text)
{
if (c >= 'Ѐ' && c <= 'ӿ')
{
return true;
}
}
return false;
}
private static void AddItem(string name, float weight, Texture2D icon = null)
{
_allItems.Add(new LootItem(name, weight, icon));
}
public static LootItem RollItem()
{
if (_allItems.Count == 0)
{
CasePlugin.Logger.LogError((object)"[LootTable] Item list is empty!");
return null;
}
float num = 0f;
foreach (LootItem allItem in _allItems)
{
num += allItem.Weight;
}
float num2 = (float)(_random.NextDouble() * (double)num);
float num3 = 0f;
foreach (LootItem allItem2 in _allItems)
{
num3 += allItem2.Weight;
if (num2 <= num3)
{
return allItem2;
}
}
return _allItems[0];
}
}
public class RouletteUI : MonoBehaviour
{
private static RouletteUI _instance;
private bool _isActive = false;
private Font _peakFont = null;
private bool _fontLoaded = false;
private readonly List<LootItem> _rouletteItems = new List<LootItem>();
private LootItem _wonItem;
private Action<LootItem> _onItemWon;
private float _phaseStartTime = -1f;
private float _showResultTime = -1f;
private float _closeStartTime = -1f;
private const float FADE_IN_DURATION = 0.4f;
private const float WAIT_DURATION = 1f;
private const float ROLL_DURATION = 3f;
private const float RESULT_DURATION = 3f;
private const float FADE_OUT_DURATION = 0.4f;
private float _scrollOffset = 0f;
private float _targetScrollOffset = 0f;
private float _uiAlpha = 0f;
private static readonly Color PEAK_BG_COLOR = new Color(0.05f, 0.08f, 0.12f, 0.95f);
private static readonly Color PEAK_BORDER_COLOR = new Color(0.3f, 0.5f, 0.7f, 1f);
private static readonly Color PEAK_ACCENT_COLOR = new Color(1f, 0.8f, 0.3f, 1f);
private static readonly Dictionary<string, Texture2D> _fallbackIcons = new Dictionary<string, Texture2D>();
private const float ITEM_WIDTH = 140f;
private const float ITEM_HEIGHT = 200f;
private const int VISIBLE_ITEMS = 5;
public bool IsActive => _isActive;
public static RouletteUI Instance
{
get
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
if ((Object)(object)_instance == (Object)null)
{
GameObject val = new GameObject("PeakCaseRouletteUI");
_instance = val.AddComponent<RouletteUI>();
Object.DontDestroyOnLoad((Object)(object)val);
}
return _instance;
}
}
private void LoadPeakFont()
{
if (_fontLoaded)
{
return;
}
_fontLoaded = true;
Font[] array = Resources.FindObjectsOfTypeAll<Font>();
Font[] array2 = array;
foreach (Font val in array2)
{
if (!((Object)(object)val == (Object)null) && ((Object)val).name.Contains("Binggrae"))
{
_peakFont = val;
break;
}
}
if ((Object)(object)_peakFont == (Object)null)
{
Font[] array3 = array;
foreach (Font val2 in array3)
{
if (!((Object)(object)val2 == (Object)null) && ((Object)val2).name.Contains("Pangolin"))
{
_peakFont = val2;
break;
}
}
}
if ((Object)(object)_peakFont == (Object)null && array.Length != 0)
{
_peakFont = array[0];
}
if ((Object)(object)_peakFont == (Object)null)
{
_peakFont = Font.CreateDynamicFontFromOSFont("Arial", 24);
}
}
public void ShowRoulette(Action<LootItem> onItemWon)
{
_onItemWon = onItemWon;
_isActive = true;
_wonItem = null;
_phaseStartTime = Time.time;
_showResultTime = -1f;
_closeStartTime = -1f;
_scrollOffset = 0f;
_uiAlpha = 0f;
_rouletteItems.Clear();
for (int i = 0; i < 20; i++)
{
_rouletteItems.Add(LootTable.RollItem());
}
_wonItem = LootTable.RollItem();
_rouletteItems.Add(_wonItem);
for (int j = 0; j < 10; j++)
{
_rouletteItems.Add(LootTable.RollItem());
}
int num = 20;
int num2 = num - 2;
_targetScrollOffset = (float)num2 * 140f;
}
private void OnGUI()
{
//IL_0199: 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_01df: Unknown result type (might be due to invalid IL or missing references)
//IL_021b: Unknown result type (might be due to invalid IL or missing references)
//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_023f: Unknown result type (might be due to invalid IL or missing references)
//IL_0244: Unknown result type (might be due to invalid IL or missing references)
//IL_0251: Unknown result type (might be due to invalid IL or missing references)
//IL_025a: Unknown result type (might be due to invalid IL or missing references)
//IL_0262: 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_0270: Unknown result type (might be due to invalid IL or missing references)
//IL_027d: Expected O, but got Unknown
//IL_028c: 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_02f4: Unknown result type (might be due to invalid IL or missing references)
//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0349: Unknown result type (might be due to invalid IL or missing references)
//IL_059e: Unknown result type (might be due to invalid IL or missing references)
//IL_05c1: Unknown result type (might be due to invalid IL or missing references)
//IL_05eb: Unknown result type (might be due to invalid IL or missing references)
//IL_0611: Unknown result type (might be due to invalid IL or missing references)
//IL_0636: Unknown result type (might be due to invalid IL or missing references)
//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0412: Unknown result type (might be due to invalid IL or missing references)
//IL_0478: Unknown result type (might be due to invalid IL or missing references)
//IL_047d: Unknown result type (might be due to invalid IL or missing references)
//IL_048a: Unknown result type (might be due to invalid IL or missing references)
//IL_0493: Unknown result type (might be due to invalid IL or missing references)
//IL_049b: Unknown result type (might be due to invalid IL or missing references)
//IL_04a3: Unknown result type (might be due to invalid IL or missing references)
//IL_04ab: Unknown result type (might be due to invalid IL or missing references)
//IL_04b1: Unknown result type (might be due to invalid IL or missing references)
//IL_04be: Expected O, but got Unknown
//IL_04d5: Unknown result type (might be due to invalid IL or missing references)
//IL_0460: Unknown result type (might be due to invalid IL or missing references)
//IL_06d6: Unknown result type (might be due to invalid IL or missing references)
//IL_06db: Unknown result type (might be due to invalid IL or missing references)
//IL_06e8: Unknown result type (might be due to invalid IL or missing references)
//IL_06f1: Unknown result type (might be due to invalid IL or missing references)
//IL_06f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0701: Unknown result type (might be due to invalid IL or missing references)
//IL_0709: Unknown result type (might be due to invalid IL or missing references)
//IL_070f: Unknown result type (might be due to invalid IL or missing references)
//IL_071c: Expected O, but got Unknown
//IL_0735: Unknown result type (might be due to invalid IL or missing references)
//IL_06be: Unknown result type (might be due to invalid IL or missing references)
//IL_0781: Unknown result type (might be due to invalid IL or missing references)
//IL_0786: Unknown result type (might be due to invalid IL or missing references)
//IL_0793: Unknown result type (might be due to invalid IL or missing references)
//IL_079c: Unknown result type (might be due to invalid IL or missing references)
//IL_07a4: Unknown result type (might be due to invalid IL or missing references)
//IL_07aa: Unknown result type (might be due to invalid IL or missing references)
//IL_07b7: Expected O, but got Unknown
//IL_07c6: Unknown result type (might be due to invalid IL or missing references)
if (!_isActive)
{
return;
}
if (!_fontLoaded)
{
LoadPeakFont();
}
float num = Time.time - _phaseStartTime;
if (num < 0.4f)
{
_uiAlpha = Mathf.Clamp01(num / 0.4f);
}
else if (num < 1.4f)
{
_uiAlpha = 1f;
}
else if (num < 4.4f)
{
_uiAlpha = 1f;
}
else if (_showResultTime < 0f)
{
_showResultTime = Time.time;
_uiAlpha = 1f;
}
else
{
float num2 = Time.time - _showResultTime;
if (num2 < 3f)
{
_uiAlpha = 1f;
}
else if (_closeStartTime < 0f)
{
_closeStartTime = Time.time;
}
else
{
float num3 = Time.time - _closeStartTime;
_uiAlpha = 1f - Mathf.Clamp01(num3 / 0.4f);
if (_uiAlpha <= 0f)
{
_onItemWon?.Invoke(_wonItem);
CloseRoulette();
return;
}
}
}
GUI.color = new Color(0f, 0f, 0f, 0.4f * _uiAlpha);
GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)Texture2D.whiteTexture);
GUI.color = new Color(1f, 1f, 1f, _uiAlpha);
float num4 = 800f;
float num5 = 500f;
float num6 = ((float)Screen.width - num4) / 2f;
float num7 = ((float)Screen.height - num5) / 2f;
DrawStyledBox(new Rect(num6, num7, num4, num5), PEAK_BG_COLOR, PEAK_BORDER_COLOR, 3f);
GUIStyle val = new GUIStyle(GUI.skin.label)
{
font = _peakFont,
fontSize = 42,
alignment = (TextAnchor)4,
fontStyle = (FontStyle)1
};
val.normal.textColor = PEAK_ACCENT_COLOR;
GUIStyle val2 = val;
GUI.Label(new Rect(num6, num7 + 15f, num4, 60f), "ITEM ROULETTE", val2);
float num8 = num7 + 90f;
float num9 = 700f;
float num10 = num6 + (num4 - num9) / 2f;
DrawStyledBox(new Rect(num10 - 10f, num8 - 10f, num9 + 20f, 220f), new Color(0.1f, 0.15f, 0.2f, 0.8f), PEAK_BORDER_COLOR, 2f);
float num11 = _phaseStartTime + 0.4f + 1f;
float num12 = Time.time - num11;
bool flag = num12 > 0f && num12 < 3f;
GUI.BeginGroup(new Rect(num10, num8, num9, 200f));
float num13 = 0f - _scrollOffset % 140f;
int num14 = Mathf.FloorToInt(_scrollOffset / 140f);
for (int i = -1; i < 6; i++)
{
int num15 = num14 + i;
if (num15 >= 0 && num15 < _rouletteItems.Count)
{
LootItem lootItem = _rouletteItems[num15];
float num16 = num13 + (float)i * 140f;
DrawStyledBox(new Rect(num16 + 5f, 5f, 130f, 190f), new Color(0.15f, 0.2f, 0.25f, 0.9f), new Color(0.5f, 0.5f, 0.5f, 0.8f), 2f);
Texture2D itemIcon = GetItemIcon(lootItem);
if ((Object)(object)itemIcon != (Object)null)
{
float num17 = 80f;
float num18 = num16 + (140f - num17) / 2f;
GUI.DrawTexture(new Rect(num18, 30f, num17, num17), (Texture)(object)itemIcon);
}
GUIStyle val3 = new GUIStyle(GUI.skin.label)
{
font = _peakFont,
fontSize = 11,
alignment = (TextAnchor)4,
wordWrap = true,
fontStyle = (FontStyle)1
};
val3.normal.textColor = Color.white;
GUIStyle val4 = val3;
GUI.Label(new Rect(num16 + 5f, 130f, 130f, 60f), lootItem.ItemName, val4);
}
}
if (flag)
{
float num19 = num12 / 3f;
float num20 = (1f - Mathf.Cos(num19 * MathF.PI)) / 2f;
_scrollOffset = Mathf.Lerp(_scrollOffset, _targetScrollOffset * num20, Time.deltaTime * 8f);
}
GUI.EndGroup();
float num21 = num10 + num9 / 2f;
float num22 = 4f;
float num23 = 20f;
Color color = default(Color);
((Color)(ref color))..ctor(LootTable.ArrowColor.r, LootTable.ArrowColor.g, LootTable.ArrowColor.b, _uiAlpha);
GUI.color = color;
DrawTriangle(new Rect(num21 - 10f, num8 - num23 - 5f, 20f, num23), pointingDown: true);
DrawTriangle(new Rect(num21 - 10f, num8 + 200f + 5f, 20f, num23), pointingDown: false);
GUI.DrawTexture(new Rect(num21 - num22 / 2f, num8 - 5f, num22, 210f), (Texture)(object)Texture2D.whiteTexture);
GUI.color = new Color(1f, 1f, 1f, _uiAlpha);
if (_wonItem != null && _showResultTime >= 0f)
{
float num24 = Time.time - _showResultTime;
Texture2D itemIcon2 = GetItemIcon(_wonItem);
if ((Object)(object)itemIcon2 != (Object)null)
{
float num25 = 100f;
float num26 = num6 + (num4 - num25) / 2f;
float num27 = num8 + 200f + 40f;
GUI.DrawTexture(new Rect(num26, num27, num25, num25), (Texture)(object)itemIcon2);
}
GUIStyle val5 = new GUIStyle(GUI.skin.label)
{
font = _peakFont,
fontSize = 28,
alignment = (TextAnchor)4,
fontStyle = (FontStyle)1,
wordWrap = true
};
val5.normal.textColor = PEAK_ACCENT_COLOR;
GUIStyle val6 = val5;
float num28 = num8 + 200f + 150f;
GUI.Label(new Rect(num6, num28, num4, 40f), _wonItem.ItemName, val6);
float num29 = 3f - num24;
if (num29 > 0f && _closeStartTime < 0f)
{
GUIStyle val7 = new GUIStyle(GUI.skin.label)
{
font = _peakFont,
fontSize = 14,
alignment = (TextAnchor)4
};
val7.normal.textColor = Color.white;
GUIStyle val8 = val7;
GUI.Label(new Rect(num6, num28 + 60f, num4, 25f), $"Closes in {Mathf.CeilToInt(num29)} sec...", val8);
}
}
}
private void DrawTriangle(Rect rect, bool pointingDown)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: 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)
int num = (int)((Rect)(ref rect)).width;
Texture2D val = new Texture2D(num, num);
for (int i = 0; i < num; i++)
{
for (int j = 0; j < num; j++)
{
float num2 = (float)i / (float)num;
float num3 = (float)j / (float)num;
bool flag = false;
flag = ((!pointingDown) ? (num2 <= num3 && num2 <= 1f - num3) : (num2 >= 1f - num3 && num2 >= num3));
val.SetPixel(j, i, (Color)(flag ? Color.white : new Color(0f, 0f, 0f, 0f)));
}
}
val.Apply();
GUI.DrawTexture(rect, (Texture)(object)val);
}
private Texture2D GetItemIcon(LootItem item)
{
if ((Object)(object)item.Icon != (Object)null)
{
return item.Icon;
}
if (!_fallbackIcons.ContainsKey(item.ItemName))
{
_fallbackIcons[item.ItemName] = CreateFallbackIcon(item.ItemName);
}
return _fallbackIcons[item.ItemName];
}
private Texture2D CreateFallbackIcon(string itemName)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Expected O, but got Unknown
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: 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_0063: 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)
int num = 128;
Texture2D val = new Texture2D(num, num);
Color val2 = default(Color);
((Color)(ref val2))..ctor(0.4f, 0.4f, 0.4f);
for (int i = 0; i < num; i++)
{
for (int j = 0; j < num; j++)
{
float num2 = Vector2.Distance(new Vector2((float)j, (float)i), new Vector2((float)num / 2f, (float)num / 2f)) / ((float)num / 2f);
val.SetPixel(j, i, Color.Lerp(val2, Color.black, num2 * 0.5f));
}
}
val.Apply();
return val;
}
private void CloseRoulette()
{
_isActive = false;
_wonItem = null;
_phaseStartTime = -1f;
_showResultTime = -1f;
_closeStartTime = -1f;
_fallbackIcons.Clear();
}
private void DrawStyledBox(Rect rect, Color bgColor, Color borderColor, float borderWidth)
{
//IL_0001: 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)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: 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_004c: 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_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_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: 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_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
GUI.color = new Color(bgColor.r, bgColor.g, bgColor.b, bgColor.a * _uiAlpha);
GUI.DrawTexture(rect, (Texture)(object)Texture2D.whiteTexture);
GUI.color = new Color(1f, 1f, 1f, _uiAlpha);
GUI.color = new Color(borderColor.r, borderColor.g, borderColor.b, borderColor.a * _uiAlpha);
GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width, borderWidth), (Texture)(object)Texture2D.whiteTexture);
GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y + ((Rect)(ref rect)).height - borderWidth, ((Rect)(ref rect)).width, borderWidth), (Texture)(object)Texture2D.whiteTexture);
GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, borderWidth, ((Rect)(ref rect)).height), (Texture)(object)Texture2D.whiteTexture);
GUI.DrawTexture(new Rect(((Rect)(ref rect)).x + ((Rect)(ref rect)).width - borderWidth, ((Rect)(ref rect)).y, borderWidth, ((Rect)(ref rect)).height), (Texture)(object)Texture2D.whiteTexture);
GUI.color = new Color(1f, 1f, 1f, _uiAlpha);
}
}