using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("TrueInstantLootDrop")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Azumatt")]
[assembly: AssemblyProduct("TrueInstantLootDrop")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("4358610B-F3F4-4843-B7AF-98B7BC60DCDE")]
[assembly: AssemblyFileVersion("1.0.2")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[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 TrueInstantLootDrop
{
[BepInPlugin("Azumatt.TrueInstantLootDrop", "TrueInstantLootDrop", "1.0.2")]
public class TrueInstantLootDropPlugin : BaseUnityPlugin
{
public enum Toggle
{
On = 1,
Off = 0
}
internal const string ModName = "TrueInstantLootDrop";
internal const string ModVersion = "1.0.2";
internal const string Author = "Azumatt";
private const string ModGUID = "Azumatt.TrueInstantLootDrop";
private readonly Harmony _harmony = new Harmony("Azumatt.TrueInstantLootDrop");
public static readonly ManualLogSource TrueInstantLootDropLogger = Logger.CreateLogSource("TrueInstantLootDrop");
internal static ConfigEntry<Toggle> ShowDeathPoof = null;
public static bool IsDeathPoofEnabled => ShowDeathPoof.Value == Toggle.On;
public void Awake()
{
ShowDeathPoof = ((BaseUnityPlugin)this).Config.Bind<Toggle>("1 - General", "Death Effects", Toggle.On, "If off, disables the smokey poof effect that appears after the ragdoll disappears.");
Assembly executingAssembly = Assembly.GetExecutingAssembly();
_harmony.PatchAll(executingAssembly);
}
}
[HarmonyPatch(typeof(Ragdoll), "Start")]
internal static class RagdollStartPatch
{
private static void Postfix(Ragdoll __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_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: 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)
Vector3 val = __instance.GetAverageBodyPosition();
if ((Object)(object)__instance.m_lootSpawnJoint != (Object)null)
{
val = __instance.m_lootSpawnJoint.transform.position;
}
__instance.SpawnLoot(val);
}
}
[HarmonyPatch(typeof(Ragdoll), "DestroyNow")]
public static class Ragdoll_DestroyNow_Patch
{
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator il)
{
//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
//IL_03c9: Expected O, but got Unknown
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Expected O, but got Unknown
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Expected O, but got Unknown
List<CodeInstruction> list = new List<CodeInstruction>(instructions);
FieldInfo fieldInfo = AccessTools.Field(typeof(Ragdoll), "m_removeEffect");
MethodInfo obj = AccessTools.Method(typeof(EffectList), "Create", new Type[5]
{
typeof(Vector3),
typeof(Quaternion),
typeof(Transform),
typeof(float),
typeof(int)
}, (Type[])null);
Label label = il.DefineLabel();
bool flag = false;
MethodInfo obj2 = AccessTools.Method(typeof(Ragdoll), "SpawnLoot", new Type[1] { typeof(Vector3) }, (Type[])null);
List<CodeInstruction> list2 = new List<CodeInstruction>();
for (int i = 0; i < list.Count; i++)
{
if (i < list.Count - 1 && list[i].opcode == OpCodes.Ldarg_0 && list[i + 1].opcode == OpCodes.Ldfld && list[i + 1].operand is FieldInfo fieldInfo2 && fieldInfo2 == fieldInfo)
{
list2.Add(new CodeInstruction(OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(TrueInstantLootDropPlugin), "IsDeathPoofEnabled")));
list2.Add(new CodeInstruction(OpCodes.Brfalse, (object)label));
for (; i < list.Count; i++)
{
list2.Add(list[i]);
if (list[i].opcode == OpCodes.Callvirt && list[i].operand.Equals(obj))
{
if (i + 1 < list.Count && list[i + 1].opcode == OpCodes.Pop)
{
i++;
list2.Add(list[i]);
}
break;
}
}
if (i + 1 < list.Count)
{
CodeInstruction val = list[i + 1];
if (val.labels == null)
{
val.labels = new List<Label>();
}
list[i + 1].labels.Add(label);
flag = true;
}
}
else if (i + 2 < list.Count && list[i].opcode == OpCodes.Ldarg_0 && list[i + 1].opcode == OpCodes.Ldloc_0 && list[i + 2].opcode == OpCodes.Call && list[i + 2].operand.Equals(obj2))
{
List<Label> list3 = new List<Label>();
int[] array = new int[3]
{
i,
i + 1,
i + 2
};
foreach (int index in array)
{
if (list[index].labels != null)
{
list3.AddRange(list[index].labels);
list[index].labels.Clear();
}
}
if (i + 3 < list.Count && list3.Count > 0)
{
CodeInstruction val = list[i + 3];
if (val.labels == null)
{
val.labels = new List<Label>();
}
list[i + 3].labels.AddRange(list3);
}
i += 2;
}
else
{
list2.Add(list[i]);
}
}
if (flag)
{
return list2;
}
CodeInstruction val2 = new CodeInstruction(OpCodes.Nop, (object)null);
val2.labels.Add(label);
list2.Add(val2);
return list2;
}
}
}