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.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using REPOLib;
using Unity.VisualScripting;
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: AssemblyCompany("Xepos")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AmericanHuntsman")]
[assembly: AssemblyTitle("AmericanHuntsman")]
[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;
}
}
}
namespace AmericanHuntsman
{
[BepInPlugin("Xepos.AmericanHuntsman", "AmericanHuntsman", "1.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class AmericanHuntsman : BaseUnityPlugin
{
internal ConfigEntry<bool> useRedWhiteBlue;
internal ConfigEntry<bool> useUsa;
internal ConfigEntry<float> soundVolume;
internal static AmericanHuntsman Instance { get; private set; }
internal static ManualLogSource Logger => Instance._logger;
private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;
internal Harmony? Harmony { get; set; }
internal AudioClip[] AmericanAudios { get; private set; } = Array.Empty<AudioClip>();
private void Awake()
{
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Expected O, but got Unknown
Instance = this;
((Component)this).gameObject.transform.parent = null;
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "americanhuntsman");
useUsa = ((BaseUnityPlugin)this).Config.Bind<bool>("Sounds", "Eagle and Gunfire", true, "Use the Eagle and Gunfire sound effect");
useRedWhiteBlue = ((BaseUnityPlugin)this).Config.Bind<bool>("Sounds", "Red White Blue", true, "Use the Red White and Blue sound effect");
soundVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Sounds", "Volume", 1f, new ConfigDescription("Volume", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1f), Array.Empty<object>()));
BundleLoader.LoadBundle(text, (Action<AssetBundle>)delegate(AssetBundle assetBundle)
{
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
List<AudioClip> list = new List<AudioClip>();
AudioClip val = assetBundle.LoadAsset<AudioClip>("usa");
if (useUsa.Value && Object.op_Implicit((Object)(object)val))
{
Logger.LogInfo((object)"Loaded Eagle and Gunfire audio");
list.Add(val);
}
AudioClip val2 = assetBundle.LoadAsset<AudioClip>("redwhiteblue");
if (useRedWhiteBlue.Value && Object.op_Implicit((Object)(object)val2))
{
Logger.LogInfo((object)"Loaded Red White Blue audio");
list.Add(val2);
}
if (list.Count > 0)
{
AmericanAudios = list.ToArray();
}
new Harmony("Xepos-AmericanHuntsman").PatchAll();
}, false);
Patch();
Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
}
internal void Patch()
{
//IL_0019: 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_0020: Expected O, but got Unknown
//IL_0025: 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 AmericanHuntsman.Patches
{
[HarmonyPatch(typeof(EnemyHunterAnim), "AimStart")]
internal class EnemyHunterAnimPatch
{
private static readonly Sound americanSound = new Sound();
private static void Postfix(EnemyHunterAnim __instance)
{
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
AudioSource val = ((Component)((Component)__instance).transform).GetComponent<AudioSource>();
if ((Object)(object)val == (Object)null)
{
val = ComponentHolderProtocol.AddComponent<AudioSource>((Object)(object)((Component)__instance).transform);
((Behaviour)val).enabled = true;
AmericanHuntsman.Logger.LogInfo((object)"Applied American audio");
if (AmericanHuntsman.Instance.AmericanAudios.Length != 0)
{
val.clip = AmericanHuntsman.Instance.AmericanAudios[0];
}
}
americanSound.Source = val;
americanSound.Sounds = AmericanHuntsman.Instance.AmericanAudios;
americanSound.Type = (AudioType)9;
americanSound.Volume = AmericanHuntsman.Instance.soundVolume.Value;
americanSound.VolumeRandom = 0.05f;
americanSound.Pitch = 1f;
americanSound.SpatialBlend = 1f;
americanSound.Doppler = 1f;
americanSound.ReverbMix = 1f;
americanSound.FalloffMultiplier = 1f;
americanSound.OffscreenVolume = 1f;
americanSound.OffscreenFalloff = 1f;
if (AmericanHuntsman.Instance.AmericanAudios.Length != 0)
{
Vector3 position = ((Component)__instance).transform.position;
Sound obj = americanSound;
if (obj != null)
{
obj.Play(position, 1f, 1f, 1f, 1f);
}
}
}
}
}