Decompiled source of REPOConomy v1.0.4

plugins/REPOConomy.dll

Decompiled 5 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("REPOConomy")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("REPOConomy")]
[assembly: AssemblyTitle("REPOConomy")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace REPOConomyMod
{
	public class EconomyController : MonoBehaviour
	{
		public static EconomyController Instance;

		public static bool UIShownOnce;

		private bool economyResetPending = true;

		private bool showGUI;

		private float displayTimer = 6f;

		private string lastSceneType = "";

		private void Awake()
		{
			Instance = this;
		}

		private void Update()
		{
			if (Input.GetKeyDown((KeyCode)103))
			{
				showGUI = !showGUI;
				displayTimer = 6f;
			}
			string currentSceneType = GetCurrentSceneType();
			if (currentSceneType != lastSceneType)
			{
				lastSceneType = currentSceneType;
				if ((currentSceneType == "Level" || currentSceneType == "Lobby") ? true : false)
				{
					economyResetPending = true;
					UIShownOnce = false;
					showGUI = false;
				}
			}
			bool flag = economyResetPending;
			if (flag)
			{
				bool flag2 = ((currentSceneType == "Level" || currentSceneType == "Lobby") ? true : false);
				flag = flag2;
			}
			if (flag)
			{
				REPOConomyPlugin.ResetEconomy();
				economyResetPending = false;
			}
			if (showGUI && REPOConomyPlugin.HasEconomy && currentSceneType == "Level")
			{
				displayTimer -= Time.deltaTime;
				if (displayTimer <= 0f)
				{
					showGUI = false;
				}
			}
		}

		private string GetCurrentSceneType()
		{
			if (SemiFunc.RunIsLevel())
			{
				return "Level";
			}
			if (SemiFunc.RunIsLobby())
			{
				return "Lobby";
			}
			return "Other";
		}

		public void ResetGUI()
		{
			showGUI = true;
			displayTimer = 6f;
		}

		public void ShowGUI()
		{
			showGUI = true;
			displayTimer = 6f;
		}

		private float ClampToStep(float value, float step = 0.1f)
		{
			return Mathf.Round(value / step) * step;
		}

		private void OnGUI()
		{
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: 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_018f: Expected O, but got Unknown
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Expected O, but got Unknown
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Expected O, but got Unknown
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Expected O, but got Unknown
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Expected O, but got Unknown
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			if (showGUI && REPOConomyPlugin.HasEconomy && SemiFunc.RunIsLevel())
			{
				int currentLevel = REPOConomyPlugin.GetCurrentLevel();
				float num3;
				float num4;
				if (PhotonNetwork.IsMasterClient)
				{
					float num = ClampToStep(REPOConfig.LevelScaleMin.Value);
					float num2 = ClampToStep(REPOConfig.LevelScaleMax.Value);
					num3 = (float)(currentLevel - 1) * num;
					num4 = (float)(currentLevel - 1) * num2;
				}
				else
				{
					num3 = REPOConomyPlugin.ClientDeltaMin;
					num4 = REPOConomyPlugin.ClientDeltaMax;
				}
				string text = (PhotonNetwork.IsMasterClient ? REPOConomyPlugin.GetEconomyName() : REPOConomyPlugin.CurrentEconomyName);
				string text2 = REPOConomyPlugin.MinPercent.ToString("+#0.##;-#0.##;0");
				string text3 = REPOConomyPlugin.MaxPercent.ToString("+#0.##;-#0.##;0");
				string text4 = "Economy: " + text;
				string text5 = "Range: " + text2 + "% - " + text3 + "%";
				string text6 = (Mathf.Approximately(num3, num4) ? $"Level: {currentLevel} ({num3:+0.##;-0.##;0}%)" : $"Level: {currentLevel} ({num3:+0.##;-0.##;0}% {num4:+0.##;-0.##;0}%)");
				string text7 = (PhotonNetwork.IsMasterClient ? REPOConomyPlugin.GetEconomyFlavor() : REPOConomyPlugin.CurrentEconomyFlavor);
				float num5 = (float)Screen.width / 2f;
				float num6 = (float)Screen.height * 0.15f;
				GUIStyle val = new GUIStyle(GUI.skin.label)
				{
					fontSize = 26,
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)1,
					richText = true,
					wordWrap = true
				};
				val.normal.textColor = REPOConomyPlugin.GetEconomyColor();
				float num7 = Mathf.Clamp(Mathf.Max(new float[4]
				{
					val.CalcSize(new GUIContent(text4)).x,
					val.CalcSize(new GUIContent(text5)).x,
					val.CalcSize(new GUIContent(text6)).x,
					val.CalcSize(new GUIContent(text7)).x
				}) + 40f, 400f, (float)Screen.width * 0.9f);
				DropShadowLabel(new Rect(num5 - num7 / 2f, num6, num7, 40f), text4, val);
				DropShadowLabel(new Rect(num5 - num7 / 2f, num6 + 30f, num7, 35f), text5, val);
				DropShadowLabel(new Rect(num5 - num7 / 2f, num6 + 60f, num7, 35f), text6, val);
				DropShadowLabel(new Rect(num5 - num7 / 2f, num6 + 90f, num7, 50f), text7, val);
			}
		}

		private void DropShadowLabel(Rect position, string content, GUIStyle style)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: 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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			Color textColor = style.normal.textColor;
			style.normal.textColor = Color.black;
			GUI.Label(new Rect(((Rect)(ref position)).x + 2f, ((Rect)(ref position)).y + 2f, ((Rect)(ref position)).width, ((Rect)(ref position)).height), content, style);
			style.normal.textColor = textColor;
			GUI.Label(position, content, style);
		}
	}
	public static class REPOConfig
	{
		public static ConfigEntry<float> DefaultBaseMin;

		public static ConfigEntry<float> DefaultBaseMax;

		public static ConfigEntry<float> LevelScaleMin;

		public static ConfigEntry<float> LevelScaleMax;

		public static ConfigEntry<float> MinClampLimit;

		public static ConfigEntry<float> MaxClampLimit;

		public static ConfigEntry<bool> ForceStableEconomy;

		public static ConfigEntry<int> EventStartLevel;

		public static ConfigEntry<bool> UseEventChance;

		public static ConfigEntry<int> EventChance;

		public static ConfigEntry<bool> ShowTotalMapValue;

		public static ConfigEntry<bool> UseSeparateModifiers;

		public static void Init(ConfigFile config)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Expected O, but got Unknown
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Expected O, but got Unknown
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Expected O, but got Unknown
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Expected O, but got Unknown
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Expected O, but got Unknown
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Expected O, but got Unknown
			DefaultBaseMin = config.Bind<float>("Economy", "DefaultBaseMin", 5f, new ConfigDescription("Base minimum (-%) value without modifiers.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 500f), Array.Empty<object>()));
			DefaultBaseMax = config.Bind<float>("Economy", "DefaultBaseMax", 10f, new ConfigDescription("Base maximum (+%) value without modifiers.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 500f), Array.Empty<object>()));
			UseSeparateModifiers = config.Bind<bool>("Economy", "UseTwoStepPercentRoll", false, "Use separate positive and negative percent rolls. Result = (base - rollMin) + rollMax.");
			LevelScaleMin = config.Bind<float>("LevelScale", "LevelScaleMin", 0.5f, new ConfigDescription("How much to add to the minimum (-%) for each level.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 500f), Array.Empty<object>()));
			LevelScaleMax = config.Bind<float>("LevelScale", "LevelScaleMax", 0.5f, new ConfigDescription("How much to add to the maximum (+%) for each level.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 500f), Array.Empty<object>()));
			MinClampLimit = config.Bind<float>("Limit", "ClampMinLimit", 100f, new ConfigDescription("Maximum reduction limit (for example: -100%).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 500f), Array.Empty<object>()));
			MaxClampLimit = config.Bind<float>("Limit", "ClampMaxLimit", 1000f, new ConfigDescription("Maximum increase limit (for example: +1000%).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10000f), Array.Empty<object>()));
			EventStartLevel = config.Bind<int>("Events", "EventsStartLevel", 2, new ConfigDescription("At what level will events start (1–12). 1 = immediately, 2 = from the second level, etc.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 12), Array.Empty<object>()));
			ForceStableEconomy = config.Bind<bool>("Events", "NoEvents", false, "Force enable a stable economy (without events).");
			UseEventChance = config.Bind<bool>("EventsChance", "UseEventsChance", true, "Enable the event drop system based on chance.");
			EventChance = config.Bind<int>("EventsChance", "EventChance", 50, new ConfigDescription("Chance (1–100) for an event to occur instead of a stable economy.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), Array.Empty<object>()));
			ShowTotalMapValue = config.Bind<bool>("Debug", "ShowTotalMapValue", false, "Show total value of all valuables on the map in logs.");
		}
	}
	public class REPOConomyNetworkHandler : MonoBehaviour
	{
		private const byte ECONOMY_SYNC_EVENT = 179;

		private void Start()
		{
			PhotonNetwork.NetworkingClient.EventReceived += OnEvent;
		}

		private void OnDestroy()
		{
			PhotonNetwork.NetworkingClient.EventReceived -= OnEvent;
		}

		private void OnEvent(EventData evt)
		{
			if (evt.Code != 179)
			{
				return;
			}
			try
			{
				object[] array = (object[])evt.CustomData;
				if (array.Length < 7)
				{
					REPOConomyPlugin.Logger.LogWarning((object)"[REPOConomy] Invalid economy event data.");
					return;
				}
				REPOConomyPlugin.CurrentEconomy = (REPOConomyPlugin.EconomyType)(int)array[0];
				REPOConomyPlugin.CurrentEconomyName = (string)array[1];
				REPOConomyPlugin.CurrentEconomyFlavor = (string)array[2];
				REPOConomyPlugin.MinPercent = (float)array[3];
				REPOConomyPlugin.MaxPercent = (float)array[4];
				REPOConomyPlugin.ClientDeltaMin = (float)array[5];
				REPOConomyPlugin.ClientDeltaMax = (float)array[6];
				REPOConomyPlugin.HasEconomy = true;
			}
			catch (Exception arg)
			{
				REPOConomyPlugin.Logger.LogError((object)$"[REPOConomy] Handler.OnEvent: {arg}");
			}
		}
	}
	[BepInPlugin("PxntxrezStudio.REPOConomy", "REPOConomy", "1.0.4")]
	public class REPOConomyPlugin : BaseUnityPlugin
	{
		public enum EconomyType
		{
			Stable,
			Deflation,
			Inflation,
			Chaos,
			FreezeMarket,
			BlackMarketSurge,
			Overload,
			RareBoom,
			CommonCrash,
			LegendaryOnlyMatters,
			EchoMarket,
			ReverseInflation,
			LuxuryHunt,
			DumpsterDive,
			ExtraProfit,
			ScamSeason,
			SuddenDrop,
			TreasureRush,
			ZeroGravity,
			Turbulence,
			BubbleBurst,
			CollectorsFrenzy,
			PanicSale,
			EconomicTwister,
			TaxAudit,
			CrashAndBurn,
			GoldenHour,
			CrystalBubble,
			CoinDecay,
			EchoCrash
		}

		[HarmonyPatch(typeof(TruckScreenText), "ArrowPointAtGoalLogic")]
		public static class EconomyUITriggerPatch
		{
			[HarmonyPostfix]
			public static void ShowEconomyUI()
			{
				if (!EconomyController.UIShownOnce && SemiFunc.RunIsLevel() && (Object)(object)EconomyController.Instance != (Object)null && HasEconomy)
				{
					EconomyController.Instance.ShowGUI();
					EconomyController.UIShownOnce = true;
					LogTotalMapValue();
				}
			}
		}

		[HarmonyPatch(typeof(TruckScreenText), "Start")]
		public static class TruckTextStartReset
		{
			[HarmonyPrefix]
			public static void ResetFlag()
			{
				EconomyController.UIShownOnce = false;
				EconomyInitialized = false;
			}
		}

		[HarmonyPatch(typeof(ValuableObject), "DollarValueSetLogic")]
		public class ValuablePatch
		{
			[HarmonyPostfix]
			public static void ApplyRandomValue(ValuableObject __instance)
			{
				if ((Object)(object)__instance == (Object)null || SemiFunc.RunIsLobby() || SemiFunc.RunIsShop() || SemiFunc.RunIsArena())
				{
					return;
				}
				if (!HasEconomy)
				{
					if (!pendingValuables.Contains(__instance))
					{
						pendingValuables.Add(__instance);
					}
					return;
				}
				if ((Object)(object)AssetManager.instance == (Object)null || (Object)(object)AssetManager.instance.surplusValuableSmall == (Object)null || (Object)(object)AssetManager.instance.surplusValuableMedium == (Object)null || (Object)(object)AssetManager.instance.surplusValuableBig == (Object)null)
				{
					Logger.LogWarning((object)"[REPOConomy] AssetManager or its values are missing, skipping…");
					return;
				}
				if (((Object)((Component)__instance).gameObject).name.Contains(((Object)AssetManager.instance.surplusValuableSmall).name) || ((Object)((Component)__instance).gameObject).name.Contains(((Object)AssetManager.instance.surplusValuableMedium).name) || ((Object)((Component)__instance).gameObject).name.Contains(((Object)AssetManager.instance.surplusValuableBig).name))
				{
					Logger.LogInfo((object)("[REPOConomy] Skipped (Surplus): " + ((Object)((Component)__instance).gameObject).name));
					return;
				}
				if (CurrentEconomy == EconomyType.EconomicTwister)
				{
					float num = Random.Range(0f, 2f);
					float num2 = Mathf.Round(__instance.dollarValueOriginal * num);
					Logger.LogInfo((object)$"[REPOConomy] [Twister] {((Object)((Component)__instance).gameObject).name} | {__instance.dollarValueOriginal} → {num2} ({num * 100f:0.##}%)");
					__instance.dollarValueCurrent = num2;
					return;
				}
				float dollarValueOriginal = __instance.dollarValueOriginal;
				float num6;
				if (REPOConfig.UseSeparateModifiers.Value)
				{
					float num3 = ((MinPercent < 0f) ? Random.Range(0f, Mathf.Abs(MinPercent)) : 0f);
					float num4 = ((MaxPercent > 0f) ? Random.Range(0f, MaxPercent) : 0f);
					float num5 = 0f - num3 + num4;
					num6 = Mathf.Round(dollarValueOriginal * (1f + num5 / 100f));
					Logger.LogInfo((object)string.Format("[REPOConomy] {0} | {1}{2}{3} = {4:+0.##;-0.##}% | {5} → {6} |", ((Object)((Component)__instance).gameObject).name, (num3 > 0f) ? ("-" + num3.ToString("0.##") + "%") : "", (num3 > 0f && num4 > 0f) ? " + " : "", (num4 > 0f) ? ("+" + num4.ToString("0.##") + "%") : "", num5, dollarValueOriginal, num6));
				}
				else
				{
					float num5 = Random.Range(MinPercent, MaxPercent);
					num6 = Mathf.Round(dollarValueOriginal * (1f + num5 / 100f));
					Logger.LogInfo((object)$"[REPOConomy] {((Object)((Component)__instance).gameObject).name} | {dollarValueOriginal} → {num6} ({num5:+0.##;-0.##}%)");
				}
				__instance.dollarValueCurrent = num6;
			}
		}

		internal static ManualLogSource Logger;

		private static readonly List<ValuableObject> pendingValuables = new List<ValuableObject>();

		public static string CurrentEconomyName = "Stability";

		public static string CurrentEconomyFlavor = "Economy by default";

		public static bool HasEconomy { get; set; } = false;


		public static EconomyType CurrentEconomy { get; set; }

		public static float MinPercent { get; set; }

		public static float MaxPercent { get; set; }

		public static bool EconomyInitialized { get; private set; } = false;


		public static float ClientDeltaMin { get; set; }

		public static float ClientDeltaMax { get; set; }

		private void Awake()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			Logger = ((BaseUnityPlugin)this).Logger;
			new Harmony("PxntxrezStudio.REPOConomy").PatchAll();
			REPOConfig.Init(((BaseUnityPlugin)this).Config);
			SceneManager.sceneLoaded += OnSceneLoaded;
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: 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_0044: Expected O, but got Unknown
			if (!SemiFunc.RunIsLobby() && !SemiFunc.RunIsShop() && !SemiFunc.RunIsArena())
			{
				if ((Object)(object)EconomyController.Instance == (Object)null)
				{
					GameObject val = new GameObject("EconomyUI");
					EconomyController.Instance = val.AddComponent<EconomyController>();
					val.AddComponent<REPOConomyNetworkHandler>();
					Object.DontDestroyOnLoad((Object)val);
				}
				if (SemiFunc.RunIsLevel())
				{
					InitializeEconomy();
				}
			}
		}

		public static void InitializeEconomy()
		{
			//IL_0561: Unknown result type (might be due to invalid IL or missing references)
			//IL_0566: Unknown result type (might be due to invalid IL or missing references)
			//IL_0568: Unknown result type (might be due to invalid IL or missing references)
			//IL_056f: Expected O, but got Unknown
			//IL_0578: Unknown result type (might be due to invalid IL or missing references)
			if (EconomyInitialized)
			{
				Logger.LogInfo((object)"[Economy] Already initialized. Skipping.");
				return;
			}
			if (SemiFunc.RunIsLobby() || SemiFunc.RunIsShop() || SemiFunc.RunIsArena())
			{
				Logger.LogInfo((object)"[Economy] Initialization canceled: Lobby, store, or arena.");
				return;
			}
			if (!PhotonNetwork.IsMasterClient)
			{
				Logger.LogInfo((object)"[Economy] Initialization skipped: not the MasterClient.");
				return;
			}
			EconomyInitialized = true;
			int currentLevel = GetCurrentLevel();
			float num = (float)(currentLevel - 1) * REPOConfig.LevelScaleMin.Value;
			float num2 = (float)(currentLevel - 1) * REPOConfig.LevelScaleMax.Value;
			ClientDeltaMin = num;
			ClientDeltaMax = num2;
			float num3 = num;
			float num4 = num2;
			float num5 = 0f - REPOConfig.DefaultBaseMin.Value - num3;
			float num6 = REPOConfig.DefaultBaseMax.Value + num4;
			bool value = REPOConfig.ForceStableEconomy.Value;
			bool flag = currentLevel >= REPOConfig.EventStartLevel.Value;
			bool flag2 = !REPOConfig.UseEventChance.Value || Random.Range(1, 101) <= REPOConfig.EventChance.Value;
			if (value || !flag || !flag2)
			{
				CurrentEconomy = EconomyType.Stable;
			}
			else
			{
				int num7 = Enum.GetNames(typeof(EconomyType)).Length;
				CurrentEconomy = (EconomyType)Random.Range(1, num7);
			}
			switch (CurrentEconomy)
			{
			case EconomyType.FreezeMarket:
				num5 = 0f;
				num6 = 0f;
				break;
			case EconomyType.Deflation:
				num5 -= 10f;
				num6 -= 5f;
				break;
			case EconomyType.Inflation:
				num5 += 0f;
				num6 += 10f;
				break;
			case EconomyType.Chaos:
				num5 -= 10f;
				num6 += 10f;
				break;
			case EconomyType.BlackMarketSurge:
				num5 -= 10f;
				num6 += 20f;
				break;
			case EconomyType.Overload:
				num5 = -100f;
				num6 += 100f;
				break;
			case EconomyType.RareBoom:
				num5 += 5f;
				num6 += 30f;
				break;
			case EconomyType.CommonCrash:
				num5 -= 30f;
				num6 -= 10f;
				break;
			case EconomyType.LegendaryOnlyMatters:
				num5 = -20f;
				num6 = 5f;
				break;
			case EconomyType.EchoMarket:
				num5 += Random.Range(-25f, 0f);
				num6 += Random.Range(0f, 25f);
				break;
			case EconomyType.ReverseInflation:
				num5 -= 15f;
				num6 -= 5f;
				break;
			case EconomyType.LuxuryHunt:
				num5 += 10f;
				num6 += 40f;
				break;
			case EconomyType.DumpsterDive:
				num5 += 5f;
				num6 += 60f;
				break;
			case EconomyType.ExtraProfit:
				num6 += 50f;
				break;
			case EconomyType.ScamSeason:
				num5 -= 30f;
				num6 -= 10f;
				break;
			case EconomyType.SuddenDrop:
				num5 = -50f;
				num6 = -20f;
				break;
			case EconomyType.TreasureRush:
				num5 += 100f;
				num6 += 200f;
				break;
			case EconomyType.ZeroGravity:
				num5 = -50f;
				num6 = 150f;
				break;
			case EconomyType.Turbulence:
			{
				float num9 = Random.Range(-30f, 30f);
				num5 += num9;
				num6 += num9;
				break;
			}
			case EconomyType.BubbleBurst:
				num5 -= 40f;
				num6 -= 5f;
				break;
			case EconomyType.CollectorsFrenzy:
				num5 += 30f;
				num6 += 80f;
				break;
			case EconomyType.PanicSale:
				num5 = -40f;
				num6 = -20f;
				break;
			case EconomyType.EconomicTwister:
				num5 = 0f;
				num6 = 0f;
				break;
			case EconomyType.TaxAudit:
				num5 = -15f;
				num6 = -15f;
				break;
			case EconomyType.CrashAndBurn:
				num5 = -90f;
				num6 = 0f;
				break;
			case EconomyType.GoldenHour:
				num5 += 20f;
				num6 += 50f;
				break;
			case EconomyType.CrystalBubble:
				num5 += 50f;
				num6 += 100f;
				break;
			case EconomyType.CoinDecay:
				num5 -= 20f;
				num6 -= 60f;
				break;
			case EconomyType.EchoCrash:
			{
				float num8 = Random.Range(-50f, 50f);
				num5 += num8;
				num6 += num8;
				break;
			}
			}
			num5 = Mathf.Clamp(num5, 0f - REPOConfig.MinClampLimit.Value, REPOConfig.MaxClampLimit.Value);
			num6 = Mathf.Clamp(num6, 0f - REPOConfig.MinClampLimit.Value, REPOConfig.MaxClampLimit.Value);
			MinPercent = num5;
			MaxPercent = num6;
			HasEconomy = true;
			Logger.LogInfo((object)$"[Economy] Level: {currentLevel}, Economy: {CurrentEconomy}, Range: {MinPercent}% - {MaxPercent}%");
			CurrentEconomyName = GetEconomyName();
			CurrentEconomyFlavor = GetEconomyFlavor();
			if (PhotonNetwork.IsMasterClient)
			{
				object[] array = new object[7]
				{
					(int)CurrentEconomy,
					GetEconomyName(),
					GetEconomyFlavor(),
					MinPercent,
					MaxPercent,
					num,
					num2
				};
				RaiseEventOptions val = new RaiseEventOptions
				{
					Receivers = (ReceiverGroup)0
				};
				PhotonNetwork.RaiseEvent((byte)179, (object)array, val, SendOptions.SendReliable);
			}
			foreach (ValuableObject pendingValuable in pendingValuables)
			{
				ValuablePatch.ApplyRandomValue(pendingValuable);
			}
			pendingValuables.Clear();
		}

		private static void LogTotalMapValue()
		{
			if (REPOConfig.ShowTotalMapValue.Value)
			{
				float num = 0f;
				ValuableObject[] array = Object.FindObjectsOfType<ValuableObject>();
				foreach (ValuableObject val in array)
				{
					num += val.dollarValueCurrent;
				}
				Logger.LogInfo((object)$"[REPOConomy] \ud83d\udcb0 Total value on map: ${Mathf.RoundToInt(num)}");
			}
		}

		public static int GetCurrentLevel()
		{
			if (StatsManager.instance?.runStats != null && StatsManager.instance.runStats.ContainsKey("level"))
			{
				return StatsManager.instance.runStats["level"] + 1;
			}
			return 1;
		}

		public static string GetEconomyName()
		{
			if (!HasEconomy)
			{
				return "Stability";
			}
			return CurrentEconomy switch
			{
				EconomyType.Stable => "Stability", 
				EconomyType.Deflation => "Deflation", 
				EconomyType.Inflation => "Inflation", 
				EconomyType.Chaos => "Chaos", 
				EconomyType.FreezeMarket => "Freeze", 
				EconomyType.BlackMarketSurge => "Black Market", 
				EconomyType.Overload => "Overload", 
				EconomyType.RareBoom => "Rare Boom", 
				EconomyType.CommonCrash => "Ordinary Disaster", 
				EconomyType.LegendaryOnlyMatters => "Legends Are Valued!", 
				EconomyType.EchoMarket => "Echo Market", 
				EconomyType.ReverseInflation => "Reverse Inflation", 
				EconomyType.LuxuryHunt => "Hunting For Luxury", 
				EconomyType.DumpsterDive => "Gold In The Dump", 
				EconomyType.ExtraProfit => "Additional Profit", 
				EconomyType.ScamSeason => "Season Of Scam", 
				EconomyType.SuddenDrop => "Sharp Fall", 
				EconomyType.TreasureRush => "Treasure Hunt", 
				EconomyType.ZeroGravity => "Weightlessness Of Prices", 
				EconomyType.Turbulence => "Turbulence", 
				EconomyType.BubbleBurst => "Bubble Burst", 
				EconomyType.CollectorsFrenzy => "Collector's Frenzy", 
				EconomyType.PanicSale => "Panic Sale", 
				EconomyType.EconomicTwister => "Economic Twister", 
				EconomyType.TaxAudit => "Tax Audit", 
				EconomyType.CrashAndBurn => "Crash & Burn", 
				EconomyType.GoldenHour => "Golden Hour", 
				EconomyType.CrystalBubble => "Crystal Bubble", 
				EconomyType.CoinDecay => "Coin Decay", 
				EconomyType.EchoCrash => "Echo Crash", 
				_ => "???", 
			};
		}

		public static string GetEconomyFlavor()
		{
			return CurrentEconomy switch
			{
				EconomyType.Stable => "Economy by default", 
				EconomyType.Deflation => "Market Crash", 
				EconomyType.Inflation => "Moment to Get Rich!", 
				EconomyType.Chaos => "Financial chaos...", 
				EconomyType.FreezeMarket => "Economy frozen :(", 
				EconomyType.BlackMarketSurge => "Values have become more expensive...", 
				EconomyType.Overload => "50/50", 
				EconomyType.RareBoom => "Values are suddenly in price!", 
				EconomyType.CommonCrash => "Values are devalued!", 
				EconomyType.LegendaryOnlyMatters => "Only the best makes sense...", 
				EconomyType.EchoMarket => "Prices are jumping like crazy...", 
				EconomyType.ReverseInflation => "Budget is better than wealth...", 
				EconomyType.LuxuryHunt => "Values are much more expensive!", 
				EconomyType.DumpsterDive => "Everything has become expensive!", 
				EconomyType.ExtraProfit => "Today you can sell more profitably!", 
				EconomyType.ScamSeason => "Prices are falling... :(", 
				EconomyType.SuddenDrop => "Almost everything has depreciated!", 
				EconomyType.TreasureRush => "Every value is - treasure!", 
				EconomyType.ZeroGravity => "Everything is unstable...", 
				EconomyType.Turbulence => "Prices behave unpredictably...", 
				EconomyType.BubbleBurst => "The market was booming... until it wasn’t", 
				EconomyType.CollectorsFrenzy => "Everything is worth more than it should be", 
				EconomyType.PanicSale => "Players are panic-selling everything for pennies!", 
				EconomyType.EconomicTwister => "Every item gets a completely random value", 
				EconomyType.TaxAudit => "The Tax Department has reviewed your valuables", 
				EconomyType.CrashAndBurn => "The market is collapsing — brace for losses", 
				EconomyType.GoldenHour => "A perfect time to sell — prices are booming!", 
				EconomyType.CrystalBubble => "Market euphoria! Prices are sky-high… for now", 
				EconomyType.CoinDecay => "Everything feels worthless. Time to sell or hold?", 
				EconomyType.EchoCrash => "Residual shockwaves shake the market unpredictably", 
				_ => "???", 
			};
		}

		public static Color GetEconomyColor()
		{
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: 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_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: 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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: 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_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: 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_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: 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_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: 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_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: 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_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: 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_0302: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			return (Color)(CurrentEconomy switch
			{
				EconomyType.Stable => Color.white, 
				EconomyType.Deflation => Color.red, 
				EconomyType.Inflation => Color.green, 
				EconomyType.Chaos => Color.cyan, 
				EconomyType.FreezeMarket => Color.gray, 
				EconomyType.BlackMarketSurge => new Color(1f, 0.84f, 0f), 
				EconomyType.Overload => Color.magenta, 
				EconomyType.RareBoom => new Color(0.7f, 0.2f, 1f), 
				EconomyType.CommonCrash => Color.gray, 
				EconomyType.LegendaryOnlyMatters => new Color(1f, 0.9f, 0.1f), 
				EconomyType.EchoMarket => Color.yellow, 
				EconomyType.ReverseInflation => Color.blue, 
				EconomyType.LuxuryHunt => new Color(0.2f, 1f, 0.4f), 
				EconomyType.DumpsterDive => new Color(0.6f, 0.3f, 0f), 
				EconomyType.ExtraProfit => new Color(0.1f, 0.8f, 1f), 
				EconomyType.ScamSeason => new Color(0.5f, 0f, 0.5f), 
				EconomyType.SuddenDrop => new Color(1f, 0.4f, 0f), 
				EconomyType.TreasureRush => new Color(1f, 0.65f, 0f), 
				EconomyType.ZeroGravity => new Color(0.8f, 0.8f, 0.8f), 
				EconomyType.Turbulence => new Color(0.4f, 0.6f, 0.8f), 
				EconomyType.BubbleBurst => new Color(0.7f, 0.2f, 0.2f), 
				EconomyType.CollectorsFrenzy => new Color(1f, 0.85f, 0.3f), 
				EconomyType.PanicSale => new Color(1f, 0.4f, 0.1f), 
				EconomyType.EconomicTwister => Color.Lerp(Color.red, Color.green, Random.value), 
				EconomyType.TaxAudit => new Color(0.3f, 0.4f, 0.6f), 
				EconomyType.CrashAndBurn => new Color(0.5f, 0.1f, 0.1f), 
				EconomyType.GoldenHour => new Color(1f, 0.85f, 0.3f), 
				EconomyType.CrystalBubble => new Color(1f, 0.9f, 1f), 
				EconomyType.CoinDecay => new Color(0.4f, 0.4f, 0.4f), 
				EconomyType.EchoCrash => new Color(0.8f, 0.3f, 0.9f), 
				_ => Color.gray, 
			});
		}

		public static void ResetEconomy()
		{
			HasEconomy = false;
			MinPercent = 0f;
			MaxPercent = 0f;
			CurrentEconomy = EconomyType.Stable;
			Logger.LogInfo((object)"[Economy] The economy has been reset. Ready for a new race.");
		}
	}
}