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 FoxQuirks.Config;
using FoxQuirks.Patches;
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: AssemblyCompany("FoxQuirks")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.0.0.0")]
[assembly: AssemblyInformationalVersion("0.0.0-dev+064973ebd6dd63f8458a944fc0d06869d3f17889")]
[assembly: AssemblyProduct("FoxQuirks")]
[assembly: AssemblyTitle("FoxQuirks")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[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 FoxQuirks
{
[BepInPlugin("FoxQuirks", "FoxQuirks", "1.0.0")]
public class FoxQuirks : BaseUnityPlugin
{
internal static ManualLogSource Log;
private readonly Harmony _harmony = new Harmony("FoxQuirks");
private void Awake()
{
Log = ((BaseUnityPlugin)this).Logger;
FoxQuirksConfig.Initialize(((BaseUnityPlugin)this).Config);
_harmony.PatchAll(typeof(ShipSanctuaryPatches));
Log.LogInfo((object)"FoxQuirks has been initialized and patched.");
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "FoxQuirks";
public const string PLUGIN_NAME = "FoxQuirks";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace FoxQuirks.Patches
{
[HarmonyPatch]
internal class ShipSanctuaryPatches
{
[HarmonyPatch(typeof(EnemyAI), "PlayerIsTargetable")]
[HarmonyPostfix]
private static void PlayerIsTargetable_Patch(EnemyAI __instance, PlayerControllerB playerScript, ref bool __result)
{
if (FoxQuirksConfig.ShipSanctuaryEnabled.Value && __instance is BushWolfEnemy && __result && playerScript.isInHangarShipRoom)
{
__result = false;
}
}
[HarmonyPatch(typeof(EnemyAI), "GetClosestPlayer")]
[HarmonyPostfix]
private static void GetClosestPlayer_Patch(EnemyAI __instance, ref PlayerControllerB __result)
{
if (FoxQuirksConfig.ShipSanctuaryEnabled.Value && __instance is BushWolfEnemy && (Object)(object)__result != (Object)null && __result.isInHangarShipRoom)
{
__result = null;
}
}
[HarmonyPatch(typeof(BushWolfEnemy), "DoAIInterval")]
[HarmonyPrefix]
private static void BushWolfDoAIInterval_Patch(BushWolfEnemy __instance)
{
if (FoxQuirksConfig.ShipSanctuaryEnabled.Value && (Object)(object)((EnemyAI)__instance).targetPlayer != (Object)null && ((EnemyAI)__instance).targetPlayer.isInHangarShipRoom && ((EnemyAI)__instance).currentBehaviourStateIndex == 1)
{
((EnemyAI)__instance).SwitchToBehaviourState(0);
}
}
}
}
namespace FoxQuirks.Config
{
internal static class FoxQuirksConfig
{
public static ConfigEntry<bool> ShipSanctuaryEnabled { get; private set; }
public static void Initialize(ConfigFile config)
{
ShipSanctuaryEnabled = config.Bind<bool>("Ship Sanctuary", "Enabled", true, "Prevents foxes from targeting or attacking players inside the ship.");
}
}
}