Decompiled source of NebulaLocalResync v0.2.1

NebulaLocalResync.dll

Decompiled 2 months ago
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using NebulaWorld;
using NebulaWorld.GameStates;
using UnityEngine;

[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: CompilationRelaxations(8)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace NebulaLocalResync;

[BepInPlugin("com.local.nebulalocalresync", "Nebula Local Resync", "0.2.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public sealed class LocalResyncPlugin : BaseUnityPlugin
{
	public const string PluginGuid = "com.local.nebulalocalresync";

	public const string PluginName = "Nebula Local Resync";

	public const string PluginVersion = "0.2.0";

	private ConfigEntry<KeyboardShortcut> _hotkey;

	private float _nextAllowedAt;

	private void Awake()
	{
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		_hotkey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Client", "ResyncHotkey", new KeyboardShortcut((KeyCode)114, (KeyCode[])(object)new KeyCode[2]
		{
			(KeyCode)306,
			(KeyCode)304
		}), "Perform Nebula's built-in fast reconnect. Default: Ctrl+Shift+R.");
		((BaseUnityPlugin)this).Logger.LogInfo((object)("Nebula Local Resync 0.2.0 loaded. Ctrl+Shift+R now invokes Nebula's built-in fast reconnect path. Hotkey: " + ((object)_hotkey.Value/*cast due to .constrained prefix*/).ToString()));
	}

	private void Update()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		KeyboardShortcut value = _hotkey.Value;
		if (!((KeyboardShortcut)(ref value)).IsDown() || Time.realtimeSinceStartup < _nextAllowedAt)
		{
			return;
		}
		_nextAllowedAt = Time.realtimeSinceStartup + 2f;
		try
		{
			if (!Multiplayer.IsActive || Multiplayer.Session == null)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"Reconnect hotkey ignored: Nebula multiplayer is not active.");
				return;
			}
			if (Multiplayer.Session.LocalPlayer == null)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"Reconnect hotkey ignored: Nebula local-player state is not available.");
				return;
			}
			if (Multiplayer.Session.LocalPlayer.IsHost)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"Reconnect hotkey ignored: Nebula /reconnect is client-only.");
				return;
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Reconnect hotkey pressed. Invoking Nebula GameStatesManager.DoFastReconnect().");
			GameStatesManager.DoFastReconnect();
		}
		catch (Exception ex)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)("Nebula fast reconnect failed: " + ex));
		}
	}
}