using System;
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.Logging;
using CSync.Extensions;
using CSync.Lib;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
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("EnoPM")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Makes the Zap gun easy to use")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2+3185e73309922657cb4a3fb0ac215034c1a0ff02")]
[assembly: AssemblyProduct("EasyZapGun")]
[assembly: AssemblyTitle("EnoPM.EasyZapGun")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.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 EnoPM.EasyZapGun
{
public sealed class HostConfig : SyncedConfig2<HostConfig>
{
private static bool SyncedState { get; set; }
[field: SyncedEntryField]
public SyncedEntry<bool> Enabled { get; }
[field: SyncedEntryField]
public SyncedEntry<bool> DisableGunOverheat { get; }
public static bool IsSynced()
{
if (!Object.op_Implicit((Object)(object)NetworkManager.Singleton))
{
return false;
}
if (NetworkManager.Singleton.IsServer)
{
return true;
}
if (!SyncedState)
{
Plugin.Log.LogError((object)"(HostConfig) Client joined without synced state");
}
return SyncedState;
}
public HostConfig(ConfigFile configFile)
: base("easyzapgun.lc.eno.pm")
{
Enabled = SyncedBindingExtensions.BindSyncedEntry<bool>(configFile, "easyzapgun.lc.eno.pm", "Enabled", true, "Globally enable/disable the plugin");
DisableGunOverheat = SyncedBindingExtensions.BindSyncedEntry<bool>(configFile, "easyzapgun.lc.eno.pm", "DisableOverheat", true, "Disable Zap gun overheat");
ConfigManager.Register<HostConfig>((SyncedConfig2<HostConfig>)this);
}
internal static void OnInitialSyncCompleted(object _0, EventArgs _1)
{
Plugin.Log.LogInfo((object)"HostConfig synced");
SyncedState = true;
}
}
[BepInPlugin("easyzapgun.lc.eno.pm", "EasyZapGun", "1.0.2")]
[BepInDependency("com.sigurd.csync", "5.0.1")]
public class Plugin : BaseUnityPlugin
{
private static readonly Harmony HarmonyPatcher = new Harmony("easyzapgun.lc.eno.pm");
public static HostConfig HostConfig { get; private set; }
public static ManualLogSource Log { get; private set; }
private void Awake()
{
Log = ((BaseUnityPlugin)this).Logger;
((BaseUnityPlugin)this).Config.SaveOnConfigSet = false;
HostConfig = new HostConfig(((BaseUnityPlugin)this).Config);
((BaseUnityPlugin)this).Config.Save();
HarmonyPatcher.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin easyzapgun.lc.eno.pm is loaded!");
((SyncedConfig2<HostConfig>)HostConfig).InitialSyncCompleted += HostConfig.OnInitialSyncCompleted;
}
}
internal static class ProjectInfos
{
internal const string Guid = "easyzapgun.lc.eno.pm";
internal const string Name = "EasyZapGun";
internal const string Version = "1.0.2";
}
}
namespace EnoPM.EasyZapGun.Patches
{
[HarmonyPatch(typeof(PatcherTool))]
internal static class PatcherToolPatches
{
[HarmonyPrefix]
[HarmonyPatch("ShiftBendRandomizer")]
private static void ShiftBendRandomizerPrefix(PatcherTool __instance)
{
if (HostConfig.IsSynced() && SyncedEntry<bool>.op_Implicit(Plugin.HostConfig.Enabled))
{
__instance.bendMultiplier = 0f;
}
}
[HarmonyPostfix]
[HarmonyPatch("LateUpdate")]
private static void LateUpdatePostfix(PatcherTool __instance)
{
if (HostConfig.IsSynced() && SyncedEntry<bool>.op_Implicit(Plugin.HostConfig.DisableGunOverheat))
{
__instance.gunOverheat = 0f;
}
}
}
}