using System;
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 GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Networking;
[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("LethalShigunMode")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("즉사급 지건을 뻥뻥 날리자")]
[assembly: AssemblyFileVersion("1.0.4.0")]
[assembly: AssemblyInformationalVersion("1.0.4+504eca149238edc4cb2974d390f4bd6d8c9f3a55")]
[assembly: AssemblyProduct("LethalShigunMode")]
[assembly: AssemblyTitle("LethalShigunMode")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.4.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;
}
}
}
[BepInPlugin("com.jiho7407.LethalShigunMode", "LethalShigunMode", "1.0.0")]
public class ShiganMods : BaseUnityPlugin
{
public static ShiganMods instance;
public AudioSource shiganAudio;
public AudioClip attackSound;
public AudioClip hitSound;
private void Awake()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
instance = this;
Harmony val = new Harmony("com.jiho7407.LethalShigunMode");
val.PatchAll(Assembly.GetExecutingAssembly());
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin LethalShigunMode is loaded!");
shiganAudio = ((Component)this).gameObject.AddComponent<AudioSource>();
Object.DontDestroyOnLoad((Object)(object)((Component)shiganAudio).gameObject);
string location = Assembly.GetExecutingAssembly().Location;
string directoryName = Path.GetDirectoryName(location);
string text = Path.Combine(directoryName, "attack.mp3");
((BaseUnityPlugin)this).Logger.LogInfo((object)("attackPath: " + text));
attackSound = LoadAudioClip(text);
string text2 = Path.Combine(directoryName, "hit.mp3");
((BaseUnityPlugin)this).Logger.LogInfo((object)("hitPath: " + text2));
hitSound = LoadAudioClip(text2);
if ((Object)(object)attackSound == (Object)null || (Object)(object)hitSound == (Object)null)
{
((BaseUnityPlugin)this).Logger.LogError((object)"Failed to create audio clip");
}
else
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"Audio clip is successfully created");
}
}
private AudioClip LoadAudioClip(string path)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Invalid comparison between Unknown and I4
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Invalid comparison between Unknown and I4
UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip(path, (AudioType)13);
try
{
audioClip.SendWebRequest();
while (!audioClip.isDone)
{
}
if ((int)audioClip.result == 2 || (int)audioClip.result == 3)
{
((BaseUnityPlugin)this).Logger.LogError((object)("Failed to load audio clip: " + audioClip.error));
return null;
}
((BaseUnityPlugin)this).Logger.LogInfo((object)("Audio clip is loaded: " + path));
return DownloadHandlerAudioClip.GetContent(audioClip);
}
finally
{
((IDisposable)audioClip)?.Dispose();
}
}
public static void PlayAttackSound()
{
if ((Object)(object)instance != (Object)null && (Object)(object)instance.attackSound != (Object)null)
{
instance.shiganAudio.PlayOneShot(instance.attackSound);
((BaseUnityPlugin)instance).Logger.LogInfo((object)"Play attack sound");
return;
}
((BaseUnityPlugin)instance).Logger.LogError((object)"Failed to play attack sound");
if ((Object)(object)instance.attackSound == (Object)null)
{
((BaseUnityPlugin)instance).Logger.LogError((object)"attackSound is null");
}
else
{
((BaseUnityPlugin)instance).Logger.LogError((object)"instance is null");
}
}
public static void PlayHitSound()
{
if ((Object)(object)instance != (Object)null && (Object)(object)instance.hitSound != (Object)null)
{
instance.shiganAudio.PlayOneShot(instance.hitSound);
((BaseUnityPlugin)instance).Logger.LogInfo((object)"Play hit sound");
}
else
{
((BaseUnityPlugin)instance).Logger.LogError((object)"Failed to play hit sound");
}
}
}
[HarmonyPatch(typeof(PlayerControllerB), "StartPerformingEmoteClientRpc")]
public static class EmoteDamagePatch
{
private static void Postfix(PlayerControllerB __instance)
{
int integer = __instance.playerBodyAnimator.GetInteger("emoteNumber");
if (integer == 2)
{
ShiganMods.PlayAttackSound();
ApplyDamage(__instance);
}
}
private static void ApplyDamage(PlayerControllerB instance)
{
//IL_000e: 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_0028: 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_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
bool flag = false;
RaycastHit[] array = Physics.SphereCastAll(((Component)instance.gameplayCamera).transform.position + ((Component)instance.gameplayCamera).transform.right * -0.35f, 0.8f, ((Component)instance.gameplayCamera).transform.forward, 2f, 11012424, (QueryTriggerInteraction)2);
RaycastHit[] array2 = array;
for (int i = 0; i < array2.Length; i++)
{
RaycastHit val = array2[i];
IHittable component = ((Component)((RaycastHit)(ref val)).transform).GetComponent<IHittable>();
if (component != null && (Object)(object)((RaycastHit)(ref val)).transform != (Object)(object)((Component)instance).transform)
{
component.Hit(20, ((Component)instance.gameplayCamera).transform.forward, instance, true, 1);
flag = true;
}
}
if (flag)
{
ShiganMods.PlayHitSound();
}
}
}
namespace LethalCompanyTemplate
{
public static class PluginInfo
{
public const string PLUGIN_GUID = "LethalShigunMode";
public const string PLUGIN_NAME = "LethalShigunMode";
public const string PLUGIN_VERSION = "1.0.4";
}
}