Decompiled source of AcceleratorFriendlyFireFix v1.0.0

AccelFriendlyFire.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Pool;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("AccelFriendlyFire")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AccelFriendlyFire")]
[assembly: AssemblyTitle("AccelFriendlyFire")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
[MycoMod(/*Could not decode attribute arguments.*/)]
[BepInPlugin("AcceleratorFriendlyFireFix", "Accelerator Friendly Fire", "1.0.0")]
public class AcceleratorFriendlyFirePlugin : BaseUnityPlugin
{
	private void Awake()
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Expected O, but got Unknown
		((BaseUnityPlugin)this).Logger.LogInfo((object)"AcceleratorFriendlyFire plugin loaded");
		Harmony val = new Harmony("AcceleratorFriendlyFire");
		val.PatchAll();
	}
}
[HarmonyPatch(typeof(RocketSalvoBullet), "Detonate")]
public static class RocketSalvoBullet_Detonate_FriendlyFireFix
{
	private static bool Prefix(RocketSalvoBullet __instance, bool hitTarget)
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: 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_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: 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_0036: 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_0050: 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_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: 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_00a8: 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)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_013b: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			Traverse val = Traverse.Create((object)__instance);
			BulletData value = val.Field("data").GetValue<BulletData>();
			Vector3 value2 = val.Field("positionNext").GetValue<Vector3>();
			List<ITarget> list = default(List<ITarget>);
			PooledObject<List<ITarget>> val2 = CollectionPool<List<ITarget>, ITarget>.Get(ref list);
			try
			{
				if (IDamageSource.GetTargetsInSphere(value2, (value.force > 0f) ? value.force : 0.1f, value.targetCollisionMask, list, (TargetType)2))
				{
					list.Clear();
				}
			}
			finally
			{
				((IDisposable)val2).Dispose();
			}
			List<ITarget> list2 = default(List<ITarget>);
			PooledObject<List<ITarget>> val3 = CollectionPool<List<ITarget>, ITarget>.Get(ref list2);
			try
			{
				if (IDamageSource.GetTargetsInSphere(value2, value.force, value.targetCollisionMask, list2, (TargetType)5))
				{
					DamageData val4 = default(DamageData);
					((DamageData)(ref val4))..ctor(value.damage, value.damageEffect, value.damageEffectAmount, (DamageFlags)(value.damageFlags | 0x10));
					foreach (ITarget item in list2)
					{
						if (IBullet.CanDamageTarget(item, (IBullet)(object)__instance))
						{
							IDamageSource.DamageTarget((IDamageSource)(object)__instance, item, val4, value2, (Collider)null);
						}
					}
				}
			}
			finally
			{
				((IDisposable)val3).Dispose();
			}
			float num = value.force * 1.5f;
			GameManager.Instance.SpawnExplosionVisualObserverSeeThrough_Rpc(value2, num, value.damageEffect, (uint)NetworkManager.Singleton.LocalClientId);
			return false;
		}
		catch
		{
			return true;
		}
	}
}