Decompiled source of PizzaClientLagFix v1.3.4

plugins/PizzaClientLagFix/PizzaClientLagFix.dll

Decompiled 4 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using HG.Reflection;
using IL.RoR2.Projectile;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.RoR2;
using On.RoR2.Projectile;
using PizzaClientLagFix.ModCompat;
using PizzaClientLagFix.Networking;
using RoR2;
using RoR2.Projectile;
using UnityEngine;
using UnityEngine.Networking;

[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyInformationalVersion("1.0.0+d6d395da7de5f94ece4a779b655a241244690e52")]
[assembly: AssemblyProduct("PizzaClientLagFix")]
[assembly: AssemblyTitle("PizzaClientLagFix")]
[assembly: AssemblyCompany("PizzaClientLagFix")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	[CompilerGenerated]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace PizzaClientLagFix
{
	internal static class Log
	{
		private static readonly StringBuilder _sharedStringBuilder;

		private static readonly int _cachedCallerPathPrefixLength;

		private static ManualLogSource _logSource;

		static Log()
		{
			_sharedStringBuilder = new StringBuilder(256);
			_cachedCallerPathPrefixLength = getCallerPathPrefixLength("E:\\Git\\RoR2\\PizzaClientLagFix\\PizzaClientLagFix\\Log.cs");
			static int getCallerPathPrefixLength([CallerFilePath] string callerPath = null)
			{
				int num = callerPath.LastIndexOf("PizzaClientLagFix\\");
				if (num >= 0)
				{
					return num + "PizzaClientLagFix\\".Length;
				}
				Debug.LogError((object)"[PizzaClientLagFix] Logger failed to determine caller path prefix length");
				return 0;
			}
		}

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

		private static StringBuilder AppendCallerPrefix(this StringBuilder stringBuilder, string callerPath, string callerMemberName, int callerLineNumber)
		{
			return stringBuilder.Append(callerPath, _cachedCallerPathPrefixLength, callerPath.Length - _cachedCallerPathPrefixLength).Append(':').Append(callerLineNumber)
				.Append(" (")
				.Append(callerMemberName)
				.Append("):");
		}

		private static StringBuilder buildCallerLogString(string callerPath, string callerMemberName, int callerLineNumber, object data)
		{
			return _sharedStringBuilder.Clear().AppendCallerPrefix(callerPath, callerMemberName, callerLineNumber).Append(' ')
				.Append(data);
		}

		[Conditional("DEBUG")]
		internal static void Debug(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogDebug((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data));
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[Conditional("DEBUG")]
		internal static void Debug_NoCallerPrefix(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void Error(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogError((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data));
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal static void Error_NoCallerPrefix(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogFatal((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data));
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal static void Fatal_NoCallerPrefix(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogInfo((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data));
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal static void Info_NoCallerPrefix(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogMessage((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data));
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal static void Message_NoCallerPrefix(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogWarning((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data));
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal static void Warning_NoCallerPrefix(object data)
		{
			_logSource.LogWarning(data);
		}

		internal static void LogType(LogLevel level, object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			//IL_0000: 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)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			if ((level & 0x20) == 0)
			{
				_logSource.Log(level, (object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data));
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal static void LogType_NoCallerPrefix(LogLevel level, object data)
		{
			//IL_0000: 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)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			if ((level & 0x20) == 0)
			{
				_logSource.Log(level, data);
			}
		}
	}
	public static class OverlapAttackIgnoreNonAuthorityHitsPatch
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_ProcessHits <0>__OverlapAttack_ProcessHits;
		}

		public static bool Enabled;

		[SystemInitializer(new Type[] { })]
		private static void Init()
		{
			//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>__OverlapAttack_ProcessHits;
			if (obj == null)
			{
				hook_ProcessHits val = OverlapAttack_ProcessHits;
				<>O.<0>__OverlapAttack_ProcessHits = val;
				obj = (object)val;
			}
			OverlapAttack.ProcessHits += (hook_ProcessHits)obj;
		}

		private static void OverlapAttack_ProcessHits(orig_ProcessHits orig, OverlapAttack self, List<OverlapInfo> hitList)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			if (!Enabled)
			{
				orig.Invoke(self, hitList);
				return;
			}
			try
			{
				_ = hitList.Count;
				_ = 0;
				for (int num = hitList.Count - 1; num >= 0; num--)
				{
					HurtBox hurtBox = hitList[num].hurtBox;
					if (Object.op_Implicit((Object)(object)hurtBox))
					{
						HealthComponent healthComponent = hurtBox.healthComponent;
						if (Object.op_Implicit((Object)(object)healthComponent) && !Util.HasEffectiveAuthority(((Component)healthComponent).gameObject))
						{
							hitList.RemoveAt(num);
						}
					}
				}
			}
			catch (Exception data)
			{
				Log.Error_NoCallerPrefix(data);
			}
			orig.Invoke(self, hitList);
		}
	}
	[BepInPlugin("Gorakh.PizzaClientLagFix", "PizzaClientLagFix", "1.3.4")]
	public sealed class PizzaClientLagFixPlugin : BaseUnityPlugin
	{
		public const string PluginGUID = "Gorakh.PizzaClientLagFix";

		public const string PluginAuthor = "Gorakh";

		public const string PluginName = "PizzaClientLagFix";

		public const string PluginVersion = "1.3.4";

		internal static PizzaClientLagFixPlugin Instance { get; private set; }

		private void Awake()
		{
			Stopwatch stopwatch = Stopwatch.StartNew();
			Log.Init(((BaseUnityPlugin)this).Logger);
			Instance = SingletonHelper.Assign<PizzaClientLagFixPlugin>(Instance, this);
			stopwatch.Stop();
			Log.Info_NoCallerPrefix($"Initialized in {stopwatch.Elapsed.TotalSeconds:F2} seconds");
		}

		private void OnDestroy()
		{
			Instance = SingletonHelper.Unassign<PizzaClientLagFixPlugin>(Instance, this);
		}
	}
	internal static class ProjectileOverlapAttackClientPredictionHooks
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_MyFixedUpdate <0>__ProjectileOverlapAttack_MyFixedUpdate_EnsurePatchDisabled;

			public static Manipulator <1>__ProjectileOverlapAttack_MyFixedUpdate_AllowClientPrediction;

			public static Func<ProjectileOverlapAttack, ProjectileOverlapAttackClientPrediction> <2>__getClientPrediction;

			public static Func<bool, ProjectileOverlapAttackClientPrediction, bool> <3>__overrideShouldProcessAttack;

			public static Action<ProjectileOverlapAttackClientPrediction> <4>__preFire;

			public static Action <5>__postFire;
		}

		[SystemInitializer(new Type[] { typeof(ProjectileCatalog) })]
		private static void Init()
		{
			//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
			//IL_0030: 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_003b: Expected O, but got Unknown
			object obj = <>O.<0>__ProjectileOverlapAttack_MyFixedUpdate_EnsurePatchDisabled;
			if (obj == null)
			{
				hook_MyFixedUpdate val = ProjectileOverlapAttack_MyFixedUpdate_EnsurePatchDisabled;
				<>O.<0>__ProjectileOverlapAttack_MyFixedUpdate_EnsurePatchDisabled = val;
				obj = (object)val;
			}
			ProjectileOverlapAttack.MyFixedUpdate += (hook_MyFixedUpdate)obj;
			object obj2 = <>O.<1>__ProjectileOverlapAttack_MyFixedUpdate_AllowClientPrediction;
			if (obj2 == null)
			{
				Manipulator val2 = ProjectileOverlapAttack_MyFixedUpdate_AllowClientPrediction;
				<>O.<1>__ProjectileOverlapAttack_MyFixedUpdate_AllowClientPrediction = val2;
				obj2 = (object)val2;
			}
			ProjectileOverlapAttack.MyFixedUpdate += (Manipulator)obj2;
			addPredictionToProjectile("BrotherUltLineProjectileRotateLeft");
			addPredictionToProjectile("BrotherUltLineProjectileRotateRight");
			addPredictionToProjectile("BrotherUltLineProjectileStatic");
			addPredictionToProjectile("BrotherSunderWave");
			addPredictionToProjectile("BrotherSunderWave, Energized");
			BaseUnityPlugin umbralPluginInstance;
			Type umbralPluginType;
			if (UmbralMithrixCompat.Enabled)
			{
				PluginInfo value = UmbralMithrixCompat.UmbralPluginInfo.Value;
				umbralPluginInstance = ((value != null) ? value.Instance : null);
				umbralPluginType = ((object)umbralPluginInstance)?.GetType();
				tryAddPredictionToUmbralProjectile("UmbralUltLineLeft", "leftUltLine");
				tryAddPredictionToUmbralProjectile("P4UltLineLeft", "leftP4Line");
				tryAddPredictionToUmbralProjectile("StaticUltLine", "staticUltLine");
				tryAddPredictionToUmbralProjectile("UmbralUltLineRight", "rightUltLine");
				tryAddPredictionToUmbralProjectile("P4UltLineRight", "rightP4Line");
				tryAddPredictionToUmbralProjectile("UmbralLeapWave", "umbralLeapWave");
			}
			static void addPredictionToPrefab(GameObject prefab)
			{
				prefab.AddComponent<ProjectileOverlapAttackValueNetworker>();
				prefab.AddComponent<ProjectileOverlapAttackClientPrediction>();
				Log.Info($"Added client prediction to {prefab}", "E:\\Git\\RoR2\\PizzaClientLagFix\\PizzaClientLagFix\\ProjectileOverlapAttackClientPredictionHooks.cs", "Init", 112);
			}
			static void addPredictionToProjectile(string projectileName)
			{
				if (!tryAddPredictionToProjectile(projectileName))
				{
					Log.Error("Failed to find projectile '" + projectileName + "'", "E:\\Git\\RoR2\\PizzaClientLagFix\\PizzaClientLagFix\\ProjectileOverlapAttackClientPredictionHooks.cs", "Init", 92);
				}
			}
			static bool tryAddPredictionToProjectile(string projectileName)
			{
				int num = ProjectileCatalog.FindProjectileIndex(projectileName);
				if (num < 0)
				{
					return false;
				}
				addPredictionToPrefab(ProjectileCatalog.GetProjectilePrefab(num));
				return true;
			}
			void tryAddPredictionToUmbralProjectile(string projectileName, string projectileFieldName)
			{
				if (tryAddPredictionToProjectile(projectileName))
				{
					return;
				}
				Log.Warning("Failed to find umbral projectile '" + projectileName + "', attempting to retrieve from field", "E:\\Git\\RoR2\\PizzaClientLagFix\\PizzaClientLagFix\\ProjectileOverlapAttackClientPredictionHooks.cs", "Init", 47);
				try
				{
					FieldInfo fieldInfo = umbralPluginType?.GetField(projectileFieldName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
					if (fieldInfo == null)
					{
						Log.Error("Failed to find umbral field '" + projectileFieldName + "'", "E:\\Git\\RoR2\\PizzaClientLagFix\\PizzaClientLagFix\\ProjectileOverlapAttackClientPredictionHooks.cs", "Init", 55);
					}
					else
					{
						object value2 = fieldInfo.GetValue(fieldInfo.IsStatic ? null : umbralPluginInstance);
						GameObject val3 = (GameObject)((value2 is GameObject) ? value2 : null);
						if (val3 == null)
						{
							string fullName = fieldInfo.FieldType.FullName;
							if (value2 != null)
							{
								fullName = value2.GetType().FullName;
							}
							Log.Error("Unexpected type " + fullName + " of umbral field '" + fieldInfo.Name + "'", "E:\\Git\\RoR2\\PizzaClientLagFix\\PizzaClientLagFix\\ProjectileOverlapAttackClientPredictionHooks.cs", "Init", 68);
						}
						else if (((Object)val3).name != projectileName)
						{
							Log.Error($"Found projectile field does not match projectile name: {val3}, expected {projectileName} ({projectileFieldName})", "E:\\Git\\RoR2\\PizzaClientLagFix\\PizzaClientLagFix\\ProjectileOverlapAttackClientPredictionHooks.cs", "Init", 74);
						}
						else
						{
							addPredictionToPrefab(val3);
						}
					}
				}
				catch (Exception arg)
				{
					Log.Error_NoCallerPrefix($"Failed to find find umbral projectile '{projectileName}' from field '{projectileFieldName}': {arg}");
				}
			}
		}

		private static void ProjectileOverlapAttack_MyFixedUpdate_EnsurePatchDisabled(orig_MyFixedUpdate orig, ProjectileOverlapAttack self, float deltaTime)
		{
			try
			{
				orig.Invoke(self, deltaTime);
			}
			finally
			{
				OverlapAttackIgnoreNonAuthorityHitsPatch.Enabled = false;
			}
		}

		private static void ProjectileOverlapAttack_MyFixedUpdate_AllowClientPrediction(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			VariableDefinition val2 = new VariableDefinition(il.Import(typeof(ProjectileOverlapAttackClientPrediction)));
			il.Method.Body.Variables.Add(val2);
			val.Emit(OpCodes.Ldarg_0);
			val.EmitDelegate<Func<ProjectileOverlapAttack, ProjectileOverlapAttackClientPrediction>>((Func<ProjectileOverlapAttack, ProjectileOverlapAttackClientPrediction>)getClientPrediction);
			val.Emit(OpCodes.Stloc, val2);
			int shouldProccessAttacksVar = -1;
			ILLabel afterCanProcessCheckLabel = null;
			if (!val.TryGotoNext(new Func<Instruction, bool>[3]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<ProjectileController>(x, "CanProcessCollisionEvents"),
				(Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref shouldProccessAttacksVar),
				(Instruction x) => ILPatternMatchingExt.MatchBr(x, ref afterCanProcessCheckLabel)
			}))
			{
				Log.Error("Failed to find initial patch location", "E:\\Git\\RoR2\\PizzaClientLagFix\\PizzaClientLagFix\\ProjectileOverlapAttackClientPredictionHooks.cs", "ProjectileOverlapAttack_MyFixedUpdate_AllowClientPrediction", 150);
				return;
			}
			val.Goto(afterCanProcessCheckLabel.Target, (MoveType)1, false);
			val.Emit(OpCodes.Ldloc, shouldProccessAttacksVar);
			val.Emit(OpCodes.Ldloc, val2);
			val.EmitDelegate<Func<bool, ProjectileOverlapAttackClientPrediction, bool>>((Func<bool, ProjectileOverlapAttackClientPrediction, bool>)overrideShouldProcessAttack);
			val.Emit(OpCodes.Stloc, shouldProccessAttacksVar);
			if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<OverlapAttack>(x, "Fire")
			}))
			{
				val.Emit(OpCodes.Ldloc, val2);
				val.EmitDelegate<Action<ProjectileOverlapAttackClientPrediction>>((Action<ProjectileOverlapAttackClientPrediction>)preFire);
				int index = val.Index;
				val.Index = index + 1;
				val.EmitDelegate<Action>((Action)postFire);
			}
			else
			{
				Log.Error("Failed to find fire patch location", "E:\\Git\\RoR2\\PizzaClientLagFix\\PizzaClientLagFix\\ProjectileOverlapAttackClientPredictionHooks.cs", "ProjectileOverlapAttack_MyFixedUpdate_AllowClientPrediction", 186);
			}
			static ProjectileOverlapAttackClientPrediction getClientPrediction(ProjectileOverlapAttack projectileOverlapAttack)
			{
				return ((Component)projectileOverlapAttack).GetComponent<ProjectileOverlapAttackClientPrediction>();
			}
			static bool overrideShouldProcessAttack(bool shouldProccessAttacks, ProjectileOverlapAttackClientPrediction clientPrediction)
			{
				if (!shouldProccessAttacks)
				{
					return Object.op_Implicit((Object)(object)clientPrediction);
				}
				return true;
			}
			static void postFire()
			{
				OverlapAttackIgnoreNonAuthorityHitsPatch.Enabled = false;
			}
			static void preFire(ProjectileOverlapAttackClientPrediction clientPrediction)
			{
				OverlapAttackIgnoreNonAuthorityHitsPatch.Enabled = Object.op_Implicit((Object)(object)clientPrediction);
			}
		}
	}
}
namespace PizzaClientLagFix.Networking
{
	public sealed class ProjectileOverlapAttackClientPrediction : MonoBehaviour
	{
	}
	public sealed class ProjectileOverlapAttackValueNetworker : NetworkBehaviour
	{
		private ProjectileController _projectileController;

		private ProjectileDamage _projectileDamage;

		private const uint PROC_CHAIN_MASK_DIRTY_BIT = 1u;

		private ProcChainMask _procChainMask;

		private const uint PROC_COEFFICIENT_DIRTY_BIT = 2u;

		private float _procCoefficient = 1f;

		private const uint DAMAGE_DIRTY_BIT = 4u;

		private float _damage;

		private const uint FORCE_DIRTY_BIT = 8u;

		private float _force;

		private const uint CRIT_DIRTY_BIT = 16u;

		private bool _crit;

		private const uint DAMAGE_COLOR_INDEX_DIRTY_BIT = 32u;

		private DamageColorIndex _damageColorIndex;

		private const uint DAMAGE_TYPE_DIRTY_BIT = 64u;

		private DamageTypeCombo _damageType = DamageTypeCombo.Generic;

		private void Awake()
		{
			_projectileController = ((Component)this).GetComponent<ProjectileController>();
			_projectileDamage = ((Component)this).GetComponent<ProjectileDamage>();
			_projectileController.onInitialized += onProjectileInitialized;
		}

		public override void OnStartClient()
		{
			((NetworkBehaviour)this).OnStartClient();
			refreshValues();
		}

		private void FixedUpdate()
		{
			refreshValues();
		}

		private void onProjectileInitialized(ProjectileController projectileController)
		{
			refreshValues();
		}

		private unsafe void refreshValues()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: 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)
			_ = ((NetworkBehaviour)this).syncVarDirtyBits;
			if (Object.op_Implicit((Object)(object)_projectileController))
			{
				ProcChainMask currentValue = _projectileController.procChainMask;
				checkValueEquatable<ProcChainMask>(ref _procChainMask, ref currentValue, 1u);
				_projectileController.procChainMask = currentValue;
				checkValueEquatable<float>(ref _procCoefficient, ref _projectileController.procCoefficient, 2u);
			}
			if (Object.op_Implicit((Object)(object)_projectileDamage))
			{
				checkValueEquatable<float>(ref _damage, ref _projectileDamage.damage, 4u);
				checkValueEquatable<float>(ref _force, ref _projectileDamage.force, 8u);
				checkValueEquatable<bool>(ref _crit, ref _projectileDamage.crit, 16u);
				checkValue<DamageColorIndex>(ref _damageColorIndex, ref _projectileDamage.damageColorIndex, 32u, (DamageColorIndex a, DamageColorIndex b) => a == b);
				checkValue<DamageTypeCombo>(ref _damageType, ref _projectileDamage.damageType, 64u, (DamageTypeCombo a, DamageTypeCombo b) => ((object)(*(DamageTypeCombo*)(&a))/*cast due to .constrained prefix*/).Equals((object?)b));
			}
			bool checkValue<T>(ref T authorityValue, ref T reference, uint dirtyBit, Func<T, T, bool> comparison)
			{
				if (comparison(authorityValue, reference))
				{
					return false;
				}
				if (NetworkServer.active)
				{
					authorityValue = reference;
					((NetworkBehaviour)this).SetDirtyBit(dirtyBit);
				}
				else
				{
					reference = authorityValue;
				}
				return true;
			}
			bool checkValueEquatable<T>(ref T authorityValue, ref T currentValue2, uint dirtyBit) where T : IEquatable<T>
			{
				return checkValue<T>(ref authorityValue, ref currentValue2, dirtyBit, (T a, T b) => a.Equals(b));
			}
		}

		public override bool OnSerialize(NetworkWriter writer, bool initialState)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: 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)
			uint num;
			if (initialState)
			{
				num = uint.MaxValue;
			}
			else
			{
				num = ((NetworkBehaviour)this).syncVarDirtyBits;
				writer.WritePackedUInt32(num);
			}
			bool flag = false;
			if ((num & 1) != 0)
			{
				NetworkExtensions.Write(writer, _procChainMask);
				flag = true;
			}
			if ((num & 2) != 0)
			{
				writer.Write(_procCoefficient);
				flag = true;
			}
			if ((num & 4) != 0)
			{
				writer.Write(_damage);
				flag = true;
			}
			if ((num & 8) != 0)
			{
				writer.Write(_force);
				flag = true;
			}
			if ((num & 0x10) != 0)
			{
				writer.Write(_crit);
				flag = true;
			}
			if ((num & 0x20) != 0)
			{
				NetworkExtensions.Write(writer, _damageColorIndex);
				flag = true;
			}
			if ((num & 0x40) != 0)
			{
				NetworkExtensions.WriteDamageType(writer, _damageType);
				flag = true;
			}
			return flag || initialState;
		}

		public override void OnDeserialize(NetworkReader reader, bool initialState)
		{
			//IL_0013: 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_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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)
			int num = (initialState ? (-1) : ((int)reader.ReadPackedUInt32()));
			if ((num & 1) != 0)
			{
				_procChainMask = NetworkExtensions.ReadProcChainMask(reader);
			}
			if ((num & 2) != 0)
			{
				_procCoefficient = reader.ReadSingle();
			}
			if ((num & 4) != 0)
			{
				_damage = reader.ReadSingle();
			}
			if ((num & 8) != 0)
			{
				_force = reader.ReadSingle();
			}
			if ((num & 0x10) != 0)
			{
				_crit = reader.ReadBoolean();
			}
			if ((num & 0x20) != 0)
			{
				_damageColorIndex = NetworkExtensions.ReadDamageColorIndex(reader);
			}
			if ((num & 0x40) != 0)
			{
				_damageType = NetworkExtensions.ReadDamageType(reader);
			}
			refreshValues();
		}

		private void UNetVersion()
		{
		}
	}
}
namespace PizzaClientLagFix.ModCompat
{
	internal static class UmbralMithrixCompat
	{
		private const string UMBRAL_GUID = "com.Nuxlar.UmbralMithrix";

		public static readonly Lazy<PluginInfo> UmbralPluginInfo = new Lazy<PluginInfo>((Func<PluginInfo>)(() => (!Chainloader.PluginInfos.TryGetValue("com.Nuxlar.UmbralMithrix", out var value)) ? null : value));

		public static bool Enabled => Chainloader.PluginInfos.ContainsKey("com.Nuxlar.UmbralMithrix");
	}
}