using System;
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 System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ClusterImprovements")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Cool mod.")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: AssemblyInformationalVersion("0.0.1")]
[assembly: AssemblyProduct("ClusterImprovements")]
[assembly: AssemblyTitle("ClusterImprovements")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.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 ClusterImprovements
{
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "ClusterImprovements";
public const string PLUGIN_NAME = "ClusterImprovements";
public const string PLUGIN_VERSION = "0.0.1";
}
}
namespace ClusterImprovements.src
{
public class ClusterImprovementsConfig
{
public ConfigEntry<bool> ConfigDebugMode { get; private set; }
public ConfigEntry<bool> ConfigExtendedLogging { get; private set; }
public void InitClusterImprovementsConfig(ConfigFile configFile)
{
ConfigDebugMode = configFile.Bind<bool>("Debug Options", "Debug Mode | Debug Mode", false, "Whether debug mode is enabled.");
ConfigExtendedLogging = configFile.Bind<bool>("Debug Options", "Debug Mode | Extended Logging", false, "Whether ExtendedLogging is enabled.");
}
}
[BepInPlugin("ClusterImprovements", "ClusterImprovements", "0.0.1")]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Logger = null;
internal static readonly Harmony _harmony = new Harmony("ClusterImprovements");
internal static readonly Dictionary<string, AssetBundle> LoadedBundles = new Dictionary<string, AssetBundle>();
internal static ConfigFile ConfigFile { get; private set; } = null;
public static ClusterImprovementsConfig ModConfig { get; private set; } = null;
public void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
ConfigFile = ((BaseUnityPlugin)this).Config;
ModConfig = new ClusterImprovementsConfig();
ModConfig.InitClusterImprovementsConfig(ConfigFile);
((BaseUnityPlugin)this).Config.Save();
Logger.LogInfo((object)"Registering ClusterImprovements content.");
_harmony.PatchAll();
Logger.LogInfo((object)"Plugin ClusterImprovements is loaded!");
}
private void OnDisable()
{
foreach (AssetBundle value in LoadedBundles.Values)
{
value.Unload(false);
}
Logger.LogDebug((object)"Unloaded assetbundles.");
LoadedBundles.Clear();
}
internal static void ExtendedLogging(object text)
{
if (ModConfig.ConfigExtendedLogging.Value)
{
Logger.LogInfo(text);
}
}
}
}
namespace ClusterImprovements.src.Util.Extensions
{
public static class ConfigFileExtensions
{
internal static void ClearUnusedEntries(this ConfigFile configFile)
{
PropertyInfo property = ((object)configFile).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)property.GetValue(configFile, null);
dictionary.Clear();
configFile.Save();
}
}
public static class RandomExtensions
{
public static T NextEnum<T>(this Random random) where T : struct, Enum
{
Array values = Enum.GetValues(typeof(T));
return (T)values.GetValue(random.Next(values.Length));
}
public static T NextItem<T>(this Random random, List<T> collection)
{
int index = random.Next(collection.Count);
return collection[index];
}
public static T NextItem<T>(this Random random, T[] collection)
{
int num = random.Next(collection.Length);
return collection[num];
}
public static double NextDouble(this Random random, double min, double max)
{
return random.NextDouble() * (max - min) + min;
}
public static float NextFloat(this Random random, float min, float max)
{
return (float)random.NextDouble(min, max);
}
public static bool NextBool(this Random random)
{
return random.Next(2) == 0;
}
public static int NextSign(this Random random)
{
if (!random.NextBool())
{
return -1;
}
return 1;
}
public static Quaternion NextQuaternion(this Random random)
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
return Quaternion.Euler(random.NextFloat(0f, 360f), random.NextFloat(0f, 360f), random.NextFloat(0f, 360f));
}
}
internal static class StringExtensions
{
private static readonly Regex ConfigCleanerRegex = new Regex("[\\n\\t\"`\\[\\]']");
public static string OrIfEmpty(this string? self, string defaultValue)
{
if (string.IsNullOrEmpty(self))
{
return defaultValue;
}
return self;
}
public static string FirstCharToUpper(this string input)
{
if (string.IsNullOrEmpty(input))
{
throw new ArgumentException("ARGH!");
}
return input.First().ToString().ToUpper() + input.Substring(1, input.Length - 1);
}
public static string CleanStringForConfig(this string input)
{
return ConfigCleanerRegex.Replace(input, string.Empty);
}
}
}
namespace ClusterImprovements.src.Patches
{
[HarmonyPatch(typeof(EnemyDirector))]
public static class EnemyDirectorPatch
{
[HarmonyPatch("PickEnemies")]
[HarmonyPrefix]
public static void OnEnablePatch(EnemyDirector __instance, List<EnemySetup> _enemiesList)
{
Plugin.ExtendedLogging($"Enemies spawned: {RunManager.instance.enemiesSpawned.Count}");
foreach (EnemySetup _enemies in _enemiesList)
{
Plugin.ExtendedLogging($"Enemy Setup: {_enemies}, levelsCompletedCondition: {_enemies.levelsCompletedCondition}");
_enemies.levelsCompletedCondition = false;
_enemies.runsPlayed = 0;
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}