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 ArcaneDecor WaterGardens v1.1.3
plugins/ArcaneDecorWaterGardens/ArcaneDecorWaterGardens.dll
Decompiled 5 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Serialization.Json; using System.Runtime.Versioning; using System.Text; using ArcaneDecorWaterGardens.Input; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Microsoft.CodeAnalysis; using Runic.Localization; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("ArcaneDecor: WaterGardens")] [assembly: AssemblyDescription("Ancient water-garden decor for Valheim")] [assembly: AssemblyCompany("Chazman")] [assembly: AssemblyFileVersion("1.1.3.0")] [assembly: InternalsVisibleTo("ArcaneWaterWorks.Smoke")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyVersion("1.1.3.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 Runic.Localization { internal sealed class LanguageCatalog { private readonly Dictionary<string, string> _english; private Dictionary<string, string> _selected = new Dictionary<string, string>(); private readonly Func<string, string> _read; private string _language; internal LanguageCatalog(string english, Func<string, string> read) { _english = Parse(english); _read = read; } internal static Dictionary<string, string> Parse(string json) { if (string.IsNullOrWhiteSpace(json)) { return new Dictionary<string, string>(); } if (json.Length > 2097152) { throw new InvalidDataException("Language file exceeds 2 MiB."); } DataContractJsonSerializer dataContractJsonSerializer = new DataContractJsonSerializer(typeof(Dictionary<string, string>), new DataContractJsonSerializerSettings { UseSimpleDictionaryFormat = true }); using MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(json.TrimStart('\ufeff'))); return ((Dictionary<string, string>)dataContractJsonSerializer.ReadObject(stream)) ?? new Dictionary<string, string>(); } internal void Select(string language) { language = (string.IsNullOrWhiteSpace(language) ? "English" : language); if (string.Equals(language, _language, StringComparison.Ordinal)) { return; } _language = language; _selected = new Dictionary<string, string>(); if (language.IndexOfAny(new char[4] { '/', '\\', ':', '\0' }) >= 0 || language == "." || language == "..") { return; } try { _selected = Parse(_read(language)); } catch (Exception) { } } internal string Get(string key) { _english.TryGetValue(key, out var value); if (_selected.TryGetValue(key, out var value2) && !string.IsNullOrWhiteSpace(value2) && (value == null || SameFields(value, value2))) { return value2; } return value ?? key; } internal string English(string key) { if (!_english.TryGetValue(key, out var value)) { return key; } return value; } internal string TranslateEnglish(string text) { foreach (KeyValuePair<string, string> item in _english) { if (item.Value == text) { return Get(item.Key); } } return text; } internal string Format(string key, params object[] args) { _english.TryGetValue(key, out var value); string text = Get(key); if (value != null && !SameFields(value, text)) { text = value; } try { return string.Format(CultureInfo.CurrentCulture, text, args); } catch (FormatException) { try { return string.Format(CultureInfo.CurrentCulture, value ?? key, args); } catch (FormatException) { return value ?? key; } } } private static bool SameFields(string a, string b) { try { return Fields(a).SetEquals(Fields(b)); } catch (FormatException) { return false; } } private static HashSet<int> Fields(string text) { HashSet<int> hashSet = new HashSet<int>(); for (int i = 0; i < text.Length; i++) { if (text[i] == '}') { if (i + 1 >= text.Length || text[i + 1] != '}') { throw new FormatException(); } i++; } else { if (text[i] != '{') { continue; } if (i + 1 < text.Length && text[i + 1] == '{') { i++; continue; } int num = ++i; for (; i < text.Length && char.IsDigit(text[i]); i++) { } if (num == i || !int.TryParse(text.Substring(num, i - num), out var result)) { throw new FormatException(); } hashSet.Add(result); for (; i < text.Length && text[i] != '}'; i++) { if (text[i] == '{') { throw new FormatException(); } } if (i == text.Length) { throw new FormatException(); } } } return hashSet; } } internal static class RunicText { private static readonly Assembly Owner = typeof(RunicText).Assembly; private static readonly string Module = Owner.GetName().Name; private static readonly LanguageCatalog Catalog = Create(); private static LanguageCatalog Create() { using Stream stream = Owner.GetManifestResourceStream("Runic.Localization.English.json"); using StreamReader streamReader = ((stream == null) ? null : new StreamReader(stream)); return new LanguageCatalog(streamReader?.ReadToEnd() ?? "{}", ReadLanguage); } private static string ReadLanguage(string language) { string path = Path.Combine(Path.Combine(Path.GetDirectoryName(Owner.Location), "Translations", Module), language + ".json"); if (!File.Exists(path)) { return null; } return File.ReadAllText(path); } private static void SelectLanguage() { string language = "English"; try { Localization instance = Localization.instance; language = ((instance != null) ? instance.GetSelectedLanguage() : null) ?? "English"; } catch { } Catalog.Select(language); } internal static string Get(string key) { SelectLanguage(); return Catalog.Get(key); } internal static string English(string key) { return Catalog.English(key); } internal static string TranslateEnglish(string text) { SelectLanguage(); return Catalog.TranslateEnglish(text); } internal static string Format(string key, params object[] args) { SelectLanguage(); return Catalog.Format(key, args); } } } namespace ArcaneDecorWaterGardens.Input { internal static class ModalGameplayInput { internal static Func<bool> IsOpen; [ThreadStatic] private static int _cameraDepth; private static int _lastOpenFrame = -10; internal static bool Blocked { get { Func<bool> isOpen = IsOpen; if (isOpen != null && isOpen()) { _lastOpenFrame = Time.frameCount; return true; } return Time.frameCount <= _lastOpenFrame + 1; } } internal static bool CameraBlocked => _cameraDepth > 0; internal static void Reset() { IsOpen = null; _lastOpenFrame = -10; _cameraDepth = 0; } internal static void EnterCamera(bool blocked) { if (blocked) { _cameraDepth++; } } internal static void ExitCamera(bool blocked) { if (blocked) { _cameraDepth = Math.Max(0, _cameraDepth - 1); } } internal static bool GameplayAction(string name) { if (name != null) { if (!name.StartsWith("Hotbar", StringComparison.Ordinal)) { switch (name) { default: return name == "JoyGuardianPower"; case "JoyHotbarUse": case "Forward": case "Backward": case "Left": case "Right": case "Attack": case "JoyAttack": case "SecondaryAttack": case "JoySecondaryAttack": case "Block": case "JoyBlock": case "Jump": case "JoyJump": case "Crouch": case "JoyCrouch": case "Run": case "JoyRun": case "AutoRun": case "Dodge": case "JoyDodge": case "Use": case "JoyUse": case "Inventory": case "JoyInventory": case "Chat": case "Console": case "GuardianPower": break; } } return true; } return false; } } [HarmonyPatch(typeof(PlayerController), "TakeInput", new Type[] { typeof(bool) })] internal static class ModalControllerInputPatch { [HarmonyPostfix] [HarmonyPriority(0)] private static void Postfix(ref bool __result) { if (ModalGameplayInput.Blocked) { __result = false; } } } [HarmonyPatch(typeof(Player), "TakeInput")] internal static class ModalPlayerInputPatch { [HarmonyPostfix] [HarmonyPriority(0)] private static void Postfix(Player __instance, ref bool __result) { if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer && ModalGameplayInput.Blocked) { __result = false; } } } [HarmonyPatch(typeof(Player), "SetControls")] internal static class ModalControlsPatch { [HarmonyPrefix] [HarmonyPriority(0)] private static void Prefix(Player __instance, ref Vector3 movedir, ref bool attack, ref bool attackHold, ref bool secondaryAttack, ref bool secondaryAttackHold, ref bool block, ref bool blockHold, ref bool jump, ref bool crouch, ref bool run, ref bool autoRun, ref bool dodge) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer) && ModalGameplayInput.Blocked) { movedir = Vector3.zero; attack = (attackHold = (secondaryAttack = (secondaryAttackHold = (block = (blockHold = (jump = (crouch = (run = (autoRun = (dodge = false)))))))))); } } } [HarmonyPatch] internal static class ModalCameraScopePatch { private static IEnumerable<MethodBase> TargetMethods() { return from m in typeof(GameCamera).GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) where m.DeclaringType == typeof(GameCamera) && (m.Name == "UpdateCamera" || m.Name == "UpdateFreeFly") select m; } [HarmonyPrefix] [HarmonyPriority(800)] private static void Prefix(out bool __state) { __state = ModalGameplayInput.Blocked; ModalGameplayInput.EnterCamera(__state); } [HarmonyFinalizer] private static Exception Finalizer(Exception __exception, bool __state) { ModalGameplayInput.ExitCamera(__state); return __exception; } } [HarmonyPatch] internal static class ModalCameraAxisPatch { private static IEnumerable<MethodBase> TargetMethods() { return from m in typeof(ZInput).GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) where m.ReturnType == typeof(float) && (m.Name == "GetMouseScrollWheel" || m.Name.StartsWith("GetJoyLeftStick", StringComparison.Ordinal) || m.Name.StartsWith("GetJoyRightStick", StringComparison.Ordinal) || m.Name == "GetJoyLTrigger" || m.Name == "GetJoyRTrigger") select m; } [HarmonyPostfix] [HarmonyPriority(0)] private static void Postfix(ref float __result) { if (ModalGameplayInput.CameraBlocked) { __result = 0f; } } } [HarmonyPatch(typeof(ZInput), "GetMouseDelta")] internal static class ModalCameraLookPatch { [HarmonyPostfix] [HarmonyPriority(0)] private static void Postfix(ref Vector2 __result) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (ModalGameplayInput.CameraBlocked) { __result = Vector2.zero; } } } [HarmonyPatch] internal static class ModalNamedActionPatch { private static IEnumerable<MethodBase> TargetMethods() { return ((IEnumerable<string>)new string[3] { "GetButton", "GetButtonDown", "GetButtonUp" }).Select((Func<string, MethodBase>)((string name) => AccessTools.Method(typeof(ZInput), name, new Type[1] { typeof(string) }, (Type[])null))); } [HarmonyPostfix] [HarmonyPriority(0)] private static void Postfix(string name, ref bool __result) { if (ModalGameplayInput.CameraBlocked || (ModalGameplayInput.Blocked && ModalGameplayInput.GameplayAction(name))) { __result = false; } } } [HarmonyPatch] internal static class ModalShortcutKeyPatch { private static IEnumerable<MethodBase> TargetMethods() { return from m in typeof(ZInput).GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) where m.ReturnType == typeof(bool) && (m.Name == "GetKey" || m.Name == "GetKeyDown" || m.Name == "GetKeyUp") && m.GetParameters().Length != 0 && m.GetParameters()[0].ParameterType == typeof(KeyCode) select m; } [HarmonyPostfix] [HarmonyPriority(0)] private static void Postfix(KeyCode key, ref bool __result) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Invalid comparison between Unknown and I4 if ((int)key != 27 && ((int)key < 323 || (int)key > 329) && ModalGameplayInput.Blocked) { __result = false; } } } } namespace RunicLilyPads { public sealed class FeatureEditor : MonoBehaviour { internal static GardenFeature Target; private static FeatureSettings draft; private static bool visible; private static CursorLockMode cursorLock; private static PondMenu menu; internal static bool IsOpen => Object.op_Implicit((Object)(object)Target); internal static void Open(GardenFeature target) { //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) GardenEditor.Close(); GardenTreeEditor.Close(); Close(); Target = target; draft = target.Settings.Copy(); visible = Cursor.visible; cursorLock = Cursor.lockState; KeepCursor(); menu = new PondMenu(target, draft, Save, Close); } private static void Save() { if (Object.op_Implicit((Object)(object)Target) && Target.Save(draft)) { Close(); } } internal static void Close() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) menu?.Dispose(); menu = null; if (Object.op_Implicit((Object)(object)Target)) { Cursor.visible = visible; Cursor.lockState = cursorLock; } Target = null; draft = null; } internal static void KeepCursor() { if (IsOpen) { Cursor.visible = true; Cursor.lockState = (CursorLockMode)0; } } private void Update() { if (IsOpen) { if (!Target.CanEdit() || Input.GetKeyDown((KeyCode)27)) { Close(); } else { KeepCursor(); } } } private void LateUpdate() { KeepCursor(); } private void OnDisable() { Close(); } } internal sealed class FeatureSettings { public float Light = 1.5f; public float Range = 6f; public float Glow = 2f; public float Volume = 0.4f; public bool Flow = true; public bool Valid { get { if (Between(Light, 0f, 5f) && Between(Range, 2f, 12f) && Between(Glow, 0f, 8f)) { return Between(Volume, 0f, 1f); } return false; } } public FeatureSettings Copy() { return (FeatureSettings)MemberwiseClone(); } private static bool Between(float v, float a, float b) { if (!float.IsNaN(v) && !float.IsInfinity(v) && v >= a) { return v <= b; } return false; } public string Encode() { return string.Join("|", "1", Light.ToString("R", CultureInfo.InvariantCulture), Range.ToString("R", CultureInfo.InvariantCulture), Glow.ToString("R", CultureInfo.InvariantCulture), Volume.ToString("R", CultureInfo.InvariantCulture), Flow ? "1" : "0"); } public static bool TryDecode(string raw, out FeatureSettings s) { s = new FeatureSettings(); if (string.IsNullOrEmpty(raw)) { return true; } string[] array = raw.Split('|'); if (array.Length != 6 || array[0] != "1") { return false; } if (float.TryParse(array[1], NumberStyles.Float, CultureInfo.InvariantCulture, out s.Light) && float.TryParse(array[2], NumberStyles.Float, CultureInfo.InvariantCulture, out s.Range) && float.TryParse(array[3], NumberStyles.Float, CultureInfo.InvariantCulture, out s.Glow) && float.TryParse(array[4], NumberStyles.Float, CultureInfo.InvariantCulture, out s.Volume) && (array[5] == "0" || array[5] == "1") && SetFlow(s, array[5])) { return s.Valid; } return false; } private static bool SetFlow(FeatureSettings s, string value) { s.Flow = value == "1"; return true; } } internal static class GardenAudio { private static readonly Dictionary<int, AudioClip> Clips = new Dictionary<int, AudioClip>(); internal static AudioClip Get(int number) { if (number < 1 || number > 10) { return null; } if (Clips.TryGetValue(number, out var value)) { return value; } try { string text = number switch { 8 => "fountain_001", 9 => "waterfall_001", 10 => "waterfall_002", _ => $"night_ambience_{number:000}", }; using BinaryReader binaryReader = new BinaryReader(typeof(Plugin).Assembly.GetManifestResourceStream("WaterGardens.Audio." + text + ".wav") ?? throw new FileNotFoundException("Embedded recording missing: " + text)); if (new string(binaryReader.ReadChars(4)) != "RIFF") { throw new InvalidDataException("RIFF expected"); } binaryReader.ReadInt32(); if (new string(binaryReader.ReadChars(4)) != "WAVE") { throw new InvalidDataException("WAVE expected"); } int num = 0; int num2 = 0; int num3 = 0; int num4 = 0; byte[] array = null; while (binaryReader.BaseStream.Position + 8 <= binaryReader.BaseStream.Length) { string text2 = new string(binaryReader.ReadChars(4)); int num5 = binaryReader.ReadInt32(); long num6 = binaryReader.BaseStream.Position + num5; if (num5 < 0 || num6 > binaryReader.BaseStream.Length) { throw new InvalidDataException("Truncated WAV"); } if (text2 == "fmt ") { num4 = binaryReader.ReadInt16(); num2 = binaryReader.ReadInt16(); num = binaryReader.ReadInt32(); binaryReader.ReadInt32(); binaryReader.ReadInt16(); num3 = binaryReader.ReadInt16(); } if (text2 == "data") { array = binaryReader.ReadBytes(num5); } binaryReader.BaseStream.Position = num6 + num5 % 2; } if (num4 != 1 || num2 != 1 || num3 != 16 || num <= 0 || array == null) { throw new InvalidDataException("Expected mono 16-bit PCM"); } float[] array2 = new float[array.Length / 2]; double num7 = 0.0; float num8 = 0f; for (int i = 0; i < array2.Length; i++) { array2[i] = (float)(short)(array[i * 2] | (array[i * 2 + 1] << 8)) / 32768f; num7 += (double)(array2[i] * array2[i]); num8 = Math.Max(num8, Math.Abs(array2[i])); } double val = Math.Sqrt(num7 / (double)Math.Max(1, array2.Length)); float num9 = (float)Math.Min(24.0, Math.Min(0.08 / Math.Max(1E-06, val), 0.95 / Math.Max(1E-06, num8))); if (number == 9 || number == 10) { num9 = (float)Math.Min(24.0, 0.24 / Math.Max(1E-06, val)); for (int j = 0; j < array2.Length; j++) { array2[j] = 0.95f * (float)Math.Tanh(array2[j] * num9 / 0.95f); } } else { for (int k = 0; k < array2.Length; k++) { array2[k] *= num9; } } Plugin.Log.LogInfo((object)(text + " loaded; loudness gain " + num9.ToString("0.00") + "x")); AudioClip val2 = AudioClip.Create(text, array2.Length, 1, num, false); val2.SetData(array2, 0); Clips[number] = val2; return val2; } catch (Exception ex) { Plugin.Log.LogError((object)("Ambience " + number + ": " + ex.Message)); Clips[number] = null; return null; } } } public sealed class GardenEditor : MonoBehaviour { internal static GardenPiece Target; private static GardenSettings draft; private static bool oldVisible; private static CursorLockMode oldLock; private static PondMenu menu; private static AudioSource preview; private static float previewUntil; internal static bool IsOpen => Object.op_Implicit((Object)(object)Target); internal static void Open(GardenPiece piece) { //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) FeatureEditor.Close(); GardenTreeEditor.Close(); Close(); Target = piece; draft = piece.Settings.Copy(); draft.CopyGroupFrom(PondNetwork.GroupSettings(piece)); oldVisible = Cursor.visible; oldLock = Cursor.lockState; KeepCursor(); menu = new PondMenu(piece, draft, Save, Close); } internal static void Close() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) menu?.Dispose(); menu = null; if (Object.op_Implicit((Object)(object)preview)) { preview.Stop(); } if (Object.op_Implicit((Object)(object)Target)) { Cursor.visible = oldVisible; Cursor.lockState = oldLock; } Target = null; draft = null; } internal static void KeepCursor() { if (IsOpen) { Cursor.visible = true; Cursor.lockState = (CursorLockMode)0; } } private void Update() { if (Object.op_Implicit((Object)(object)preview) && Time.unscaledTime >= previewUntil) { preview.Stop(); } if (IsOpen) { if (!Target.CanEdit() || Input.GetKeyDown((KeyCode)27)) { Close(); } else { KeepCursor(); } } } private void LateUpdate() { KeepCursor(); } private void OnDisable() { Close(); } private static void Save() { if (Object.op_Implicit((Object)(object)Target) && Target.Save(draft)) { Close(); return; } Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)2, RunicText.Get("text_55c069c39dad"), 0, (Sprite)null, false); } } internal static void TestSound(GardenSettings settings) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) if (settings.Track == 0) { Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)2, RunicText.Get("text_4f7f167be4f3"), 0, (Sprite)null, false); } return; } if (!Object.op_Implicit((Object)(object)preview)) { preview = new GameObject("WaterGardens sound preview").AddComponent<AudioSource>(); Object.DontDestroyOnLoad((Object)(object)((Component)preview).gameObject); preview.playOnAwake = false; preview.spatialBlend = 0f; } preview.Stop(); preview.clip = GardenAudio.Get(settings.Track); preview.volume = settings.Volume * Plugin.MasterVolume.Value; preview.pitch = settings.Speed; preview.loop = false; previewUntil = Time.unscaledTime + 6f; preview.Play(); } private void OnDestroy() { if (Object.op_Implicit((Object)(object)preview)) { Object.Destroy((Object)(object)((Component)preview).gameObject); } preview = null; } private static float Snap(float value, float step) { return Mathf.Round(value / step) * step; } } [HarmonyPatch(typeof(GameCamera), "UpdateMouseCapture")] internal static class GardenCursor { private static void Postfix() { GardenEditor.KeepCursor(); FeatureEditor.KeepCursor(); GardenTreeEditor.KeepCursor(); } } [HarmonyPatch(typeof(ZInput), "GetKeyDown", new Type[] { typeof(KeyCode), typeof(bool) })] internal static class GardenEscape { private static void Postfix(KeyCode key, ref bool __result) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 if ((int)key == 27 && GardenMenuCursor.IsOpen) { __result = false; } } } public sealed class GardenFeature : MonoBehaviour, Hoverable, Interactable { public int Kind; public float ModelHeight; internal FeatureSettings Settings = new FeatureSettings(); private ZNetView view; private Light lamp; private AudioSource waterSound; private Material flameMaterial; private MeshRenderer model; private MeshRenderer flame; private MaterialPropertyBlock block; private string last; private float poll; private float deadline; private FeatureSettings pending; private bool built; private readonly List<WaterFlow> flows = new List<WaterFlow>(); internal bool Fountain { get { if (Kind > 0) { return Kind != 4; } return false; } } internal bool HasGlobe { get { if (Kind >= 1) { return Kind <= 5; } return false; } } internal bool Live { get { if (Object.op_Implicit((Object)(object)view)) { return view.IsValid(); } return false; } } private void Start() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown view = ((Component)this).GetComponent<ZNetView>(); block = new MaterialPropertyBlock(); } internal bool CanEdit() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) if (Live && Object.op_Implicit((Object)(object)Player.m_localPlayer) && Vector3.Distance(((Component)Player.m_localPlayer).transform.position, ((Component)this).transform.position) < 8f) { return PrivateArea.CheckAccess(((Component)this).transform.position, 0f, false, false); } return false; } internal bool Save(FeatureSettings settings) { if (!settings.Valid || !CanEdit()) { return false; } pending = settings.Copy(); deadline = Time.time + 5f; view.ClaimOwnership(); return true; } private void Update() { //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Invalid comparison between Unknown and I4 //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: 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) if (!Live) { return; } if (pending != null) { if (!CanEdit() || Time.time > deadline) { pending = null; } else if (view.IsOwner()) { view.GetZDO().Set("wg_feature_settings", pending.Encode()); pending = null; poll = 0f; } } if (Time.time >= poll) { poll = Time.time + 0.5f; string text = view.GetZDO().GetString("wg_feature_settings", ""); if (text == "" && view.IsOwner()) { text = Settings.Encode(); view.GetZDO().Set("wg_feature_settings", text); } if (text != last && FeatureSettings.TryDecode(text, out var s)) { Settings = s; last = text; } } if ((int)SystemInfo.graphicsDeviceType == 4) { return; } if (!built) { Build(); } bool flag = Object.op_Implicit((Object)(object)Player.m_localPlayer) && Vector3.Distance(((Component)Player.m_localPlayer).transform.position, ((Component)this).transform.position) < 45f; Color val = ((Kind == -1) ? new Color(1f, 0.65f, 0.25f) : ((Kind == 1 || Kind == 5) ? new Color(0.25f, 1f, 0.7f) : ((Kind == 4) ? new Color(1f, 0.75f, 0.2f) : new Color(0.65f, 0.4f, 1f)))); if (Object.op_Implicit((Object)(object)lamp)) { ((Behaviour)lamp).enabled = flag && Settings.Light > 0f; lamp.color = val; lamp.intensity = Settings.Light; lamp.range = Settings.Range; } if (Object.op_Implicit((Object)(object)model)) { ((Renderer)model).GetPropertyBlock(block); block.SetColor("_EmissionColor", Color.white * Settings.Glow); ((Renderer)model).SetPropertyBlock(block); } if (Object.op_Implicit((Object)(object)flame)) { ((Renderer)flame).enabled = Settings.Glow > 0f; flameMaterial.SetColor("_EmissionColor", val * Settings.Glow); } if (Object.op_Implicit((Object)(object)waterSound)) { waterSound.volume = Mathf.MoveTowards(waterSound.volume, flag ? Settings.Volume : 0f, Time.deltaTime * 0.7f); if (flag && Settings.Volume > 0f) { if (!Object.op_Implicit((Object)(object)waterSound.clip)) { waterSound.clip = GardenAudio.Get(8); } if (Object.op_Implicit((Object)(object)waterSound.clip) && !waterSound.isPlaying) { waterSound.Play(); } } else if (waterSound.volume < 0.001f) { waterSound.Stop(); } } foreach (WaterFlow flow in flows) { if (Object.op_Implicit((Object)(object)flow)) { ((Component)flow).gameObject.SetActive(flag && Settings.Flow); } } } private void Build() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: 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_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Expected O, but got Unknown //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Expected O, but got Unknown //IL_01dd: 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_027b: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_032b: 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_0335: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Expected O, but got Unknown //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_024f: 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_0479: 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_03f7: Unknown result type (might be due to invalid IL or missing references) //IL_03fe: Unknown result type (might be due to invalid IL or missing references) //IL_0403: Unknown result type (might be due to invalid IL or missing references) //IL_0417: Unknown result type (might be due to invalid IL or missing references) //IL_041c: Unknown result type (might be due to invalid IL or missing references) //IL_0423: Unknown result type (might be due to invalid IL or missing references) //IL_0428: Unknown result type (might be due to invalid IL or missing references) //IL_04a2: Unknown result type (might be due to invalid IL or missing references) //IL_04b6: 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_04e9: Unknown result type (might be due to invalid IL or missing references) built = true; model = ((Component)((Component)this).transform.Find("garden_visual")).GetComponentInChildren<MeshRenderer>(); if (HasGlobe || Kind == -1) { GameObject val = new GameObject("garden_light"); val.transform.SetParent(((Component)this).transform.Find("garden_visual"), false); val.transform.localPosition = ((Kind == -1) ? new Vector3(0f, 0.61f, 0f) : ((Kind == 1) ? new Vector3(-0.005f, 0.799f, -0.031f) : ((Kind == 4) ? new Vector3(-0.145f, 0.78f, 0f) : ((Kind == 5) ? new Vector3(0f, 0.748f, 0.229f) : new Vector3(-0.003f, 0.6f, -0.002f))))) * ModelHeight; lamp = val.AddComponent<Light>(); lamp.type = (LightType)2; lamp.shadows = (LightShadows)0; if (Kind == -1) { GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)0); ((Object)val2).name = "lantern_warm_glow"; Object.Destroy((Object)(object)val2.GetComponent<Collider>()); val2.transform.SetParent(val.transform, false); val2.transform.localScale = Vector3.one * 0.1f; flame = val2.GetComponent<MeshRenderer>(); flameMaterial = new Material(((Renderer)model).sharedMaterial); flameMaterial.mainTexture = (Texture)(object)Texture2D.whiteTexture; flameMaterial.SetTexture("_EmissiveTex", (Texture)(object)Texture2D.whiteTexture); flameMaterial.SetColor("_Color", new Color(1f, 0.6f, 0.15f)); ((Renderer)flame).sharedMaterial = flameMaterial; } } if (!Fountain) { return; } GameObject val3 = new GameObject("fountain_audio"); val3.transform.SetParent(((Component)this).transform.Find("garden_visual"), false); val3.transform.localPosition = ((Kind == 1) ? new Vector3(0f, 0.55f, 0f) : ((Kind == 5) ? new Vector3(0f, 0.47f, 0.34f) : new Vector3(0f, 0.29f, 0f))) * ModelHeight; waterSound = val3.AddComponent<AudioSource>(); waterSound.playOnAwake = false; waterSound.loop = true; waterSound.spatialBlend = 1f; waterSound.rolloffMode = (AudioRolloffMode)2; waterSound.SetCustomCurve((AudioSourceCurveType)0, new AnimationCurve((Keyframe[])(object)new Keyframe[4] { new Keyframe(0f, 1f), new Keyframe(0.15f, 0.6f), new Keyframe(0.4f, 0.18f), new Keyframe(1f, 0f) })); waterSound.minDistance = 0.6f; waterSound.maxDistance = 10f; waterSound.spread = 0f; waterSound.reverbZoneMix = 0f; waterSound.volume = 0f; waterSound.dopplerLevel = 0f; if (Kind == 1) { Vector3 val4 = default(Vector3); for (int i = 0; i < 4; i++) { float num = (float)i * MathF.PI * 0.5f + 0.4f; ((Vector3)(ref val4))..ctor(Mathf.Cos(num), 0f, Mathf.Sin(num)); AddFlow(new Vector3(-0.005f, 0.7f, -0.031f) + val4 * 0.13f, new Vector3(-0.005f, 0.553f, -0.031f) + val4 * 0.2f, 0.017f); } } else if (Kind == 2 || Kind == 3) { AddFlow(new Vector3(-0.008f, 0.478f, -0.015f), new Vector3(-0.008f, 0.292f, -0.04f), 0.024f); } else if (Kind == 5) { AddFlow(new Vector3(-0.08f, 0.64f, 0.305f), new Vector3(-0.08f, 0.475f, 0.345f), 0.015f); AddFlow(new Vector3(0.08f, 0.64f, 0.305f), new Vector3(0.08f, 0.475f, 0.345f), 0.015f); } } private void AddFlow(Vector3 start, Vector3 finish, float radius) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_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_0055: Unknown result type (might be due to invalid IL or missing references) flows.Add(WaterFlow.Create(((Component)this).transform.Find("garden_visual"), (start - Vector3.right * radius) * ModelHeight, (start + Vector3.right * radius) * ModelHeight, finish * ModelHeight, waterfall: false)); } public string GetHoverName() { if (Kind != 4) { if (!Fountain) { return RunicText.Get("text_0961a763d612"); } return RunicText.Get("text_6a84e2bf653c") + Kind; } return RunicText.Get("text_79eafab85a1b"); } public float GetHoverOffset() { return 0f; } public string GetHoverText() { return GetHoverName() + RunicText.Get("text_a2b67a1fd860"); } public bool Interact(Humanoid user, bool hold, bool alt) { if (hold || (Object)(object)user != (Object)(object)Player.m_localPlayer || !CanEdit()) { return false; } FeatureEditor.Open(this); return true; } public bool UseItem(Humanoid user, ItemData item) { return false; } private void OnDestroy() { if ((Object)(object)FeatureEditor.Target == (Object)(object)this) { FeatureEditor.Close(); } if (Object.op_Implicit((Object)(object)flameMaterial)) { Object.Destroy((Object)(object)flameMaterial); } } } public sealed class GardenFloat : MonoBehaviour { public int Kind; private Transform visual; private Vector3 rest; private float rockCenter; private void Awake() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00af: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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) visual = ((Component)this).transform.Find("garden_visual"); if (!Object.op_Implicit((Object)(object)visual)) { return; } rest = visual.localPosition; float num = float.PositiveInfinity; float num2 = float.NegativeInfinity; MeshFilter[] componentsInChildren = ((Component)visual).GetComponentsInChildren<MeshFilter>(true); foreach (MeshFilter val in componentsInChildren) { if (Object.op_Implicit((Object)(object)val.sharedMesh)) { Bounds bounds = val.sharedMesh.bounds; for (int j = 0; j < 8; j++) { Vector3 val2 = ((Bounds)(ref bounds)).center + Vector3.Scale(((Bounds)(ref bounds)).extents, new Vector3((float)(((j & 1) != 0) ? 1 : (-1)), (float)(((j & 2) != 0) ? 1 : (-1)), (float)(((j & 4) != 0) ? 1 : (-1)))); float y = ((Component)this).transform.InverseTransformPoint(((Component)val).transform.TransformPoint(val2)).y; num = Mathf.Min(num, y); num2 = Mathf.Max(num2, y); } } } if (!float.IsInfinity(num)) { rockCenter = (num + num2) * 0.5f; } } internal bool Floating(GardenPiece pond) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) GardenSettings gardenSettings = RiverGardens.SettingsAt(((Component)this).transform.position) ?? (Object.op_Implicit((Object)(object)pond) ? PondNetwork.GroupSettings(pond) : new GardenSettings()); if (Kind != 0 && (Kind != 1 || !gardenSettings.FloatLanterns) && (Kind != 2 || !gardenSettings.FloatFountains)) { if (Kind == 3) { return gardenSettings.FloatStatues; } return false; } return true; } internal float Height() { //IL_0006: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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) GardenPiece pond = PondNetwork.At(((Component)this).transform.position); float num = LilyFloat.WaterAt(((Component)this).transform.position); float num2 = default(float); bool height = Heightmap.GetHeight(((Component)this).transform.position, ref num2); if (num > -1000f && (!height || num > num2 + 0.02f) && Floating(pond)) { if (Kind != 0) { return num + 0.015f; } return num - rockCenter * ((Component)this).transform.lossyScale.y; } float result = default(float); if (Heightmap.GetHeight(((Component)this).transform.position, ref result)) { return result; } return ((Component)this).transform.position.y; } internal void PlaceGhost() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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) Vector3 position = ((Component)this).transform.position; position.y = Height(); ((Component)this).transform.position = position; if (Object.op_Implicit((Object)(object)visual)) { visual.localPosition = rest; } } private void LateUpdate() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)visual) && Object.op_Implicit((Object)(object)ZoneSystem.instance)) { Vector3 position = visual.position; position.y = Height() + rest.y; visual.position = position; } } } public sealed class GardenFlowerScale : MonoBehaviour { private Transform visual; private Vector3 scale; private float next; private void Start() { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) visual = ((Component)this).transform.Find("lily_visual/floating_lily"); if (!Object.op_Implicit((Object)(object)visual)) { visual = ((Component)this).transform.Find("garden_visual"); } if (Object.op_Implicit((Object)(object)visual)) { scale = visual.localScale; } } private void Update() { //IL_0032: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)visual) && !(Time.time < next)) { next = Time.time + 0.5f; GardenPiece gardenPiece = PondNetwork.At(((Component)this).transform.position); visual.localScale = scale * (RiverGardens.SettingsAt(((Component)this).transform.position)?.FlowerScale ?? (Object.op_Implicit((Object)(object)gardenPiece) ? PondNetwork.GroupSettings(gardenPiece).FlowerScale : 0.5f)); } } } internal static class GardenFlora { internal static void RegisterAll() { Plant("grass_plains_gold", GardenLanguage.Token("text_e49cfd9c9343"), "instanced_heathgrass", 1.5f, 1.35f); Plant("grass_plains_green", GardenLanguage.Token("text_73f0b3c64655"), "grasscross_heath_green", 1.3f, 1.15f); Plant("grass_blackforest", GardenLanguage.Token("text_1392e24d496e"), "instanced_meadows_grass", 1.5f, 1.3f); Plant("bush_forest", GardenLanguage.Token("text_b51a7cb6d769"), "Bush01", 1.7f, 1.4f); Plant("bush_plains", GardenLanguage.Token("text_53d43f87f970"), "Bush01_heath", 1.7f, 1.3f); Plant("yggdrasil_001", GardenLanguage.Token("text_e78107033b90"), "YggaShoot1", 0f, 10f, tree: true); Plant("yggdrasil_002", GardenLanguage.Token("text_35281087dcb1"), "YggaShoot2", 0f, 12f, tree: true); Plant("yggdrasil_003", GardenLanguage.Token("text_d198b32ba85b"), "YggaShoot3", 0f, 14f, tree: true); } private static void Plant(string id, string name, string source, float width, float height, bool tree = false) { try { GameObject prefab = PrefabManager.Instance.GetPrefab(source); if (!Object.op_Implicit((Object)(object)prefab)) { throw new Exception("Missing native prefab " + source); } GameObject val = GardenPrefabs.Root("piece_arcanedecor_" + id, name, ""); Transform val2 = val.transform.Find("garden_visual"); GardenPrefabs.AddVisual(prefab, val2, width, solid: false, null, height, tree); if (!tree) { ((Component)val2).gameObject.AddComponent<PlantTouch>(); } else { val.AddComponent<GardenTree>(); } val.AddComponent<GardenWind>().Strength = (tree ? 0.009f : 0.035f); GardenIcons.Assign(val, ((Component)val2).gameObject, lily: false, id.StartsWith("bush_") ? 0.6f : 1f); GardenPrefabs.Register(val, name, tree ? GardenLanguage.Token("text_b4db4e75bd08") : GardenLanguage.Token("text_649ff9e7a9f6"), tree ? 10 : 2); } catch (Exception ex) { Plugin.Log.LogError((object)(name + ": " + ex)); } } } internal static class GardenHealth { internal static bool IsPreviouslyRemoved(float health) { return health == 0f; } } internal static class GardenIcons { private static Sprite serverIcon; private static bool AssignServerIcon(GameObject root) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_0057: Expected O, but got Unknown if ((int)SystemInfo.graphicsDeviceType != 4) { return false; } if (!Object.op_Implicit((Object)(object)serverIcon)) { serverIcon = Sprite.Create(new Texture2D(2, 2, (TextureFormat)4, false) { name = "WaterGardens server icon" }, new Rect(0f, 0f, 2f, 2f), new Vector2(0.5f, 0.5f)); } root.GetComponent<Piece>().m_icon = serverIcon; return true; } internal static void Assign(GameObject root, GameObject visual, bool lily = false, float distance = 1f) { //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_024f: 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_0265: 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_0269: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Expected O, but got Unknown //IL_00c8: 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_00d1: 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_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: 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_01f5: Expected O, but got Unknown //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) if (AssignServerIcon(root)) { return; } GameObject val = null; List<Mesh> list = new List<Mesh>(); try { val = Object.Instantiate<GameObject>(visual); ((Object)val).name = ((Object)root).name + "_icon"; PlantTouch[] componentsInChildren = val.GetComponentsInChildren<PlantTouch>(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren[i]); } val.SetActive(true); if (lily) { MeshFilter[] componentsInChildren2 = val.GetComponentsInChildren<MeshFilter>(true); foreach (MeshFilter val2 in componentsInChildren2) { if (((Object)val2).name != "vanilla_waterlilies") { continue; } Mesh sharedMesh = val2.sharedMesh; Vector3[] vertices = sharedMesh.vertices; Vector3[] normals = sharedMesh.normals; Vector2[] uv = sharedMesh.uv; List<Vector3> list2 = new List<Vector3>(); List<Vector3> list3 = new List<Vector3>(); List<Vector2> list4 = new List<Vector2>(); List<int> list5 = new List<int>(); Bounds bounds = sharedMesh.bounds; float num = ((Bounds)(ref bounds)).max.y - 0.08f / Mathf.Max(0.001f, ((Component)val2).transform.lossyScale.y); int[] triangles = sharedMesh.triangles; for (int j = 0; j < triangles.Length; j += 3) { if (!(vertices[triangles[j]].y < num) && !(vertices[triangles[j + 1]].y < num) && !(vertices[triangles[j + 2]].y < num)) { for (int k = 0; k < 3; k++) { int num2 = triangles[j + k]; list5.Add(list2.Count); list2.Add(vertices[num2]); list3.Add(normals[num2]); list4.Add(uv[num2]); } } } if (list5.Count == 0) { throw new Exception("No leaf triangles in " + ((Object)root).name); } Mesh val3 = new Mesh { name = "Leaf canopy thumbnail", indexFormat = (IndexFormat)1 }; val3.SetVertices(list2); val3.SetNormals(list3); val3.SetUVs(0, list4); val3.SetTriangles(list5, 0); val3.RecalculateBounds(); list.Add(val3); val2.sharedMesh = val3; } } Sprite val4 = RenderManager.Instance.Render(new RenderRequest(val) { Width = 128, Height = 128, Rotation = (lily ? Quaternion.Euler(65f, 20f, 0f) : RenderManager.IsometricRotation), DistanceMultiplier = distance, ParticleSimulationTime = -1f, UseCache = false }); if (!Object.op_Implicit((Object)(object)val4)) { throw new Exception("Empty icon render for " + ((Object)root).name); } root.GetComponent<Piece>().m_icon = val4; } catch (Exception ex) { Plugin.Log.LogError((object)("Garden icon: " + ex)); } finally { if (Object.op_Implicit((Object)(object)val)) { Object.DestroyImmediate((Object)(object)val); } foreach (Mesh item in list) { Object.DestroyImmediate((Object)(object)item); } } } internal static void Pond(GameObject root, int shape) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Expected O, but got Unknown //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Expected O, but got Unknown //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_023a: 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_0249: 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_0258: Unknown result type (might be due to invalid IL or missing references) if (AssignServerIcon(root)) { return; } GameObject val = new GameObject("pond_thumbnail"); List<Object> list = new List<Object>(); try { Vector3[] array = (Vector3[])(object)new Vector3[65]; Vector2[] array2 = (Vector2[])(object)new Vector2[65]; int[] array3 = new int[192]; for (int i = 0; i < 64; i++) { double num = (double)i * Math.PI * 2.0 / 64.0; float num2 = (float)PondMath.Radius(shape, num) * 3f; array[i + 1] = new Vector3((float)Math.Cos(num) * num2, 0f, (float)Math.Sin(num) * num2 * (float)PondMath.Aspect(shape)); array2[i + 1] = new Vector2(array[i + 1].x, array[i + 1].z); array3[i * 3] = 0; array3[i * 3 + 1] = (i + 1) % 64 + 1; array3[i * 3 + 2] = i + 1; } Mesh val2 = new Mesh { vertices = array, triangles = array3, uv = array2 }; val2.RecalculateNormals(); list.Add((Object)(object)val2); Material val3 = new Material(((Renderer)GardenPrefabs.Rock.GetComponentInChildren<MeshRenderer>(true)).sharedMaterial); val3.mainTexture = (Texture)(object)Texture2D.whiteTexture; val3.SetColor("_Color", new Color(0.16f, 0.48f, 0.53f)); string[] array4 = new string[4] { "_MossAlpha", "_MossBlend", "_BumpScale", "_TriplanarMap" }; foreach (string text in array4) { if (val3.HasProperty(text)) { val3.SetFloat(text, 0f); } } list.Add((Object)(object)val3); GameObject val4 = new GameObject("water"); val4.transform.SetParent(val.transform, false); val4.AddComponent<MeshFilter>().sharedMesh = val2; ((Renderer)val4.AddComponent<MeshRenderer>()).sharedMaterial = val3; for (int k = 0; k < 64; k += 4) { GardenPrefabs.AddVisual(GardenPrefabs.Rock, val.transform, 0.48f, solid: true).transform.localPosition = array[k + 1] * 1.06f + Vector3.down * 0.14f; } Assign(root, val, lily: true); } finally { Object.DestroyImmediate((Object)(object)val); foreach (Object item in list) { Object.DestroyImmediate(item); } } } } public interface IGardenController { string PoolName { get; } void ConfigureDefaults(GardenSettings settings); bool OpenMenu(); void BuildLiquid(Transform surface, MeshRenderer renderer); } public static class GardenIntegration { public static GardenSettings Settings(GardenPiece pond) { return pond.Settings.Copy(); } public static GardenSettings GroupSettings(GardenPiece pond) { return PondNetwork.GroupSettings(pond).Copy(); } public static bool IsLive(GardenPiece pond) { if (Object.op_Implicit((Object)(object)pond)) { return pond.Live; } return false; } public static bool CanEdit(GardenPiece pond) { if (Object.op_Implicit((Object)(object)pond)) { return pond.CanEdit(); } return false; } public static bool Save(GardenPiece pond, GardenSettings settings) { if (Object.op_Implicit((Object)(object)pond)) { return pond.Save(settings); } return false; } public static bool Save(GardenPiece pond, GardenSettings settings, string controllerData) { if (controllerData == null || controllerData.Length > 256 || !Save(pond, settings)) { return false; } pond.PendingControllerData = controllerData; return true; } public static float WaterHeight(GardenPiece pond) { return pond.WaterHeight; } public static float WaterLevel(Vector3 point) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return PondNetwork.WaterLevel(point); } public static float Distance(GardenPiece pond, Vector3 world) { //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) //IL_000c: 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_001a: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)pond).transform.InverseTransformPoint(world); return (float)PondMath.Distance(pond.Shape, val.x, val.z, pond.Settings.Width); } public static Vector3 Boundary(int shape, float width, float angle, float fraction) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) float num = (float)PondMath.Radius(shape, angle) * width * 0.5f * fraction; return new Vector3(Mathf.Cos(angle) * num, 0f, Mathf.Sin(angle) * num * (float)PondMath.Aspect(shape)); } public static GameObject WhiteSittingStone(Transform parent) { return GardenModels.Model("rock_001", parent, 1f, solid: false); } public static void CloseEditors() { GardenEditor.Close(); FeatureEditor.Close(); GardenTreeEditor.Close(); } } internal static class GardenLanguage { internal static string Token(string key) { return "$arcanedecor_watergardens_" + key; } internal static void Load() { Assembly assembly = typeof(Plugin).Assembly; string text; using (Stream stream = assembly.GetManifestResourceStream("Runic.Localization.English.json")) { using StreamReader streamReader = new StreamReader(stream); text = streamReader.ReadToEnd(); } Dictionary<string, string> entries = LanguageCatalog.Parse(text); string directory = Path.Combine(Path.GetDirectoryName(assembly.Location), "Translations", assembly.GetName().Name); LanguageCatalog catalog = new LanguageCatalog(text, (string language) => File.ReadAllText(Path.Combine(directory, language + ".json"))); CustomLocalization localization = LocalizationManager.Instance.GetLocalization(); Add("English"); if (Directory.Exists(directory)) { string[] files = Directory.GetFiles(directory, "*.json"); foreach (string path in files) { Add(Path.GetFileNameWithoutExtension(path)); } } void Add(string language) { catalog.Select(language); string text2; foreach (KeyValuePair<string, string> item in entries) { CustomLocalization obj = localization; text2 = Token(item.Key).Substring(1); obj.AddTranslation(ref language, ref text2, catalog.Get(item.Key)); } CustomLocalization obj2 = localization; text2 = "jotunn_cat_water_garden"; obj2.AddTranslation(ref language, ref text2, catalog.Get("menu_water_garden")); } } } public sealed class GardenLifecycle : MonoBehaviour { internal static void Configure(GameObject root, GameObject visual) { WearNTear component = root.GetComponent<WearNTear>(); component.m_new = (component.m_worn = (component.m_broken = visual)); component.m_wet = null; component.m_snow = (component.m_snowWorn = (component.m_snowBroken = null)); component.m_autoCreateFragments = false; component.m_fragmentRoots = Array.Empty<GameObject>(); component.m_nonSolidRenderers.Clear(); component.m_noSupportWear = (component.m_noRoofWear = false); root.GetComponent<Piece>().m_canBeRemoved = true; root.AddComponent<GardenLifecycle>(); } private void Start() { ((MonoBehaviour)this).InvokeRepeating("CleanupPreviouslyRemoved", 0f, 0.5f); } private void CleanupPreviouslyRemoved() { ZNetView component = ((Component)this).GetComponent<ZNetView>(); if (!Object.op_Implicit((Object)(object)component) || !component.IsValid()) { ((MonoBehaviour)this).CancelInvoke(); } else if (component.IsOwner() && GardenHealth.IsPreviouslyRemoved(component.GetZDO().GetFloat(ZDOVars.s_health, 1f)) && Object.op_Implicit((Object)(object)ZNetScene.instance)) { ZNetScene.instance.Destroy(((Component)this).gameObject); } } } public sealed class GardenMenuCursor : MonoBehaviour { [CompilerGenerated] private static class <>O { public static WillRenderCanvases <0>__Keep; } private static int openCount; public static bool IsOpen => openCount > 0; private void OnEnable() { //IL_001c: 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_0027: Expected O, but got Unknown openCount++; object obj = <>O.<0>__Keep; if (obj == null) { WillRenderCanvases val = Keep; <>O.<0>__Keep = val; obj = (object)val; } Canvas.willRenderCanvases += (WillRenderCanvases)obj; Keep(); } private void OnDisable() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown openCount = Mathf.Max(0, openCount - 1); object obj = <>O.<0>__Keep; if (obj == null) { WillRenderCanvases val = Keep; <>O.<0>__Keep = val; obj = (object)val; } Canvas.willRenderCanvases -= (WillRenderCanvases)obj; } private void LateUpdate() { Keep(); } public static void Keep() { if (IsOpen) { ZCursor.LockState = (CursorLockMode)0; ZCursor.Show(); Cursor.visible = true; } } } [HarmonyPatch(typeof(GameCamera), "UpdateMouseCapture")] internal static class GardenMenuCapture { [HarmonyPriority(0)] private static void Postfix() { GardenMenuCursor.Keep(); } } internal static class GardenModels { internal sealed class Data { public Mesh Mesh; public Material Material; public Sprite Icon; } private static readonly Dictionary<string, Data> Cache = new Dictionary<string, Data>(); private static bool IsPlant(string id) { if (!(id == "cattail_001") && !id.StartsWith("fern_") && !id.StartsWith("fauna_") && !id.StartsWith("reeds_") && !id.StartsWith("glowshrooms_") && !id.StartsWith("bluelilly_") && !id.StartsWith("blueiris_")) { return id.StartsWith("whitelilly_"); } return true; } private static Stream Open(string name) { return typeof(Plugin).Assembly.GetManifestResourceStream("WaterGardens.Models." + name); } private static Texture2D Texture(string name) { //IL_001d: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0040: Expected O, but got Unknown using Stream stream = Open(name); if (stream == null) { return null; } using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); Texture2D val = new Texture2D(2, 2) { name = name }; if (!ImageConversion.LoadImage(val, memoryStream.ToArray(), true)) { throw new Exception(name); } return val; } internal static Data Load(string id) { //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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_0102: 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_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Expected O, but got Unknown //IL_0168: 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_0179: Expected O, but got Unknown //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_0255: 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_02cc: Unknown result type (might be due to invalid IL or missing references) if (Cache.TryGetValue(id, out var value)) { return value; } value = new Data(); using (BinaryReader binaryReader = new BinaryReader(Open(id + ".meshbin"))) { if (binaryReader.ReadInt32() != 1464290609) { throw new InvalidDataException(id); } int num = binaryReader.ReadInt32(); int num2 = binaryReader.ReadInt32(); Vector3[] array = (Vector3[])(object)new Vector3[num]; Vector3[] array2 = (Vector3[])(object)new Vector3[num]; Vector2[] array3 = (Vector2[])(object)new Vector2[num]; int[] array4 = new int[num2]; for (int i = 0; i < num; i++) { array[i] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); array2[i] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); array3[i] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle()); } for (int j = 0; j < num2; j++) { array4[j] = binaryReader.ReadInt32(); } value.Mesh = new Mesh { name = id, indexFormat = (IndexFormat)1, vertices = array, normals = array2, uv = array3, triangles = array4 }; value.Mesh.RecalculateBounds(); value.Mesh.RecalculateTangents(); } value.Material = new Material(((Renderer)GardenPrefabs.Rock.GetComponentInChildren<MeshRenderer>(true)).sharedMaterial) { name = id }; value.Material.mainTexture = (Texture)(object)Texture(id + ".jpg"); value.Material.SetColor("_Color", Color.white); string[] array5 = new string[4] { "_TriplanarMap", "_MossAlpha", "_MossBlend", "_BumpScale" }; foreach (string text in array5) { if (value.Material.HasProperty(text)) { value.Material.SetFloat(text, 0f); } } Texture2D val = Texture(id + "_emission.png"); value.Material.SetTexture("_EmissiveTex", (Texture)(object)(Object.op_Implicit((Object)(object)val) ? val : Texture2D.blackTexture)); value.Material.SetColor("_EmissionColor", (id == "glowshrooms_001") ? (new Color(1f, 0.55f, 0.08f) * 2f) : Color.black); if (IsPlant(id)) { GardenWind.ConfigureImported(value.Material); } Texture2D val2 = Texture(id + ".png"); value.Icon = Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), new Vector2(0.5f, 0.5f)); Cache[id] = value; return value; } internal static GameObject Model(string id, Transform parent, float height, bool solid) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: 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_009f: 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_00a7: Unknown result type (might be due to invalid IL or missing references) Data data = Load(id); GameObject val = new GameObject(id) { layer = LayerMask.NameToLayer("piece") }; val.transform.SetParent(parent, false); val.transform.localScale = Vector3.one * height; val.AddComponent<MeshFilter>().sharedMesh = data.Mesh; ((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = data.Material; if (solid) { val.AddComponent<MeshCollider>().sharedMesh = data.Mesh; } else { BoxCollider obj = val.AddComponent<BoxCollider>(); Bounds bounds = data.Mesh.bounds; obj.center = ((Bounds)(ref bounds)).center; bounds = data.Mesh.bounds; obj.size = ((Bounds)(ref bounds)).size; ((Collider)obj).isTrigger = true; } return val; } private static void Static(string id, string asset, string name, float height, int cost, int feature = 0) { bool flag = asset == "cattail_001" || asset.StartsWith("fern_") || asset.StartsWith("fauna_") || asset.StartsWith("reeds_") || asset.StartsWith("glowshrooms_"); GameObject val = GardenPrefabs.Root(id, name, ""); Model(asset, val.transform.Find("garden_visual"), height, !flag); val.GetComponent<Piece>().m_icon = Load(asset).Icon; val.GetComponent<WearNTear>().m_supports = !flag; if (flag) { val.AddComponent<GardenWind>(); } if (flag) { ((Component)val.transform.Find("garden_visual")).gameObject.AddComponent<PlantTouch>(); } if (!flag) { val.AddComponent<GardenFloat>().Kind = ((feature == -1) ? 1 : ((feature == 4) ? 3 : ((feature > 0) ? 2 : 0))); val.GetComponent<Piece>().m_groundOnly = false; } if (feature != 0) { GardenFeature gardenFeature = val.AddComponent<GardenFeature>(); gardenFeature.Kind = feature; gardenFeature.ModelHeight = height; } GardenPrefabs.Register(val, name, (feature == 0) ? GardenLanguage.Token("text_775ddf77b69d") : GardenLanguage.Token("text_87269e395fba"), cost, feature == 3); } internal static void RegisterStatics() { Static("piece_arcanedecor_fern_red_001", "fern_red_001", GardenLanguage.Token("text_4208168eba6d"), 1f, 2); Static("piece_arcanedecor_fern_001", "fern_001", GardenLanguage.Token("text_543795048192"), 1.1f, 2); Static("piece_arcanedecor_fern_002", "fern_002", GardenLanguage.Token("text_e3c6cd4408bb"), 0.8f, 2); Static("piece_arcanedecor_fauna_001", "fauna_001", GardenLanguage.Token("text_102dfbcc80e7"), 0.9f, 2); Static("piece_arcanedecor_glowshrooms_001", "glowshrooms_001", GardenLanguage.Token("text_de08fd38995a"), 0.65f, 2); Static("piece_arcanedecor_reeds_006", "reeds_006", GardenLanguage.Token("text_550f5d04e50b"), 1.3f, 2); Static("piece_arcanedecor_cattail_001", "cattail_001", GardenLanguage.Token("text_4957f6b9dcc1"), 1.6f, 2); Static("piece_arcanedecor_rock_001", "rock_001", GardenLanguage.Token("text_bc0fb957ca78"), 0.45f, 2); Static("piece_arcanedecor_rock_002", "rock_002", GardenLanguage.Token("text_f89d7083b5cb"), 0.3f, 2); Static("piece_arcanedecor_rock_003", "rock_003", GardenLanguage.Token("text_25b6d38fe761"), 0.4f, 2); Static("piece_arcanedecor_mossrock_001", "mossrock_001", GardenLanguage.Token("text_acf3dc50af70"), 0.35f, 2); Static("piece_arcanedecor_mossrock_002", "mossrock_002", GardenLanguage.Token("text_53058b04a3fb"), 0.3f, 2); Static("piece_arcanedecor_lantern_001", "lantern_001", GardenLanguage.Token("text_0961a763d612"), 2.4f, 10, -1); for (int i = 1; i <= 5; i++) { if (i != 3) { Static("piece_arcanedecor_fountain_00" + i, "fountain_00" + i, i switch { 2 => GardenLanguage.Token("piece_fountain_2"), 1 => GardenLanguage.Token("piece_fountain_1"), 4 => GardenLanguage.Token("text_79eafab85a1b"), _ => GardenLanguage.Token("piece_fountain_5"), }, 3f, 20, i); } } } private static void RegisterOriginalLilies() { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0118: 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_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Expected O, but got Unknown //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Expected O, but got Unknown string[] array = new string[4] { "small", "broad", "white", "pink_cluster" }; string[] array2 = new string[4] { GardenLanguage.Token("text_416e68e17069"), GardenLanguage.Token("text_ecb64c23b7d4"), GardenLanguage.Token("text_3aad34cea38b"), GardenLanguage.Token("text_6c0e09413ee2") }; for (int i = 0; i < 4; i++) { GameObject val = GardenPrefabs.Root("piece_runic_lilypad_" + array[i], array2[i], ""); Transform val2 = val.transform.Find("garden_visual"); ((Object)val2).name = "lily_visual"; GameObject val3 = new GameObject("floating_lily"); val3.transform.SetParent(val2, false); val3.AddComponent<PlantTouch>(); val.AddComponent<GardenWind>().Strength = 0.018f; VanillaLilies.Build(val3.transform, i); Piece component = val.GetComponent<Piece>(); component.m_groundOnly = false; component.m_waterPiece = true; val.AddComponent<LilyFloat>(); GardenIcons.Assign(val, ((Component)val2).gameObject, lily: true); PieceConfig val4 = new PieceConfig { Name = array2[i], Description = GardenLanguage.Token("text_85416ebd2722"), PieceTable = "Hammer", Category = "Water Garden" }; val4.AddRequirement("Wood", (i == 3) ? 4 : 2, true); if (i >= 2) { val4.AddRequirement("Dandelion", 1, true); } if (!PieceManager.Instance.AddPiece(new CustomPiece(val, false, val4))) { throw new Exception(((Object)val).name); } } } internal static void RegisterLilies() { //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown //IL_0184: 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_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0225: 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_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Expected O, but got Unknown //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Expected O, but got Unknown //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_035b: 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_036a: Expected O, but got Unknown //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_0392: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Expected O, but got Unknown //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Expected O, but got Unknown if (!VanillaLilies.Load()) { throw new Exception("Native lily base unavailable"); } RegisterOriginalLilies(); string[] array = new string[6] { "blue_001", "blue_002", "white_002", "blue_003", "white_001", "white_003" }; string[] array2 = new string[6] { "bluelilly_001", "blueiris_001", "whitelilly_002", "bluelilly_003", "whitelilly_001", "whitelilly_003" }; string[] array3 = new string[6] { GardenLanguage.Token("text_d79c948d74be"), GardenLanguage.Token("text_45c332271437"), GardenLanguage.Token("text_27c951887acf"), GardenLanguage.Token("text_917ee3ebf289"), GardenLanguage.Token("text_4b31eceaef76"), GardenLanguage.Token("text_d3e94a60aa85") }; for (int i = 0; i < array.Length; i++) { GameObject val = GardenPrefabs.Root("piece_arcanedecor_lily_" + array[i], array3[i], ""); Transform val2 = val.transform.Find("garden_visual"); ((Object)val2).name = "lily_visual"; GameObject val3 = new GameObject("floating_lily"); val3.transform.SetParent(val2, false); val3.AddComponent<PlantTouch>(); val.AddComponent<GardenWind>().Strength = 0.018f; VanillaLilies.Build(val3.transform, 0); int num; switch (i) { default: num = 2; break; case 1: case 2: num = 1; break; case 0: case 4: num = 0; break; } int num2 = num; Transform child = val3.transform.GetChild(0); child.localScale *= num2 switch { 1 => 1.25f, 0 => 0.8f, _ => 1.8f, }; val3.GetComponent<PlantTouch>().Radius = num2 switch { 1 => 0.85f, 0 => 0.65f, _ => 1.05f, }; val.AddComponent<GardenFlowerScale>(); Model(array2[i], val3.transform, num2 switch { 1 => 0.4f, 0 => 0.25f, _ => 0.55f, }, solid: false).transform.localPosition = Vector3.down * ((num2 == 0) ? 0.06f : 0.08f); Piece component = val.GetComponent<Piece>(); component.m_groundOnly = false; component.m_waterPiece = true; val.AddComponent<LilyFloat>(); GardenIcons.Assign(val, ((Component)val2).gameObject, lily: true); PieceConfig val4 = new PieceConfig { Name = array3[i], Description = GardenLanguage.Token("text_067fe535f574"), PieceTable = "Hammer", Category = "Water Garden" }; val4.AddRequirement("Wood", (i == 3) ? 4 : 2, true); if (i >= 2) { val4.AddRequirement("Dandelion", 1, true); } if (!PieceManager.Instance.AddPiece(new CustomPiece(val, false, val4))) { throw new Exception(((Object)val).name); } Plugin.Log.LogInfo((object)("Registered " + ((Object)val).name)); if (i == 4 || i == 5) { GameObject val5 = PrefabManager.Instance.CreateClonedPrefab("piece_runic_lilypad_" + ((i == 4) ? "white_bud" : "white_open"), val); val5.GetComponent<Piece>().m_resources = (Requirement[])(object)new Requirement[2] { new Requirement { m_resItem = PrefabManager.Instance.GetPrefab("Wood").GetComponent<ItemDrop>(), m_amount = 2, m_recover = true }, new Requirement { m_resItem = PrefabManager.Instance.GetPrefab("Dandelion").GetComponent<ItemDrop>(), m_amount = 1, m_recover = true } }; PrefabManager.Instance.AddPrefab(new CustomPrefab(val5, false)); } } } } public sealed class GardenPiece : MonoBehaviour, Hoverable, Interactable { internal static readonly List<GardenPiece> Ponds = new List<GardenPiece>(); public int Shape = -1; internal GardenSettings Settings = new GardenSettings(); private ZNetView view; private GameObject generated; private AudioSource audioSource; private ParticleSystem[] particles = Array.Empty<ParticleSystem>(); private string last = ""; private float check; private int playingTrack = -1; private bool registered; private bool ambienceOn; private GardenSettings pending; private float pendingDeadline; internal string PendingControllerData; private readonly List<Object> assets = new List<Object>(); private readonly List<Object> surfaceAssets = new List<Object>(); internal static readonly List<GardenPiece> Active = new List<GardenPiece>(); internal bool Live { get { if (Object.op_Implicit((Object)(object)view)) { return view.IsValid(); } return false; } } internal bool RiverSection => Object.op_Implicit((Object)(object)((Component)this).GetComponent<RiverGardenSection>()); internal float WaterHeight => ((Component)this).transform.position.y - 0.15f; internal string SoundStatus { get { if (Settings.Track == 0) { return "Sound is off."; } if (Settings.Volume <= 0f || Plugin.MasterVolume.Value <= 0f) { return "Sound is muted (volume is zero)."; } if (AudioListener.volume <= 0f || AudioListener.pause) { return "Game audio is muted or paused."; } if (Settings.NightOnly && !EnvMan.IsNight()) { return "Waiting for night. Turn off Night only and save to play now."; } if (!Object.op_Implicit((Object)(object)audioSource)) { return "Audio source is not ready."; } if (!Object.op_Implicit((Object)(object)audioSource.clip)) { return "Waiting for nearby listener / recording."; } if (!audioSource.isPlaying) { return "Sound is outside its active range."; } return "Playing night_ambience_" + Settings.Track.ToString("000"); } } internal void Own(Object obj) { assets.Add(obj); } internal void OwnSurface(Object obj) { surfaceAssets.Add(obj); } private void ClearSurface() { foreach (Object surfaceAsset in surfaceAssets) { if (Object.op_Implicit(surfaceAsset)) { Object.Destroy(surfaceAsset); } } surfaceAssets.Clear(); } private void Start() { view = ((Component)this).GetComponent<ZNetView>(); Settings = Plugin.DefaultSettings(); ((Component)this).GetComponent<IGardenController>()?.ConfigureDefaults(Settings); Poll(force: true); } private void Update() { //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) if (Time.time >= check) { check = Time.time + 0.5f; Poll(force: false); SettleControlStone(); } if (pending != null) { if (!CanEdit() || Time.time > pendingDeadline) { pending = null; } else if (view.IsOwner()) { view.GetZDO().Set("arcane_garden_settings", pending.Encode()); if (PendingControllerData != null) { view.GetZDO().Set("arcane_pool_controller", PendingControllerData); } PendingControllerData = null; pending = null; Poll(force: true); } } if (!Live || !Object.op_Implicit((Object)(object)Player.m_localPlayer)) { return; } bool flag = Vector3.Distance(((Component)Player.m_localPlayer).transform.position, ((Component)this).transform.position) < Settings.Range + 10f && (!Settings.NightOnly || EnvMan.IsNight()); if (flag != ambienceOn) { ambienceOn = flag; ParticleSystem[] array = particles; foreach (ParticleSystem val in array) { if (flag && Settings.Fireflies > 0) { val.Play(); } else { val.Stop(true, (ParticleSystemStopBehavior)1); } } } if (!Object.op_Implicit((Object)(object)audioSource)) { return; } if (flag && Settings.Track > 0 && playingTrack != Settings.Track) { audioSource.Stop(); audioSource.clip = GardenAudio.Get(Settings.Track); playingTrack = Settings.Track; } float num = ((flag && Settings.Track > 0) ? (Settings.Volume * Plugin.MasterVolume.Value) : 0f); if (flag) { int num2 = 0; foreach (GardenPiece item in Active) { if (Object.op_Implicit((Object)(object)item) && item.Live && item.Settings.Track > 0 && item.Settings.Volume > 0f && (!item.Settings.NightOnly || EnvMan.IsNight()) && Vector3.Distance(((Component)Player.m_localPlayer).transform.position, ((Component)item).transform.position) < item.Settings.Range) { num2++; } } num /= Mathf.Sqrt((float)Mathf.Clamp(num2, 1, 4)); } audioSource.volume = Mathf.MoveTowards(audioSource.volume, num, Time.deltaTime * 0.3f); audioSource.pitch = Settings.Speed; if (flag && Settings.Track > 0 && Object.op_Implicit((Object)(object)audioSource.clip) && !audioSource.isPlaying) { audioSource.Play(); } if ((!flag || Settings.Track == 0) && audioSource.volume <= 0.001f) { audioSource.Stop(); } } private void SettleControlStone() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) if (!Live || Shape < 0) { return; } Transform val = ((Component)this).transform.Find("garden_visual/control_stone"); if (!Object.op_Implicit((Object)(object)val)) { return; } Vector3 position = val.position; if (PondTerrain.Sample(position, out var height)) { position.y = height + 0.015f; Vector3 val2 = val.position - position; if (((Vector3)(ref val2)).sqrMagnitude > 1E-06f) { val.position = position; } } } private void Poll(bool force) { if (!Object.op_Implicit((Object)(object)view)) { return; } if (Live) { if (!registered) { registered = true; Active.Add(this); if (Shape >= 0) { Ponds.Add(this); } } string text = view.GetZDO().GetString("arcane_garden_settings", ""); if (text == "" && view.IsOwner()) { view.GetZDO().Set("arcane_garden_settings", Settings.Encode()); text = Settings.Encode(); } if (!force && !(text != last)) { return; } if (GardenSettings.TryDecode(text, out var s)) { if (text != "") { Settings = s; } last = text; Rebuild(); } else { Plugin.Log.LogWarning((object)"Invalid pond settings retained without applying."); } } else if (!Object.op_Implicit((Object)(object)generated)) { Rebuild(); } } private void Rebuild() { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Invalid comparison between Unknown and I4 //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_028e: 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_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: 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_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) ClearSurface(); if (Object.op_Implicit((Object)(object)generated)) { generated.SetActive(false); Object.Destroy((Object)(object)generated); } foreach (Object asset in assets) { if (Object.op_Implicit(asset)) { Object.Destroy(asset); } } assets.Clear(); generated = new GameObject("garden_generated"); generated.SetActive(false); generated.transform.SetParent(((Component)this).transform, false); if (Shape >= 0) { PondBuilder.Build(this, generated.transform, Live); Transform val = ((Component)this).transform.Find("garden_visual/control_stone"); if (Object.op_Implicit((Object)(object)val)) { val.localPosition = new Vector3((0f - Settings.Width) * 0.57f, 0.02f, 0f); } } if (Live && (int)SystemInfo.graphicsDeviceType != 4) { audioSource = generated.AddComponent<AudioSource>(); audioSource.playOnAwake = false; audioSource.loop = true; audioSource.spatialBlend = 1f; audioSource.rolloffMode = (AudioRolloffMode)1; audioSource.minDistance = 2f; audioSource.maxDistance = Settings.Range; audioSource.volume = 0f; audioSource.dopplerLevel = 0f; playingTrack = -1; if (Object.op_Implicit((Object)(object)GardenPrefabs.Fireflies)) { ParticleSystem componentInChildren = GardenPrefabs.Fireflies.GetComponentInChildren<ParticleSystem>(true); if (Object.op_Implicit((Object)(object)componentInChildren)) { GameObject val2 = Object.Instantiate<GameObject>(((Component)componentInChildren).gameObject, generated.transform, false); val2.transform.localPosition = Vector3.up * 0.8f; MonoBehaviour[] componentsInChildren = val2.GetComponentsInChildren<MonoBehaviour>(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren[i]); } particles = val2.GetComponentsInChildren<ParticleSystem>(true); ParticleSystem[] array = particles; foreach (ParticleSystem val3 in array) { val3.Stop(true, (ParticleSystemStopBehavior)0); MainModule main = val3.main; ((MainModule)(ref main)).loop = true; ((MainModule)(ref main)).playOnAwake = false; ((MainModule)(ref main)).maxParticles = Settings.Fireflies; ((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(6f); ((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)0; ConfigureFireflyColor(val3); EmissionModule emission = val3.emission; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit((float)Settings.Fireflies / 6f); ShapeModule shape = val3.shape; ((ShapeModule)(ref shape)).enabled = true; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)5; ((ShapeModule)(ref shape)).scale = new Vector3(Settings.Width, 0.9f, Settings.Width * (float)PondMath.Aspect(Shape)); if (RiverSection) { ((Component)this).GetComponent<RiverGardenSection>().Configure(val3); } } } } } ambienceOn = false; generated.SetActive(true); if (Shape >= 0 && Live) { PondTerrain.Refresh(((Component)this).transform.position, 18f); PondNetwork.MarkDirty(); } } internal static void ConfigureFireflyColor(ParticleSystem p) { //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) //IL_001d: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_003b: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_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_00c9: 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_00da: 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_00ea: Unknown result type (might be due to invalid IL or missing references) MainModule main = p.main; ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(1f, 0.92f, 0.02f, 1f)); Gradient val = new Gradient(); val.SetKeys((GradientColorKey[])(object)new GradientColorKey[2] { new GradientColorKey(Color.white, 0f), new GradientColorKey(Color.white, 1f) }, (GradientAlphaKey[])(object)new GradientAlphaKey[4] { new GradientAlphaKey(0f, 0f), new GradientAlphaKey(1f, 0.12f), new GradientAlphaKey(1f, 0.8f), new GradientAlphaKey(0f, 1f) }); ColorOverLifetimeModule colorOverLifetime = p.colorOverLifetime; ((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true; ((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val); ColorBySpeedModule colorBySpeed = p.colorBySpeed; ((ColorBySpeedModule)(ref colorBySpeed)).enabled = false; } internal bool CanEdit() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) if (Live && Object.op_Implicit((Object)(object)Player.m_localPlayer) && Vector3.Distance(((Component)Player.m_localPlayer).transform.position, ((Component)this).transform.position) < Settings.Width + 6f) { return PrivateArea.CheckAccess(((Component)this).transform.position, (Shape >= 0) ? (Settings.Width * 0.7f) : 0f, false, false); } return false; } internal bool Save(GardenSettings settings) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) if (RiverSection && !((Component)this).GetComponent<RiverGardenSection>().CanEdit()) { return false; } if (!settings.Valid || !CanEdit() || !PrivateArea.CheckAccess(((Component)this).transform.position, (Shape >= 0) ? (settings.Width * 0.7f) : 0f, true, false)) { return false; } if (Shape >= 0 && !settings.SameGroup(PondNetwork.GroupSettings(this))) { foreach (GardenPiece item in PondNetwork.Group(this)) { if (!PrivateArea.CheckAccess(((Component)item).transform.position, item.Settings.Width * 0.7f, true, false)) { return false; } } settings.GroupRevision = Math.Max(DateTime.UtcNow.Ticks, PondNetwork.GroupSettings(this).GroupRevision + 1); } if (RiverSection) { settings.GroupRevision = Math.Max(DateTime.UtcNow.Ticks, Settings.GroupRevision + 1); } PendingControllerData = null; pending = settings.Copy(); pendingDeadline = Time.time + 5f; view.ClaimOwnership(); return true; } public string GetHoverName() { object obj = ((Component)this).GetComponent<IGardenController>()?.PoolName; if (obj == null) { if (!RiverSection) { if (Shape >= 0) { return RunicText.Get("text_98ab40b0cda3"); } return RunicText.Get("text_c92e4ced068f"); } obj = "River Garden Stone"; } return (string)obj; } public float GetHoverOffset() { return 0f; } public string GetHoverText() { return GetHoverName() + RunicText.Get("text_d5c2bb3c1387"); } public bool Interact(Humanoid user, bool hold, bool alt) { if (hold || (Object)(object)user != (Object)(object)Player.m_localPlayer || !CanEdit()) { return false; } IGardenController component = ((Component)this).GetComponent<IGardenController>(); if (component != null) { return component.OpenMenu(); } GardenEditor.Open(this); return true; } public bool UseItem(Humanoid user, ItemData item) { return false; } internal void SyncGroup(GardenSettings settings) { if (Live && view.IsOwner() && Settings.GroupRevision < settings.GroupRevision) { Settings.CopyGroupFrom