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 Tides v1.3.1
plugins/Tides.dll
Decompiled a month agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using HarmonyLib; using Jotunn; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Tides.Commands; using Tides.Compatibility; using Tides.Core; using Tides.Systems; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Tides")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Tides")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")] [assembly: AssemblyFileVersion("1.3.1")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.3.1.0")] namespace Tides { [BepInPlugin("com.naexn.Tides", "Tides", "1.3.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] internal class Tides : BaseUnityPlugin { public const string PluginGUID = "com.naexn.Tides"; public const string PluginName = "Tides"; public const string PluginVersion = "1.3.1"; public static CustomLocalization Localization = LocalizationManager.Instance.GetLocalization(); private void Awake() { //IL_006f: 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_007f: Expected O, but got Unknown Logger.LogInfo((object)"Tides has landed"); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new TidesInfoCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new TidesDiagCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new TidesDebugLilyCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new TidesDebugCattailCommand()); SeasonsCompat.CheckForCompatibility(); SeasonalityCompat.CheckForCompatibility(); TidesConfig.SetupLocalizations(); TidesConfig.CreateConfigValues(((BaseUnityPlugin)this).Config); TideSystem.ApplyConfigModifications(); TidesConfig.RegisterChangeCallbacks(); Harmony val = new Harmony("com.naexn.Tides"); val.PatchAll(); SeasonalityCompat.Initialize(val); } } } namespace Tides.Systems { internal class SwampMovementSystem { private static float BaseWaterLevel => TideSystem.OceanBaseY - 0.1f; internal static float ComputeSwampVariant(Character c, float baseSpeed) { //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_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) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)c).transform.position; Biome biome = WorldGenerator.instance.GetBiome(position); if ((int)biome != 2) { return baseSpeed; } float groundHeight = ZoneSystem.instance.GetGroundHeight(position); float num = BaseWaterLevel - groundHeight; if (num <= 0f) { return baseSpeed; } float num2 = c.m_collider.height / 3f; float num3 = Mathf.Clamp01(num / num2); float num4 = baseSpeed; num4 -= num4 * num4 * num3 * 0.05f; if (Diagnostics.DebugSwampMovementEnabled) { Logger.LogInfo((object)$"SWAMP: Biome={biome}, GroundY={groundHeight}, Depth={num}, DepthFactor={num3}, BaseSpeed={baseSpeed}, ResultSpeed={num4}"); } return num4; } } internal class TideSystem { internal static float TidePeriodDays = 0.5175f; internal static float TideAmplitude = 1.4f; internal static float OceanBaseY = 30f; internal static float _lastTideOffset = 0f; private static bool _debugTidesEnabled = false; private static Transform _waterPlane; internal static void UpdateTides() { //IL_00be: 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_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ZNet.instance == (Object)null || TideAmplitude == 0f) { return; } if ((Object)(object)_waterPlane == (Object)null) { if (Diagnostics.DebugTidesEnabled && _debugTidesEnabled) { Logger.LogWarning((object)"Waterplane is null, trying to get and cache."); } CacheWaterPlane(); } float num = (float)EnvMan.instance.GetDay() + EnvMan.instance.GetDayFraction(); float tideOffset = Mathf.Sin(num / TidePeriodDays * (float)Math.PI * 2f) * TideAmplitude; float baseWaterY = OceanBaseY; ApplyCompatibilityModifiers(ref tideOffset, ref baseWaterY); _lastTideOffset = tideOffset; float num2 = baseWaterY + tideOffset; if ((Object)(object)_waterPlane != (Object)null) { if (Diagnostics.DebugTidesEnabled && _debugTidesEnabled) { Logger.LogWarning((object)"Waterplane is not null, applying transform."); } Vector3 position = _waterPlane.position; position.y = num2; _waterPlane.position = position; } else if (Diagnostics.DebugTidesEnabled && _debugTidesEnabled) { Logger.LogWarning((object)"Waterplane is null, skipping transform."); } foreach (WaterVolume instance in WaterVolume.Instances) { if ((Object)(object)instance == (Object)null) { continue; } Material material = ((Renderer)instance.m_waterSurface).material; if (!((Object)(object)material == (Object)null) && !(((Object)material).name.ToLowerInvariant() != "water (instance)")) { Vector3 position2 = ((Component)instance).transform.position; position2.y = num2; ((Component)instance).transform.position = position2; Vector3 position3 = ((Component)instance.m_waterSurface).transform.position; position3.y = num2; ((Component)instance.m_waterSurface).transform.position = position3; if (Diagnostics.DebugTidesEnabled && _debugTidesEnabled) { Logger.LogInfo((object)$"offset={tideOffset}m, worldDay={num}, Day={EnvMan.instance.GetDay()} + Frac={EnvMan.instance.GetDayFraction()} = WorldDays={(float)EnvMan.instance.GetDay() + EnvMan.instance.GetDayFraction()}, finalY={num2}m , physPos={((Component)instance).transform.position.y}m, visualPos={((Component)instance.m_waterSurface).transform.position.y}m"); _debugTidesEnabled = false; } } } } internal static void ApplyConfigModifications() { float value = TidesConfig.TideAmplitude.Value; float value2 = TidesConfig.BaseWaterLevel.Value; float value3 = TidesConfig.TideSpeedMultiplier.Value; float num = Mathf.Clamp(value, 0f, 3f); float num2 = Mathf.Clamp(value2, 26f, 34f); float num3 = Mathf.Clamp(value3, 0.1f, 5f); if (num != TideAmplitude) { if (Diagnostics.DebugTidesEnabled && _debugTidesEnabled) { Logger.LogInfo((object)$"Tide amplitude modified from {TideAmplitude}m to {num}m"); } TideAmplitude = num; } if (num2 != OceanBaseY) { if (Diagnostics.DebugTidesEnabled && _debugTidesEnabled) { Logger.LogInfo((object)$"Base water level modified from {OceanBaseY}m to {num2}m"); } OceanBaseY = num2; } if (num3 != 1f) { if (Diagnostics.DebugTidesEnabled && _debugTidesEnabled) { Logger.LogInfo((object)$"Tide speed multiplier modified to {num3}x"); } TidePeriodDays = 0.5175f / num3; } } internal static void CacheWaterPlane() { GameObject obj = GameObject.Find("WaterPlane"); _waterPlane = ((obj != null) ? obj.transform : null); if (Diagnostics.DebugTidesEnabled && _debugTidesEnabled) { if ((Object)(object)_waterPlane == (Object)null) { Logger.LogWarning((object)"Failed to find WaterPlane."); } Logger.LogWarning((object)"WaterPlane found."); } } internal static void ApplyCompatibilityModifiers(ref float tideOffset, ref float baseWaterY) { float num = 0f; if (SeasonsCompat.IsEnabled) { num = Mathf.Max(num, SeasonsCompat.GetWaterFreezeStatus()); } if (SeasonalityCompat.IsEnabled && SeasonalityCompat.IsWaterFrozen) { num = 1f; } if (!(num <= 0f)) { tideOffset *= 1f - num; baseWaterY = Mathf.Lerp(baseWaterY, 30f, num); } } } internal static class VegetationSystem { private class WaterLilyInstance { public Matrix4x4 OriginalMatrix; public float MinOffset; public float MaxOffset; } private class WaterLiliesBatch { public InstanceRenderer Renderer; public WaterLilyInstance[] WaterLilies; } private class CattailsBatch { public InstanceRenderer Renderer; public Matrix4x4[] OriginalMatrices; } private const float MinLilyMaxOffset = 0.4f; private const float MaxLilyMaxOffset = 2f; private const float LilyMinGroundHeight = 0.2f; private const float CattailStartDepth = 0.45f; private const float CattailMaxDepth = 1.4f; private const float CattailMaxOffset = -1.1f; private static readonly List<WaterLiliesBatch> _waterLilies = new List<WaterLiliesBatch>(); private static readonly List<CattailsBatch> _cattails = new List<CattailsBatch>(); private static readonly HashSet<InstanceRenderer> _pendingLilies = new HashSet<InstanceRenderer>(); private static readonly HashSet<InstanceRenderer> _pendingCattails = new HashSet<InstanceRenderer>(); private static FieldInfo _instancesField; private static FieldInfo _instanceCountField; private static FieldInfo _dirtyBoundsField; private static bool _initialized; internal static void Initialize() { if (!_initialized) { _instancesField = typeof(InstanceRenderer).GetField("m_instances", BindingFlags.Instance | BindingFlags.NonPublic); _instanceCountField = typeof(InstanceRenderer).GetField("m_instanceCount", BindingFlags.Instance | BindingFlags.NonPublic); _dirtyBoundsField = typeof(InstanceRenderer).GetField("m_dirtyBounds", BindingFlags.Instance | BindingFlags.NonPublic); _initialized = true; } } internal static void Update(float tideOffset) { Initialize(); InstanceRenderer[] array = _pendingLilies.ToArray(); foreach (InstanceRenderer val in array) { if ((int)_instanceCountField.GetValue(val) > 0) { TryRegister(val); _pendingLilies.Remove(val); } } array = _pendingCattails.ToArray(); foreach (InstanceRenderer val2 in array) { if ((int)_instanceCountField.GetValue(val2) > 0) { RegisterCattails(val2); _pendingCattails.Remove(val2); } } foreach (WaterLiliesBatch waterLily in _waterLilies) { if (!((Object)(object)waterLily.Renderer == (Object)null)) { ApplyWaterLilyOffset(waterLily); } } } internal static void TryRegister(InstanceRenderer renderer) { Initialize(); if (!((Object)(object)renderer == (Object)null) && !((Object)(object)renderer.m_material == (Object)null)) { if (((Object)renderer.m_material).name == "clutter_waterlilies") { RegisterWaterLilies(renderer); } else if (((Object)renderer.m_material).name == "vass") { RegisterCattails(renderer); } } } internal static void RegisterWaterLilies(InstanceRenderer renderer) { //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) foreach (WaterLiliesBatch waterLily in _waterLilies) { if ((Object)(object)waterLily.Renderer == (Object)(object)renderer) { return; } } Matrix4x4[] array = (Matrix4x4[])_instancesField.GetValue(renderer); int num = (int)_instanceCountField.GetValue(renderer); if (num == 0) { if (Diagnostics.DebugVegetationEnabled) { Logger.LogInfo((object)"Waterlily renderer created but has no instances yet"); } if (!_pendingLilies.Contains(renderer)) { _pendingLilies.Add(renderer); } return; } if (Diagnostics.DebugVegetationEnabled) { Logger.LogWarning((object)$"Registering water lilies. Count={num}"); } WaterLilyInstance[] array2 = new WaterLilyInstance[num]; for (int i = 0; i < num; i++) { Vector3 val = Vector4.op_Implicit(((Matrix4x4)(ref array[i])).GetColumn(3)); float groundHeight = ZoneSystem.instance.GetGroundHeight(val); array2[i] = new WaterLilyInstance { OriginalMatrix = array[i], MinOffset = groundHeight + 0.2f - TideSystem.OceanBaseY, MaxOffset = Random.Range(0.4f, 2f) }; } WaterLiliesBatch waterLiliesBatch = new WaterLiliesBatch { Renderer = renderer, WaterLilies = array2 }; _waterLilies.Add(waterLiliesBatch); ApplyWaterLilyOffset(waterLiliesBatch); } internal static void RegisterCattails(InstanceRenderer renderer) { foreach (CattailsBatch cattail in _cattails) { if ((Object)(object)cattail.Renderer == (Object)(object)renderer) { return; } } Matrix4x4[] sourceArray = (Matrix4x4[])_instancesField.GetValue(renderer); int num = (int)_instanceCountField.GetValue(renderer); if (num == 0) { if (Diagnostics.DebugVegetationEnabled) { Logger.LogInfo((object)"Cattail renderer created but has no instances yet"); } if (!_pendingCattails.Contains(renderer)) { _pendingCattails.Add(renderer); } return; } if (Diagnostics.DebugVegetationEnabled) { Logger.LogWarning((object)$"Registering cattails. Count={num}"); } Matrix4x4[] array = (Matrix4x4[])(object)new Matrix4x4[num]; Array.Copy(sourceArray, array, num); CattailsBatch cattailsBatch = new CattailsBatch { Renderer = renderer, OriginalMatrices = array }; _cattails.Add(cattailsBatch); ApplyCattailOffset(cattailsBatch); } private static void ApplyWaterLilyOffset(WaterLiliesBatch batch) { //IL_0024: 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) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) Matrix4x4[] array = (Matrix4x4[])_instancesField.GetValue(batch.Renderer); for (int i = 0; i < batch.WaterLilies.Length; i++) { WaterLilyInstance waterLilyInstance = batch.WaterLilies[i]; Matrix4x4 originalMatrix = waterLilyInstance.OriginalMatrix; float num = Mathf.Clamp(TideSystem._lastTideOffset, waterLilyInstance.MinOffset, waterLilyInstance.MaxOffset); ((Matrix4x4)(ref originalMatrix))[1, 3] = ((Matrix4x4)(ref originalMatrix))[1, 3] + num; array[i] = originalMatrix; } _dirtyBoundsField.SetValue(batch.Renderer, true); } private static void ApplyCattailOffset(CattailsBatch batch) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) Matrix4x4[] array = (Matrix4x4[])_instancesField.GetValue(batch.Renderer); if (Diagnostics.DebugVegetationEnabled) { Logger.LogInfo((object)"Cattail - about to apply offset"); } for (int i = 0; i < batch.OriginalMatrices.Length; i++) { Matrix4x4 val = batch.OriginalMatrices[i]; Vector3 val2 = Vector4.op_Implicit(((Matrix4x4)(ref val)).GetColumn(3)); float groundHeight = ZoneSystem.instance.GetGroundHeight(val2); float num = TideSystem.OceanBaseY - groundHeight; float num2 = CalculateCattailOffset(num); if (Diagnostics.DebugVegetationEnabled) { Logger.LogInfo((object)$"Cattail originally at {num} from base, moved by {num2}"); } ((Matrix4x4)(ref val))[1, 3] = ((Matrix4x4)(ref val))[1, 3] + num2; array[i] = val; } _dirtyBoundsField.SetValue(batch.Renderer, true); } private static float CalculateCattailOffset(float depth) { if (depth <= 0.45f) { return 0f; } float num = Mathf.InverseLerp(0.45f, 1.4f, depth); return Mathf.Lerp(0f, -1.1f, num); } internal static void TestMoveVegetation(string vegetation) { foreach (IMonoUpdater instance in InstanceRenderer.Instances) { InstanceRenderer val = (InstanceRenderer)(object)((instance is InstanceRenderer) ? instance : null); if (val == null || (Object)(object)val.m_material == (Object)null) { continue; } if (Diagnostics.DebugVegetationEnabled) { Logger.LogInfo((object)("Renderer found: " + ((Object)val.m_material).name)); } if (((Object)val.m_material).name != vegetation) { continue; } Matrix4x4[] array = (Matrix4x4[])_instancesField.GetValue(val); int num = (int)_instanceCountField.GetValue(val); if (Diagnostics.DebugVegetationEnabled) { Logger.LogInfo((object)$"{vegetation}: {num}"); } for (int i = 0; i < num; i++) { float num2 = ((Matrix4x4)(ref array[i]))[1, 3]; if (Diagnostics.DebugVegetationEnabled) { Logger.LogInfo((object)$"{vegetation} instance {i}: Y={num2}"); } ref Matrix4x4 reference = ref array[i]; ((Matrix4x4)(ref reference))[1, 3] = ((Matrix4x4)(ref reference))[1, 3] + 2f; } _dirtyBoundsField.SetValue(val, true); if (Diagnostics.DebugVegetationEnabled) { Logger.LogInfo((object)("Moved " + vegetation + " +2")); } } } } } namespace Tides.Patches { internal class InstanceRendererPatches { [HarmonyPatch(typeof(InstanceRenderer), "OnEnable")] internal static class InstanceRendererPatch { private static void Postfix(InstanceRenderer __instance) { VegetationSystem.TryRegister(__instance); } } } internal class SwampMovementPatches { [HarmonyPatch(typeof(Character), "ApplyLiquidResistance")] public static class ApplyLiquidResistance_Patch { private static void Prefix(ref float speed, ref float __state) { __state = speed; } private static void Postfix(Character __instance, ref float speed, float __state) { float num = speed; float num2 = SwampMovementSystem.ComputeSwampVariant(__instance, __state); speed = Mathf.Min(num, num2); if (Diagnostics.DebugSwampMovementEnabled) { Logger.LogInfo((object)$"SWAMP RUN: Original={__state}, Vanilla={num}, SwampPeat={num2}, Final={speed}"); } } } } internal class ZNetReadyPatches { [HarmonyPatch(typeof(ZNet), "Update")] internal static class ZNet_Update_Patch { private static void Postfix() { TidesManager.Update(); } } [HarmonyPatch(typeof(ZNet), "Start")] internal static class ZNet_Start_Patch { private static void Postfix() { TidesManager.SetWorldReady(ready: true); } } [HarmonyPatch(typeof(ZNet), "OnDestroy")] internal static class ZNet_Destroy_Patch { private static void Prefix() { TidesManager.SetWorldReady(ready: false); } } } } namespace Tides.Core { internal class Diagnostics { internal static bool DebugTidesEnabled; internal static bool DebugVegetationEnabled; internal static bool DebugSwampMovementEnabled; public static void MasterSwitchOff() { DebugTidesEnabled = false; DebugVegetationEnabled = false; DebugSwampMovementEnabled = false; } } internal class TidesConfig { internal static ConfigEntry<float> TideAmplitude; internal static ConfigEntry<float> BaseWaterLevel; internal static ConfigEntry<float> TideSpeedMultiplier; internal static ConfigEntry<string> TidePresetButtons; private static bool _isApplyingPreset; internal static void CreateConfigValues(ConfigFile config) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Expected O, but got Unknown //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Expected O, but got Unknown TidePresetButtons = config.Bind<string>("General", "Presets", "Default", new ConfigDescription(Localization.instance.Localize("$tides_config_preset_desc"), (AcceptableValueBase)null, new object[1] { GetAttrWithOrder(10, DrawPresetButtonsDrawer) })); TideAmplitude = config.Bind<float>("General", "Tide Amplitude", 1.4f, new ConfigDescription(Localization.instance.Localize("$tides_amplitude_desc"), (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 3f), new object[1] { GetAttrWithOrder(8) })); BaseWaterLevel = config.Bind<float>("General", "Base Ocean Level", 30f, new ConfigDescription(Localization.instance.Localize("$tides_waterlevel_desc"), (AcceptableValueBase)(object)new AcceptableValueRange<float>(26f, 34f), new object[1] { GetAttrWithOrder(6) })); TideSpeedMultiplier = config.Bind<float>("General", "Tide Speed Multiplier", 1f, new ConfigDescription(Localization.instance.Localize("$tides_speed_desc"), (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), new object[1] { GetAttrWithOrder(4) })); } internal static void RegisterChangeCallbacks() { TideAmplitude.SettingChanged += delegate { TideSystem.ApplyConfigModifications(); MarkPresetCustom(); }; BaseWaterLevel.SettingChanged += delegate { TideSystem.ApplyConfigModifications(); MarkPresetCustom(); }; TideSpeedMultiplier.SettingChanged += delegate { TideSystem.ApplyConfigModifications(); MarkPresetCustom(); }; TidePresetButtons.SettingChanged += delegate { if (TidePresetButtons.Value == "Default") { _isApplyingPreset = true; TideAmplitude.Value = 1.4f; BaseWaterLevel.Value = 30f; TideSpeedMultiplier.Value = 1f; _isApplyingPreset = false; } }; } private static void MarkPresetCustom() { if (!_isApplyingPreset) { TidePresetButtons.Value = "Custom"; } } internal static void SetupLocalizations() { if (Localization.instance.GetSelectedLanguage() == "Czech") { Localization.instance.AddWord("tides_preset_default", "Výchozí"); Localization.instance.AddWord("tides_preset_default_desc", "Doporučená nastavení. Vyvážená primárně pro hratelnost."); Localization.instance.AddWord("tides_preset_realistic", "Realistické"); Localization.instance.AddWord("tides_preset_realistic_desc", "Nejrealističtější nastavení, bez záplav, omezuje některé zajímavé herní prvky."); Localization.instance.AddWord("tides_preset_visuals", "Vizuály"); Localization.instance.AddWord("tides_preset_visuals_desc", "Upřednostňuje dramatické vizuální efekty (výrazně ovlivňuje hratelnost pro bažiny, řeky a přístavy)."); Localization.instance.AddWord("tides_config_preset_desc", "Kliknutím na předvolbu rychle nastavíte hodnoty přílivu."); Localization.instance.AddWord("tides_amplitude_desc", "Maximální Rozsah přílivu v metrech.\n1.4 = doporučená amplituda.\nUrčuje maximální výšku přílivu a minimální výšku odlivu od základní hladiny oceánu.\nPři hodnotě 0 nejsou žádné přílivy."); Localization.instance.AddWord("tides_waterlevel_desc", "Základní hladina oceánu v metrech.\n30.0 = normální hladina.\nVyšší hodnoty zvedají celkovou hladinu oceánu."); Localization.instance.AddWord("tides_speed_desc", "Násobí rychlost cyklu přílivu.\n1.0 = normální rychlost.\nVyšší hodnoty způsobují rychlejší změny přílivu.\nPři rychlosti 0.1x se příliv opakuje cca jednou za 5 dní.\nPři rychlosti 5x nastává příliv cca 10x za den."); } else { Localization.instance.AddWord("tides_preset_default", "Default"); Localization.instance.AddWord("tides_preset_default_desc", "Recommended settings. Balanced primarily for gameplay."); Localization.instance.AddWord("tides_preset_realistic", "Realistic"); Localization.instance.AddWord("tides_preset_realistic_desc", "The most realistic settings, without floods, limiting some interesting gameplay aspects."); Localization.instance.AddWord("tides_preset_visuals", "Visuals"); Localization.instance.AddWord("tides_preset_visuals_desc", "Prioritizing dramatic visual effects (heavily affects gameplay in swamps, rivers and docks)."); Localization.instance.AddWord("tides_config_preset_desc", "Click a preset button to quickly configure tide settings."); Localization.instance.AddWord("tides_amplitude_desc", "Maximum tide amplitude in meters.\n1.4 = recommended amplitude.\nDecides maximum height of high tide and minimal height of low tide from the base ocean level.\nAt value 0 there are no tides."); Localization.instance.AddWord("tides_waterlevel_desc", "Base ocean level in meters.\n30.0 = normal level.\nHigher values raise the whole ocean level."); Localization.instance.AddWord("tides_speed_desc", "Multiplies the speed of the tide cycle.\n1.0 = normal speed.\nHigher values make tides change faster.\nAt 0.1x speed high tide repeats cca once every 5 days.\nAt 5x speed high tide happens cca 10x per day."); } } private static ConfigurationManagerAttributes GetAttrWithOrder(int order, Action<ConfigEntryBase> drawer = null) { //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) //IL_000c: 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_0020: Expected O, but got Unknown return new ConfigurationManagerAttributes { IsAdminOnly = true, Order = order, CustomDrawer = drawer }; } private static void DrawPresetButtonsDrawer(ConfigEntryBase entry) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Expected O, but got Unknown GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button(new GUIContent(Localization.instance.Localize("$tides_preset_default"), Localization.instance.Localize("$tides_preset_default_desc")), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(25f) })) { TidePresetButtons.Value = "Default"; TideAmplitude.Value = 1.4f; BaseWaterLevel.Value = 30f; TideSpeedMultiplier.Value = 1f; } if (GUILayout.Button(new GUIContent(Localization.instance.Localize("$tides_preset_realistic"), Localization.instance.Localize("$tides_preset_realistic_desc")), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(25f) })) { TidePresetButtons.Value = "Realistic"; TideAmplitude.Value = 0.75f; BaseWaterLevel.Value = 29.3f; TideSpeedMultiplier.Value = 1f; } if (GUILayout.Button(new GUIContent(Localization.instance.Localize("$tides_preset_visuals"), Localization.instance.Localize("$tides_preset_visuals_desc")), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(25f) })) { TidePresetButtons.Value = "Visuals"; TideAmplitude.Value = 2.1f; BaseWaterLevel.Value = 28.1f; TideSpeedMultiplier.Value = 1f; } GUILayout.EndHorizontal(); } } internal class TidesManager { private static bool _worldReady; public static void SetWorldReady(bool ready) { _worldReady = ready; } public static void Update() { if (_worldReady) { TideSystem.UpdateTides(); VegetationSystem.Update(TideSystem._lastTideOffset); if (Diagnostics.DebugTidesEnabled) { Logger.LogInfo((object)$"_lastTideOffset={TideSystem._lastTideOffset}"); } } } } } namespace Tides.Compatibility { public static class SeasonalityCompat { public const string GUID = "RustyMods.Seasonality"; public static bool IsEnabled { get; private set; } public static bool IsWaterFrozen { get; private set; } public static void CheckForCompatibility() { IsEnabled = Chainloader.PluginInfos.TryGetValue("RustyMods.Seasonality", out var _); } public static void Initialize(Harmony harmony) { CheckForCompatibility(); if (!IsEnabled) { return; } try { if (Chainloader.PluginInfos.TryGetValue("RustyMods.Seasonality", out var value)) { Assembly assembly = ((object)value.Instance).GetType().Assembly; Type type = assembly.GetType("Seasonality.FrozenZones"); Type type2 = assembly.GetType("Seasonality.FrozenWaterLOD"); PatchMethod(harmony, type, "FreezeWater", "Prefix_FreezeWater"); PatchMethod(harmony, type, "ThawWater", "Prefix_ThawWater"); PatchMethod(harmony, type2, "Freeze", "Prefix_LOD_Freeze"); PatchMethod(harmony, type2, "Thaw", "Prefix_LOD_Thaw"); PatchMethod(harmony, type2, "SetInitialValues", "Prefix_LOD_SetInitial"); Logger.LogInfo((object)"[Tides] Successfully bound Seasonality compatibility hooks."); } } catch (Exception ex) { Debug.LogWarning((object)("[Tides] Failed to initialize Seasonality compatibility patches: " + ex.Message)); } } private static void PatchMethod(Harmony harmony, Type targetType, string methodName, string patchMethodName) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown if (!(targetType == null)) { MethodInfo method = targetType.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); MethodInfo method2 = typeof(SeasonalityCompat).GetMethod(patchMethodName, BindingFlags.Static | BindingFlags.NonPublic); if (method != null && method2 != null) { harmony.Patch((MethodBase)method, new HarmonyMethod(method2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } } private static void ForceWaterFlatToBaseline(object frozenZonesInstance) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //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_0091: Unknown result type (might be due to invalid IL or missing references) IsWaterFrozen = true; try { object? obj = frozenZonesInstance.GetType().GetField("m_waterVolume", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(frozenZonesInstance); WaterVolume val = (WaterVolume)((obj is WaterVolume) ? obj : null); if (val != null && (Object)(object)val != (Object)null) { Vector3 position = ((Component)val).transform.position; position.y = 30f; ((Component)val).transform.position = position; if ((Object)(object)val.m_waterSurface != (Object)null) { Vector3 position2 = ((Component)val.m_waterSurface).transform.position; position2.y = 30f; ((Component)val.m_waterSurface).transform.position = position2; } } } catch (Exception ex) { Debug.LogWarning((object)("[Tides] Failed to flatten water for Seasonality: " + ex.Message)); } } private static void ForceLODToBaseline(object lodInstance) { //IL_0029: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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) IsWaterFrozen = true; try { FieldInfo field = lodInstance.GetType().GetField("m_originalPos", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { Vector3 val = (Vector3)field.GetValue(lodInstance); val.y = 30f; field.SetValue(lodInstance, val); } MonoBehaviour val2 = (MonoBehaviour)((lodInstance is MonoBehaviour) ? lodInstance : null); if (val2 != null && (Object)(object)val2 != (Object)null) { Vector3 position = ((Component)val2).transform.position; position.y = 29.8f; ((Component)val2).transform.position = position; } } catch (Exception ex) { Debug.LogWarning((object)("[Tides] Failed to baseline Seasonality LOD: " + ex.Message)); } } private static void Prefix_FreezeWater(object __instance) { ForceWaterFlatToBaseline(__instance); } private static void Prefix_ThawWater() { IsWaterFrozen = false; } private static void Prefix_LOD_Freeze(object __instance) { ForceLODToBaseline(__instance); } private static void Prefix_LOD_Thaw() { IsWaterFrozen = false; } private static void Prefix_LOD_SetInitial(object __instance) { if (!Chainloader.PluginInfos.TryGetValue("RustyMods.Seasonality", out var value)) { return; } try { Type type = ((object)value.Instance).GetType().Assembly.GetType("Seasonality.Configs"); if (type != null) { object? obj = type.GetField("m_season", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null); object obj2 = type.GetField("m_waterFreezes", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null); if (obj?.ToString() == "Winter" && obj2?.ToString() != "Off") { ForceLODToBaseline(__instance); } } } catch { } } } public static class SeasonsCompat { public const string GUID = "shudnal.Seasons"; private static Type s_mainSeasonsType; private static Type s_seasonStateType; private static FieldInfo s_stateField; private static PropertyInfo s_stateProp; private static MethodInfo s_getFreezeStatusMethod; private static object s_seasonStateInstance; private static bool s_isInitialized; public static bool IsEnabled { get; private set; } public static void CheckForCompatibility() { IsEnabled = Chainloader.PluginInfos.TryGetValue("shudnal.Seasons", out var value); if (IsEnabled) { CacheTypes(value); } } private static void CacheTypes(PluginInfo info) { if (s_isInitialized) { return; } s_isInitialized = true; try { Assembly assembly = ((object)info.Instance).GetType().Assembly; s_mainSeasonsType = assembly.GetType("Seasons.Seasons"); if (s_mainSeasonsType != null) { s_stateField = s_mainSeasonsType.GetField("seasonState", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); s_stateProp = s_mainSeasonsType.GetProperty("seasonState", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); } s_seasonStateType = assembly.GetType("Seasons.SeasonState") ?? assembly.GetType("Seasons.seasonstate"); if (s_seasonStateType != null) { s_getFreezeStatusMethod = s_seasonStateType.GetMethod("GetWaterSurfaceFreezeStatus", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } } catch (Exception ex) { Debug.LogWarning((object)("[Tides] Failed to cache shudnal.Seasons reflection types: " + ex.Message)); } } public static float GetWaterFreezeStatus() { if (!IsEnabled) { return 0f; } try { if (s_seasonStateInstance == null) { if (s_stateField != null) { s_seasonStateInstance = s_stateField.GetValue(null); } else if (s_stateProp != null) { s_seasonStateInstance = s_stateProp.GetValue(null, null); } } if (s_seasonStateInstance != null && s_getFreezeStatusMethod != null) { return Mathf.Clamp01((float)s_getFreezeStatusMethod.Invoke(s_seasonStateInstance, null)); } } catch (Exception ex) { Debug.LogWarning((object)("[Tides] Failed to read shudnal.Seasons freeze status: " + ex.Message)); } return 0f; } } } namespace Tides.Commands { public class TidesDebugCattailCommand : ConsoleCommand { public override string Name => "tides_debug_cattail"; public override string Help => "Test Move Vegetation"; public override void Run(string[] args) { Console.instance.Print("tides_debug_cattail command response."); VegetationSystem.TestMoveVegetation("vass"); } public override List<string> CommandOptionList() { return new List<string>(); } } public class TidesDebugLilyCommand : ConsoleCommand { public override string Name => "tides_debug_lily"; public override string Help => "tides debug lily"; public override void Run(string[] args) { Console.instance.Print("tides_debug_lily command response."); VegetationSystem.TestMoveVegetation("clutter_waterlilies"); } public override List<string> CommandOptionList() { return new List<string>(); } } public class TidesDiagCommand : ConsoleCommand { public override string Name => "tides_diag"; public override string Help => "Diag chosen systems tides/swampmovement/vegetation"; public override void Run(string[] args) { switch (args[0].ToLowerInvariant()) { case "off": case "false": case "0": Diagnostics.MasterSwitchOff(); Console.instance.Print("Logging disabled. All diagnostics OFF."); break; case "tides": case "t": Diagnostics.DebugTidesEnabled = true; Console.instance.Print("Logging enabled. Tides diagnostics ON."); break; case "swampmovement": case "swamp": case "s": Diagnostics.DebugSwampMovementEnabled = true; Console.instance.Print("Logging enabled. Swamp movement diagnostics ON."); break; case "vegetation": case "vege": case "v": Diagnostics.DebugVegetationEnabled = true; Console.instance.Print("Logging enabled. Vegetation diagnostics ON."); break; } } public override List<string> CommandOptionList() { return new List<string> { "off", "tides", "vegetation", "swampmovement" }; } } public class TidesInfoCommand : ConsoleCommand { public override string Name => "tides"; public override string Help => "Tides Info"; public override void Run(string[] args) { Console.instance.Print($"[Tides Info] current tides offset = {TideSystem._lastTideOffset:F2}m, base ocean level={TideSystem.OceanBaseY}m, max tide amplitude={TideSystem.TideAmplitude}m"); if (Diagnostics.DebugTidesEnabled) { Logger.LogWarning((object)$"[Config Values] base ocean level={TidesConfig.BaseWaterLevel.Value}m, amp={TidesConfig.TideAmplitude.Value}m"); Logger.LogWarning((object)$"[Time] current day={EnvMan.instance.GetCurrentDay()}, m_totalSeconds={EnvMan.instance.m_totalSeconds}, m_dayLengthSec={EnvMan.instance.m_dayLengthSec}, m_smoothDayFraction={EnvMan.instance.m_smoothDayFraction}"); } } public override List<string> CommandOptionList() { return new List<string>(); } } }