Decompiled source of CrimsonGauntlet v0.1.1

CrimsonGauntlet.dll

Decompiled 4 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.Json;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using CrimsonGauntlet.Services;
using CrimsonGauntlet.Structs;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using ProjectM;
using ProjectM.Network;
using Stunlock.Core;
using Unity.Collections;
using Unity.Entities;
using UnityEngine;
using VAMP;
using VAMP.Models;
using VAMP.Services;
using VAMP.Structs;
using VAMP.Utilities;
using VampireCommandFramework;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("CrimsonGauntlet")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Roll dice in local chat to resolve disputes!")]
[assembly: AssemblyFileVersion("0.1.1.0")]
[assembly: AssemblyInformationalVersion("0.1.1+1.Branch.master.Sha.634542462f8de7553847cf1f2f2812d2d2d9881f.634542462f8de7553847cf1f2f2812d2d2d9881f")]
[assembly: AssemblyProduct("CrimsonGauntlet")]
[assembly: AssemblyTitle("CrimsonGauntlet")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 CrimsonGauntlet
{
	[BepInPlugin("CrimsonGauntlet", "CrimsonGauntlet", "0.1.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BasePlugin
	{
		private Harmony _harmony;

		public static Plugin Instance { get; private set; }

		public static Harmony Harmony => Instance._harmony;

		public static ManualLogSource LogInstance => ((BasePlugin)Instance).Log;

		public static Settings Settings { get; private set; }

		public static string ConfigFiles => Path.Combine(Paths.ConfigPath, "CrimsonGauntlet");

		public static RewardService RewardService { get; private set; }

		public static Scheduler Scheduler { get; private set; }

		public override void Load()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			Instance = this;
			Settings = default(Settings);
			if (Settings.InitConfig())
			{
				Scheduler = new Scheduler();
				_harmony = new Harmony("CrimsonGauntlet");
				_harmony.PatchAll(Assembly.GetExecutingAssembly());
				CommandRegistry.RegisterAll();
				Events.OnCoreLoaded = (Action)Delegate.Combine(Events.OnCoreLoaded, new Action(Loaded));
			}
		}

		public void Loaded()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Expected O, but got Unknown
			//IL_008b: 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_00aa: Expected O, but got Unknown
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Expected O, but got Unknown
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Expected O, but got Unknown
			RewardService = new RewardService();
			EventTrigger val = (EventTrigger)(Scheduler.GauntletSchedule.Count <= 0);
			EventTrigger val2 = (EventTrigger)(Scheduler.VGauntletSchedule.Count <= 0);
			EventTrigger val3 = (EventTrigger)(Scheduler.MobGauntletSchedule.Count <= 0);
			if (Settings.ToggleMixed.Value)
			{
				EventScheduler.Register(new Event(GauntletService.guid, "Gauntlet", val, Scheduler.GauntletSchedule.ToArray(), Settings.MinimumPlayers.Value));
			}
			if (Settings.ToggleVBloods.Value)
			{
				EventScheduler.Register(new Event(GauntletService.guid, "VBlood Gauntlet", val2, Scheduler.VGauntletSchedule.ToArray(), Settings.MinimumPlayers.Value));
			}
			if (Settings.ToggleMob.Value)
			{
				EventScheduler.Register(new Event(GauntletService.guid, "Mob Gauntlet", val3, Scheduler.MobGauntletSchedule.ToArray(), Settings.MinimumPlayers.Value));
			}
			EventScheduler.OnEventStarted = (Action<Event>)Delegate.Combine(EventScheduler.OnEventStarted, new Action<Event>(GauntletService.StartEvent));
			ManualLogSource log = ((BasePlugin)this).Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(27, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("Plugin ");
				((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>("CrimsonGauntlet");
				((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" version ");
				((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>("0.1.1");
				((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" is loaded!");
			}
			log.LogInfo(val4);
		}

		public override bool Unload()
		{
			CommandRegistry.UnregisterAssembly();
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			return true;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "CrimsonGauntlet";

		public const string PLUGIN_NAME = "CrimsonGauntlet";

		public const string PLUGIN_VERSION = "0.1.1";
	}
}
namespace CrimsonGauntlet.Structs
{
	public struct EventReward
	{
		public int ItemHash { get; set; }

		public int ItemQuantity { get; set; }

		public EventReward(int itemHash, int itemQuantity)
		{
			ItemHash = itemHash;
			ItemQuantity = itemQuantity;
		}

		public EventReward()
		{
			ItemHash = 0;
			ItemQuantity = 0;
		}
	}
	public class Scheduler
	{
		public static readonly string ConfigFiles = Path.Combine(Paths.ConfigPath, "EventScheduler");

		private static string GauntletPath = Path.Combine(ConfigFiles, "Gauntlet_Schedule.json");

		private static string VGauntletPath = Path.Combine(ConfigFiles, "VBlood_Gauntlet_Schedule.json");

		private static string MobGauntletPath = Path.Combine(ConfigFiles, "Mob_Gauntlet_Schedule.json");

		public static List<ScheduleEntry> GauntletSchedule;

		public static List<ScheduleEntry> VGauntletSchedule;

		public static List<ScheduleEntry> MobGauntletSchedule;

		public Scheduler()
		{
			if (!Directory.Exists(ConfigFiles))
			{
				Directory.CreateDirectory(ConfigFiles);
			}
			LoadOrCreateSchedule(GauntletPath, out GauntletSchedule, 0);
			LoadOrCreateSchedule(VGauntletPath, out VGauntletSchedule, 1);
			LoadOrCreateSchedule(MobGauntletPath, out MobGauntletSchedule, 2);
		}

		private void LoadOrCreateSchedule(string filePath, out List<ScheduleEntry> schedule, int templateId)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			if (File.Exists(filePath))
			{
				try
				{
					List<ScheduleEntry> list = JsonSerializer.Deserialize<List<ScheduleEntry>>(File.ReadAllText(filePath));
					if (list != null)
					{
						schedule = list;
					}
					else
					{
						schedule = new List<ScheduleEntry>();
					}
					return;
				}
				catch (Exception ex)
				{
					ManualLogSource logInstance = Plugin.LogInstance;
					bool flag = default(bool);
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(30, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error loading schedule from ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(filePath);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
					}
					logInstance.LogError(val);
					schedule = new List<ScheduleEntry>();
					return;
				}
			}
			schedule = CreateTemplateEntries(templateId);
			SaveSchedule(filePath, schedule);
		}

		private List<ScheduleEntry> CreateTemplateEntries(int i = 0)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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_0074: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Expected O, but got Unknown
			return i switch
			{
				0 => new List<ScheduleEntry>(), 
				1 => new List<ScheduleEntry>
				{
					new ScheduleEntry
					{
						DayOfWeek = DayOfWeek.Saturday,
						Hour = 20,
						Minute = 0
					},
					new ScheduleEntry
					{
						DayOfWeek = DayOfWeek.Wednesday,
						Hour = 19,
						Minute = 30
					}
				}, 
				2 => new List<ScheduleEntry>
				{
					new ScheduleEntry
					{
						DayOfWeek = null,
						Hour = 12,
						Minute = 0
					}
				}, 
				_ => new List<ScheduleEntry>(), 
			};
		}

		public static void SaveSchedule(string filePath, List<ScheduleEntry> schedule)
		{
			string contents = JsonSerializer.Serialize(schedule, new JsonSerializerOptions
			{
				WriteIndented = true
			});
			File.WriteAllText(filePath, contents);
		}
	}
	[StructLayout(LayoutKind.Sequential, Size = 1)]
	public readonly struct Settings
	{
		private static readonly List<string> OrderedSections = new List<string> { "Config", "Types", "Options" };

		public static ConfigEntry<bool> ToggleMod { get; private set; }

		public static ConfigEntry<bool> ToggleMixed { get; private set; }

		public static ConfigEntry<bool> ToggleVBloods { get; private set; }

		public static ConfigEntry<bool> ToggleMob { get; private set; }

		public static ConfigEntry<int> MinimumPlayers { get; private set; }

		public static ConfigEntry<int> TimeLimit { get; private set; }

		public static ConfigEntry<int> ScoreUpdates { get; private set; }

		public static ConfigEntry<bool> ScoresPrivate { get; private set; }

		public static ConfigEntry<int> StealPercentage { get; private set; }

		public static ConfigEntry<bool> KillConfirmed { get; private set; }

		public static bool InitConfig()
		{
			ToggleMod = InitConfigEntry(OrderedSections[0], "ToggleMod", defaultValue: true, "ToggleMod = true");
			ToggleMixed = InitConfigEntry(OrderedSections[1], "MixedGauntlet", defaultValue: true, "Enable mixed Gauntlet events. Both mobs and V Bloods are valid targets (Default mode).");
			ToggleVBloods = InitConfigEntry(OrderedSections[1], "VBloodGauntlet", defaultValue: false, "Enable V Blood-only Gauntlet events. Only V Bloods are valid targets.");
			ToggleMob = InitConfigEntry(OrderedSections[1], "MobGauntlet", defaultValue: false, "Enable mob-only Gauntlet events. Only mobs are valid targets.");
			MinimumPlayers = InitConfigEntry(OrderedSections[2], "MinimumPlayers", 2, "The minimum number of players required to start an event.");
			TimeLimit = InitConfigEntry(OrderedSections[2], "EventLength", 15, "The length of an event (minutes).");
			ScoreUpdates = InitConfigEntry(OrderedSections[2], "ScoreUpdates", 5, " Interval (minutes) between players' chat gauntlet score announcements during the event. Set to 0 to only announce the winner.");
			ScoresPrivate = InitConfigEntry(OrderedSections[2], "ScoresPrivate", defaultValue: false, "If this is true, each player will receive their current placement and score in the event privately. Otherwise, the top 10 players will be announced in Global chat.");
			StealPercentage = InitConfigEntry(OrderedSections[2], "StealPercentage", 30, "The percentage of a player's score that is stolen when killed by another player. For example, setting 30 would be 30% of their score.");
			KillConfirmed = InitConfigEntry(OrderedSections[2], "KillConfirmed", defaultValue: true, "If this is true, fully draining the slain vampire of their blood (full kill) will be required to steal score. Otherwise, simply downing them is enough to steal score.");
			ReorderConfigSections();
			return ToggleMod.Value;
		}

		private static ConfigEntry<T> InitConfigEntry<T>(string section, string key, T defaultValue, string description)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			ConfigEntry<T> val = ((BasePlugin)Plugin.Instance).Config.Bind<T>(section, key, defaultValue, description);
			string text = Path.Combine(Paths.ConfigPath, "CrimsonGauntlet.cfg");
			ConfigEntry<T> val2 = default(ConfigEntry<T>);
			if (File.Exists(text) && new ConfigFile(text, true).TryGetEntry<T>(section, key, ref val2))
			{
				val.Value = val2.Value;
			}
			return val;
		}

		private static void ReorderConfigSections()
		{
			string path = Path.Combine(Paths.ConfigPath, "CrimsonGauntlet.cfg");
			if (!File.Exists(path))
			{
				return;
			}
			List<string> list = File.ReadAllLines(path).ToList();
			Dictionary<string, List<string>> dictionary = new Dictionary<string, List<string>>();
			string text = "";
			foreach (string item in list)
			{
				if (item.StartsWith("["))
				{
					text = item.Trim('[', ']');
					dictionary[text] = new List<string> { item };
				}
				else if (!string.IsNullOrWhiteSpace(text))
				{
					dictionary[text].Add(item);
				}
			}
			using StreamWriter streamWriter = new StreamWriter(path, append: false);
			foreach (string orderedSection in OrderedSections)
			{
				if (!dictionary.ContainsKey(orderedSection))
				{
					continue;
				}
				foreach (string item2 in dictionary[orderedSection])
				{
					streamWriter.WriteLine(item2);
				}
				streamWriter.WriteLine();
			}
		}
	}
}
namespace CrimsonGauntlet.Services
{
	public static class GauntletService
	{
		public enum GauntletType
		{
			Mixed,
			VBlood,
			Mob
		}

		public static Guid guid;

		public static Dictionary<ulong, int> Scores;

		public static GauntletType Type;

		private static bool gauntletActive;

		public static void StartEvent(Event e)
		{
			if (!(e.id != guid))
			{
				if (e.name == "VBlood Gauntlet")
				{
					Type = GauntletType.VBlood;
				}
				else if (e.name == "Mob Gauntlet")
				{
					Type = GauntletType.Mob;
				}
				else
				{
					Type = GauntletType.Mixed;
				}
				StartEvent();
			}
		}

		public static void StartEvent()
		{
			if (!gauntletActive)
			{
				Scores = new Dictionary<ulong, int>();
				gauntletActive = true;
				ChatUtil.SystemSendAll(Type switch
				{
					GauntletType.VBlood => "VBlood Gauntlet", 
					GauntletType.Mob => "Mob Gauntlet", 
					_ => "Gauntlet", 
				} + " Event has started!");
				Core.StartCoroutine(Loop());
			}
		}

		public static bool IsActive()
		{
			return gauntletActive;
		}

		public static void AddScore(ulong id, int value)
		{
			if (!Scores.ContainsKey(id))
			{
				Scores.Add(id, 0);
			}
			Scores[id] += value;
		}

		public static void StealScore(ulong killer, ulong killed)
		{
			if (Settings.StealPercentage.Value != 0 && Scores.ContainsKey(killed))
			{
				int value = Settings.StealPercentage.Value;
				int num = (int)((float)Scores[killed] * ((float)value / 100f));
				if (!Scores.ContainsKey(killer))
				{
					Scores.Add(killer, 0);
				}
				Scores[killer] += num;
				Scores[killed] -= num;
			}
		}

		public static IEnumerator Loop()
		{
			int minutesPassed = 0;
			while (gauntletActive)
			{
				yield return (object)new WaitForSeconds(60f);
				minutesPassed++;
				if (minutesPassed >= Settings.TimeLimit.Value)
				{
					gauntletActive = false;
					RewardWinner();
				}
				else if (Settings.ScoreUpdates.Value > 0 && minutesPassed % Settings.ScoreUpdates.Value == 0)
				{
					UpdateInterval();
				}
			}
		}

		private static void UpdateInterval()
		{
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			List<KeyValuePair<ulong, int>> list = Scores.OrderByDescending((KeyValuePair<ulong, int> s) => s.Value).ToList();
			if (Settings.ScoresPrivate.Value)
			{
				Player val = default(Player);
				foreach (KeyValuePair<ulong, int> score in Scores)
				{
					if (PlayerService.TryFindBySteam(score.Key, ref val))
					{
						int value = list.FindIndex((KeyValuePair<ulong, int> s) => s.Key == score.Key) + 1;
						ChatUtil.SystemSendUser(EntityUtil.Read<User>(val.User), $"You are currently placed {value} with {score.Value} points.");
					}
				}
				return;
			}
			IEnumerable<string> values = list.Take(10).Select(delegate(KeyValuePair<ulong, int> keyValuePair, int index)
			{
				string value2 = "Unknown";
				Player val2 = default(Player);
				if (PlayerService.TryFindBySteam(keyValuePair.Key, ref val2))
				{
					value2 = val2.Name;
				}
				return $"{index + 1}. {value2}: {keyValuePair.Value} points";
			});
			ChatUtil.SystemSendAll("Gauntlet Event Standings:\n" + string.Join("\n", values));
		}

		private static void RewardWinner()
		{
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			List<KeyValuePair<ulong, int>> source = Scores.OrderByDescending((KeyValuePair<ulong, int> s) => s.Value).ToList();
			IEnumerable<string> values = source.Take(10).Select(delegate(KeyValuePair<ulong, int> score, int index)
			{
				string value = "Unknown";
				Player val3 = default(Player);
				if (PlayerService.TryFindBySteam(score.Key, ref val3))
				{
					value = val3.Name;
				}
				return $"{index + 1}. {value}: {score.Value} points";
			});
			ChatUtil.SystemSendAll("Gauntlet Final Standings:\n" + string.Join("\n", values));
			Player val = default(Player);
			if (PlayerService.TryFindBySteam(source.First().Key, ref val))
			{
				Entity val2 = default(Entity);
				foreach (EventReward reward in RewardService.Rewards)
				{
					ItemUtil.AddItemToInventory(val.Character, new PrefabGUID(reward.ItemHash), reward.ItemQuantity, ref val2, true, 0, true);
				}
			}
			Type = GauntletType.Mixed;
		}
	}
	public class RewardService
	{
		private static readonly JsonSerializerOptions prettyJsonOptions = new JsonSerializerOptions
		{
			WriteIndented = true,
			IncludeFields = true
		};

		public static string RewardsFile = Path.Combine(Plugin.ConfigFiles, "Rewards.json");

		public static List<EventReward> Rewards { get; set; }

		public RewardService()
		{
			CreateRewardFile();
			LoadFile();
		}

		public static void CreateRewardFile()
		{
			if (!Directory.Exists(Plugin.ConfigFiles))
			{
				Directory.CreateDirectory(Plugin.ConfigFiles);
			}
			if (!File.Exists(RewardsFile))
			{
				Rewards = new List<EventReward>(2)
				{
					new EventReward(714007172, 1),
					new EventReward(-305440546, 1)
				};
				string contents = JsonSerializer.Serialize(Rewards, prettyJsonOptions);
				File.WriteAllText(RewardsFile, contents);
			}
		}

		public static void LoadFile()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			try
			{
				Rewards = JsonSerializer.Deserialize<List<EventReward>>(File.ReadAllText(RewardsFile));
			}
			catch (Exception ex)
			{
				ManualLogSource logInstance = Plugin.LogInstance;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(28, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error loading rewards file: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
				}
				logInstance.LogError(val);
				Rewards = new List<EventReward>();
			}
		}
	}
}
namespace CrimsonGauntlet.Patches
{
	[HarmonyPatch]
	internal static class DeathEventListenerSystemPatch
	{
		private static readonly PrefabGUID siegeGolem = new PrefabGUID(914043867);

		[HarmonyPatch(typeof(DeathEventListenerSystem), "OnUpdate")]
		[HarmonyPostfix]
		private static void OnUpdatePostfix(DeathEventListenerSystem __instance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: 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_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Expected O, but got Unknown
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: 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_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: 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_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: 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_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			EntityQuery deathEventQuery = __instance._DeathEventQuery;
			NativeArray<DeathEvent> val = ((EntityQuery)(ref deathEventQuery)).ToComponentDataArray<DeathEvent>(AllocatorHandle.op_Implicit((Allocator)2));
			try
			{
				Enumerator<DeathEvent> enumerator = val.GetEnumerator();
				UnitLevel val2 = default(UnitLevel);
				while (enumerator.MoveNext())
				{
					DeathEvent current = enumerator.Current;
					if (!GauntletService.IsActive() || !EntityUtil.Has<PlayerCharacter>(current.Killer))
					{
						continue;
					}
					Entity userEntity = EntityUtil.Read<PlayerCharacter>(current.Killer).UserEntity;
					if (EntityUtil.Has<PlayerCharacter>(current.Killer) && EntityUtil.Has<PlayerCharacter>(current.Died))
					{
						Entity userEntity2 = EntityUtil.Read<PlayerCharacter>(current.Died).UserEntity;
						GauntletService.StealScore(EntityUtil.Read<User>(userEntity).PlatformId, EntityUtil.Read<User>(userEntity2).PlatformId);
					}
					else
					{
						if (!EntityUtil.TryGetComponent<UnitLevel>(current.Died, ref val2))
						{
							continue;
						}
						if (EntityUtil.Has<VBloodUnit>(current.Died))
						{
							if (GauntletService.Type != GauntletService.GauntletType.Mob)
							{
								GauntletService.AddScore(EntityUtil.Read<User>(userEntity).PlatformId, ModifiableInt.op_Implicit(val2.Level));
							}
						}
						else if (EntityUtil.Has<AggroConsumer>(current.Died) && GauntletService.Type != GauntletService.GauntletType.VBlood)
						{
							GauntletService.AddScore(EntityUtil.Read<User>(userEntity).PlatformId, ModifiableInt.op_Implicit(val2.Level));
						}
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource logInstance = Plugin.LogInstance;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(44, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Exited DeathEventListenerSystem hook early: ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<Exception>(ex);
				}
				logInstance.LogInfo(val3);
			}
			finally
			{
				val.Dispose();
			}
		}
	}
}
namespace CrimsonGauntlet.Commands
{
	[CommandGroup("gauntlet", null)]
	internal static class EventCommands
	{
		[Command("StartMixed", "mixed", null, null, null, true)]
		public static void StartMixedGauntlet(ChatCommandContext ctx)
		{
			GauntletService.Type = GauntletService.GauntletType.Mixed;
			GauntletService.StartEvent();
		}

		[Command("StartVBlood", "vblood", null, null, null, true)]
		public static void StartVBloodGauntlet(ChatCommandContext ctx)
		{
			GauntletService.Type = GauntletService.GauntletType.VBlood;
			GauntletService.StartEvent();
		}

		[Command("StartMob", "mob", null, null, null, true)]
		public static void StartMobGauntlet(ChatCommandContext ctx)
		{
			GauntletService.Type = GauntletService.GauntletType.Mob;
			GauntletService.StartEvent();
		}
	}
}