using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("AgentRev")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2+765c8912d400fe0756048ed150d9050e7d6ee618")]
[assembly: AssemblyProduct("NoFriendlyGunfire")]
[assembly: AssemblyTitle("NoFriendlyGunfire")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/AgentRev/LC-NoFriendlyGunfire.git")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace NoFriendlyGunfire
{
[BepInPlugin("NoFriendlyGunfire", "NoFriendlyGunfire", "1.0.2")]
public class Plugin : BaseUnityPlugin
{
public void Awake()
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin NoFriendlyGunfire v1.0.2 loaded!");
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
}
}
[HarmonyPatch(typeof(ShotgunItem))]
public static class ShotgunPatch
{
public static bool PreCheckFriendly(this ShotgunItem shotgun)
{
return !((GrabbableObject)shotgun).isHeldByEnemy;
}
[HarmonyPatch("ShootGun")]
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
bool pending = true;
foreach (CodeInstruction inst in instructions)
{
yield return inst;
if (pending && inst.opcode == OpCodes.Stloc_0)
{
yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null);
yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ShotgunPatch), "PreCheckFriendly", (Type[])null, (Type[])null));
yield return new CodeInstruction(OpCodes.Stloc_0, (object)null);
pending = false;
}
}
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "NoFriendlyGunfire";
public const string PLUGIN_NAME = "NoFriendlyGunfire";
public const string PLUGIN_VERSION = "1.0.2";
}
}