using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using UnityEngine;
using Zorro.Core;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("ClassLibrary1")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ClassLibrary1")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c6a0255f-f87f-4d1c-b3a0-e1fa4407c322")]
[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("com.user.peak.catmouse_auto_store", "猫鼠游戏物资收纳版", "3.2.0")]
public class CatMousePlugin : BaseUnityPlugin
{
[CompilerGenerated]
private sealed class <>c__DisplayClass1_0
{
public string keyword;
internal bool <SpawnAndStore>b__1(Item i)
{
if (((Object)i).name != null)
{
if (!((Object)i).name.ToLower().Contains(keyword.ToLower()))
{
if (keyword == "Cure-all")
{
return ((Object)i).name.ToLower().Contains("cure");
}
return false;
}
return true;
}
return false;
}
}
[CompilerGenerated]
private sealed class <SpawnAndStore>d__1 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public string[] items;
public CatMousePlugin <>4__this;
private ItemDatabase <db>5__2;
private Player <player>5__3;
private string[] <>7__wrap3;
private int <>7__wrap4;
private Item <data>5__6;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <SpawnAndStore>d__1(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<db>5__2 = null;
<player>5__3 = null;
<>7__wrap3 = null;
<data>5__6 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Expected O, but got Unknown
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Expected O, but got Unknown
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
int num = <>1__state;
CatMousePlugin catMousePlugin = <>4__this;
switch (num)
{
default:
return false;
case 0:
{
<>1__state = -1;
<db>5__2 = SingletonAsset<ItemDatabase>.Instance;
<player>5__3 = Player.localPlayer;
if ((Object)(object)<db>5__2 == (Object)null || (Object)(object)<player>5__3 == (Object)null)
{
return false;
}
Item val = ((IEnumerable<Item>)<db>5__2.itemLookup.Values).FirstOrDefault((Func<Item, bool>)((Item i) => ((Object)i).name.ToLower().Contains("backpack")));
if ((Object)(object)val != (Object)null)
{
ItemDatabase.Add(val, ((Component)<player>5__3).transform.position);
}
<>2__current = (object)new WaitForSeconds(0.2f);
<>1__state = 1;
return true;
}
case 1:
<>1__state = -1;
<>7__wrap3 = items;
<>7__wrap4 = 0;
goto IL_01a5;
case 2:
{
<>1__state = -1;
((Component)<player>5__3).GetComponentInChildren<MonoBehaviour>();
catMousePlugin.TryPushToBackpack(<player>5__3, <data>5__6);
goto IL_0190;
}
IL_01a5:
if (<>7__wrap4 < <>7__wrap3.Length)
{
<>c__DisplayClass1_0 CS$<>8__locals0 = new <>c__DisplayClass1_0
{
keyword = <>7__wrap3[<>7__wrap4]
};
<data>5__6 = ((IEnumerable<Item>)<db>5__2.itemLookup.Values).FirstOrDefault((Func<Item, bool>)((Item i) => ((Object)i).name != null && (((Object)i).name.ToLower().Contains(CS$<>8__locals0.keyword.ToLower()) || (CS$<>8__locals0.keyword == "Cure-all" && ((Object)i).name.ToLower().Contains("cure")))));
if ((Object)(object)<data>5__6 != (Object)null)
{
ItemDatabase.Add(<data>5__6, ((Component)<player>5__3).transform.position);
<>2__current = (object)new WaitForSeconds(0.1f);
<>1__state = 2;
return true;
}
goto IL_0190;
}
<>7__wrap3 = null;
((BaseUnityPlugin)catMousePlugin).Logger.LogInfo((object)">>> 物资发放并尝试收纳完成。");
return false;
IL_0190:
<data>5__6 = null;
<>7__wrap4++;
goto IL_01a5;
}
}
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 void Update()
{
if (Input.GetKeyDown((KeyCode)111))
{
((MonoBehaviour)this).StartCoroutine(SpawnAndStore(new string[4] { "Flare", "Flare", "Coconut", "Marshmallow" }));
}
if (Input.GetKeyDown((KeyCode)112))
{
((MonoBehaviour)this).StartCoroutine(SpawnAndStore(new string[4] { "Hook", "Hook", "Hook", "Cure-all" }));
}
if (Input.GetKeyDown((KeyCode)109))
{
LogDatabase();
}
}
[IteratorStateMachine(typeof(<SpawnAndStore>d__1))]
private IEnumerator SpawnAndStore(string[] items)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <SpawnAndStore>d__1(0)
{
<>4__this = this,
items = items
};
}
private void TryPushToBackpack(Player player, Item item)
{
MonoBehaviour[] componentsInChildren = ((Component)player).GetComponentsInChildren<MonoBehaviour>(true);
foreach (MonoBehaviour val in componentsInChildren)
{
if (((Object)((Component)val).gameObject).name.ToLower().Contains("backpack"))
{
MethodInfo method = ((object)val).GetType().GetMethod("AddItem", new Type[1] { typeof(Item) });
if (method != null)
{
method.Invoke(val, new object[1] { item });
break;
}
}
}
}
private void LogDatabase()
{
foreach (KeyValuePair<ushort, Item> item in SingletonAsset<ItemDatabase>.Instance.itemLookup)
{
((BaseUnityPlugin)this).Logger.LogInfo((object)$"ID: {item.Key} | Name: {((Object)item.Value).name}");
}
}
}