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.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using ItemSpawner;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using RandomItemGenerating;
using UnityEngine;
using Zorro.Core;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.Nathrexeio.RandomItemGenerating")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("com.Nathrexeio.RandomItemGenerating")]
[assembly: AssemblyTitle("RandomItemGenerating")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[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 BepInEx
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class BepInAutoPluginAttribute : Attribute
{
public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace BepInEx.Preloader.Core.Patching
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class PatcherAutoPluginAttribute : Attribute
{
public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace RandomItemGenerating
{
[BepInPlugin("com.Nathrexeio.RandomItemGenerating", "RandomItemGenerating", "1.0.5")]
public class Plugin : BaseUnityPlugin
{
private ConfigEntry<int> configSpawnIntervalSeconds;
private ConfigEntry<bool> configSameItemForAll;
private ConfigEntry<bool> configExcludePassport;
private ConfigEntry<bool> configExcludeProblematicItems;
private static Plugin _instance;
public const string Id = "com.Nathrexeio.RandomItemGenerating";
public static int SpawnIntervalSeconds => Instance.configSpawnIntervalSeconds.Value;
public static bool sameItemForAll => Instance.configSameItemForAll.Value;
public static bool excludePassport => Instance.configExcludePassport.Value;
public static bool excludeProblematicItems => Instance.configExcludeProblematicItems.Value;
internal static ManualLogSource Log { get; private set; }
public static Plugin Instance
{
get
{
return _instance;
}
private set
{
_instance = value;
}
}
public static string Name => "RandomItemGenerating";
public static string Version => "1.0.5";
private void Awake()
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Expected O, but got Unknown
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Expected O, but got Unknown
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Expected O, but got Unknown
Instance = this;
Log = ((BaseUnityPlugin)this).Logger;
Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
Harmony val = new Harmony("com.Nathrexeio.RandomItemGenerating");
val.PatchAll();
GameObject val2 = new GameObject("ItemSpawnerHost");
val2.AddComponent<global::ItemSpawner.ItemSpawner>();
Object.DontDestroyOnLoad((Object)(object)val2);
Log.LogInfo((object)"ItemSpawner component successfully added to the game.");
configSpawnIntervalSeconds = ((BaseUnityPlugin)this).Config.Bind<int>("General", "SpawnTimerSeconds", 20, new ConfigDescription("The interval (in seconds) between item spawns.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(5, 300), Array.Empty<object>()));
configSameItemForAll = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "SameItemForAll", false, "If true, all players receive the same item ID for the current spawn cycle.");
configExcludePassport = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ExcludePassport", true, "If true, the Passport will not be in the random spawn item pool");
configExcludeProblematicItems = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ExlcudeProblematicItems", true, "If true, this will remove The grappling hook, cheater compass, and warp compass from the random spawn item pool");
}
}
}
namespace ItemSpawner
{
public class ItemSpawner : MonoBehaviour
{
[CompilerGenerated]
private sealed class <SpawnRoutine>d__1 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public ItemSpawner <>4__this;
private Exception <ex>5__1;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <SpawnRoutine>d__1(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<ex>5__1 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
break;
case 1:
<>1__state = -1;
break;
}
try
{
if (PhotonNetwork.LocalPlayer.IsMasterClient)
{
<>4__this.SpawnARandomItem();
}
}
catch (Exception ex)
{
<ex>5__1 = ex;
Plugin.Log.LogWarning((object)("[ERROR] Spawning logic failed: " + <ex>5__1.Message));
}
<>2__current = (object)new WaitForSeconds((float)Plugin.SpawnIntervalSeconds);
<>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();
}
}
private static readonly Random random = new Random();
private List<Item> randomItemPool = ((DatabaseAsset<ItemDatabase, Item>)(object)SingletonAsset<ItemDatabase>.Instance).Objects;
private void Start()
{
if (Plugin.excludePassport)
{
randomItemPool.RemoveAll((Item item) => ((Object)item).name == "Passport");
}
if (Plugin.excludeProblematicItems)
{
randomItemPool.RemoveAll((Item item) => ((Object)item).name == "Cheat Compass");
randomItemPool.RemoveAll((Item item) => ((Object)item).name == "RescueHook");
randomItemPool.RemoveAll((Item item) => ((Object)item).name == "Warp Compass");
}
Plugin.Log.LogInfo((object)"Starting to spawn items soon");
((MonoBehaviour)this).StartCoroutine(SpawnRoutine());
}
[IteratorStateMachine(typeof(<SpawnRoutine>d__1))]
private IEnumerator SpawnRoutine()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <SpawnRoutine>d__1(0)
{
<>4__this = this
};
}
public void SpawnARandomItem()
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
try
{
Item item = new Item();
if (randomItemPool.Count <= 0)
{
return;
}
int num = 0;
List<Character> list = Character.AllCharacters.Where((Character plr) => (Object)(object)plr != (Object)null && ((Component)plr).gameObject.activeSelf).ToList();
for (int i = 0; i < list.Count; i++)
{
if (i == 0 || !Plugin.sameItemForAll)
{
num = random.Next(0, randomItemPool.Count - 1);
item = randomItemPool[num];
}
Spawn(item, list[i]);
}
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("Finding random item to spawn failed: " + ex.Message));
}
}
public static void Spawn(Item item, Character player)
{
if (!PhotonNetwork.IsConnected || !Object.op_Implicit((Object)(object)Character.localCharacter))
{
return;
}
try
{
if (((Object)item).name == "Backpack" && !player.player.backpackSlot.hasBackpack)
{
ItemSlot val = default(ItemSlot);
player.player.AddItem(item.itemID, (ItemInstanceData)null, ref val);
return;
}
ItemSlot val2 = default(ItemSlot);
for (int i = 0; i < player.player.itemSlots.Length; i++)
{
if (player.player.itemSlots[i].IsEmpty())
{
player.player.AddItem(item.itemID, (ItemInstanceData)null, ref val2);
break;
}
}
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("Random item to slot failed: " + ex.Message));
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}