using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LightningItemSlot.Patches;
using LightningItemSlot.Utilities;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("LightningItemSlot")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A template for Lethal Company")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+43206f0475d7dae18e393eaa115cfd192399712f")]
[assembly: AssemblyProduct("LightningItemSlot")]
[assembly: AssemblyTitle("LightningItemSlot")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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 LightningItemSlot
{
public class Enums
{
public enum eAutoLaunchOption
{
NONE,
ONLINE,
LAN
}
public enum eShowHiddenMoons
{
Never,
AfterDiscovery,
Always
}
public enum eMaskedEntityCopyLook
{
None,
Suit,
SuitAndCosmetics
}
public enum eSaveFurniturePlacement
{
None,
StartingFurniture,
All
}
public enum eShipCamRotation
{
None,
North,
East,
South,
West
}
public enum eMonitorNames
{
None,
Credits,
DangerLevel,
DaysSinceDeath,
Deadline,
DoorPower,
FancyWeather,
PlayerHealth,
PlayerHealthExact,
ProfitQuota,
Sales,
ScrapLeft,
ShipScrap,
Time,
TotalDays,
TotalDeaths,
TotalQuotas,
Weather,
ExternalCam,
InternalCam
}
public enum eValidKeys
{
None,
Space,
Enter,
Tab,
Backquote,
Quote,
Semicolon,
Comma,
Period,
Slash,
Backslash,
LeftBracket,
RightBracket,
Minus,
Equals,
A,
B,
C,
D,
E,
F,
G,
H,
I,
J,
K,
L,
M,
N,
O,
P,
Q,
R,
S,
T,
U,
V,
W,
X,
Y,
Z,
Digit1,
Digit2,
Digit3,
Digit4,
Digit5,
Digit6,
Digit7,
Digit8,
Digit9,
Digit0,
LeftShift,
RightShift,
LeftAlt,
AltGr,
LeftCtrl,
RightCtrl,
LeftWindows,
RightCommand,
ContextMenu,
Escape,
LeftArrow,
RightArrow,
UpArrow,
DownArrow,
Backspace,
PageDown,
PageUp,
Home,
End,
Insert,
Delete,
CapsLock,
NumLock,
PrintScreen,
ScrollLock,
Pause,
NumpadEnter,
NumpadDivide,
NumpadMultiply,
NumpadPlus,
NumpadMinus,
NumpadPeriod,
NumpadEquals,
Numpad0,
Numpad1,
Numpad2,
Numpad3,
Numpad4,
Numpad5,
Numpad6,
Numpad7,
Numpad8,
Numpad9,
F1,
F2,
F3,
F4,
F5,
F6,
F7,
F8,
F9,
F10,
F11,
F12,
MouseLeft,
MouseRight,
MouseMiddle,
MouseBackButton,
MouseForwardButton
}
public enum eItemsToKeep
{
None,
Held,
NonScrap,
All
}
public static ButtonControl GetMouseButtonMapping(eValidKeys mouseButton)
{
if (1 == 0)
{
}
ButtonControl result = (ButtonControl)(mouseButton switch
{
eValidKeys.MouseLeft => Mouse.current.leftButton,
eValidKeys.MouseRight => Mouse.current.rightButton,
eValidKeys.MouseMiddle => Mouse.current.middleButton,
eValidKeys.MouseBackButton => Mouse.current.backButton,
eValidKeys.MouseForwardButton => Mouse.current.forwardButton,
_ => throw new NotImplementedException(),
});
if (1 == 0)
{
}
return result;
}
}
internal class Metadata
{
public const string GUID = "Blinov34.LightningItemSlot";
public const string PLUGIN_NAME = "LightningItemSlot";
public const string VERSION = "0.0.1";
}
[BepInPlugin("LightningItemSlot", "LightningItemSlot", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
private const string UISection = "UI";
private readonly Harmony harmony = new Harmony("Blinov34.LightningItemSlot");
private static Plugin Instance;
public static ManualLogSource MLS { get; private set; }
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
MLS = ((BaseUnityPlugin)this).Logger;
AssetBundleHelper.Initialize();
MLS.LogInfo((object)"Configuration Initialized.");
harmony.PatchAll(typeof(StormyWeatherPatch));
harmony.PatchAll(typeof(HUDManagerPatch));
MLS.LogInfo((object)"StormyWeather patched.");
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin LightningItemSlot is loaded!");
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "LightningItemSlot";
public const string PLUGIN_NAME = "LightningItemSlot";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace LightningItemSlot.Utilities
{
internal class AssetBundleHelper
{
private static AssetBundle _bundle;
public static GameObject MonitorsPrefab { get; private set; }
public static Sprite Reticle { get; private set; }
public static GameObject MedStationPrefab { get; private set; }
public static GameObject LightningOverlay { get; private set; }
public static void Initialize()
{
if ((Object)(object)_bundle == (Object)null)
{
string text = Path.Combine(new FileInfo(Assembly.GetExecutingAssembly().Location).DirectoryName, "LightningItemSlotAssets");
if (!new FileInfo(text).Exists)
{
Plugin.MLS.LogError((object)Path.Combine(new FileInfo(Assembly.GetExecutingAssembly().Location).DirectoryName));
Plugin.MLS.LogError((object)"Could not find asset bundle!");
return;
}
_bundle = AssetBundle.LoadFromFile(text, 2424832663u);
Plugin.MLS.LogInfo((object)"Loading assets...");
MonitorsPrefab = _bundle.LoadAsset<GameObject>("MonitorGroup.prefab");
Reticle = _bundle.LoadAsset<Sprite>("reticle.png");
MedStationPrefab = _bundle.LoadAsset<GameObject>("MedStation.prefab");
LightningOverlay = _bundle.LoadAsset<GameObject>("LightningOverlay.prefab");
}
}
}
internal static class OtherModHelper
{
private static bool _initialized;
public const string MimicsGUID = "x753.Mimics";
public const string TwoRadarCamsGUID = "Zaggy1024.TwoRadarMaps";
public const string WeatherTweaksGUID = "WeatherTweaks";
private static Type _reservedPlayerPatcherType;
private static Type _reservedPlayerDataType;
private static FieldInfo _reservedPlayerData;
private static MethodInfo _isReservedSlot;
public static bool AdvancedCompanyActive { get; private set; }
public static bool ReservedItemSlotCoreActive { get; private set; }
public static bool FlashlightFixActive { get; private set; }
public static bool MimicsActive { get; private set; }
public static bool TwoRadarCamsActive { get; private set; }
public static bool WeatherTweaksActive { get; private set; }
public static ManualCameraRenderer TwoRadarCamsMapRenderer { get; set; }
private static FieldInfo PlayerData => _reservedPlayerData ?? (_reservedPlayerData = _reservedPlayerPatcherType.GetField("allPlayerData", BindingFlags.Static | BindingFlags.NonPublic));
private static MethodInfo IsReservedSlot => _isReservedSlot ?? (_isReservedSlot = _reservedPlayerDataType.GetMethod("IsReservedItemSlot"));
public static void Initialize()
{
if (!_initialized)
{
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
Assembly assembly = assemblies.FirstOrDefault((Assembly a) => a.FullName.Contains("ReservedItemSlotCore,"));
if (assembly != null)
{
_reservedPlayerPatcherType = assembly.GetType("ReservedItemSlotCore.Patches.PlayerPatcher");
_reservedPlayerDataType = assembly.GetType("ReservedItemSlotCore.ReservedPlayerData");
}
AdvancedCompanyActive = AppDomain.CurrentDomain.GetAssemblies().Any((Assembly a) => a.FullName.Contains("AdvancedCompany,"));
ReservedItemSlotCoreActive = assembly != null;
PluginInfo val = TypeLoader.FindPluginTypes<PluginInfo>(Paths.PluginPath, (Func<TypeDefinition, PluginInfo>)Chainloader.ToPluginInfo, (Func<AssemblyDefinition, bool>)null, (string)null).FirstOrDefault(delegate(KeyValuePair<string, List<PluginInfo>> p)
{
PluginInfo? obj = p.Value.FirstOrDefault();
return ((obj != null) ? obj.Metadata.GUID : null) == "ShaosilGaming.FlashlightFix";
}).Value?.FirstOrDefault();
FlashlightFixActive = val != null && val.Metadata.Version.Minor < 2;
MimicsActive = Chainloader.PluginInfos.ContainsKey("x753.Mimics");
TwoRadarCamsActive = Chainloader.PluginInfos.ContainsKey("Zaggy1024.TwoRadarMaps");
WeatherTweaksActive = Chainloader.PluginInfos.ContainsKey("WeatherTweaks");
if (AdvancedCompanyActive)
{
Plugin.MLS.LogDebug((object)"Advanced Company Detected");
}
if (ReservedItemSlotCoreActive)
{
Plugin.MLS.LogDebug((object)"Reserved Item Slot Core Detected");
}
if (MimicsActive)
{
Plugin.MLS.LogDebug((object)"Mimics Detected");
}
if (TwoRadarCamsActive)
{
Plugin.MLS.LogDebug((object)"Two Radar Cams Detected");
}
if (WeatherTweaksActive)
{
Plugin.MLS.LogDebug((object)"Weather Tweaks Detected");
}
_initialized = true;
}
}
public static bool IsReservedItemSlot(PlayerControllerB player, int slot)
{
if (!ReservedItemSlotCoreActive)
{
return false;
}
if (PlayerData == null || IsReservedSlot == null)
{
Plugin.MLS.LogWarning((object)"Could not load one or more ReservedItemSlot types when checking slot is reserved type. Assuming >= 4 is reserved");
return slot >= 4;
}
object obj = ((IDictionary)PlayerData.GetValue(null))[player];
return (bool)IsReservedSlot.Invoke(obj, new object[1] { slot });
}
}
}
namespace LightningItemSlot.Patches
{
internal static class HUDManagerPatch
{
public static GrabbableObject CurrentLightningTarget;
private static List<SpriteRenderer> _lightningOverlays;
[HarmonyPatch(typeof(HUDManager), "Start")]
[HarmonyPostfix]
[HarmonyPriority(200)]
private static void Start(HUDManager __instance)
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
_lightningOverlays = new List<SpriteRenderer>();
for (int i = 0; i < __instance.itemSlotIconFrames.Length; i++)
{
GameObject val = Object.Instantiate<GameObject>(AssetBundleHelper.LightningOverlay, ((Component)__instance.itemSlotIconFrames[i]).transform);
val.transform.SetLocalPositionAndRotation(Vector3.zero, Quaternion.identity);
val.transform.localScale = Vector3.one;
SpriteRenderer component = val.GetComponent<SpriteRenderer>();
((Renderer)component).enabled = false;
_lightningOverlays.Add(component);
}
}
[HarmonyPatch(typeof(HUDManager), "Update")]
[HarmonyPostfix]
private static void Update(HUDManager __instance)
{
if (_lightningOverlays.Count <= 0 || !((Object)(object)HUDManager.Instance != (Object)null) || !((Object)(object)StartOfRound.Instance.localPlayerController != (Object)null))
{
return;
}
for (int num = 0; num < Mathf.Min(new int[3]
{
HUDManager.Instance.itemSlotIconFrames.Length,
_lightningOverlays.Count,
StartOfRound.Instance.localPlayerController.ItemSlots.Length
}); num++)
{
bool flag = (Object)(object)CurrentLightningTarget != (Object)null && (Object)(object)StartOfRound.Instance.localPlayerController.ItemSlots[num] == (Object)(object)CurrentLightningTarget;
if (((Renderer)_lightningOverlays[num]).enabled != flag)
{
((Renderer)_lightningOverlays[num]).enabled = flag;
}
}
}
}
internal static class StormyWeatherPatch
{
public static StormyWeather Instance { get; private set; }
[HarmonyPatch(typeof(StormyWeather), "OnEnable")]
[HarmonyPostfix]
private static void OnEnable(StormyWeather __instance)
{
if ((Object)(object)Instance != (Object)(object)__instance)
{
Instance = __instance;
}
}
[HarmonyPatch(typeof(StormyWeather), "OnDisable")]
[HarmonyPostfix]
private static void OnDisable()
{
Instance = null;
}
[HarmonyPatch(typeof(StormyWeather), "SetStaticElectricityWarning")]
[HarmonyPostfix]
private static void SetStaticElectricityWarning(NetworkObject warningObject)
{
((Component)warningObject).TryGetComponent<GrabbableObject>(ref HUDManagerPatch.CurrentLightningTarget);
}
[HarmonyPatch(typeof(StormyWeather), "LightningStrike")]
[HarmonyPostfix]
private static void LightningStrike(bool useTargetedObject)
{
if (useTargetedObject)
{
HUDManagerPatch.CurrentLightningTarget = null;
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
internal IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}