using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using R2API.Utils;
using RoR2;
using RoR2.EntityLogic;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;
using UnityEngine.ResourceManagement.AsyncOperations;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: NetworkCompatibility(/*Could not decode attribute arguments.*/)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("PizzaSoundFix")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PizzaSoundFix")]
[assembly: AssemblyTitle("PizzaSoundFix")]
[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 PizzaSoundFix
{
internal static class Log
{
internal static ManualLogSource _logSource;
internal static void Init(ManualLogSource logSource)
{
_logSource = logSource;
}
private static string getLogPrefix(string callerPath, string callerMemberName, int callerLineNumber)
{
int num = callerPath.LastIndexOf("PizzaSoundFix\\");
if (num >= 0)
{
callerPath = callerPath.Substring(num + "PizzaSoundFix\\".Length);
}
return $"{callerPath}:{callerLineNumber} ({callerMemberName}) ";
}
internal static void Error(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
{
_logSource.LogError((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
}
internal static void Error_NoCallerPrefix(object data)
{
_logSource.LogError(data);
}
internal static void Fatal(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
{
_logSource.LogFatal((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
}
internal static void Fatal_NoCallerPrefix(object data)
{
_logSource.LogFatal(data);
}
internal static void Info(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
{
_logSource.LogInfo((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
}
internal static void Info_NoCallerPrefix(object data)
{
_logSource.LogInfo(data);
}
internal static void Message(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
{
_logSource.LogMessage((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
}
internal static void Message_NoCallerPrefix(object data)
{
_logSource.LogMessage(data);
}
internal static void Warning(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
{
_logSource.LogWarning((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
}
internal static void Warning_NoCallerPrefix(object data)
{
_logSource.LogWarning(data);
}
}
[BepInPlugin("Gorakh.PizzaSoundFix", "PizzaSoundFix", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class PizzaSoundFixPlugin : BaseUnityPlugin
{
public const string PluginGUID = "Gorakh.PizzaSoundFix";
public const string PluginAuthor = "Gorakh";
public const string PluginName = "PizzaSoundFix";
public const string PluginVersion = "1.0.0";
internal static PizzaSoundFixPlugin Instance { get; private set; }
private void Awake()
{
Stopwatch stopwatch = Stopwatch.StartNew();
Log.Init(((BaseUnityPlugin)this).Logger);
Instance = SingletonHelper.Assign<PizzaSoundFixPlugin>(Instance, this);
fixPizzaSoundEvent("RoR2/Base/Brother/BrotherUltLineGhost.prefab");
fixPizzaSoundEvent("RoR2/Base/BrotherHaunt/BrotherUltLineGhost, Simple.prefab");
stopwatch.Stop();
Log.Message_NoCallerPrefix($"Initialized in {stopwatch.Elapsed.TotalMilliseconds:F0}ms");
static void fixPizzaSoundEvent(string path)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)path);
val.Completed += delegate(AsyncOperationHandle<GameObject> handle)
{
GameObject result = handle.Result;
Transform val2 = (Object.op_Implicit((Object)(object)result) ? result.transform.Find("Size/EarlySFX") : null);
if (Object.op_Implicit((Object)(object)val2))
{
fixOnEnableSoundEvent(val2);
}
else
{
Log.Error("Failed to find EarlySFX on '" + path + "'", "X:\\Git\\RoR2\\PizzaSoundFix\\PizzaSoundFix\\PizzaSoundFixPlugin.cs", "Awake", 47);
}
};
}
}
private void OnDestroy()
{
Instance = SingletonHelper.Unassign<PizzaSoundFixPlugin>(Instance, this);
}
private static void fixOnEnableSoundEvent(Transform earlySfx)
{
DelayedEvent component = ((Component)earlySfx).GetComponent<DelayedEvent>();
if (!Object.op_Implicit((Object)(object)component))
{
Log.Error("Failed to find DelayedEvent on " + Util.BuildPrefabTransformPath(earlySfx.root, earlySfx, false, true), "X:\\Git\\RoR2\\PizzaSoundFix\\PizzaSoundFix\\PizzaSoundFixPlugin.cs", "fixOnEnableSoundEvent", 69);
return;
}
OnEnableEvent component2 = ((Component)earlySfx).GetComponent<OnEnableEvent>();
if (!Object.op_Implicit((Object)(object)component2))
{
Log.Error("Failed to find EnableEvent on " + Util.BuildPrefabTransformPath(earlySfx.root, earlySfx, false, true), "X:\\Git\\RoR2\\PizzaSoundFix\\PizzaSoundFix\\PizzaSoundFixPlugin.cs", "fixOnEnableSoundEvent", 76);
return;
}
PersistentCallGroup persistentCalls = ((UnityEventBase)component2.action).m_PersistentCalls;
persistentCalls.Clear();
int count = persistentCalls.Count;
persistentCalls.AddListener();
persistentCalls.RegisterFloatPersistentListener(count, (Object)(object)component, typeof(DelayedEvent), 0.7f, "CallDelayed");
}
}
}