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.Configuration;
using BepInEx.Logging;
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: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("Omniscye")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SPCinematic")]
[assembly: AssemblyTitle("SPCinematic")]
[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.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 Empress.REPO.OfflineCommands
{
[BepInPlugin("empress.repo.offlinecommands", "REPO Offline Commands", "1.1.0")]
public class OfflineCommandsPlugin : BaseUnityPlugin
{
public const string PluginGuid = "empress.repo.offlinecommands";
public const string PluginName = "REPO Offline Commands";
public const string PluginVersion = "1.1.0";
internal static ManualLogSource Log;
internal static ConfigEntry<KeyCode> ToggleKeyPrimary;
internal static ConfigEntry<KeyCode> ToggleKeySecondary;
internal static ConfigEntry<bool> UseChatKeyT;
internal static ConfigEntry<bool> PrefillSlashOnOpen;
internal static ConfigEntry<bool> AllowInMultiplayer;
internal static ConfigEntry<bool> SubmitCloses;
internal static ConfigEntry<bool> ForceChatInSingleplayer;
private Harmony _harmony;
private void Awake()
{
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Expected O, but got Unknown
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Expected O, but got Unknown
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
Log = ((BaseUnityPlugin)this).Logger;
ToggleKeyPrimary = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "ToggleKeyPrimary", (KeyCode)96, "Primary key to open/close the offline command bar.");
ToggleKeySecondary = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "ToggleKeySecondary", (KeyCode)289, "Secondary key to open/close the bar (fallback).");
UseChatKeyT = ((BaseUnityPlugin)this).Config.Bind<bool>("Controls", "UseChatKeyT", true, "Open the bar when the game’s Chat key (InputKey.Chat, default: T) is pressed in singleplayer.");
PrefillSlashOnOpen = ((BaseUnityPlugin)this).Config.Bind<bool>("Controls", "PrefillSlashOnOpen", true, "When opening via Chat key or '/' key, prefill the input with '/'.");
AllowInMultiplayer = ((BaseUnityPlugin)this).Config.Bind<bool>("Safety", "AllowInMultiplayer", false, "If true, the overlay is allowed in multiplayer. Leave this OFF.");
SubmitCloses = ((BaseUnityPlugin)this).Config.Bind<bool>("UX", "SubmitCloses", true, "Close the bar after submitting a command.");
ForceChatInSingleplayer = ((BaseUnityPlugin)this).Config.Bind<bool>("Patches", "ForceChatInSingleplayer", true, "Let the Multiplayer chat system run in Singleplayer by spoofing IsMultiplayer() calls originating from ChatManager only.");
_harmony = new Harmony("empress.repo.offlinecommands");
_harmony.PatchAll();
GameObject val = new GameObject("__OfflineCommandConsole__");
val.AddComponent<OfflineCommandConsole>();
Object.DontDestroyOnLoad((Object)(object)val);
Log.LogInfo((object)string.Format("{0} {1} loaded. Keys: Primary={2}, Secondary={3}, UseChatKeyT={4}, ForceChatInSingleplayer={5}", "REPO Offline Commands", "1.1.0", ToggleKeyPrimary.Value, ToggleKeySecondary.Value, UseChatKeyT.Value, ForceChatInSingleplayer.Value));
}
private void OnDestroy()
{
try
{
Harmony harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
catch
{
}
}
}
public class OfflineCommandConsole : MonoBehaviour
{
private bool _open;
private string _input = string.Empty;
private readonly List<string> _history = new List<string>();
private int _histIndex = -1;
private float _blockedToastUntil;
private const int BoxHeight = 36;
private const int BoxWidth = 720;
private const int Margin = 12;
private const int Padding = 8;
private void Update()
{
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
if (IsMainMenu())
{
_open = false;
return;
}
bool flag = IsMultiplayer();
if (!(!_open && !OfflineCommandsPlugin.AllowInMultiplayer.Value && flag))
{
if (OfflineCommandsPlugin.UseChatKeyT.Value)
{
try
{
if (SemiFunc.InputDown((InputKey)7) && !_open)
{
_open = true;
_histIndex = -1;
if (OfflineCommandsPlugin.PrefillSlashOnOpen.Value)
{
_input = (string.IsNullOrEmpty(_input) ? "/" : _input);
}
TrySoftDisablePlayerInput();
UnlockCursor();
}
}
catch
{
}
}
if (Input.GetKeyDown(OfflineCommandsPlugin.ToggleKeyPrimary.Value) || Input.GetKeyDown(OfflineCommandsPlugin.ToggleKeySecondary.Value))
{
ToggleOpen();
}
if ((Input.GetKeyDown((KeyCode)47) || Input.GetKeyDown((KeyCode)267)) && !_open)
{
_open = true;
_histIndex = -1;
_input = (OfflineCommandsPlugin.PrefillSlashOnOpen.Value ? "/" : string.Empty);
TrySoftDisablePlayerInput();
UnlockCursor();
}
}
if (_open)
{
TrySoftDisablePlayerInput();
}
}
private void ToggleOpen()
{
_open = !_open;
if (_open)
{
_histIndex = -1;
if (OfflineCommandsPlugin.PrefillSlashOnOpen.Value && string.IsNullOrEmpty(_input))
{
_input = "/";
}
TrySoftDisablePlayerInput();
UnlockCursor();
}
else
{
LockCursorIfNeeded();
}
}
private void OnGUI()
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Invalid comparison between Unknown and I4
//IL_0307: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Invalid comparison between Unknown and I4
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Invalid comparison between Unknown and I4
//IL_01af: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: Invalid comparison between Unknown and I4
//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
//IL_01e6: Invalid comparison between Unknown and I4
//IL_0258: Unknown result type (might be due to invalid IL or missing references)
//IL_0262: Invalid comparison between Unknown and I4
if (Time.unscaledTime < _blockedToastUntil)
{
Rect val = default(Rect);
((Rect)(ref val))..ctor(12f, 12f, 520f, 26f);
GUI.Box(val, GUIContent.none);
GUI.Label(new Rect(((Rect)(ref val)).x + 8f, ((Rect)(ref val)).y + 4f, ((Rect)(ref val)).width - 16f, ((Rect)(ref val)).height - 8f), "OfflineCommands disabled in multiplayer. Enable it in config if you really want to.");
}
if (!_open)
{
return;
}
int num = 720;
int num2 = 36;
float num3 = (float)(Screen.width - num) / 2f;
int num4 = Screen.height - num2 - 12;
Rect val2 = default(Rect);
((Rect)(ref val2))..ctor(num3, (float)num4, (float)num, (float)num2);
GUI.Box(val2, GUIContent.none);
Rect val3 = default(Rect);
((Rect)(ref val3))..ctor(num3 + 8f, (float)num4 + 4f, (float)(num - 16), (float)(num2 - 8));
GUI.SetNextControlName("OfflineCmdField");
_input = GUI.TextField(val3, _input ?? string.Empty, 256);
GUI.FocusControl("OfflineCmdField");
Event current = Event.current;
if ((int)current.type == 4)
{
if ((int)current.keyCode == 13 || (int)current.keyCode == 271)
{
Submit(_input);
if (OfflineCommandsPlugin.SubmitCloses.Value)
{
_open = false;
LockCursorIfNeeded();
}
_input = string.Empty;
current.Use();
}
else if ((int)current.keyCode == 27)
{
_open = false;
LockCursorIfNeeded();
current.Use();
}
else if ((int)current.keyCode == 273)
{
if (_history.Count > 0)
{
_histIndex = ((_histIndex < 0) ? (_history.Count - 1) : Mathf.Max(0, _histIndex - 1));
_input = _history[_histIndex];
current.Use();
}
}
else if ((int)current.keyCode == 274 && _history.Count > 0)
{
_histIndex = Mathf.Min(_history.Count, _histIndex + 1);
_input = ((_histIndex >= 0 && _histIndex < _history.Count) ? _history[_histIndex] : string.Empty);
current.Use();
}
}
string text = "T to open (Chat key) — Commands: /greenscreen, /cinematic, /hud on|off|toggle";
Rect val4 = default(Rect);
((Rect)(ref val4))..ctor(num3 + 8f, (float)(num4 - 20), (float)(num - 16), 18f);
GUI.Label(val4, text);
}
private void Submit(string raw)
{
string text = (raw ?? string.Empty).Trim();
if (string.IsNullOrEmpty(text))
{
return;
}
_history.Add(text);
_histIndex = -1;
try
{
if (text.Equals("/hud", StringComparison.OrdinalIgnoreCase) || text.Equals("/hud toggle", StringComparison.OrdinalIgnoreCase))
{
ToggleHud();
}
else if (text.Equals("/hud on", StringComparison.OrdinalIgnoreCase))
{
ShowHud(on: true);
}
else if (text.Equals("/hud off", StringComparison.OrdinalIgnoreCase))
{
ShowHud(on: false);
}
else if (text.Equals("/greenscreen on", StringComparison.OrdinalIgnoreCase))
{
if ((Object)(object)VideoGreenScreen.instance == (Object)null)
{
SemiFunc.Command("/greenscreen");
}
}
else if (text.Equals("/greenscreen off", StringComparison.OrdinalIgnoreCase))
{
if ((Object)(object)VideoGreenScreen.instance != (Object)null)
{
SemiFunc.Command("/greenscreen");
}
}
else
{
SemiFunc.Command(text);
}
}
catch (Exception arg)
{
OfflineCommandsPlugin.Log.LogError((object)$"Command error: {arg}");
}
}
private static bool IsMultiplayer()
{
try
{
return SemiFunc.IsMultiplayer();
}
catch
{
return false;
}
}
private static bool IsMainMenu()
{
try
{
return SemiFunc.IsMainMenu();
}
catch
{
return false;
}
}
private static void TrySoftDisablePlayerInput()
{
try
{
SemiFunc.InputDisableMovement();
}
catch
{
}
try
{
SemiFunc.InputDisableAiming();
}
catch
{
}
}
private static void ToggleHud()
{
HUD instance = HUD.instance;
if (!((Object)(object)instance == (Object)null))
{
if (instance.hidden)
{
instance.Show();
}
else
{
instance.Hide();
}
}
}
private static void ShowHud(bool on)
{
HUD instance = HUD.instance;
if (!((Object)(object)instance == (Object)null))
{
if (on)
{
instance.Show();
}
else
{
instance.Hide();
}
}
}
private static void UnlockCursor()
{
try
{
Cursor.visible = true;
Cursor.lockState = (CursorLockMode)0;
}
catch
{
}
}
private static void LockCursorIfNeeded()
{
try
{
Cursor.visible = false;
Cursor.lockState = (CursorLockMode)1;
}
catch
{
}
}
}
[HarmonyPatch(typeof(SemiFunc), "IsMultiplayer")]
internal static class Patch_IsMultiplayer_ForChatOnly
{
private static bool Prefix(ref bool __result)
{
if (!OfflineCommandsPlugin.ForceChatInSingleplayer.Value)
{
return true;
}
try
{
if ((Object)(object)GameManager.instance != (Object)null && GameManager.instance.gameMode == 1)
{
return true;
}
StackTrace stackTrace = new StackTrace();
for (int i = 1; i < Math.Min(12, stackTrace.FrameCount); i++)
{
MethodBase methodBase = stackTrace.GetFrame(i)?.GetMethod();
if (methodBase?.DeclaringType != null && methodBase.DeclaringType.FullName == "ChatManager")
{
__result = true;
return false;
}
}
}
catch
{
}
return true;
}
}
}
namespace SPCinematic
{
[BepInPlugin("Omniscye.SPCinematic", "SPCinematic", "1.0")]
public class SPCinematic : BaseUnityPlugin
{
internal static SPCinematic Instance { get; private set; }
internal static ManualLogSource Logger => Instance._logger;
private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;
internal Harmony? Harmony { get; set; }
private void Awake()
{
Instance = this;
((Component)this).gameObject.transform.parent = null;
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
Patch();
Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
}
internal void Patch()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
//IL_0026: Expected O, but got Unknown
if (Harmony == null)
{
Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
Harmony val2 = val;
Harmony = val;
}
Harmony.PatchAll();
}
internal void Unpatch()
{
Harmony? harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
private void Update()
{
}
}
}