using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using CSync.Lib;
using CSync.Util;
using ExtendMouthDogSlide.Patches;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
[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("ExtendMouthDogSlide")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+2296cfa90be3376b92b10587e966316ba378f53a")]
[assembly: AssemblyProduct("ExtendMouthDogSlide")]
[assembly: AssemblyTitle("ExtendMouthDogSlide")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
}
}
}
namespace ExtendMouthDogSlide
{
[DataContract]
public class ConfigSettings : SyncedConfig<ConfigSettings>
{
[DataMember]
public SyncedEntry<float> configSlideDuration { get; private set; }
[DataMember]
public SyncedEntry<float> configTopSpeed { get; private set; }
[DataMember]
public SyncedEntry<bool> configAlwaysTopSpeed { get; private set; }
public ConfigSettings(ConfigFile cfg)
: base("dummy.SlipperyDogs")
{
ConfigManager.Register<ConfigSettings>(this);
configSlideDuration = Extensions.BindSyncedEntry<float>(cfg, "SlipperyDogs", "SlideDuration", 5f, "Duration of the slide after a lunge in seconds. For vanilla settings set this to 2.3.");
configTopSpeed = Extensions.BindSyncedEntry<float>(cfg, "SlipperyDogs", "TopSpeed", 15f, "Starting speed of the lunge. For vanilla settings, set this to 13.");
configAlwaysTopSpeed = Extensions.BindSyncedEntry<bool>(cfg, "SlipperyDogs", "AlwaysTopSpeed", true, "If the whole slide is at top speed. For vanilla settings, set this to false.");
}
}
[BepInPlugin("dummy.SlipperyDogs", "dummy.SlipperyDogs", "1.0.2")]
public class Plugin : BaseUnityPlugin
{
private readonly Harmony harmony = new Harmony("dummy.SlipperyDogs");
public static Plugin instance;
private void Awake()
{
if ((Object)(object)instance == (Object)null)
{
instance = this;
}
new ConfigSettings(((BaseUnityPlugin)this).Config);
harmony.PatchAll(typeof(Plugin));
harmony.PatchAll(typeof(MouthDogAIPatch));
harmony.PatchAll(typeof(ConfigSettings));
((BaseUnityPlugin)this).Logger.LogInfo((object)"SlipperyDogs loaded");
}
public static void Log(string message)
{
((BaseUnityPlugin)instance).Logger.LogInfo((object)(message ?? ""));
}
public static void LogError(string message)
{
((BaseUnityPlugin)instance).Logger.LogError((object)message);
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "dummy.SlipperyDogs";
public const string PLUGIN_NAME = "SlipperyDogs";
public const string PLUGIN_VERSION = "1.0.2";
}
}
namespace ExtendMouthDogSlide.Patches
{
[HarmonyPatch(typeof(MouthDogAI))]
internal class MouthDogAIPatch
{
private static readonly float customSlideDuration = SyncedEntry<float>.op_Implicit(SyncedInstance<ConfigSettings>.Instance.configSlideDuration);
private static readonly float topSpeed = SyncedEntry<float>.op_Implicit(SyncedInstance<ConfigSettings>.Instance.configTopSpeed);
private static readonly bool alwaysTopSpeed = SyncedEntry<bool>.op_Implicit(SyncedInstance<ConfigSettings>.Instance.configAlwaysTopSpeed);
private static readonly float defaultSlideDuration = (topSpeed - 1.5f) / 5f;
private static float tempSlideDuration = customSlideDuration;
[HarmonyPostfix]
[HarmonyPatch("Update")]
private static void ChangeSlideDuration(MouthDogAI __instance, int ___currentBehaviourStateIndex, NavMeshAgent ___agent)
{
if (___currentBehaviourStateIndex != 3 || !((NetworkBehaviour)__instance).IsOwner)
{
return;
}
if (alwaysTopSpeed)
{
if (tempSlideDuration <= 0f)
{
___agent.speed = 1.49f;
tempSlideDuration = customSlideDuration;
}
else
{
tempSlideDuration -= Time.deltaTime;
___agent.speed = topSpeed;
}
}
else if (customSlideDuration <= 0f)
{
___agent.speed = 1.49f;
}
else if (customSlideDuration < defaultSlideDuration)
{
float num = customSlideDuration * 5f;
float num2 = (topSpeed - 1.5f - num) / customSlideDuration;
___agent.speed -= Time.deltaTime * num2;
}
else if (customSlideDuration != defaultSlideDuration)
{
float num = customSlideDuration * 5f;
float num2 = (0f - (topSpeed - 1.5f - num)) / customSlideDuration;
___agent.speed += Time.deltaTime * num2;
}
}
[HarmonyPostfix]
[HarmonyPatch("EnterLunge")]
private static void ChangeSlideDistance(MouthDogAI __instance, Ray ___ray, RaycastHit ___rayHit, NavMeshAgent ___agent)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: 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_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
float num = 50f;
Vector3 val = ((!Physics.Raycast(___ray, ref ___rayHit, num, StartOfRound.Instance.collidersAndRoomMask)) ? ((Ray)(ref ___ray)).GetPoint(num) : ((RaycastHit)(ref ___rayHit)).point);
val = RoundManager.Instance.GetNavMeshPosition(val, default(NavMeshHit), 5f, -1);
((EnemyAI)__instance).SetDestinationToPosition(val, false);
___agent.speed = topSpeed;
}
}
}