using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("BadNorthSamuraiBackup")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BadNorthSamuraiBackup")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("2f9dc06c-0e12-4b4b-ad2e-e92f427ea8f5")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("reskin.badnorth", "Enemy Atlas Reskin", "1.0")]
public class ReskinMod : BaseUnityPlugin
{
[CompilerGenerated]
private sealed class <WaitAndPatch>d__4 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public ReskinMod <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitAndPatch>d__4(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
break;
case 1:
<>1__state = -1;
break;
}
if (!<>4__this.patched)
{
<>4__this.TryPatchAtlas();
<>2__current = (object)new WaitForSeconds(0.5f);
<>1__state = 1;
return true;
}
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 const string AtlasName = "PartTex_Median_BlurAlpha";
private Texture2D replacementAtlas;
private bool patched = false;
private void Awake()
{
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Expected O, but got Unknown
string text = Path.Combine(Paths.PluginPath, "my_enemy_atlas.png");
if (!File.Exists(text))
{
((BaseUnityPlugin)this).Logger.LogError((object)("custom not found: " + text));
return;
}
byte[] array = File.ReadAllBytes(text);
replacementAtlas = new Texture2D(2, 2, (TextureFormat)4, false);
ImageConversion.LoadImage(replacementAtlas, array);
replacementAtlas.Apply();
((BaseUnityPlugin)this).Logger.LogInfo((object)"custom atlas loaded waiting for enemy atlas");
((MonoBehaviour)this).StartCoroutine(WaitAndPatch());
}
[IteratorStateMachine(typeof(<WaitAndPatch>d__4))]
private IEnumerator WaitAndPatch()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitAndPatch>d__4(0)
{
<>4__this = this
};
}
private void TryPatchAtlas()
{
Texture2D[] array = Resources.FindObjectsOfTypeAll<Texture2D>();
Texture2D[] array2 = array;
foreach (Texture2D val in array2)
{
if (!(((Object)val).name != "PartTex_Median_BlurAlpha"))
{
((BaseUnityPlugin)this).Logger.LogInfo((object)("FOUND atlas: " + ((Object)val).name));
val.Resize(((Texture)replacementAtlas).width, ((Texture)replacementAtlas).height, (TextureFormat)4, false);
Color32[] pixels = replacementAtlas.GetPixels32();
val.SetPixels32(pixels);
val.Apply(false, false);
((BaseUnityPlugin)this).Logger.LogInfo((object)"atlas replaced");
patched = true;
return;
}
}
((BaseUnityPlugin)this).Logger.LogDebug((object)"atlas not loaded");
}
}