using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("MrokNadchodzi")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MrokNadchodzi")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("dd95be33-0b92-4e5b-ae6e-4febf59ebf12")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("com.czekoloczek.peakmod.mroknadchodzi", "Mrok Nadchodzi", "1.0.0")]
public class PeakMod : BaseUnityPlugin
{
[CompilerGenerated]
private sealed class <LoadAudio>d__2 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public PeakMod <>4__this;
private string <path>5__1;
private WWW <www>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <LoadAudio>d__2(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || num == 1)
{
try
{
}
finally
{
<>m__Finally1();
}
}
<path>5__1 = null;
<www>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Expected O, but got Unknown
try
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<path>5__1 = "file://" + Paths.PluginPath + "/MrokNadchodzi/replacement.ogg";
<www>5__2 = new WWW(<path>5__1);
<>1__state = -3;
<>2__current = <www>5__2;
<>1__state = 1;
return true;
case 1:
<>1__state = -3;
<>4__this.replacementClip = <www>5__2.GetAudioClip(false, false, (AudioType)14);
<>m__Finally1();
<www>5__2 = null;
return false;
}
}
catch
{
//try-fault
((IDisposable)this).Dispose();
throw;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
if (<www>5__2 != null)
{
((IDisposable)<www>5__2).Dispose();
}
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <ReplaceAudio>d__4 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public PeakMod <>4__this;
private GameObject <audioObj>5__1;
private AudioSource <audioSource>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <ReplaceAudio>d__4(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<audioObj>5__1 = null;
<audioSource>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
<audioObj>5__1 = GameObject.Find("GAME/GUIManager/Canvas_HUD/Notification/SFX");
if ((Object)(object)<audioObj>5__1 != (Object)null && (Object)(object)<>4__this.replacementClip != (Object)null)
{
<audioSource>5__2 = <audioObj>5__1.GetComponent<AudioSource>();
if ((Object)(object)<audioSource>5__2 != (Object)null)
{
<audioSource>5__2.clip = <>4__this.replacementClip;
((BaseUnityPlugin)<>4__this).Logger.LogInfo((object)"Dźwięk został podmieniony.");
}
<audioSource>5__2 = null;
}
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private AudioClip replacementClip;
private void Awake()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
((BaseUnityPlugin)this).Logger.LogInfo((object)"PeakMod został załadowany!");
Harmony val = new Harmony("com.czekoloczek.peakmod.mroknadchodzi");
val.PatchAll();
SceneManager.sceneLoaded += OnSceneLoaded;
((MonoBehaviour)this).StartCoroutine(LoadAudio());
}
[IteratorStateMachine(typeof(<LoadAudio>d__2))]
private IEnumerator LoadAudio()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <LoadAudio>d__2(0)
{
<>4__this = this
};
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
((MonoBehaviour)this).StartCoroutine(ReplaceAudio());
}
[IteratorStateMachine(typeof(<ReplaceAudio>d__4))]
private IEnumerator ReplaceAudio()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <ReplaceAudio>d__4(0)
{
<>4__this = this
};
}
}
[HarmonyPatch]
public static class LocalizedText_RefreshText_Patch
{
private static MethodBase TargetMethod()
{
Type type = AccessTools.TypeByName("LocalizedText");
return AccessTools.Method(type, "RefreshText", (Type[])null, (Type[])null);
}
private static void Postfix(object __instance)
{
Component val = (Component)((__instance is Component) ? __instance : null);
if (!((Object)(object)val != (Object)null) || !((Object)(object)val.gameObject != (Object)null))
{
return;
}
string hierarchyPath = val.gameObject.transform.GetHierarchyPath();
if (hierarchyPath.EndsWith("GAME/GUIManager/Canvas_HUD/Notification/Fog"))
{
TextMeshProUGUI component = val.GetComponent<TextMeshProUGUI>();
if ((Object)(object)component != (Object)null)
{
((TMP_Text)component).text = "Mrok Nadchodzi...";
}
}
}
}
public static class TransformExtensions
{
public static string GetHierarchyPath(this Transform transform)
{
string text = ((Object)transform).name;
while ((Object)(object)transform.parent != (Object)null)
{
transform = transform.parent;
text = ((Object)transform).name + "/" + text;
}
return text;
}
public static string GetHierarchyPath(this GameObject go)
{
return go.transform.GetHierarchyPath();
}
}