using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using DunGen;
using HarmonyLib;
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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Tomatobird.BrackenLootRoom")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+5fe9ea569de2b615066ebea949488ef7b2c652f0")]
[assembly: AssemblyProduct("BrackenLootRoom")]
[assembly: AssemblyTitle("Tomatobird.BrackenLootRoom")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.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 BrackenLootRoom
{
[BepInPlugin("Tomatobird.BrackenLootRoom", "BrackenLootRoom", "1.0.1")]
public class BrackenLootRoom : BaseUnityPlugin
{
internal static int lootSpawners = 4;
internal static float spawnRadius = 3f;
internal static string spawnType = "GeneralScrapSpawn";
public static BrackenLootRoom Instance { get; private set; } = null;
internal static ManualLogSource Logger { get; private set; } = null;
internal static Harmony? Harmony { get; set; }
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Instance = this;
lootSpawners = ((BaseUnityPlugin)this).Config.Bind<int>("General", "LootSpawners", 4, "How many loot spawners should be in the bracken room? Not every loot spawner spawns loot every day depending on item count and factory size.").Value;
spawnRadius = ((BaseUnityPlugin)this).Config.Bind<float>("General", "SpawnRadius", 3f, "In how large of a radius should items be spawned?").Value;
spawnType = ((BaseUnityPlugin)this).Config.Bind<string>("General", "SpawnType", "GeneralScrapSpawn", "Which item pool should be used for spawning items? GeneralScrapSpawn is the common vanilla item pool.").Value;
Patch();
Logger.LogInfo((object)"Tomatobird.BrackenLootRoom v1.0.1 has loaded!");
}
internal static void Patch()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
if (Harmony == null)
{
Harmony = new Harmony("Tomatobird.BrackenLootRoom");
}
Logger.LogDebug((object)"Patching...");
Harmony.PatchAll();
Logger.LogDebug((object)"Finished patching!");
}
internal static void Unpatch()
{
Logger.LogDebug((object)"Unpatching...");
Harmony? harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
Logger.LogDebug((object)"Finished unpatching!");
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "Tomatobird.BrackenLootRoom";
public const string PLUGIN_NAME = "BrackenLootRoom";
public const string PLUGIN_VERSION = "1.0.1";
}
}
namespace BrackenLootRoom.Patches
{
[HarmonyPatch(typeof(Dungeon))]
internal class DungeonPatch
{
internal static List<string> dungeonFlows = new List<string>(3) { "Level1Flow", "Level1Flow3Exits", "Level1FlowExtraLarge" };
internal static Vector3 centerPosition = Vector3.zero;
internal static float circleRadius = 3f;
[HarmonyPatch("PostGenerateDungeon")]
[HarmonyPostfix]
internal static void PostGenerateDungeonPostfix(Dungeon __instance)
{
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
if (!dungeonFlows.Contains(((Object)__instance.DungeonFlow).name))
{
return;
}
foreach (Tile allTile in __instance.AllTiles)
{
if (!(((Object)allTile).name == "SmallRoom2(Clone)"))
{
continue;
}
Transform val = ((Component)allTile).transform.Find("AINode");
Transform val2 = ((Component)allTile).transform.Find("AINode (1)");
if ((Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null)
{
centerPosition = (val.localPosition + val2.localPosition) / 2f;
}
else
{
BrackenLootRoom.Logger.LogWarning((object)("AINodes not found in " + ((Object)allTile).name + ". Center position won't be set properly."));
}
if (BrackenLootRoom.lootSpawners > 1)
{
Vector3[] array = CreateCircularSpawns(BrackenLootRoom.lootSpawners, centerPosition, circleRadius);
Vector3[] array2 = array;
foreach (Vector3 localPos in array2)
{
CreateScrapSpawner(((Component)allTile).transform, localPos);
}
}
else
{
CreateScrapSpawner(((Component)allTile).transform, centerPosition);
}
}
}
internal static GameObject CreateScrapSpawner(Transform parent, Vector3 localPos)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Expected O, but got Unknown
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject
{
name = "BrackenLootSpawner"
};
val.transform.SetParent(parent);
val.transform.localPosition = localPos;
RandomScrapSpawn val2 = val.AddComponent<RandomScrapSpawn>();
ItemGroup[] array = Resources.FindObjectsOfTypeAll<ItemGroup>();
ItemGroup[] array2 = array;
foreach (ItemGroup val3 in array2)
{
if (((Object)val3).name == "GeneralScrapSpawn")
{
val2.spawnableItems = val3;
break;
}
}
val2.itemSpawnRange = BrackenLootRoom.spawnRadius;
val2.spawnedItemsCopyPosition = false;
return val;
}
internal static Vector3[] CreateCircularSpawns(int amount, Vector3 centerPoint, float radius)
{
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
List<Vector3> list = new List<Vector3>();
Vector3 val = default(Vector3);
for (int i = 0; i < amount; i++)
{
float num = MathF.PI * 2f * (float)i / (float)amount;
float num2 = Mathf.Sin(num);
float num3 = Mathf.Cos(num);
((Vector3)(ref val))..ctor(num2, 0f, num3);
Vector3 item = centerPoint + val * radius;
list.Add(item);
}
return list.ToArray();
}
}
}