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 HarmonyLib;
using Microsoft.CodeAnalysis;
using ModsCacones.Patches;
using Photon.Pun;
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: AssemblyCompany("Desay1")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+43f134ab5fe98991267f5b826c14538f4c468c1f")]
[assembly: AssemblyProduct("ModsCacones")]
[assembly: AssemblyTitle("ModsCacones")]
[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.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;
}
}
}
public static class EnemyDuckExtension
{
private static readonly ConditionalWeakTable<EnemyDuck, EnemyDuckData> data = new ConditionalWeakTable<EnemyDuck, EnemyDuckData>();
public static EnemyDuckData GetDuckData(this EnemyDuck instance)
{
return data.GetOrCreateValue(instance);
}
}
namespace ModsCacones
{
[HarmonyPatch(typeof(PlayerController))]
internal static class ExamplePlayerControllerPatch
{
[HarmonyPrefix]
[HarmonyPatch("Start")]
private static void Start_Prefix(PlayerController __instance)
{
ModsCacones.Logger.LogDebug((object)$"{__instance} Start Prefix");
}
[HarmonyPostfix]
[HarmonyPatch("Start")]
private static void Start_Postfix(PlayerController __instance)
{
ModsCacones.Logger.LogDebug((object)$"{__instance} Start Postfix");
}
}
[BepInPlugin("Desay1.ModsCacones", "ModsCacones", "1.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class ModsCacones : BaseUnityPlugin
{
private static string modFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
internal static ModsCacones Instance { get; private set; } = null;
internal static ManualLogSource Logger => Instance._logger;
private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;
internal Harmony? Harmony { get; set; }
private void Awake()
{
Instance = this;
((Component)this).gameObject.transform.parent = null;
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
LoadSounds("snipermissbundle", EnemyHunterPatch.ClipsMiss);
LoadSounds("sniperhitbundle", EnemyHunterPatch.ClipsHitPlayer);
LoadSounds("sniperchapas", EnemyHunterPatch.ClipsHitChapita);
LoadSounds("sniperjoker", EnemyHunterPatch.ClipsHitJoker);
LoadSounds("demoangry", EnemyDuckPatch.AngryClips);
LoadSounds("democalm", EnemyDuckPatch.DestranClips);
LoadSounds("demoroto", EnemyDuckPatch.ValRotoClips);
LoadSounds("demostun", EnemyDuckPatch.StunClips);
Patch();
Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
}
private void LoadSounds(string bundleName, List<AudioClip> loadedClips)
{
string text = Path.Combine(modFolder, bundleName);
AssetBundle val = AssetBundle.LoadFromFile(text);
if ((Object)(object)val == (Object)null)
{
return;
}
AudioClip[] array = val.LoadAllAssets<AudioClip>();
if (array.Length != 0)
{
AudioClip[] array2 = array;
foreach (AudioClip item in array2)
{
loadedClips.Add(item);
}
}
}
internal void Patch()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
//IL_0026: Expected O, but got Unknown
if (Harmony == null)
{
Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
Harmony val2 = val;
Harmony = val;
}
Harmony.PatchAll();
}
internal void Unpatch()
{
Harmony? harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
private void Update()
{
}
}
}
namespace ModsCacones.Patches
{
[HarmonyPatch(typeof(EnemyDuck))]
public class EnemyDuckPatch
{
public static List<AudioClip> AngryClips = new List<AudioClip>();
public static List<AudioClip> DestranClips = new List<AudioClip>();
public static List<AudioClip> ValRotoClips = new List<AudioClip>();
public static List<AudioClip> StunClips = new List<AudioClip>();
public static int stunTimer = 0;
[HarmonyPatch("Awake")]
[HarmonyPrefix]
private static void AwakePatch(EnemyDuck __instance)
{
if (SemiFunc.IsMasterClientOrSingleplayer())
{
PhotonView component = ((Component)__instance).gameObject.GetComponent<PhotonView>();
if ((Object)(object)component == (Object)null)
{
component = ((Component)__instance).gameObject.AddComponent<PhotonView>();
}
mySync orSetSync_Duck = myHelper.GetOrSetSync_Duck(__instance);
}
}
[HarmonyPatch("StateAttackStart")]
[HarmonyPrefix]
private static void GritoEnojo(EnemyDuck __instance)
{
if (SemiFunc.IsMasterClientOrSingleplayer() && __instance.stateImpulse)
{
__instance.GetDuckData().angry = true;
mySync orSetSync_Duck = myHelper.GetOrSetSync_Duck(__instance);
if ((Object)(object)orSetSync_Duck != (Object)null)
{
orSetSync_Duck.SyncSound("duck", "angry", myHelper.GetRandomSound(AngryClips));
}
}
}
[HarmonyPatch("StateDeTransform")]
[HarmonyPostfix]
private static void GritoDestr(EnemyDuck __instance)
{
if (SemiFunc.IsMasterClientOrSingleplayer() && __instance.stateTimer <= 0f)
{
__instance.GetDuckData().angry = false;
mySync orSetSync_Duck = myHelper.GetOrSetSync_Duck(__instance);
if ((Object)(object)orSetSync_Duck != (Object)null)
{
orSetSync_Duck.SyncSound("duck", "calm", myHelper.GetRandomSound(DestranClips));
}
}
}
[HarmonyPatch("StateStun")]
[HarmonyPostfix]
private static void Stuneado(EnemyDuck __instance)
{
if (SemiFunc.IsMasterClientOrSingleplayer() && __instance.enemy.IsStunned() && (((__instance.enemy.StateStunned.stunTimer >= 6f) & (__instance.enemy.StateStunned.stunTimer <= 7f)) || ((__instance.enemy.StateStunned.stunTimer >= 12f) & (__instance.enemy.StateStunned.stunTimer <= 13f))))
{
mySync orSetSync_Duck = myHelper.GetOrSetSync_Duck(__instance);
if ((Object)(object)orSetSync_Duck != (Object)null)
{
orSetSync_Duck.SyncSound("duck", "stun", myHelper.GetRandomSound(StunClips));
}
}
}
}
[HarmonyPatch(typeof(EnemyHunter))]
public class EnemyHunterPatch
{
[HarmonyPatch(typeof(EnemyHunter), "ShootRPC")]
public static class EnemyScript_ShootRPC_Patch
{
private static void Postfix(Vector3 _hitPosition, EnemyHunter __instance)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
if (!SemiFunc.IsMasterClientOrSingleplayer())
{
return;
}
float num = 0.1f;
LayerMask val = LayerMask.op_Implicit(LayerMask.op_Implicit(SemiFunc.LayerMaskGetPhysGrabObject()) + LayerMask.GetMask(new string[1] { "Player" }) + LayerMask.GetMask(new string[1] { "Default" }) + LayerMask.GetMask(new string[1] { "Enemy" }));
Collider[] array = Physics.OverlapSphere(_hitPosition, num, LayerMask.op_Implicit(val));
Collider[] array2 = array;
foreach (Collider val2 in array2)
{
PlayerController componentInParent = ((Component)val2).GetComponentInParent<PlayerController>();
if ((Object)(object)componentInParent != (Object)null)
{
if (componentInParent.playerName == "Chapita")
{
PlayRandomLine(__instance, "chapita");
}
else if (componentInParent.playerName == "Trickap")
{
PlayRandomLine(__instance, "joker");
}
else
{
PlayRandomLine(__instance, "player");
}
break;
}
PlayerTumble componentInParent2 = ((Component)val2).GetComponentInParent<PlayerTumble>();
if ((Object)(object)componentInParent2 != (Object)null)
{
PlayRandomLine(__instance, "player");
break;
}
EnemyRigidbody componentInParent3 = ((Component)val2).GetComponentInParent<EnemyRigidbody>();
if ((Object)(object)componentInParent3 != (Object)null)
{
PlayRandomLine(__instance, "player");
break;
}
PlayRandomLine(__instance, "miss");
}
}
}
public static List<AudioClip> ClipsMiss = new List<AudioClip>();
public static List<AudioClip> ClipsHitPlayer = new List<AudioClip>();
public static List<AudioClip> ClipsHitChapita = new List<AudioClip>();
public static List<AudioClip> ClipsHitJoker = new List<AudioClip>();
[HarmonyPatch("Awake")]
[HarmonyPrefix]
private static void AwakePatch(EnemyHunter __instance)
{
if (PhotonNetwork.IsConnected)
{
PhotonView component = ((Component)__instance).gameObject.GetComponent<PhotonView>();
if ((Object)(object)component == (Object)null)
{
component = ((Component)__instance).gameObject.AddComponent<PhotonView>();
}
mySync orSetSync_Hunter = myHelper.GetOrSetSync_Hunter(__instance);
}
}
private static void PlayRandomLine(EnemyHunter __instance, string hit)
{
if (!SemiFunc.IsMasterClientOrSingleplayer())
{
return;
}
mySync orSetSync_Hunter = myHelper.GetOrSetSync_Hunter(__instance);
switch (hit)
{
case "miss":
orSetSync_Hunter.SyncSound("hunter", "miss", myHelper.GetRandomSound(ClipsMiss));
break;
case "player":
orSetSync_Hunter.SyncSound("hunter", "hit", myHelper.GetRandomSound(ClipsHitPlayer));
break;
case "chapita":
if (Random.RandomRangeInt(0, 3) == 0)
{
orSetSync_Hunter.SyncSound("hunter", "hit", myHelper.GetRandomSound(ClipsHitPlayer));
}
else
{
orSetSync_Hunter.SyncSound("hunter", "chapas", myHelper.GetRandomSound(ClipsHitChapita));
}
break;
case "joker":
if (Random.RandomRangeInt(0, 3) == 0)
{
orSetSync_Hunter.SyncSound("hunter", "joker", myHelper.GetRandomSound(ClipsHitJoker));
}
else
{
orSetSync_Hunter.SyncSound("hunter", "hit", myHelper.GetRandomSound(ClipsHitPlayer));
}
break;
}
}
}
[HarmonyPatch(typeof(PhysGrabObjectImpactDetector))]
internal class PhysGrabObjectImpactDetectorPatch
{
[HarmonyPatch("DestroyObject")]
[HarmonyPrefix]
private static void ValDestroyed(ValuableObject? ___valuableObject)
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)___valuableObject == (Object)null || !SemiFunc.IsMasterClientOrSingleplayer())
{
return;
}
LayerMask val = LayerMask.op_Implicit(LayerMask.GetMask(new string[1] { "PhysGrabObject" }));
Collider[] array = Physics.OverlapSphere(((Component)___valuableObject).transform.position, 15f, LayerMask.op_Implicit(val));
Collider[] array2 = array;
foreach (Collider val2 in array2)
{
EnemyParent componentInParent = ((Component)val2).GetComponentInParent<EnemyParent>();
if (!((Object)(object)componentInParent != (Object)null) || !(((Object)componentInParent).name == "Enemy - Duck(Clone)"))
{
continue;
}
EnemyDuck componentInParent2 = ((Component)componentInParent.Enemy).GetComponentInParent<EnemyDuck>();
if ((Object)(object)componentInParent2 == (Object)null)
{
break;
}
if (!componentInParent2.enemy.IsStunned() & !componentInParent2.GetDuckData().angry)
{
mySync component = ((Component)componentInParent2).GetComponent<mySync>();
if ((Object)(object)component != (Object)null)
{
component.SyncSound("duck", "roto", myHelper.GetRandomSound(EnemyDuckPatch.ValRotoClips));
}
}
}
}
}
public class EnemyDuckData
{
public bool angry = false;
}
public static class myHelper
{
public static int GetRandomSound(List<AudioClip> clipsList)
{
if (clipsList == null || clipsList.Count == 0)
{
return -1;
}
return Random.Range(0, clipsList.Count);
}
public static AudioSource GetOrSetEnemyAS_Hunter(EnemyHunter instance)
{
AudioSource val = ((Component)instance).GetComponent<AudioSource>();
if ((Object)(object)val == (Object)null)
{
val = ((Component)instance).gameObject.AddComponent<AudioSource>();
val.spatialBlend = 1f;
}
return val;
}
public static AudioSource GetOrSetEnemyAS_Duck(EnemyDuck instance)
{
AudioSource val = ((Component)instance).GetComponent<AudioSource>();
if ((Object)(object)val == (Object)null)
{
val = ((Component)instance).gameObject.AddComponent<AudioSource>();
val.spatialBlend = 1f;
val.maxDistance = 800f;
val.dopplerLevel = 0f;
}
return val;
}
public static mySync GetOrSetSync_Hunter(EnemyHunter __instance)
{
mySync mySync2 = ((Component)__instance).GetComponent<mySync>();
if ((Object)(object)mySync2 == (Object)null)
{
mySync2 = ((Component)__instance).gameObject.AddComponent<mySync>();
mySync2.hunter = __instance;
}
return mySync2;
}
public static mySync GetOrSetSync_Duck(EnemyDuck __instance)
{
mySync mySync2 = ((Component)__instance).GetComponent<mySync>();
if ((Object)(object)mySync2 == (Object)null)
{
mySync2 = ((Component)__instance).gameObject.AddComponent<mySync>();
mySync2.duck = __instance;
}
return mySync2;
}
}
public class mySync : MonoBehaviourPun
{
public EnemyDuck? duck;
public EnemyHunter? hunter;
private AudioSource audioSource;
public void SyncSound(string enemy, string list, int clip)
{
if (SemiFunc.IsMultiplayer())
{
((MonoBehaviourPun)this).photonView.RPC("PlaySoundRPC", (RpcTarget)0, new object[3] { enemy, list, clip });
}
else
{
PlaySoundRPC(enemy, list, clip);
}
}
[PunRPC]
public void PlaySoundRPC(string enemy, string list, int clip)
{
if (clip == -1)
{
return;
}
if (!(enemy == "duck"))
{
if (!(enemy == "hunter"))
{
return;
}
if ((Object)(object)hunter != (Object)null)
{
audioSource = myHelper.GetOrSetEnemyAS_Hunter(hunter);
}
switch (list)
{
case "miss":
if (!audioSource.isPlaying)
{
audioSource.PlayOneShot(EnemyHunterPatch.ClipsMiss[clip]);
}
break;
case "hit":
if (!audioSource.isPlaying)
{
audioSource.PlayOneShot(EnemyHunterPatch.ClipsHitPlayer[clip]);
}
break;
case "chapas":
if (!audioSource.isPlaying)
{
audioSource.PlayOneShot(EnemyHunterPatch.ClipsHitChapita[clip]);
}
break;
case "joker":
if (!audioSource.isPlaying)
{
audioSource.PlayOneShot(EnemyHunterPatch.ClipsHitJoker[clip]);
}
break;
}
return;
}
if ((Object)(object)duck != (Object)null)
{
audioSource = myHelper.GetOrSetEnemyAS_Duck(duck);
}
switch (list)
{
case "angry":
if (!audioSource.isPlaying)
{
audioSource.PlayOneShot(EnemyDuckPatch.AngryClips[clip]);
}
break;
case "calm":
if (!audioSource.isPlaying)
{
audioSource.PlayOneShot(EnemyDuckPatch.DestranClips[clip]);
}
break;
case "roto":
if (!audioSource.isPlaying)
{
audioSource.PlayOneShot(EnemyDuckPatch.ValRotoClips[clip]);
}
break;
case "stun":
if (!audioSource.isPlaying)
{
audioSource.PlayOneShot(EnemyDuckPatch.StunClips[clip]);
}
break;
}
}
}
}