using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Unity.Netcode;
using UnityEngine;
using WebSocketSharp;
using WebSocketSharp.Net;
using WebSocketSharp.Server;
using com.github.zehsteam.StreamOverlays.Dependencies;
using com.github.zehsteam.StreamOverlays.Patches;
using com.github.zehsteam.StreamOverlays.Server;
[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: AssemblyCompany("com.github.zehsteam.StreamOverlays")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2+a6f11b764c400be16ca92149698759d8f512978f")]
[assembly: AssemblyProduct("StreamOverlays")]
[assembly: AssemblyTitle("com.github.zehsteam.StreamOverlays")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.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 com.github.zehsteam.StreamOverlays
{
internal static class ConfigHelper
{
public static void SkipAutoGen()
{
if (LethalConfigProxy.Enabled)
{
LethalConfigProxy.SkipAutoGen();
}
}
public static void AddButton(string section, string name, string description, string buttonText, Action callback)
{
if (LethalConfigProxy.Enabled)
{
LethalConfigProxy.AddButton(section, name, description, buttonText, callback);
}
}
public static ConfigEntry<T> Bind<T>(string section, string key, T defaultValue, bool requiresRestart, string description, AcceptableValueBase acceptableValues = null, Action<T> settingChanged = null, ConfigFile configFile = null)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Expected O, but got Unknown
if (configFile == null)
{
configFile = Plugin.Config;
}
ConfigEntry<T> configEntry = ((acceptableValues == null) ? configFile.Bind<T>(section, key, defaultValue, description) : configFile.Bind<T>(section, key, defaultValue, new ConfigDescription(description, acceptableValues, Array.Empty<object>())));
if (settingChanged != null)
{
configEntry.SettingChanged += delegate
{
settingChanged?.Invoke(configEntry.Value);
};
}
if (LethalConfigProxy.Enabled)
{
LethalConfigProxy.AddConfig<T>(configEntry, requiresRestart);
}
return configEntry;
}
public static Dictionary<ConfigDefinition, string> GetOrphanedConfigEntries(ConfigFile configFile = null)
{
if (configFile == null)
{
configFile = Plugin.Config;
}
PropertyInfo property = ((object)configFile).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
return (Dictionary<ConfigDefinition, string>)property.GetValue(configFile, null);
}
public static void SetConfigEntryValue<T>(ConfigEntry<T> configEntry, string value)
{
if (typeof(T) == typeof(int) && int.TryParse(value, out var result))
{
configEntry.Value = (T)(object)result;
return;
}
if (typeof(T) == typeof(float) && float.TryParse(value, out var result2))
{
configEntry.Value = (T)(object)result2;
return;
}
if (typeof(T) == typeof(double) && double.TryParse(value, out var result3))
{
configEntry.Value = (T)(object)result3;
return;
}
if (typeof(T) == typeof(bool) && bool.TryParse(value, out var result4))
{
configEntry.Value = (T)(object)result4;
return;
}
if (typeof(T) == typeof(string))
{
configEntry.Value = (T)(object)value;
return;
}
throw new InvalidOperationException($"Unsupported type: {typeof(T)}");
}
public static void ClearUnusedEntries(ConfigFile configFile = null)
{
if (configFile == null)
{
configFile = Plugin.Config;
}
Dictionary<ConfigDefinition, string> orphanedConfigEntries = GetOrphanedConfigEntries(configFile);
if (orphanedConfigEntries != null)
{
orphanedConfigEntries.Clear();
configFile.Save();
}
}
}
internal class ConfigManager
{
public ConfigEntry<bool> ExtendedLogging { get; private set; }
public ConfigEntry<int> Overlay_DayOffset { get; private set; }
public ConfigEntry<bool> Overlay_ShowWeatherIcon { get; private set; }
public ConfigEntry<bool> Server_AutoStart { get; private set; }
public ConfigEntry<int> Server_HttpPort { get; private set; }
public ConfigEntry<int> Server_WebSocketPort { get; private set; }
public ConfigManager()
{
BindConfigs();
ConfigHelper.ClearUnusedEntries();
}
private void BindConfigs()
{
ConfigHelper.SkipAutoGen();
ExtendedLogging = ConfigHelper.Bind("General", "ExtendedLogging", defaultValue: false, requiresRestart: false, "Enable extended logging.");
Overlay_DayOffset = ConfigHelper.Bind("Overlay", "DayOffset", 0, requiresRestart: false, "The day offset. If you are playing multiplayer and you are not the host, the day count can be desynced.");
Overlay_ShowWeatherIcon = ConfigHelper.Bind("Overlay", "ShowWeatherIcon", defaultValue: true, requiresRestart: false, "If enabled, will show the current weather as an icon after the moon name.");
ConfigHelper.AddButton("Overlay", "Refresh Overlay", "Refresh the overlay.", "Refresh", WebServer.UpdateOverlay);
Overlay_DayOffset.SettingChanged += delegate
{
WebServer.UpdateOverlay();
};
Overlay_ShowWeatherIcon.SettingChanged += delegate
{
WebServer.UpdateOverlay();
};
Server_AutoStart = ConfigHelper.Bind("Server", "AutoStart", defaultValue: true, requiresRestart: false, "If enabled, the server will automatically start when you launch the game.");
ConfigHelper.AddButton("Server", "Start Server", "Start the server.", "Start", WebServer.Start);
ConfigHelper.AddButton("Server", "Stop Server", "Stop the server.", "Stop", WebServer.Stop);
Server_HttpPort = ConfigHelper.Bind("Server", "HttpPort", 8080, requiresRestart: false, "The HTTP port for the server.");
Server_WebSocketPort = ConfigHelper.Bind("Server", "WebSocketPort", 8000, requiresRestart: false, "The WebSocket port for the server.");
}
}
internal static class NetworkUtils
{
public static bool IsServer
{
get
{
if ((Object)(object)NetworkManager.Singleton == (Object)null)
{
return false;
}
return NetworkManager.Singleton.IsServer;
}
}
public static bool IsHost
{
get
{
if ((Object)(object)NetworkManager.Singleton == (Object)null)
{
return false;
}
return NetworkManager.Singleton.IsHost;
}
}
public static ulong GetLocalClientId()
{
return NetworkManager.Singleton.LocalClientId;
}
public static bool IsLocalClientId(ulong clientId)
{
return clientId == GetLocalClientId();
}
}
internal static class PlayerUtils
{
public static PlayerControllerB GetLocalPlayerScript()
{
if ((Object)(object)GameNetworkManager.Instance == (Object)null)
{
return null;
}
return GameNetworkManager.Instance.localPlayerController;
}
public static bool IsLocalPlayer(PlayerControllerB playerScript)
{
return (Object)(object)playerScript == (Object)(object)GetLocalPlayerScript();
}
public static bool IsLocalPlayerSpawned()
{
return (Object)(object)GetLocalPlayerScript() != (Object)null;
}
public static PlayerControllerB GetPlayerScriptByClientId(ulong clientId)
{
PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
foreach (PlayerControllerB val in allPlayerScripts)
{
if (val.actualClientId == clientId)
{
return val;
}
}
return null;
}
}
[BepInPlugin("com.github.zehsteam.StreamOverlays", "StreamOverlays", "1.0.2")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
internal class Plugin : BaseUnityPlugin
{
private readonly Harmony _harmony = new Harmony("com.github.zehsteam.StreamOverlays");
internal static Plugin Instance { get; private set; }
internal static ManualLogSource Logger { get; private set; }
internal static ConfigFile Config { get; private set; }
internal static ConfigManager ConfigManager { get; private set; }
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
Logger = Logger.CreateLogSource("com.github.zehsteam.StreamOverlays");
Logger.LogInfo((object)"StreamOverlays has awoken!");
Config = Utils.CreateGlobalConfigFile();
_harmony.PatchAll(typeof(StartOfRoundPatch));
_harmony.PatchAll(typeof(TimeOfDayPatch));
_harmony.PatchAll(typeof(PlayerControllerBPatch));
_harmony.PatchAll(typeof(VehicleControllerPatch));
_harmony.PatchAll(typeof(DepositItemsDeskPatch));
ConfigManager = new ConfigManager();
Task.Run((Func<Task?>)WebServer.Initialize);
}
public void LogInfoExtended(object data)
{
LogExtended((LogLevel)16, data);
}
public void LogExtended(LogLevel level, object data)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
if (ConfigManager == null || ConfigManager.ExtendedLogging == null)
{
Logger.Log(level, data);
}
else if (ConfigManager.ExtendedLogging.Value)
{
Logger.Log(level, data);
}
}
}
internal static class Utils
{
public static string GetEnumName<T>(T e) where T : Enum
{
return Enum.GetName(typeof(T), e) ?? string.Empty;
}
public static string GetPluginDirectoryPath()
{
return Path.GetDirectoryName(((BaseUnityPlugin)Plugin.Instance).Info.Location);
}
public static ConfigFile CreateConfigFile(string path, string name = null, bool saveOnInit = false)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
BepInPlugin metadata = MetadataHelper.GetMetadata((object)Plugin.Instance);
if (name == null)
{
name = metadata.GUID;
}
name += ".cfg";
return new ConfigFile(Path.Combine(path, name), saveOnInit, metadata);
}
public static ConfigFile CreateLocalConfigFile(string name = null, bool saveOnInit = false)
{
BepInPlugin metadata = MetadataHelper.GetMetadata((object)Plugin.Instance);
if (name == null)
{
name = metadata.GUID + "-" + name;
}
return CreateConfigFile(Paths.ConfigPath, null, saveOnInit);
}
public static ConfigFile CreateGlobalConfigFile(string name = null, bool saveOnInit = false)
{
BepInPlugin metadata = MetadataHelper.GetMetadata((object)Plugin.Instance);
string path = Path.Combine(Application.persistentDataPath, metadata.Name);
if (name == null)
{
name = "global";
}
return CreateConfigFile(path, name, saveOnInit);
}
public static Transform GetHangarShipTransform()
{
if ((Object)(object)StartOfRound.Instance == (Object)null)
{
return null;
}
return StartOfRound.Instance.elevatorTransform;
}
public static bool CanShowOverlay()
{
if ((Object)(object)GameNetworkManager.Instance == (Object)null)
{
return false;
}
if (GameNetworkManager.Instance.isDisconnecting)
{
return false;
}
if (!PlayerUtils.IsLocalPlayerSpawned())
{
return false;
}
return true;
}
public static int GetCrewCount()
{
if (NetworkUtils.IsServer)
{
if ((Object)(object)GameNetworkManager.Instance == (Object)null)
{
return 0;
}
return GameNetworkManager.Instance.connectedPlayers;
}
if ((Object)(object)StartOfRound.Instance == (Object)null)
{
return 0;
}
return StartOfRound.Instance.connectedPlayersAmount + 1;
}
public static string GetCurrentPlanetName()
{
if ((Object)(object)StartOfRound.Instance == (Object)null || (Object)(object)StartOfRound.Instance.currentLevel == (Object)null)
{
return string.Empty;
}
return StartOfRound.Instance.currentLevel.PlanetName;
}
public static LevelWeatherType GetCurrentPlanetWeather()
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: 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)
if ((Object)(object)StartOfRound.Instance == (Object)null || (Object)(object)StartOfRound.Instance.currentLevel == (Object)null)
{
return (LevelWeatherType)(-1);
}
return StartOfRound.Instance.currentLevel.currentWeather;
}
public static int GetDayCount()
{
if ((Object)(object)StartOfRound.Instance == (Object)null || StartOfRound.Instance.gameStats == null)
{
return 0;
}
int num = 0;
if (Plugin.ConfigManager != null && Plugin.ConfigManager.Overlay_DayOffset != null)
{
num = Plugin.ConfigManager.Overlay_DayOffset.Value;
}
return StartOfRound.Instance.gameStats.daysSpent + num + 1;
}
public static int GetProfitQuota()
{
if ((Object)(object)TimeOfDay.Instance == (Object)null)
{
return 0;
}
return TimeOfDay.Instance.profitQuota;
}
public static int GetLootTotal()
{
return GetShipLootTotal() + GetVehicleLootTotal();
}
public static int GetShipLootTotal()
{
Transform hangarShipTransform = GetHangarShipTransform();
if ((Object)(object)hangarShipTransform == (Object)null)
{
return 0;
}
GrabbableObject[] componentsInChildren = ((Component)hangarShipTransform).GetComponentsInChildren<GrabbableObject>();
return componentsInChildren.Where(IsValidScrapAndNotHeld).Sum((GrabbableObject x) => x.scrapValue);
}
public static int GetVehicleLootTotal()
{
VehicleController val = Object.FindFirstObjectByType<VehicleController>();
if ((Object)(object)val == (Object)null)
{
return 0;
}
if (!val.magnetedToShip)
{
return 0;
}
GrabbableObject[] componentsInChildren = ((Component)val).GetComponentsInChildren<GrabbableObject>();
return componentsInChildren.Where(IsValidScrapAndNotHeld).Sum((GrabbableObject x) => x.scrapValue);
}
public static bool IsValidScrapAndNotHeld(GrabbableObject grabbableObject)
{
if (!IsValidScrap(grabbableObject))
{
return false;
}
if (grabbableObject.isHeld)
{
return false;
}
return true;
}
public static bool IsValidScrap(GrabbableObject grabbableObject)
{
if ((Object)(object)grabbableObject == (Object)null || (Object)(object)grabbableObject.itemProperties == (Object)null)
{
return false;
}
if (grabbableObject.deactivated)
{
return false;
}
return grabbableObject.itemProperties.isScrap;
}
public static Coroutine StartCoroutine(IEnumerator routine)
{
if ((Object)(object)Plugin.Instance != (Object)null)
{
return ((MonoBehaviour)Plugin.Instance).StartCoroutine(routine);
}
if ((Object)(object)GameNetworkManager.Instance != (Object)null)
{
return ((MonoBehaviour)GameNetworkManager.Instance).StartCoroutine(routine);
}
Plugin.Logger.LogError((object)("Failed to start coroutine. " + routine));
return null;
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "com.github.zehsteam.StreamOverlays";
public const string PLUGIN_NAME = "StreamOverlays";
public const string PLUGIN_VERSION = "1.0.2";
}
}
namespace com.github.zehsteam.StreamOverlays.Server
{
public class OverlayBehavior : WebSocketBehavior
{
protected override void OnOpen()
{
UpdateOverlay();
}
protected override void OnMessage(MessageEventArgs e)
{
try
{
JObject val = JObject.Parse(e.Data);
if (((object)val["request"])?.ToString() == "latestData")
{
UpdateOverlay();
}
}
catch (Exception ex)
{
Plugin.Logger.LogError((object)("Failed to parse JSON message: " + ex.Message));
}
}
public void SendJsonToClient(object jsonData)
{
((WebSocketBehavior)this).Send(JsonConvert.SerializeObject(jsonData));
}
public void UpdateOverlay()
{
SendJsonToClient(WebServer.GetOverlayData());
}
}
internal static class WebServer
{
private static HttpListener _httpListener;
private static WebSocketServer _webSocketServer;
private static bool _isRunning;
public static int HttpPort => Plugin.ConfigManager.Server_HttpPort.Value;
public static int WebSocketPort => Plugin.ConfigManager.Server_WebSocketPort.Value;
public static bool IsRunning => _isRunning;
public static async Task Initialize()
{
Application.quitting += Stop;
if (PublicArchiveExists())
{
await DecompressPublicArchive();
}
if (!PublicFolderExists())
{
Plugin.Logger.LogFatal((object)"Error! The \"public\" folder does not exist. The overlays will not work. Please report the bug to the mod developer!");
}
if (Plugin.ConfigManager.Server_AutoStart.Value)
{
Start();
}
}
public static void Start()
{
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Expected O, but got Unknown
if (_isRunning)
{
Plugin.Logger.LogWarning((object)"Server is already running!");
return;
}
_isRunning = true;
Task.Run(delegate
{
StartHttpServer(HttpPort);
});
_webSocketServer = new WebSocketServer($"ws://localhost:{WebSocketPort}");
_webSocketServer.AddWebSocketService<OverlayBehavior>("/overlay");
_webSocketServer.Start();
Plugin.Logger.LogInfo((object)$"WebSocket server started on ws://localhost:{WebSocketPort}");
}
public static void Stop()
{
if (_isRunning)
{
_isRunning = false;
HttpListener httpListener = _httpListener;
if (httpListener != null)
{
httpListener.Stop();
}
WebSocketServer webSocketServer = _webSocketServer;
if (webSocketServer != null)
{
webSocketServer.Stop();
}
Plugin.Logger.LogInfo((object)"Server stopped.");
}
}
private static void StartHttpServer(int port)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
_httpListener = new HttpListener();
_httpListener.Prefixes.Add($"http://localhost:{port}/");
_httpListener.Start();
Plugin.Logger.LogInfo((object)$"HTTP server started on http://localhost:{port}");
while (_isRunning)
{
try
{
HttpListenerContext context = _httpListener.GetContext();
Task.Run(delegate
{
HandleHttpRequest(context);
});
}
catch (Exception ex) when (!_isRunning)
{
Plugin.Logger.LogWarning((object)("HTTP server stopped: " + ex.Message));
}
}
}
private static void HandleHttpRequest(HttpListenerContext context)
{
HttpListenerRequest request = context.Request;
HttpListenerResponse response = context.Response;
try
{
string text = request.Url.LocalPath.TrimStart('/');
if (string.IsNullOrEmpty(text))
{
text = "overlay.html";
}
else if (!Path.HasExtension(text))
{
text += ".html";
}
Plugin.Logger.LogInfo((object)("Requested path: \"" + text + "\""));
if (text.Equals("config.js", StringComparison.OrdinalIgnoreCase))
{
response.ContentType = "application/javascript";
string s = $"const webSocketPort = {WebSocketPort};";
byte[] bytes = Encoding.UTF8.GetBytes(s);
response.ContentLength64 = bytes.Length;
response.OutputStream.Write(bytes, 0, bytes.Length);
return;
}
string path = Path.Combine(Utils.GetPluginDirectoryPath(), "public");
string text2 = Path.Combine(path, text);
if (File.Exists(text2))
{
string mimeType = GetMimeType(text2);
response.ContentType = mimeType;
byte[] array = File.ReadAllBytes(text2);
response.ContentLength64 = array.Length;
response.OutputStream.Write(array, 0, array.Length);
}
else
{
response.StatusCode = 404;
byte[] bytes2 = Encoding.UTF8.GetBytes("404 - File Not Found");
response.ContentLength64 = bytes2.Length;
response.OutputStream.Write(bytes2, 0, bytes2.Length);
}
}
catch (Exception ex)
{
response.StatusCode = 500;
byte[] bytes3 = Encoding.UTF8.GetBytes("500 - Internal Server Error");
response.ContentLength64 = bytes3.Length;
response.OutputStream.Write(bytes3, 0, bytes3.Length);
Plugin.Logger.LogError((object)("Error serving request: " + ex.Message));
}
finally
{
response.OutputStream.Close();
}
}
private static string GetMimeType(string filePath)
{
string text = Path.GetExtension(filePath).ToLower();
if (1 == 0)
{
}
string result = text switch
{
".html" => "text/html",
".css" => "text/css",
".js" => "application/javascript",
".png" => "image/png",
".jpg" => "image/jpeg",
".jpeg" => "image/jpeg",
".gif" => "image/gif",
".svg" => "image/svg+xml",
".woff" => "font/woff",
".woff2" => "font/woff2",
".ttf" => "font/ttf",
".otf" => "font/otf",
".mp3" => "audio/mpeg",
".wav" => "audio/wav",
".json" => "application/json",
_ => "application/octet-stream",
};
if (1 == 0)
{
}
return result;
}
public static void SendJsonToClients(object jsonData)
{
if (_webSocketServer == null)
{
return;
}
string text = JsonConvert.SerializeObject(jsonData);
foreach (string path in _webSocketServer.WebSocketServices.Paths)
{
WebSocketServiceHost val = _webSocketServer.WebSocketServices[path];
val.Sessions.Broadcast(text);
}
}
public static void UpdateOverlay()
{
SendJsonToClients(GetOverlayData());
}
public static object GetOverlayData()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
return new
{
source = "overlay",
visible = Utils.CanShowOverlay(),
crew = Utils.GetCrewCount(),
moon = Utils.GetCurrentPlanetName(),
weather = Utils.GetEnumName<LevelWeatherType>(Utils.GetCurrentPlanetWeather()),
showWeatherIcon = Plugin.ConfigManager.Overlay_ShowWeatherIcon.Value,
day = Utils.GetDayCount(),
quota = Utils.GetProfitQuota(),
loot = Utils.GetLootTotal()
};
}
private static bool PublicFolderExists()
{
return Directory.Exists(GetPublicFolderPath());
}
private static bool PublicArchiveExists()
{
return File.Exists(GetPublicArchivePath());
}
private static async Task DecompressPublicArchive()
{
string archivePath = GetPublicArchivePath();
if (!File.Exists(archivePath))
{
return;
}
if (PublicFolderExists())
{
Directory.Delete(GetPublicFolderPath(), recursive: true);
}
try
{
await Task.Run(delegate
{
ZipFile.ExtractToDirectory(archivePath, Utils.GetPluginDirectoryPath());
});
File.Delete(archivePath);
Plugin.Logger.LogInfo((object)"Successfully decompressed public archive.");
}
catch (Exception ex)
{
Plugin.Logger.LogError((object)("Error while decompressing public archive: " + ex.Message));
}
}
private static string GetPublicFolderPath()
{
return Path.Combine(Utils.GetPluginDirectoryPath(), "public");
}
private static string GetPublicArchivePath()
{
return Path.Combine(Utils.GetPluginDirectoryPath(), "public.zip");
}
}
}
namespace com.github.zehsteam.StreamOverlays.Patches
{
[HarmonyPatch(typeof(DepositItemsDesk))]
internal static class DepositItemsDeskPatch
{
[HarmonyPatch("SellAndDisplayItemProfits")]
[HarmonyPostfix]
private static void SellAndDisplayItemProfitsPatch()
{
WebServer.UpdateOverlay();
}
}
[HarmonyPatch(typeof(PlayerControllerB))]
internal static class PlayerControllerBPatch
{
[HarmonyPatch("ConnectClientToPlayerObject")]
[HarmonyPostfix]
private static void ConnectClientToPlayerObjectPatch()
{
WebServer.UpdateOverlay();
}
[HarmonyPatch("GrabObjectClientRpc")]
[HarmonyPostfix]
private static void GrabObjectClientRpcPatch(NetworkObjectReference grabbedObject)
{
NetworkObject val = default(NetworkObject);
GrabbableObject val2 = default(GrabbableObject);
if (((NetworkObjectReference)(ref grabbedObject)).TryGet(ref val, (NetworkManager)null) && ((Component)val).TryGetComponent<GrabbableObject>(ref val2) && (val2.isInShipRoom || val2.isInElevator))
{
WebServer.UpdateOverlay();
}
}
[HarmonyPatch("ThrowObjectClientRpc")]
[HarmonyPostfix]
private static void ThrowObjectClientRpcPatch(bool droppedInElevator, bool droppedInShipRoom)
{
if (droppedInShipRoom || droppedInElevator)
{
WebServer.UpdateOverlay();
}
}
}
[HarmonyPatch(typeof(StartOfRound))]
internal static class StartOfRoundPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void StartPatch()
{
WebServer.UpdateOverlay();
}
[HarmonyPatch("OnPlayerConnectedClientRpc")]
[HarmonyPostfix]
private static void OnPlayerConnectedClientRpcPatch()
{
WebServer.UpdateOverlay();
}
[HarmonyPatch("SyncShipUnlockablesClientRpc")]
[HarmonyPostfix]
private static void SyncShipUnlockablesClientRpcPatch()
{
WebServer.UpdateOverlay();
}
[HarmonyPatch("OnClientConnect")]
[HarmonyPostfix]
private static void OnClientConnectPatch()
{
WebServer.UpdateOverlay();
}
[HarmonyPatch("OnPlayerDC")]
[HarmonyPostfix]
private static void OnPlayerDCPatch()
{
WebServer.UpdateOverlay();
}
[HarmonyPatch("ChangeLevelClientRpc")]
[HarmonyPostfix]
private static void ChangeLevelClientRpcPatch()
{
WebServer.UpdateOverlay();
}
[HarmonyPatch("StartGame")]
[HarmonyPostfix]
private static void StartGamePatch()
{
WebServer.UpdateOverlay();
}
[HarmonyPatch("EndOfGameClientRpc")]
[HarmonyPostfix]
private static void EndOfGameClientRpcPatch()
{
WebServer.UpdateOverlay();
}
[HarmonyPatch("ReviveDeadPlayers")]
[HarmonyPostfix]
private static void ReviveDeadPlayersPatch()
{
WebServer.UpdateOverlay();
}
[HarmonyPatch("SetMapScreenInfoToCurrentLevel")]
[HarmonyPostfix]
private static void SetMapScreenInfoToCurrentLevelPatch()
{
WebServer.UpdateOverlay();
}
[HarmonyPatch("ResetShip")]
[HarmonyPostfix]
private static void ResetShipPatch()
{
WebServer.UpdateOverlay();
}
[HarmonyPatch("OnLocalDisconnect")]
[HarmonyPostfix]
private static void OnLocalDisconnectPatch()
{
WebServer.UpdateOverlay();
}
}
[HarmonyPatch(typeof(TimeOfDay))]
internal static class TimeOfDayPatch
{
[HarmonyPatch("SyncNewProfitQuotaClientRpc")]
[HarmonyPostfix]
private static void SyncNewProfitQuotaClientRpcPatch()
{
WebServer.UpdateOverlay();
}
}
[HarmonyPatch(typeof(VehicleController))]
internal static class VehicleControllerPatch
{
[HarmonyPatch("CollectItemsInTruck")]
[HarmonyPostfix]
private static void CollectItemsInTruckPatch()
{
WebServer.UpdateOverlay();
}
}
}
namespace com.github.zehsteam.StreamOverlays.Dependencies
{
internal static class LethalConfigProxy
{
public const string PLUGIN_GUID = "ainavt.lc.lethalconfig";
public static bool Enabled => Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig");
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static void SkipAutoGen()
{
LethalConfigManager.SkipAutoGen();
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static void AddConfig<T>(ConfigEntry<T> configEntry, bool requiresRestart = false)
{
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Expected O, but got Unknown
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Expected O, but got Unknown
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Expected O, but got Unknown
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Expected O, but got Unknown
AcceptableValueBase acceptableValues = ((ConfigEntryBase)configEntry).Description.AcceptableValues;
if (acceptableValues != null)
{
if (acceptableValues is AcceptableValueRange<float> || acceptableValues is AcceptableValueRange<int>)
{
AddConfigSlider<T>(configEntry, requiresRestart);
return;
}
if (acceptableValues is AcceptableValueList<string>)
{
AddConfigDropdown<T>(configEntry, requiresRestart);
return;
}
}
if (!(configEntry is ConfigEntry<string> val))
{
if (!(configEntry is ConfigEntry<bool> val2))
{
if (!(configEntry is ConfigEntry<float> val3))
{
if (!(configEntry is ConfigEntry<int> val4))
{
throw new NotSupportedException($"Unsupported type: {typeof(T)}");
}
LethalConfigManager.AddConfigItem((BaseConfigItem)new IntInputFieldConfigItem(val4, requiresRestart));
}
else
{
LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatInputFieldConfigItem(val3, requiresRestart));
}
}
else
{
LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(val2, requiresRestart));
}
}
else
{
LethalConfigManager.AddConfigItem((BaseConfigItem)new TextInputFieldConfigItem(val, requiresRestart));
}
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static void AddConfigSlider<T>(ConfigEntry<T> configEntry, bool requiresRestart = false)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Expected O, but got Unknown
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Expected O, but got Unknown
if (!(configEntry is ConfigEntry<float> val))
{
if (!(configEntry is ConfigEntry<int> val2))
{
throw new NotSupportedException($"Slider not supported for type: {typeof(T)}");
}
LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(val2, requiresRestart));
}
else
{
LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(val, requiresRestart));
}
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static void AddConfigDropdown<T>(ConfigEntry<T> configEntry, bool requiresRestart = false)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Expected O, but got Unknown
if (configEntry is ConfigEntry<string> val)
{
LethalConfigManager.AddConfigItem((BaseConfigItem)new TextDropDownConfigItem(val, requiresRestart));
return;
}
throw new NotSupportedException($"Dropdown not supported for type: {typeof(T)}");
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static void AddButton(string section, string name, string description, string buttonText, Action callback)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Expected O, but got Unknown
LethalConfigManager.AddConfigItem((BaseConfigItem)new GenericButtonConfigItem(section, name, description, buttonText, (GenericButtonHandler)delegate
{
callback?.Invoke();
}));
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}