using System;
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.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using On.RoR2;
using RoR2;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("ServerSider")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+45c0b6ab38577c981084aa1723aa8fec895a6971")]
[assembly: AssemblyProduct("ServerSider")]
[assembly: AssemblyTitle("ServerSider")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace ServerSider
{
public sealed class Config
{
private readonly ConfigEntry<bool> rescueShipPortal;
private readonly ConfigEntry<bool> voidFieldFogAltStart;
public bool RescueShipPortal => rescueShipPortal.Value;
public bool VoidFieldFogAltStart => voidFieldFogAltStart.Value;
public Config(ConfigFile config)
{
rescueShipPortal = config.Bind<bool>("Tweaks", "rescueShipPortal", true, "Spawn a portal in the Rescue Ship to allow looping after defeating Mithrix.");
voidFieldFogAltStart = config.Bind<bool>("Tweaks", "voidFieldFogAltStart", false, "Change the Void Fields fog to only become active once a Cell Vent has been activated.");
}
}
internal static class Log
{
private static ManualLogSource _logSource;
internal static void Init(ManualLogSource baseLogger)
{
Logger.Sources.Remove((ILogSource)(object)baseLogger);
_logSource = Logger.CreateLogSource("itsschwer.ServerSider");
}
internal static void Debug(object data)
{
_logSource.LogDebug(data);
}
internal static void Error(object data)
{
_logSource.LogError(data);
}
internal static void Fatal(object data)
{
_logSource.LogFatal(data);
}
internal static void Info(object data)
{
_logSource.LogInfo(data);
}
internal static void Message(object data)
{
_logSource.LogMessage(data);
}
internal static void Warning(object data)
{
_logSource.LogWarning(data);
}
internal static string GetExecutingMethod(int index = 0)
{
MethodBase method = new StackTrace().GetFrame(index + 2).GetMethod();
return $"{method.DeclaringType}::{method.Name}";
}
}
[BepInPlugin("itsschwer.ServerSider", "ServerSider", "1.0.0")]
public sealed class Plugin : BaseUnityPlugin
{
public const string GUID = "itsschwer.ServerSider";
public const string Author = "itsschwer";
public const string Name = "ServerSider";
public const string Version = "1.0.0";
private static Plugin Instance;
public static Config Config { get; private set; }
public static bool Enabled => ((Behaviour)Instance).enabled;
private event Action OnManageHooks;
private void Awake()
{
Log.Init(((BaseUnityPlugin)this).Logger);
Config = new Config(((BaseUnityPlugin)this).Config);
Instance = this;
Run.onRunStartGlobal += SetPluginActiveState;
Run.onRunDestroyGlobal += SetPluginActiveState;
SetPluginActiveState();
SetupHooks();
Log.Message("~awake.");
}
private void SetPluginActiveState(Run _ = null)
{
SetActive(NetworkServer.active);
}
private void SetActive(bool value)
{
((Behaviour)this).enabled = value;
Log.Message("~" + (value ? "active" : "inactive") + ".");
}
private void OnEnable()
{
this.OnManageHooks?.Invoke();
Log.Message("~enabled.");
}
private void OnDisable()
{
this.OnManageHooks?.Invoke();
Log.Message("~disabled.");
}
private void SetupHooks()
{
OnManageHooks += RescueShipLoopPortal.ManageHook;
OnManageHooks += VoidFieldFogTweak.ManageHook;
}
public static void UnmanageHook(Action manageHookMethod)
{
Instance.OnManageHooks -= manageHookMethod;
}
}
public static class RescueShipLoopPortal
{
[CompilerGenerated]
private static class <>O
{
public static hook_Start <0>__HoldoutZoneController_Start;
}
private static bool _hooked;
public static void Hook()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Expected O, but got Unknown
if (!_hooked)
{
_hooked = true;
object obj = <>O.<0>__HoldoutZoneController_Start;
if (obj == null)
{
hook_Start val = HoldoutZoneController_Start;
<>O.<0>__HoldoutZoneController_Start = val;
obj = (object)val;
}
HoldoutZoneController.Start += (hook_Start)obj;
Log.Debug("RescueShipLoopPortal> Hooked by " + Log.GetExecutingMethod());
}
}
public static void Unhook()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Expected O, but got Unknown
if (_hooked)
{
_hooked = false;
object obj = <>O.<0>__HoldoutZoneController_Start;
if (obj == null)
{
hook_Start val = HoldoutZoneController_Start;
<>O.<0>__HoldoutZoneController_Start = val;
obj = (object)val;
}
HoldoutZoneController.Start -= (hook_Start)obj;
Log.Debug("RescueShipLoopPortal> Unhooked by " + Log.GetExecutingMethod());
}
}
public static void Rehook(bool condition)
{
Unhook();
if (condition)
{
Hook();
}
Log.Debug("RescueShipLoopPortal> Rehooked by " + Log.GetExecutingMethod());
}
public static void ManageHook()
{
Rehook(Plugin.Enabled && Plugin.Config.RescueShipPortal);
}
private static void HoldoutZoneController_Start(orig_Start orig, HoldoutZoneController self)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: 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_003c: 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)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self);
if (self.inBoundsObjectiveToken == "OBJECTIVE_MOON_CHARGE_DROPSHIP")
{
Vector3 position = ((Component)self).transform.position + ((Component)self).transform.up * 10f + ((Component)self).transform.forward * -3.5f + ((Component)self).transform.right * -1.8f;
Quaternion rotation = Quaternion.Inverse(((Component)self).transform.rotation) * Quaternion.Euler(((Component)self).transform.up * 90f);
InstantiatePortal(position, rotation);
}
}
internal static void InstantiatePortal(Vector3 position, Quaternion rotation)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Expected O, but got Unknown
GameObject obj = Object.Instantiate<GameObject>(((SpawnCard)Addressables.LoadAssetAsync<InteractableSpawnCard>((object)"RoR2/DLC1/GameModes/InfiniteTowerRun/InfiniteTowerAssets/iscInfiniteTowerPortal.asset").WaitForCompletion()).prefab, position, rotation);
obj.GetComponent<SceneExitController>().useRunNextStageScene = true;
NetworkServer.Spawn(obj);
Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
{
baseToken = "<size=120%><style=cIsVoid>The Void beckons...</style></size>"
});
}
}
public static class VoidFieldFogTweak
{
[CompilerGenerated]
private static class <>O
{
public static hook_OnStartServer <0>__ArenaMissionController_OnStartServer;
public static hook_BeginRound <1>__ArenaMissionController_BeginRound;
}
private static bool _hooked;
public static void Hook()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Expected O, but got Unknown
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Expected O, but got Unknown
if (!_hooked)
{
_hooked = true;
object obj = <>O.<0>__ArenaMissionController_OnStartServer;
if (obj == null)
{
hook_OnStartServer val = ArenaMissionController_OnStartServer;
<>O.<0>__ArenaMissionController_OnStartServer = val;
obj = (object)val;
}
ArenaMissionController.OnStartServer += (hook_OnStartServer)obj;
object obj2 = <>O.<1>__ArenaMissionController_BeginRound;
if (obj2 == null)
{
hook_BeginRound val2 = ArenaMissionController_BeginRound;
<>O.<1>__ArenaMissionController_BeginRound = val2;
obj2 = (object)val2;
}
ArenaMissionController.BeginRound += (hook_BeginRound)obj2;
Log.Debug("VoidFieldFogTweak> Hooked by " + Log.GetExecutingMethod());
}
}
public static void Unhook()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Expected O, but got Unknown
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Expected O, but got Unknown
if (_hooked)
{
_hooked = false;
object obj = <>O.<0>__ArenaMissionController_OnStartServer;
if (obj == null)
{
hook_OnStartServer val = ArenaMissionController_OnStartServer;
<>O.<0>__ArenaMissionController_OnStartServer = val;
obj = (object)val;
}
ArenaMissionController.OnStartServer -= (hook_OnStartServer)obj;
object obj2 = <>O.<1>__ArenaMissionController_BeginRound;
if (obj2 == null)
{
hook_BeginRound val2 = ArenaMissionController_BeginRound;
<>O.<1>__ArenaMissionController_BeginRound = val2;
obj2 = (object)val2;
}
ArenaMissionController.BeginRound -= (hook_BeginRound)obj2;
Log.Debug("VoidFieldFogTweak> Unhooked by " + Log.GetExecutingMethod());
}
}
public static void Rehook(bool condition)
{
Unhook();
if (condition)
{
Hook();
}
Log.Debug("VoidFieldFogTweak> Rehooked by " + Log.GetExecutingMethod());
}
public static void ManageHook()
{
Rehook(Plugin.Enabled && Plugin.Config.VoidFieldFogAltStart);
}
private static void ArenaMissionController_OnStartServer(orig_OnStartServer orig, ArenaMissionController self)
{
orig.Invoke(self);
self.SetFogActive(value: false);
}
private static void ArenaMissionController_BeginRound(orig_BeginRound orig, ArenaMissionController self)
{
orig.Invoke(self);
if (self.currentRound == 1)
{
self.SetFogActive(value: true);
}
}
private static void SetFogActive(this ArenaMissionController controller, bool value)
{
GameObject fogDamageInstance = controller.fogDamageInstance;
if (fogDamageInstance != null)
{
fogDamageInstance.SetActive(value);
}
controller.clearedEffect.SetActive(!value);
}
}
}