using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Unity.Netcode;
using UnityEngine;
using UnlimitedJetpack.Patches;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("0.0.0.0")]
namespace UnlimitedJetpack
{
internal static class ModInfo
{
internal const string modGUID = "PixelIndieDev_UnlimitedJetpack";
internal const string modName = "Unlimited Jetpack";
internal const string modVersion = "1.1.0.0";
}
[BepInPlugin("PixelIndieDev_UnlimitedJetpack", "Unlimited Jetpack", "1.1.0.0")]
public class JetpackFuelPatchBase : BaseUnityPlugin
{
private readonly Harmony harmony = new Harmony("PixelIndieDev_UnlimitedJetpack");
private static JetpackFuelPatchBase instance;
internal ManualLogSource logSource;
private void Awake()
{
if ((Object)(object)instance == (Object)null)
{
instance = this;
}
logSource = Logger.CreateLogSource("PixelIndieDev_UnlimitedJetpack");
harmony.PatchAll(typeof(JetpackFuelPatchBase));
harmony.PatchAll(typeof(JetpackUnlimitedFuelPatch));
harmony.PatchAll(typeof(NetworkPatch));
logSource.LogInfo((object)"Unlimited Jetpack (version - 1.1.0.0): patches applied successfully");
}
}
}
namespace UnlimitedJetpack.Patches
{
[HarmonyPatch(typeof(GrabbableObject))]
internal class JetpackUnlimitedFuelPatch
{
[HarmonyPatch("Update")]
[HarmonyPostfix]
[HarmonyPriority(0)]
private static void PatchJetpack(GrabbableObject __instance)
{
if (__instance is JetpackItem && ((NetworkBehaviour)__instance).IsOwner)
{
__instance.insertedBattery.charge = 1f;
}
}
}
[HarmonyPatch(typeof(NetworkManager))]
internal static class NetworkPatch
{
[HarmonyPostfix]
[HarmonyPatch("SetSingleton")]
private static void RegisterPrefab()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("PixelIndieDev_UnlimitedJetpack Prefab");
((Object)val).hideFlags = (HideFlags)(((Object)val).hideFlags | 0x3D);
Object.DontDestroyOnLoad((Object)(object)val);
NetworkObject obj = val.AddComponent<NetworkObject>();
typeof(NetworkObject).GetField("GlobalObjectIdHash", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(obj, GetHash("PixelIndieDev_UnlimitedJetpack"));
NetworkManager.Singleton.PrefabHandler.AddNetworkPrefab(val);
}
private static uint GetHash(string value)
{
return value?.Aggregate(17u, (uint current, char c) => (current * 31) ^ c) ?? 0;
}
}
}