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 HarmonyLib;
using Microsoft.CodeAnalysis;
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("ScannableCodes")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.6.0")]
[assembly: AssemblyInformationalVersion("1.0.6+77d072b816829f9b17754e3c8879aa4d5d2010c2")]
[assembly: AssemblyProduct("ScannableCodes")]
[assembly: AssemblyTitle("ScannableCodes")]
[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 ScannableCodes
{
[BepInPlugin("Dev1A3.ScannableCodes", "ScannableCodes", "1.0.0")]
internal class PluginLoader : BaseUnityPlugin
{
internal const string modGUID = "Dev1A3.ScannableCodes";
private readonly Harmony harmony = new Harmony("Dev1A3.ScannableCodes");
private const string modVersion = "1.0.0";
private static bool initialized;
internal static ManualLogSource logSource;
public static PluginLoader Instance { get; private set; }
private void Awake()
{
if (!initialized)
{
initialized = true;
Instance = this;
ScanConfig.InitConfig();
Assembly executingAssembly = Assembly.GetExecutingAssembly();
harmony.PatchAll(executingAssembly);
logSource = Logger.CreateLogSource("Dev1A3.ScannableCodes");
logSource.LogInfo((object)"Loaded ScannableCodes");
}
}
public void BindConfig<T>(ref ConfigEntry<T> config, string section, string key, T defaultValue, string description = "")
{
config = ((BaseUnityPlugin)this).Config.Bind<T>(section, key, defaultValue, description);
}
}
internal class ScanConfig
{
internal static ConfigEntry<bool> SpikeTrapScanEnabled;
internal static void InitConfig()
{
PluginLoader.Instance.BindConfig(ref SpikeTrapScanEnabled, "Settings", "Spike Traps", defaultValue: true, "Should spike traps be able to be scanned?");
}
}
[HarmonyPatch]
internal static class ScanPatch
{
[HarmonyPatch(typeof(TerminalAccessibleObject), "SetCodeTo")]
[HarmonyPostfix]
private static void SetCodeTo(ref TerminalAccessibleObject __instance, int codeIndex)
{
if (__instance.objectCode == null)
{
return;
}
Transform val = (Object.op_Implicit((Object)(object)((Component)__instance).transform.parent) ? ((Component)__instance).transform.parent : ((Component)__instance).transform);
ScanNodeProperties componentInChildren = ((Component)val).GetComponentInChildren<ScanNodeProperties>();
if ((Object)(object)componentInChildren != (Object)null)
{
componentInChildren.subText = " " + __instance.objectCode.ToUpper();
if (__instance.isBigDoor)
{
componentInChildren.maxRange = 8;
}
else if ((Object)(object)((Component)__instance).GetComponent<Turret>() != (Object)null)
{
componentInChildren.maxRange = 10;
}
PluginLoader.logSource.LogDebug((object)$"Set code of {((Object)val).name}: {__instance.objectCode.ToUpper()} (Range: {componentInChildren.maxRange})");
}
}
[HarmonyPatch(typeof(SpikeRoofTrap), "Start")]
[HarmonyPostfix]
private static void SpikeRoofTrap_Start(SpikeRoofTrap __instance)
{
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
if (ScanConfig.SpikeTrapScanEnabled.Value)
{
GameObject obj = GameObject.CreatePrimitive((PrimitiveType)3);
obj.tag = "DoNotSet";
obj.layer = 22;
obj.transform.parent = __instance.stickingPointsContainer;
obj.transform.localPosition = new Vector3(-0.8f, 0f, -0.5f);
Object.Destroy((Object)(object)obj.GetComponent<MeshFilter>());
Object.Destroy((Object)(object)obj.GetComponent<MeshRenderer>());
ScanNodeProperties obj2 = obj.AddComponent<ScanNodeProperties>();
obj2.headerText = "Spike Trap";
obj2.subText = "";
obj2.requiresLineOfSight = true;
obj2.maxRange = 8;
obj2.minRange = 1;
obj2.scrapValue = 0;
obj2.creatureScanID = -1;
obj2.nodeType = 1;
}
}
}
internal static class MyPluginInfo
{
public const string PLUGIN_GUID = "ScannableCodes";
public const string PLUGIN_NAME = "ScannableCodes";
public const string PLUGIN_VERSION = "1.0.6";
}
}