using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
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 HarmonyLib;
using Microsoft.CodeAnalysis;
using Pigeon.Math;
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("Sparroh")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2")]
[assembly: AssemblyProduct("ArcLightningRework")]
[assembly: AssemblyTitle("ArcLightningRework")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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 ArcLightningRework
{
public static class ConfigManager
{
private const float DebounceSeconds = 0.25f;
private static ConfigFile config;
private static ManualLogSource logger;
private static FileSystemWatcher configWatcher;
private static volatile bool reloadPending;
private static float lastReloadTime;
public static ConfigEntry<bool> EnableArcLightningRework { get; private set; }
public static void Initialize(ConfigFile configFile, ManualLogSource log)
{
config = configFile;
logger = log;
EnableArcLightningRework = config.Bind<bool>("General", "Enable Rework", true, "Enhances lightning arc behavior for Scout Laser Rifle, allowing chaining and turbocharged upgrades.");
try
{
SetupFileWatcher();
}
catch (Exception ex)
{
logger.LogError((object)("Error setting up config file watcher: " + ex.Message));
}
}
public static void Tick()
{
if (!reloadPending || Time.unscaledTime - lastReloadTime < 0.25f)
{
return;
}
reloadPending = false;
lastReloadTime = Time.unscaledTime;
try
{
config.Reload();
logger.LogInfo((object)"Config reloaded from disk.");
}
catch (Exception ex)
{
logger.LogError((object)("Error reloading config: " + ex.Message));
}
}
public static void Dispose()
{
if (configWatcher != null)
{
configWatcher.EnableRaisingEvents = false;
configWatcher.Changed -= OnConfigFileChanged;
configWatcher.Created -= OnConfigFileChanged;
configWatcher.Renamed -= OnConfigFileChanged;
configWatcher.Dispose();
configWatcher = null;
}
}
private static void SetupFileWatcher()
{
configWatcher = new FileSystemWatcher(Paths.ConfigPath, "sparroh.arclightningrework.cfg");
configWatcher.NotifyFilter = NotifyFilters.FileName | NotifyFilters.Size | NotifyFilters.LastWrite;
configWatcher.Changed += OnConfigFileChanged;
configWatcher.Created += OnConfigFileChanged;
configWatcher.Renamed += OnConfigFileChanged;
configWatcher.EnableRaisingEvents = true;
}
private static void OnConfigFileChanged(object sender, FileSystemEventArgs e)
{
reloadPending = true;
}
}
[BepInPlugin("sparroh.arclightningrework", "ArcLightningRework", "1.0.2")]
[MycoMod(/*Could not decode attribute arguments.*/)]
public class ArcLightningReworkPlugin : BaseUnityPlugin
{
public const string PluginGUID = "sparroh.arclightningrework";
public const string PluginName = "ArcLightningRework";
public const string PluginVersion = "1.0.2";
internal static ManualLogSource Logger;
private Harmony harmony;
private void Awake()
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Expected O, but got Unknown
Logger = ((BaseUnityPlugin)this).Logger;
ConfigManager.Initialize(((BaseUnityPlugin)this).Config, Logger);
harmony = new Harmony("sparroh.arclightningrework");
harmony.PatchAll(typeof(ScoutLaserRifle_OnTargetDamaged_Patch));
harmony.PatchAll(typeof(ScoutLaserRifle_OnStartedFiring_Patch));
harmony.PatchAll(typeof(ScoutLaserRifle_OnStoppedFiring_Patch));
harmony.PatchAll(typeof(TextBlocks_GetString_Patch));
harmony.PatchAll(typeof(Upgrade_Flags_Getter_Patch));
harmony.PatchAll(typeof(Upgrade_Description_Getter_Patch));
harmony.PatchAll(typeof(UpgradeProperty_GetTurbochargedInfo_Patch));
harmony.PatchAll(typeof(UpgradeProperty_DMLR_LightningArc_GetStatData_Patch));
Logger.LogInfo((object)"ArcLightningRework v1.0.2 loaded successfully.");
}
private void Update()
{
ConfigManager.Tick();
}
private void OnDestroy()
{
ConfigManager.Dispose();
Harmony obj = harmony;
if (obj != null)
{
obj.UnpatchSelf();
}
}
}
[HarmonyPatch(typeof(ScoutLaserRifle), "OnTargetDamaged")]
public static class ScoutLaserRifle_OnTargetDamaged_Patch
{
internal static readonly Dictionary<ScoutLaserRifle, bool> lightningSpawned = new Dictionary<ScoutLaserRifle, bool>();
private static bool Prefix(ScoutLaserRifle __instance, in DamageCallbackData data)
{
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
if (!ConfigManager.EnableArcLightningRework.Value)
{
return true;
}
if (__instance.IsLaserModeActive && __instance.LaserData.lightningArcChance > 0f && ((Random)(ref Random.shared)).NextFloat() <= __instance.LaserData.lightningArcChance && (!lightningSpawned.ContainsKey(__instance) || !lightningSpawned[__instance]))
{
bool flag = false;
foreach (UpgradeInstance activeUpgrade in ((Gun)__instance).ActiveUpgrades)
{
int num = 0;
while (true)
{
int num2 = num;
UpgradePropertyList properties = activeUpgrade.Upgrade.Properties;
if (num2 >= ((UpgradePropertyList)(ref properties)).Count)
{
break;
}
properties = activeUpgrade.Upgrade.Properties;
if (((UpgradePropertyList)(ref properties))[num] is UpgradeProperty_DMLR_LightningArc && activeUpgrade.IsTurbocharged)
{
flag = true;
break;
}
num++;
}
if (flag)
{
break;
}
}
if (flag)
{
GameManager.Instance.SpawnLightningForkEffect_ServerRpc(NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)__instance), data.position, 10f, (TargetType)1, 10, 15f);
}
else
{
GameManager.Instance.SpawnLightningForkEffect_ServerRpc(NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)__instance), data.position, 10f, (TargetType)1, 1);
}
lightningSpawned[__instance] = true;
return false;
}
return true;
}
}
[HarmonyPatch(typeof(ScoutLaserRifle), "OnStartedFiring")]
public static class ScoutLaserRifle_OnStartedFiring_Patch
{
private static void Postfix(ScoutLaserRifle __instance)
{
if (ConfigManager.EnableArcLightningRework.Value)
{
ScoutLaserRifle_OnTargetDamaged_Patch.lightningSpawned[__instance] = false;
}
}
}
[HarmonyPatch(typeof(ScoutLaserRifle), "OnStoppedFiring")]
public static class ScoutLaserRifle_OnStoppedFiring_Patch
{
private static void Postfix(ScoutLaserRifle __instance)
{
if (ConfigManager.EnableArcLightningRework.Value && ScoutLaserRifle_OnTargetDamaged_Patch.lightningSpawned.ContainsKey(__instance))
{
ScoutLaserRifle_OnTargetDamaged_Patch.lightningSpawned[__instance] = false;
}
}
}
[HarmonyPatch(typeof(TextBlocks), "GetString", new Type[] { typeof(string) })]
public static class TextBlocks_GetString_Patch
{
private static void Postfix(ref string __result, string id)
{
if (ConfigManager.EnableArcLightningRework.Value && id == "ArcLightning_2")
{
__result = "Chains to 5 enemies with 15 base damage\nMax Hits: 10\nDamage: 15";
}
}
}
[HarmonyPatch(typeof(Upgrade), "get_Flags")]
public static class Upgrade_Flags_Getter_Patch
{
private static void Postfix(ref UpgradeFlags __result, Upgrade __instance)
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
if (!ConfigManager.EnableArcLightningRework.Value)
{
return;
}
try
{
int num = 0;
while (true)
{
int num2 = num;
UpgradePropertyList properties = __instance.Properties;
if (num2 < ((UpgradePropertyList)(ref properties)).Count)
{
properties = __instance.Properties;
if (((UpgradePropertyList)(ref properties))[num] is UpgradeProperty_DMLR_LightningArc)
{
__result = (UpgradeFlags)((uint)__result | 0x2000u);
break;
}
num++;
continue;
}
break;
}
}
catch
{
}
}
}
[HarmonyPatch(typeof(Upgrade), "get_Description")]
public static class Upgrade_Description_Getter_Patch
{
private static void Postfix(ref string __result, Upgrade __instance)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
if (!ConfigManager.EnableArcLightningRework.Value || (__instance.Flags & 0x2000) == 0)
{
return;
}
try
{
int num = 0;
while (true)
{
int num2 = num;
UpgradePropertyList properties = __instance.Properties;
if (num2 < ((UpgradePropertyList)(ref properties)).Count)
{
properties = __instance.Properties;
if (((UpgradePropertyList)(ref properties))[num] is UpgradeProperty_DMLR_LightningArc)
{
__result += "\nWhen Turbocharged:\nMax Hits: 10\nDamage: 15";
break;
}
num++;
continue;
}
break;
}
}
catch
{
}
}
}
[HarmonyPatch(typeof(UpgradeProperty), "GetTurbochargedInfo")]
public static class UpgradeProperty_GetTurbochargedInfo_Patch
{
private static bool Prefix(ref string __result, UpgradeProperty __instance)
{
if (!ConfigManager.EnableArcLightningRework.Value)
{
return true;
}
if (__instance is UpgradeProperty_DMLR_LightningArc)
{
__result = "Chains to 10 enemies with 15 base damage";
return false;
}
return true;
}
}
[HarmonyPatch(typeof(UpgradeProperty_DMLR_LightningArc), "GetStatData")]
public static class UpgradeProperty_DMLR_LightningArc_GetStatData_Patch
{
private static void Postfix(ref IEnumerator<StatData> __result, Random rand, IUpgradable gear, UpgradeInstance upgrade)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
if (ConfigManager.EnableArcLightningRework.Value)
{
__result = GetModifiedStatData(__result, rand, gear, upgrade);
}
}
private static IEnumerator<StatData> GetModifiedStatData(IEnumerator<StatData> original, Random rand, IUpgradable gear, UpgradeInstance upgrade)
{
while (original.MoveNext())
{
yield return original.Current;
}
yield return StatData.Create("Max Hits", 10f, (OverrideType)3, (LabelType)1, (string)null);
yield return StatData.Create("Damage", 15f, (OverrideType)3, (LabelType)1, (string)null);
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "ArcLightningRework";
public const string PLUGIN_NAME = "ArcLightningRework";
public const string PLUGIN_VERSION = "1.0.2";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}