using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("DropCleaner")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DropCleaner")]
[assembly: AssemblyTitle("DropCleaner")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 DropCleanerMod
{
[BepInPlugin("com.yourname.dropcleaner", "DropCleaner", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class DropCleaner : BaseUnityPlugin
{
[CompilerGenerated]
private sealed class <CleanupCoroutine>d__8 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public DropCleaner <>4__this;
private int <cleaned>5__1;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <CleanupCoroutine>d__8(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
break;
case 1:
<>1__state = -1;
<cleaned>5__1 = <>4__this.CleanDroppedItems();
((BaseUnityPlugin)<>4__this).Logger.LogInfo((object)$"[DropCleaner] Removed {<cleaned>5__1} items.");
break;
}
<>2__current = (object)new WaitForSeconds(<>4__this.cleanupInterval.Value);
<>1__state = 1;
return true;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public const string ModGUID = "com.yourname.dropcleaner";
public const string ModName = "DropCleaner";
public const string ModVersion = "1.0.0";
private ConfigEntry<float> cleanupInterval;
private ConfigEntry<string> minimumRarityToKeep;
private ConfigEntry<float> arenaRadius;
private Coroutine cleanupRoutine;
private void Awake()
{
cleanupInterval = ((BaseUnityPlugin)this).Config.Bind<float>("General", "CleanupInterval", 30f, "Time in seconds between cleanups.");
minimumRarityToKeep = ((BaseUnityPlugin)this).Config.Bind<string>("Filters", "MinimumRarityToKeep", "Magic", "Minimum EpicLoot rarity to keep.");
arenaRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Filters", "ArenaRadius", 60f, "Radius around boss spawns to skip cleanup.");
cleanupRoutine = ((MonoBehaviour)this).StartCoroutine(CleanupCoroutine());
((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("{0} loaded. Cleanup every {1}s.", "DropCleaner", cleanupInterval.Value));
}
[IteratorStateMachine(typeof(<CleanupCoroutine>d__8))]
private IEnumerator CleanupCoroutine()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <CleanupCoroutine>d__8(0)
{
<>4__this = this
};
}
private int CleanDroppedItems()
{
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
int num = 0;
ItemDrop[] array = Object.FindObjectsOfType<ItemDrop>();
ItemDrop[] array2 = array;
foreach (ItemDrop val in array2)
{
if (!((Object)val).name.Contains("Arrow") && !((Object)val).name.Contains("Projectile") && !((Object)(object)val == (Object)null) && val.m_itemData != null && !((Object)(object)((Component)val).transform.parent != (Object)null) && !IsInsideBossArena(((Component)val).transform.position) && (!val.m_itemData.m_customData.TryGetValue("Rarity", out var value) || IsBelowMinRarity(value)))
{
ZNetScene.instance.Destroy(((Component)val).gameObject);
num++;
}
}
return num;
}
private bool IsBelowMinRarity(string rarityStr)
{
string[] array = new string[6] { "None", "Magic", "Rare", "Epic", "Legendary", "Unique" };
int num = Array.IndexOf(array, rarityStr);
int num2 = Array.IndexOf(array, minimumRarityToKeep.Value);
return num < num2;
}
private bool IsInsideBossArena(Vector3 pos)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
foreach (Character allCharacter in Character.GetAllCharacters())
{
if ((Object)(object)allCharacter != (Object)null && allCharacter.IsBoss() && Vector3.Distance(pos, ((Component)allCharacter).transform.position) < arenaRadius.Value)
{
return true;
}
}
return false;
}
}
}