Decompiled source of BetterRounds v0.34.1

plugins/BetterRounds.dll

Decompiled 4 days ago
using System;
using System.Collections;
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.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using RoundsPartyPack.Abilities;
using RoundsPartyPack.Art;
using RoundsPartyPack.Cards;
using RoundsPartyPack.Draft;
using RoundsPartyPack.Framework;
using RoundsPartyPack.Settings;
using RoundsPartyPack.Visuals;
using TMPro;
using UnboundLib;
using UnboundLib.Cards;
using UnboundLib.GameModes;
using UnboundLib.Networking;
using UnboundLib.Utils;
using UnboundLib.Utils.UI;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("BetterRounds")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BetterRounds")]
[assembly: AssemblyTitle("BetterRounds")]
[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 RoundsPartyPack
{
	internal static class CardRegistry
	{
		private static readonly MethodInfo BuildCardMethod = typeof(CustomCard).GetMethods(BindingFlags.Static | BindingFlags.Public).Single((MethodInfo method) => method.Name == "BuildCard" && method.IsGenericMethodDefinition && method.GetParameters().Length == 1);

		private static readonly MethodInfo BuildUnityCardMethod = (from method in typeof(CustomCard).GetMethods(BindingFlags.Static | BindingFlags.Public)
			where method.Name == "BuildUnityCard" && method.IsGenericMethodDefinition
			select method).Single(delegate(MethodInfo method)
		{
			ParameterInfo[] parameters = method.GetParameters();
			return parameters.Length == 2 && parameters[0].ParameterType == typeof(GameObject);
		});

		private static readonly MethodInfo DontDestroyOnLoadMethod = typeof(Object).GetMethod("DontDestroyOnLoad", BindingFlags.Static | BindingFlags.Public);

		private static readonly MethodInfo DestroyImmediateMethod = typeof(Object).GetMethod("DestroyImmediate", BindingFlags.Static | BindingFlags.Public, null, new Type[1] { typeof(Object) }, null);

		private static readonly FieldInfo UnboundTemplateCardField = typeof(Unbound).GetField("templateCard", BindingFlags.Static | BindingFlags.NonPublic);

		private static readonly FieldInfo IsPrefabField = typeof(CustomCard).GetField("isPrefab", BindingFlags.Instance | BindingFlags.NonPublic);

		private static readonly List<Type> ManualCardTypes = (from type in GetLoadableTypes()
			where type != null && !type.IsAbstract && typeof(BalancedCard).IsAssignableFrom(type) && type != typeof(GeneratedTemplateCard)
			select type).OrderBy<Type, string>((Type type) => type.FullName, StringComparer.Ordinal).ToList();

		private static readonly TemplateCardDefinition[] TemplateCards = PrototypeTemplateCatalog.All;

		private static bool _registered;

		internal static int CardCount => ManualCardTypes.Count + TemplateCards.Length;

		internal static void RegisterAll()
		{
			if (_registered)
			{
				return;
			}
			_registered = true;
			List<string> list = new List<string>();
			foreach (Type manualCardType in ManualCardTypes)
			{
				Action<CardInfo> action = CardMetadataRegistry.Register;
				BuildCardMethod.MakeGenericMethod(manualCardType).Invoke(null, new object[1] { action });
			}
			TemplateCardDefinition[] templateCards = TemplateCards;
			foreach (TemplateCardDefinition templateCardDefinition in templateCards)
			{
				if (templateCardDefinition.Spec.IsManagedClass && templateCardDefinition.Spec.Tier >= 4 && !templateCardDefinition.HasUniqueMechanic)
				{
					list.Add(templateCardDefinition.Spec.Title);
				}
				RegisterTemplate(templateCardDefinition);
			}
			if (list.Count <= 0)
			{
				return;
			}
			throw new InvalidOperationException("BetterRounds upper-tier audit failed. Managed T4/T5 cards without unique mechanics: " + string.Join(", ", list));
		}

		private static IEnumerable<Type> GetLoadableTypes()
		{
			try
			{
				return typeof(CardRegistry).Assembly.GetTypes();
			}
			catch (ReflectionTypeLoadException ex)
			{
				return ex.Types.Where((Type type) => type != null);
			}
		}

		private static void RegisterTemplate(TemplateCardDefinition templateCard)
		{
			//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_003e: Unknown result type (might be due to invalid IL or missing references)
			object? obj = UnboundTemplateCardField?.GetValue(null);
			CardInfo val = (CardInfo)((obj is CardInfo) ? obj : null);
			if (val != null)
			{
				GameObject val2 = Object.Instantiate<GameObject>(((Component)val).gameObject, new Vector3(0f, 100f, 0f), default(Quaternion), (Transform)null);
				if (val2.transform.childCount > 0)
				{
					GameObject gameObject = ((Component)val2.transform.GetChild(0)).gameObject;
					DestroyImmediateMethod?.Invoke(null, new object[1] { gameObject });
				}
				val2.transform.parent = null;
				((Object)val2).name = templateCard.Spec.Title;
				DontDestroyOnLoadMethod?.Invoke(null, new object[1] { val2 });
				ExtensionMethods.GetOrAddComponent<TemplateCardState>(val2, false).Definition = templateCard;
				GeneratedTemplateCard orAddComponent = ExtensionMethods.GetOrAddComponent<GeneratedTemplateCard>(val2, false);
				IsPrefabField?.SetValue(orAddComponent, true);
				CardMetadataRegistry.RegisterTemplate(((Object)val2).name, templateCard);
				Action<CardInfo> action = CardMetadataRegistry.Register;
				BuildUnityCardMethod.MakeGenericMethod(typeof(GeneratedTemplateCard)).Invoke(null, new object[2] { val2, action });
			}
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.betterrounds.rounds", "BetterRounds", "0.34.1")]
	[BepInProcess("Rounds.exe")]
	public sealed class Plugin : BaseUnityPlugin
	{
		internal const string ModId = "com.betterrounds.rounds";

		internal const string ModName = "BetterRounds";

		internal const string ModVersion = "0.34.1";

		private Harmony _harmony;

		internal static Plugin Instance { get; private set; }

		internal static ManualLogSource Log { get; private set; }

		private void Awake()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			_harmony = new Harmony("com.betterrounds.rounds");
			_harmony.PatchAll();
		}

		private void Start()
		{
			BetterRoundsSettings.Initialize((BaseUnityPlugin)(object)this);
			CardRegistry.RegisterAll();
			AbilityGameModeHooks.Initialize();
			PickFlowController.Initialize();
			DraftEngine.Initialize();
			((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("Loaded {0} with {1} discovered cards.", "BetterRounds", CardRegistry.CardCount));
			Unbound.RegisterCredits("BetterRounds", new string[1] { "BetterRounds" }, "Discord", "https://discord.gg/FactionRealm");
		}
	}
}
namespace RoundsPartyPack.Visuals
{
	internal enum FeedbackCueKind
	{
		Ready,
		Shield,
		Summon,
		Beacon,
		Hazard,
		Consume,
		Disrupt,
		Expose,
		Overheat
	}
	internal static class FeedbackCueUtility
	{
		private const int SampleRate = 22050;

		private const BindingFlags MemberFlags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;

		private static readonly Dictionary<FeedbackCueKind, object> Clips = new Dictionary<FeedbackCueKind, object>();

		private static readonly Type AudioClipType = Type.GetType("UnityEngine.AudioClip, UnityEngine.AudioModule") ?? Type.GetType("UnityEngine.AudioClip, UnityEngine");

		private static readonly Type AudioSourceType = Type.GetType("UnityEngine.AudioSource, UnityEngine.AudioModule") ?? Type.GetType("UnityEngine.AudioSource, UnityEngine");

		internal static void PlayCue(Vector3 position, FeedbackCueKind kind, float volume = 0.12f, float pitch = 1f)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			object clip = GetClip(kind);
			if (clip != null && !(AudioSourceType == null))
			{
				GameObject val = new GameObject();
				((Object)val).name = "BetterRoundsFeedbackCue";
				val.transform.position = position;
				object? target = ((object)val).GetType().GetMethod("AddComponent", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(Type) }, null)?.Invoke(val, new object[1] { AudioSourceType });
				SetProperty(target, "playOnAwake", false);
				SetProperty(target, "spatialBlend", 0f);
				SetProperty(target, "volume", Clamp01(volume));
				float num = ((pitch <= 0.01f) ? 1f : pitch);
				SetProperty(target, "pitch", num);
				SetProperty(target, "clip", clip);
				InvokeMethod(target, "Play");
				float floatProperty = GetFloatProperty(clip, "length", 0.1f);
				ExtensionMethods.GetOrAddComponent<FeedbackCueLifetime>(val, false).Initialize(floatProperty / Math.Max(0.05f, num) + 0.08f);
			}
		}

		private static object GetClip(FeedbackCueKind kind)
		{
			if (Clips.TryGetValue(kind, out var value) && value != null)
			{
				return value;
			}
			value = CreateClip(kind);
			if (value != null)
			{
				Clips[kind] = value;
			}
			return value;
		}

		private static object CreateClip(FeedbackCueKind kind)
		{
			return kind switch
			{
				FeedbackCueKind.Ready => BuildTone("BetterRoundsCueReady", 0.09f, 820f, 1120f, 0.38f, 1.6f, 0.18f), 
				FeedbackCueKind.Shield => BuildTone("BetterRoundsCueShield", 0.11f, 540f, 720f, 0.44f, 1.8f, 0.2f), 
				FeedbackCueKind.Summon => BuildTone("BetterRoundsCueSummon", 0.12f, 660f, 990f, 0.48f, 1.9f, 0.17f), 
				FeedbackCueKind.Beacon => BuildTone("BetterRoundsCueBeacon", 0.12f, 580f, 860f, 0.42f, 1.8f, 0.18f), 
				FeedbackCueKind.Hazard => BuildTone("BetterRoundsCueHazard", 0.13f, 320f, 220f, 0.55f, 2.2f, 0.2f), 
				FeedbackCueKind.Consume => BuildTone("BetterRoundsCueConsume", 0.08f, 920f, 1240f, 0.34f, 1.5f, 0.16f), 
				FeedbackCueKind.Disrupt => BuildTone("BetterRoundsCueDisrupt", 0.1f, 430f, 310f, 0.5f, 2f, 0.18f), 
				FeedbackCueKind.Expose => BuildTone("BetterRoundsCueExpose", 0.1f, 740f, 520f, 0.46f, 1.8f, 0.18f), 
				FeedbackCueKind.Overheat => BuildTone("BetterRoundsCueOverheat", 0.14f, 280f, 180f, 0.62f, 2.4f, 0.22f), 
				_ => null, 
			};
		}

		private static object BuildTone(string name, float durationSeconds, float primaryFrequency, float secondaryFrequency, float secondaryMix, float decayPower, float amplitude)
		{
			if (AudioClipType == null)
			{
				return null;
			}
			int num = Math.Max(1, (int)(22050f * Math.Max(0.03f, durationSeconds)));
			float[] array = new float[num];
			double num2 = Math.PI * 2.0;
			for (int i = 0; i < num; i++)
			{
				float num3 = (float)i / 22050f;
				float num4 = (float)i / (float)Math.Max(1, num - 1);
				float num5 = (float)Math.Pow(Math.Max(0f, 1f - num4), decayPower);
				float num6 = (float)Math.Sin(num2 * (double)primaryFrequency * (double)num3);
				float num7 = ((secondaryFrequency > 0.01f) ? ((float)Math.Sin(num2 * (double)secondaryFrequency * (double)num3)) : 0f);
				float num8 = num6 + num7 * secondaryMix;
				array[i] = num8 * num5 * amplitude;
			}
			object obj = AudioClipType.GetMethod("Create", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[5]
			{
				typeof(string),
				typeof(int),
				typeof(int),
				typeof(int),
				typeof(bool)
			}, null)?.Invoke(null, new object[5] { name, num, 1, 22050, false });
			InvokeMethod(obj, "SetData", array, 0);
			return obj;
		}

		private static void SetProperty(object target, string propertyName, object value)
		{
			PropertyInfo propertyInfo = target?.GetType().GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			if (propertyInfo != null && propertyInfo.CanWrite)
			{
				propertyInfo.SetValue(target, value, null);
			}
		}

		private static float GetFloatProperty(object target, string propertyName, float fallback)
		{
			PropertyInfo propertyInfo = target?.GetType().GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			if (propertyInfo != null && propertyInfo.CanRead && propertyInfo.PropertyType == typeof(float))
			{
				return (float)propertyInfo.GetValue(target, null);
			}
			return fallback;
		}

		private static void InvokeMethod(object target, string methodName, params object[] args)
		{
			(target?.GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic))?.Invoke(target, args);
		}

		private static float Clamp01(float value)
		{
			if (value < 0f)
			{
				return 0f;
			}
			if (value > 1f)
			{
				return 1f;
			}
			return value;
		}
	}
	internal sealed class FeedbackCueLifetime : MonoBehaviour
	{
		private float _destroyAt;

		internal void Initialize(float duration)
		{
			_destroyAt = Time.unscaledTime + Math.Max(0.05f, duration);
		}

		private void Update()
		{
			if (Time.unscaledTime >= _destroyAt)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}
	}
	internal sealed class PlayerUpgradeVisualController : MonoBehaviour
	{
		private struct UpgradeProfile
		{
			internal int ManagedCards;

			internal int MechanicScore;

			internal int UniqueMechanicCards;

			internal int UpperTierCards;

			internal int CapstoneCards;

			internal int GemCount;

			internal CardClass DominantClass;

			internal Color ThemeColor;

			internal float VisualPower;
		}

		private struct OrbitGem
		{
			internal GameObject GameObject;

			internal float PhaseOffset;

			internal float VerticalOffset;
		}

		private struct BurstGem
		{
			internal GameObject GameObject;

			internal Vector3 Direction;

			internal float VerticalLift;

			internal float Speed;

			internal float Age;

			internal float Lifetime;

			internal float StartScale;

			internal float EndScale;
		}

		private struct StatusSignal
		{
			internal Vector3 Position { get; }

			internal float Scale { get; }

			internal Color Color { get; }

			internal float Alpha { get; }

			internal float PulseAmplitude { get; }

			internal float PulseSpeed { get; }

			internal float FloatAmplitude { get; }

			internal float FloatSpeed { get; }

			internal float SpinSpeed { get; }

			internal StatusSignal(Vector3 position, float scale, Color color, float alpha, float pulseAmplitude, float pulseSpeed, float floatAmplitude, float floatSpeed, float spinSpeed)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: 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)
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				Position = position;
				Scale = scale;
				Color = color;
				Alpha = alpha;
				PulseAmplitude = pulseAmplitude;
				PulseSpeed = pulseSpeed;
				FloatAmplitude = floatAmplitude;
				FloatSpeed = floatSpeed;
				SpinSpeed = spinSpeed;
			}
		}

		private const BindingFlags MemberFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;

		private static readonly Type ComponentType = typeof(Transform).BaseType;

		private static readonly MethodInfo GetComponentsInChildrenMethod = typeof(GameObject).GetMethod("GetComponentsInChildren", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[2]
		{
			typeof(Type),
			typeof(bool)
		}, null);

		private Player _player;

		private CharacterData _data;

		private Gun _gun;

		private Gun _coloredGun;

		private bool _projectileColorCaptured;

		private bool _projectileColorApplied;

		private Color _baseProjectileColor = WhiteColor;

		private readonly List<OrbitGem> _orbitGems = new List<OrbitGem>();

		private readonly List<BurstGem> _burstGems = new List<BurstGem>();

		private readonly List<GameObject> _statusGems = new List<GameObject>();

		private readonly List<StatusSignal> _statusSignals = new List<StatusSignal>();

		private UpgradeProfile _profile;

		private bool _refreshQueued;

		private float _refreshAt;

		private float _pickupAccentUntil;

		private float _lastUpdateAt;

		private bool _telemetryCueInitialized;

		private bool _wasChamberReady;

		private bool _wasReloadModeReady;

		private bool _wasPerfectParryReady;

		private bool _wasOrbitWardActive;

		private bool _wasHazardZoneArmed;

		private bool _wasOverheatActive;

		private static Color WhiteColor => new Color(1f, 1f, 1f, 1f);

		internal static PlayerUpgradeVisualController GetOrAdd(Player player)
		{
			if (player != null)
			{
				return ExtensionMethods.GetOrAddComponent<PlayerUpgradeVisualController>(((Component)player).gameObject, false);
			}
			return null;
		}

		internal void NotifyCardAdded(CardSpec spec)
		{
			if (spec != null)
			{
				SpawnPickupBurst(spec);
				_pickupAccentUntil = MaxFloat(_pickupAccentUntil, Time.unscaledTime + 0.9f + (float)spec.Tier * 0.1f);
				EmitPickupCue(spec);
			}
			QueueRefresh(0.08f);
		}

		internal void NotifyCardRemoved()
		{
			QueueRefresh(0.08f);
		}

		private void OnEnable()
		{
			_telemetryCueInitialized = false;
			QueueRefresh(0f);
		}

		private void Update()
		{
			ResolveReferences();
			SyncTintTarget();
			if (_refreshQueued && Time.unscaledTime >= _refreshAt)
			{
				RefreshProfile();
			}
			float unscaledTime = Time.unscaledTime;
			float deltaTime = ((_lastUpdateAt <= 0f) ? 0f : MaxFloat(0f, unscaledTime - _lastUpdateAt));
			_lastUpdateAt = unscaledTime;
			UpdateOrbitGems(unscaledTime);
			UpdateBurstGems(deltaTime);
			UpdateStatusGems(unscaledTime);
		}

		private void OnDisable()
		{
			RestoreProjectileColor();
			ClearVisualObjects();
		}

		private void QueueRefresh(float delay)
		{
			_refreshQueued = true;
			_refreshAt = Time.unscaledTime + MaxFloat(0f, delay);
		}

		private void RefreshProfile()
		{
			_refreshQueued = false;
			_profile = BuildProfile();
			SyncPersistentVisuals();
			ApplyProjectileColor();
		}

		private UpgradeProfile BuildProfile()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			UpgradeProfile upgradeProfile = default(UpgradeProfile);
			upgradeProfile.ThemeColor = ResolveClassColor(CardClass.Neutral);
			UpgradeProfile upgradeProfile2 = upgradeProfile;
			if (_data?.currentCards == null)
			{
				return upgradeProfile2;
			}
			Dictionary<CardClass, int> dictionary = new Dictionary<CardClass, int>();
			int num = 0;
			int num2 = 0;
			int num3 = 0;
			foreach (CardInfo currentCard in _data.currentCards)
			{
				if (!CardMetadataRegistry.TryGetMetadata(currentCard, out var metadata) || metadata?.Spec == null)
				{
					continue;
				}
				CardSpec spec = metadata.Spec;
				upgradeProfile2.ManagedCards++;
				if (metadata.HasUniqueMechanic)
				{
					upgradeProfile2.UniqueMechanicCards++;
				}
				upgradeProfile2.MechanicScore += metadata.MechanicScore;
				if (spec.Tier >= 4 || spec.Track == CardTrack.Signature || spec.Track == CardTrack.Capstone)
				{
					upgradeProfile2.UpperTierCards++;
				}
				if (spec.Track == CardTrack.Capstone || spec.Tier >= 5)
				{
					upgradeProfile2.CapstoneCards++;
				}
				if (spec.IsWildcard)
				{
					num++;
					continue;
				}
				if (spec.IsTroll)
				{
					num2++;
					continue;
				}
				if (!spec.IsManagedClass)
				{
					num3++;
					continue;
				}
				if (!dictionary.ContainsKey(spec.CardClass))
				{
					dictionary[spec.CardClass] = 0;
				}
				dictionary[spec.CardClass]++;
			}
			upgradeProfile2.DominantClass = ResolveDominantClass(dictionary, num, num2, num3);
			upgradeProfile2.ThemeColor = ResolveClassColor(upgradeProfile2.DominantClass);
			upgradeProfile2.GemCount = ResolveGemCount(upgradeProfile2);
			upgradeProfile2.VisualPower = Clamp01((float)upgradeProfile2.ManagedCards * 0.05f + (float)upgradeProfile2.MechanicScore * 0.05f + (float)upgradeProfile2.UniqueMechanicCards * 0.08f + (float)upgradeProfile2.UpperTierCards * 0.14f + (float)upgradeProfile2.CapstoneCards * 0.24f);
			return upgradeProfile2;
		}

		private static CardClass ResolveDominantClass(Dictionary<CardClass, int> classCounts, int wildcardCount, int trollCount, int neutralCount)
		{
			CardClass result = CardClass.Neutral;
			int num = 0;
			foreach (KeyValuePair<CardClass, int> classCount in classCounts)
			{
				if (classCount.Value > num)
				{
					result = classCount.Key;
					num = classCount.Value;
				}
			}
			if (num > 0)
			{
				return result;
			}
			if (wildcardCount >= trollCount && wildcardCount >= neutralCount && wildcardCount > 0)
			{
				return CardClass.Wildcard;
			}
			if (trollCount > 0 && trollCount >= neutralCount)
			{
				return CardClass.Troll;
			}
			return CardClass.Neutral;
		}

		private static int ResolveGemCount(UpgradeProfile profile)
		{
			if (profile.ManagedCards <= 0)
			{
				return 0;
			}
			return ClampInt(1 + Math.Min(1, profile.MechanicScore / 4) + Math.Min(2, profile.UpperTierCards / 2) + Math.Min(1, profile.UniqueMechanicCards / 3) + Math.Min(2, profile.CapstoneCards), 1, 6);
		}

		private void SyncPersistentVisuals()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			EnsureOrbitGemCount(_profile.GemCount);
			for (int i = 0; i < _orbitGems.Count; i++)
			{
				OrbitGem value = _orbitGems[i];
				if (value.GameObject != null)
				{
					ApplyTint(value.GameObject, BuildGemTint(_profile.ThemeColor, i, _orbitGems.Count));
					float num = 0.24f + _profile.VisualPower * 0.16f + ((_profile.CapstoneCards > 0 && i == _orbitGems.Count - 1) ? 0.08f : 0f);
					value.GameObject.transform.localScale = new Vector3(num, num, num);
					_orbitGems[i] = value;
				}
			}
		}

		private void EnsureOrbitGemCount(int desiredCount)
		{
			while (_orbitGems.Count > desiredCount)
			{
				int index = _orbitGems.Count - 1;
				OrbitGem orbitGem = _orbitGems[index];
				if (orbitGem.GameObject != null)
				{
					Object.Destroy((Object)(object)orbitGem.GameObject);
				}
				_orbitGems.RemoveAt(index);
			}
			while (_orbitGems.Count < desiredCount)
			{
				GameObject val = CreateVisualSeed($"BetterRoundsOrbitGem_{_orbitGems.Count}");
				if (val != null)
				{
					OrbitGem orbitGem2 = default(OrbitGem);
					orbitGem2.GameObject = val;
					orbitGem2.PhaseOffset = 360f * ((float)_orbitGems.Count / (float)Math.Max(1, desiredCount));
					orbitGem2.VerticalOffset = 0.12f * ((_orbitGems.Count % 2 == 0) ? 1f : (-1f));
					OrbitGem item = orbitGem2;
					_orbitGems.Add(item);
					continue;
				}
				break;
			}
		}

		private void UpdateOrbitGems(float time)
		{
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: 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_01e2: 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)
			if (_orbitGems.Count == 0)
			{
				return;
			}
			float num = ((time <= _pickupAccentUntil) ? 0.18f : 0f);
			for (int i = 0; i < _orbitGems.Count; i++)
			{
				OrbitGem value = _orbitGems[i];
				if (value.GameObject != null)
				{
					bool flag = _profile.CapstoneCards > 0 && i == _orbitGems.Count - 1;
					float num2 = (flag ? 38f : (62f + _profile.VisualPower * 36f));
					float num3 = time * num2 + value.PhaseOffset;
					float num4 = (flag ? (0.3f + (float)_profile.CapstoneCards * 0.05f) : (0.55f + _profile.VisualPower * 0.35f + (float)i * 0.04f));
					float num5 = (flag ? (0.92f + 0.06f * Sin(time * 2.8f + (float)i)) : (value.VerticalOffset + 0.14f * Sin(time * 2.1f + (float)i)));
					Vector3 position = (flag ? new Vector3(Cos(DegToRad(num3)) * num4, num5, 0f) : new Vector3(Cos(DegToRad(num3)) * num4, num5 + Sin(DegToRad(num3)) * 0.1f, 0f));
					SetTransformLocalPosition(value.GameObject.transform, position);
					float num6 = 1f + 0.1f * Sin(time * 3.1f + (float)i);
					if (num > 0f)
					{
						num6 += num;
					}
					float num7 = 0.24f + _profile.VisualPower * 0.16f + (flag ? 0.08f : 0f);
					value.GameObject.transform.localScale = new Vector3(num7 * num6, num7 * num6, num7 * num6);
					SetTransformLocalRotation(value.GameObject.transform, Quaternion.Euler(0f, 0f, 0f - num3));
					_orbitGems[i] = value;
				}
			}
		}

		private void SpawnPickupBurst(CardSpec spec)
		{
			//IL_0044: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: 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)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			int num = ((spec.Tier >= 5) ? 4 : ((spec.Tier >= 4) ? 3 : ((spec.Tier < 3) ? 1 : 2)));
			Color a = ResolveClassColor(spec.IsWildcard ? CardClass.Wildcard : (spec.IsTroll ? CardClass.Troll : spec.CardClass));
			for (int i = 0; i < num; i++)
			{
				GameObject val = CreateVisualSeed($"BetterRoundsBurstGem_{i}");
				if (val == null)
				{
					break;
				}
				ApplyTint(val, LerpColor(a, WhiteColor, 0.2f + (float)spec.Tier * 0.05f));
				float num2 = 0.22f + (float)spec.Tier * 0.04f;
				val.transform.localScale = new Vector3(num2, num2, num2);
				BurstGem burstGem = default(BurstGem);
				burstGem.GameObject = val;
				burstGem.Direction = BuildDirection(360f / (float)num * (float)i);
				burstGem.VerticalLift = 0.25f + 0.05f * (float)i;
				burstGem.StartScale = num2;
				burstGem.EndScale = num2 * 0.55f;
				burstGem.Lifetime = 0.45f + (float)spec.Tier * 0.08f;
				burstGem.Speed = 0.8f + (float)spec.Tier * 0.12f;
				BurstGem item = burstGem;
				_burstGems.Add(item);
			}
		}

		private void UpdateStatusGems(float time)
		{
			//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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			BuildStatusSignals();
			EnsureStatusGemCount(_statusSignals.Count);
			for (int i = 0; i < _statusSignals.Count; i++)
			{
				GameObject val = _statusGems[i];
				if (val != null)
				{
					StatusSignal statusSignal = _statusSignals[i];
					Vector3 position = statusSignal.Position;
					if (statusSignal.FloatAmplitude > 0.001f)
					{
						position.y += statusSignal.FloatAmplitude * Sin(time * statusSignal.FloatSpeed + (float)i * 0.7f);
					}
					SetTransformLocalPosition(val.transform, position);
					float num = statusSignal.Scale;
					if (statusSignal.PulseAmplitude > 0.001f)
					{
						num *= 1f + statusSignal.PulseAmplitude * Sin(time * statusSignal.PulseSpeed + (float)i * 0.8f);
					}
					val.transform.localScale = new Vector3(num, num, num);
					SetTransformLocalRotation(val.transform, Quaternion.Euler(0f, 0f, time * statusSignal.SpinSpeed + (float)i * 18f));
					ApplyTint(val, statusSignal.Color);
					SetVisualAlpha(val, statusSignal.Alpha);
				}
			}
		}

		private void BuildStatusSignals()
		{
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: 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_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0367: Unknown result type (might be due to invalid IL or missing references)
			//IL_0385: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0439: Unknown result type (might be due to invalid IL or missing references)
			//IL_0457: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_050b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0529: Unknown result type (might be due to invalid IL or missing references)
			//IL_0574: Unknown result type (might be due to invalid IL or missing references)
			//IL_0592: Unknown result type (might be due to invalid IL or missing references)
			//IL_05dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0646: Unknown result type (might be due to invalid IL or missing references)
			//IL_0664: Unknown result type (might be due to invalid IL or missing references)
			//IL_0758: Unknown result type (might be due to invalid IL or missing references)
			//IL_0776: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_07df: 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_06f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_082a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0848: Unknown result type (might be due to invalid IL or missing references)
			//IL_0893: Unknown result type (might be due to invalid IL or missing references)
			//IL_08b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_08fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_091a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0965: Unknown result type (might be due to invalid IL or missing references)
			//IL_0983: Unknown result type (might be due to invalid IL or missing references)
			//IL_09ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_09ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a37: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a55: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ab0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ace: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b11: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b2f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b75: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b93: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bd9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bf7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c3d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c5b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ca1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cbf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d05: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d23: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d86: Unknown result type (might be due to invalid IL or missing references)
			//IL_0da4: Unknown result type (might be due to invalid IL or missing references)
			//IL_1051: Unknown result type (might be due to invalid IL or missing references)
			//IL_107f: Unknown result type (might be due to invalid IL or missing references)
			//IL_10c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_10e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f94: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f79: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f99: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e82: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e87: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ea8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e58: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e5d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e67: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e4b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fcf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ebd: Unknown result type (might be due to invalid IL or missing references)
			_statusSignals.Clear();
			if (_player == null)
			{
				return;
			}
			PlayerAbilityController.AbilityVisualTelemetry telemetry = ((Component)_player).GetComponent<PlayerAbilityController>()?.GetVisualTelemetry() ?? default(PlayerAbilityController.AbilityVisualTelemetry);
			DraftEconomyController component = ((Component)_player).GetComponent<DraftEconomyController>();
			PlayerMarkStatusController component2 = ((Component)_player).GetComponent<PlayerMarkStatusController>();
			PlayerDisruptionStatusController component3 = ((Component)_player).GetComponent<PlayerDisruptionStatusController>();
			int num = component?.PeekQueuedRoundBonuses() ?? 0;
			int num2 = component2?.GetTotalMarks() ?? 0;
			bool flag = component3?.HasActiveDisruption() ?? false;
			float num3 = component3?.GetVisualIntensity() ?? 0f;
			bool flag2 = false;
			bool flag3 = false;
			bool flag4 = false;
			bool flag5 = false;
			bool flag6 = false;
			bool flag7 = false;
			bool flag8 = false;
			if (_data?.currentCards != null)
			{
				foreach (CardInfo currentCard in _data.currentCards)
				{
					if (CardMetadataRegistry.TryGetMetadata(currentCard, out var metadata) && metadata?.Spec?.DraftTags != null)
					{
						IReadOnlyList<string> draftTags = metadata.Spec.DraftTags;
						flag2 |= draftTags.Any((string tag) => string.Equals(tag, "teleport", StringComparison.OrdinalIgnoreCase));
						flag3 |= draftTags.Any((string tag) => string.Equals(tag, "drill", StringComparison.OrdinalIgnoreCase));
						flag4 |= draftTags.Any((string tag) => string.Equals(tag, "reflect", StringComparison.OrdinalIgnoreCase));
						flag5 |= draftTags.Any((string tag) => string.Equals(tag, "orbit", StringComparison.OrdinalIgnoreCase));
						flag6 |= draftTags.Any((string tag) => string.Equals(tag, "shield", StringComparison.OrdinalIgnoreCase));
						flag7 |= draftTags.Any((string tag) => string.Equals(tag, "minion", StringComparison.OrdinalIgnoreCase) || string.Equals(tag, "helper", StringComparison.OrdinalIgnoreCase));
						flag8 |= draftTags.Any((string tag) => string.Equals(tag, "spawn", StringComparison.OrdinalIgnoreCase) || string.Equals(tag, "remnant", StringComparison.OrdinalIgnoreCase));
					}
				}
			}
			EmitTelemetryCues(telemetry);
			if (telemetry.CounterChargeReady || telemetry.BlockGhostReady)
			{
				_statusSignals.Add(new StatusSignal(new Vector3(-0.48f, 0.42f, 0f), 0.2f, new Color(0.32f, 0.72f, 1f, 1f), 0.96f, 0.08f, 3.6f, 0.04f, 2.4f, 72f));
			}
			if (telemetry.PerfectParryReady)
			{
				_statusSignals.Add(new StatusSignal(new Vector3(-0.54f, 0.68f, 0f), 0.21f, new Color(0.84f, 0.94f, 1f, 1f), 0.98f, 0.1f, 4.6f, 0.04f, 2.6f, 92f));
			}
			if (telemetry.ChamberReady)
			{
				_statusSignals.Add(new StatusSignal(new Vector3(0.48f, 0.42f, 0f), 0.22f, new Color(0.99f, 0.84f, 0.22f, 1f), 0.98f, 0.1f, 4.4f, 0.03f, 2f, 85f));
			}
			if (telemetry.LastShellReady)
			{
				_statusSignals.Add(new StatusSignal(new Vector3(0.34f, 0.12f, 0f), 0.19f, new Color(1f, 0.52f, 0.16f, 1f), 0.95f, 0.12f, 5.4f, 0.03f, 2f, 96f));
			}
			if (telemetry.ReloadChargeReady)
			{
				_statusSignals.Add(new StatusSignal(new Vector3(0.54f, 0.72f, 0f), 0.17f, new Color(1f, 0.92f, 0.42f, 1f), 0.95f, 0.09f, 4.1f, 0.03f, 1.9f, 82f));
			}
			if (telemetry.ReloadModeReady)
			{
				_statusSignals.Add(new StatusSignal(new Vector3(0.56f, 0.58f, 0f), 0.18f, new Color(0.96f, 0.8f, 0.3f, 1f), 0.96f, 0.12f, 4.8f, 0.03f, 2.1f, 108f));
			}
			if (telemetry.KillChargeReady)
			{
				_statusSignals.Add(new StatusSignal(new Vector3(-0.34f, 0.88f, 0f), 0.18f, new Color(1f, 0.38f, 0.24f, 1f), 0.95f, 0.11f, 4.9f, 0.04f, 2.2f, 90f));
			}
			if (telemetry.MissChargeReady)
			{
				_statusSignals.Add(new StatusSignal(new Vector3(-0.48f, -0.04f, 0f), 0.17f, new Color(0.62f, 0.82f, 1f, 1f), 0.9f, 0.08f, 3.8f, 0.03f, 1.8f, 66f));
			}
			if (telemetry.MarkChargeReady)
			{
				_statusSignals.Add(new StatusSignal(new Vector3(0f, 0.62f, 0f), 0.2f, new Color(0.97f, 0.34f, 0.78f, 1f), 0.98f, 0.1f, 4.2f, 0.05f, 2.8f, 94f));
			}
			if (telemetry.HitDisruptionArmed)
			{
				_statusSignals.Add(new StatusSignal(new Vector3(-0.12f, 0.84f, 0f), 0.16f, new Color(1f, 0.38f, 0.62f, 1f), 0.9f, 0.08f, 3.6f, 0.03f, 1.8f, 78f));
			}
			if (telemetry.OrbitWardActive)
			{
				int num4 = Math.Min(2, Math.Max(1, telemetry.OrbitWardCount));
				for (int i = 0; i < num4; i++)
				{
					_statusSignals.Add(new StatusSignal(new Vector3(-0.2f + (float)i * 0.4f, 0.98f, 0f), 0.15f, new Color(0.82f, 0.42f, 1f, 1f), 0.92f, 0.1f, 4.4f, 0.05f, 2.6f, (i % 2 == 0) ? 120f : (-120f)));
				}
			}
			else if (flag5)
			{
				_statusSignals.Add(new StatusSignal(new Vector3(-0.56f, 0.98f, 0f), 0.13f, new Color(0.76f, 0.54f, 1f, 1f), 0.76f, 0.05f, 2.6f, 0.03f, 1.8f, 96f));
			}
			if (telemetry.HazardZoneArmed)
			{
				_statusSignals.Add(new StatusSignal(new Vector3(0f, -0.34f, 0f), 0.18f, new Color(1f, 0.52f, 0.22f, 1f), 0.84f, 0.08f, 3f, 0.02f, 1.5f, 44f));
			}
			if (telemetry.GroundedStanceActive)
			{
				_statusSignals.Add(new StatusSignal(new Vector3(-0.26f, -0.28f, 0f), 0.18f, new Color(0.78f, 0.88f, 1f, 1f), 0.86f, 0.07f, 2.6f, 0.02f, 1.4f, 34f));
			}
			if (telemetry.WallStanceActive)
			{
				_statusSignals.Add(new StatusSignal(new Vector3(0.52f, -0.04f, 0f), 0.17f, new Color(0.72f, 0.9f, 1f, 1f), 0.88f, 0.07f, 3.2f, 0.03f, 1.6f, 44f));
			}
			if (telemetry.LowHealthStanceActive)
			{
				_statusSignals.Add(new StatusSignal(new Vector3(-0.18f, 0.06f, 0f), 0.21f, new Color(0.94f, 0.2f, 0.18f, 1f), 0.92f, 0.14f, 5f, 0.02f, 1.8f, 52f));
			}
			if (telemetry.ComebackRushActive)
			{
				_statusSignals.Add(new StatusSignal(new Vector3(0.32f, 1.04f, 0f), 0.18f, new Color(1f, 0.72f, 0.26f, 1f), 0.96f, 0.12f, 4.8f, 0.05f, 2.5f, 88f));
			}
			if (telemetry.EmptyMagRushActive)
			{
				_statusSignals.Add(new StatusSignal(new Vector3(0f, -0.16f, 0f), 0.24f, new Color(1f, 0.34f, 0.22f, 1f), 0.92f, 0.14f, 5.2f, 0.03f, 2f, 68f));
			}
			if (telemetry.OverheatActive)
			{
				_statusSignals.Add(new StatusSignal(new Vector3(0.22f, -0.3f, 0f), 0.2f, new Color(1f, 0.42f, 0.18f, 1f), 0.96f, 0.13f, 5.6f, 0.03f, 2f, 76f));
			}
			if (flag)
			{
				float alpha = Clamp01(0.72f + num3 * 0.6f);
				_statusSignals.Add(new StatusSignal(new Vector3(0f, 0.18f, 0f), 0.19f, new Color(0.98f, 0.18f, 0.18f, 1f), alpha, 0.1f, 5.4f, 0.02f, 1.8f, -58f));
			}
			if (flag2)
			{
				_statusSignals.Add(new StatusSignal(new Vector3(-0.58f, 0.22f, 0f), 0.13f, new Color(0.96f, 0.42f, 0.86f, 1f), 0.78f, 0.05f, 2.4f, 0.03f, 1.6f, 72f));
			}
			if (flag3)
			{
				_statusSignals.Add(new StatusSignal(new Vector3(0.6f, 0.24f, 0f), 0.13f, new Color(1f, 0.82f, 0.32f, 1f), 0.8f, 0.05f, 2.5f, 0.03f, 1.6f, 56f));
			}
			if (flag4)
			{
				_statusSignals.Add(new StatusSignal(new Vector3(0.58f, 0.9f, 0f), 0.13f, new Color(0.7f, 0.9f, 1f, 1f), 0.78f, 0.05f, 2.7f, 0.03f, 1.7f, -84f));
			}
			if (flag6)
			{
				_statusSignals.Add(new StatusSignal(new Vector3(-0.6f, 0.56f, 0f), 0.14f, new Color(0.54f, 0.86f, 1f, 1f), 0.8f, 0.05f, 2.6f, 0.03f, 1.7f, 34f));
			}
			if (flag7)
			{
				_statusSignals.Add(new StatusSignal(new Vector3(0.18f, 0.96f, 0f), 0.13f, new Color(0.7f, 1f, 0.64f, 1f), 0.78f, 0.06f, 2.8f, 0.04f, 1.9f, 104f));
			}
			if (flag8)
			{
				_statusSignals.Add(new StatusSignal(new Vector3(0.18f, -0.44f, 0f), 0.14f, new Color(1f, 0.68f, 0.24f, 1f), 0.8f, 0.07f, 3f, 0.03f, 1.8f, 52f));
			}
			if (num > 0)
			{
				int num5 = Math.Min(3, num);
				for (int j = 0; j < num5; j++)
				{
					_statusSignals.Add(new StatusSignal(new Vector3(-0.22f + (float)j * 0.16f, 1.06f, 0f), 0.15f, new Color(0.98f, 0.92f, 0.48f, 1f), 0.94f, 0.06f, 3.1f, 0.04f, 1.7f, 54f));
				}
			}
			if (telemetry.CadenceInterval > 0)
			{
				int num6 = Math.Min(4, telemetry.CadenceInterval);
				int num7 = Math.Min(num6, telemetry.CadenceProgress);
				for (int k = 0; k < num6; k++)
				{
					bool flag9 = k < num7;
					bool flag10 = telemetry.CadenceReady && k == num6 - 1;
					Color color = (Color)(flag10 ? new Color(1f, 0.86f, 0.28f, 1f) : (flag9 ? LerpColor(_profile.ThemeColor, WhiteColor, 0.18f) : new Color(0.42f, 0.46f, 0.52f, 1f)));
					_statusSignals.Add(new StatusSignal(new Vector3(0.14f + (float)k * 0.12f, 0.86f, 0f), flag10 ? 0.15f : 0.12f, color, (flag9 || flag10) ? 0.92f : 0.7f, flag10 ? 0.1f : 0.04f, flag10 ? 5f : 2.8f, 0.02f, 1.7f, flag10 ? 74f : 28f));
				}
			}
			if (telemetry.HeatThreshold > 0)
			{
				int num8 = Math.Min(5, telemetry.HeatThreshold);
				int num9 = Math.Min(num8, telemetry.HeatStacks);
				for (int l = 0; l < num8; l++)
				{
					bool flag11 = l < num9;
					Color color2 = (flag11 ? new Color(1f, 0.54f, 0.18f, 1f) : new Color(0.46f, 0.4f, 0.36f, 1f));
					_statusSignals.Add(new StatusSignal(new Vector3(-0.08f + (float)l * 0.1f, -0.4f, 0f), flag11 ? 0.12f : 0.1f, color2, flag11 ? 0.92f : 0.68f, flag11 ? 0.08f : 0.03f, flag11 ? 4.3f : 2.4f, 0.02f, 1.4f, flag11 ? 62f : 18f));
				}
			}
			if (num2 > 0)
			{
				_statusSignals.Add(new StatusSignal(new Vector3(0f, 1.18f, 0f), 0.19f + (float)Math.Min(2, num2) * 0.03f, new Color(0.96f, 0.24f, 0.62f, 1f), 0.96f, 0.12f, 4.8f, 0.05f, 3.1f, 92f));
				if (num2 > 1)
				{
					_statusSignals.Add(new StatusSignal(new Vector3(0.18f, 1.1f, 0f), 0.12f, new Color(1f, 0.48f, 0.74f, 1f), 0.88f, 0.08f, 3.7f, 0.04f, 2.2f, 60f));
				}
			}
		}

		private void EmitPickupCue(CardSpec spec)
		{
			//IL_0050: 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_00d6: 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)
			if (spec?.DraftTags != null && spec.DraftTags.Count != 0)
			{
				IReadOnlyList<string> draftTags = spec.DraftTags;
				if (draftTags.Any((string tag) => string.Equals(tag, "shield", StringComparison.OrdinalIgnoreCase) || string.Equals(tag, "block", StringComparison.OrdinalIgnoreCase) || string.Equals(tag, "parry", StringComparison.OrdinalIgnoreCase)))
				{
					FeedbackCueUtility.PlayCue(((Component)this).transform.position, FeedbackCueKind.Shield, 0.11f, 1.02f);
				}
				else if (draftTags.Any((string tag) => string.Equals(tag, "summon", StringComparison.OrdinalIgnoreCase) || string.Equals(tag, "orbit", StringComparison.OrdinalIgnoreCase) || string.Equals(tag, "ward", StringComparison.OrdinalIgnoreCase) || string.Equals(tag, "helper", StringComparison.OrdinalIgnoreCase) || string.Equals(tag, "minion", StringComparison.OrdinalIgnoreCase)))
				{
					FeedbackCueUtility.PlayCue(((Component)this).transform.position, FeedbackCueKind.Summon, 0.11f, 1.04f);
				}
				else if (draftTags.Any((string tag) => string.Equals(tag, "hazard", StringComparison.OrdinalIgnoreCase) || string.Equals(tag, "zone", StringComparison.OrdinalIgnoreCase) || string.Equals(tag, "mine", StringComparison.OrdinalIgnoreCase) || string.Equals(tag, "remnant", StringComparison.OrdinalIgnoreCase) || string.Equals(tag, "spawn", StringComparison.OrdinalIgnoreCase)))
				{
					FeedbackCueUtility.PlayCue(((Component)this).transform.position, FeedbackCueKind.Hazard, 0.1f);
				}
				else if (draftTags.Any((string tag) => string.Equals(tag, "reload", StringComparison.OrdinalIgnoreCase) || string.Equals(tag, "chamber", StringComparison.OrdinalIgnoreCase) || string.Equals(tag, "weapon mode", StringComparison.OrdinalIgnoreCase) || string.Equals(tag, "teleport", StringComparison.OrdinalIgnoreCase) || string.Equals(tag, "reflect", StringComparison.OrdinalIgnoreCase) || string.Equals(tag, "drill", StringComparison.OrdinalIgnoreCase)))
				{
					FeedbackCueUtility.PlayCue(((Component)this).transform.position, FeedbackCueKind.Ready, 0.1f);
				}
			}
		}

		private void EmitTelemetryCues(PlayerAbilityController.AbilityVisualTelemetry telemetry)
		{
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			if (!_telemetryCueInitialized)
			{
				_telemetryCueInitialized = true;
				_wasChamberReady = telemetry.ChamberReady;
				_wasReloadModeReady = telemetry.ReloadModeReady;
				_wasPerfectParryReady = telemetry.PerfectParryReady;
				_wasOrbitWardActive = telemetry.OrbitWardActive;
				_wasHazardZoneArmed = telemetry.HazardZoneArmed;
				_wasOverheatActive = telemetry.OverheatActive;
				return;
			}
			if (telemetry.ChamberReady && !_wasChamberReady)
			{
				FeedbackCueUtility.PlayCue(((Component)this).transform.position, FeedbackCueKind.Ready, 0.09f, 1.06f);
			}
			if (telemetry.ReloadModeReady && !_wasReloadModeReady)
			{
				FeedbackCueUtility.PlayCue(((Component)this).transform.position, FeedbackCueKind.Ready, 0.1f, 0.94f);
			}
			if (telemetry.PerfectParryReady && !_wasPerfectParryReady)
			{
				FeedbackCueUtility.PlayCue(((Component)this).transform.position, FeedbackCueKind.Shield, 0.1f, 1.08f);
			}
			if (telemetry.OrbitWardActive && !_wasOrbitWardActive)
			{
				FeedbackCueUtility.PlayCue(((Component)this).transform.position, FeedbackCueKind.Summon, 0.1f);
			}
			if (telemetry.HazardZoneArmed && !_wasHazardZoneArmed)
			{
				FeedbackCueUtility.PlayCue(((Component)this).transform.position, FeedbackCueKind.Hazard, 0.08f, 0.96f);
			}
			if (telemetry.OverheatActive && !_wasOverheatActive)
			{
				FeedbackCueUtility.PlayCue(((Component)this).transform.position, FeedbackCueKind.Overheat, 0.12f, 0.92f);
			}
			_wasChamberReady = telemetry.ChamberReady;
			_wasReloadModeReady = telemetry.ReloadModeReady;
			_wasPerfectParryReady = telemetry.PerfectParryReady;
			_wasOrbitWardActive = telemetry.OrbitWardActive;
			_wasHazardZoneArmed = telemetry.HazardZoneArmed;
			_wasOverheatActive = telemetry.OverheatActive;
		}

		private void EnsureStatusGemCount(int desiredCount)
		{
			while (_statusGems.Count > desiredCount)
			{
				int index = _statusGems.Count - 1;
				GameObject val = _statusGems[index];
				if (val != null)
				{
					Object.Destroy((Object)(object)val);
				}
				_statusGems.RemoveAt(index);
			}
			while (_statusGems.Count < desiredCount)
			{
				GameObject val2 = CreateVisualSeed($"BetterRoundsStatusGem_{_statusGems.Count}");
				if (val2 != null)
				{
					_statusGems.Add(val2);
					continue;
				}
				break;
			}
		}

		private void UpdateBurstGems(float deltaTime)
		{
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			for (int num = _burstGems.Count - 1; num >= 0; num--)
			{
				BurstGem value = _burstGems[num];
				value.Age += deltaTime;
				if (value.GameObject == null || value.Age >= value.Lifetime)
				{
					if (value.GameObject != null)
					{
						Object.Destroy((Object)(object)value.GameObject);
					}
					_burstGems.RemoveAt(num);
				}
				else
				{
					float num2 = value.Age / value.Lifetime;
					float num3 = 1f - (float)Math.Pow(1f - num2, 2.0);
					Vector3 position = value.Direction * (value.Speed * num3) + new Vector3(0f, 1f, 0f) * value.VerticalLift * num3;
					SetTransformLocalPosition(value.GameObject.transform, position);
					float num4 = LerpFloat(value.StartScale, value.EndScale, num3);
					value.GameObject.transform.localScale = new Vector3(num4, num4, num4);
					SetTransformLocalRotation(value.GameObject.transform, Quaternion.Euler(0f, 0f, num3 * 540f));
					SetVisualAlpha(value.GameObject, 1f - num2);
					_burstGems[num] = value;
				}
			}
		}

		private GameObject CreateVisualSeed(string name)
		{
			//IL_002f: 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_003c: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: 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)
			GameObject val = ((CardChoiceVisuals.instance != null) ? CardChoiceVisuals.instance.shieldGem : null);
			GameObject val2 = (GameObject)((val != null) ? ((object)Object.Instantiate<GameObject>(val, new Vector3(0f, 0f, 0f), default(Quaternion), (Transform)null)) : ((object)new GameObject()));
			if (val2 == null)
			{
				return null;
			}
			((Object)val2).name = name;
			SetTransformParent(val2.transform, ((Component)this).transform);
			SetTransformLocalPosition(val2.transform, new Vector3(0f, 0f, 0f));
			SetTransformLocalRotation(val2.transform, default(Quaternion));
			val2.transform.localScale = Vector3.one * 0.25f;
			return val2;
		}

		private void SyncTintTarget()
		{
			if (_coloredGun != _gun)
			{
				RestoreProjectileColor();
				_coloredGun = _gun;
				_projectileColorCaptured = _coloredGun != null && TryGetMemberValue<Color>(_coloredGun, "projectileColor", out _baseProjectileColor);
				_projectileColorApplied = false;
				if (_coloredGun != null)
				{
					ApplyProjectileColor();
				}
			}
		}

		private void ApplyProjectileColor()
		{
			//IL_0056: 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_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)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			if (_coloredGun != null && _projectileColorCaptured && !(_baseProjectileColor.a < 0.2f))
			{
				if (_profile.ManagedCards <= 0)
				{
					RestoreProjectileColor();
					return;
				}
				float t = Clamp01(0.22f + _profile.VisualPower * 0.48f);
				Color value = LerpColor(_baseProjectileColor, _profile.ThemeColor, t);
				value.a = MaxFloat(_baseProjectileColor.a, 0.85f);
				SetMemberValue<Color>(_coloredGun, "projectileColor", value);
				_projectileColorApplied = true;
			}
		}

		private void RestoreProjectileColor()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			if (_coloredGun != null && _projectileColorCaptured && _projectileColorApplied)
			{
				SetMemberValue<Color>(_coloredGun, "projectileColor", _baseProjectileColor);
			}
			_projectileColorApplied = false;
		}

		private void ResolveReferences()
		{
			if (_player == null)
			{
				_player = ((Component)this).GetComponent<Player>();
			}
			if (_player != null)
			{
				_data = _player.data ?? ((Component)_player).GetComponent<CharacterData>();
				_gun = ((Component)_player).GetComponentInChildren<Gun>();
			}
		}

		private void ClearVisualObjects()
		{
			for (int i = 0; i < _orbitGems.Count; i++)
			{
				if (_orbitGems[i].GameObject != null)
				{
					Object.Destroy((Object)(object)_orbitGems[i].GameObject);
				}
			}
			for (int j = 0; j < _burstGems.Count; j++)
			{
				if (_burstGems[j].GameObject != null)
				{
					Object.Destroy((Object)(object)_burstGems[j].GameObject);
				}
			}
			for (int k = 0; k < _statusGems.Count; k++)
			{
				if (_statusGems[k] != null)
				{
					Object.Destroy((Object)(object)_statusGems[k]);
				}
			}
			_orbitGems.Clear();
			_burstGems.Clear();
			_statusGems.Clear();
			_statusSignals.Clear();
		}

		private static Color BuildGemTint(Color baseColor, int index, int total)
		{
			//IL_001f: 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_0026: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			float t = ((total <= 1) ? 0.08f : ((float)index / (float)Math.Max(1, total - 1) * 0.26f));
			Color result = LerpColor(baseColor, WhiteColor, t);
			result.a = 0.95f;
			return result;
		}

		private static void ApplyTint(GameObject target, Color color)
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			foreach (object component in GetComponents(target))
			{
				if (component == null)
				{
					continue;
				}
				PropertyInfo property = component.GetType().GetProperty("color", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (property != null && property.CanWrite && property.PropertyType == typeof(Color))
				{
					property.SetValue(component, color, null);
				}
				object obj = component.GetType().GetProperty("material", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(component, null);
				if (obj != null)
				{
					PropertyInfo property2 = obj.GetType().GetProperty("color", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (property2 != null && property2.CanWrite && property2.PropertyType == typeof(Color))
					{
						property2.SetValue(obj, color, null);
					}
				}
			}
		}

		private static void SetVisualAlpha(GameObject target, float alpha)
		{
			//IL_0061: 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_0072: Unknown result type (might be due to invalid IL or missing references)
			//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_00fd: Unknown result type (might be due to invalid IL or missing references)
			foreach (object component in GetComponents(target))
			{
				if (component == null)
				{
					continue;
				}
				PropertyInfo property = component.GetType().GetProperty("color", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (property != null && property.CanWrite && property.PropertyType == typeof(Color))
				{
					Color val = (Color)property.GetValue(component, null);
					val.a = alpha;
					property.SetValue(component, val, null);
				}
				object obj = component.GetType().GetProperty("material", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(component, null);
				if (obj != null)
				{
					PropertyInfo property2 = obj.GetType().GetProperty("color", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (property2 != null && property2.CanWrite && property2.PropertyType == typeof(Color))
					{
						Color val2 = (Color)property2.GetValue(obj, null);
						val2.a = alpha;
						property2.SetValue(obj, val2, null);
					}
				}
			}
		}

		private static IEnumerable GetComponents(GameObject target)
		{
			if (target == null || GetComponentsInChildrenMethod == null || ComponentType == null)
			{
				return Array.Empty<object>();
			}
			return (GetComponentsInChildrenMethod.Invoke(target, new object[2] { ComponentType, true }) as IEnumerable) ?? Array.Empty<object>();
		}

		private static Color ResolveClassColor(CardClass cardClass)
		{
			//IL_0049: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: 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_00ff: 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_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			return (Color)(cardClass switch
			{
				CardClass.Marksman => new Color(0.95f, 0.78f, 0.22f, 1f), 
				CardClass.Bulwark => new Color(0.25f, 0.57f, 0.92f, 1f), 
				CardClass.Skirmisher => new Color(0.6f, 0.9f, 0.88f, 1f), 
				CardClass.Trickster => new Color(0.93f, 0.42f, 0.82f, 1f), 
				CardClass.Demolitionist => new Color(0.95f, 0.4f, 0.24f, 1f), 
				CardClass.Brawler => new Color(0.88f, 0.24f, 0.28f, 1f), 
				CardClass.Arcanist => new Color(0.44f, 0.82f, 1f, 1f), 
				CardClass.Gambler => new Color(0.97f, 0.84f, 0.38f, 1f), 
				CardClass.Wildcard => new Color(0.94f, 0.9f, 0.56f, 1f), 
				CardClass.Troll => new Color(0.92f, 0.28f, 0.3f, 1f), 
				_ => new Color(0.8f, 0.84f, 0.92f, 1f), 
			});
		}

		private static bool TryGetMemberValue<T>(object target, string memberName, out T value)
		{
			value = default(T);
			object memberValue = GetMemberValue(target, memberName);
			if (memberValue == null)
			{
				return false;
			}
			if (memberValue is T val)
			{
				value = val;
				return true;
			}
			try
			{
				value = (T)Convert.ChangeType(memberValue, typeof(T));
				return true;
			}
			catch
			{
				return false;
			}
		}

		private static object GetMemberValue(object target, string memberName)
		{
			Type type = target?.GetType();
			if (type == null)
			{
				return null;
			}
			FieldInfo field = type.GetField(memberName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field != null)
			{
				return field.GetValue(target);
			}
			PropertyInfo property = type.GetProperty(memberName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (property != null && property.GetIndexParameters().Length == 0)
			{
				return property.GetValue(target, null);
			}
			return null;
		}

		private static void SetMemberValue<T>(object target, string memberName, T value)
		{
			Type type = target?.GetType();
			if (type == null)
			{
				return;
			}
			FieldInfo field = type.GetField(memberName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field != null)
			{
				field.SetValue(target, value);
				return;
			}
			PropertyInfo property = type.GetProperty(memberName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (property != null && property.CanWrite && property.GetIndexParameters().Length == 0)
			{
				property.SetValue(target, value, null);
			}
		}

		private static void SetTransformParent(Transform child, Transform parent)
		{
			PropertyInfo propertyInfo = ((object)child)?.GetType().GetProperty("parent", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (propertyInfo != null && propertyInfo.CanWrite)
			{
				propertyInfo.SetValue(child, parent, null);
			}
		}

		private static void SetTransformLocalPosition(Transform transform, Vector3 position)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			PropertyInfo propertyInfo = ((object)transform)?.GetType().GetProperty("localPosition", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (propertyInfo != null && propertyInfo.CanWrite)
			{
				propertyInfo.SetValue(transform, position, null);
			}
		}

		private static void SetTransformLocalRotation(Transform transform, Quaternion rotation)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			PropertyInfo propertyInfo = ((object)transform)?.GetType().GetProperty("localRotation", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (propertyInfo != null && propertyInfo.CanWrite)
			{
				propertyInfo.SetValue(transform, rotation, null);
			}
		}

		private static float Sin(float value)
		{
			return (float)Math.Sin(value);
		}

		private static float Cos(float value)
		{
			return (float)Math.Cos(value);
		}

		private static float DegToRad(float degrees)
		{
			return degrees * (MathF.PI / 180f);
		}

		private static Vector3 BuildDirection(float angleDegrees)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			float value = DegToRad(angleDegrees);
			return new Vector3(Cos(value), Sin(value), 0f);
		}

		private static float Clamp01(float value)
		{
			if (value < 0f)
			{
				return 0f;
			}
			if (value > 1f)
			{
				return 1f;
			}
			return value;
		}

		private static float MaxFloat(float a, float b)
		{
			if (!(a > b))
			{
				return b;
			}
			return a;
		}

		private static int ClampInt(int value, int min, int max)
		{
			if (value < min)
			{
				return min;
			}
			if (value > max)
			{
				return max;
			}
			return value;
		}

		private static float LerpFloat(float a, float b, float t)
		{
			float num = Clamp01(t);
			return a + (b - a) * num;
		}

		private static Color LerpColor(Color a, Color b, float t)
		{
			//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_001d: 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: 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: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			float num = Clamp01(t);
			return new Color(a.r + (b.r - a.r) * num, a.g + (b.g - a.g) * num, a.b + (b.b - a.b) * num, a.a + (b.a - a.a) * num);
		}
	}
}
namespace RoundsPartyPack.Settings
{
	internal static class BetterRoundsSettings
	{
		private delegate int IntValueProvider();

		private delegate bool BoolValueProvider();

		private struct RuntimeSettings
		{
			internal int RoundsToWinGame { get; }

			internal int PointsToWinRound { get; }

			internal int StarterCardsShownPerDraw { get; }

			internal int CardsShownPerDraw { get; }

			internal int StarterCardsSelectedPerDraw { get; }

			internal int CardsSelectedPerDraw { get; }

			internal bool BetterRoundsOnlyDraftPool { get; }

			internal RuntimeSettings(int roundsToWinGame, int pointsToWinRound, int starterCardsShownPerDraw, int cardsShownPerDraw, int starterCardsSelectedPerDraw, int cardsSelectedPerDraw, bool betterRoundsOnlyDraftPool)
			{
				RoundsToWinGame = roundsToWinGame;
				PointsToWinRound = pointsToWinRound;
				StarterCardsShownPerDraw = starterCardsShownPerDraw;
				CardsShownPerDraw = cardsShownPerDraw;
				StarterCardsSelectedPerDraw = starterCardsSelectedPerDraw;
				CardsSelectedPerDraw = cardsSelectedPerDraw;
				BetterRoundsOnlyDraftPool = betterRoundsOnlyDraftPool;
			}
		}

		private interface ISettingBinding
		{
			void Refresh(bool interactable);
		}

		private sealed class SliderBinding : ISettingBinding
		{
			private static readonly MethodInfo SliderSetValueWithoutNotifyMethod = typeof(Slider).GetMethod("SetValueWithoutNotify", BindingFlags.Instance | BindingFlags.Public, null, new Type[1] { typeof(float) }, null);

			private static readonly PropertyInfo SliderValueProperty = typeof(Slider).GetProperty("value", BindingFlags.Instance | BindingFlags.Public);

			private readonly Slider _slider;

			private readonly TMP_InputField _inputField;

			private readonly IntValueProvider _valueProvider;

			internal SliderBinding(Slider slider, TMP_InputField inputField, IntValueProvider valueProvider)
			{
				_slider = slider;
				_inputField = inputField;
				_valueProvider = valueProvider;
			}

			public void Refresh(bool interactable)
			{
				int num = _valueProvider();
				if (SliderSetValueWithoutNotifyMethod != null)
				{
					SliderSetValueWithoutNotifyMethod.Invoke(_slider, new object[1] { (float)num });
				}
				else if (SliderValueProperty != null)
				{
					SliderValueProperty.SetValue(_slider, (float)num, null);
				}
				_slider.interactable = interactable;
				if (_inputField != null)
				{
					_inputField.SetTextWithoutNotify(num.ToString());
					_inputField.interactable = interactable;
					_inputField.readOnly = !interactable;
				}
			}
		}

		private sealed class ToggleBinding : ISettingBinding
		{
			private static readonly MethodInfo ToggleSetIsOnWithoutNotifyMethod = typeof(Component).Assembly.GetType("UnityEngine.UI.Toggle")?.GetMethod("SetIsOnWithoutNotify", BindingFlags.Instance | BindingFlags.Public, null, new Type[1] { typeof(bool) }, null);

			private static readonly PropertyInfo ToggleIsOnProperty = typeof(Component).Assembly.GetType("UnityEngine.UI.Toggle")?.GetProperty("isOn", BindingFlags.Instance | BindingFlags.Public);

			private static readonly PropertyInfo ToggleInteractableProperty = typeof(Component).Assembly.GetType("UnityEngine.UI.Selectable")?.GetProperty("interactable", BindingFlags.Instance | BindingFlags.Public);

			private readonly Component _toggle;

			private readonly BoolValueProvider _valueProvider;

			internal ToggleBinding(Component toggle, BoolValueProvider valueProvider)
			{
				_toggle = toggle;
				_valueProvider = valueProvider;
			}

			public void Refresh(bool interactable)
			{
				if (_toggle != null)
				{
					bool flag = _valueProvider();
					if (ToggleSetIsOnWithoutNotifyMethod != null)
					{
						ToggleSetIsOnWithoutNotifyMethod.Invoke(_toggle, new object[1] { flag });
					}
					else if (ToggleIsOnProperty != null)
					{
						ToggleIsOnProperty.SetValue(_toggle, flag, null);
					}
					ToggleInteractableProperty?.SetValue(_toggle, interactable, null);
				}
			}
		}

		private sealed class SettingsMenuController : MonoBehaviour
		{
			private readonly List<ISettingBinding> _bindings = new List<ISettingBinding>();

			private TextMeshProUGUI _statusText;

			internal void Initialize(TextMeshProUGUI statusText, IEnumerable<ISettingBinding> bindings)
			{
				_statusText = statusText;
				_bindings.Clear();
				_bindings.AddRange(bindings);
				Refresh();
			}

			private void OnEnable()
			{
				Refresh();
			}

			private void Update()
			{
				Refresh();
			}

			private void Refresh()
			{
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				if (_statusText != null)
				{
					_statusText.text = GetRoomStateText();
					_statusText.color = GetRoomStateColor();
				}
				bool interactable = CanEditLiveRoomSettings();
				foreach (ISettingBinding binding in _bindings)
				{
					binding.Refresh(interactable);
				}
			}
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static UnityAction <0>__EmptyMenuAction;

			public static Action<GameObject> <1>__BuildMenu;

			public static Action <2>__OnHandshakeCompleted;

			public static OnLeftDelegate <3>__OnLeftRoom;

			public static Func<IGameModeHandler, IEnumerator> <4>__ApplyMatchSettingsHook;

			public static UnityAction<float> <5>__OnRoundsToWinGameChanged;

			public static UnityAction<float> <6>__OnPointsToWinRoundChanged;

			public static UnityAction<float> <7>__OnStarterCardsShownPerDrawChanged;

			public static UnityAction<float> <8>__OnStarterCardsSelectedPerDrawChanged;

			public static UnityAction<float> <9>__OnCardsShownPerDrawChanged;

			public static UnityAction<float> <10>__OnCardsSelectedPerDrawChanged;

			public static UnityAction<bool> <11>__OnBetterRoundsOnlyDraftPoolChanged;
		}

		private const string ConfigSection = "BetterRounds";

		private const int MinRoundsToWinGame = 1;

		private const int MaxRoundsToWinGame = 99;

		private const int MinPointsToWinRound = 1;

		private const int MaxPointsToWinRound = 99;

		private const int MinCardsShownPerDraw = 1;

		private const int MaxCardsShownPerDraw = 99;

		private const int MinCardsSelectedPerDraw = 1;

		private const int MaxCardsSelectedPerDraw = 99;

		private static ConfigEntry<int> _roundsToWinGameConfig;

		private static ConfigEntry<int> _pointsToWinRoundConfig;

		private static ConfigEntry<int> _starterCardsShownPerDrawConfig;

		private static ConfigEntry<int> _cardsShownPerDrawConfig;

		private static ConfigEntry<int> _starterCardsSelectedPerDrawConfig;

		private static ConfigEntry<int> _cardsSelectedPerDrawConfig;

		private static ConfigEntry<bool> _betterRoundsOnlyDraftPoolConfig;

		private static RuntimeSettings _runtimeSettings;

		private static bool _initialized;

		internal static int GetCardsShownPerDraw(bool starterPhase)
		{
			if (!starterPhase)
			{
				return _runtimeSettings.CardsShownPerDraw;
			}
			return _runtimeSettings.StarterCardsShownPerDraw;
		}

		internal static int GetCardsSelectedPerDraw(bool starterPhase)
		{
			if (!starterPhase)
			{
				return _runtimeSettings.CardsSelectedPerDraw;
			}
			return _runtimeSettings.StarterCardsSelectedPerDraw;
		}

		internal static bool UseBetterRoundsOnlyDraftPool()
		{
			return _runtimeSettings.BetterRoundsOnlyDraftPool;
		}

		internal static void Initialize(BaseUnityPlugin plugin)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Expected O, but got Unknown
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Expected O, but got Unknown
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Expected O, but got Unknown
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Expected O, but got Unknown
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Expected O, but got Unknown
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Expected O, but got Unknown
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Expected O, but got Unknown
			if (!_initialized)
			{
				_initialized = true;
				_roundsToWinGameConfig = plugin.Config.Bind<int>("BetterRounds", "Rounds To Win Game", 5, new ConfigDescription("Rounds needed to win the match.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 99), Array.Empty<object>()));
				_pointsToWinRoundConfig = plugin.Config.Bind<int>("BetterRounds", "Points To Win Round", 2, new ConfigDescription("Points needed to win each round.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 99), Array.Empty<object>()));
				_starterCardsShownPerDrawConfig = plugin.Config.Bind<int>("BetterRounds", "Starter Cards Shown Per Draw", 5, new ConfigDescription("How many cards are shown in the opening game-start draft.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 99), Array.Empty<object>()));
				_cardsShownPerDrawConfig = plugin.Config.Bind<int>("BetterRounds", "Cards Shown Per Draw", 5, new ConfigDescription("How many cards are shown during standard in-match drafts.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 99), Array.Empty<object>()));
				_starterCardsSelectedPerDrawConfig = plugin.Config.Bind<int>("BetterRounds", "Starter Cards Selected Per Draw", 1, new ConfigDescription("How many cards each player gets to take during the opening game-start draft.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 99), Array.Empty<object>()));
				_cardsSelectedPerDrawConfig = plugin.Config.Bind<int>("BetterRounds", "Cards Selected Per Draw", 1, new ConfigDescription("How many cards each player gets to take during standard in-match drafts.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 99), Array.Empty<object>()));
				_betterRoundsOnlyDraftPoolConfig = plugin.Config.Bind<bool>("BetterRounds", "BetterRounds Only Draft Pool", true, new ConfigDescription("When enabled, draft pools only use BetterRounds-managed cards instead of mixing in default base-game cards.", (AcceptableValueBase)null, Array.Empty<object>()));
				LoadRuntimeFromConfig();
				object obj = <>O.<0>__EmptyMenuAction;
				if (obj == null)
				{
					UnityAction val = EmptyMenuAction;
					<>O.<0>__EmptyMenuAction = val;
					obj = (object)val;
				}
				Unbound.RegisterMenu("BetterRounds", (UnityAction)obj, (Action<GameObject>)BuildMenu, (GameObject)null, true);
				Unbound.RegisterHandshake("com.betterrounds.rounds", (Action)OnHandshakeCompleted);
				object obj2 = <>O.<3>__OnLeftRoom;
				if (obj2 == null)
				{
					OnLeftDelegate val2 = OnLeftRoom;
					<>O.<3>__OnLeftRoom = val2;
					obj2 = (object)val2;
				}
				Unbound.OnLeftRoom += (OnLeftDelegate)obj2;
				GameModeManager.AddHook("InitEnd", (Func<IGameModeHandler, IEnumerator>)ApplyMatchSettingsHook, 0);
				GameModeManager.AddHook("GameStart", (Func<IGameModeHandler, IEnumerator>)ApplyMatchSettingsHook, 800);
				ApplyCurrentMatchSettings();
			}
		}

		private static void BuildMenu(GameObject menu)
		{
			List<ISettingBinding> list = new List<ISettingBinding>();
			TextMeshProUGUI val = default(TextMeshProUGUI);
			MenuHandler.CreateText("BetterRounds Settings", menu, ref val, 60, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			MenuHandler.CreateText(" ", menu, ref val, 12, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			TextMeshProUGUI statusText = default(TextMeshProUGUI);
			MenuHandler.CreateText(string.Empty, menu, ref statusText, 26, false, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			MenuHandler.CreateText(" ", menu, ref val, 18, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			MenuHandler.CreateText("Match settings", menu, ref val, 42, false, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			list.Add(CreateSlider(menu, "Rounds to win game", 1, 99, () => _runtimeSettings.RoundsToWinGame, OnRoundsToWinGameChanged));
			list.Add(CreateSlider(menu, "Points to win round", 1, 99, () => _runtimeSettings.PointsToWinRound, OnPointsToWinRoundChanged));
			MenuHandler.CreateText(" ", menu, ref val, 18, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			MenuHandler.CreateText("Opening draft", menu, ref val, 42, false, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			list.Add(CreateSlider(menu, "Starter cards shown", 1, 99, () => _runtimeSettings.StarterCardsShownPerDraw, OnStarterCardsShownPerDrawChanged));
			list.Add(CreateSlider(menu, "Starter cards selected", 1, 99, () => _runtimeSettings.StarterCardsSelectedPerDraw, OnStarterCardsSelectedPerDrawChanged));
			MenuHandler.CreateText(" ", menu, ref val, 18, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			MenuHandler.CreateText("Round drafts", menu, ref val, 42, false, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			list.Add(CreateSlider(menu, "Cards shown", 1, 99, () => _runtimeSettings.CardsShownPerDraw, OnCardsShownPerDrawChanged));
			list.Add(CreateSlider(menu, "Cards selected", 1, 99, () => _runtimeSettings.CardsSelectedPerDraw, OnCardsSelectedPerDrawChanged));
			list.Add(CreateToggle(menu, "BetterRounds-only cards", () => _runtimeSettings.BetterRoundsOnlyDraftPool, OnBetterRoundsOnlyDraftPoolChanged));
			ExtensionMethods.GetOrAddComponent<SettingsMenuController>(menu, false).Initialize(statusText, list);
		}

		private static SliderBinding CreateSlider(GameObject menu, string label, int min, int max, IntValueProvider valueProvider, UnityAction<float> onValueChanged)
		{
			Slider slider = default(Slider);
			TMP_InputField componentInChildren = MenuHandler.CreateSlider(label, menu, 30, (float)min, (float)max, (float)valueProvider(), onValueChanged, ref slider, true, (Color?)null, (Direction)0, false, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null).GetComponentInChildren<TMP_InputField>();
			TextMeshProUGUI val = default(TextMeshProUGUI);
			MenuHandler.CreateText(" ", menu, ref val, 12, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			return new SliderBinding(slider, componentInChildren, valueProvider);
		}

		private static ToggleBinding CreateToggle(GameObject menu, string label, BoolValueProvider valueProvider, UnityAction<bool> onValueChanged)
		{
			GameObject val = MenuHandler.CreateToggle(valueProvider(), label, menu, onValueChanged, 30, false, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			Type type = typeof(Component).Assembly.GetType("UnityEngine.UI.Toggle");
			Component toggle = ((type == null) ? null : val.GetComponent(type));
			TextMeshProUGUI val2 = default(TextMeshProUGUI);
			MenuHandler.CreateText(" ", menu, ref val2, 12, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			return new ToggleBinding(toggle, valueProvider);
		}

		private static void OnRoundsToWinGameChanged(float value)
		{
			_roundsToWinGameConfig.Value = Clamp(Mathf.RoundToInt(value), 1, 99);
			AdoptLocalSettingsIfAuthoritative();
		}

		private static void OnPointsToWinRoundChanged(float value)
		{
			_pointsToWinRoundConfig.Value = Clamp(Mathf.RoundToInt(value), 1, 99);
			AdoptLocalSettingsIfAuthoritative();
		}

		private static void OnStarterCardsShownPerDrawChanged(float value)
		{
			_starterCardsShownPerDrawConfig.Value = Clamp(Mathf.RoundToInt(value), 1, 99);
			AdoptLocalSettingsIfAuthoritative();
		}

		private static void OnCardsShownPerDrawChanged(float value)
		{
			_cardsShownPerDrawConfig.Value = Clamp(Mathf.RoundToInt(value), 1, 99);
			AdoptLocalSettingsIfAuthoritative();
		}

		private static void OnStarterCardsSelectedPerDrawChanged(float value)
		{
			_starterCardsSelectedPerDrawConfig.Value = Clamp(Mathf.RoundToInt(value), 1, 99);
			AdoptLocalSettingsIfAuthoritative();
		}

		private static void OnCardsSelectedPerDrawChanged(float value)
		{
			_cardsSelectedPerDrawConfig.Value = Clamp(Mathf.RoundToInt(value), 1, 99);
			AdoptLocalSettingsIfAuthoritative();
		}

		private static void OnBetterRoundsOnlyDraftPoolChanged(bool value)
		{
			_betterRoundsOnlyDraftPoolConfig.Value = value;
			AdoptLocalSettingsIfAuthoritative();
		}

		private static void AdoptLocalSettingsIfAuthoritative()
		{
			if (CanEditLiveRoomSettings())
			{
				LoadRuntimeFromConfig();
				ApplyCurrentMatchSettings();
				BroadcastRuntimeSettingsIfHost();
			}
		}

		private static void LoadRuntimeFromConfig()
		{
			_runtimeSettings = BuildRuntimeSettings(_roundsToWinGameConfig.Value, _pointsToWinRoundConfig.Value, _starterCardsShownPerDrawConfig.Value, _cardsShownPerDrawConfig.Value, _starterCardsSelectedPerDrawConfig.Value, _cardsSelectedPerDrawConfig.Value, _betterRoundsOnlyDraftPoolConfig.Value);
		}

		private static RuntimeSettings BuildRuntimeSettings(int roundsToWinGame, int pointsToWinRound, int starterCardsShownPerDraw, int cardsShownPerDraw, int starterCardsSelectedPerDraw, int cardsSelectedPerDraw, bool betterRoundsOnlyDraftPool)
		{
			return new RuntimeSettings(Clamp(roundsToWinGame, 1, 99), Clamp(pointsToWinRound, 1, 99), Clamp(starterCardsShownPerDraw, 1, 99), Clamp(cardsShownPerDraw, 1, 99), Clamp(starterCardsSelectedPerDraw, 1, 99), Clamp(cardsSelectedPerDraw, 1, 99), betterRoundsOnlyDraftPool);
		}

		private static void OnHandshakeCompleted()
		{
			if (PhotonNetwork.IsMasterClient)
			{
				ApplyCurrentMatchSettings();
				BroadcastRuntimeSettingsIfHost();
			}
		}

		private static void BroadcastRuntimeSettingsIfHost()
		{
			if (PhotonNetwork.CurrentRoom != null && PhotonNetwork.IsMasterClient)
			{
				NetworkingManager.RPC_Others(typeof(BetterRoundsSettings), "RPC_SyncSettings", new object[7] { _runtimeSettings.RoundsToWinGame, _runtimeSettings.PointsToWinRound, _runtimeSettings.StarterCardsShownPerDraw, _runtimeSettings.CardsShownPerDraw, _runtimeSettings.StarterCardsSelectedPerDraw, _runtimeSettings.CardsSelectedPerDraw, _runtimeSettings.BetterRoundsOnlyDraftPool });
			}
		}

		[UnboundRPC]
		private static void RPC_SyncSettings(int roundsToWinGame, int pointsToWinRound, int starterCardsShownPerDraw, int cardsShownPerDraw, int starterCardsSelectedPerDraw, int cardsSelectedPerDraw, bool betterRoundsOnlyDraftPool)
		{
			_runtimeSettings = BuildRuntimeSettings(roundsToWinGame, pointsToWinRound, starterCardsShownPerDraw, cardsShownPerDraw, starterCardsSelectedPerDraw, cardsSelectedPerDraw, betterRoundsOnlyDraftPool);
			ApplyCurrentMatchSettings();
		}

		private static IEnumerator ApplyMatchSettingsHook(IGameModeHandler gameModeHandler)
		{
			ApplyCurrentMatchSettings();
			yield break;
		}

		private static void ApplyCurrentMatchSettings()
		{
			try
			{
				IGameModeHandler currentHandler = GameModeManager.CurrentHandler;
				if (((currentHandler != null) ? currentHandler.Settings : null) != null)
				{
					if (currentHandler.Settings.ContainsKey("roundsToWinGame"))
					{
						currentHandler.ChangeSetting("roundsToWinGame", (object)_runtimeSettings.RoundsToWinGame);
					}
					if (currentHandler.Settings.ContainsKey("pointsToWinRound"))
					{
						currentHandler.ChangeSetting("pointsToWinRound", (object)_runtimeSettings.PointsToWinRound);
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				if (log != null)
				{
					log.LogWarning((object)("BetterRounds skipped applying match settings: " + ex.GetType().Name));
				}
			}
		}

		private static void OnLeftRoom()
		{
			LoadRuntimeFromConfig();
			ApplyCurrentMatchSettings();
		}

		private static bool CanEditLiveRoomSettings()
		{
			if (!PhotonNetwork.OfflineMode && PhotonNetwork.CurrentRoom != null)
			{
				return PhotonNetwork.IsMasterClient;
			}
			return true;
		}

		private static string GetRoomStateText()
		{
			if (PhotonNetwork.OfflineMode)
			{
				return "Offline match. Changes apply immediately.";
			}
			if (PhotonNetwork.CurrentRoom == null)
			{
				return "Local defaults. These apply offline and when you host a room.";
			}
			if (PhotonNetwork.IsMasterClient)
			{
				int num = Mathf.Max(0, PhotonNetwork.CurrentRoom.PlayerCount - 1);
				if (num <= 0)
				{
					return "You are the host. Changes apply immediately and will sync when others join.";
				}
				return string.Format("You are the host. Live changes sync to {0} other player{1}.", num, (num == 1) ? string.Empty : "s");
			}
			Player masterClient = PhotonNetwork.MasterClient;
			string text = ((masterClient != null) ? masterClient.NickName : null);
			if (string.IsNullOrWhiteSpace(text))
			{
				text = "The host";
			}
			return text + " controls this room. Sliders are locked and show the live host values.";
		}

		private static Color GetRoomStateColor()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			if (!CanEditLiveRoomSettings())
			{
				return new Color(1f, 0.79f, 0.43f, 1f);
			}
			return new Color(0.74f, 0.95f, 0.82f, 1f);
		}

		private static int Clamp(int value, int min, int max)
		{
			return Mathf.Clamp(value, min, max);
		}

		private static void EmptyMenuAction()
		{
		}
	}
}
namespace RoundsPartyPack.Patches
{
	[HarmonyPatch(typeof(Gun), "Attack")]
	internal static class GunAttackAbilityPatch
	{
		private static void Prefix(Gun __instance, ref bool __state)
		{
			__state = PlayerAbilityController.GetOrAdd(PlayerAbilityController.ResolvePlayerFromGun(__instance))?.PrepareAttack() ?? false;
		}

		private static void Postfix(Gun __instance, bool __result, bool __state)
		{
			if (__state)
			{
				PlayerAbilityController.GetOrAdd(PlayerAbilityController.ResolvePlayerFromGun(__instance))?.CompleteAttack(__result);
			}
		}
	}
	[HarmonyPatch(typeof(Block), "blocked")]
	internal static class BlockedAbilityPatch
	{
		private static void Postfix(Block __instance)
		{
			HealthHandler value = Traverse.Create((object)__instance).Field("health").GetValue<HealthHandler>();
			PlayerAbilityController.GetOrAdd(PlayerAbilityController.ResolvePlayerFromCharacterData((value == null) ? null : Traverse.Create((object)value).Field("data").GetValue<CharacterData>()))?.NotifySuccessfulBlock();
		}
	}
	[HarmonyPatch]
	internal static class TakeDamageAbilityPatch
	{
		private struct DamageState
		{
			internal Player DamagingPlayer { get; }

			internal Player DamagedPlayer { get; }

			internal CharacterData DamagedData { get; }

			internal bool Valid { get; }

			internal DamageState(Player damagingPlayer, Player damagedPlayer, CharacterData damagedData)
			{
				DamagingPlayer = damagingPlayer;
				DamagedPlayer = damagedPlayer;
				DamagedData = damagedData;
				Valid = damagingPlayer != null && damagedPlayer != null && damagedData != null;
			}
		}

		private static readonly Type Vector2Type = AccessTools.TypeByName("UnityEngine.Vector2");

		private static readonly Type ColorType = AccessTools.TypeByName("UnityEngine.Color");

		private static readonly Type GameObjectType = AccessTools.TypeByName("UnityEngine.GameObject");

		private static MethodBase TargetMethod()
		{
			if (Vector2Type == null || ColorType == null || GameObjectType == null)
			{
				return null;
			}
			return AccessTools.Method(typeof(HealthHandler), "TakeDamage", new Type[7]
			{
				Vector2Type,
				Vector2Type,
				ColorType,
				GameObjectType,
				typeof(Player),
				typeof(bool),
				typeof(bool)
			}, (Type[])null);
		}

		private static void Prefix(HealthHandler __instance, object[] __args, out DamageState __state)
		{
			__state = default(DamageState);
			if (__args == null || __args.Length < 7)
			{
				return;
			}
			float num = PlayerAbilityController.ReadDamageMagnitude(__args[0]);
			if (num <= 0.001f)
			{
				return;
			}
			CharacterData value = Traverse.Create((object)__instance).Field("data").GetValue<CharacterData>();
			if (value == null || Traverse.Create((object)__instance).Field("isRespawning").GetValue<bool>() || !Traverse.Create((object)value).Field("isPlaying").GetValue<bool>() || Traverse.Create((object)value).Field("dead").GetValue<bool>())
			{
				return;
			}
			object obj = __args[6];
			bool flag = default(bool);
			int num2;
			if (obj is bool)
			{
				flag = (bool)obj;
				num2 = 1;
			}
			else
			{
				num2 = 0;
			}
			int num3 = num2 & (flag ? 1 : 0);
			Block value2 = Traverse.Create((object)value).Field("block").GetValue<Block>();
			if (num3 == 0 && PlayerAbilityController.IsBlocking(value2))
			{
				return;
			}
			Player val = PlayerAbilityController.ResolvePlayerFromCharacterData(value);
			object obj2 = __args[4];
			Player val2 = (Player)((obj2 is Player) ? obj2 : null);
			if (val != null && val2 != null)
			{
				float num4 = PlayerExposureStatusController.GetOrAdd(val)?.GetDamageTakenMultiplier(val2) ?? 1f;
				if (num4 > 1.001f)
				{
					__args[0] = PlayerAbilityController.ScaleDamageArgument(__args[0], num4);
					num *= num4;
				}
			}
			PlayerAbilityController.GetOrAdd(val)?.NotifyDamageTaken(num);
			PlayerAbilityController.GetOrAdd(val2)?.NotifyDamageDealt(num, val);
			__state = new DamageState(val2, val, value);
		}

		private static void Postfix(DamageState __state)
		{
			if (__state.Valid && __state.DamagedPlayer != __state.DamagingPlayer && Traverse.Create((object)__state.DamagedData).Field("dead").GetValue<bool>())
			{
				PlayerAbilityController.GetOrAdd(__state.DamagingPlayer)?.NotifyKillConfirmed(__state.DamagedPlayer);
			}
		}
	}
	[HarmonyPatch(typeof(CardChoice), "DoPick", new Type[]
	{
		typeof(int),
		typeof(int),
		typeof(PickerType)
	})]
	internal static class CardChoiceDoPickPatch
	{
		private static void Prefix(CardChoice __instance, int __1)
		{
			try
			{
				DraftEngine.PreparePickPool(__instance, __1);
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				if (log != null)
				{
					log.LogWarning((object)("BetterRounds skipped pick-pool curation: " + ex.GetType().Name));
				}
			}
		}

		private static void Postfix(int __1, PickerType __2)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				PickFlowController.TrackPicker(__1, __2);
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				if (log != null)
				{
					log.LogWarning((object)("BetterRounds skipped pick tracking: " + ex.GetType().Name));
				}
			}
		}
	}
	[HarmonyPatch(typeof(CardChoice), "Spawn")]
	internal static class CardChoiceSpawnPatch
	{
		private static void Postfix(ref GameObject __result)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (__result != null)
				{
					__result.transform.localScale = PickOfferLayout.GetScale(PickOfferLayout.GetDisplayedCardCount());
					PhotonView component = __result.GetComponent<PhotonView>();
					if (component != null && PhotonNetwork.CurrentRoom != null)
					{
						NetworkingManager.RPC_Others(typeof(CardChoiceSpawnPatch), "RPC_ApplyRemoteScale", new object[1] { component.ViewID });
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				if (log != null)
				{
					log.LogWarning((object)("BetterRounds skipped card spawn scaling: " + ex.GetType().Name));
				}
			}
		}

		[UnboundRPC]
		private static void RPC_ApplyRemoteScale(int viewId)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			PhotonView val = PhotonView.Find(viewId);
			if (val != null)
			{
				((Component)val).gameObject.transform.localScale = PickOfferLayout.GetScale(PickOfferLayout.GetDisplayedCardCount());
			}
		}
	}
	[HarmonyPatch(typeof(CardChoice), "StartPick")]
	internal static class CardChoiceStartPickPatch
	{
		private static void Prefix(CardChoice __instance)
		{
			//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_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: 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_0125: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Transform[] value = Traverse.Create((object)__instance).Field("children").GetValue<Transform[]>();
				if (value == null || value.Length == 0)
				{
					return;
				}
				Transform val = value[0];
				if (val == null)
				{
					return;
				}
				Transform[] array = value.Skip(1).ToArray();
				foreach (Transform val2 in array)
				{
					if (val2 != null)
					{
						Object.Destroy((Object)(object)((Component)val2).gameObject);
					}
				}
				int displayedCardCount = PickOfferLayout.GetDisplayedCardCount();
				if (displayedCardCount <= 0)
				{
					return;
				}
				List<Vector3> worldPositions = PickOfferLayout.GetWorldPositions(displayedCardCount);
				List<Quaternion> rotations = PickOfferLayout.GetRotations(displayedCardCount);
				if (worldPositions.Count < displayedCardCount || rotations.Count < displayedCardCount)
				{
					return;
				}
				Vector3 scale = PickOfferLayout.GetScale(displayedCardCount);
				List<Transform> list = new List<Transform> { val };
				val.position = worldPositions[0];
				val.rotation = rotations[0];
				val.localScale = scale;
				for (int j = 1; j < displayedCardCount; j++)
				{
					GameObject val3 = Object.Instantiate<GameObject>(((Component)val).gameObject, worldPositions[j], rotations[j], ((Component)__instance).transform);
					if (val3 != null)
					{
						((Object)val3).name = list.Count.ToString();
						val3.transform.localScale = scale;
						list.Add(val3.transform);
					}
				}
				Traverse.Create((object)__instance).Field("children").SetValue((object)list.ToArray());
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				if (log != null)
				{
					log.LogWarning((object)("BetterRounds skipped card-offer relayout: " + ex.GetType().Name));
				}
			}
		}
	}
}
namespace RoundsPartyPack.Framework
{
	internal static class AbilityCardEffects
	{
		internal static CardEffectModule CounterCharge(float damageMultiplier, float speedMultiplier)
		{
			return new CounterChargeEffect(damageMultiplier, speedMultiplier);
		}

		internal static CardEffectModule FirstShotBonus(float damageMultiplier, float speedMultiplier)
		{
			return new FirstShotBonusEffect(damageMultiplier, speedMultiplier);
		}

		internal static CardEffectModule LastBulletBonus(float damageMultiplier, float speedMultiplier)
		{
			return new LastBulletBonusEffect(damageMultiplier, speedMultiplier);
		}

		internal static CardEffectModule LastShell(float damageMultiplier, float speedMultiplier, float projectileSizeMultiplier, bool unblockable)
		{
			return new LastShellEffect(damageMultiplier, speedMultiplier, projectileSizeMultiplier, unblockable);
		}

		internal static CardEffectModule ReloadCharge(float damageMultiplier, float speedMultiplier, float projectileSizeMultiplier, bool unblockable)
		{
			return new ReloadChargeEffect(damageMultiplier, speedMultiplier, projectileSizeMultiplier, unblockable);
		}

		internal static CardEffectModule KillCharge(float damageMultiplier, float speedMultiplier, float projectileSizeMultiplier, bool unblockable)
		{
			return new KillChargeEffect(damageMultiplier, speedMultiplier, projectileSizeMultiplier, unblockable);
		}

		internal static CardEffectModule MissCharge(float damageMultiplier, float speedMultiplier, float projectileSizeMultiplier, bool unblockable)
		{
			return new MissChargeEffect(damageMultiplier, speedMultiplier, projectileSizeMultiplier, unblockable);
		}

		internal static CardEffectModule AirborneBonus(float damageMultiplier, float speedMultiplier)
		{
			return new AirborneBonusEffect(damageMultiplier, speedMultiplier);
		}

		internal static CardEffectModule BlockAmmo(int ammoGain)
		{
			return new BlockAmmoEffect(ammoGain);
		}

		internal static CardEffectModule BlockTempo(float duration, float movementMultiplier, float reloadMultiplier)
		{
			return new BlockTempoEffect(duration, movementMultiplier, reloadMultiplier);
		}

		internal static CardEffectModule BlockGhost(float damageMultiplier, float speedMultiplier, float projectileSizeMultiplier, bool unblockable)
		{
			return new BlockGhostEffect(damageMultiplier, speedMultiplier, projectileSizeMultiplier, unblockable);
		}

		internal static CardEffectModule PerfectParry(float readyWindowSeconds, float damageMultiplier, float speedMultiplier, float projectileSizeMultiplier, bool unblockable)
		{
			return new PerfectParryEffect(readyWindowSeconds, damageMultiplier, speedMultiplier, projectileSizeMultiplier, unblockable);
		}

		internal static CardEffectModule ChamberedRound(float damageMultiplier, float speedMultiplier, float projectileSizeMultiplier, bool unblockable)
		{
			return new ChamberedRoundEffect(damageMultiplier, speedMultiplier, projectileSizeMultiplier, unblockable);
		}

		internal static CardEffectModule EmptyMagRush(float duration, float movementMultiplier, float reloadMultiplier)
		{
			return new EmptyMagRushEffect(duration, movementMultiplier, reloadMultiplier);
		}

		internal static CardEffectModule LowHealthStance(float healthFractionThreshold, float damageMultiplier, float movementMultiplier, float reloadMultiplier, float lifestealFraction)
		{
			return new LowHealthStanceEffect(healthFractionThreshold, damageMultiplier, movementMultiplier, reloadMultiplier, lifestealFraction);
		}

		internal static CardEffectModule GroundedStance(float damageMultiplier, float movementMultiplier, float reloadMultiplier)
		{
			return new GroundedStanceEffect(damageMultiplier, movementMultiplier, reloadMultiplier);
		}

		internal static CardEffectModule WallStance(float wallDistance, float damageMultiplier, float speedMultiplier, float reloadMultiplier)
		{
			return new WallStanceEffect(wallDistance, damageMultiplier, speedMultiplier, reloadMultiplier);
		}

		internal static CardEffectModule PatientShot(float readyDelay, float damageMultiplier, float speedMultiplier)
		{
			return new PatientShotEffect(readyDelay, damageMultiplier, speedMultiplier);
		}

		internal static CardEffectModule ChainShot(float window, float damageStep, float speedStep, int maxStacks)
		{
			return new ChainShotEffect(window, damageStep, speedStep, maxStacks);
		}

		internal static Ca