using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using ArenaMode.Patches;
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: AssemblyTitle("ArenaMode")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ArenaMode")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("19891aa7-6620-49ba-ab70-c51f51876bc6")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
}
}
}
namespace ArenaMode
{
[BepInPlugin("Shelton.ArenaFight", "ArenaFight", "0.0.1")]
public class ArenaOverride : BaseUnityPlugin
{
public const string modGUID = "Shelton.ArenaFight";
public const string modName = "ArenaFight";
public const string modVersion = "0.0.1";
private readonly Harmony harmony = new Harmony("Shelton.ArenaFight");
private static ArenaOverride _instance;
public static ManualLogSource log;
internal ArenaConfig BoundConfig { get; private set; }
private void Awake()
{
_instance = this;
harmony.PatchAll(typeof(ArenaOverride));
harmony.PatchAll(typeof(GameDirectorPatch));
log = Logger.CreateLogSource("Shelton.ArenaFight");
BoundConfig = new ArenaConfig(((BaseUnityPlugin)this).Config);
if (ArenaConfig.enableArenaOnly.Value)
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"true");
}
log.LogInfo((object)"ArenaFight has awoken!");
}
}
internal class ArenaConfig
{
public static ConfigEntry<bool> enableArenaOnly;
public ArenaConfig(ConfigFile cfg)
{
cfg.SaveOnConfigSet = false;
enableArenaOnly = cfg.Bind<bool>("General.Toggles", "EnableArenaOnly", true, "Replace every level with arena");
ClearOrphanedEntries(cfg);
cfg.Save();
cfg.SaveOnConfigSet = true;
}
private static void ClearOrphanedEntries(ConfigFile cfg)
{
((Dictionary<ConfigDefinition, string>)AccessTools.Property(typeof(ConfigFile), "OrphanedEntries").GetValue(cfg)).Clear();
}
}
}
namespace ArenaMode.Patches
{
[HarmonyPatch(typeof(RunManager))]
internal class GameDirectorPatch
{
[HarmonyPatch("ChangeLevel")]
[HarmonyPostfix]
private static void patchUpdate(RunManager __instance)
{
if (ArenaConfig.enableArenaOnly.Value && (Object)(object)__instance.levelCurrent != (Object)(object)__instance.levelLobby && (Object)(object)__instance.levelCurrent != (Object)(object)__instance.levelLobbyMenu && (Object)(object)__instance.levelCurrent != (Object)(object)__instance.levelMainMenu && (Object)(object)__instance.levelCurrent != (Object)(object)__instance.levelArena)
{
ArenaOverride.log.LogInfo((object)$"triggered! {SemiFunc.IsMasterClient()}");
ArenaOverride.log.LogInfo((object)$"current level is: {__instance.levelCurrent}");
if (SemiFunc.IsMasterClient())
{
ArenaOverride.log.LogInfo((object)"You are the host, have fun!");
__instance.levelCurrent = __instance.levelArena;
__instance.ChangeLevel(false, true, (ChangeLevelType)0);
}
else
{
ArenaOverride.log.LogInfo((object)"You are not the host");
}
}
}
}
}