Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of SolarPower v1.0.0
SolarPower.dll
Decompiled 17 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; 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 ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using REPOLib; using REPOLib.Modules; using REPOLib.Objects.Sdk; using REPOMod.Items; using REPOMod.Patches; using REPOMod.Systems; using REPOMod.UI; using REPOMod.Utils; using TMPro; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("MR_QualiwTek")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("REPOModSDK")] [assembly: AssemblyTitle("REPOModSDK")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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] [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 REPOMod { [BepInPlugin("com.repomod.solarpower", "REPO Solar Power", "1.0.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Logger; private static Harmony _harmony; private static bool _gameSystemsStarted; private void Awake() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown Logger = ((BaseUnityPlugin)this).Logger; Logger.LogInfo((object)"Plugin com.repomod.solarpower is loaded!"); ConfigManager.Initialize(((BaseUnityPlugin)this).Config); LocalizationManager.Initialize(((BaseUnityPlugin)this).Config); _harmony = new Harmony("com.repomod.solarpower"); _harmony.PatchAll(Assembly.GetExecutingAssembly()); EnergySystem.Initialize(); LightDetectionSystem.Initialize(); ModNetworkSync.Initialize(); ItemManager.RegisterItems(); Logger.LogInfo((object)"========================================"); Logger.LogInfo((object)"REPO Solar Power Mod initialized!"); Logger.LogInfo((object)"Developed by MR_QualiwTek TTV!"); Logger.LogInfo((object)"Special thanks to Damlis (:"); Logger.LogInfo((object)"Made with Love"); Logger.LogInfo((object)("Language: " + LocalizationManager.GetCurrentLanguage())); Logger.LogInfo((object)$"Clock format: {ConfigManager.ClockFormat.Value}-hour"); Logger.LogInfo((object)$"Generator capacity: {ConfigManager.GeneratorCapacity.Value}"); Logger.LogInfo((object)$"Generator efficiency: {ConfigManager.GeneratorEfficiency.Value:P0}"); Logger.LogInfo((object)"========================================"); } private void OnDestroy() { if (_harmony != null) { _harmony.UnpatchSelf(); Logger.LogInfo((object)"Harmony patches unloaded."); } DayNightCycle.Dispose(); EnergySystem.Dispose(); WeatherSystem.Dispose(); ModNetworkSync.Dispose(); } private void Update() { try { bool isRestrictedMap = MapHelper.IsRestrictedMap; if (isRestrictedMap && _gameSystemsStarted) { _gameSystemsStarted = false; DayNightCycle.Dispose(); WeatherSystem.Dispose(); } else if (!isRestrictedMap && !_gameSystemsStarted) { _gameSystemsStarted = true; DayNightCycle.Initialize(); WeatherSystem.Initialize(); } } catch { } DayNightCycle.Update(); EnergySystem.Update(); LightDetectionSystem.Update(); WeatherSystem.Update(); ModNetworkSync.Update(); EnemyAIPatch.Update(); PlayerPatches.Tick(); DebugSpawnMenu.Update(); } private void OnGUI() { DebugSpawnMenu.OnGUI(); WeatherClockUI.OnGUI(); } } public static class PluginInfo { public const string PLUGIN_GUID = "com.repomod.solarpower"; public const string PLUGIN_NAME = "REPO Solar Power"; public const string PLUGIN_VERSION = "1.0.1"; } } namespace REPOMod.Utils { public static class ConfigManager { private const int MIN_CAPACITY = 25; private const int MAX_CAPACITY = 5000; private const float MIN_EFFICIENCY = 0.1f; private const float MAX_EFFICIENCY = 10f; private const float MIN_CHARGE_RATE = 0f; private const float MAX_CHARGE_RATE = 100f; private const float MIN_VOLUME = 0f; private const float MAX_VOLUME = 1f; private const float MIN_TIME_SPEED = 0.1f; private const float MAX_TIME_SPEED = 10f; private static readonly HashSet<string> _validLanguages = new HashSet<string> { "English", "Turkish" }; public static ConfigEntry<bool> EnableDebugMode { get; private set; } public static ConfigEntry<string> Language { get; private set; } public static ConfigEntry<int> ClockFormat { get; private set; } public static ConfigEntry<float> TimeSpeedMultiplier { get; private set; } public static ConfigEntry<int> SunriseHour { get; private set; } public static ConfigEntry<int> SunsetHour { get; private set; } public static ConfigEntry<int> GeneratorCapacity { get; private set; } public static ConfigEntry<float> GeneratorEfficiency { get; private set; } public static ConfigEntry<float> SolarPanelChargeRate { get; private set; } public static ConfigEntry<float> SolarChargeMultiplier { get; private set; } public static ConfigEntry<float> OrbEnergyPerOrb { get; private set; } public static ConfigEntry<float> ConnectSoundVolume { get; private set; } public static ConfigEntry<float> DisconnectSoundVolume { get; private set; } public static ConfigEntry<float> MapArctic { get; private set; } public static ConfigEntry<float> MapManor { get; private set; } public static ConfigEntry<float> MapMuseum { get; private set; } public static ConfigEntry<float> MapWizard { get; private set; } public static ConfigEntry<float> MapDefault { get; private set; } public static ConfigEntry<bool> EnableWeather { get; private set; } public static ConfigEntry<float> WeatherChangeIntervalMinutes { get; private set; } public static ConfigEntry<float> WeatherSunnyMultiplier { get; private set; } public static ConfigEntry<float> WeatherCloudyMultiplier { get; private set; } public static ConfigEntry<float> WeatherFoggyMultiplier { get; private set; } public static ConfigEntry<float> WeatherRainyMultiplier { get; private set; } public static ConfigEntry<float> WeatherStormyMultiplier { get; private set; } public static ConfigEntry<float> WeatherSnowyMultiplier { get; private set; } public static ConfigEntry<bool> EnableWeatherVisuals { get; private set; } public static ConfigEntry<bool> EnableWeatherSounds { get; private set; } public static ConfigEntry<float> WeatherSoundVolume { get; private set; } public static ConfigEntry<bool> EnableClockWeatherHUD { get; private set; } public static void Initialize(ConfigFile config) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Expected O, but got Unknown //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Expected O, but got Unknown //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Expected O, but got Unknown //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Expected O, but got Unknown //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Expected O, but got Unknown //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Expected O, but got Unknown //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Expected O, but got Unknown //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Expected O, but got Unknown //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Expected O, but got Unknown //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_0370: Expected O, but got Unknown //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Expected O, but got Unknown //IL_03ba: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Expected O, but got Unknown //IL_03e4: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Expected O, but got Unknown //IL_040e: Unknown result type (might be due to invalid IL or missing references) //IL_0418: Expected O, but got Unknown //IL_0438: Unknown result type (might be due to invalid IL or missing references) //IL_0442: Expected O, but got Unknown //IL_04a6: Unknown result type (might be due to invalid IL or missing references) //IL_04b0: Expected O, but got Unknown EnableDebugMode = config.Bind<bool>("General", "EnableDebugMode", false, "Enable debug logging for the mod."); Language = config.Bind<string>("General", "Language", "English", new ConfigDescription("Mod language.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[2] { "English", "Turkish" }), Array.Empty<object>())); ClockFormat = config.Bind<int>("Time", "ClockFormat", 24, new ConfigDescription("Clock display format: 12-hour (AM/PM) or 24-hour.", (AcceptableValueBase)(object)new AcceptableValueList<int>(new int[2] { 12, 24 }), Array.Empty<object>())); TimeSpeedMultiplier = config.Bind<float>("Time", "TimeSpeedMultiplier", 1f, "Multiplier for how fast time passes. Range: 0.1-10.0"); SunriseHour = config.Bind<int>("Time", "SunriseHour", 8, new ConfigDescription("Hour when sunrise begins (solar panels start charging). Max: 24.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 24), Array.Empty<object>())); SunsetHour = config.Bind<int>("Time", "SunsetHour", 18, new ConfigDescription("Hour when sunset ends (solar panels stop charging). Max: 24.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 24), Array.Empty<object>())); GeneratorCapacity = config.Bind<int>("Generator", "GeneratorCapacity", 500, "Maximum crystal energy capacity. Range: 25-5000."); GeneratorEfficiency = config.Bind<float>("Generator", "GeneratorEfficiency", 2f, "Energy efficiency multiplier when charging from ship. Range: 0.1-10.0"); SolarPanelChargeRate = config.Bind<float>("SolarPanel", "SolarPanelChargeRate", 5f, "Base charge rate per second. Range: 0-100."); SolarChargeMultiplier = config.Bind<float>("SolarPanel", "SolarChargeMultiplier", 1f, "Multiplier for solar charge rate based on light intensity."); OrbEnergyPerOrb = config.Bind<float>("OrbFuel", "OrbEnergyPerOrb", 5f, new ConfigDescription("Energy gained per orb (flat, regardless of orb value).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>())); ConnectSoundVolume = config.Bind<float>("Audio", "ConnectSoundVolume", 1f, "Volume for cable connect sound. Range: 0.0-1.0."); DisconnectSoundVolume = config.Bind<float>("Audio", "DisconnectSoundVolume", 1f, "Volume for cable disconnect sound. Range: 0.0-1.0."); AcceptableValueRange<float> val = new AcceptableValueRange<float>(0f, 2f); MapArctic = config.Bind<float>("Maps", "Arctic", 1.2f, new ConfigDescription("Solar light multiplier for Arctic (McJannek Station). Snow reflection boosts light.", (AcceptableValueBase)(object)val, Array.Empty<object>())); MapManor = config.Bind<float>("Maps", "Manor", 0.8f, new ConfigDescription("Solar light multiplier for Headman Manor (indoor mansion, less sunlight).", (AcceptableValueBase)(object)val, Array.Empty<object>())); MapMuseum = config.Bind<float>("Maps", "Museum", 0.7f, new ConfigDescription("Solar light multiplier for the Museum (mostly indoors).", (AcceptableValueBase)(object)val, Array.Empty<object>())); MapWizard = config.Bind<float>("Maps", "Wizard", 0.9f, new ConfigDescription("Solar light multiplier for Wizard (Swiftbroom Academy).", (AcceptableValueBase)(object)val, Array.Empty<object>())); MapDefault = config.Bind<float>("Maps", "Default", 1f, new ConfigDescription("Solar light multiplier for any other map.", (AcceptableValueBase)(object)val, Array.Empty<object>())); EnableWeather = config.Bind<bool>("Weather", "EnableWeather", true, "Enable the dynamic weather system (affects solar panel efficiency)."); WeatherChangeIntervalMinutes = config.Bind<float>("Weather", "WeatherChangeIntervalMinutes", 5f, new ConfigDescription("How often the weather changes (in real minutes).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 60f), Array.Empty<object>())); AcceptableValueRange<float> val2 = new AcceptableValueRange<float>(0f, 2f); WeatherSunnyMultiplier = config.Bind<float>("Weather", "SunnyEfficiency", 1f, new ConfigDescription("Solar efficiency multiplier during sunny weather.", (AcceptableValueBase)(object)val2, Array.Empty<object>())); WeatherCloudyMultiplier = config.Bind<float>("Weather", "CloudyEfficiency", 0.7f, new ConfigDescription("Solar efficiency multiplier during cloudy weather.", (AcceptableValueBase)(object)val2, Array.Empty<object>())); WeatherFoggyMultiplier = config.Bind<float>("Weather", "FoggyEfficiency", 0.5f, new ConfigDescription("Solar efficiency multiplier during foggy weather.", (AcceptableValueBase)(object)val2, Array.Empty<object>())); WeatherRainyMultiplier = config.Bind<float>("Weather", "RainyEfficiency", 0.35f, new ConfigDescription("Solar efficiency multiplier during rainy weather.", (AcceptableValueBase)(object)val2, Array.Empty<object>())); WeatherStormyMultiplier = config.Bind<float>("Weather", "StormyEfficiency", 0.15f, new ConfigDescription("Solar efficiency multiplier during stormy weather.", (AcceptableValueBase)(object)val2, Array.Empty<object>())); WeatherSnowyMultiplier = config.Bind<float>("Weather", "SnowyEfficiency", 0.4f, new ConfigDescription("Solar efficiency multiplier during snowy weather (snow reflects some light).", (AcceptableValueBase)(object)val2, Array.Empty<object>())); EnableWeatherVisuals = config.Bind<bool>("Weather", "EnableWeatherVisuals", true, "Show visual weather effects (fog, darkness, rain particles, lightning)."); EnableWeatherSounds = config.Bind<bool>("Weather", "EnableWeatherSounds", true, "Play weather sound effects (rain, thunder)."); WeatherSoundVolume = config.Bind<float>("Weather", "WeatherSoundVolume", 0.5f, new ConfigDescription("Volume of weather sound effects.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); EnableClockWeatherHUD = config.Bind<bool>("HUD", "EnableClockWeatherHUD", true, "Show the clock + weather HUD at the top-center of the screen (hidden in Lobby/Arena/Shop)."); ValidateConfig(); Plugin.Logger.LogInfo((object)"Configuration loaded and validated."); } public static float GetMapLightMultiplier(string mapName) { if (string.IsNullOrEmpty(mapName)) { return MapDefault.Value; } string text = mapName.ToLowerInvariant().Replace(" ", "").Replace("-", ""); if (text.Contains("arctic")) { return MapArctic.Value; } if (text.Contains("manor")) { return MapManor.Value; } if (text.Contains("museum")) { return MapMuseum.Value; } if (text.Contains("wizard")) { return MapWizard.Value; } if (text.Contains("lobby") || text.Contains("arena") || text.Contains("shop")) { return 0f; } return MapDefault.Value; } private static void ValidateConfig() { string value = Language.Value; if (!_validLanguages.Contains(value)) { Plugin.Logger.LogWarning((object)("Invalid language: " + value + ". Setting to English.")); Language.Value = "English"; } if (ClockFormat.Value != 12 && ClockFormat.Value != 24) { Plugin.Logger.LogWarning((object)$"Invalid ClockFormat: {ClockFormat.Value}. Setting to 24."); ClockFormat.Value = 24; } TimeSpeedMultiplier.Value = ClampValue(TimeSpeedMultiplier.Value, 0.1f, 10f, "TimeSpeedMultiplier"); GeneratorCapacity.Value = ClampValue(GeneratorCapacity.Value, 25, 5000, "GeneratorCapacity"); GeneratorEfficiency.Value = ClampValue(GeneratorEfficiency.Value, 0.1f, 10f, "GeneratorEfficiency"); SolarPanelChargeRate.Value = ClampValue(SolarPanelChargeRate.Value, 0f, 100f, "SolarPanelChargeRate"); ConnectSoundVolume.Value = ClampValue(ConnectSoundVolume.Value, 0f, 1f, "ConnectSoundVolume"); DisconnectSoundVolume.Value = ClampValue(DisconnectSoundVolume.Value, 0f, 1f, "DisconnectSoundVolume"); ValidateSunriseSunset(); } private static void ValidateSunriseSunset() { if (SunriseHour.Value < 0 || SunriseHour.Value >= 24) { Plugin.Logger.LogWarning((object)$"Invalid SunriseHour: {SunriseHour.Value}. Setting to 8."); SunriseHour.Value = 8; } if (SunsetHour.Value <= SunriseHour.Value || SunsetHour.Value > 24) { Plugin.Logger.LogWarning((object)$"Invalid SunsetHour: {SunsetHour.Value}. Setting to 18."); SunsetHour.Value = 18; } } private static T ClampValue<T>(T value, T min, T max, string name) where T : IComparable<T> { if (value.CompareTo(min) < 0) { Plugin.Logger.LogWarning((object)$"{name} value {value} is below minimum {min}. Clamping."); return min; } if (value.CompareTo(max) > 0) { Plugin.Logger.LogWarning((object)$"{name} value {value} is above maximum {max}. Clamping."); return max; } return value; } } public static class LocalizationManager { private static ConfigEntry<string> _languageConfig; private static readonly Dictionary<string, Dictionary<string, string>> _translations = new Dictionary<string, Dictionary<string, string>> { ["item_solar_panel"] = new Dictionary<string, string> { ["English"] = "Solar Panel", ["Turkish"] = "Güneş Paneli" }, ["item_generator"] = new Dictionary<string, string> { ["English"] = "Generator", ["Turkish"] = "Jeneratör" }, ["item_cable"] = new Dictionary<string, string> { ["English"] = "Cable", ["Turkish"] = "Kablo" }, ["desc_solar_panel"] = new Dictionary<string, string> { ["English"] = "Generates energy from sunlight. Connect to a generator with a cable.", ["Turkish"] = "Güneş ışığından enerji üretir. Kablo ile jeneratöre bağlayın." }, ["desc_generator"] = new Dictionary<string, string> { ["English"] = "Stores crystal energy. Can be charged from ship or solar panels.", ["Turkish"] = "Kristal enerjisini depolar. Gemi veya güneş panelinden şarj edilebilir." }, ["desc_cable"] = new Dictionary<string, string> { ["English"] = "Connects solar panels to generators.", ["Turkish"] = "Güneş panellerini jeneratöre bağlar." }, ["msg_connect_cable"] = new Dictionary<string, string> { ["English"] = "Press E to connect cable", ["Turkish"] = "Kabloyu bağlamak için E tuşuna basın" }, ["msg_disconnect_cable"] = new Dictionary<string, string> { ["English"] = "Press E to disconnect cable", ["Turkish"] = "Kabloyu çıkarmak için E tuşuna basın" }, ["msg_cable_connected"] = new Dictionary<string, string> { ["English"] = "Cable connected!", ["Turkish"] = "Kablo bağlandı!" }, ["msg_cable_disconnected"] = new Dictionary<string, string> { ["English"] = "Cable disconnected!", ["Turkish"] = "Kablo çıkarıldı!" }, ["msg_generator_full"] = new Dictionary<string, string> { ["English"] = "Generator is full!", ["Turkish"] = "Jeneratör dolu!" }, ["msg_night_time"] = new Dictionary<string, string> { ["English"] = "Solar panels don't work at night.", ["Turkish"] = "Güneş panelleri gece çalışmaz." }, ["msg_use_orb"] = new Dictionary<string, string> { ["English"] = "Press E to use orb as fuel", ["Turkish"] = "Küreyi yakıt olarak kullanmak için E tuşuna basın" }, ["msg_orb_used"] = new Dictionary<string, string> { ["English"] = "Orb used! Energy gained: {0}", ["Turkish"] = "Küre kullanıldı! Kazanılan enerji: {0}" }, ["msg_cable_too_far"] = new Dictionary<string, string> { ["English"] = "Solar panel is too far! Max distance: 3 meters", ["Turkish"] = "Güneş paneli çok uzak! Mesafe: 3 metre" }, ["msg_cable_jammed"] = new Dictionary<string, string> { ["English"] = "Cable is jammed! Try again.", ["Turkish"] = "Kablo takıldı! Tekrar deneyin." }, ["ui_energy"] = new Dictionary<string, string> { ["English"] = "Energy", ["Turkish"] = "Enerji" }, ["ui_capacity"] = new Dictionary<string, string> { ["English"] = "Capacity", ["Turkish"] = "Kapasite" }, ["ui_efficiency"] = new Dictionary<string, string> { ["English"] = "Efficiency", ["Turkish"] = "Verimlilik" }, ["ui_time"] = new Dictionary<string, string> { ["English"] = "Time", ["Turkish"] = "Saat" }, ["ui_day"] = new Dictionary<string, string> { ["English"] = "Day", ["Turkish"] = "Gündüz" }, ["ui_night"] = new Dictionary<string, string> { ["English"] = "Night", ["Turkish"] = "Gece" }, ["ui_charging"] = new Dictionary<string, string> { ["English"] = "Charging", ["Turkish"] = "Şarj Oluyor" }, ["ui_not_charging"] = new Dictionary<string, string> { ["English"] = "Not Charging", ["Turkish"] = "Şarj Olmuyor" }, ["ui_connected"] = new Dictionary<string, string> { ["English"] = "Connected", ["Turkish"] = "Bağlı" }, ["ui_disconnected"] = new Dictionary<string, string> { ["English"] = "Disconnected", ["Turkish"] = "Bağlı Değil" }, ["config_language"] = new Dictionary<string, string> { ["English"] = "Language", ["Turkish"] = "Dil" }, ["weather_sunny"] = new Dictionary<string, string> { ["English"] = "Sunny", ["Turkish"] = "Güneşli" }, ["weather_cloudy"] = new Dictionary<string, string> { ["English"] = "Cloudy", ["Turkish"] = "Bulutlu" }, ["weather_foggy"] = new Dictionary<string, string> { ["English"] = "Foggy", ["Turkish"] = "Sisli" }, ["weather_rainy"] = new Dictionary<string, string> { ["English"] = "Rainy", ["Turkish"] = "Yağmurlu" }, ["weather_stormy"] = new Dictionary<string, string> { ["English"] = "Stormy", ["Turkish"] = "Fırtınalı" }, ["weather_snowy"] = new Dictionary<string, string> { ["English"] = "Snowy", ["Turkish"] = "Karlı" } }; private static readonly HashSet<string> _validLanguages = new HashSet<string> { "English", "Turkish" }; public static void Initialize(ConfigFile config) { _languageConfig = ConfigManager.Language; ValidateLanguage(); } private static void ValidateLanguage() { string value = _languageConfig.Value; if (!_validLanguages.Contains(value)) { Plugin.Logger.LogWarning((object)("Invalid language: " + value + ". Setting to English.")); _languageConfig.Value = "English"; } } public static string Get(string key) { if (_translations.TryGetValue(key, out Dictionary<string, string> value)) { string currentLanguage = GetCurrentLanguage(); if (value.TryGetValue(currentLanguage, out var value2)) { return value2; } if (value.TryGetValue("English", out var value3)) { return value3; } } return "[" + key + "]"; } public static string Get(string key, params object[] args) { string text = Get(key); try { return string.Format(text, args); } catch { return text; } } public static string GetCurrentLanguage() { string text = _languageConfig?.Value ?? "English"; if (!_validLanguages.Contains(text)) { return "English"; } return text; } public static void SetLanguage(string language) { if (_validLanguages.Contains(language)) { _languageConfig.Value = language; } else { Plugin.Logger.LogWarning((object)("Attempted to set invalid language: " + language)); } } public static IEnumerable<string> GetAvailableLanguages() { return _validLanguages; } } public static class MapHelper { public static bool IsRestrictedMap { get { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) Scene activeScene = SceneManager.GetActiveScene(); string name = ((Scene)(ref activeScene)).name; if (string.IsNullOrEmpty(name)) { return true; } string text = name.ToLowerInvariant(); if (text.Contains("menu") || text.Contains("lobby") || text.Contains("shop") || text.Contains("arena")) { return true; } try { return SemiFunc.RunIsLobby() || SemiFunc.RunIsLobbyMenu() || SemiFunc.RunIsShop() || SemiFunc.RunIsArena(); } catch { return true; } } } public static bool SolarChargingAllowed => !IsRestrictedMap; } } namespace REPOMod.UI { public class BatteryUI : MonoBehaviour { [Header("UI Settings")] [SerializeField] private float displayDistance = 2f; [Header("UI Elements")] [SerializeField] private GameObject uiPanel; [SerializeField] private TextMeshProUGUI chargeText; [SerializeField] private Slider chargeSlider; [Header("Colors")] [SerializeField] private Color highColor = Color.green; [SerializeField] private Color mediumColor = Color.yellow; [SerializeField] private Color lowColor = Color.red; private BatteryPack _battery; private Transform _playerCamera; public static BatteryUI Instance { get; private set; } private void Awake() { Instance = this; CreateUI(); } private void CreateUI() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Expected O, but got Unknown //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Expected O, but got Unknown //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("BatteryUI_Canvas"); Canvas val2 = val.AddComponent<Canvas>(); val2.renderMode = (RenderMode)2; val2.worldCamera = Camera.main; RectTransform component = val.GetComponent<RectTransform>(); component.sizeDelta = new Vector2(2f, 0.4f); uiPanel = new GameObject("Panel"); uiPanel.transform.SetParent(val.transform); RectTransform val3 = uiPanel.AddComponent<RectTransform>(); val3.anchorMin = Vector2.zero; val3.anchorMax = Vector2.one; val3.sizeDelta = Vector2.zero; Image val4 = uiPanel.AddComponent<Image>(); ((Graphic)val4).color = new Color(0f, 0f, 0f, 0.7f); GameObject val5 = new GameObject("ChargeText"); val5.transform.SetParent(uiPanel.transform); RectTransform val6 = val5.AddComponent<RectTransform>(); val6.anchorMin = new Vector2(0f, 0.5f); val6.anchorMax = new Vector2(1f, 1f); val6.sizeDelta = new Vector2(-10f, 0f); chargeText = val5.AddComponent<TextMeshProUGUI>(); ((TMP_Text)chargeText).fontSize = 20f; ((TMP_Text)chargeText).alignment = (TextAlignmentOptions)514; ((Graphic)chargeText).color = Color.white; GameObject val7 = new GameObject("ChargeSlider"); val7.transform.SetParent(uiPanel.transform); RectTransform val8 = val7.AddComponent<RectTransform>(); val8.anchorMin = new Vector2(0f, 0f); val8.anchorMax = new Vector2(1f, 0.5f); val8.sizeDelta = new Vector2(-10f, 0f); chargeSlider = val7.AddComponent<Slider>(); val.SetActive(false); } private void Start() { Camera main = Camera.main; _playerCamera = ((main != null) ? ((Component)main).transform : null); } private void Update() { if (!((Object)(object)_playerCamera == (Object)null)) { CheckForBattery(); } } private void CheckForBattery() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) BatteryPack[] array = Object.FindObjectsOfType<BatteryPack>(); BatteryPack batteryPack = null; float num = float.MaxValue; BatteryPack[] array2 = array; foreach (BatteryPack batteryPack2 in array2) { float num2 = Vector3.Distance(_playerCamera.position, ((Component)batteryPack2).transform.position); if (num2 < displayDistance && num2 < num) { Vector3 val = ((Component)batteryPack2).transform.position - _playerCamera.position; Vector3 normalized = ((Vector3)(ref val)).normalized; float num3 = Vector3.Dot(_playerCamera.forward, normalized); if (num3 > 0.5f) { num = num2; batteryPack = batteryPack2; } } } if ((Object)(object)batteryPack != (Object)null) { ShowUI(batteryPack); } else { HideUI(); } } private void ShowUI(BatteryPack battery) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) _battery = battery; if (!uiPanel.activeSelf) { uiPanel.SetActive(true); } if ((Object)(object)_battery != (Object)null) { ((Component)this).transform.position = ((Component)_battery).transform.position + Vector3.up * 0.8f; ((Component)this).transform.LookAt(_playerCamera); ((Component)this).transform.Rotate(0f, 180f, 0f); } UpdateDisplay(); } private void HideUI() { _battery = null; if (uiPanel.activeSelf) { uiPanel.SetActive(false); } } private void UpdateDisplay() { //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_battery == (Object)null)) { float currentEnergy = _battery.CurrentEnergy; float maxCapacity = _battery.MaxCapacity; float energyPercentage = _battery.EnergyPercentage; string text = ""; if (_battery.IsInSolarSlot) { text = " (Charging)"; } else if (_battery.IsConnectedToGenerator) { text = " (Discharging)"; } ((TMP_Text)chargeText).text = $"[Battery: {(int)currentEnergy}/{(int)maxCapacity} Crystal | {energyPercentage:P0}]{text}"; chargeSlider.value = energyPercentage; if (energyPercentage > 0.5f) { ((Graphic)chargeText).color = highColor; } else if (energyPercentage > 0.25f) { ((Graphic)chargeText).color = mediumColor; } else { ((Graphic)chargeText).color = lowColor; } } } private void OnDestroy() { if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } } public static class DebugSpawnMenu { [CompilerGenerated] private static class <>O { public static WindowFunction <0>__DrawWindow; } private static bool _isOpen; private static bool _showAllItems; private static Vector2 _scrollPos; private static Rect _windowRect = new Rect(60f, 60f, 360f, 480f); private static string _statusMessage = ""; private static float _statusClearTime; private const int WINDOW_ID = 331433; public static void Update() { if (!ConfigManager.EnableDebugMode.Value) { if (_isOpen) { Close(); } return; } if (WasF11PressedThisFrame()) { if (_isOpen) { Close(); } else { Open(); } } if (_isOpen) { Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } } private static void Open() { _isOpen = true; _statusMessage = ""; } private static void Close() { _isOpen = false; Cursor.lockState = (CursorLockMode)1; Cursor.visible = false; } private static bool WasF11PressedThisFrame() { try { return Input.GetKeyDown((KeyCode)292); } catch (InvalidOperationException) { Keyboard current = Keyboard.current; return current != null && ((ButtonControl)current.f11Key).wasPressedThisFrame; } } public static void OnGUI() { //IL_0019: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown if (_isOpen && ConfigManager.EnableDebugMode.Value) { Rect windowRect = _windowRect; object obj = <>O.<0>__DrawWindow; if (obj == null) { WindowFunction val = DrawWindow; <>O.<0>__DrawWindow = val; obj = (object)val; } _windowRect = GUILayout.Window(331433, windowRect, (WindowFunction)obj, "Solar Power - Item Spawner [F11]", Array.Empty<GUILayoutOption>()); } } private static void DrawWindow(int windowId) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0536: Unknown result type (might be due to invalid IL or missing references) //IL_054e: Unknown result type (might be due to invalid IL or missing references) //IL_0553: Unknown result type (might be due to invalid IL or missing references) //IL_060b: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); if (!ModNetworkSync.IsHost) { GUI.color = Color.yellow; GUILayout.Label("! Only the HOST can spawn items / change weather !", Array.Empty<GUILayoutOption>()); GUI.color = Color.white; } GUILayout.Label("Current Weather: " + WeatherSystem.GetWeatherName(), Array.Empty<GUILayoutOption>()); if (ModNetworkSync.IsHost) { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button("Sunny", Array.Empty<GUILayoutOption>())) { TrySetWeather(WeatherType.Sunny); } if (GUILayout.Button("Cloudy", Array.Empty<GUILayoutOption>())) { TrySetWeather(WeatherType.Cloudy); } if (GUILayout.Button("Foggy", Array.Empty<GUILayoutOption>())) { TrySetWeather(WeatherType.Foggy); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button("Rainy", Array.Empty<GUILayoutOption>())) { TrySetWeather(WeatherType.Rainy); } if (GUILayout.Button("Stormy", Array.Empty<GUILayoutOption>())) { TrySetWeather(WeatherType.Stormy); } if (GUILayout.Button("Snowy", Array.Empty<GUILayoutOption>())) { TrySetWeather(WeatherType.Snowy); } GUILayout.EndHorizontal(); } GUILayout.Space(5f); Generator[] array = Object.FindObjectsOfType<Generator>(); if (array != null && array.Length != 0 && ModNetworkSync.IsHost) { GUILayout.Space(5f); GUILayout.Label($"--- Generator Energy ({array.Length} active) ---", Array.Empty<GUILayoutOption>()); Generator[] array2 = array; foreach (Generator generator in array2) { if ((Object)(object)generator == (Object)null) { continue; } float currentEnergy = generator.CurrentEnergy; float maxEnergy = generator.MaxEnergy; float num = Mathf.Max(1f, maxEnergy * 0.1f); GUILayout.Label($"ID {generator.InstanceId}: {currentEnergy:F0} / {maxEnergy:F0}", Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button($"+{num:F0}", Array.Empty<GUILayoutOption>())) { EnergySystem.AddEnergy(generator.InstanceId, num); SetStatus($"Added {num:F0} energy to Generator {generator.InstanceId}"); } if (GUILayout.Button($"-{num:F0}", Array.Empty<GUILayoutOption>())) { float num2 = Mathf.Min(num, currentEnergy); if (num2 > 0f) { EnergySystem.ConsumeEnergy(generator.InstanceId, num2); SetStatus($"Removed {num2:F0} energy from Generator {generator.InstanceId}"); } else { SetStatus("Generator already empty."); } } if (GUILayout.Button("Fill", Array.Empty<GUILayoutOption>())) { EnergySystem.AddEnergy(generator.InstanceId, maxEnergy - currentEnergy); SetStatus($"Generator {generator.InstanceId} filled."); } if (GUILayout.Button("Empty", Array.Empty<GUILayoutOption>())) { EnergySystem.ConsumeEnergy(generator.InstanceId, currentEnergy); SetStatus($"Generator {generator.InstanceId} emptied."); } GUILayout.EndHorizontal(); } GUILayout.Space(5f); } SolarPanel[] array3 = Object.FindObjectsOfType<SolarPanel>(); if (array3 != null && array3.Length != 0 && ModNetworkSync.IsHost) { GUILayout.Label($"--- Solar Panel Storage ({array3.Length} active) ---", Array.Empty<GUILayoutOption>()); SolarPanel[] array4 = array3; foreach (SolarPanel solarPanel in array4) { if (!((Object)(object)solarPanel == (Object)null)) { GUILayout.Label($"ID {solarPanel.InstanceId}: {solarPanel.StoredEnergy:F0} / {30f:F0}", Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button("+5", Array.Empty<GUILayoutOption>())) { solarPanel.AddStoredEnergy(5f); SetStatus($"Added 5 energy to Solar Panel {solarPanel.InstanceId}"); } if (GUILayout.Button("-5", Array.Empty<GUILayoutOption>())) { solarPanel.AddStoredEnergy(-5f); SetStatus($"Removed 5 energy from Solar Panel {solarPanel.InstanceId}"); } if (GUILayout.Button("Fill", Array.Empty<GUILayoutOption>())) { solarPanel.AddStoredEnergy(30f); SetStatus($"Solar Panel {solarPanel.InstanceId} filled."); } if (GUILayout.Button("Empty", Array.Empty<GUILayoutOption>())) { solarPanel.AddStoredEnergy(-30f); SetStatus($"Solar Panel {solarPanel.InstanceId} emptied."); } GUILayout.EndHorizontal(); } } GUILayout.Space(5f); } _showAllItems = GUILayout.Toggle(_showAllItems, " Show ALL game items", Array.Empty<GUILayoutOption>()); GUILayout.Space(5f); IReadOnlyList<Item> readOnlyList = (_showAllItems ? Items.AllItems : Items.RegisteredItems); if (readOnlyList == null || readOnlyList.Count == 0) { GUILayout.Label(_showAllItems ? "No items found (not in a game yet?)" : "No mod items registered.", Array.Empty<GUILayoutOption>()); } else { GUILayout.Label($"Items ({readOnlyList.Count}):", Array.Empty<GUILayoutOption>()); _scrollPos = GUILayout.BeginScrollView(_scrollPos, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(330f) }); foreach (Item item in readOnlyList) { if (!((Object)(object)item == (Object)null) && GUILayout.Button(item.itemName, Array.Empty<GUILayoutOption>())) { TrySpawnItem(item); } } GUILayout.EndScrollView(); } if (!string.IsNullOrEmpty(_statusMessage) && Time.time < _statusClearTime) { GUILayout.Label(_statusMessage, Array.Empty<GUILayoutOption>()); } GUILayout.Space(5f); if (GUILayout.Button("Close (F11)", Array.Empty<GUILayoutOption>())) { Close(); } GUILayout.EndVertical(); GUI.DragWindow(new Rect(0f, 0f, 10000f, 20f)); } private static void TrySpawnItem(Item item) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_004c: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) if (!ModNetworkSync.IsHost) { SetStatus("Failed: only the host can spawn items."); return; } Camera main = Camera.main; if ((Object)(object)main == (Object)null) { SetStatus("Failed: no camera found (are you in a game?)"); return; } Vector3 val = ((Component)main).transform.position + ((Component)main).transform.forward * 2f + Vector3.up * 0.5f; GameObject val2 = Items.SpawnItem(item, val, Quaternion.identity); if ((Object)(object)val2 != (Object)null) { SetStatus("Spawned: " + item.itemName); Plugin.Logger.LogInfo((object)$"[DebugSpawnMenu] Spawned {item.itemName} at {val}"); } else { SetStatus("Failed to spawn: " + item.itemName + " (check log)"); } } private static void TrySetWeather(WeatherType weather) { if (!ModNetworkSync.IsHost) { SetStatus("Failed: only the host can change weather."); return; } WeatherSystem.SetWeather(weather); ModNetworkSync.BroadcastState(); SetStatus("Weather set to: " + WeatherSystem.GetWeatherName()); } private static void SetStatus(string message) { _statusMessage = message; _statusClearTime = Time.time + 5f; } } public class GeneratorUI : MonoBehaviour { [Header("UI Settings")] [SerializeField] private float displayDistance = 3f; [SerializeField] private float updateInterval = 0.1f; [Header("UI Elements")] [SerializeField] private GameObject uiPanel; [SerializeField] private TextMeshProUGUI energyText; [SerializeField] private Slider energySlider; [SerializeField] private Image chargingIcon; [Header("Colors")] [SerializeField] private Color lowEnergyColor = Color.red; [SerializeField] private Color mediumEnergyColor = Color.yellow; [SerializeField] private Color highEnergyColor = Color.green; [SerializeField] private Color chargingColor = Color.cyan; private Generator _generator; private Transform _playerCamera; private float _updateTimer; private bool _isVisible; public static GeneratorUI Instance { get; private set; } private void Awake() { Instance = this; CreateUI(); } private void CreateUI() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Expected O, but got Unknown //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Expected O, but got Unknown //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Expected O, but got Unknown //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("GeneratorUI_Canvas"); Canvas val2 = val.AddComponent<Canvas>(); val2.renderMode = (RenderMode)2; val2.worldCamera = Camera.main; RectTransform component = val.GetComponent<RectTransform>(); component.sizeDelta = new Vector2(2f, 0.5f); uiPanel = new GameObject("Panel"); uiPanel.transform.SetParent(val.transform); RectTransform val3 = uiPanel.AddComponent<RectTransform>(); val3.anchorMin = Vector2.zero; val3.anchorMax = Vector2.one; val3.sizeDelta = Vector2.zero; Image val4 = uiPanel.AddComponent<Image>(); ((Graphic)val4).color = new Color(0f, 0f, 0f, 0.7f); GameObject val5 = new GameObject("EnergyText"); val5.transform.SetParent(uiPanel.transform); RectTransform val6 = val5.AddComponent<RectTransform>(); val6.anchorMin = new Vector2(0f, 0.5f); val6.anchorMax = new Vector2(1f, 1f); val6.sizeDelta = new Vector2(-20f, 0f); val6.anchoredPosition = new Vector2(0f, 0f); energyText = val5.AddComponent<TextMeshProUGUI>(); ((TMP_Text)energyText).fontSize = 24f; ((TMP_Text)energyText).alignment = (TextAlignmentOptions)514; ((Graphic)energyText).color = Color.white; GameObject val7 = new GameObject("EnergySlider"); val7.transform.SetParent(uiPanel.transform); RectTransform val8 = val7.AddComponent<RectTransform>(); val8.anchorMin = new Vector2(0f, 0f); val8.anchorMax = new Vector2(1f, 0.5f); val8.sizeDelta = new Vector2(-20f, 0f); val8.anchoredPosition = new Vector2(0f, 0f); energySlider = val7.AddComponent<Slider>(); GameObject val9 = new GameObject("ChargingIcon"); val9.transform.SetParent(uiPanel.transform); RectTransform val10 = val9.AddComponent<RectTransform>(); val10.anchorMin = new Vector2(1f, 0.5f); val10.anchorMax = new Vector2(1f, 0.5f); val10.sizeDelta = new Vector2(30f, 30f); val10.anchoredPosition = new Vector2(-20f, 0f); chargingIcon = val9.AddComponent<Image>(); ((Graphic)chargingIcon).color = chargingColor; ((Behaviour)chargingIcon).enabled = false; val.SetActive(false); } private void Start() { Camera main = Camera.main; _playerCamera = ((main != null) ? ((Component)main).transform : null); } private void Update() { if (!((Object)(object)_playerCamera == (Object)null)) { _updateTimer += Time.deltaTime; if (!(_updateTimer < updateInterval)) { _updateTimer = 0f; CheckForGenerator(); } } } private void CheckForGenerator() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) Generator[] array = Object.FindObjectsOfType<Generator>(); Generator generator = null; float num = float.MaxValue; Generator[] array2 = array; foreach (Generator generator2 in array2) { float num2 = Vector3.Distance(_playerCamera.position, ((Component)generator2).transform.position); if (num2 < displayDistance && num2 < num) { Vector3 val = ((Component)generator2).transform.position - _playerCamera.position; Vector3 normalized = ((Vector3)(ref val)).normalized; float num3 = Vector3.Dot(_playerCamera.forward, normalized); if (num3 > 0.5f) { num = num2; generator = generator2; } } } if ((Object)(object)generator != (Object)null) { ShowUI(generator); } else { HideUI(); } } private void ShowUI(Generator generator) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) _generator = generator; if (!uiPanel.activeSelf) { uiPanel.SetActive(true); } if ((Object)(object)_generator != (Object)null) { ((Component)this).transform.position = ((Component)_generator).transform.position + Vector3.up * 1.5f; ((Component)this).transform.LookAt(_playerCamera); ((Component)this).transform.Rotate(0f, 180f, 0f); } UpdateDisplay(); } private void HideUI() { _generator = null; if (uiPanel.activeSelf) { uiPanel.SetActive(false); } } private void UpdateDisplay() { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_generator == (Object)null) && _generator.EnergyData != null) { float currentEnergy = _generator.CurrentEnergy; float maxEnergy = _generator.MaxEnergy; float energyPercentage = _generator.EnergyPercentage; string arg = (_generator.EnergyData.IsChargingFromSolar ? " âš¡" : ""); ((TMP_Text)energyText).text = $"[{(int)currentEnergy} / {(int)maxEnergy} Crystal]{arg}"; energySlider.value = energyPercentage; if (_generator.EnergyData.IsChargingFromSolar) { ((Graphic)energyText).color = chargingColor; } else if (energyPercentage < 0.33f) { ((Graphic)energyText).color = lowEnergyColor; } else if (energyPercentage < 0.66f) { ((Graphic)energyText).color = mediumEnergyColor; } else { ((Graphic)energyText).color = highEnergyColor; } ((Behaviour)chargingIcon).enabled = _generator.EnergyData.IsChargingFromSolar; } } private void OnDestroy() { if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } } public class SolarPanelUI : MonoBehaviour { [Header("UI Settings")] [SerializeField] private float displayDistance = 3f; [SerializeField] private float updateInterval = 0.1f; [Header("UI Elements")] [SerializeField] private GameObject uiPanel; [SerializeField] private TextMeshProUGUI infoText; [SerializeField] private Slider efficiencySlider; [SerializeField] private Image statusIcon; [Header("Status Colors")] [SerializeField] private Color chargingColor = Color.green; [SerializeField] private Color idleColor = Color.yellow; [SerializeField] private Color noLightColor = Color.red; [SerializeField] private Color nightColor = Color.blue; [Header("Weather Icons")] [SerializeField] private Sprite sunnyIcon; [SerializeField] private Sprite cloudyIcon; [SerializeField] private Sprite nightIcon; [SerializeField] private Sprite noLightIcon; private SolarPanel _solarPanel; private Transform _playerCamera; private float _updateTimer; private string _currentMapName = "Default"; public static SolarPanelUI Instance { get; private set; } private void Awake() { Instance = this; CreateUI(); DetectCurrentMap(); } private void CreateUI() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Expected O, but got Unknown //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Expected O, but got Unknown //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Expected O, but got Unknown //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("SolarPanelUI_Canvas"); Canvas val2 = val.AddComponent<Canvas>(); val2.renderMode = (RenderMode)2; val2.worldCamera = Camera.main; RectTransform component = val.GetComponent<RectTransform>(); component.sizeDelta = new Vector2(2.5f, 0.6f); uiPanel = new GameObject("Panel"); uiPanel.transform.SetParent(val.transform); RectTransform val3 = uiPanel.AddComponent<RectTransform>(); val3.anchorMin = Vector2.zero; val3.anchorMax = Vector2.one; val3.sizeDelta = Vector2.zero; Image val4 = uiPanel.AddComponent<Image>(); ((Graphic)val4).color = new Color(0f, 0f, 0f, 0.7f); GameObject val5 = new GameObject("StatusIcon"); val5.transform.SetParent(uiPanel.transform); RectTransform val6 = val5.AddComponent<RectTransform>(); val6.anchorMin = new Vector2(0f, 0.5f); val6.anchorMax = new Vector2(0f, 0.5f); val6.sizeDelta = new Vector2(30f, 30f); val6.anchoredPosition = new Vector2(20f, 0f); statusIcon = val5.AddComponent<Image>(); GameObject val7 = new GameObject("InfoText"); val7.transform.SetParent(uiPanel.transform); RectTransform val8 = val7.AddComponent<RectTransform>(); val8.anchorMin = new Vector2(0f, 0.5f); val8.anchorMax = new Vector2(1f, 1f); val8.sizeDelta = new Vector2(-50f, 0f); val8.anchoredPosition = new Vector2(10f, 0f); infoText = val7.AddComponent<TextMeshProUGUI>(); ((TMP_Text)infoText).fontSize = 18f; ((TMP_Text)infoText).alignment = (TextAlignmentOptions)513; ((Graphic)infoText).color = Color.white; GameObject val9 = new GameObject("EfficiencySlider"); val9.transform.SetParent(uiPanel.transform); RectTransform val10 = val9.AddComponent<RectTransform>(); val10.anchorMin = new Vector2(0f, 0f); val10.anchorMax = new Vector2(1f, 0.5f); val10.sizeDelta = new Vector2(-20f, 0f); val10.anchoredPosition = new Vector2(0f, 0f); efficiencySlider = val9.AddComponent<Slider>(); val.SetActive(false); } private void Start() { Camera main = Camera.main; _playerCamera = ((main != null) ? ((Component)main).transform : null); } private void DetectCurrentMap() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) Scene activeScene = SceneManager.GetActiveScene(); string name = ((Scene)(ref activeScene)).name; if (name.Contains("Desert") || name.Contains("desert")) { _currentMapName = "Desert"; } else if (name.Contains("Underground") || name.Contains("underground") || name.Contains("Cave")) { _currentMapName = "Underground"; } else if (name.Contains("Cloudy") || name.Contains("cloudy") || name.Contains("Fog")) { _currentMapName = "Cloudy"; } else if (name.Contains("Forest") || name.Contains("forest")) { _currentMapName = "Forest"; } else if (name.Contains("Snow") || name.Contains("snow") || name.Contains("Ice")) { _currentMapName = "Snow"; } else { _currentMapName = "Default"; } } private void Update() { if (!((Object)(object)_playerCamera == (Object)null)) { _updateTimer += Time.deltaTime; if (!(_updateTimer < updateInterval)) { _updateTimer = 0f; CheckForSolarPanel(); } } } private void CheckForSolarPanel() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) SolarPanel[] array = Object.FindObjectsOfType<SolarPanel>(); SolarPanel solarPanel = null; float num = float.MaxValue; SolarPanel[] array2 = array; foreach (SolarPanel solarPanel2 in array2) { float num2 = Vector3.Distance(_playerCamera.position, ((Component)solarPanel2).transform.position); if (num2 < displayDistance && num2 < num) { Vector3 val = ((Component)solarPanel2).transform.position - _playerCamera.position; Vector3 normalized = ((Vector3)(ref val)).normalized; float num3 = Vector3.Dot(_playerCamera.forward, normalized); if (num3 > 0.5f) { num = num2; solarPanel = solarPanel2; } } } if ((Object)(object)solarPanel != (Object)null) { ShowUI(solarPanel); } else { HideUI(); } } private void ShowUI(SolarPanel panel) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) _solarPanel = panel; if (!uiPanel.activeSelf) { uiPanel.SetActive(true); } if ((Object)(object)_solarPanel != (Object)null) { ((Component)this).transform.position = ((Component)_solarPanel).transform.position + Vector3.up * 1.2f; ((Component)this).transform.LookAt(_playerCamera); ((Component)this).transform.Rotate(0f, 180f, 0f); } UpdateDisplay(); } private void HideUI() { _solarPanel = null; if (uiPanel.activeSelf) { uiPanel.SetActive(false); } } private void UpdateDisplay() { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_solarPanel == (Object)null)) { float currentLightIntensity = _solarPanel.CurrentLightIntensity; float chargeRate = _solarPanel.GetChargeRate(); bool isCharging = _solarPanel.IsCharging; bool isConnectedToGenerator = _solarPanel.IsConnectedToGenerator; float mapLightMultiplier = ConfigManager.GetMapLightMultiplier(_currentMapName); float num = currentLightIntensity * mapLightMultiplier * 100f; string arg; Color color; if (!isConnectedToGenerator) { arg = "Not Connected"; color = idleColor; statusIcon.sprite = cloudyIcon; } else if (DayNightCycle.IsNighttime) { arg = "Night"; color = nightColor; statusIcon.sprite = nightIcon; } else if (currentLightIntensity < 0.1f) { arg = "No Light"; color = noLightColor; statusIcon.sprite = noLightIcon; } else if (isCharging) { arg = "Charging"; color = chargingColor; statusIcon.sprite = sunnyIcon; } else { arg = "Idle"; color = idleColor; statusIcon.sprite = cloudyIcon; } string arg2 = (isCharging ? $"+{chargeRate:F1}/s" : "0/s"); ((TMP_Text)infoText).text = $"Efficiency: {num:F0}%\n{arg} | {arg2}"; ((Graphic)infoText).color = color; efficiencySlider.value = num / 100f; ((Graphic)statusIcon).color = color; } } private void OnDestroy() { if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } } public static class WeatherClockUI { private static readonly Color STAMINA_YELLOW = new Color(1f, 0.81f, 0.1f); private static Texture2D _whiteTex; private static Texture2D[] _icons; private const int ICON_SIZE = 16; public static void OnGUI() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected O, but got Unknown //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Expected O, but got Unknown //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Expected O, but got Unknown //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Expected O, but got Unknown //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) if ((int)Event.current.type == 7 && ConfigManager.EnableClockWeatherHUD.Value && !MapHelper.IsRestrictedMap && DayNightCycle.IsInitialized && WeatherSystem.IsInitialized && !((Object)(object)Camera.main == (Object)null)) { EnsureTextures(); string formattedTime = DayNightCycle.GetFormattedTime(); string weatherName = WeatherSystem.GetWeatherName(); GUIStyle val = new GUIStyle(GUI.skin.label); val.alignment = (TextAnchor)4; val.fontSize = 14; val.fontStyle = (FontStyle)1; val.normal.textColor = STAMINA_YELLOW; GUIStyle val2 = new GUIStyle(val); val2.fontSize = 11; GUIStyle val3 = new GUIStyle(val); val3.normal.textColor = new Color(0f, 0f, 0f, 0.8f); GUIStyle val4 = new GUIStyle(val2); val4.normal.textColor = new Color(0f, 0f, 0f, 0.8f); Vector2 val5 = val.CalcSize(new GUIContent(formattedTime)); Vector2 val6 = val2.CalcSize(new GUIContent(weatherName)); float num = (float)Screen.width / 2f; float num2 = 8f; Rect val7 = default(Rect); ((Rect)(ref val7))..ctor(num - val5.x / 2f, num2, val5.x, val5.y); GUI.Label(new Rect(((Rect)(ref val7)).x + 1f, ((Rect)(ref val7)).y + 1f, ((Rect)(ref val7)).width, ((Rect)(ref val7)).height), formattedTime, val3); GUI.Label(val7, formattedTime, val); float num3 = num2 + val5.y + 2f; float num4 = 20f + val6.x; float num5 = num - num4 / 2f; int currentWeather = (int)WeatherSystem.CurrentWeather; if (_icons != null && currentWeather >= 0 && currentWeather < _icons.Length && (Object)(object)_icons[currentWeather] != (Object)null) { GUI.DrawTexture(new Rect(num5, num3 + (val6.y - 16f) / 2f, 16f, 16f), (Texture)(object)_icons[currentWeather]); } Rect val8 = default(Rect); ((Rect)(ref val8))..ctor(num5 + 16f + 4f, num3, val6.x, val6.y); GUI.Label(new Rect(((Rect)(ref val8)).x + 1f, ((Rect)(ref val8)).y + 1f, ((Rect)(ref val8)).width, ((Rect)(ref val8)).height), weatherName, val4); GUI.Label(val8, weatherName, val2); } } private static void EnsureTextures() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_whiteTex == (Object)null) { _whiteTex = new Texture2D(1, 1); _whiteTex.SetPixel(0, 0, Color.white); _whiteTex.Apply(); } if (_icons == null) { _icons = (Texture2D[])(object)new Texture2D[6]; _icons[0] = MakeSunIcon(); _icons[1] = MakeCloudIcon(new Color(0.75f, 0.75f, 0.78f)); _icons[2] = MakeFogIcon(); _icons[3] = MakeRainIcon(stormy: false); _icons[4] = MakeRainIcon(stormy: true); _icons[5] = MakeSnowIcon(); } } private static Texture2D NewIcon() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(16, 16, (TextureFormat)4, false); ((Texture)val).filterMode = (FilterMode)0; Color val2 = default(Color); ((Color)(ref val2))..ctor(0f, 0f, 0f, 0f); for (int i = 0; i < 16; i++) { for (int j = 0; j < 16; j++) { val.SetPixel(i, j, val2); } } return val; } private static Texture2D MakeSunIcon() { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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_004d: Unknown result type (might be due to invalid IL or missing references) Texture2D val = NewIcon(); Color val2 = default(Color); ((Color)(ref val2))..ctor(1f, 0.85f, 0.2f); int num = 8; for (int i = 0; i < 16; i++) { for (int j = 0; j < 16; j++) { float num2 = Mathf.Sqrt((float)((i - num) * (i - num) + (j - num) * (j - num))); if (num2 <= 4f) { val.SetPixel(i, j, val2); } } } for (int k = 1; k <= 2; k++) { val.SetPixel(num, num + 5 + k, val2); val.SetPixel(num, num - 5 - k, val2); val.SetPixel(num + 5 + k, num, val2); val.SetPixel(num - 5 - k, num, val2); } val.Apply(); return val; } private static Texture2D MakeCloudIcon(Color color) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) Texture2D val = NewIcon(); DrawCircle(val, 5, 7, 3f, color); DrawCircle(val, 9, 8, 4f, color); DrawCircle(val, 12, 7, 3f, color); for (int i = 3; i <= 13; i++) { for (int j = 4; j <= 7; j++) { val.SetPixel(i, j, color); } } val.Apply(); return val; } private static Texture2D MakeFogIcon() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) Texture2D val = NewIcon(); Color val2 = default(Color); ((Color)(ref val2))..ctor(0.7f, 0.7f, 0.72f); for (int i = 0; i < 4; i++) { int num = 3 + i * 3; int num2 = ((i % 2 == 0) ? 2 : 4); for (int j = num2; j < num2 + 10; j++) { val.SetPixel(j, num, val2); } } val.Apply(); return val; } private static Texture2D MakeRainIcon(bool stormy) { //IL_002e: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_012a: 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) Texture2D val = NewIcon(); Color val2 = (stormy ? new Color(0.4f, 0.42f, 0.5f) : new Color(0.6f, 0.62f, 0.68f)); DrawCircle(val, 5, 11, 2.5f, val2); DrawCircle(val, 9, 12, 3f, val2); DrawCircle(val, 12, 11, 2.5f, val2); for (int i = 3; i <= 13; i++) { for (int j = 9; j <= 11; j++) { val.SetPixel(i, j, val2); } } Color val3 = default(Color); ((Color)(ref val3))..ctor(0.4f, 0.6f, 1f); val.SetPixel(5, 6, val3); val.SetPixel(5, 5, val3); val.SetPixel(9, 5, val3); val.SetPixel(9, 4, val3); val.SetPixel(12, 6, val3); val.SetPixel(12, 5, val3); if (stormy) { Color val4 = default(Color); ((Color)(ref val4))..ctor(1f, 0.9f, 0.2f); val.SetPixel(8, 7, val4); val.SetPixel(7, 6, val4); val.SetPixel(8, 5, val4); val.SetPixel(7, 4, val4); val.SetPixel(8, 3, val4); val.SetPixel(7, 2, val4); } val.Apply(); return val; } private static Texture2D MakeSnowIcon() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) Texture2D val = NewIcon(); Color val2 = default(Color); ((Color)(ref val2))..ctor(0.8f, 0.82f, 0.88f); DrawCircle(val, 5, 11, 2.5f, val2); DrawCircle(val, 9, 12, 3f, val2); DrawCircle(val, 12, 11, 2.5f, val2); for (int i = 3; i <= 13; i++) { for (int j = 9; j <= 11; j++) { val.SetPixel(i, j, val2); } } Color white = Color.white; val.SetPixel(5, 6, white); val.SetPixel(9, 4, white); val.SetPixel(12, 6, white); val.SetPixel(7, 3, white); val.SetPixel(11, 2, white); val.Apply(); return val; } private static void DrawCircle(Texture2D tex, int cx, int cy, float radius, Color color) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < 16; i++) { for (int j = 0; j < 16; j++) { float num = Mathf.Sqrt((float)((i - cx) * (i - cx) + (j - cy) * (j - cy))); if (num <= radius) { tex.SetPixel(i, j, color); } } } } } } namespace REPOMod.Systems { public static class DayNightCycle { private static float _currentTime; private static float _timeAccumulator; private static bool _isInitialized; private const float BASE_SECONDS_PER_HOUR = 60f; private const int DAY_CYCLE_HOURS = 24; public static float CurrentTime => _currentTime; public static bool IsInitialized => _isInitialized; public static int CurrentHour => Mathf.FloorToInt(_currentTime); public static int CurrentMinute => Mathf.FloorToInt((_currentTime - (float)CurrentHour) * 60f); public static bool IsDaytime { get { int value = ConfigManager.SunriseHour.Value; int value2 = ConfigManager.SunsetHour.Value; if (_currentTime >= (float)value) { return _currentTime < (float)value2; } return false; } } public static bool IsNighttime => !IsDaytime; public static float GetLightIntensity() { int value = ConfigManager.SunriseHour.Value; int value2 = ConfigManager.SunsetHour.Value; if (_currentTime < (float)value || _currentTime >= (float)value2) { return 0f; } float num = value2 - value; float num2 = (float)value + num / 2f; float num3 = Mathf.Abs(_currentTime - num2); float num4 = 1f - num3 / (num / 2f); return Mathf.Clamp01(num4) * WeatherSystem.GetSunlightMultiplier(); } public static bool CanSolarPanelsCharge() { if (IsDaytime) { return GetLightIntensity() > 0.1f; } return false; } public static string GetFormattedTime() { int currentHour = CurrentHour; int currentMinute = CurrentMinute; int value = ConfigManager.ClockFormat.Value; if (value == 12) { string arg = ((currentHour < 12) ? "AM" : "PM"); int num = currentHour % 12; if (num == 0) { num = 12; } return $"{num:D2}:{currentMinute:D2} {arg}"; } return $"{currentHour:D2}:{currentMinute:D2}"; } public static string GetPeriodOfDay() { if (IsDaytime) { return LocalizationManager.Get("ui_day"); } return LocalizationManager.Get("ui_night"); } public static void SetTimeFromNetwork(float time) { _currentTime = Mathf.Clamp(time, 0f, 24f); } public static void Initialize() { _currentTime = ConfigManager.SunriseHour.Value; _timeAccumulator = 0f; _isInitialized = true; Plugin.Logger.LogInfo((object)$"Day/Night cycle initialized. Clock format: {ConfigManager.ClockFormat.Value}-hour"); } public static void Update() { if (!_isInitialized) { return; } float value = ConfigManager.TimeSpeedMultiplier.Value; float num = 60f / value; _timeAccumulator += Time.deltaTime; if (_timeAccumulator >= num) { float num2 = _timeAccumulator / num; _timeAccumulator = 0f; _currentTime += num2; if (_currentTime >= 24f) { _currentTime -= 24f; } if (ConfigManager.EnableDebugMode.Value) { Plugin.Logger.LogDebug((object)$"Time: {GetFormattedTime()} | Light: {GetLightIntensity():F2}"); } } } public static void Dispose() { _isInitialized = false; } } public static class EnemyAIPatch { private static readonly List<GeneratorSound> _activeGenerators = new List<GeneratorSound>(); private static float _updateInterval = 0.5f; private static float _updateTimer; public static void Update() { _updateTimer += Time.deltaTime; if (!(_updateTimer < _updateInterval)) { _updateTimer = 0f; _activeGenerators.Clear(); _activeGenerators.AddRange(Object.FindObjectsOfType<GeneratorSound>()); if (ConfigManager.EnableDebugMode.Value && _activeGenerators.Count > 0) { Plugin.Logger.LogDebug((object)$"Active noisy generators: {_activeGenerators.Count}"); } } } public static GeneratorSound GetNearestGenerator(Vector3 position, float maxRange = 50f) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return EnemyAIHelper.GetNearestGenerator(position, maxRange); } public static bool IsWithinGeneratorHearingRange(Vector3 position, out GeneratorSound heardGenerator) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return EnemyAIHelper.IsWithinGeneratorHearingRange(position, out heardGenerator); } } public static class EnemyAIHelper { public static GeneratorSound GetNearestGenerator(Vector3 position, float maxRange = 50f) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) GeneratorSound[] array = Object.FindObjectsOfType<GeneratorSound>(); GeneratorSound result = null; float num = maxRange; GeneratorSound[] array2 = array; foreach (GeneratorSound generatorSound in array2) { if (!((Object)(object)generatorSound == (Object)null)) { float num2 = Vector3.Distance(position, ((Component)generatorSound).transform.position); if (num2 < num) { num = num2; result = generatorSound; } } } return result; } public static bool IsWithinGeneratorHearingRange(Vector3 position, out GeneratorSound heardGenerator) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) heardGenerator = null; GeneratorSound[] array = Object.FindObjectsOfType<GeneratorSound>(); foreach (GeneratorSound generatorSound in array) { if (!((Object)(object)generatorSound == (Object)null)) { float num = Vector3.Distance(position, ((Component)generatorSound).transform.position); if (num <= generatorSound.GetHearingRange()) { heardGenerator = generatorSound; return true; } } } return false; } } public static class EnergySystem { public class GeneratorData { public int InstanceId; public float CurrentEnergy; public float MaxEnergy; public float Efficiency; public bool IsConnectedToSolar; public int ConnectedSolarPanelId; public bool IsChargingFromSolar; public float SolarChargeRate; public float LastSyncTime; public float EnergyPercentage { get { if (!(MaxEnergy > 0f)) { return 0f; } return CurrentEnergy / MaxEnergy; } } public bool IsFull => CurrentEnergy >= MaxEnergy; public bool IsEmpty => CurrentEnergy <= 0f; public GeneratorData(int instanceId, float maxEnergy, float efficiency) { InstanceId = instanceId; MaxEnergy = maxEnergy; Efficiency = efficiency; CurrentEnergy = 0f; IsConnectedToSolar = false; ConnectedSolarPanelId = -1; IsChargingFromSolar = false; SolarChargeRate = 0f; LastSyncTime = 0f; } } private static readonly Dictionary<int, GeneratorData> _generators = new Dictionary<int, GeneratorData>(); private static readonly object _lock = new object(); private static bool _isInitialized; public static void Initialize() { lock (_lock) { _generators.Clear(); _isInitialized = true; } Plugin.Logger.LogInfo((object)"Energy system initialized."); } public static void Update() { if (!_isInitialized) { return; } lock (_lock) { List<int> list = new List<int>(_generators.Keys); foreach (int item in list) { if (_generators.TryGetValue(item, out GeneratorData value) && value != null) { UpdateGeneratorCharging(value); } } } } private static void UpdateGeneratorCharging(GeneratorData generator) { if (generator.IsConnectedToSolar && DayNightCycle.CanSolarPanelsCharge()) { float value = ConfigManager.SolarPanelChargeRate.Value; float value2 = ConfigManager.SolarChargeMultiplier.Value; float lightIntensity = DayNightCycle.GetLightIntensity(); float num = value * value2 * lightIntensity * Time.deltaTime; AddEnergyInternal(generator, num); generator.IsChargingFromSolar = true; generator.SolarChargeRate = num / Mathf.Max(Time.deltaTime, 0.001f); } else { generator.IsChargingFromSolar = false; generator.SolarChargeRate = 0f; } } public static GeneratorData RegisterGenerator(int instanceId) { lock (_lock) { if (_generators.ContainsKey(instanceId)) { Plugin.Logger.LogWarning((object)$"Generator {instanceId} already registered. Returning existing."); return _generators[instanceId]; } float num = ConfigManager.GeneratorCapacity.Value; float value = ConfigManager.GeneratorEfficiency.Value; GeneratorData generatorData = new GeneratorData(instanceId, num, value); _generators[instanceId] = generatorData; Plugin.Logger.LogInfo((object)$"Generator registered. ID: {instanceId}, Capacity: {num}, Efficiency: {value:P0}"); return generatorData; } } public static void UnregisterGenerator(int instanceId) { lock (_lock) { if (_generators.Remove(instanceId)) { Plugin.Logger.LogInfo((object)$"Generator unregistered. ID: {instanceId}"); } } } public static GeneratorData GetGenerator(int instanceId) { lock (_lock) { _generators.TryGetValue(instanceId, out GeneratorData value); return value; } } public static bool AddEnergyFromShip(int instanceId, float baseEnergy) { GeneratorData generator = GetGenerator(instanceId); if (generator == null) { Plugin.Logger.LogWarning((object)$"AddEnergyFromShip: Generator {instanceId} not found."); return false; } if (generator.IsFull) { return false; } float amount = baseEnergy * generator.Efficiency; return AddEnergy(instanceId, amount); } public static bool AddEnergy(int instanceId, float amount) { if (amount <= 0f) { return false; } GeneratorData generator = GetGenerator(instanceId); if (generator == null) { Plugin.Logger.LogWarning((object)$"AddEnergy: Generator {instanceId} not found."); return false; } return AddEnergyInternal(generator, amount); } private static bool AddEnergyInternal(GeneratorData generator, float amount) { if (generator.IsFull) { return false; } float currentEnergy = generator.CurrentEnergy; generator.CurrentEnergy = Mathf.Min(generator.CurrentEnergy + amount, generator.MaxEnergy); return generator.CurrentEnergy > currentEnergy; } public static bool ConsumeEnergy(int instanceId, float amount) { if (amount <= 0f) { return false; } GeneratorData generator = GetGenerator(instanceId); if (generator == null) { Plugin.Logger.LogWarning((object)$"ConsumeEnergy: Generator {instanceId} not found."); return false; } if (generator.CurrentEnergy < amount) { return false; } generator.CurrentEnergy -= amount; return true; } public static float AddEnergyFromOrb(int instanceId, float orbValue) { if (orbValue <= 0f) { return 0f; } GeneratorData generator = GetGenerator(instanceId); if (generator == null) { Plugin.Logger.LogWarning((object)$"AddEnergyFromOrb: Generator {instanceId} not found."); return 0f; } if (generator.IsFull) { return 0f; } float value = ConfigManager.OrbEnergyPerOrb.Value; float currentEnergy = generator.CurrentEnergy; AddEnergyInternal(generator, value); return generator.CurrentEnergy - currentEnergy; } public static void ConnectSolarPanel(int generatorId, int solarPanelId) { GeneratorData generator = GetGenerator(generatorId); if (generator == null) { Plugin.Logger.LogWarning((object)$"ConnectSolarPanel: Generator {generatorId} not found."); return; } generator.IsConnectedToSolar = true; generator.ConnectedSolarPanelId = solarPanelId; Plugin.Logger.LogInfo((object)$"Solar panel {solarPanelId} connected to generator {generatorId}"); } public static void DisconnectSolarPanel(int generatorId) { GeneratorData generator = GetGenerator(generatorId); if (generator == null) { Plugin.Logger.LogWarning((object)$"DisconnectSolarPanel: Generator {generatorId} not found."); return; } generator.IsConnectedToSolar = false; generator.ConnectedSolarPanelId = -1; generator.IsChargingFromSolar = false; generator.SolarChargeRate = 0f; Plugin.Logger.LogInfo((object)$"Solar panel disconnected from generator {generatorId}"); } public static List<GeneratorData> GetAllGenerators() { lock (_lock) { return new List<GeneratorData>(_generators.Values); } } public static float GetTotalEnergy() { float num = 0f; lock (_lock) { foreach (KeyValuePair<int, GeneratorData> generator in _generators) { if (generator.Value != null) { num += generator.Value.CurrentEnergy; } } return num; } } public static void Dispose() { lock (_lock) { _generators.Clear(); _isInitialized = false; } } } public static class LightDetectionSystem { private static List<Light> _sunLights = new List<Light>(); private static bool _hasSunLight; private static float _lastCacheTime; private const float CACHE_INTERVAL = 5f; public static void Initialize() { CacheLightSources(); Plugin.Logger.LogInfo((object)"Light detection system initialized."); } public static void CacheLightSources() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Invalid comparison between Unknown and I4 _sunLights.Clear(); _hasSunLight = false; Light[] array = Object.FindObjectsOfType<Light>(); Light[] array2 = array; foreach (Light val in array2) { if ((int)val.type == 1) { _sunLights.Add(val); _hasSunLight = true; } } _lastCacheTime = Time.time; if (ConfigManager.EnableDebugMode.Value) { Plugin.Logger.LogDebug((object)$"Found {_sunLights.Count} sun light(s) in scene."); } } public static bool CanReceiveSunlight(Vector3 position, float detectionRadius = 10f) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) if (_hasSunLight) { foreach (Light sunLight in _sunLights) { if (((Behaviour)sunLight).enabled && sunLight.intensity > 0.1f && IsPositionInSunlight(position, sunLight)) { return true; } } } if (HasLineOfSightToSky(position, detectionRadius)) { return true; } if (GetAmbientLightIntensity(position) > 0.3f) { return true; } return DayNightCycle.IsDaytime; } public static float GetSunlightIntensity(Vector3 position, float detectionRadius = 10f) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) float num = 0f; if (_hasSunLight) { foreach (Light sunLight in _sunLights) { if (((Behaviour)sunLight).enabled) { float sunIntensityAtPosition = GetSunIntensityAtPosition(position, sunLight); num = Mathf.Max(num, sunIntensityAtPosition); } } } if (HasLineOfSightToSky(position, detectionRadius)) { num = Mathf.Max(num, 0.8f); } float ambientLightIntensity = GetAmbientLightIntensity(position); num = Mathf.Max(num, ambientLightIntensity); num *= DayNightCycle.GetLightIntensity(); return Mathf.Clamp01(num); } private static bool IsPositionInSunlight(Vector3 position, Light sunLight) { //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) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) Vector3 val = -((Component)sunLight).transform.forward; RaycastHit val2 = default(RaycastHit); if (Physics.Raycast(position, val, ref val2, 100f)) { return false; } return true; } private static float GetSunIntensityAtPosition(Vector3 position, Light sunLight) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (!IsPositionInSunlight(position, sunLight)) { return 0f; } return sunLight.intensity; } private static bool HasLineOfSightToSky(Vector3 position, float maxDistance = 10f) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: 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) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) Vector3 val = position + Vector3.up * 0.5f; RaycastHit val2 = default(RaycastHit); if (Physics.Raycast(val, Vector3.up, ref val2, maxDistance)) { if (((RaycastHit)(ref val2)).collider.isTrigger || IsTransparent(((RaycastHit)(ref val2)).collider)) { return HasLineOfSightToSky(((RaycastHit)(ref val2)).point + Vector3.up * 0.1f, maxDistance - ((RaycastHit)(ref val2)).distance); } return false; } return true; } private static bool IsTransparent(Collider collider) { Renderer component = ((Component)collider).GetComponent<Renderer>(); if ((Object)(object)component == (Object)null) { return false; } Material material = component.material; if ((Object)(object)material == (Object)null) { return false; } if (material.renderQueue >= 3000) { return true; } return false; } private static float GetAmbientLightIntensity(Vector3 position) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) float[] array = new float[9]; SphericalHarmonicsL2 val = default(SphericalHarmonicsL2); LightProbes.GetInterpolatedProbe(position, (Renderer)null, ref val); float num = 0f; for (int i = 0; i < 3; i++) { num += ((SphericalHarmonicsL2)(ref val))[i, 0]; } return Mathf.Clamp01(num); } public static void Update() { if (Time.time - _lastCacheTime > 5f) { CacheLightSources(); } } public static string GetDebugInfo(Vector3 position) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) return $"Sun Lights: {_sunLights.Count}\n" + $"Can Receive Sun: {CanReceiveSunlight(position)}\n" + $"Intensity: {GetSunlightIntensity(position):F2}\n" + $"Daytime: {DayNightCycle.IsDaytime}\n" + "Time: " + DayNightCycle.GetFormattedTime(); } } public static class ModNetworkSync { private static NetworkedEvent _stateSyncEvent; private static float _broadcastTimer; private static bool _isInitialized; private const float BROADCAST_INTERVAL = 15f; public static bool IsHost { get { try { return SemiFunc.IsMasterClientOrSingleplayer(); } catch { return true; } } } public static void Initialize() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown try { _stateSyncEvent = new NetworkedEvent("SolarPower_StateSync", (Action<EventData>)HandleStateSync); _isInitialized = true; Plugin.Logger.LogInfo((object)"Network sync initialized (host-authoritative)."); } catch (Exception ex) { Plugin.Logger.LogError((object)("Failed to initialize network sync: " + ex.Message)); } } public static void Update() { if (_isInitialized && IsHost) { _broadcastTimer += Time.deltaTime; if (_broadcastTimer >= 15f) { _broadcastTimer = 0f; BroadcastState(); } } } public static void BroadcastState() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) if (!_isInitialized || !IsHost) { return; } try { object[] array = new object[2] { (int)WeatherSystem.CurrentWeather, DayNightCycle.CurrentTime }; _stateSyncEvent.RaiseEvent((object)array, NetworkingEvents.RaiseOthers, SendOptions.SendReliable); } catch (Exception ex) { Plugin.Logger.LogError((object)("Failed to broadcast state: " + ex.Message)); } } private static void HandleStateSync(EventData eventData) { if (IsHost) { return; } try { if (!(eventData.CustomData is object[] array) || array.Length < 2 || !(array