using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[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("NoPenalty")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("No Penalty")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+3bfb8e07e7f1b4c8af2b9a9557470386fec07b37")]
[assembly: AssemblyProduct("NoPenalty")]
[assembly: AssemblyTitle("NoPenalty")]
[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.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 ExampleMod
{
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("NoPenalty", "NoPenalty", "1.0.0")]
public class ExampleMod : BaseUnityPlugin
{
private Harmony harmony;
private async Task Awake()
{
Log.Init(((BaseUnityPlugin)this).Logger);
RCGLifeCycle.DontDestroyForever(((Component)this).gameObject);
harmony = Harmony.CreateAndPatchAll(typeof(ExampleMod).Assembly, (string)null);
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin NoPenalty is loaded!");
while ((Object)(object)Player.i == (Object)null)
{
await Task.Run(async delegate
{
await Task.Delay(1000);
});
Log.Message("Waiting for player");
}
Log.Message("Player loaded");
FieldRef<PlayerDeadRecord, DropPickable> playerLastBag = AccessTools.FieldRefAccess<PlayerDeadRecord, DropPickable>("lastDroppedBag");
int iteration = 0;
while ((Object)(object)playerLastBag.Invoke(SingletonBehaviour<GameCore>.Instance.deadRecord) == (Object)null && iteration != 10)
{
await Task.Run(async delegate
{
await Task.Delay(1000);
});
Log.Message("Waiting for bag");
iteration++;
}
if (iteration != 10)
{
Object.Destroy((Object)(object)((Component)playerLastBag.Invoke(SingletonBehaviour<GameCore>.Instance.deadRecord)).gameObject);
Log.Message("Last bag destroyed");
}
}
private void OnDestroy()
{
harmony.UnpatchSelf();
}
}
internal static class Log
{
private static ManualLogSource? logSource;
internal static void Init(ManualLogSource logSource)
{
Log.logSource = logSource;
}
internal static void Debug(object data)
{
ManualLogSource? obj = logSource;
if (obj != null)
{
obj.LogDebug(data);
}
}
internal static void Error(object data)
{
ManualLogSource? obj = logSource;
if (obj != null)
{
obj.LogError(data);
}
}
internal static void Fatal(object data)
{
ManualLogSource? obj = logSource;
if (obj != null)
{
obj.LogFatal(data);
}
}
internal static void Info(object data)
{
ManualLogSource? obj = logSource;
if (obj != null)
{
obj.LogInfo(data);
}
}
internal static void Message(object data)
{
ManualLogSource? obj = logSource;
if (obj != null)
{
obj.LogMessage(data);
}
}
internal static void Warning(object data)
{
ManualLogSource? obj = logSource;
if (obj != null)
{
obj.LogWarning(data);
}
}
}
[HarmonyPatch]
public class Patches
{
[HarmonyPatch(typeof(Player), "DeadCheck")]
[HarmonyPrefix]
private static bool PatchDeadCheck()
{
if (((Health)Player.i.health).IsDead)
{
int gold = PlayerGamePlayData.Instance.CurrentGold;
int exp = PlayerGamePlayData.Instance.CurrentExp;
Task.Run(async delegate
{
await Task.Delay(5000);
DropPickable val = AccessTools.FieldRefAccess<PlayerDeadRecord, DropPickable>("lastDroppedBag").Invoke(SingletonBehaviour<GameCore>.Instance.deadRecord);
if ((Object)(object)val != (Object)null)
{
Object.Destroy((Object)(object)((Component)val).gameObject);
}
PlayerGamePlayData instance = PlayerGamePlayData.Instance;
instance.CurrentGold += gold;
PlayerGamePlayData instance2 = PlayerGamePlayData.Instance;
instance2.CurrentExp += exp;
});
return true;
}
return true;
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "NoPenalty";
public const string PLUGIN_NAME = "NoPenalty";
public const string PLUGIN_VERSION = "1.0.0";
}
}