using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Teleporter_Cooldown_Reset")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Teleporter_Cooldown_Reset")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("3bbc7bbc-ba96-40e0-a606-f86260a16fd9")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Teleporter_Cooldown_Reset
{
[BepInPlugin("rattenbonkers.Teleporter_Cooldown_Reset", "Teleporter_Cooldown_Reset", "1.0.1")]
public class Teleporter_Cooldown_ResetPlugin : BaseUnityPlugin
{
private const string MyGUID = "rattenbonkers.Teleporter_Cooldown_Reset";
private const string PluginName = "Teleporter_Cooldown_Reset";
private const string VersionString = "1.0.1";
private static readonly Harmony Harmony = new Harmony("rattenbonkers.Teleporter_Cooldown_Reset");
public static ManualLogSource Log = new ManualLogSource("Teleporter_Cooldown_Reset");
private void Awake()
{
Log = ((BaseUnityPlugin)this).Logger;
Harmony.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"PluginName: Teleporter_Cooldown_Reset, VersionString: 1.0.1 is loaded.");
}
}
}
namespace Teleporter_Cooldown_Reset.Patches
{
[HarmonyPatch(typeof(ShipTeleporter))]
internal class TeleporterPatches
{
private static FieldInfo cooldownProp = typeof(ShipTeleporter).GetField("cooldownTime", BindingFlags.Instance | BindingFlags.NonPublic);
[HarmonyPostfix]
[HarmonyPatch("Awake")]
private static void Awake(ShipTeleporter __instance)
{
cooldownProp.SetValue(__instance, 0f);
}
}
[HarmonyPatch(typeof(StartOfRound))]
internal class StartOfRoundPatches
{
private static FieldInfo cooldownProp = typeof(ShipTeleporter).GetField("cooldownTime", BindingFlags.Instance | BindingFlags.NonPublic);
[HarmonyPostfix]
[HarmonyPatch("EndOfGame")]
private static void EndGame(StartOfRound __instance)
{
ResetCooldown(__instance);
}
[HarmonyPostfix]
[HarmonyPatch("EndGameServerRpc")]
private static void EndGameServerRpc(StartOfRound __instance)
{
ResetCooldown(__instance);
}
[HarmonyPostfix]
[HarmonyPatch("EndOfGameClientRpc")]
private static void EndOfGameClientRpc(StartOfRound __instance)
{
ResetCooldown(__instance);
}
[HarmonyPostfix]
[HarmonyPatch("StartGameServerRpc")]
private static void StartGameServerRpc(StartOfRound __instance)
{
ResetCooldown(__instance);
}
[HarmonyPostfix]
[HarmonyPatch("StartGame")]
private static void StartGame(StartOfRound __instance)
{
ResetCooldown(__instance);
}
private static void ResetCooldown(StartOfRound instance)
{
ShipTeleporter[] array = Object.FindObjectsOfType<ShipTeleporter>();
foreach (ShipTeleporter obj in array)
{
cooldownProp.SetValue(obj, 0f);
}
}
}
}