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 BepInEx.Logging;
using CG.Game;
using CG.Ship.Repair;
using CG.Space;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using VoidManager;
using VoidManager.MPModChecks;
using VoidManager.Utilities;
[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("NoUnrepairableDamage")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.8.0")]
[assembly: AssemblyInformationalVersion("1.0.8+2862874f9bd36b216e748dc5b0a1d5c210d9423f")]
[assembly: AssemblyProduct("No Unrepairable Damage")]
[assembly: AssemblyTitle("NoUnrepairableDamage")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.8.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 NoUnrepairableDamage
{
[BepInPlugin("NoUnrepairableDamage", "No Unrepairable Damage", "1.0.8")]
[BepInProcess("Void Crew.exe")]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Log;
private void Awake()
{
Log = ((BaseUnityPlugin)this).Logger;
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "NoUnrepairableDamage");
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin NoUnrepairableDamage is loaded!");
}
}
[HarmonyPatch(typeof(HullDamageController), "OnRepairedBreach")]
internal class HullDamageControllerPatch
{
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Expected O, but got Unknown
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Expected O, but got Unknown
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Expected O, but got Unknown
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Expected O, but got Unknown
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Expected O, but got Unknown
List<CodeInstruction> list = new List<CodeInstruction>
{
new CodeInstruction(OpCodes.Ldarg_0, (object)null),
new CodeInstruction(OpCodes.Ldfld, (object)null),
new CodeInstruction(OpCodes.Dup, (object)null),
new CodeInstruction(OpCodes.Callvirt, (object)null),
new CodeInstruction(OpCodes.Ldloc_0, (object)null),
new CodeInstruction(OpCodes.Add, (object)null)
};
List<CodeInstruction> list2 = new List<CodeInstruction>
{
new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(HullDamageControllerPatch), "ClampHitpoints", (Type[])null, (Type[])null))
};
return HarmonyHelpers.PatchBySequence(instructions, (IEnumerable<CodeInstruction>)list, (IEnumerable<CodeInstruction>)list2, (PatchMode)1, (CheckMode)2, false);
}
private static float ClampHitpoints(float hitpoints)
{
return Mathf.Min(((OrbitObject)ClientGame.Current.PlayerShip).StartingHitPoints, hitpoints);
}
}
[HarmonyPatch(typeof(HullState), "SetRepairableHp")]
public class HullStatePatch
{
[HarmonyPrefix]
private static bool PrefixSetRepairableHp(ref float newRepairableHp, ref float newUnrepairableHp)
{
newRepairableHp += newUnrepairableHp;
newUnrepairableHp = 0f;
return true;
}
}
internal class VoidManagerPlugin : VoidPlugin
{
public override MultiplayerType MPType => (MultiplayerType)4;
public override string Author => "Arpharel";
public override string Description => "Allows you to repair your ship to full health";
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "NoUnrepairableDamage";
public const string PLUGIN_NAME = "No Unrepairable Damage";
public const string PLUGIN_VERSION = "1.0.8";
}
}