using System;
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 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: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("Kittenji")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("NavMeshInCompany")]
[assembly: AssemblyTitle("NavMeshInCompany")]
[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 Kittenji.NavMeshInCompany
{
[BepInPlugin("dev.kittenji.NavMeshInCompany", "NavMeshInCompany", "1.0.3")]
public class Plugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(DepositItemsDesk))]
internal class DepositItemsDeskPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
internal static void StartPatch(DepositItemsDesk __instance)
{
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
try
{
GameObject[] array = GameObject.FindGameObjectsWithTag("OutsideAINode");
for (int i = 0; i < array.Length; i++)
{
Object.Destroy((Object)(object)array[i]);
}
array = GameObject.FindGameObjectsWithTag("AINode");
for (int i = 0; i < array.Length; i++)
{
Object.Destroy((Object)(object)array[i]);
}
Debug.Log((object)"Instantiating Company Navigation!");
Transform transform = Object.Instantiate<GameObject>(navPrefab, ((Component)__instance).transform.parent, true).transform;
transform.position = Vector3.zero;
transform.rotation = Quaternion.identity;
transform.localScale = Vector3.one;
Transform child = transform.GetChild(0);
RoundManager.Instance.outsideAINodes = (GameObject[])(object)new GameObject[child.childCount];
for (int j = 0; j < child.childCount; j++)
{
RoundManager.Instance.outsideAINodes[j] = ((Component)child.GetChild(j)).gameObject;
}
child = transform.GetChild(1);
RoundManager.Instance.insideAINodes = (GameObject[])(object)new GameObject[child.childCount];
for (int k = 0; k < child.childCount; k++)
{
RoundManager.Instance.insideAINodes[k] = ((Component)child.GetChild(k)).gameObject;
}
}
catch (Exception ex)
{
Debug.LogException(ex);
}
}
}
public const string pluginGUID = "dev.kittenji.NavMeshInCompany";
public const string pluginName = "NavMeshInCompany";
public const string pluginVersion = "1.0.3";
public static readonly Harmony harmony = new Harmony("dev.kittenji.NavMeshInCompany");
public static Assets assets { get; private set; }
public static GameObject navPrefab { get; internal set; }
private void Awake()
{
assets = new Assets();
navPrefab = assets.LoadByName<GameObject>("CompanyNavSurface.prefab", nameOnly: false);
harmony.PatchAll();
}
}
public static class ResourceUtils
{
public static Stream Get(string name)
{
Assembly executingAssembly = Assembly.GetExecutingAssembly();
string[] manifestResourceNames = executingAssembly.GetManifestResourceNames();
if (manifestResourceNames.Length == 0)
{
throw new FileNotFoundException("Assembly does not contain any resource stream names.");
}
string text = manifestResourceNames.FirstOrDefault((string n) => n.EndsWith(name));
if (string.IsNullOrEmpty(text))
{
throw new FileNotFoundException("Assembly does not contain a resource stream ending with '" + name + "'");
}
return executingAssembly.GetManifestResourceStream(text);
}
public static string GetString(string name)
{
using Stream stream = Get(name);
using StreamReader streamReader = new StreamReader(stream);
return streamReader.ReadToEnd();
}
}
public class Assets
{
private readonly AssetBundle mainAssetBundle;
private readonly string[] allAssetNames;
public Assets(string name = ".bundle")
{
mainAssetBundle = AssetBundle.LoadFromStream(ResourceUtils.Get(name));
allAssetNames = mainAssetBundle.GetAllAssetNames();
}
public T Load<T>(string name) where T : Object
{
if (name == null)
{
return default(T);
}
return mainAssetBundle.LoadAsset<T>(name);
}
public T LoadByName<T>(string name, bool nameOnly = false) where T : Object
{
string name2 = allAssetNames.FirstOrDefault((string x) => (nameOnly ? Path.GetFileNameWithoutExtension(x) : Path.GetFileName(x)).Equals(name, StringComparison.OrdinalIgnoreCase));
return Load<T>(name2);
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}