using System;
using System.Collections;
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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Utils.Collections;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Microsoft.CodeAnalysis;
using P2.Game.Unit;
using P2.GameSystem;
using P2.GameSystem.Actor;
using P2.GameSystem.Actor.Status;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("DontDieHatapon_")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Don't Die Hatapon!")]
[assembly: AssemblyTitle("DontDieHatapon_")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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 DontDieHatapon_
{
[BepInPlugin("com.melonthug.dontdiehatapon", "Don't Die Hatapon!", "1.0.0")]
public class Plugin : BasePlugin
{
public static ManualLogSource Logger;
public static ConfigEntry<int> HataponHP;
public override void Load()
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Expected O, but got Unknown
ClassInjector.RegisterTypeInIl2Cpp<CoroutineRunner>();
HataponHP = ((BasePlugin)this).Config.Bind<int>("HP", "HataponHP", 99999, "Set the HP of Hatapon.");
Logger = ((BasePlugin)this).Log;
Harmony val = new Harmony("com.melonthug.dontdiehatapon");
val.PatchAll();
Logger.LogInfo((object)"[Don't Die Hatapon!] loaded");
}
}
public class CoroutineRunner : MonoBehaviour
{
private static CoroutineRunner _instance;
public static CoroutineRunner Instance
{
get
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
if ((Object)(object)_instance == (Object)null)
{
GameObject val = new GameObject("DontDieHatapon_CoroutineRunner");
Object.DontDestroyOnLoad((Object)(object)val);
_instance = val.AddComponent<CoroutineRunner>();
}
return _instance;
}
}
public CoroutineRunner(IntPtr handle)
: base(handle)
{
}
public CoroutineRunner()
: base(ClassInjector.DerivedConstructorPointer<CoroutineRunner>())
{
ClassInjector.DerivedConstructorBody((Il2CppObjectBase)(object)this);
}
}
[HarmonyPatch(typeof(FlagUnit), "createActorModel")]
internal class createActorModelLogger
{
[CompilerGenerated]
private sealed class <SetHataponHP>d__1 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public FlagUnit flagUnit;
private string <charaName>5__1;
private ActorStatusObj <status>5__2;
private int <maxHP>5__3;
private int <hp>5__4;
private int <new_maxHP>5__5;
private int <new_hp>5__6;
private ManualLogSource <>s__7;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <SetHataponHP>d__1(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<charaName>5__1 = null;
<status>5__2 = null;
<>s__7 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(3f);
<>1__state = 1;
return true;
case 1:
{
<>1__state = -1;
<charaName>5__1 = flagUnit.pCharaParam_.name;
if (<charaName>5__1 != "unit001_01_01")
{
return false;
}
<status>5__2 = ((ActorObj)flagUnit).pActorStatus_;
if (<status>5__2 == null)
{
return false;
}
<maxHP>5__3 = ((GameStatus)<status>5__2).getMaxHitPoint();
<hp>5__4 = ((GameStatus)<status>5__2).getHitPoint();
((GameStatus)<status>5__2).setHitPoint(Plugin.HataponHP.Value);
((GameStatus)<status>5__2).info_.maxHitPoint = Plugin.HataponHP.Value;
<new_maxHP>5__5 = ((GameStatus)<status>5__2).getMaxHitPoint();
<new_hp>5__6 = ((GameStatus)<status>5__2).getHitPoint();
<>s__7 = Plugin.Logger;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(30, 4, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Hatapon HP changed from ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(<hp>5__4);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("/");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(<maxHP>5__3);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" -> ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(<new_hp>5__6);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("/");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(<new_maxHP>5__5);
}
<>s__7.LogInfo(val);
<>s__7 = null;
return false;
}
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private static void Postfix(string pArcResourceNode, FlagUnit __instance)
{
((MonoBehaviour)CoroutineRunner.Instance).StartCoroutine(CollectionExtensions.WrapToIl2Cpp(SetHataponHP(__instance)));
}
[IteratorStateMachine(typeof(<SetHataponHP>d__1))]
private static IEnumerator SetHataponHP(FlagUnit flagUnit)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <SetHataponHP>d__1(0)
{
flagUnit = flagUnit
};
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "DontDieHatapon_";
public const string PLUGIN_NAME = "Don't Die Hatapon!";
public const string PLUGIN_VERSION = "1.0.0";
}
}