Decompiled source of CompetitiveSurvival v1.0.0

plugins/CompetitiveSurvival/CompetitiveSurvival.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using EntityStates.GoldGat;
using Microsoft.CodeAnalysis;
using On.EntityStates.GoldGat;
using On.RoR2;
using On.RoR2.UI;
using R2API.Networking;
using R2API.Networking.Interfaces;
using R2API.Utils;
using RoR2;
using RoR2.UI;
using UnityEngine;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("CompetitiveSurvival")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CompetitiveSurvival")]
[assembly: AssemblyTitle("CompetitiveSurvival")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: UnverifiableCode]
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 CompetitiveSurvival
{
	internal sealed class Allocation
	{
		private readonly List<CharacterMaster> masters = new List<CharacterMaster>();

		private readonly List<double> weights = new List<double>();

		public double Total => weights.Sum();

		public static Allocation Single(CharacterMaster master)
		{
			if (!Object.op_Implicit((Object)(object)master))
			{
				return null;
			}
			Allocation allocation = new Allocation();
			allocation.Add(master, 1.0);
			return allocation;
		}

		public void Add(CharacterMaster master, double weight)
		{
			if (Object.op_Implicit((Object)(object)master) && weight > 0.0)
			{
				int num = masters.IndexOf(master);
				if (num < 0)
				{
					masters.Add(master);
					weights.Add(weight);
				}
				else
				{
					weights[num] += weight;
				}
			}
		}

		public void AddAll(Allocation other)
		{
			if (other != null)
			{
				for (int i = 0; i < other.masters.Count; i++)
				{
					Add(other.masters[i], other.weights[i]);
				}
			}
		}

		public List<KeyValuePair<CharacterMaster, ulong>> Split(ulong total)
		{
			List<KeyValuePair<CharacterMaster, ulong>> list = new List<KeyValuePair<CharacterMaster, ulong>>();
			double total2 = Total;
			if (total == 0L || total2 <= 0.0)
			{
				return list;
			}
			ulong[] array = new ulong[masters.Count];
			List<KeyValuePair<int, double>> list2 = new List<KeyValuePair<int, double>>();
			ulong num = 0uL;
			for (int i = 0; i < masters.Count; i++)
			{
				double num2 = (double)total * (weights[i] / total2);
				array[i] = (ulong)Math.Floor(num2);
				num += array[i];
				list2.Add(new KeyValuePair<int, double>(i, num2 - (double)array[i]));
			}
			foreach (KeyValuePair<int, double> item in from r in list2
				orderby r.Value descending, r.Key
				select r)
			{
				if (num >= total)
				{
					break;
				}
				array[item.Key]++;
				num++;
			}
			for (int num3 = 0; num3 < masters.Count; num3++)
			{
				if (array[num3] != 0)
				{
					list.Add(new KeyValuePair<CharacterMaster, ulong>(masters[num3], array[num3]));
				}
			}
			return list;
		}
	}
	internal static class Attribution
	{
		private static readonly List<Allocation> stack = new List<Allocation>();

		private static readonly HashSet<string> reported = new HashSet<string>();

		public static Allocation Current => (stack.Count > 0) ? stack[stack.Count - 1] : null;

		public static void Push(Allocation allocation)
		{
			stack.Add(allocation);
		}

		public static void Pop()
		{
			if (stack.Count > 0)
			{
				stack.RemoveAt(stack.Count - 1);
			}
		}

		public static CharacterMaster ResolvePlayer(CharacterMaster master)
		{
			int num = 0;
			while (Object.op_Implicit((Object)(object)master) && num < 8)
			{
				if (Object.op_Implicit((Object)(object)master.playerCharacterMasterController))
				{
					return master;
				}
				CharacterMaster val = (Object.op_Implicit((Object)(object)master.minionOwnership) ? master.minionOwnership.ownerMaster : null);
				if (!Object.op_Implicit((Object)(object)val) || (Object)(object)val == (Object)(object)master)
				{
					break;
				}
				master = val;
				num++;
			}
			return null;
		}

		public static CharacterMaster PlayerOf(GameObject gameObject)
		{
			if (!Object.op_Implicit((Object)(object)gameObject))
			{
				return null;
			}
			CharacterBody val = gameObject.GetComponent<CharacterBody>();
			if (!Object.op_Implicit((Object)(object)val))
			{
				val = gameObject.GetComponentInParent<CharacterBody>();
			}
			return Object.op_Implicit((Object)(object)val) ? ResolvePlayer(val.master) : null;
		}

		public static CharacterMaster PlayerOf(Component component)
		{
			return Object.op_Implicit((Object)(object)component) ? PlayerOf(component.gameObject) : null;
		}

		public static IEnumerable<CharacterMaster> PlayerMasters()
		{
			foreach (PlayerCharacterMasterController pcmc in PlayerCharacterMasterController.instances)
			{
				if (Object.op_Implicit((Object)(object)pcmc) && Object.op_Implicit((Object)(object)pcmc.master))
				{
					yield return pcmc.master;
				}
			}
		}

		public static void ReportUnattributed(string what)
		{
			string text = "unknown";
			try
			{
				StackFrame[] array = new StackTrace().GetFrames() ?? new StackFrame[0];
				foreach (StackFrame stackFrame in array)
				{
					MethodBase method = stackFrame.GetMethod();
					if (!(method == null))
					{
						string text2 = ((method.DeclaringType != null) ? (method.DeclaringType.FullName ?? "") : "");
						if (!text2.StartsWith("CompetitiveSurvival") && !text2.StartsWith("System.") && !text2.StartsWith("MonoMod") && !text2.StartsWith("On.") && !method.Name.StartsWith("DMD<") && !method.Name.Contains("GiveTeam"))
						{
							text = text2 + "." + method.Name;
							break;
						}
					}
				}
			}
			catch
			{
			}
			if (reported.Add(what + "|" + text))
			{
				Log.Info("Team " + what + " from '" + text + "' could not be attributed to a player; vanilla behaviour used.", "C:\\doshy\\Projects\\bro-vs-bro-mods\\(RiskofRain2) CompetitiveSurvival\\CompetitiveSurvival\\Attribution.cs", 141);
			}
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("doshyw.CompetitiveSurvival", "CompetitiveSurvival", "1.0.0")]
	public class CompetitiveSurvivalPlugin : BaseUnityPlugin
	{
		public const string PluginGUID = "doshyw.CompetitiveSurvival";

		public const string PluginAuthor = "doshyw";

		public const string PluginName = "CompetitiveSurvival";

		public const string PluginVersion = "1.0.0";

		public void Awake()
		{
			Log.Init(((BaseUnityPlugin)this).Logger);
			NetworkingAPI.RegisterMessageType<SyncPersonalXpMessage>();
		}

		private void OnEnable()
		{
			DamageTracker.Enable();
			PersonalGold.Enable();
			PersonalExperience.Enable();
			Log.Info("CompetitiveSurvival 1.0.0 enabled: personal gold (damage-share kills) and personal XP/levels.", "C:\\doshy\\Projects\\bro-vs-bro-mods\\(RiskofRain2) CompetitiveSurvival\\CompetitiveSurvival\\CompetitiveSurvivalPlugin.cs", 55);
		}

		private void OnDisable()
		{
			PersonalExperience.Disable();
			PersonalGold.Disable();
			DamageTracker.Disable();
		}
	}
	internal static class DamageTracker
	{
		private sealed class Frame
		{
			public HealthComponent victim;

			public CharacterMaster attacker;

			public float before;

			public float innerSameVictim;

			public bool consumed;
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static hook_TakeDamage <0>__HealthComponent_TakeDamage;
		}

		private static readonly List<Frame> inFlight = new List<Frame>();

		private static readonly ConditionalWeakTable<HealthComponent, Allocation> recorded = new ConditionalWeakTable<HealthComponent, Allocation>();

		public static void Enable()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			object obj = <>O.<0>__HealthComponent_TakeDamage;
			if (obj == null)
			{
				hook_TakeDamage val = HealthComponent_TakeDamage;
				<>O.<0>__HealthComponent_TakeDamage = val;
				obj = (object)val;
			}
			HealthComponent.TakeDamage += (hook_TakeDamage)obj;
		}

		public static void Disable()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			object obj = <>O.<0>__HealthComponent_TakeDamage;
			if (obj == null)
			{
				hook_TakeDamage val = HealthComponent_TakeDamage;
				<>O.<0>__HealthComponent_TakeDamage = val;
				obj = (object)val;
			}
			HealthComponent.TakeDamage -= (hook_TakeDamage)obj;
		}

		private static void HealthComponent_TakeDamage(orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo)
		{
			Frame frame = new Frame
			{
				victim = self,
				attacker = ((damageInfo != null) ? Attribution.PlayerOf(damageInfo.attacker) : null),
				before = (Object.op_Implicit((Object)(object)self) ? self.combinedHealth : 0f)
			};
			inFlight.Add(frame);
			try
			{
				orig.Invoke(self, damageInfo);
			}
			finally
			{
				inFlight.RemoveAt(inFlight.Count - 1);
				Record(frame);
			}
		}

		private static float Dealt(Frame f)
		{
			if (!Object.op_Implicit((Object)(object)f.victim))
			{
				return 0f;
			}
			float num = f.before - f.victim.combinedHealth;
			return (num > 0f) ? num : 0f;
		}

		private static void Record(Frame f)
		{
			float num = Dealt(f);
			Frame frame = ((inFlight.Count > 0) ? inFlight[inFlight.Count - 1] : null);
			if (frame != null && (Object)(object)frame.victim == (Object)(object)f.victim)
			{
				frame.innerSameVictim += num;
			}
			if (f.consumed || !Object.op_Implicit((Object)(object)f.attacker) || !Object.op_Implicit((Object)(object)f.victim))
			{
				return;
			}
			float num2 = num - f.innerSameVictim;
			if (num2 > 0f)
			{
				recorded.GetValue(f.victim, (HealthComponent _) => new Allocation()).Add(f.attacker, num2);
			}
		}

		public static Allocation TakeShares(HealthComponent victim)
		{
			Allocation allocation = new Allocation();
			if (!Object.op_Implicit((Object)(object)victim))
			{
				return allocation;
			}
			if (recorded.TryGetValue(victim, out var value))
			{
				allocation.AddAll(value);
				recorded.Remove(victim);
			}
			float num = 0f;
			for (int num2 = inFlight.Count - 1; num2 >= 0; num2--)
			{
				Frame frame = inFlight[num2];
				if (!((Object)(object)frame.victim != (Object)(object)victim) && !frame.consumed)
				{
					float num3 = Dealt(frame);
					float num4 = num3 - frame.innerSameVictim - num;
					if (Object.op_Implicit((Object)(object)frame.attacker) && num4 > 0f)
					{
						allocation.Add(frame.attacker, num4);
					}
					num = num3;
					frame.consumed = true;
				}
			}
			return allocation;
		}
	}
	internal static class Log
	{
		private static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		private static string Format(object data, string file, int line)
		{
			string fileName = Path.GetFileName(file);
			return $"[{fileName}:{line}] {data}";
		}

		internal static void Debug(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogDebug((object)Format(data, file, line));
		}

		internal static void Error(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogError((object)Format(data, file, line));
		}

		internal static void Fatal(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogFatal((object)Format(data, file, line));
		}

		internal static void Info(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogInfo((object)Format(data, file, line));
		}

		internal static void Message(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogMessage((object)Format(data, file, line));
		}

		internal static void Warning(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogWarning((object)Format(data, file, line));
		}
	}
	internal static class PersonalExperience
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Action<Run> <0>__OnRunStart;

			public static Action<Run, PlayerCharacterMasterController> <1>__OnPlayerJoined;

			public static Action<Stage> <2>__OnServerStageBegin;

			public static hook_AwardExperience <3>__ExperienceManager_AwardExperience;

			public static hook_FixedUpdate <4>__ExperienceManager_FixedUpdate;

			public static hook_GiveTeamExperience <5>__TeamManager_GiveTeamExperience;

			public static hook_GiveExperience <6>__CharacterMaster_GiveExperience;

			public static hook_GiveMoneyWithOnLevelUpFreeUnlock <7>__CharacterMaster_GiveMoneyWithOnLevelUpFreeUnlock;

			public static hook_GetTeamLevel <8>__TeamManager_GetTeamLevel;

			public static hook_RecalculateStats <9>__CharacterBody_RecalculateStats;

			public static hook_FireBullet <10>__GoldGatFire_FireBullet;

			public static hook_Update <11>__ExpBar_Update;

			public static hook_GetTeamExperience <12>__TeamManager_GetTeamExperience;

			public static hook_GetTeamCurrentLevelExperience <13>__TeamManager_GetTeamCurrentLevelExperience;

			public static hook_GetTeamNextLevelExperience <14>__TeamManager_GetTeamNextLevelExperience;

			public static Action <15>__FlushSend;
		}

		private static readonly Dictionary<CharacterMaster, ulong> xp = new Dictionary<CharacterMaster, ulong>();

		private static readonly Dictionary<CharacterMaster, uint> knownLevel = new Dictionary<CharacterMaster, uint>();

		private static readonly List<CharacterMaster> levelContext = new List<CharacterMaster>();

		private static readonly List<CharacterMaster> hudContext = new List<CharacterMaster>();

		private static int orbDeliveryDepth;

		private static bool sendQueued;

		public static void Enable()
		{
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			//IL_0095: 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_00a0: Expected O, but got Unknown
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Expected O, but got Unknown
			//IL_00d7: 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_00e2: Expected O, but got Unknown
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Expected O, but got Unknown
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Expected O, but got Unknown
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Expected O, but got Unknown
			//IL_015b: 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_0166: Expected O, but got Unknown
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Expected O, but got Unknown
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Expected O, but got Unknown
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Expected O, but got Unknown
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Expected O, but got Unknown
			Run.onRunStartGlobal += OnRunStart;
			Run.onPlayerFirstCreatedServer += OnPlayerJoined;
			Stage.onServerStageBegin += OnServerStageBegin;
			object obj = <>O.<3>__ExperienceManager_AwardExperience;
			if (obj == null)
			{
				hook_AwardExperience val = ExperienceManager_AwardExperience;
				<>O.<3>__ExperienceManager_AwardExperience = val;
				obj = (object)val;
			}
			ExperienceManager.AwardExperience += (hook_AwardExperience)obj;
			object obj2 = <>O.<4>__ExperienceManager_FixedUpdate;
			if (obj2 == null)
			{
				hook_FixedUpdate val2 = ExperienceManager_FixedUpdate;
				<>O.<4>__ExperienceManager_FixedUpdate = val2;
				obj2 = (object)val2;
			}
			ExperienceManager.FixedUpdate += (hook_FixedUpdate)obj2;
			object obj3 = <>O.<5>__TeamManager_GiveTeamExperience;
			if (obj3 == null)
			{
				hook_GiveTeamExperience val3 = TeamManager_GiveTeamExperience;
				<>O.<5>__TeamManager_GiveTeamExperience = val3;
				obj3 = (object)val3;
			}
			TeamManager.GiveTeamExperience += (hook_GiveTeamExperience)obj3;
			object obj4 = <>O.<6>__CharacterMaster_GiveExperience;
			if (obj4 == null)
			{
				hook_GiveExperience val4 = CharacterMaster_GiveExperience;
				<>O.<6>__CharacterMaster_GiveExperience = val4;
				obj4 = (object)val4;
			}
			CharacterMaster.GiveExperience += (hook_GiveExperience)obj4;
			object obj5 = <>O.<7>__CharacterMaster_GiveMoneyWithOnLevelUpFreeUnlock;
			if (obj5 == null)
			{
				hook_GiveMoneyWithOnLevelUpFreeUnlock val5 = CharacterMaster_GiveMoneyWithOnLevelUpFreeUnlock;
				<>O.<7>__CharacterMaster_GiveMoneyWithOnLevelUpFreeUnlock = val5;
				obj5 = (object)val5;
			}
			CharacterMaster.GiveMoneyWithOnLevelUpFreeUnlock += (hook_GiveMoneyWithOnLevelUpFreeUnlock)obj5;
			object obj6 = <>O.<8>__TeamManager_GetTeamLevel;
			if (obj6 == null)
			{
				hook_GetTeamLevel val6 = TeamManager_GetTeamLevel;
				<>O.<8>__TeamManager_GetTeamLevel = val6;
				obj6 = (object)val6;
			}
			TeamManager.GetTeamLevel += (hook_GetTeamLevel)obj6;
			object obj7 = <>O.<9>__CharacterBody_RecalculateStats;
			if (obj7 == null)
			{
				hook_RecalculateStats val7 = CharacterBody_RecalculateStats;
				<>O.<9>__CharacterBody_RecalculateStats = val7;
				obj7 = (object)val7;
			}
			CharacterBody.RecalculateStats += (hook_RecalculateStats)obj7;
			object obj8 = <>O.<10>__GoldGatFire_FireBullet;
			if (obj8 == null)
			{
				hook_FireBullet val8 = GoldGatFire_FireBullet;
				<>O.<10>__GoldGatFire_FireBullet = val8;
				obj8 = (object)val8;
			}
			GoldGatFire.FireBullet += (hook_FireBullet)obj8;
			object obj9 = <>O.<11>__ExpBar_Update;
			if (obj9 == null)
			{
				hook_Update val9 = ExpBar_Update;
				<>O.<11>__ExpBar_Update = val9;
				obj9 = (object)val9;
			}
			ExpBar.Update += (hook_Update)obj9;
			object obj10 = <>O.<12>__TeamManager_GetTeamExperience;
			if (obj10 == null)
			{
				hook_GetTeamExperience val10 = TeamManager_GetTeamExperience;
				<>O.<12>__TeamManager_GetTeamExperience = val10;
				obj10 = (object)val10;
			}
			TeamManager.GetTeamExperience += (hook_GetTeamExperience)obj10;
			object obj11 = <>O.<13>__TeamManager_GetTeamCurrentLevelExperience;
			if (obj11 == null)
			{
				hook_GetTeamCurrentLevelExperience val11 = TeamManager_GetTeamCurrentLevelExperience;
				<>O.<13>__TeamManager_GetTeamCurrentLevelExperience = val11;
				obj11 = (object)val11;
			}
			TeamManager.GetTeamCurrentLevelExperience += (hook_GetTeamCurrentLevelExperience)obj11;
			object obj12 = <>O.<14>__TeamManager_GetTeamNextLevelExperience;
			if (obj12 == null)
			{
				hook_GetTeamNextLevelExperience val12 = TeamManager_GetTeamNextLevelExperience;
				<>O.<14>__TeamManager_GetTeamNextLevelExperience = val12;
				obj12 = (object)val12;
			}
			TeamManager.GetTeamNextLevelExperience += (hook_GetTeamNextLevelExperience)obj12;
		}

		public static void Disable()
		{
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Expected O, but got Unknown
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Expected O, but got Unknown
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Expected O, but got Unknown
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Expected O, but got Unknown
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Expected O, but got Unknown
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Expected O, but got Unknown
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Expected O, but got Unknown
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Expected O, but got Unknown
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Expected O, but got Unknown
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Expected O, but got Unknown
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Expected O, but got Unknown
			Run.onRunStartGlobal -= OnRunStart;
			Run.onPlayerFirstCreatedServer -= OnPlayerJoined;
			Stage.onServerStageBegin -= OnServerStageBegin;
			if (sendQueued)
			{
				RoR2Application.onNextUpdate -= FlushSend;
				sendQueued = false;
			}
			object obj = <>O.<3>__ExperienceManager_AwardExperience;
			if (obj == null)
			{
				hook_AwardExperience val = ExperienceManager_AwardExperience;
				<>O.<3>__ExperienceManager_AwardExperience = val;
				obj = (object)val;
			}
			ExperienceManager.AwardExperience -= (hook_AwardExperience)obj;
			object obj2 = <>O.<4>__ExperienceManager_FixedUpdate;
			if (obj2 == null)
			{
				hook_FixedUpdate val2 = ExperienceManager_FixedUpdate;
				<>O.<4>__ExperienceManager_FixedUpdate = val2;
				obj2 = (object)val2;
			}
			ExperienceManager.FixedUpdate -= (hook_FixedUpdate)obj2;
			object obj3 = <>O.<5>__TeamManager_GiveTeamExperience;
			if (obj3 == null)
			{
				hook_GiveTeamExperience val3 = TeamManager_GiveTeamExperience;
				<>O.<5>__TeamManager_GiveTeamExperience = val3;
				obj3 = (object)val3;
			}
			TeamManager.GiveTeamExperience -= (hook_GiveTeamExperience)obj3;
			object obj4 = <>O.<6>__CharacterMaster_GiveExperience;
			if (obj4 == null)
			{
				hook_GiveExperience val4 = CharacterMaster_GiveExperience;
				<>O.<6>__CharacterMaster_GiveExperience = val4;
				obj4 = (object)val4;
			}
			CharacterMaster.GiveExperience -= (hook_GiveExperience)obj4;
			object obj5 = <>O.<7>__CharacterMaster_GiveMoneyWithOnLevelUpFreeUnlock;
			if (obj5 == null)
			{
				hook_GiveMoneyWithOnLevelUpFreeUnlock val5 = CharacterMaster_GiveMoneyWithOnLevelUpFreeUnlock;
				<>O.<7>__CharacterMaster_GiveMoneyWithOnLevelUpFreeUnlock = val5;
				obj5 = (object)val5;
			}
			CharacterMaster.GiveMoneyWithOnLevelUpFreeUnlock -= (hook_GiveMoneyWithOnLevelUpFreeUnlock)obj5;
			object obj6 = <>O.<8>__TeamManager_GetTeamLevel;
			if (obj6 == null)
			{
				hook_GetTeamLevel val6 = TeamManager_GetTeamLevel;
				<>O.<8>__TeamManager_GetTeamLevel = val6;
				obj6 = (object)val6;
			}
			TeamManager.GetTeamLevel -= (hook_GetTeamLevel)obj6;
			object obj7 = <>O.<9>__CharacterBody_RecalculateStats;
			if (obj7 == null)
			{
				hook_RecalculateStats val7 = CharacterBody_RecalculateStats;
				<>O.<9>__CharacterBody_RecalculateStats = val7;
				obj7 = (object)val7;
			}
			CharacterBody.RecalculateStats -= (hook_RecalculateStats)obj7;
			object obj8 = <>O.<10>__GoldGatFire_FireBullet;
			if (obj8 == null)
			{
				hook_FireBullet val8 = GoldGatFire_FireBullet;
				<>O.<10>__GoldGatFire_FireBullet = val8;
				obj8 = (object)val8;
			}
			GoldGatFire.FireBullet -= (hook_FireBullet)obj8;
			object obj9 = <>O.<11>__ExpBar_Update;
			if (obj9 == null)
			{
				hook_Update val9 = ExpBar_Update;
				<>O.<11>__ExpBar_Update = val9;
				obj9 = (object)val9;
			}
			ExpBar.Update -= (hook_Update)obj9;
			object obj10 = <>O.<12>__TeamManager_GetTeamExperience;
			if (obj10 == null)
			{
				hook_GetTeamExperience val10 = TeamManager_GetTeamExperience;
				<>O.<12>__TeamManager_GetTeamExperience = val10;
				obj10 = (object)val10;
			}
			TeamManager.GetTeamExperience -= (hook_GetTeamExperience)obj10;
			object obj11 = <>O.<13>__TeamManager_GetTeamCurrentLevelExperience;
			if (obj11 == null)
			{
				hook_GetTeamCurrentLevelExperience val11 = TeamManager_GetTeamCurrentLevelExperience;
				<>O.<13>__TeamManager_GetTeamCurrentLevelExperience = val11;
				obj11 = (object)val11;
			}
			TeamManager.GetTeamCurrentLevelExperience -= (hook_GetTeamCurrentLevelExperience)obj11;
			object obj12 = <>O.<14>__TeamManager_GetTeamNextLevelExperience;
			if (obj12 == null)
			{
				hook_GetTeamNextLevelExperience val12 = TeamManager_GetTeamNextLevelExperience;
				<>O.<14>__TeamManager_GetTeamNextLevelExperience = val12;
				obj12 = (object)val12;
			}
			TeamManager.GetTeamNextLevelExperience -= (hook_GetTeamNextLevelExperience)obj12;
		}

		private static void ExperienceManager_AwardExperience(orig_AwardExperience orig, ExperienceManager self, Vector3 origin, CharacterBody body, ulong amount)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Invalid comparison between Unknown and I4
			if (NetworkServer.active && !SuppressExperience.suppressExperience && Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)body.master) && (int)body.master.teamIndex == 1)
			{
				Allocation to = Attribution.Current ?? Allocation.Single(Attribution.ResolvePlayer(body.master));
				Credit(to, amount);
			}
			orig.Invoke(self, origin, body, amount);
		}

		private static void ExperienceManager_FixedUpdate(orig_FixedUpdate orig, ExperienceManager self)
		{
			orbDeliveryDepth++;
			try
			{
				orig.Invoke(self);
			}
			finally
			{
				orbDeliveryDepth--;
			}
		}

		private static void TeamManager_GiveTeamExperience(orig_GiveTeamExperience orig, TeamManager self, TeamIndex teamIndex, ulong experience)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			if ((int)teamIndex != 1)
			{
				orig.Invoke(self, teamIndex, experience);
			}
			else if (orbDeliveryDepth <= 0)
			{
				Allocation current = Attribution.Current;
				if (current == null)
				{
					Attribution.ReportUnattributed("XP (given in full to every player, as vanilla shared XP would)");
				}
				Credit(current, experience);
			}
		}

		private static void CharacterMaster_GiveExperience(orig_GiveExperience orig, CharacterMaster self, ulong amount)
		{
			Attribution.Push(Allocation.Single(Attribution.ResolvePlayer(self)) ?? Attribution.Current);
			try
			{
				orig.Invoke(self, amount);
			}
			finally
			{
				Attribution.Pop();
			}
		}

		private static void CharacterMaster_GiveMoneyWithOnLevelUpFreeUnlock(orig_GiveMoneyWithOnLevelUpFreeUnlock orig, CharacterMaster self, uint amount)
		{
			Attribution.Push(Allocation.Single(Attribution.ResolvePlayer(self)) ?? Attribution.Current);
			try
			{
				orig.Invoke(self, amount);
			}
			finally
			{
				Attribution.Pop();
			}
		}

		private static void Credit(Allocation to, ulong amount)
		{
			if (amount == 0)
			{
				return;
			}
			if (to != null)
			{
				foreach (KeyValuePair<CharacterMaster, ulong> item in to.Split(ScaleForPlayerCount(amount)))
				{
					CreditOne(item.Key, item.Value);
				}
			}
			else
			{
				foreach (CharacterMaster item2 in Attribution.PlayerMasters().ToList())
				{
					CreditOne(item2, amount);
				}
			}
			QueueSend();
			OnLevelsMaybeChanged();
		}

		private static ulong ScaleForPlayerCount(ulong amount)
		{
			ulong num = (ulong)Math.Max(1, PlayerCharacterMasterController.instances.Count);
			return (amount > ulong.MaxValue / num) ? ulong.MaxValue : (amount * num);
		}

		private static void CreditOne(CharacterMaster master, ulong amount)
		{
			if (Object.op_Implicit((Object)(object)master))
			{
				xp.TryGetValue(master, out var value);
				ulong num = value + amount;
				xp[master] = ((num < value) ? ulong.MaxValue : num);
				master.TrackBeadExperience(amount);
			}
		}

		public static ulong XpOf(CharacterMaster master)
		{
			ulong value;
			return (Object.op_Implicit((Object)(object)master) && xp.TryGetValue(master, out value)) ? value : 0;
		}

		public static uint LevelOf(CharacterMaster master)
		{
			return TeamManager.FindLevelForExperience(XpOf(master));
		}

		private static uint LevelForMaster(CharacterMaster master)
		{
			CharacterMaster val = Attribution.ResolvePlayer(master);
			if (Object.op_Implicit((Object)(object)val))
			{
				return LevelOf(val);
			}
			uint num = 1u;
			foreach (CharacterMaster item in Attribution.PlayerMasters())
			{
				num = Math.Max(num, LevelOf(item));
			}
			return num;
		}

		private static uint TeamManager_GetTeamLevel(orig_GetTeamLevel orig, TeamManager self, TeamIndex teamIndex)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Invalid comparison between Unknown and I4
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Invalid comparison between Unknown and I4
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			CharacterMaster val = ((levelContext.Count > 0) ? levelContext[levelContext.Count - 1] : null);
			if ((int)teamIndex != 1 || !Object.op_Implicit((Object)(object)val) || (int)val.teamIndex != 1 || OverrideTeamLevel.GetTeamLevelOverride(teamIndex).HasValue)
			{
				return orig.Invoke(self, teamIndex);
			}
			return LevelForMaster(val);
		}

		private static void CharacterBody_RecalculateStats(orig_RecalculateStats orig, CharacterBody self)
		{
			levelContext.Add(Object.op_Implicit((Object)(object)self) ? self.master : null);
			try
			{
				orig.Invoke(self);
			}
			finally
			{
				levelContext.RemoveAt(levelContext.Count - 1);
			}
		}

		private static void GoldGatFire_FireBullet(orig_FireBullet orig, GoldGatFire self)
		{
			levelContext.Add(((BaseGoldGatState)(self?)).bodyMaster);
			try
			{
				orig.Invoke(self);
			}
			finally
			{
				levelContext.RemoveAt(levelContext.Count - 1);
			}
		}

		private static void ExpBar_Update(orig_Update orig, ExpBar self)
		{
			hudContext.Add(Object.op_Implicit((Object)(object)self) ? self.source : null);
			try
			{
				orig.Invoke(self);
			}
			finally
			{
				hudContext.RemoveAt(hudContext.Count - 1);
			}
		}

		private static CharacterMaster HudOwner(TeamIndex teamIndex)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			if ((int)teamIndex != 1 || hudContext.Count == 0)
			{
				return null;
			}
			return Attribution.ResolvePlayer(hudContext[hudContext.Count - 1]);
		}

		private static ulong TeamManager_GetTeamExperience(orig_GetTeamExperience orig, TeamManager self, TeamIndex teamIndex)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			CharacterMaster val = HudOwner(teamIndex);
			return Object.op_Implicit((Object)(object)val) ? XpOf(val) : orig.Invoke(self, teamIndex);
		}

		private static ulong TeamManager_GetTeamCurrentLevelExperience(orig_GetTeamCurrentLevelExperience orig, TeamManager self, TeamIndex teamIndex)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			CharacterMaster val = HudOwner(teamIndex);
			return Object.op_Implicit((Object)(object)val) ? TeamManager.GetExperienceForLevel(LevelOf(val)) : orig.Invoke(self, teamIndex);
		}

		private static ulong TeamManager_GetTeamNextLevelExperience(orig_GetTeamNextLevelExperience orig, TeamManager self, TeamIndex teamIndex)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			CharacterMaster val = HudOwner(teamIndex);
			return Object.op_Implicit((Object)(object)val) ? TeamManager.GetExperienceForLevel(LevelOf(val) + 1) : orig.Invoke(self, teamIndex);
		}

		private static void OnLevelsMaybeChanged()
		{
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Invalid comparison between Unknown and I4
			bool flag = false;
			bool flag2 = false;
			LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
			CharacterMaster val = ((firstLocalUser != null) ? firstLocalUser.cachedMaster : null);
			foreach (CharacterMaster item in Attribution.PlayerMasters())
			{
				uint num = LevelOf(item);
				if (!knownLevel.TryGetValue(item, out var value))
				{
					value = 1u;
				}
				if (num != value)
				{
					knownLevel[item] = num;
					flag = true;
					if (num > value && (Object)(object)item == (Object)(object)val)
					{
						flag2 = true;
					}
				}
			}
			if (!flag)
			{
				return;
			}
			foreach (CharacterMaster readOnlyInstances in CharacterMaster.readOnlyInstancesList)
			{
				if (Object.op_Implicit((Object)(object)readOnlyInstances) && (int)readOnlyInstances.teamIndex == 1)
				{
					CharacterBody body = readOnlyInstances.GetBody();
					if (Object.op_Implicit((Object)(object)body))
					{
						body.OnTeamLevelChanged();
					}
				}
			}
			if (flag2)
			{
				GlobalEventManager.OnTeamLevelUp((TeamIndex)1);
			}
		}

		private static void OnRunStart(Run run)
		{
			xp.Clear();
			knownLevel.Clear();
		}

		private static void QueueSend()
		{
			if (!sendQueued && NetworkServer.active)
			{
				sendQueued = true;
				RoR2Application.onNextUpdate += FlushSend;
			}
		}

		private static void FlushSend()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			sendQueued = false;
			if (!NetworkServer.active)
			{
				return;
			}
			List<SyncPersonalXpMessage.Entry> list = new List<SyncPersonalXpMessage.Entry>();
			foreach (CharacterMaster item in Attribution.PlayerMasters())
			{
				list.Add(new SyncPersonalXpMessage.Entry(((NetworkBehaviour)item).netId, XpOf(item)));
			}
			NetMessageExtensions.Send((INetMessage)(object)new SyncPersonalXpMessage(list), (NetworkDestination)1);
		}

		private static void OnPlayerJoined(Run run, PlayerCharacterMasterController player)
		{
			QueueSend();
		}

		private static void OnServerStageBegin(Stage stage)
		{
			QueueSend();
		}

		public static void ApplyFromHost(List<SyncPersonalXpMessage.Entry> entries)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkServer.active || entries == null)
			{
				return;
			}
			xp.Clear();
			foreach (SyncPersonalXpMessage.Entry entry in entries)
			{
				GameObject val = Util.FindNetworkObject(entry.masterNetId);
				CharacterMaster val2 = (Object.op_Implicit((Object)(object)val) ? val.GetComponent<CharacterMaster>() : null);
				if (Object.op_Implicit((Object)(object)val2))
				{
					xp[val2] = entry.experience;
				}
			}
			OnLevelsMaybeChanged();
		}
	}
	internal static class PersonalGold
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_GiveTeamMoney_TeamIndex_uint_bool <0>__TeamManager_GiveTeamMoney;

			public static hook_OnKilledServer <1>__DeathRewards_OnKilledServer;

			public static hook_PerformInteraction <2>__Interactor_PerformInteraction;

			public static hook_OnInteractionBegin <3>__BarrelInteraction_OnInteractionBegin;

			public static hook_OnTriggerStay <4>__MoneyPickup_OnTriggerStay;
		}

		public static void Enable()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			//IL_0095: 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_00a0: Expected O, but got Unknown
			object obj = <>O.<0>__TeamManager_GiveTeamMoney;
			if (obj == null)
			{
				hook_GiveTeamMoney_TeamIndex_uint_bool val = TeamManager_GiveTeamMoney;
				<>O.<0>__TeamManager_GiveTeamMoney = val;
				obj = (object)val;
			}
			TeamManager.GiveTeamMoney_TeamIndex_uint_bool += (hook_GiveTeamMoney_TeamIndex_uint_bool)obj;
			object obj2 = <>O.<1>__DeathRewards_OnKilledServer;
			if (obj2 == null)
			{
				hook_OnKilledServer val2 = DeathRewards_OnKilledServer;
				<>O.<1>__DeathRewards_OnKilledServer = val2;
				obj2 = (object)val2;
			}
			DeathRewards.OnKilledServer += (hook_OnKilledServer)obj2;
			object obj3 = <>O.<2>__Interactor_PerformInteraction;
			if (obj3 == null)
			{
				hook_PerformInteraction val3 = Interactor_PerformInteraction;
				<>O.<2>__Interactor_PerformInteraction = val3;
				obj3 = (object)val3;
			}
			Interactor.PerformInteraction += (hook_PerformInteraction)obj3;
			object obj4 = <>O.<3>__BarrelInteraction_OnInteractionBegin;
			if (obj4 == null)
			{
				hook_OnInteractionBegin val4 = BarrelInteraction_OnInteractionBegin;
				<>O.<3>__BarrelInteraction_OnInteractionBegin = val4;
				obj4 = (object)val4;
			}
			BarrelInteraction.OnInteractionBegin += (hook_OnInteractionBegin)obj4;
			object obj5 = <>O.<4>__MoneyPickup_OnTriggerStay;
			if (obj5 == null)
			{
				hook_OnTriggerStay val5 = MoneyPickup_OnTriggerStay;
				<>O.<4>__MoneyPickup_OnTriggerStay = val5;
				obj5 = (object)val5;
			}
			MoneyPickup.OnTriggerStay += (hook_OnTriggerStay)obj5;
		}

		public static void Disable()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			//IL_0095: 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_00a0: Expected O, but got Unknown
			object obj = <>O.<0>__TeamManager_GiveTeamMoney;
			if (obj == null)
			{
				hook_GiveTeamMoney_TeamIndex_uint_bool val = TeamManager_GiveTeamMoney;
				<>O.<0>__TeamManager_GiveTeamMoney = val;
				obj = (object)val;
			}
			TeamManager.GiveTeamMoney_TeamIndex_uint_bool -= (hook_GiveTeamMoney_TeamIndex_uint_bool)obj;
			object obj2 = <>O.<1>__DeathRewards_OnKilledServer;
			if (obj2 == null)
			{
				hook_OnKilledServer val2 = DeathRewards_OnKilledServer;
				<>O.<1>__DeathRewards_OnKilledServer = val2;
				obj2 = (object)val2;
			}
			DeathRewards.OnKilledServer -= (hook_OnKilledServer)obj2;
			object obj3 = <>O.<2>__Interactor_PerformInteraction;
			if (obj3 == null)
			{
				hook_PerformInteraction val3 = Interactor_PerformInteraction;
				<>O.<2>__Interactor_PerformInteraction = val3;
				obj3 = (object)val3;
			}
			Interactor.PerformInteraction -= (hook_PerformInteraction)obj3;
			object obj4 = <>O.<3>__BarrelInteraction_OnInteractionBegin;
			if (obj4 == null)
			{
				hook_OnInteractionBegin val4 = BarrelInteraction_OnInteractionBegin;
				<>O.<3>__BarrelInteraction_OnInteractionBegin = val4;
				obj4 = (object)val4;
			}
			BarrelInteraction.OnInteractionBegin -= (hook_OnInteractionBegin)obj4;
			object obj5 = <>O.<4>__MoneyPickup_OnTriggerStay;
			if (obj5 == null)
			{
				hook_OnTriggerStay val5 = MoneyPickup_OnTriggerStay;
				<>O.<4>__MoneyPickup_OnTriggerStay = val5;
				obj5 = (object)val5;
			}
			MoneyPickup.OnTriggerStay -= (hook_OnTriggerStay)obj5;
		}

		private static void TeamManager_GiveTeamMoney(orig_GiveTeamMoney_TeamIndex_uint_bool orig, TeamManager self, TeamIndex teamIndex, uint money, bool bypassStatManager)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			if ((int)teamIndex != 1)
			{
				orig.Invoke(self, teamIndex, money, bypassStatManager);
				return;
			}
			Allocation current = Attribution.Current;
			if (current == null)
			{
				Attribution.ReportUnattributed("gold");
				orig.Invoke(self, teamIndex, money, bypassStatManager);
				return;
			}
			foreach (KeyValuePair<CharacterMaster, ulong> item in current.Split(money))
			{
				item.Key.GiveMoney((uint)item.Value, bypassStatManager);
			}
		}

		private static void DeathRewards_OnKilledServer(orig_OnKilledServer orig, DeathRewards self, DamageReport damageReport)
		{
			Attribution.Push(KillShares(damageReport));
			try
			{
				orig.Invoke(self, damageReport);
			}
			finally
			{
				Attribution.Pop();
			}
		}

		private static Allocation KillShares(DamageReport report)
		{
			if (report == null)
			{
				return null;
			}
			Allocation allocation = DamageTracker.TakeShares(report.victim);
			if (allocation.Total > 0.0)
			{
				return allocation;
			}
			CharacterMaster val = report.attackerMaster;
			if (!Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)report.attackerBody))
			{
				val = report.attackerBody.master;
			}
			if (!Object.op_Implicit((Object)(object)val))
			{
				val = report.attackerOwnerMaster;
			}
			return Allocation.Single(Attribution.ResolvePlayer(val));
		}

		private static void Interactor_PerformInteraction(orig_PerformInteraction orig, Interactor self, GameObject interactableObject)
		{
			Attribution.Push(Allocation.Single(Attribution.PlayerOf((Component)(object)self)));
			try
			{
				orig.Invoke(self, interactableObject);
			}
			finally
			{
				Attribution.Pop();
			}
		}

		private static void BarrelInteraction_OnInteractionBegin(orig_OnInteractionBegin orig, BarrelInteraction self, Interactor activator)
		{
			Attribution.Push(Allocation.Single(Attribution.PlayerOf((Component)(object)activator)) ?? Attribution.Current);
			try
			{
				orig.Invoke(self, activator);
			}
			finally
			{
				Attribution.Pop();
			}
		}

		private static void MoneyPickup_OnTriggerStay(orig_OnTriggerStay orig, MoneyPickup self, Collider other)
		{
			Attribution.Push(Allocation.Single(Attribution.PlayerOf((Component)(object)other)));
			try
			{
				orig.Invoke(self, other);
			}
			finally
			{
				Attribution.Pop();
			}
		}
	}
	public class SyncPersonalXpMessage : INetMessage, ISerializableObject
	{
		public struct Entry
		{
			public NetworkInstanceId masterNetId;

			public ulong experience;

			public Entry(NetworkInstanceId masterNetId, ulong experience)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				this.masterNetId = masterNetId;
				this.experience = experience;
			}
		}

		private const int MaxEntries = 64;

		private List<Entry> entries = new List<Entry>();

		public SyncPersonalXpMessage()
		{
		}

		public SyncPersonalXpMessage(List<Entry> entries)
		{
			this.entries = entries ?? new List<Entry>();
		}

		public void Serialize(NetworkWriter writer)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			writer.WritePackedUInt32((uint)entries.Count);
			foreach (Entry entry in entries)
			{
				writer.Write(entry.masterNetId);
				writer.WritePackedUInt64(entry.experience);
			}
		}

		public void Deserialize(NetworkReader reader)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			uint num = reader.ReadPackedUInt32();
			entries = new List<Entry>();
			for (uint num2 = 0u; num2 < num; num2++)
			{
				NetworkInstanceId masterNetId = reader.ReadNetworkId();
				ulong experience = reader.ReadPackedUInt64();
				if (num2 < 64)
				{
					entries.Add(new Entry(masterNetId, experience));
				}
			}
		}

		public void OnReceived()
		{
			PersonalExperience.ApplyFromHost(entries);
		}
	}
}