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 ArcaneNaturalWaters v0.9.16
plugins/ArcaneNaturalWaters/ArcaneNaturalWaters.dll
Decompiled a day 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.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using ArcaneWaterWorks.Input; using ArcaneWaterWorks.Pools; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.Networking; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: InternalsVisibleTo("ArcaneWaterWorks.Tests")] [assembly: InternalsVisibleTo("ArcaneWaterWorks.Smoke")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ArcaneNaturalWaters")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.9.16.0")] [assembly: AssemblyInformationalVersion("0.9.16")] [assembly: AssemblyProduct("ArcaneNaturalWaters")] [assembly: AssemblyTitle("ArcaneNaturalWaters")] [assembly: AssemblyVersion("0.9.16.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [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 ArcaneWaterWorks { internal static class GardenBridge { internal static void Register() { RiverGardens.SampleWater = Water; RiverGardens.Section = Section; RiverGardens.PondRegionChanged += PondsChanged; RiverGardens.NotifyChanged(); } internal static void Unregister() { RiverGardens.PondRegionChanged -= PondsChanged; RiverGardens.SampleWater = null; RiverGardens.Section = null; RiverGardens.NotifyChanged(); } private static Spring Nearest(Vector3 world, out float level, out float margin) { //IL_0040: 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_0053: 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) //IL_0098: Unknown result type (might be due to invalid IL or missing references) Spring result = null; level = 0f; margin = 0f; foreach (Spring item in Spring.Active) { if (Object.op_Implicit((Object)(object)item) && item.Live && item.Route != null) { Vector3 val = world - ((Component)item).transform.position; item.Surface(val.x, val.z, out var distance, out var level2, out var _); float num = item.Route.Width * 0.5f + 1.5f - distance; if (!(num <= margin)) { result = item; level = level2 + ((Component)item).transform.position.y; margin = num; } } } return result; } internal static float JoinRiver(Vector3 world, float river) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (!RiverGardens.PondConnection(world, out var edge, out var height)) { return river; } return PondRiverJoin.Height(river, height, edge); } internal static float SurfaceHeight(Vector3 world, float fallback) { //IL_0000: 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) float num = RiverGardens.RawPondLevel(world); if (!float.IsNegativeInfinity(num)) { return num; } if (!Object.op_Implicit((Object)(object)Nearest(world, out var level, out var _))) { return fallback; } return level; } internal static Vector3 SurfaceNormal(Vector3 world) { //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_0020: 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) //IL_002b: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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_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_0056: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: 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) float num = SurfaceHeight(world + Vector3.left * 0.05f, world.y); float num2 = SurfaceHeight(world + Vector3.right * 0.05f, world.y); float num3 = SurfaceHeight(world + Vector3.back * 0.05f, world.y); float num4 = SurfaceHeight(world + Vector3.forward * 0.05f, world.y); Vector3 val = new Vector3((num - num2) * 10f, 1f, (num3 - num4) * 10f); return ((Vector3)(ref val)).normalized; } private static void PondsChanged(Bounds region) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) RiverRebuildQueue.Region(region); foreach (Spring item in Spring.Active) { if (Object.op_Implicit((Object)(object)item) && item.Live && item.Route != null && ((Bounds)(ref region)).Intersects(RiverTerrain.Bounds(item, item.Route))) { RiverTerrain.Refresh(item, item.Route); } } } internal static float Water(Vector3 world) { //IL_0033: 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_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_0046: 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_0061: 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) float num = float.NegativeInfinity; foreach (Spring item in Spring.Active) { if (Object.op_Implicit((Object)(object)item) && item.Live && item.Route != null) { Vector3 val = world - ((Component)item).transform.position; if (item.Surface(val.x, val.z, out var _, out var level, out var _)) { num = Mathf.Max(num, RiverSurface.Level(item, world, level + ((Component)item).transform.position.y)); } } } return num; } internal static List<RiverGardens.Span> Section(Vector3 stone) { //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: 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_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: 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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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) //IL_00b4: 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_00c2: 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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_03f2: Unknown result type (might be due to invalid IL or missing references) //IL_0401: Unknown result type (might be due to invalid IL or missing references) //IL_0406: Unknown result type (might be due to invalid IL or missing references) //IL_0408: Unknown result type (might be due to invalid IL or missing references) //IL_040a: Unknown result type (might be due to invalid IL or missing references) //IL_04c3: Unknown result type (might be due to invalid IL or missing references) //IL_04c5: Unknown result type (might be due to invalid IL or missing references) //IL_04c9: Unknown result type (might be due to invalid IL or missing references) //IL_04ce: Unknown result type (might be due to invalid IL or missing references) //IL_04d0: Unknown result type (might be due to invalid IL or missing references) //IL_04d4: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Unknown result type (might be due to invalid IL or missing references) List<Vector3> points = new List<Vector3>(); List<(int, int, float)> list = new List<(int, int, float)>(); Dictionary<(int, int, int), int> lookup = new Dictionary<(int, int, int), int>(); foreach (Spring item in Spring.Active) { if (!Object.op_Implicit((Object)(object)item) || !item.Live || item.Route == null) { continue; } Route route = item.Route; for (int i = 1; i < route.Points.Count; i++) { Vector3 val = ((Component)item).transform.position + V(route.Points[route.Parent(i)]); Vector3 val2 = ((Component)item).transform.position + V(route.Points[i]); Vector3 val3 = new RiverGardens.Span(val, val2, route.Width).Closest(stone) - stone; val3.y = 0f; if (!(((Vector3)(ref val3)).sqrMagnitude > 1024f)) { list.Add((Vertex(val), Vertex(val2), route.Width)); } } } List<RiverGardens.Span> list2 = new List<RiverGardens.Span>(); int num = -1; float num2 = float.PositiveInfinity; float num3 = 0f; for (int j = 0; j < list.Count; j++) { (int, int, float) tuple = list[j]; Vector3 a = points[tuple.Item1]; Vector3 b = points[tuple.Item2]; Vector3 val4 = new RiverGardens.Span(a, b, tuple.Item3).Closest(stone); Vector3 val5 = stone - val4; val5.y = 0f; if (((Vector3)(ref val5)).sqrMagnitude < num2 && ((Vector3)(ref val5)).magnitude <= tuple.Item3 * 0.5f + 4f) { num2 = ((Vector3)(ref val5)).sqrMagnitude; num = j; num3 = Horizontal(a, val4) / Mathf.Max(0.001f, Horizontal(a, b)); } } if (num < 0) { return list2; } float[] array = new float[points.Count]; bool[] array2 = new bool[points.Count]; for (int k = 0; k < array.Length; k++) { array[k] = float.PositiveInfinity; } (int, int, float) tuple2 = list[num]; float num4 = Horizontal(points[tuple2.Item1], points[tuple2.Item2]); array[tuple2.Item1] = num4 * num3; array[tuple2.Item2] = num4 * (1f - num3); for (int l = 0; l < points.Count; l++) { int num5 = -1; float num6 = 10.001f; for (int m = 0; m < array.Length; m++) { if (!array2[m] && array[m] < num6) { num6 = array[m]; num5 = m; } } if (num5 < 0) { break; } array2[num5] = true; foreach (var item2 in list) { int num7; if (item2.Item1 != num5) { if (item2.Item2 == num5) { (num7, _, _) = item2; } else { num7 = -1; } } else { num7 = item2.Item2; } int num8 = num7; if (num8 >= 0) { array[num8] = Mathf.Min(array[num8], num6 + Horizontal(points[num5], points[num8])); } } } for (int n = 0; n < list.Count; n++) { (int, int, float) tuple4 = list[n]; Vector3 val6 = points[tuple4.Item1]; Vector3 val7 = points[tuple4.Item2]; float num9 = Horizontal(val6, val7); float num10 = 0f; float num11 = 1f; if (n == num) { num10 = Mathf.Clamp01(num3 - 10f / num9); num11 = Mathf.Clamp01(num3 + 10f / num9); } else { bool flag = array[tuple4.Item1] < 10f; bool flag2 = array[tuple4.Item2] < 10f; if (!flag && !flag2) { continue; } if (!flag) { num10 = Mathf.Clamp01(1f - (10f - array[tuple4.Item2]) / num9); } if (!flag2) { num11 = Mathf.Clamp01((10f - array[tuple4.Item1]) / num9); } } if (num11 > num10) { list2.Add(new RiverGardens.Span(Vector3.Lerp(val6, val7, num10), Vector3.Lerp(val6, val7, num11), tuple4.Item3)); } } return list2; int Vertex(Vector3 p) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) (int, int, int) key = (Mathf.RoundToInt(p.x * 20f), Mathf.RoundToInt(p.y * 20f), Mathf.RoundToInt(p.z * 20f)); if (lookup.TryGetValue(key, out var value)) { return value; } lookup[key] = points.Count; points.Add(p); return points.Count - 1; } } private static float Horizontal(Vector3 a, Vector3 b) { //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) a.y = (b.y = 0f); return Vector3.Distance(a, b); } internal static Vector3 V(Node p) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) return new Vector3(p.X, p.Y, p.Z); } } [HarmonyPatch(typeof(Player), "PieceRayTest")] internal static class RiverPlacementRay { private static void Postfix(GameObject ___m_placementGhost, Transform ___m_eye, float ___m_maxPlaceDistance, int ___m_placeRayMask, ref bool __result, ref Vector3 point, ref Vector3 normal, ref Piece piece, ref Heightmap heightmap, ref Collider waterSurface) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_0664: Unknown result type (might be due to invalid IL or missing references) //IL_0666: Unknown result type (might be due to invalid IL or missing references) //IL_066d: Unknown result type (might be due to invalid IL or missing references) //IL_0672: Unknown result type (might be due to invalid IL or missing references) //IL_067f: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_028a: 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_0291: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_0330: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_0361: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_03a1: Unknown result type (might be due to invalid IL or missing references) //IL_03a6: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Unknown result type (might be due to invalid IL or missing references) //IL_03d2: Unknown result type (might be due to invalid IL or missing references) //IL_03e0: Unknown result type (might be due to invalid IL or missing references) //IL_03f7: Unknown result type (might be due to invalid IL or missing references) //IL_0404: 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_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_0421: Unknown result type (might be due to invalid IL or missing references) //IL_0425: Unknown result type (might be due to invalid IL or missing references) //IL_042f: Unknown result type (might be due to invalid IL or missing references) //IL_0434: Unknown result type (might be due to invalid IL or missing references) //IL_0439: Unknown result type (might be due to invalid IL or missing references) //IL_043d: Unknown result type (might be due to invalid IL or missing references) //IL_0444: Unknown result type (might be due to invalid IL or missing references) //IL_0457: Unknown result type (might be due to invalid IL or missing references) //IL_0460: Unknown result type (might be due to invalid IL or missing references) //IL_0465: Unknown result type (might be due to invalid IL or missing references) //IL_0473: Unknown result type (might be due to invalid IL or missing references) //IL_048a: Unknown result type (might be due to invalid IL or missing references) //IL_0499: Unknown result type (might be due to invalid IL or missing references) //IL_0521: Unknown result type (might be due to invalid IL or missing references) //IL_0526: Unknown result type (might be due to invalid IL or missing references) //IL_0528: Unknown result type (might be due to invalid IL or missing references) //IL_052f: Unknown result type (might be due to invalid IL or missing references) //IL_0537: Unknown result type (might be due to invalid IL or missing references) //IL_053f: Unknown result type (might be due to invalid IL or missing references) //IL_0546: 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_0574: Unknown result type (might be due to invalid IL or missing references) //IL_057d: Unknown result type (might be due to invalid IL or missing references) //IL_0582: Unknown result type (might be due to invalid IL or missing references) //IL_0587: Unknown result type (might be due to invalid IL or missing references) //IL_058b: Unknown result type (might be due to invalid IL or missing references) //IL_0592: Unknown result type (might be due to invalid IL or missing references) //IL_05a6: Unknown result type (might be due to invalid IL or missing references) //IL_05ad: Unknown result type (might be due to invalid IL or missing references) //IL_05b6: Unknown result type (might be due to invalid IL or missing references) //IL_05d5: Unknown result type (might be due to invalid IL or missing references) //IL_05f2: Unknown result type (might be due to invalid IL or missing references) //IL_05f7: Unknown result type (might be due to invalid IL or missing references) //IL_05e2: Unknown result type (might be due to invalid IL or missing references) //IL_0611: Unknown result type (might be due to invalid IL or missing references) //IL_0613: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)___m_placementGhost) || !Object.op_Implicit((Object)(object)GameCamera.instance)) { return; } Piece component = ___m_placementGhost.GetComponent<Piece>(); if (!Object.op_Implicit((Object)(object)component) || !component.m_waterPiece) { return; } Transform transform = ((Component)GameCamera.instance).transform; Ray val = default(Ray); ((Ray)(ref val))..ctor(transform.position, transform.forward); float num = (__result ? Vector3.Distance(((Ray)(ref val)).origin, point) : 50f); Vector3 val2 = default(Vector3); Collider val3 = null; RaycastHit val4 = default(RaycastHit); if (Physics.Raycast(val, ref val4, num, ___m_placeRayMask, (QueryTriggerInteraction)1)) { num = ((RaycastHit)(ref val4)).distance; } foreach (KeyValuePair<WaterVolume, RiverLiquid> item in RiverLiquid.Registry) { RiverLiquid value = item.Value; if (!Object.op_Implicit((Object)(object)value)) { continue; } if (Object.op_Implicit((Object)(object)value.Pond)) { if (Mathf.Abs(((Ray)(ref val)).direction.y) < 1E-05f) { continue; } float num2 = (GardenIntegration.WaterHeight(value.Pond) - ((Ray)(ref val)).origin.y) / ((Ray)(ref val)).direction.y; if (num2 < 0f || num2 >= num) { continue; } Vector3 point2 = ((Ray)(ref val)).GetPoint(num2); for (int i = 0; i < 4; i++) { float num3 = GardenIntegration.WaterLevel(point2); if (float.IsNegativeInfinity(num3)) { break; } num2 = (num3 - ((Ray)(ref val)).origin.y) / ((Ray)(ref val)).direction.y; point2 = ((Ray)(ref val)).GetPoint(num2); } if (!(num2 < 0f) && !(num2 >= num) && !(GardenIntegration.Distance(value.Pond, point2) > 1f) && !(Vector3.Distance(___m_eye.position, point2) >= ___m_maxPlaceDistance + (float)___m_placementGhost.GetComponent<Piece>().m_extraPlacementDistance) && (!RiverTerrain.SampleCurrent(point2, out var height) || !(height >= point2.y - 0.015f))) { num = num2; val2 = point2; val3 = ((Component)item.Key).GetComponent<Collider>(); } } else { if (!Object.op_Implicit((Object)(object)value.Spring) || value.Spring.Route == null) { continue; } Spring spring = value.Spring; Route route = spring.Route; for (int j = 1; j < route.Points.Count; j++) { Vector3 val5 = ((Component)spring).transform.position + GardenBridge.V(route.Points[route.Parent(j)]); Vector3 val6 = ((Component)spring).transform.position + GardenBridge.V(route.Points[j]) - val5; float num4 = val6.x * val6.x + val6.z * val6.z; if (num4 < 0.001f) { continue; } float num5 = val6.y * val6.x / num4; float num6 = val6.y * val6.z / num4; float num7 = ((Ray)(ref val)).direction.y - num5 * ((Ray)(ref val)).direction.x - num6 * ((Ray)(ref val)).direction.z; if (Mathf.Abs(num7) < 1E-05f) { continue; } float num8 = (val5.y - ((Ray)(ref val)).origin.y + num5 * (((Ray)(ref val)).origin.x - val5.x) + num6 * (((Ray)(ref val)).origin.z - val5.z)) / num7; if (num8 < 0f || num8 >= num) { continue; } float distance; float progress; for (int k = 0; k < 8; k++) { Vector3 val7 = ((Ray)(ref val)).GetPoint(num8) - ((Component)spring).transform.position; spring.Surface(val7.x, val7.z, out distance, out var level, out progress); level = OceanJoin.Level(val7 + ((Component)spring).transform.position, level + ((Component)spring).transform.position.y) - ((Component)spring).transform.position.y; float num9 = val7.y - level; if (Mathf.Abs(num9) < 0.005f) { break; } Vector3 val8 = val7 + ((Ray)(ref val)).direction * 0.02f; spring.Surface(val8.x, val8.z, out progress, out var level2, out distance); level2 = OceanJoin.Level(val8 + ((Component)spring).transform.position, level2 + ((Component)spring).transform.position.y) - ((Component)spring).transform.position.y; float num10 = ((Ray)(ref val)).direction.y - (level2 - level) / 0.02f; if (float.IsNaN(num10) || Mathf.Abs(num10) < 0.0001f) { break; } num8 -= Mathf.Clamp(num9 / num10, -2f, 2f); if (num8 < 0f || num8 >= num) { break; } } if (float.IsNaN(num8) || num8 < 0f || num8 >= num) { continue; } Vector3 point3 = ((Ray)(ref val)).GetPoint(num8); float num11 = ((point3.x - val5.x) * val6.x + (point3.z - val5.z) * val6.z) / num4; if (!(num11 < 0f) && !(num11 > 1f)) { Vector3 val9 = point3 - ((Component)spring).transform.position; if (spring.Surface(val9.x, val9.z, out distance, out var level3, out progress) && !(Mathf.Abs(point3.y - OceanJoin.Level(point3, ((Component)spring).transform.position.y + level3)) > 0.1f) && (!RiverTerrain.SampleCurrent(point3, out var height2) || !(height2 >= point3.y - 0.015f)) && !(Vector3.Distance(___m_eye.position, point3) >= ___m_maxPlaceDistance + (float)___m_placementGhost.GetComponent<Piece>().m_extraPlacementDistance)) { num = num8; val2 = point3; val3 = ((Component)item.Key).GetComponent<Collider>(); } } } } } if (Object.op_Implicit((Object)(object)val3)) { point = val2; normal = Vector3.up; piece = null; heightmap = Heightmap.FindHeightmap(point); waterSurface = val3; __result = true; } } } internal static class HoeIcons { private const int Size = 128; internal static Sprite Create(string mode, Sprite terrain) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 //IL_00a0: 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_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Expected O, but got Unknown //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_03d0: Unknown result type (might be due to invalid IL or missing references) //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_03e6: Unknown result type (might be due to invalid IL or missing references) //IL_03eb: Unknown result type (might be due to invalid IL or missing references) //IL_0430: Unknown result type (might be due to invalid IL or missing references) //IL_0437: Unknown result type (might be due to invalid IL or missing references) //IL_048e: Unknown result type (might be due to invalid IL or missing references) //IL_049d: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_0347: Unknown result type (might be due to invalid IL or missing references) //IL_0365: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Unknown result type (might be due to invalid IL or missing references) //IL_0381: Unknown result type (might be due to invalid IL or missing references) //IL_0386: Unknown result type (might be due to invalid IL or missing references) //IL_039b: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_03a6: Unknown result type (might be due to invalid IL or missing references) //IL_03a8: Unknown result type (might be due to invalid IL or missing references) if ((int)SystemInfo.graphicsDeviceType == 4) { return terrain; } object obj; switch (mode) { default: obj = null; break; case "smooth": case "unsmooth": case "shallow": obj = "Hoe"; break; case "trench": case "deepen": obj = "PickaxeBronze"; break; } string text = (string)obj; GameObject val = ((text == null) ? null : PrefabManager.Instance.GetPrefab(text)); ItemDrop val2 = (Object.op_Implicit((Object)(object)val) ? val.GetComponent<ItemDrop>() : null); Sprite val3 = (Object.op_Implicit((Object)(object)val2) ? val2.m_itemData.m_shared.m_icons[0] : terrain); Rect textureRect = val3.textureRect; RenderTexture active = RenderTexture.active; RenderTexture temporary = RenderTexture.GetTemporary(128, 128, 0, (RenderTextureFormat)0); Graphics.Blit((Texture)(object)val3.texture, temporary, new Vector2(((Rect)(ref textureRect)).width / (float)((Texture)val3.texture).width, ((Rect)(ref textureRect)).height / (float)((Texture)val3.texture).height), new Vector2(((Rect)(ref textureRect)).x / (float)((Texture)val3.texture).width, ((Rect)(ref textureRect)).y / (float)((Texture)val3.texture).height)); RenderTexture.active = temporary; Texture2D val4 = new Texture2D(128, 128, (TextureFormat)4, false) { name = "native hoe " + mode, filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1 }; val4.ReadPixels(new Rect(0f, 0f, 128f, 128f), 0, 0); RenderTexture.active = active; RenderTexture.ReleaseTemporary(temporary); Color[] pixels = val4.GetPixels(); List<(Vector2 a, Vector2 b)> strokes = new List<(Vector2, Vector2)>(); switch (mode) { case "start": Stroke(new Vector2(64f, 27f), new Vector2(64f, 94f)); Stroke(new Vector2(64f, 94f), new Vector2(91f, 84f)); Stroke(new Vector2(91f, 84f), new Vector2(64f, 74f)); break; case "trench": Arrow(new Vector2(72f, 24f), new Vector2(111f, 24f)); break; case "deepen": Arrow(new Vector2(105f, 67f), new Vector2(105f, 17f)); break; case "shallow": Arrow(new Vector2(105f, 17f), new Vector2(105f, 67f)); break; case "undo": case "unsmooth": { Vector2 val5 = default(Vector2); ((Vector2)(ref val5))..ctor((float)((mode == "undo") ? 67 : 96), (float)((mode == "undo") ? 67 : 37)); float num = ((mode == "undo") ? 30 : 21); Vector2 a = val5 + Vector2.right * num; for (int i = 1; i <= 20; i++) { float num2 = (float)i / 20f * MathF.PI * 1.35f; Vector2 val6 = val5 + new Vector2(Mathf.Cos(num2), Mathf.Sin(num2)) * num; if (i == 20) { Arrow(a, val6); } else { Stroke(a, val6); } a = val6; } break; } } foreach (var item in strokes) { Line(item.a + Vector2.down, item.b + Vector2.down, 4f, shadow: true); } foreach (var item2 in strokes) { Line(item2.a, item2.b, 2f, shadow: false); } val4.SetPixels(pixels); val4.Apply(false, false); Sprite obj2 = Sprite.Create(val4, new Rect(0f, 0f, 128f, 128f), new Vector2(0.5f, 0.5f)); ((Object)obj2).name = "hoe-" + mode; return obj2; void Arrow(Vector2 val7, Vector2 b) { //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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_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) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_0054: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_006c: 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) Stroke(val7, b); Vector2 val8 = b - val7; Vector2 normalized = ((Vector2)(ref val8)).normalized; Vector2 val9 = default(Vector2); ((Vector2)(ref val9))..ctor(0f - normalized.y, normalized.x); Stroke(b, b - normalized * 12f + val9 * 10f); Stroke(b, b - normalized * 12f - val9 * 10f); } void Line(Vector2 val8, Vector2 b, float width, bool shadow) { //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_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_0045: 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_0049: 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_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: 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_0174: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) Vector2 val7 = b - val8; Vector2 val9 = default(Vector2); for (int j = 0; j < 128; j++) { for (int k = 0; k < 128; k++) { ((Vector2)(ref val9))..ctor((float)k, (float)j); float num3 = Mathf.Clamp01(Vector2.Dot(val9 - val8, val7) / ((Vector2)(ref val7)).sqrMagnitude); float num4 = Mathf.Clamp01(width + 0.5f - Vector2.Distance(val9, val8 + val7 * num3)); if (!(num4 <= 0f)) { float num5 = 0.92f + 0.08f * Mathf.Sin((float)k * 1.7f + (float)j * 2.1f); Color val10 = (shadow ? new Color(0.1f, 0.065f, 0.025f, 0.9f) : new Color(0.73f * num5, 0.59f * num5, 0.3f * num5, 1f)); num4 *= val10.a; int num6 = j * 128 + k; Color val11 = pixels[num6]; float num7 = num4 + val11.a * (1f - num4); pixels[num6] = new Color((val10.r * num4 + val11.r * val11.a * (1f - num4)) / num7, (val10.g * num4 + val11.g * val11.a * (1f - num4)) / num7, (val10.b * num4 + val11.b * val11.a * (1f - num4)) / num7, num7); } } } } void Stroke(Vector2 item, Vector2 b) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) strokes.Add((item, b)); } } } internal sealed class HotSpring : MonoBehaviour, IGardenController { internal static readonly List<HotSpring> All = new List<HotSpring>(); internal GardenPiece Pond; internal HotSpringSettings Settings = new HotSpringSettings(); internal GardenSettings Garden; internal ZNetView View; internal Chair[] Seats = Array.Empty<Chair>(); private GameObject generated; private GameObject ward; private ParticleSystem steam; private ParticleSystem bubbles; private Vector3[] emitPoints = Array.Empty<Vector3>(); private float check; private float nextParticles; private float steamCredit; private float bubbleCredit; private float builtWidth = -1f; private float builtDepth = -1f; private bool registered; private static Material softSteam; internal bool Live { get { if (Object.op_Implicit((Object)(object)View)) { return View.IsValid(); } return false; } } internal float Water => GardenIntegration.WaterHeight(Pond); internal float WardRadius => Garden.Width * 0.5f + 4f; public string PoolName => "Arcane Hot Spring — " + HotSpringPrefabs.Shapes[Mathf.Clamp(Object.op_Implicit((Object)(object)Pond) ? Pond.Shape : ((Component)this).GetComponent<GardenPiece>().Shape, 0, 3)]; public void ConfigureDefaults(GardenSettings settings) { settings.Track = 0; settings.Width = 6f; settings.Depth = 1.4f; settings.Fireflies = 25; } public bool OpenMenu() { HotSpringEditor.Show(this); return true; } public void BuildLiquid(Transform surface, MeshRenderer renderer) { //IL_0041: 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_0056: 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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)Pond)) { Pond = ((Component)this).GetComponent<GardenPiece>(); } GardenSettings gardenSettings = GardenIntegration.Settings(Pond); HotSpringShoreline.Extend(Pond, ((Component)renderer).GetComponent<MeshFilter>().sharedMesh, surface); GameObject val = new GameObject("hot_spring_water_volume") { layer = LayerMask.NameToLayer("WaterVolume") }; val.SetActive(false); val.transform.SetParent(surface, false); BoxCollider val2 = val.AddComponent<BoxCollider>(); ((Collider)val2).isTrigger = true; val2.center = new Vector3(0f, (0f - gardenSettings.Depth) * 0.5f, 0f); val2.size = new Vector3(gardenSettings.Width, gardenSettings.Depth + 0.4f, gardenSettings.Width * ((Pond.Shape == 1) ? 0.65f : 1f)); WaterVolume obj = val.AddComponent<WaterVolume>(); obj.m_waterSurface = renderer; obj.m_forceDepth = 0f; obj.m_useGlobalWind = true; obj.m_surfaceOffset = 0f; RiverLiquid riverLiquid = val.AddComponent<RiverLiquid>(); riverLiquid.Pond = Pond; val.SetActive(true); Physics.SyncTransforms(); riverLiquid.WorldBounds = ((Collider)val2).bounds; } private void Start() { Pond = ((Component)this).GetComponent<GardenPiece>(); View = ((Component)this).GetComponent<ZNetView>(); Garden = GardenIntegration.Settings(Pond); } internal bool Contains(Vector3 position, float margin = 0f) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)Pond) && Garden != null && Mathf.Abs(position.y - Water) < Garden.Depth + 3f) { return GardenIntegration.Distance(Pond, position) <= 1f + margin / Mathf.Max(2f, Garden.Width * 0.5f); } return false; } internal bool Protects(Vector3 position) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_004d: 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) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) if (Live && Settings.Warded && Garden != null && Mathf.Abs(position.y - Water) < 12f) { Vector2 val = new Vector2(position.x - ((Component)this).transform.position.x, position.z - ((Component)this).transform.position.z); return ((Vector2)(ref val)).sqrMagnitude < WardRadius * WardRadius; } return false; } internal bool Occupied() { Chair[] seats = Seats; foreach (Chair val in seats) { if (Object.op_Implicit((Object)(object)val) && val.IsInUse()) { return true; } } return false; } internal bool Save(GardenSettings garden, HotSpringSettings settings) { //IL_0083: Unknown result type (might be due to invalid IL or missing references) if (!Live || !settings.Valid || garden.Depth < 0.8f || !GardenIntegration.CanEdit(Pond)) { return false; } if ((garden.Width != Garden.Width || garden.Depth != Garden.Depth) && Occupied()) { Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)2, "Wait until everyone leaves their sitting stone before resizing the pool.", 0, (Sprite)null, false); } return false; } if (settings.Warded && !PrivateArea.CheckAccess(((Component)this).transform.position, garden.Width * 0.5f + 4f, true, false)) { return false; } return GardenIntegration.Save(Pond, garden, settings.Encode()); } private void Update() { //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)Pond)) { return; } if (Time.time >= check) { check = Time.time + 0.5f; Garden = GardenIntegration.Settings(Pond); if (Live) { if (!registered) { registered = true; All.Add(this); } if (HotSpringSettings.TryDecode(View.GetZDO().GetString("arcane_pool_controller", ""), out var s)) { Settings = s; } } if ((builtWidth != Garden.Width || builtDepth != Garden.Depth) && !Occupied()) { Rebuild(); } UpdateWard(); if (Live && Object.op_Implicit((Object)(object)Player.m_localPlayer) && Contains(((Component)Player.m_localPlayer).transform.position)) { ((Character)Player.m_localPlayer).OnNearFire(((Component)this).transform.position); } if (Live && Settings.Warded) { RepelCreatures(); } } if (!Live || !Object.op_Implicit((Object)(object)steam) || !Object.op_Implicit((Object)(object)bubbles)) { return; } if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { Vector3 val = ((Component)Player.m_localPlayer).transform.position - ((Component)this).transform.position; if (((Vector3)(ref val)).sqrMagnitude < 3600f) { if (!steam.isPlaying) { steam.Play(); } if (!bubbles.isPlaying) { bubbles.Play(); } if (!(Time.time < nextParticles)) { nextParticles = Time.time + 0.1f; float num = Mathf.Clamp(Garden.Width / 6f, 1f, 3f); Emit(steam, ref steamCredit, Settings.Steam * num * 3f, 0.12f); Emit(bubbles, ref bubbleCredit, Settings.Bubbles * num * 1.4f, -0.06f); } return; } } if (steam.isPlaying) { steam.Stop(); } if (bubbles.isPlaying) { bubbles.Stop(); } } private void Emit(ParticleSystem system, ref float credit, float rate, float height) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_0058: 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_006e: 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_0072: Unknown result type (might be due to invalid IL or missing references) credit += rate; int num = Mathf.Min(8, (int)credit); credit -= num; for (int i = 0; i < num; i++) { Vector3 position = emitPoints[Random.Range(0, emitPoints.Length)]; position.y = Water - ((Component)this).transform.position.y + height; EmitParams val = default(EmitParams); ((EmitParams)(ref val)).position = position; ((EmitParams)(ref val)).applyShapeToPosition = false; EmitParams val2 = val; system.Emit(val2, 1); } } private void Rebuild() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //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) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Expected O, but got Unknown //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0151: 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_0161: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_03a1: Unknown result type (might be due to invalid IL or missing references) //IL_03b8: Unknown result type (might be due to invalid IL or missing references) //IL_03e2: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: 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_0206: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Expected O, but got Unknown //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_035d: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_0456: Unknown result type (might be due to invalid IL or missing references) //IL_045c: Invalid comparison between Unknown and I4 //IL_042e: Unknown result type (might be due to invalid IL or missing references) //IL_0440: Unknown result type (might be due to invalid IL or missing references) //IL_04f1: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)generated)) { generated.SetActive(false); Object.Destroy((Object)(object)generated); } generated = new GameObject("hotspring_seats_and_heat"); generated.SetActive(false); generated.transform.SetParent(((Component)this).transform, false); builtWidth = Garden.Width; builtDepth = Garden.Depth; int num = HotSpringSettings.SeatCount(Garden.Width, Pond.Shape); Seats = (Chair[])(object)new Chair[num]; for (int i = 0; i < num; i++) { float angle = ((float)i + 0.5f) * MathF.PI * 2f / (float)num; Vector3 val = GardenIntegration.Boundary(Pond.Shape, Garden.Width, angle, HotSpringSettings.SeatContour(Garden.Depth)); GameObject val2 = new GameObject("Submerged sitting stone " + (i + 1)) { layer = LayerMask.NameToLayer("piece") }; val2.transform.SetParent(generated.transform, false); val2.transform.localPosition = val; val2.transform.localRotation = Quaternion.LookRotation(-new Vector3(val.x, 0f, val.z)); GameObject val3 = GardenIntegration.WhiteSittingStone(val2.transform); Collider[] components = val3.GetComponents<Collider>(); for (int j = 0; j < components.Length; j++) { Object.DestroyImmediate((Object)(object)components[j]); } Bounds bounds = val3.GetComponent<MeshFilter>().sharedMesh.bounds; float num2 = Mathf.Min(0.9f, Garden.Width * 0.15f); val3.transform.localScale = new Vector3(num2 / ((Bounds)(ref bounds)).size.x, 0.25f / ((Bounds)(ref bounds)).size.y, num2 / ((Bounds)(ref bounds)).size.z); float num3 = -0.15f - Mathf.Min(0.45f, Garden.Depth * 0.4f); val3.transform.localPosition = new Vector3((0f - ((Bounds)(ref bounds)).center.x) * val3.transform.localScale.x, num3 - ((Bounds)(ref bounds)).max.y * val3.transform.localScale.y, (0f - ((Bounds)(ref bounds)).center.z) * val3.transform.localScale.z); BoxCollider obj = val2.AddComponent<BoxCollider>(); obj.center = new Vector3(0f, num3 - 0.125f, 0f); obj.size = new Vector3(num2, 0.25f, num2); GameObject val4 = new GameObject("hidden_sitting_point"); val4.transform.SetParent(val2.transform, false); val4.transform.localPosition = new Vector3(0f, num3 - 0.45f, 0f); Chair val5 = val2.AddComponent<Chair>(); val5.m_name = "Hot spring sitting stone"; val5.m_attachPoint = val4.transform; val5.m_useDistance = 3f; val5.m_detachOffset = new Vector3(0f, 1.1f, 0.8f); Seats[i] = val5; } if (Live) { GameObject val6 = new GameObject("natural_hot_spring_warmth") { layer = LayerMask.NameToLayer("character_trigger") }; val6.transform.SetParent(generated.transform, false); BoxCollider obj2 = val6.AddComponent<BoxCollider>(); ((Collider)obj2).isTrigger = true; obj2.center = new Vector3(0f, (0f - Garden.Depth) * 0.5f, 0f); obj2.size = new Vector3(Garden.Width, Garden.Depth + 2f, Garden.Width * ((Pond.Shape == 1) ? 0.65f : 1f)); EffectArea obj3 = val6.AddComponent<EffectArea>(); obj3.m_type = (Type)65; obj3.m_playerOnly = true; } if (Live && (int)SystemInfo.graphicsDeviceType != 4) { GameObject prefab = PrefabManager.Instance.GetPrefab("piece_bathtub"); steam = CloneParticles(prefab, "vfx_bath_mist", 160); bubbles = CloneParticles(prefab, "bubbles", 128); List<Vector3> list = new List<Vector3>(); for (int k = 0; k < 96; k++) { float angle2 = (float)k * 2.399963f; float fraction = 0.86f * Mathf.Sqrt(((float)k + 0.5f) / 96f); list.Add(GardenIntegration.Boundary(Pond.Shape, Garden.Width, angle2, fraction)); } emitPoints = list.ToArray(); } generated.SetActive(true); } private ParticleSystem CloneParticles(GameObject prefab, string name, int limit) { //IL_00f5: 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_0115: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: 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_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_03a4: Unknown result type (might be due to invalid IL or missing references) //IL_03ba: Unknown result type (might be due to invalid IL or missing references) //IL_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_03eb: Unknown result type (might be due to invalid IL or missing references) //IL_03f0: Unknown result type (might be due to invalid IL or missing references) //IL_0406: Unknown result type (might be due to invalid IL or missing references) //IL_0411: Unknown result type (might be due to invalid IL or missing references) //IL_0416: Unknown result type (might be due to invalid IL or missing references) //IL_0421: Unknown result type (might be due to invalid IL or missing references) //IL_0426: Unknown result type (might be due to invalid IL or missing references) //IL_043f: Unknown result type (might be due to invalid IL or missing references) //IL_0450: Unknown result type (might be due to invalid IL or missing references) //IL_0461: Unknown result type (might be due to invalid IL or missing references) //IL_046c: Unknown result type (might be due to invalid IL or missing references) //IL_0471: Unknown result type (might be due to invalid IL or missing references) //IL_049b: Unknown result type (might be due to invalid IL or missing references) //IL_04a6: Unknown result type (might be due to invalid IL or missing references) //IL_04ab: Unknown result type (might be due to invalid IL or missing references) //IL_04b5: Unknown result type (might be due to invalid IL or missing references) //IL_04bc: Expected O, but got Unknown //IL_04c6: Unknown result type (might be due to invalid IL or missing references) //IL_04d0: Unknown result type (might be due to invalid IL or missing references) //IL_04d5: Unknown result type (might be due to invalid IL or missing references) //IL_04dc: Unknown result type (might be due to invalid IL or missing references) //IL_04e6: Unknown result type (might be due to invalid IL or missing references) //IL_04eb: Unknown result type (might be due to invalid IL or missing references) //IL_0502: Unknown result type (might be due to invalid IL or missing references) //IL_0507: Unknown result type (might be due to invalid IL or missing references) //IL_0518: Unknown result type (might be due to invalid IL or missing references) //IL_051d: Unknown result type (might be due to invalid IL or missing references) //IL_052e: Unknown result type (might be due to invalid IL or missing references) //IL_0533: Unknown result type (might be due to invalid IL or missing references) //IL_0541: 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_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Expected O, but got Unknown //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Expected O, but got Unknown //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) ParticleSystem val = null; ParticleSystem[] componentsInChildren = prefab.GetComponentsInChildren<ParticleSystem>(true); foreach (ParticleSystem val2 in componentsInChildren) { if (((Object)val2).name == name) { val = val2; break; } } if (!Object.op_Implicit((Object)(object)val)) { Plugin.Log.LogWarning((object)("Hot spring effect unavailable: " + name)); return null; } GameObject val3 = Object.Instantiate<GameObject>(((Component)val).gameObject, generated.transform, false); MonoBehaviour[] componentsInChildren2 = val3.GetComponentsInChildren<MonoBehaviour>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[i]); } Collider[] componentsInChildren3 = val3.GetComponentsInChildren<Collider>(true); for (int i = 0; i < componentsInChildren3.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren3[i]); } for (int num = val3.transform.childCount - 1; num >= 0; num--) { Object.DestroyImmediate((Object)(object)((Component)val3.transform.GetChild(num)).gameObject); } val3.transform.localPosition = Vector3.zero; val3.transform.localRotation = Quaternion.identity; val3.transform.localScale = Vector3.one; ParticleSystem component = val3.GetComponent<ParticleSystem>(); component.Stop(true, (ParticleSystemStopBehavior)0); MainModule main = component.main; ((MainModule)(ref main)).loop = true; ((MainModule)(ref main)).playOnAwake = false; ((MainModule)(ref main)).maxParticles = limit; ((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)0; EmissionModule emission = component.emission; ((EmissionModule)(ref emission)).enabled = false; ShapeModule shape = component.shape; ((ShapeModule)(ref shape)).enabled = false; CollisionModule collision = component.collision; ((CollisionModule)(ref collision)).enabled = false; if (name == "vfx_bath_mist") { if (!Object.op_Implicit((Object)(object)softSteam)) { ParticleSystem val4 = null; componentsInChildren = prefab.GetComponentsInChildren<ParticleSystem>(true); foreach (ParticleSystem val5 in componentsInChildren) { if (((Object)val5).name == "bubbles") { val4 = val5; break; } } if (Object.op_Implicit((Object)(object)val4)) { softSteam = new Material(((Renderer)((Component)val4).GetComponent<ParticleSystemRenderer>()).sharedMaterial) { name = "ArcaneNaturalWaters soft steam" }; Texture2D val6 = new Texture2D(64, 64, (TextureFormat)4, false) { name = "Hot spring soft steam falloff", wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1 }; Color[] array = (Color[])(object)new Color[4096]; for (int j = 0; j < 64; j++) { for (int k = 0; k < 64; k++) { float num2 = ((float)k - 31.5f) / 31.5f; float num3 = ((float)j - 31.5f) / 31.5f; float num4 = num2 * num2 + num3 * num3; float num5 = Mathf.Clamp01(1f - num4); num5 = num5 * num5 * num5; float num6 = 0.55f + 0.45f * Mathf.PerlinNoise((float)k * 0.09f, (float)j * 0.09f); array[j * 64 + k] = new Color(1f, 1f, 1f, num5 * num6); } } val6.SetPixels(array); val6.Apply(false, true); softSteam.mainTexture = (Texture)(object)val6; if (softSteam.HasProperty("_TintColor")) { softSteam.SetColor("_TintColor", Color.white); } if (softSteam.HasProperty("_Color")) { softSteam.SetColor("_Color", Color.white); } } } ParticleSystemRenderer component2 = ((Component)component).GetComponent<ParticleSystemRenderer>(); if (Object.op_Implicit((Object)(object)softSteam)) { ((Renderer)component2).sharedMaterial = softSteam; } component2.renderMode = (ParticleSystemRenderMode)0; component2.alignment = (ParticleSystemRenderSpace)0; ((MainModule)(ref main)).startLifetime = new MinMaxCurve(4f, 6f); ((MainModule)(ref main)).startSize = new MinMaxCurve(1.1f, 1.8f); ((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(0f); ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(0.9f, 0.95f, 1f, 0.24f)); ((MainModule)(ref main)).startRotation = new MinMaxCurve(0f, MathF.PI * 2f); TextureSheetAnimationModule textureSheetAnimation = component.textureSheetAnimation; ((TextureSheetAnimationModule)(ref textureSheetAnimation)).enabled = false; VelocityOverLifetimeModule velocityOverLifetime = component.velocityOverLifetime; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = true; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).space = (ParticleSystemSimulationSpace)0; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).x = MinMaxCurve.op_Implicit(0f); ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).y = MinMaxCurve.op_Implicit(0.25f); ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).z = MinMaxCurve.op_Implicit(0f); SizeOverLifetimeModule sizeOverLifetime = component.sizeOverLifetime; ((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true; ((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, AnimationCurve.Linear(0f, 0.7f, 1f, 1.8f)); ColorOverLifetimeModule colorOverLifetime = component.colorOverLifetime; ((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true; Gradient val7 = new Gradient(); val7.SetKeys((GradientColorKey[])(object)new GradientColorKey[2] { new GradientColorKey(Color.white, 0f), new GradientColorKey(Color.white, 1f) }, (GradientAlphaKey[])(object)new GradientAlphaKey[3] { new GradientAlphaKey(0f, 0f), new GradientAlphaKey(0.8f, 0.2f), new GradientAlphaKey(0f, 1f) }); ((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val7); } val3.SetActive(true); return component; } private void RepelCreatures() { //IL_0040: 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_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_006a: 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_0098: 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) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) float num = default(float); foreach (Character allCharacter in Character.GetAllCharacters()) { if (Object.op_Implicit((Object)(object)allCharacter) && !allCharacter.IsPlayer() && allCharacter.IsOwner() && Protects(((Component)allCharacter).transform.position)) { Vector3 val = ((Component)allCharacter).transform.position - ((Component)this).transform.position; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { val = Vector3.forward; } Vector3 val2 = ((Component)this).transform.position + ((Vector3)(ref val)).normalized * (WardRadius + 2f); val2.y = ((Component)allCharacter).transform.position.y; if (Object.op_Implicit((Object)(object)ZoneSystem.instance) && ZoneSystem.instance.GetGroundHeight(val2, ref num)) { val2.y = Mathf.Max(val2.y, num + 0.3f); } ((Component)allCharacter).transform.position = val2; Rigidbody component = ((Component)allCharacter).GetComponent<Rigidbody>(); if (Object.op_Implicit((Object)(object)component)) { component.position = val2; component.linearVelocity = Vector3.zero; } } } } private void UpdateWard() { //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown //IL_00fd: Unknown result type (might be due to invalid IL or missing references) if (!Live || !Settings.Warded) { if (Object.op_Implicit((Object)(object)ward)) { ward.SetActive(false); Object.Destroy((Object)(object)ward); ward = null; } } else if (!Object.op_Implicit((Object)(object)ward) || !Mathf.Approximately(ward.GetComponent<SphereCollider>().radius, WardRadius)) { if (Object.op_Implicit((Object)(object)ward)) { ward.SetActive(false); Object.Destroy((Object)(object)ward); } ward = new GameObject("hot_spring_creature_ward") { layer = LayerMask.NameToLayer("character_trigger") }; ward.SetActive(false); ward.transform.SetParent(((Component)this).transform, false); SphereCollider obj = ward.AddComponent<SphereCollider>(); ((Collider)obj).isTrigger = true; obj.radius = WardRadius; ward.AddComponent<EffectArea>().m_type = (Type)32; ward.SetActive(true); } } private void OnDestroy() { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)HotSpringEditor.Target == (Object)(object)this) { HotSpringEditor.Close(); } All.Remove(this); Chair[] seats = Seats; foreach (Chair val in seats) { if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)Player.m_localPlayer) && Vector3.Distance(((Component)Player.m_localPlayer).transform.position, val.m_attachPoint.position) < 0.15f) { ((Character)Player.m_localPlayer).AttachStop(); } } } } internal sealed class HotSpringAudio : MonoBehaviour { internal static readonly string[] SoundNames = new string[6] { "Off", "Quiet bubbles", "Mineral spring", "Gentle simmer", "Hidden grotto", "Deep relaxation" }; private static HotSpringAudio instance; private static readonly Dictionary<int, AudioClip> loops = new Dictionary<int, AudioClip>(); private readonly HashSet<int> loading = new HashSet<int>(); private AudioSource ambience; private AudioSource music; private AudioSource preview; private AudioSource mutedNative; private bool nativeWasMuted; private int wantedMusic = -1; private int currentMusic = -1; private int musicRequest; private float scan; private float previewUntil; private HotSpring audible; private HotSpring inside; private static bool Headless => (int)SystemInfo.graphicsDeviceType == 4; private void Awake() { instance = this; if (!Headless) { ambience = Source("Bubbling hot spring", 1f); music = Source("Hot spring music", 0f); preview = Source("Hot spring sound preview", 0f); } } private AudioSource Source(string name, float spatial) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(((Component)this).transform, false); AudioSource obj = val.AddComponent<AudioSource>(); obj.playOnAwake = false; obj.loop = true; obj.spatialBlend = spatial; obj.dopplerLevel = 0f; obj.volume = 0f; obj.rolloffMode = (AudioRolloffMode)1; return obj; } internal static void Preview(int id, float volume, float speed) { if (Object.op_Implicit((Object)(object)instance) && !Headless) { ((MonoBehaviour)instance).StartCoroutine(instance.PlayPreview(id, volume, speed)); } } private IEnumerator PlayPreview(int id, float volume, float speed) { StopPreview(); if (id > 0) { float requested = (previewUntil = Time.unscaledTime + 10f); yield return EnsureLoop(id); if (previewUntil == requested && loops.TryGetValue(id, out var value) && Object.op_Implicit((Object)(object)value)) { preview.clip = value; preview.volume = volume * Plugin.Volume.Value; preview.pitch = speed; preview.Play(); previewUntil = Time.unscaledTime + 8f; } } } internal static void StopPreview() { if (Object.op_Implicit((Object)(object)instance)) { instance.previewUntil = 0f; if (Object.op_Implicit((Object)(object)instance.preview)) { instance.preview.Stop(); } } } private IEnumerator EnsureLoop(int id) { if (id <= 0 || loops.ContainsKey(id)) { yield break; } if (!loading.Add(id)) { while (loading.Contains(id)) { yield return null; } yield break; } yield return Load("spring_" + id.ToString("000") + ".ogg", (AudioType)14, streaming: false, delegate(AudioClip clip) { loops[id] = clip; }); loading.Remove(id); } private IEnumerator Load(string name, AudioType type, bool streaming, Action<AudioClip> done) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) string text = Path.Combine(Paths.CachePath, "ArcaneNaturalWaters-0.5.0", name); try { if (!File.Exists(text)) { Directory.CreateDirectory(Path.GetDirectoryName(text)); using (Stream stream = typeof(Plugin).Assembly.GetManifestResourceStream("ArcaneWaterWorks.HotSprings." + name)) { if (stream == null) { throw new FileNotFoundException(name); } using FileStream destination = File.Create(text + ".tmp"); stream.CopyTo(destination); } File.Move(text + ".tmp", text); } } catch (Exception ex) { Plugin.Log.LogError((object)("Hot spring audio: " + ex.Message)); done(null); yield break; } UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(new Uri(text).AbsoluteUri, type); try { ((DownloadHandlerAudioClip)request.downloadHandler).streamAudio = streaming; yield return request.SendWebRequest(); if ((int)request.result != 1) { Plugin.Log.LogError((object)("Hot spring audio: " + request.error)); done(null); } else { AudioClip content = DownloadHandlerAudioClip.GetContent(request); ((Object)content).name = name; done(content); } } finally { ((IDisposable)request)?.Dispose(); } } private void Update() { //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //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) //IL_00f1: 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) if (Headless || !Object.op_Implicit((Object)(object)ambience)) { return; } if (preview.isPlaying && Time.unscaledTime >= previewUntil) { preview.Stop(); } if (Time.unscaledTime >= scan) { scan = Time.unscaledTime + 0.25f; audible = null; inside = null; float num = float.MaxValue; float num2 = float.MaxValue; Player localPlayer = Player.m_localPlayer; if (Object.op_Implicit((Object)(object)localPlayer) && !((Character)localPlayer).IsDead()) { foreach (HotSpring item in HotSpring.All) { if (Object.op_Implicit((Object)(object)item) && item.Live && item.Garden != null) { Vector3 val = ((Component)item).transform.position - ((Component)localPlayer).transform.position; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (item.Settings.Sound > 0 && item.Settings.Volume > 0f && sqrMagnitude < item.Garden.Range * item.Garden.Range && sqrMagnitude < num) { num = sqrMagnitude; audible = item; } if (item.Contains(((Component)localPlayer).transform.position) && sqrMagnitude < num2) { num2 = sqrMagnitude; inside = item; } } } } if (Object.op_Implicit((Object)(object)audible) && !loops.ContainsKey(audible.Settings.Sound) && !loading.Contains(audible.Settings.Sound)) { ((MonoBehaviour)this).StartCoroutine(EnsureLoop(audible.Settings.Sound)); } int num3 = (Object.op_Implicit((Object)(object)inside) ? inside.Settings.Music : 0); if (num3 != wantedMusic) { wantedMusic = num3; musicRequest++; } } AudioClip value = null; if (Object.op_Implicit((Object)(object)audible)) { loops.TryGetValue(audible.Settings.Sound, out value); } bool flag = (Object)(object)ambience.clip == (Object)(object)value; float num4 = ((Object.op_Implicit((Object)(object)audible) && Object.op_Implicit((Object)(object)value) && flag) ? (audible.Settings.Volume * Plugin.Volume.Value) : 0f); ambience.volume = Mathf.MoveTowards(ambience.volume, num4, Time.unscaledDeltaTime * 0.5f); if (ambience.volume <= 0.001f && !flag) { ambience.Stop(); ambience.clip = value; if (Object.op_Implicit((Object)(object)value)) { ambience.Play(); } } if (Object.op_Implicit((Object)(object)audible)) { ((Component)ambience).transform.position = ((Component)audible).transform.position; ambience.minDistance = audible.Garden.Width * 0.5f; ambience.maxDistance = Mathf.Max(ambience.minDistance + 1f, audible.Garden.Range); ambience.pitch = audible.Garden.Speed; } bool flag2 = currentMusic == wantedMusic; float num5 = ((Object.op_Implicit((Object)(object)inside) && flag2 && Object.op_Implicit((Object)(object)music.clip)) ? (inside.Settings.MusicVolume * MusicMan.m_masterMusicVolume) : 0f); music.volume = Mathf.MoveTowards(music.volume, num5, Time.unscaledDeltaTime * 0.5f); if (music.volume <= 0.001f && !flag2) { music.Stop(); if (Object.op_Implicit((Object)(object)music.clip)) { Object.Destroy((Object)(object)music.clip); } music.clip = null; currentMusic = wantedMusic; if (wantedMusic > 0) { ((MonoBehaviour)this).StartCoroutine(ChangeMusic(wantedMusic, musicRequest)); } } if (!music.isPlaying) { RestoreNative(); } } private IEnumerator ChangeMusic(int id, int request) { AudioClip clip = null; yield return Load("AW_HSMusic_" + id.ToString("000") + ".mp3", (AudioType)13, streaming: true, delegate(AudioClip result) { clip = result; }); if (!Object.op_Implicit((Object)(object)this) || request != musicRequest || wantedMusic != id) { if (Object.op_Implicit((Object)(object)clip)) { Object.Destroy((Object)(object)clip); } yield break; } music.clip = clip; if (Object.op_Implicit((Object)(object)clip)) { music.Play(); } } internal static void OverrideMusic(AudioSource source) { if (Object.op_Implicit((Object)(object)instance) && Object.op_Implicit((Object)(object)instance.music) && instance.music.isPlaying && Object.op_Implicit((Object)(object)source)) { if ((Object)(object)instance.mutedNative != (Object)(object)source) { instance.RestoreNative(); instance.mutedNative = source; instance.nativeWasMuted = source.mute; } instance.music.outputAudioMixerGroup = source.outputAudioMixerGroup; source.mute = true; } } private void RestoreNative() { if (Object.op_Implicit((Object)(object)mutedNative)) { mutedNative.mute = nativeWasMuted; } mutedNative = null; } private void OnDisable() { RestoreNative(); if (Object.op_Implicit((Object)(object)music)) { music.Stop(); } if (Object.op_Implicit((Object)(object)ambience)) { ambience.Stop(); } StopPreview(); } private void OnDestroy() { RestoreNative(); if (Object.op_Implicit((Object)(object)music) && Object.op_Implicit((Object)(object)music.clip)) { Object.Destroy((Object)(object)music.clip); } foreach (AudioClip value in loops.Values) { if (Object.op_Implicit((Object)(object)value)) { Object.Destroy((Object)(object)value); } } loops.Clear(); if ((Object)(object)instance == (Object)(object)this) { instance = null; } } } [HarmonyPatch(typeof(MusicMan), "UpdateMusic")] internal static class HotSpringMusicOverride { private static void Postfix(AudioSource ___m_musicSource) { HotSpringAudio.OverrideMusic(___m_musicSource); } } [HarmonyPatch(typeof(SpawnSystem), "IsSpawnPointGood")] internal static class HotSpringSpawnWard { private static void Postfix(Vector3 spawnPoint, ref bool __result) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) if (!__result) { return; } foreach (HotSpring item in HotSpring.All) { if (Object.op_Implicit((Object)(object)item) && item.Protects(spawnPoint)) { __result = false; break; } } } } [HarmonyPatch(typeof(Heightmap), "ApplyModifiers")] internal static class HotSpringBank { [HarmonyPostfix] [HarmonyPriority(200)] private static void Postfix(Heightmap __instance, List<float> ___m_heights) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_024d: 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_025b: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) if (__instance.IsDistantLod || HotSpring.All.Count == 0) { return; } int width = __instance.m_width; float scale = __instance.m_scale; float num = (float)width * scale * 0.5f; Vector3 position = ((Component)__instance).transform.position; Vector3 val = default(Vector3); foreach (HotSpring item in HotSpring.All) { if (!Object.op_Implicit((Object)(object)item) || !item.Live || item.Garden == null) { continue; } Vector3 position2 = ((Component)item).transform.position; float num2 = item.Garden.Width * 0.5f; float num3 = num2 + 3f; if (Mathf.Abs(position.x - position2.x) > num + num3 || Mathf.Abs(position.z - position2.z) > num + num3) { continue; } int num4 = Mathf.Clamp(Mathf.FloorToInt((position2.x - num3 - position.x + num) / scale), 0, width); int num5 = Mathf.Clamp(Mathf.CeilToInt((position2.x + num3 - position.x + num) / scale), 0, width); int num6 = Mathf.Clamp(Mathf.FloorToInt((position2.z - num3 - position.z + num) / scale), 0, width); int num7 = Mathf.Clamp(Mathf.CeilToInt((position2.z + num3 - position.z + num) / scale), 0, width); for (int i = num6; i <= num7; i++) { for (int j = num4; j <= num5; j++) { ((Vector3)(ref val))..ctor(position.x + (float)j * scale - num, item.Water, position.z + (float)i * scale - num); float num8 = GardenIntegration.Distance(item.Pond, val); float num9 = (num8 - 1f) * num2; if (!((float)HotSpringBankProfile.Height(num9) <= 0f) && !(num8 < 0.001f) && (!(num8 > 1.0001f) || (float.IsNegativeInfinity(GardenIntegration.WaterLevel(val)) && float.IsNegativeInfinity(GardenBridge.Water(val))))) { Vector3 val2 = val - position2; val2.y = 0f; Vector3 val3 = position2 + val2 * ((1f + 0.12f / num2) / num8); val3.y = item.Water; if (float.IsNegativeInfinity(GardenIntegration.WaterLevel(val3)) && float.IsNegativeInfinity(GardenBridge.Water(val3))) { int index = i * (width + 1) + j; ___m_heights[index] = (float)HotSpringBankProfile.Apply(___m_heights[index] + position.y, item.Water, num9) - position.y; } } } } } } } internal static class HotSpringBankProfile { internal static double Height(double edge) { if (edge < 0.0 || edge >= 3.0) { return 0.0; } double value = ((edge < 0.25) ? 1.0 : ((3.0 - edge) / 2.75)); value = Math.Clamp(value, 0.0, 1.0); return 0.24 * value * value * (3.0 - 2.0 * value); } internal static double Apply(double original, double water, double edge) { double num = Height(edge); if (num <= 0.0) { return original; } double val = water - 0.025 + num; return Math.Max(original, val); } } internal sealed class HotSpringEditor : MonoBehaviour { internal static HotSpring Target; private static PondMenu menu; private static GardenSettings garden; private static HotSpringSettings settings; private static int page; internal static void Show(HotSpring pool) { RiverEditor.Close(); GardenIntegration.CloseEditors(); Close(); Target = pool; garden = GardenIntegration.Settings(pool.Pond); settings = pool.Settings.Copy(); GardenSettings gardenSettings = GardenIntegration.GroupSettings(pool.Pond); garden.FlowerScale = gardenSettings.FlowerScale; garden.FloatLanterns = gardenSettings.FloatLanterns; garden.FloatFountains = gardenSettings.FloatFountains; garden.FloatStatues = gardenSettings.FloatStatues; page = 0; Panel(); } internal static void Close() { menu?.Dispose(); menu = null; Target = null; HotSpringAudio.StopPreview(); } private static void Page(int next) { menu?.Dispose(); menu = null; page = next; Panel(); } private static string Percent(float value) { return Mathf.RoundToInt(value * 100f) + "%"; } private static void Panel() { menu = new PondMenu(960f); menu.Heading("ARCANE WATERS"); menu.Heading(Target.PoolName, 65f, 23); float y = 120f; if (page == 0) { menu.Range("Pool width", 4f, 24f, garden.Width, delegate(float v) { garden.Width = Mathf.Round(v * 2f) / 2f; }, () => garden.Width.ToString("0.0") + " m", ref y); menu.Range("Pool depth", 0.8f, 3f, garden.Depth, delegate(float v) { garden.Depth = Mathf.Round(v * 10f) / 10f; }, () => garden.Depth.ToString("0.0") + " m", ref y); menu.Range("Rising steam", 0f, 1f, settings.Steam, delegate(float v) { settings.Steam = v; }, () => Percent(settings.Steam), ref y); menu.Range("Bubbling water", 0f, 1f, settings.Bubbles, delegate(float v) { settings.Bubbles = v; }, () => Percent(settings.Bubbles), ref y); menu.Option("Warded pool", () => settings.Warded, delegate(bool v) { settings.Warded = v; }, ref y); menu.Action("Bubbling sounds and music", y, delegate { Page(1); }); y += 48f; menu.Action("Pool ambience", y, delegate { Page(2); }); y += 48f; menu.Heading("Naturally heated - no fuel. Submerged white stones provide individual sitting spots; larger pools receive more stones. Everyone must stand before resizing.\n\nThe optional ward keeps creatures, including pets, outside the pool and a 4 m margin. Players can enter freely.", y, 18, 230f); } else if (page == 1) { menu.Range("Bubbling loop", 0f, 5f, settings.Sound, delegate(float v) { settings.Sound = Mathf.RoundToInt(v); }, () => HotSpringAudio.SoundNames[settings.Sound], ref y); menu.Range("Bubbling volume", 0f, 1f, settings.Volume, delegate(float v) { settings.Volume = v; }, () => Percent(settings.Volume), ref y); menu.Range("Playback speed", 0.5f, 1.5f, garden.Speed, delegate(float v) { garden.Speed = v; }, () => garden.Speed.ToString("0.00") + "x", ref y); menu.Range("Audible distance", 5f, 40f, garden.Range, delegate(float v) { garden.Range = Mathf.Round(v); }, () => garden.Range.ToString("0") + " m", ref y); menu.Action("Preview bubbling loop", y, delegate { HotSpringAudio.Preview(settings.Sound, settings.Volume, garden.Speed); }); y += 48f; menu.Range("Pool music", 0f, 6f, settings.Music, delegate(float v) { settings.Music = Mathf.RoundToInt(v); }, () => (settings.Music != 0) ? ("AW_HSMusic_" + settings.Music.ToString("000")) : "Valheim music", ref y); menu.Range("Pool music volume", 0f, 1f, settings.MusicVolume, delegate(float v) { settings.MusicVolume = v; }, () => Percent(settings.MusicVolume), ref y); menu.Heading("Five seamless bubbling loops from your three recordings. Music choices use all six supplied songs. Pool music replaces Valheim music only while inside this pool and follows the game's music-volume setting.", y, 18, 110f); } else { menu.Range("Waterfall volume", 0f, 1f, garden.WaterfallVolume, delegate(float v) { garden.WaterfallVolume = v; }, () => Percent(garden.WaterfallVolume), ref y); menu.Range("Waterfall distance", 5f, 100f, garden.WaterfallRange, delegate(float v) { garden.WaterfallRange = Mathf.Round(v); }, () => garden.WaterfallRange.ToString("0") + " m", ref y); menu.Range("Garden ambience", 0f, 7f, garden.Track, delegate(float v) { garden.Track = Mathf.RoundToInt(v); }, () => (garden.Track != 0) ? ("Night ambience " + garden.Track.ToString("000")) : "Off", ref y); menu.Range("Garden ambience volume", 0f, 1f, garden.Volume, delegate(float v) { garden.Volume = v; }, () => Percent(garden.Volume), ref y); menu.Range("Fireflies", 0f, 100f, garden.Fireflies, delegate(float v) { garden.Fireflies = Mathf.RoundToInt(v); }, () => garden.Fireflies.ToString(), ref y); menu.Option("Fireflies / garden ambience at night only", () => garden.NightOnly, delegate(bool v) { garden.NightOnly = v; }, ref y); menu.Heading("Bubbling and music also work during the day.", y, 17, 50f); } if (page != 0) { menu.Action("Back to pool settings", 802f, delegate { Page(0); }); } menu.Action("Save all hot spring settings", 850f, delegate { if (Object.op_Implicit((Object)(object)Target) && Target.Save(garden, settings)) { Close(); } else { Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)2, "Unable to save: check access and occupied seats.", 0, (Sprite)null, false); } } }); menu.Action("Cancel", 900f, Close); } private void Update() { if (Object.op_Implicit((Object)(object)Target) && (!GardenIntegration.CanEdit(Target.Pond) || Input.GetKeyDown((KeyCode)27))) { Close(); } } private void OnDisable() {