using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
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 Unity.Netcode;
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("LCPointPet")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Can I Pet That Dog")]
[assembly: AssemblyTitle("LCPointPet")]
[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 LCPointPet
{
[BepInPlugin("raptureawaits.pointpet", "Can I Pet That Dog?", "1.0.0")]
public class LCPointPetBase : BaseUnityPlugin
{
private const string mod_guid = "raptureawaits.pointpet";
private const string mod_name = "Can I Pet That Dog?";
private const string mod_version = "1.0.0";
internal static LCPointPetBase instance;
internal static ManualLogSource modlog;
private readonly Harmony harmony = new Harmony("raptureawaits.pointpet");
internal static AssetBundle new_sounds;
private AudioClip[] clips;
internal Random rand;
public static float volume = 1f;
public static int point_mask = 524288;
public static string[] dog_collider_names = new string[2] { "MouthDogModel", "MouthDog(Clone)" };
private int _last_played;
public TimeSpan cooldown_seconds = new TimeSpan(0, 0, 3);
public Dictionary<ulong, DateTime> cooldowns = new Dictionary<ulong, DateTime>();
public int last_played
{
get
{
return _last_played;
}
set
{
_last_played = value;
}
}
private void Awake()
{
if ((Object)(object)instance == (Object)null)
{
instance = this;
}
modlog = Logger.CreateLogSource("PointPet");
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
new_sounds = AssetBundle.LoadFromFile(Path.Combine(directoryName, "pointpet"));
if ((Object)(object)new_sounds == (Object)null)
{
modlog.LogError((object)"Failed to load AssetBundle.");
return;
}
clips = new_sounds.LoadAllAssets<AudioClip>();
if (clips == null || clips.Length == 0)
{
modlog.LogError((object)"Failed to load audio data from extracted assets.");
}
rand = new Random();
harmony.PatchAll();
modlog.LogInfo((object)"Plugin raptureawaits.pointpet is loaded!");
}
public AudioClip getRandomClip()
{
int num;
for (num = last_played; num == last_played; num = rand.Next(clips.Length))
{
}
last_played = num;
return clips[num];
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "LCPointPet";
public const string PLUGIN_NAME = "Can I Pet That Dog";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace LCPointPet.Patches
{
[HarmonyPatch(typeof(PlayerControllerB))]
internal class PointPetPatch
{
internal static ManualLogSource modlog = LCPointPetBase.modlog;
internal static LCPointPetBase b = LCPointPetBase.instance;
[HarmonyPatch("PerformEmote")]
[HarmonyPostfix]
private static void PerformEmotePostfix(int emoteID, PlayerControllerB __instance, ref bool ___performingEmote, ref AudioSource ___itemAudio, ref ulong ___playerClientId)
{
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
ulong key = ___playerClientId;
bool flag = b.cooldowns.ContainsKey(key);
if (flag && DateTime.Now > b.cooldowns[key])
{
b.cooldowns.Remove(key);
flag = false;
}
bool flag2 = ((NetworkBehaviour)__instance).IsOwner && __instance.isPlayerControlled;
if (emoteID == 2 && flag2 && !flag)
{
Vector3 position = ((Component)__instance.gameplayCamera).transform.position;
Vector3 forward = ((Component)__instance.gameplayCamera).transform.forward;
RaycastHit hit_collider = default(RaycastHit);
if (Physics.Raycast(position, forward, ref hit_collider, float.PositiveInfinity, LCPointPetBase.point_mask) && Array.Exists(LCPointPetBase.dog_collider_names, (string element) => element == ((Object)((RaycastHit)(ref hit_collider)).collider).name))
{
modlog.LogInfo((object)$"[{((NetworkBehaviour)__instance).OwnerClientId}] Can I pet that dog?");
___itemAudio.PlayOneShot(b.getRandomClip(), LCPointPetBase.volume);
b.cooldowns.Add(___playerClientId, DateTime.Now + b.cooldown_seconds);
}
}
}
}
[HarmonyPatch(typeof(StartOfRound))]
internal class CooldownResetPatch
{
internal static ManualLogSource modlog = LCPointPetBase.modlog;
internal static LCPointPetBase b = LCPointPetBase.instance;
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void StartPostfix()
{
b.cooldowns.Clear();
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}