using System;
using System.Collections.Generic;
using System.Diagnostics;
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.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[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-CSharp")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: AssemblyCompany("ShipScanRange")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("The main entrance and ship can be scanned from any range, ignoring LOS. This makes it easier to find your way around the map, especially for custom maps. The item dropship has the same properties applied if another mod enables it to be scanned (e.g. GeneralImprovements)")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: AssemblyInformationalVersion("0.0.1")]
[assembly: AssemblyProduct("ShipScanRange")]
[assembly: AssemblyTitle("ShipScanRange")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.1.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 ShipScanRange
{
[BepInPlugin("DBJ.ShipScanRange", "ShipScanRange", "1.0.0")]
public class ShipScanRangeBase : BaseUnityPlugin
{
private const string modGUID = "DBJ.ShipScanRange";
private const string modName = "Ship Scan Range";
private const string modVersion = "0.0.1";
public static readonly string[] scannables = new string[3] { "ship", "main entrance", "dropship" };
private readonly Harmony harmony = new Harmony("DBJ.ShipScanRange");
public static ManualLogSource mls;
private void Awake()
{
mls = Logger.CreateLogSource("DBJ.ShipScanRange");
harmony.PatchAll();
foreach (MethodBase patchedMethod in harmony.GetPatchedMethods())
{
mls.LogInfo((object)(patchedMethod.ToString() + " patched."));
}
mls.LogInfo((object)"Ship Scan Range has loaded!");
}
}
[HarmonyPatch(typeof(HUDManager))]
public class AssignNewNodesPatch
{
[HarmonyPatch("AssignNewNodes")]
[HarmonyPostfix]
public static void AssignNewNodes(PlayerControllerB playerScript)
{
if (playerScript.isInsideFactory || HUDManager.Instance.nodesOnScreen.Count >= HUDManager.Instance.scanElements.Length)
{
return;
}
Plane[] camPlanes = GeometryUtility.CalculateFrustumPlanes(playerScript.gameplayCamera);
IOrderedEnumerable<KeyValuePair<string, ScanNodeProperties>> orderedEnumerable = from s in (from s in Object.FindObjectsOfType<ScanNodeProperties>()
select new KeyValuePair<string, ScanNodeProperties>(s.headerText.ToLower(), s)).Where(delegate(KeyValuePair<string, ScanNodeProperties> s)
{
//IL_003f: 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)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
Collider component = ((Component)s.Value).GetComponent<Collider>();
return component != null && component.enabled && ShipScanRangeBase.scannables.Contains(s.Key) && GeometryUtility.TestPlanesAABB(camPlanes, new Bounds(((Component)s.Value).transform.position, Vector3.one));
})
orderby s.Key == "ship" descending
select s;
CollectionExtensions.Do<KeyValuePair<string, ScanNodeProperties>>((IEnumerable<KeyValuePair<string, ScanNodeProperties>>)orderedEnumerable, (Action<KeyValuePair<string, ScanNodeProperties>>)delegate(KeyValuePair<string, ScanNodeProperties> s)
{
ScanNodeProperties value = s.Value;
int maxRange;
if (!(s.Key != "dropship"))
{
ItemDropship obj = Object.FindAnyObjectByType<ItemDropship>();
if (obj == null || !obj.deliveringOrder)
{
maxRange = 0;
goto IL_0036;
}
}
maxRange = 1000;
goto IL_0036;
IL_0036:
value.maxRange = maxRange;
s.Value.requiresLineOfSight = false;
if (HUDManager.Instance.nodesOnScreen.Count < HUDManager.Instance.scanElements.Length)
{
HUDManager.Instance.AttemptScanNode(s.Value, HUDManager.Instance.nodesOnScreen.Count, playerScript);
}
});
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "ShipScanRange";
public const string PLUGIN_NAME = "ShipScanRange";
public const string PLUGIN_VERSION = "0.0.1";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}