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 Moonasses v0.9.0
plugins/Moonasses.dll
Decompiled 3 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.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("0.0.0.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 Moonasses { internal static class HandVisual { private static readonly HashSet<string> _logged = new HashSet<string>(); private static bool FirstLog(string kind, string prefabName) { if (MoonassesPlugin.Verbose.Value) { return _logged.Add(kind + ":" + prefabName); } return false; } public static GameObject Attach(string prefabName, Transform hand, float bodyScale = 1f) { //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Expected O, but got Unknown //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Expected O, but got Unknown //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)hand == (Object)null || string.IsNullOrEmpty(prefabName) || (Object)(object)ZNetScene.instance == (Object)null) { return null; } GameObject prefab = ZNetScene.instance.GetPrefab(prefabName); if ((Object)(object)prefab == (Object)null) { return null; } Transform val = prefab.transform.Find("attach"); HashSet<Renderer> hashSet = new HashSet<Renderer>(); LODGroup[] componentsInChildren = prefab.GetComponentsInChildren<LODGroup>(true); for (int i = 0; i < componentsInChildren.Length; i++) { LOD[] lODs = componentsInChildren[i].GetLODs(); for (int j = 1; j < lODs.Length; j++) { Renderer[] renderers = lODs[j].renderers; foreach (Renderer val2 in renderers) { if ((Object)(object)val2 != (Object)null) { hashSet.Add(val2); } } } } int layer = ((Component)hand).gameObject.layer; MoonassesPlugin.Grip grip = MoonassesPlugin.GetGrip(prefabName); float num = Mathf.Max(0.05f, bodyScale); float num2 = Mathf.Max(0.05f, grip.Scale) * num; GameObject val3 = new GameObject("MoonassHeld_" + prefabName) { layer = layer }; val3.transform.SetParent(hand, false); Vector3 lossyScale = hand.lossyScale; val3.transform.localScale = new Vector3(num2 / ((Mathf.Abs(lossyScale.x) > 0.0001f) ? lossyScale.x : 1f), num2 / ((Mathf.Abs(lossyScale.y) > 0.0001f) ? lossyScale.y : 1f), num2 / ((Mathf.Abs(lossyScale.z) > 0.0001f) ? lossyScale.z : 1f)); GameObject val4 = new GameObject("grip") { layer = layer }; val4.transform.SetParent(val3.transform, false); val4.transform.localPosition = grip.Offset * num / num2; val4.transform.localRotation = Quaternion.Euler(grip.Rotation); int count = 0; bool flag = false; if ((Object)(object)val != (Object)null) { count = CopyAttach(val, val4.transform, prefabName); } if (count == 0) { CopyMeshes(prefab.transform, val4.transform, isRoot: true, hashSet, layer, ref count); flag = true; } if (count == 0) { Object.Destroy((Object)(object)val3); MoonassesPlugin.Log.LogWarning((object)L.F("[hands] {0} has no model for the hand", "[hands] У {0} нет модели для руки", prefabName)); return null; } bool flag2 = flag || IsSmallItem(prefab); if (FirstLog("model", prefabName)) { MoonassesPlugin.Log.LogInfo((object)L.F("[hands] {0}: model from {1}, shrunk to Max held size: {2}", "[hands] {0}: модель из {1}, уменьшение до Max held size: {2}", prefabName, flag ? L.T("the item on the ground", "предмета на земле") : "attach", (flag2 && !MoonassesPlugin.HasItemGrip(prefabName)) ? L.T("yes", "да") : L.T("no", "нет"))); } if (flag2 && !MoonassesPlugin.HasItemGrip(prefabName)) { FitSize(val4.transform, MoonassesPlugin.MaxHeldSize.Value * num, prefabName); } if (MoonassesPlugin.TryGetGlow(prefabName, out var g)) { AddGlow(val4.transform, layer, g); } return val3; } private static bool IsSmallItem(GameObject prefab) { //IL_0032: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Invalid comparison between Unknown and I4 //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Invalid comparison between Unknown and I4 //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Invalid comparison between Unknown and I4 //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Invalid comparison between Unknown and I4 //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Invalid comparison between Unknown and I4 ItemDrop component = prefab.GetComponent<ItemDrop>(); if ((Object)(object)component == (Object)null || component.m_itemData == null || component.m_itemData.m_shared == null) { return true; } ItemType itemType = component.m_itemData.m_shared.m_itemType; if ((int)itemType != 1 && (int)itemType != 2 && (int)itemType != 13 && (int)itemType != 16) { return (int)itemType == 9; } return true; } private static void AddGlow(Transform parent, int layer, MoonassesPlugin.Glow g) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("MoonassGlow") { layer = layer }; val.transform.SetParent(parent, false); Light val2 = val.AddComponent<Light>(); val2.type = (LightType)2; val2.color = new Color(g.Color.x, g.Color.y, g.Color.z); val2.range = Mathf.Max(0.5f, g.Range); val2.intensity = Mathf.Max(0f, g.Intensity); val2.shadows = (LightShadows)0; val.AddComponent<GlowFlicker>().Init(val2); } private static int CopyAttach(Transform attach, Transform parent, string prefabName) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) GameObject val; try { val = Object.Instantiate<GameObject>(((Component)attach).gameObject, parent, false); } catch (Exception ex) { MoonassesPlugin.Log.LogWarning((object)L.F("[hands] Could not copy attach: {0}", "[hands] Не удалось скопировать attach: {0}", ex.Message)); return 0; } ((Object)val).name = "attach"; val.transform.localPosition = Vector3.zero; val.transform.localRotation = Quaternion.identity; val.transform.localScale = Vector3.one; val.SetActive(true); Collider[] componentsInChildren = val.GetComponentsInChildren<Collider>(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.Destroy((Object)(object)componentsInChildren[i]); } Rigidbody[] componentsInChildren2 = val.GetComponentsInChildren<Rigidbody>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.Destroy((Object)(object)componentsInChildren2[i]); } int num = 0; Transform[] componentsInChildren3 = val.GetComponentsInChildren<Transform>(true); foreach (Transform val2 in componentsInChildren3) { if (((Object)val2).name == "equiped" || ((Object)val2).name == "equipped") { ((Component)val2).gameObject.SetActive(true); num++; } } if (FirstLog("attach", prefabName)) { MoonassesPlugin.Log.LogInfo((object)L.F("[hands] {0}: attach copied, effects in hand (equiped): {1}, particles: {2}, lights: {3}", "[hands] {0}: attach скопирован, эффектов в руке (equiped): {1}, частиц: {2}, света: {3}", prefabName, num, val.GetComponentsInChildren<ParticleSystem>(true).Length, val.GetComponentsInChildren<Light>(true).Length)); } int num2 = val.GetComponentsInChildren<Renderer>(true).Length; if (num2 == 0) { Object.Destroy((Object)(object)val); } return num2; } private static void FitSize(Transform root, float maxSize, string prefabName) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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_018f: 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_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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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_00ae: Unknown result type (might be due to invalid IL or missing references) if (maxSize <= 0f) { return; } bool flag = false; Bounds val = default(Bounds); MeshFilter[] componentsInChildren = ((Component)root).GetComponentsInChildren<MeshFilter>(true); foreach (MeshFilter val2 in componentsInChildren) { if ((Object)(object)val2.sharedMesh == (Object)null) { continue; } Bounds bounds = val2.sharedMesh.bounds; Matrix4x4 localToWorldMatrix = ((Component)val2).transform.localToWorldMatrix; for (int j = 0; j < 8; j++) { Vector3 val3 = ((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)))); Vector3 val4 = ((Matrix4x4)(ref localToWorldMatrix)).MultiplyPoint3x4(val3); if (!flag) { ((Bounds)(ref val))..ctor(val4, Vector3.zero); flag = true; } else { ((Bounds)(ref val)).Encapsulate(val4); } } } if (!flag) { MoonassesPlugin.Log.LogWarning((object)L.F("[hands] {0}: no meshes found, size not changed", "[hands] {0}: сеток не найдено, размер не изменён", prefabName)); return; } float num = Mathf.Max(((Bounds)(ref val)).size.x, Mathf.Max(((Bounds)(ref val)).size.y, ((Bounds)(ref val)).size.z)); if (num <= maxSize || num < 0.0001f) { if (FirstLog("size", prefabName)) { MoonassesPlugin.Log.LogInfo((object)L.F("[hands] {0}: model {1:0.##} m, not larger than {2:0.##} m, not shrunk", "[hands] {0}: модель {1:0.##} м, не больше {2:0.##} м, не уменьшена", prefabName, num, maxSize)); } return; } root.localScale *= maxSize / num; if (FirstLog("size", prefabName)) { MoonassesPlugin.Log.LogInfo((object)L.F("[hands] {0}: model {1:0.##} m, shrunk to {2:0.##} m", "[hands] {0}: модель {1:0.##} м, уменьшена до {2:0.##} м", prefabName, num, maxSize)); } } public static Transform FindHand(Transform root, bool right) { string[] array = ((!right) ? new string[4] { "l_hand", "LeftHand", "Hand_L", "hand_l" } : new string[4] { "r_hand", "RightHand", "Hand_R", "hand_r" }); foreach (string name in array) { Transform val = FindDeep(root, name); if ((Object)(object)val != (Object)null) { return val; } } return null; } public static Transform FindDeep(Transform t, string name) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown if (((Object)t).name == name) { return t; } foreach (Transform item in t) { Transform val = FindDeep(item, name); if ((Object)(object)val != (Object)null) { return val; } } return null; } private static void CopyMeshes(Transform src, Transform parent, bool isRoot, HashSet<Renderer> skip, int layer, ref int count) { //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_0014: Expected O, but got Unknown //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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_00d6: Expected O, but got Unknown GameObject val = new GameObject(((Object)src).name) { layer = layer }; val.transform.SetParent(parent, false); if (!isRoot) { val.transform.localPosition = src.localPosition; val.transform.localRotation = src.localRotation; val.transform.localScale = src.localScale; } MeshFilter component = ((Component)src).GetComponent<MeshFilter>(); MeshRenderer component2 = ((Component)src).GetComponent<MeshRenderer>(); if ((Object)(object)component != (Object)null && (Object)(object)component2 != (Object)null && (Object)(object)component.sharedMesh != (Object)null && ((Renderer)component2).enabled && !skip.Contains((Renderer)(object)component2)) { val.AddComponent<MeshFilter>().sharedMesh = component.sharedMesh; ((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterials = ((Renderer)component2).sharedMaterials; count++; } foreach (Transform item in src) { Transform val2 = item; if (((Component)val2).gameObject.activeSelf) { CopyMeshes(val2, val.transform, isRoot: false, skip, layer, ref count); } } } } internal class GlowFlicker : MonoBehaviour { private Light _light; private float _base; private float _seed; public void Init(Light light) { _light = light; _base = light.intensity; _seed = Random.Range(0f, 100f); } private void Update() { if (!((Object)(object)_light == (Object)null)) { float num = Mathf.PerlinNoise(Time.time * 2.5f, _seed); _light.intensity = _base * (0.85f + 0.3f * num); } } } [BepInPlugin("omertah.moonasses", "Moonasses", "0.9.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class MoonassesPlugin : BaseUnityPlugin { internal struct Grip { public float Scale; public Vector3 Offset; public Vector3 Rotation; } internal struct Glow { public Vector3 Color; public float Range; public float Intensity; } public const string Guid = "omertah.moonasses"; public const string Version = "0.9.0"; public const string PrefabName = "Moonass"; public const string KarlanPrefabName = "Karlan"; internal static ConfigEntry<string> KarlanCost; internal static ConfigEntry<int> KarlanCapacity; internal static ConfigEntry<float> KarlanHouseScale; internal static ConfigEntry<string> KarlanHouseBase; internal static ConfigEntry<float> KarlanScale; internal static ConfigEntry<int> ChainMaxCells; internal static ConfigEntry<float> StationRadius; internal static ConfigEntry<int> MinStationSpace; internal static ConfigEntry<int> ChainMaxRadius; internal static ConfigEntry<string> WandModel; internal static ConfigEntry<string> WandIconColor; internal static ConfigEntry<string> HouseCost; internal static ConfigEntry<int> HouseCapacity; internal static ConfigEntry<float> HouseScale; internal static ConfigEntry<float> MoonassScale; internal static ConfigEntry<bool> Verbose; internal static ConfigEntry<float> HeldScale; internal static ConfigEntry<float> MaxHeldSize; internal static ConfigEntry<string> GripOffset; internal static ConfigEntry<string> GripRotation; internal static ConfigEntry<string> ItemGrips; internal static ConfigEntry<string> GlowItems; internal static ConfigEntry<string> GlowColor; internal static ConfigEntry<float> GlowRange; internal static ConfigEntry<float> GlowIntensity; internal static ManualLogSource Log; private static Dictionary<string, Grip> _gripTable; private static string _gripTableSrc; internal static int VisualVersion; private static Dictionary<string, List<float>> _glowTable; private static string _glowTableSrc; private void Awake() { //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) //IL_0023: Expected O, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Expected O, but got Unknown //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Expected O, but got Unknown //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Expected O, but got Unknown //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Expected O, but got Unknown //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Expected O, but got Unknown //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Expected O, but got Unknown //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Expected O, but got Unknown //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Expected O, but got Unknown //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_03f8: Expected O, but got Unknown //IL_048d: Unknown result type (might be due to invalid IL or missing references) //IL_0497: Expected O, but got Unknown //IL_052b: Unknown result type (might be due to invalid IL or missing references) //IL_0535: Expected O, but got Unknown //IL_0861: Unknown result type (might be due to invalid IL or missing references) //IL_0867: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; L.Bind(((BaseUnityPlugin)this).Config); ConfigurationManagerAttributes val = new ConfigurationManagerAttributes { IsAdminOnly = true }; ChainMaxCells = ((BaseUnityPlugin)this).Config.Bind<int>("Chain", "Max cells", 20, new ConfigDescription(L.T("The largest number of tasks in the chain of one worker (the \"+ Task\" button in the chain window).", "Наибольшее число задач в цепочке одного работника (в окне цепочки кнопка «+ Задача»)."), (AcceptableValueBase)(object)new AcceptableValueRange<int>(2, 20), new object[1] { val })); MinStationSpace = ((BaseUnityPlugin)this).Config.Bind<int>("Chain", "Min station space", 1, new ConfigDescription(L.T("Destination station: the worker does not go for cargo until the station has this many free places (for ore or fuel). 1 = carries at once, even a single piece. More = fewer trips, but bigger loads.", "Станок-приёмник: работник не идёт за грузом, пока в станке не освободится столько мест (руды или топлива). 1 — носит сразу, даже по одной штуке. Больше — реже ходит, но носит помногу."), (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 20), new object[1] { val })); ChainMaxRadius = ((BaseUnityPlugin)this).Config.Bind<int>("Chain", "Max radius", 30, new ConfigDescription(L.T("The largest radius of a zone (all chests, stations or bushes around the point you picked with the wand), m.", "Наибольший радиус зоны (все сундуки, станки или кусты вокруг точки, которую вы указали жезлом), м."), (AcceptableValueBase)(object)new AcceptableValueRange<int>(5, 50), new object[1] { val })); MoonassSpeech.Bind(((BaseUnityPlugin)this).Config); StationRadius = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Station output radius", 2f, new ConfigDescription(L.T("Source station: the radius around the output point where the worker picks up finished items from the ground, m.", "Станок-источник: радиус вокруг точки выдачи, где работник подбирает готовое с земли, м."), (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 5f), new object[1] { val })); WandModel = ((BaseUnityPlugin)this).Config.Bind<string>("Wand", "Model", "StaffIceShards", L.T("The game staff whose model and icon the Moon Wand uses (needs a game restart): StaffIceShards (Frost Staff), StaffFireball (Staff of Embers), StaffShield (Staff of Protection), StaffSkeleton (Staff of the Dead), StaffGreenRoots (Staff of Nature).", "Посох игры, чья модель и иконка у Лунного жезла (нужен перезапуск игры): StaffIceShards (Посох льда), StaffFireball (Посох углей), StaffShield (Посох защиты), StaffSkeleton (Посох мёртвых), StaffGreenRoots (Посох дикой природы).")); WandIconColor = ((BaseUnityPlugin)this).Config.Bind<string>("Wand", "Icon background", "0.45 0.3 0.85", L.T("The color of the plate under the wand icon: R G B from 0 to 1 (needs a game restart).", "Цвет плашки под иконкой жезла: R G B от 0 до 1 (нужен перезапуск игры).")); HouseCost = ((BaseUnityPlugin)this).Config.Bind<string>("House", "Cost", "Wood:10, Resin:4, Thistle:2", new ConfigDescription(L.T("The cost of the Moonass House: Prefab:amount, comma-separated.", "Стоимость Дома Лунопопиков: Префаб:количество через запятую."), (AcceptableValueBase)null, new object[1] { val })); HouseCapacity = ((BaseUnityPlugin)this).Config.Bind<int>("House", "Moonasses per house", 6, new ConfigDescription(L.T("How many Moonasses can be summoned from one house (LMB with the wand on the house).", "Сколько Лунопопиков можно призвать из одного дома (ЛКМ жезлом на доме)."), (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 10), new object[1] { val })); HouseScale = ((BaseUnityPlugin)this).Config.Bind<float>("House", "House scale", 0.7f, new ConfigDescription(L.T("The size of the Moonass House (1 = like a Greydwarf nest). Applies at once, also to houses already built.", "Размер Дома Лунопопиков (1 = как гнездо грейдворфов). Меняется сразу, у уже построенных домов тоже."), (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.3f, 2f), new object[1] { val })); HouseScale.SettingChanged += delegate { MoonassHouse.ApplyScaleAll(); }; KarlanCost = ((BaseUnityPlugin)this).Config.Bind<string>("KarlanHouse", "Cost", "BlackMarble:10, YggdrasilWood:10, Sap:4", new ConfigDescription(L.T("The cost of the Karlan House: Prefab:amount, comma-separated. By default items that are found only in the Mistlands (black marble, Yggdrasil wood, sap).", "Стоимость Дома Карланов: Префаб:количество через запятую. По умолчанию предметы, которые добываются только в Туманных землях (чёрный мрамор, древо Иггдрасиля, сок)."), (AcceptableValueBase)null, new object[1] { val })); KarlanCapacity = ((BaseUnityPlugin)this).Config.Bind<int>("KarlanHouse", "Karlans per house", 6, new ConfigDescription(L.T("How many Karlans can be summoned from one house (LMB with the wand on the house).", "Сколько Карланов можно призвать из одного дома (ЛКМ жезлом на доме)."), (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 10), new object[1] { val })); KarlanHouseScale = ((BaseUnityPlugin)this).Config.Bind<float>("KarlanHouse", "House scale", 0.8f, new ConfigDescription(L.T("The size of the Karlan House (1 = the size of the game model). Applies at once, also to houses already built.", "Размер Дома Карланов (1 = размер модели игры). Меняется сразу, у уже построенных домов тоже."), (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.3f, 2f), new object[1] { val })); KarlanHouseScale.SettingChanged += delegate { MoonassHouse.ApplyScaleAll(); }; KarlanHouseBase = ((BaseUnityPlugin)this).Config.Bind<string>("KarlanHouse", "Base prefab", "dverger_guardstone", L.T("The game building whose model the Karlan House uses (needs a game restart). If there is none, a Greydwarf nest is used and all prefabs with the word dverger are written to the log: pick a suitable one from them.", "Постройка игры, чья модель у Дома Карланов (нужен перезапуск игры). Если такой нет, берётся гнездо грейдворфов, а в лог выписываются все префабы со словом dverger: выберите из них подходящий.")); KarlanScale = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "Karlan scale", 0.6f, new ConfigDescription(L.T("The size of a Karlan (1 = like a Dverger). The item in hand shrinks together with it.", "Размер Карлана (1 = как Дверг). Предмет в руке уменьшается вместе с ним."), (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.3f, 2f), new object[1] { val })); KarlanScale.SettingChanged += delegate { MoonassWorker[] array = Object.FindObjectsByType<MoonassWorker>((FindObjectsSortMode)0); for (int i = 0; i < array.Length; i++) { array[i].ApplyScale(); } VisualVersion++; }; Verbose = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "Verbose log", true, L.T("Write to the log what was picked up and where it was taken.", "Писать в лог, что подобрал и куда отнёс.")); MoonassScale = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "Moonass scale", 0.8f, new ConfigDescription(L.T("The size of a Moonass (1 = like a Greyling). The item in hand shrinks together with it.", "Размер Лунопопика (1 = как Greyling). Предмет в руке уменьшается вместе с ним."), (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.3f, 2f), new object[1] { val })); MoonassScale.SettingChanged += delegate { MoonassWorker[] array = Object.FindObjectsByType<MoonassWorker>((FindObjectsSortMode)0); for (int i = 0; i < array.Length; i++) { array[i].ApplyScale(); } VisualVersion++; }; HeldScale = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "Held item scale", 1f, L.T("The size of the item in a worker's hand (1 = the real size of the item).", "Размер предмета в руке работника (1 = настоящий размер предмета).")); MaxHeldSize = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "Max held size", 0.15f, new ConfigDescription(L.T("The largest size of an item in hand, m (for a worker of size 1). Applies to small items (berries, ingots, coal, trophies): their model shrinks to this size. Weapons, tools, the torch and items from Item grips are left alone.", "Наибольший размер предмета в руке, м (для работника размера 1). Касается мелких предметов (ягоды, слитки, уголь, трофеи): их модель уменьшается до этого размера. Оружие, инструменты, факел и предметы из Item grips не трогает."), (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 2f), Array.Empty<object>())); MaxHeldSize.SettingChanged += delegate { VisualVersion++; }; GripOffset = ((BaseUnityPlugin)this).Config.Bind<string>("Visual", "Grip offset", "0 0.1 0", L.T("The offset of the item in hand, m: x y z separated by spaces. Easier to change with the moonass_grip command.", "Сдвиг предмета в руке, м: x y z через пробел. Удобнее менять командой moonass_grip.")); GripRotation = ((BaseUnityPlugin)this).Config.Bind<string>("Visual", "Grip rotation", "-10 100 50", L.T("The rotation of the item in hand, degrees: x y z separated by spaces.", "Поворот предмета в руке, градусы: x y z через пробел.")); ItemGrips = ((BaseUnityPlugin)this).Config.Bind<string>("Visual", "Item grips", "Thistle=0.4 0 0.1 0 0 0 -100", L.T("Own grip for individual items: Prefab=scale offset_x y z rotation_x y z, entries separated by ';'. Easier to change with the command moonass_grip <Prefab> ...", "Свой хват для отдельных предметов: Префаб=размер сдвиг_x y z поворот_x y z, записи через ';'. Удобнее менять командой moonass_grip <Префаб> ...")); GlowItems = ((BaseUnityPlugin)this).Config.Bind<string>("Visual", "Glowing items", "Thistle", L.T("Items that glow in a worker's hand like a torch, entries separated by ';'. Just Prefab: the common light (Glow color/range/intensity). Prefab=R G B [range] [intensity]: its own light, decimals with a point. Easier to change with the command moonass_glow <Prefab> ...", "Предметы, которые светятся в руке работника как факел, записи через ';'. Просто Префаб: общий свет (Glow color/range/intensity). Префаб=R G B [дальность] [яркость]: свой свет, дробные числа через точку. Удобнее менять командой moonass_glow <Префаб> ...")); GlowColor = ((BaseUnityPlugin)this).Config.Bind<string>("Visual", "Glow color", "0.45 0.75 1", L.T("The glow color: R G B from 0 to 1 separated by spaces.", "Цвет свечения: R G B от 0 до 1 через пробел.")); GlowRange = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "Glow range", 6f, L.T("The glow range, m.", "Дальность свечения, м.")); GlowIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "Glow intensity", 1.5f, L.T("The glow brightness.", "Яркость свечения.")); HeldScale.SettingChanged += delegate { VisualVersion++; }; GripOffset.SettingChanged += delegate { VisualVersion++; }; GripRotation.SettingChanged += delegate { VisualVersion++; }; ItemGrips.SettingChanged += delegate { VisualVersion++; }; GlowItems.SettingChanged += delegate { VisualVersion++; }; GlowColor.SettingChanged += delegate { VisualVersion++; }; GlowRange.SettingChanged += delegate { VisualVersion++; }; GlowIntensity.SettingChanged += delegate { VisualVersion++; }; PrefabManager.OnVanillaPrefabsAvailable += CreateMoonass; CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new SpawnCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new RemoveCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new HandsCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new GripCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new GlowCommand()); if (!GUIManager.IsHeadless()) { ((Component)this).gameObject.AddComponent<WandController>(); } Harmony val2 = new Harmony("omertah.moonasses"); Type[] types = typeof(MoonassesPlugin).Assembly.GetTypes(); foreach (Type type in types) { try { val2.CreateClassProcessor(type).Patch(); } catch (Exception ex) { Log.LogError((object)L.F("Patch {0} was not applied: {1}", "Патч {0} не применён: {1}", type.Name, ex.Message)); } } } private void CreateMoonass() { PrefabManager.OnVanillaPrefabsAvailable -= CreateMoonass; MakeWorker("Moonass", "Greyling", L.T("Moonass", "Лунопопик"), dwarf: false); MakeWorker("Karlan", "Dverger", L.T("Karlan", "Карлан"), dwarf: true); MoonassWand.Register(); MoonassHouse.Register(karlan: false); MoonassHouse.Register(karlan: true); } private static void MakeWorker(string prefabName, string basePrefab, string displayName, bool dwarf) { //IL_0049: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) GameObject val = PrefabManager.Instance.CreateClonedPrefab(prefabName, basePrefab); if ((Object)(object)val == (Object)null) { Log.LogError((object)L.F("Could not clone {0}", "Не удалось клонировать {0}", basePrefab)); return; } Character component = val.GetComponent<Character>(); component.m_name = displayName; component.m_faction = (Faction)0; component.m_health = 100000f; component.m_damageModifiers = new DamageModifiers { m_blunt = (DamageModifier)3, m_slash = (DamageModifier)3, m_pierce = (DamageModifier)3, m_chop = (DamageModifier)3, m_pickaxe = (DamageModifier)3, m_fire = (DamageModifier)3, m_frost = (DamageModifier)3, m_lightning = (DamageModifier)3, m_poison = (DamageModifier)3, m_spirit = (DamageModifier)3 }; if (dwarf) { Humanoid component2 = val.GetComponent<Humanoid>(); if ((Object)(object)component2 != (Object)null) { string[] array = new string[5] { "m_defaultItems", "m_randomWeapon", "m_randomArmor", "m_randomShield", "m_randomSets" }; foreach (string field in array) { EmptyArray(component2, field); } } HashSet<string> hashSet = new HashSet<string> { "CharacterDrop", "NpcTalk", "Tameable", "Procreation" }; for (int j = 0; j < 3; j++) { bool flag = false; MonoBehaviour[] componentsInChildren = val.GetComponentsInChildren<MonoBehaviour>(true); foreach (MonoBehaviour val2 in componentsInChildren) { if (!((Object)(object)val2 == (Object)null) && hashSet.Contains(((object)val2).GetType().Name)) { Object.DestroyImmediate((Object)(object)val2); flag = true; } } if (!flag) { break; } } } val.AddComponent<MoonassWorker>(); PrefabManager.Instance.AddPrefab(val); Log.LogInfo((object)L.F("Prefab {0} created (based on {1})", "Префаб {0} создан (основа {1})", prefabName, basePrefab)); } private static void EmptyArray(object obj, string field) { FieldInfo fieldInfo = AccessTools.Field(obj.GetType(), field); if (!(fieldInfo == null) && fieldInfo.FieldType.IsArray) { fieldInfo.SetValue(obj, Array.CreateInstance(fieldInfo.FieldType.GetElementType(), 0)); } } internal static Vector3 ParseVec(string s) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) Vector3 zero = Vector3.zero; if (string.IsNullOrEmpty(s)) { return zero; } string[] array = s.Split(new char[2] { ' ', ';' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length && i < 3; i++) { if (float.TryParse(array[i].Replace(',', '.'), NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { ((Vector3)(ref zero))[i] = result; } } return zero; } internal static string VecText(Vector3 v) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) return string.Format(CultureInfo.InvariantCulture, "{0:0.###} {1:0.###} {2:0.###}", v.x, v.y, v.z); } internal static string GripText(Grip g) { //IL_0016: 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) return string.Format(CultureInfo.InvariantCulture, "{0:0.###} {1} {2}", g.Scale, VecText(g.Offset), VecText(g.Rotation)); } internal static Grip GetGrip(string prefabName) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) if (!string.IsNullOrEmpty(prefabName) && ItemGripTable().TryGetValue(prefabName, out var value)) { return value; } return new Grip { Scale = HeldScale.Value, Offset = ParseVec(GripOffset.Value), Rotation = ParseVec(GripRotation.Value) }; } internal static bool HasItemGrip(string prefabName) { if (!string.IsNullOrEmpty(prefabName)) { return ItemGripTable().ContainsKey(prefabName); } return false; } internal static Dictionary<string, Grip> ItemGripTable() { //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_010b: 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_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) string text = ItemGrips.Value ?? ""; if (_gripTable != null && _gripTableSrc == text) { return _gripTable; } Dictionary<string, Grip> dictionary = new Dictionary<string, Grip>(StringComparer.OrdinalIgnoreCase); string[] array = text.Split(new char[1] { ';' }); foreach (string text2 in array) { int num = text2.IndexOf('='); if (num <= 0) { continue; } string text3 = text2.Substring(0, num).Trim(); List<float> list = ParseNumbers(text2.Substring(num + 1)); if (text3.Length != 0 && list.Count != 0) { Grip value = new Grip { Scale = Mathf.Clamp(list[0], 0.05f, 5f), Offset = Vector3.zero, Rotation = Vector3.zero }; if (list.Count >= 4) { value.Offset = new Vector3(list[1], list[2], list[3]); } if (list.Count >= 7) { value.Rotation = new Vector3(list[4], list[5], list[6]); } dictionary[text3] = value; } } _gripTable = dictionary; _gripTableSrc = text; return dictionary; } internal static void SaveItemGrips(Dictionary<string, Grip> table) { List<string> list = new List<string>(); foreach (KeyValuePair<string, Grip> item in table) { list.Add(item.Key + "=" + GripText(item.Value)); } ItemGrips.Value = string.Join("; ", list.ToArray()); } internal static Dictionary<string, List<float>> GlowTable() { string text = GlowItems.Value ?? ""; if (_glowTable != null && _glowTableSrc == text) { return _glowTable; } Dictionary<string, List<float>> dictionary = new Dictionary<string, List<float>>(StringComparer.OrdinalIgnoreCase); string[] array = text.Split(new char[2] { ';', ',' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i++) { string text2 = array[i].Trim(); int num = text2.IndexOf('='); string text3 = ((num < 0) ? text2 : text2.Substring(0, num)).Trim(); if (text3.Length != 0) { dictionary[text3] = ((num < 0) ? new List<float>() : ParseNumbers(text2.Substring(num + 1))); } } _glowTable = dictionary; _glowTableSrc = text; return dictionary; } internal static void SaveGlowTable(Dictionary<string, List<float>> table) { List<string> list = new List<string>(); foreach (KeyValuePair<string, List<float>> item in table) { if (item.Value.Count == 0) { list.Add(item.Key); continue; } List<string> list2 = new List<string>(); foreach (float item2 in item.Value) { list2.Add(item2.ToString("0.###", CultureInfo.InvariantCulture)); } list.Add(item.Key + "=" + string.Join(" ", list2.ToArray())); } GlowItems.Value = string.Join("; ", list.ToArray()); } internal static Glow CommonGlow() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) return new Glow { Color = ParseVec(GlowColor.Value), Range = GlowRange.Value, Intensity = GlowIntensity.Value }; } internal static bool TryGetGlow(string prefabName, out Glow g) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) g = CommonGlow(); if (string.IsNullOrEmpty(prefabName) || !GlowTable().TryGetValue(prefabName, out var value)) { return false; } if (value.Count >= 3) { g.Color = new Vector3(value[0], value[1], value[2]); } if (value.Count >= 4) { g.Range = value[3]; } if (value.Count >= 5) { g.Intensity = value[4]; } return true; } internal static bool IsGlowing(string prefabName) { Glow g; return TryGetGlow(prefabName, out g); } internal static bool HasOwnGlow(string prefabName) { if (!string.IsNullOrEmpty(prefabName) && GlowTable().TryGetValue(prefabName, out var value)) { return value.Count >= 3; } return false; } internal static string GlowText(Glow g) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) return L.F("color {0}, range {1:0.##} m, intensity {2:0.##}", "цвет {0}, дальность {1:0.##} м, яркость {2:0.##}", VecText(g.Color), g.Range, g.Intensity); } private static List<float> ParseNumbers(string s) { List<float> list = new List<float>(); string[] array = s.Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i++) { if (float.TryParse(array[i].Replace(',', '.'), NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { list.Add(result); } } return list; } } internal class GripCommand : ConsoleCommand { public override string Name => "moonass_grip"; public override string Help => L.T("Item in hand: moonass_grip [Prefab] <scale> [offset x y z] [rotation x y z]; moonass_grip <Prefab> reset. Without numbers it shows the current ones.", "Предмет в руке: moonass_grip [Префаб] <размер> [сдвиг x y z] [поворот x y z]; moonass_grip <Префаб> reset. Без чисел показывает текущие."); public override void Run(string[] args) { //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: 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) string text = null; int num = 0; if (args.Length != 0 && !IsNumber(args[0])) { text = args[0]; num = 1; if ((Object)(object)ZNetScene.instance != (Object)null && (Object)(object)ZNetScene.instance.GetPrefab(text) == (Object)null) { Print(L.F("Item {0} not found. The prefab name must be exact, with a capital letter: Thistle, AxeBronze.", "Предмет {0} не найден. Имя префаба пишется точно, с большой буквы: Thistle, AxeBronze.", text)); return; } } if (text != null && args.Length > 1 && args[1].ToLowerInvariant() == "reset") { Dictionary<string, MoonassesPlugin.Grip> dictionary = new Dictionary<string, MoonassesPlugin.Grip>(MoonassesPlugin.ItemGripTable(), StringComparer.OrdinalIgnoreCase); if (dictionary.Remove(text)) { MoonassesPlugin.SaveItemGrips(dictionary); } Print(L.F("{0}: own grip removed, the common one is used now", "{0}: свой хват убран, теперь общий", text)); return; } int num2 = args.Length - num; if (num2 > 0) { float[] array = new float[7]; int num3 = 0; for (int i = 0; i < num2 && i < 7; i++) { if (!float.TryParse(args[num + i].Replace(',', '.'), NumberStyles.Float, CultureInfo.InvariantCulture, out array[i])) { Print(L.T("Not a number: ", "Не число: ") + args[num + i]); return; } num3++; } if (num3 != 1 && num3 != 4 && num3 != 7) { Print(L.T("1, 4 or 7 numbers are needed. Extra numbers were skipped.", "Нужно 1, 4 или 7 чисел. Лишние числа пропущены.")); } MoonassesPlugin.Grip grip = MoonassesPlugin.GetGrip(text); grip.Scale = Mathf.Clamp(array[0], 0.05f, 5f); if (num3 >= 4) { grip.Offset = new Vector3(array[1], array[2], array[3]); } if (num3 >= 7) { grip.Rotation = new Vector3(array[4], array[5], array[6]); } if (text == null) { MoonassesPlugin.HeldScale.Value = grip.Scale; MoonassesPlugin.GripOffset.Value = MoonassesPlugin.VecText(grip.Offset); MoonassesPlugin.GripRotation.Value = MoonassesPlugin.VecText(grip.Rotation); } else { MoonassesPlugin.SaveItemGrips(new Dictionary<string, MoonassesPlugin.Grip>(MoonassesPlugin.ItemGripTable(), StringComparer.OrdinalIgnoreCase) { [text] = grip }); } } if (text != null) { Print(L.F("Grip of {0}: ", "Хват {0}: ", text) + Describe(MoonassesPlugin.GetGrip(text)) + (MoonassesPlugin.HasItemGrip(text) ? "" : L.T(" (common)", " (общий)")) + (MoonassesPlugin.IsGlowing(text) ? L.T(", glows", ", светится") : "")); return; } Print(L.T("Common grip: ", "Хват общий: ") + Describe(MoonassesPlugin.GetGrip(null))); foreach (KeyValuePair<string, MoonassesPlugin.Grip> item in MoonassesPlugin.ItemGripTable()) { Print(L.F("Grip of {0}: ", "Хват {0}: ", item.Key) + Describe(item.Value) + (MoonassesPlugin.IsGlowing(item.Key) ? L.T(", glows", ", светится") : "")); } } private static string Describe(MoonassesPlugin.Grip g) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) return L.F("scale {0:0.##}, offset {1}, rotation {2}", "размер {0:0.##}, сдвиг {1}, поворот {2}", g.Scale, MoonassesPlugin.VecText(g.Offset), MoonassesPlugin.VecText(g.Rotation)); } private static bool IsNumber(string s) { float result; return float.TryParse(s.Replace(',', '.'), NumberStyles.Float, CultureInfo.InvariantCulture, out result); } private static void Print(string msg) { Console instance = Console.instance; if (instance != null) { instance.Print("[Moonass] " + msg); } MoonassesPlugin.Log.LogInfo((object)("[grip] " + msg)); } } internal class GlowCommand : ConsoleCommand { public override string Name => "moonass_glow"; public override string Help => L.T("Glow of an item in hand: moonass_glow <Prefab> on|off or moonass_glow <Prefab> R G B [range] [intensity]. Without arguments it shows the list.", "Свечение предмета в руке: moonass_glow <Префаб> on|off или moonass_glow <Префаб> R G B [дальность] [яркость]. Без аргументов показывает список."); public override void Run(string[] args) { if (args.Length == 0) { Print(L.T("Common light: ", "Общий свет: ") + MoonassesPlugin.GlowText(MoonassesPlugin.CommonGlow())); Dictionary<string, List<float>> dictionary = MoonassesPlugin.GlowTable(); if (dictionary.Count == 0) { Print(L.T("No glowing items", "Светящихся предметов нет")); } { foreach (KeyValuePair<string, List<float>> item in dictionary) { Show(item.Key); } return; } } string text = args[0]; if ((Object)(object)ZNetScene.instance != (Object)null && (Object)(object)ZNetScene.instance.GetPrefab(text) == (Object)null) { Print(L.F("Item {0} not found. The prefab name must be exact, with a capital letter: Thistle, Resin.", "Предмет {0} не найден. Имя префаба пишется точно, с большой буквы: Thistle, Resin.", text)); return; } if (args.Length == 1) { Show(text); return; } Dictionary<string, List<float>> dictionary2 = new Dictionary<string, List<float>>(MoonassesPlugin.GlowTable(), StringComparer.OrdinalIgnoreCase); string text2 = args[1].ToLowerInvariant(); if (text2 == "off") { dictionary2.Remove(text); MoonassesPlugin.SaveGlowTable(dictionary2); Print(L.F("{0}: does not glow", "{0}: не светится", text)); return; } if (text2 == "on") { dictionary2[text] = new List<float>(); MoonassesPlugin.SaveGlowTable(dictionary2); Show(text); return; } List<float> list = new List<float>(); for (int i = 1; i < args.Length; i++) { if (list.Count >= 5) { break; } if (!float.TryParse(args[i].Replace(',', '.'), NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { Print(L.T("Not a number: ", "Не число: ") + args[i] + L.T(". Example: moonass_glow Thistle 0.45 0.75 1 6 1.5", ". Пример: moonass_glow Thistle 0.45 0.75 1 6 1.5")); return; } list.Add(result); } if (list.Count < 3) { Print(L.T("At least 3 color numbers are needed: R G B from 0 to 1. Example: moonass_glow Thistle 1 0.5 0.8", "Нужно хотя бы 3 числа цвета: R G B от 0 до 1. Пример: moonass_glow Thistle 1 0.5 0.8")); return; } list[0] = Mathf.Clamp01(list[0]); list[1] = Mathf.Clamp01(list[1]); list[2] = Mathf.Clamp01(list[2]); if (list.Count >= 4) { list[3] = Mathf.Clamp(list[3], 0.5f, 30f); } if (list.Count >= 5) { list[4] = Mathf.Clamp(list[4], 0f, 8f); } dictionary2[text] = list; MoonassesPlugin.SaveGlowTable(dictionary2); Show(text); } private static void Show(string item) { if (!MoonassesPlugin.TryGetGlow(item, out var g)) { Print(L.F("{0}: does not glow", "{0}: не светится", item)); } else { Print(L.F("{0}: glows, ", "{0}: светится, ", item) + MoonassesPlugin.GlowText(g) + (MoonassesPlugin.HasOwnGlow(item) ? "" : L.T(" (common light)", " (общий свет)"))); } } private static void Print(string msg) { Console instance = Console.instance; if (instance != null) { instance.Print("[Moonass] " + msg); } MoonassesPlugin.Log.LogInfo((object)("[glow] " + msg)); } } internal class RemoveCommand : ConsoleCommand { public override string Name => "moonass_remove"; public override string Help => L.T("Remove the nearest Moonass or Karlan (within 10 m). moonass_remove all removes everyone within 50 m.", "Убрать ближайшего Лунопопика или Карлана (до 10 м). moonass_remove all — всех в радиусе 50 м."); public override void Run(string[] args) { //IL_0040: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } bool flag = args.Length != 0 && args[0].ToLowerInvariant() == "all"; float num = (flag ? 50f : 10f); Vector3 position = ((Component)localPlayer).transform.position; List<MoonassWorker> list = new List<MoonassWorker>(); MoonassWorker moonassWorker = null; float num2 = float.MaxValue; MoonassWorker[] array = Object.FindObjectsByType<MoonassWorker>((FindObjectsSortMode)0); foreach (MoonassWorker moonassWorker2 in array) { float num3 = Vector3.Distance(position, ((Component)moonassWorker2).transform.position); if (!(num3 > num)) { list.Add(moonassWorker2); if (num3 < num2) { num2 = num3; moonassWorker = moonassWorker2; } } } if ((Object)(object)moonassWorker == (Object)null) { Console.instance.Print(L.F("[Moonass] No workers nearby (radius {0:0} m)", "[Moonass] Рядом нет работников (радиус {0:0} м)", num)); return; } if (!flag) { list = new List<MoonassWorker> { moonassWorker }; } foreach (MoonassWorker item in list) { item.Remove(); } Console.instance.Print(L.F("[Moonass] Workers removed: {0}", "[Moonass] Убрано работников: {0}", list.Count)); } } internal class HandsCommand : ConsoleCommand { public override string Name => "moonass_hands"; public override string Help => L.T("Diagnostics of the hands of the nearest worker (within 10 m) and of the attach points of items. Details go to the log.", "Диагностика рук ближайшего работника (до 10 м) и точек attach у предметов. Подробности в лог."); public override void Run(string[] args) { //IL_0032: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } MoonassWorker moonassWorker = null; float num = 10f; MoonassWorker[] array = Object.FindObjectsByType<MoonassWorker>((FindObjectsSortMode)0); foreach (MoonassWorker moonassWorker2 in array) { float num2 = Vector3.Distance(((Component)localPlayer).transform.position, ((Component)moonassWorker2).transform.position); if (num2 < num) { num = num2; moonassWorker = moonassWorker2; } } if ((Object)(object)moonassWorker == (Object)null) { Report(L.T("No workers nearby (radius 10 m)", "Рядом нет работников (радиус 10 м)")); return; } GameObject gameObject = ((Component)moonassWorker).gameObject; Transform transform = gameObject.transform; Report(L.F("Worker: {0}, scale {1}", "Работник: {0}, масштаб {1}", ((Object)gameObject).name, transform.lossyScale)); Report("Humanoid: " + ((Object)(object)gameObject.GetComponent<Humanoid>() != (Object)null)); Report("Animator: " + ((Object)(object)gameObject.GetComponentInChildren<Animator>() != (Object)null)); VisEquipment component = gameObject.GetComponent<VisEquipment>(); Report("VisEquipment: " + ((Object)(object)component != (Object)null)); if ((Object)(object)component != (Object)null) { Report(" m_rightHand: " + DescribeField(component, "m_rightHand", transform)); Report(" m_leftHand: " + DescribeField(component, "m_leftHand", transform)); Report(" m_rightItem: " + DescribeField(component, "m_rightItem", transform)); } Humanoid component2 = gameObject.GetComponent<Humanoid>(); if ((Object)(object)component2 != (Object)null) { ItemData val = RightItemOf(component2); Report(L.T(" Item in the right hand: ", " Предмет в правой руке: ") + ((val != null) ? val.m_shared.m_name : L.T("none", "нет"))); } int num3 = 0; Transform[] componentsInChildren = gameObject.GetComponentsInChildren<Transform>(true); foreach (Transform val2 in componentsInChildren) { string text = ((Object)val2).name.ToLowerInvariant(); if (text.Contains("hand") || text.Contains("arm") || text.Contains("attach")) { Report(L.F(" bone: {0}, scale {1}", " кость: {0}, масштаб {1}", PathOf(val2, transform), val2.lossyScale)); num3++; } } Report(L.T("Bones with hand/arm/attach found: ", "Найдено костей с hand/arm/attach: ") + num3); List<string> list = new List<string>(); string[] array2 = new string[6] { "Coal", "Copper", "Tin", "Iron", "Thistle", "Raspberry" }; foreach (string item in array2) { list.Add(item); } ItemData val3 = RightItemOf((Humanoid)(object)localPlayer); if (val3 != null && (Object)(object)val3.m_dropPrefab != (Object)null) { list.Add(((Object)val3.m_dropPrefab).name); } foreach (string item2 in list) { GameObject val4 = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab(item2) : null); if ((Object)(object)val4 == (Object)null) { Report(L.F(" {0}: prefab not found", " {0}: префаб не найден", item2)); } else { Report(" " + item2 + ": attach " + (((Object)(object)val4.transform.Find("attach") != (Object)null) ? L.T("yes", "есть") : L.T("no", "нет"))); } } StringBuilder stringBuilder = new StringBuilder(); Dump(transform, 0, stringBuilder); MoonassesPlugin.Log.LogInfo((object)(L.T("[hands] Object tree:\n", "[hands] Дерево объектов:\n") + stringBuilder)); Report(L.T("The object tree was written to LogOutput.log", "Дерево объектов записано в LogOutput.log")); } private static ItemData RightItemOf(Humanoid h) { object? obj = AccessTools.Field(typeof(Humanoid), "m_rightItem")?.GetValue(h); return (ItemData)((obj is ItemData) ? obj : null); } private static string DescribeField(object obj, string field, Transform root) { FieldInfo fieldInfo = AccessTools.Field(obj.GetType(), field); if (fieldInfo == null) { return L.T("field not found", "поле не найдено"); } object value = fieldInfo.GetValue(obj); if (value == null) { return L.T("empty", "пусто"); } Transform val = (Transform)((value is Transform) ? value : null); if (val != null) { if (!((Object)(object)val == (Object)null)) { return PathOf(val, root); } return L.T("empty", "пусто"); } string text = value.ToString(); if (!(text == "")) { return text; } return L.T("empty", "пусто"); } private static string PathOf(Transform t, Transform root) { string text = ((Object)t).name; Transform parent = t.parent; while ((Object)(object)parent != (Object)null && (Object)(object)parent != (Object)(object)root.parent) { text = ((Object)parent).name + "/" + text; parent = parent.parent; } return text; } private static void Dump(Transform t, int depth, StringBuilder sb) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown sb.Append(' ', depth * 2).Append(((Object)t).name); if ((Object)(object)((Component)t).GetComponent<SkinnedMeshRenderer>() != (Object)null) { sb.Append(" [SkinnedMesh]"); } if ((Object)(object)((Component)t).GetComponent<MeshRenderer>() != (Object)null) { sb.Append(" [Mesh]"); } sb.AppendLine(); foreach (Transform item in t) { Dump(item, depth + 1, sb); } } private static void Report(string msg) { Console instance = Console.instance; if (instance != null) { instance.Print("[Moonass] " + msg); } MoonassesPlugin.Log.LogInfo((object)("[hands] " + msg)); } } internal class SpawnCommand : ConsoleCommand { public override string Name => "moonass_spawn"; public override string Help => L.T("Test: summon a Moonass next to you. moonass_spawn karlan summons a Karlan.", "Тест: призвать Лунопопика рядом с собой. moonass_spawn karlan — Карлана."); public override void Run(string[] args) { //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: 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_0301: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } string text = ((args.Length != 0 && args[0].ToLowerInvariant() == "karlan") ? "Karlan" : "Moonass"); ZNetScene instance = ZNetScene.instance; GameObject val = (((Object)(object)instance != (Object)null) ? instance.GetPrefab(text) : null); GameObject prefab = PrefabManager.Instance.GetPrefab(text); Report(L.T("ZNetScene found: ", "ZNetScene найден: ") + ((Object)(object)instance != (Object)null)); Report(L.T("Prefab in ZNetScene: ", "Префаб в ZNetScene: ") + ((Object)(object)val != (Object)null)); Report(L.T("Prefab in Jotunn: ", "Префаб в Jotunn: ") + ((Object)(object)prefab != (Object)null)); if ((Object)(object)prefab != (Object)null) { Report(" ZNetView: " + ((Object)(object)prefab.GetComponent<ZNetView>() != (Object)null)); Report(" Character: " + ((Object)(object)prefab.GetComponent<Character>() != (Object)null)); Report(" MonsterAI: " + ((Object)(object)prefab.GetComponent<MonsterAI>() != (Object)null)); Report(" MoonassWorker: " + ((Object)(object)prefab.GetComponent<MoonassWorker>() != (Object)null)); Report(" activeSelf: " + prefab.activeSelf); Report(" hash: " + StableHash(text)); } GameObject val2 = (((Object)(object)instance != (Object)null) ? instance.GetPrefab("Greyling") : null); Report(L.T("Greyling in ZNetScene: ", "Greyling в ZNetScene: ") + ((Object)(object)val2 != (Object)null)); if ((Object)(object)val == (Object)null && (Object)(object)prefab != (Object)null && (Object)(object)instance != (Object)null) { if (AccessTools.Field(typeof(ZNetScene), "m_namedPrefabs")?.GetValue(instance) is Dictionary<int, GameObject> dictionary) { dictionary[StableHash(text)] = prefab; val = instance.GetPrefab(text); Report(L.T("Added to ZNetScene by hand: ", "Внесён в ZNetScene вручную: ") + ((Object)(object)val != (Object)null)); } else { Report(L.T("Field m_namedPrefabs not found", "Поле m_namedPrefabs не найдено")); } } if ((Object)(object)val == (Object)null) { Console.instance.Print(L.T("The Moonass prefab was not found", "Префаб Moonass не найден")); return; } Vector3 val3 = ((Component)localPlayer).transform.position + ((Component)localPlayer).transform.forward * 2f + Vector3.up * 0.5f; Object.Instantiate<GameObject>(val, val3, Quaternion.identity); Report(L.T("Instance created", "Создан экземпляр")); } private static int StableHash(string str) { int num = 5381; int num2 = num; for (int i = 0; i < str.Length && str[i] != 0; i += 2) { num = ((num << 5) + num) ^ str[i]; if (i == str.Length - 1 || str[i + 1] == '\0') { break; } num2 = ((num2 << 5) + num2) ^ str[i + 1]; } return num + num2 * 1566083941; } private static void Report(string msg) { Console instance = Console.instance; if (instance != null) { instance.Print("[Moonass] " + msg); } MoonassesPlugin.Log.LogInfo((object)("[diag] " + msg)); } } public class MoonassHouse : MonoBehaviour, Hoverable, Interactable { internal sealed class Kind { public bool Karlan; public string HousePrefab; public string Worker; public Func<string> Cost; public Func<int> Capacity; public Func<float> Scale; public string Display { get { if (!Karlan) { return L.T("Moonass House", "Дом Лунопопиков"); } return L.T("Karlan House", "Дом Карланов"); } } public string Nom { get { if (!Karlan) { return L.T("Moonass", "Лунопопик"); } return L.T("Karlan", "Карлан"); } } public string Gen { get { if (!Karlan) { return L.T("Moonass", "Лунопопика"); } return L.T("Karlan", "Карлана"); } } public string GenPl { get { if (!Karlan) { return L.T("Moonasses", "Лунопопиков"); } return L.T("Karlans", "Карланов"); } } public string NomPl { get { if (!Karlan) { return L.T("Moonasses", "Лунопопики"); } return L.T("Karlans", "Карланы"); } } } public const string PrefabName = "MoonassHouse"; public const string BasePrefab = "Spawner_GreydwarfNest"; public const string KarlanPrefabName = "KarlanHouse"; private const string KarlanFallbackBase = "Spawner_GreydwarfNest"; internal static readonly Kind Moonass = new Kind { Karlan = false, HousePrefab = "MoonassHouse", Worker = "Moonass", Cost = () => MoonassesPlugin.HouseCost.Value, Capacity = () => Mathf.Max(1, MoonassesPlugin.HouseCapacity.Value), Scale = () => Mathf.Clamp(MoonassesPlugin.HouseScale.Value, 0.3f, 2f) }; internal static readonly Kind KarlanKind = new Kind { Karlan = true, HousePrefab = "KarlanHouse", Worker = "Karlan", Cost = () => MoonassesPlugin.KarlanCost.Value, Capacity = () => Mathf.Max(1, MoonassesPlugin.KarlanCapacity.Value), Scale = () => Mathf.Clamp(MoonassesPlugin.KarlanHouseScale.Value, 0.3f, 2f) }; private const string CreatorKey = "moonass_house_creator"; private const string CreatorNameKey = "moonass_house_creator_name"; private const string CostKey = "moonass_house_cost"; private const string MembersKey = "moonass_house_members2"; private static readonly HashSet<string> Strip = new HashSet<string> { "SpawnArea", "CreatureSpawner", "DropOnDestroyed", "HoverText", "Destructible", "WearNTear", "Piece" }; private static readonly FieldInfo NoCostField = AccessTools.Field(typeof(Player), "m_noPlacementCost"); private ZNetView _nview; private static readonly List<MoonassHouse> Houses = new List<MoonassHouse>(); private static Vector3 _baseScale = Vector3.one; private static Vector3 _karlanBaseScale = Vector3.one; private static HashSet<long> _worldUids; private static float _worldUidsAt = -100f; private static readonly List<ZDO> ZdoBuffer = new List<ZDO>(); private const string LostKey = "moonass_house_lost"; private const int LostWidth = 8; private const int LostHeight = 4; private string _lostRaw; private int _lostCount; internal Kind K { get { if (!((Object)((Component)this).gameObject).name.StartsWith("KarlanHouse")) { return Moonass; } return KarlanKind; } } internal static float Scale => Moonass.Scale(); private int Capacity => K.Capacity(); internal static Kind KindOf(bool karlan) { if (!karlan) { return Moonass; } return KarlanKind; } private void OnEnable() { if (!Houses.Contains(this)) { Houses.Add(this); } } private void OnDisable() { Houses.Remove(this); } internal static MoonassHouse FindNear(Vector3 pos) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_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) foreach (MoonassHouse house in Houses) { if (!((Object)(object)house == (Object)null) && !((Object)(object)house._nview == (Object)null) && house._nview.IsValid()) { Vector3 val = ((Component)house).transform.position - pos; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude <= 9f) { return house; } } } return null; } private void Awake() { _nview = ((Component)this).GetComponent<ZNetView>(); ApplyScale(); } internal void ApplyScale() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) Kind k = K; ((Component)this).transform.localScale = (k.Karlan ? _karlanBaseScale : _baseScale) * k.Scale(); } internal static void ApplyScaleAll() { MoonassHouse[] array = Object.FindObjectsByType<MoonassHouse>((FindObjectsInactive)1, (FindObjectsSortMode)0); foreach (MoonassHouse moonassHouse in array) { if ((Object)(object)moonassHouse != (Object)null) { moonassHouse.ApplyScale(); } } } public static void Register(bool karlan) { //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) Kind kind = KindOf(karlan); string text = "Spawner_GreydwarfNest"; if (karlan) { string text2 = (MoonassesPlugin.KarlanHouseBase.Value ?? "").Trim(); if (text2 != "" && (Object)(object)PrefabManager.Instance.GetPrefab(text2) != (Object)null) { text = text2; } else { text = "Spawner_GreydwarfNest"; MoonassesPlugin.Log.LogWarning((object)(L.F("Karlan House: prefab \"{0}\" not found, using {1}. Prefabs with the word dverger: ", "Дом Карланов: префаб «{0}» не найден, беру {1}. Префабы со словом dverger: ", text2, text) + string.Join(", ", DvergerPrefabNames().ToArray()))); } } GameObject val = PrefabManager.Instance.CreateClonedPrefab(kind.HousePrefab, text); if ((Object)(object)val == (Object)null) { MoonassesPlugin.Log.LogError((object)L.F("{0}: could not clone {1}", "{0}: не удалось клонировать {1}", kind.Display, text)); return; } HashSet<string> hashSet = new HashSet<string>(Strip); if (karlan) { string[] array = new string[5] { "PrivateArea", "Demister", "Container", "Fireplace", "CookingStation" }; foreach (string item in array) { hashSet.Add(item); } } for (int j = 0; j < 4; j++) { bool flag = false; MonoBehaviour[] componentsInChildren = val.GetComponentsInChildren<MonoBehaviour>(true); foreach (MonoBehaviour val2 in componentsInChildren) { if (!((Object)(object)val2 == (Object)null) && hashSet.Contains(((object)val2).GetType().Name)) { Object.DestroyImmediate((Object)(object)val2); flag = true; } } if (!flag) { break; } } if (karlan) { _karlanBaseScale = val.transform.localScale; } else { _baseScale = val.transform.localScale; } val.AddComponent<MoonassHouse>(); List<string> list = new List<string>(); Component[] componentsInChildren2 = val.GetComponentsInChildren<Component>(true); foreach (Component val3 in componentsInChildren2) { if ((Object)(object)val3 != (Object)null && !(val3 is Transform)) { list.Add(((object)val3).GetType().Name); } } MoonassesPlugin.Log.LogInfo((object)(L.F("Prefab {0} created (based on {1}). Components: ", "Префаб {0} создан (основа {1}). Компоненты: ", kind.HousePrefab, text) + string.Join(", ", list.ToArray()))); PrefabManager.Instance.AddPrefab(val); } private static List<string> DvergerPrefabNames() { List<string> list = new List<string>(); ZNetScene instance = ZNetScene.instance; List<GameObject> list2 = (((Object)(object)instance != (Object)null) ? Traverse.Create((object)instance).Field("m_prefabs").GetValue<List<GameObject>>() : null); if (list2 == null) { return list; } foreach (GameObject item in list2) { if ((Object)(object)item != (Object)null && ((Object)item).name.ToLowerInvariant().Contains("dverger")) { list.Add(((Object)item).name); } } return list; } internal static List<KeyValuePair<ItemDrop, int>> ParseCost(string s) { List<KeyValuePair<ItemDrop, int>> list = new List<KeyValuePair<ItemDrop, int>>(); if (string.IsNullOrEmpty(s) || (Object)(object)ZNetScene.instance == (Object)null) { return list; } string[] array = s.Split(new char[1] { ',' }); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split(new char[1] { ':' }); if (array2.Length == 2 && int.TryParse(array2[1].Trim(), out var result) && result > 0) { GameObject prefab = ZNetScene.instance.GetPrefab(array2[0].Trim()); ItemDrop val = (((Object)(object)prefab != (Object)null) ? prefab.GetComponent<ItemDrop>() : null); if ((Object)(object)val == (Object)null) { MoonassesPlugin.Log.LogWarning((object)L.F("House cost: unknown item {0}", "Стоимость дома: неизвестный предмет {0}", array2[0].Trim())); } else { list.Add(new KeyValuePair<ItemDrop, int>(val, result)); } } } return list; } internal static string CostText(List<KeyValuePair<ItemDrop, int>> cost) { if (cost.Count == 0) { return L.T("free", "бесплатно"); } List<string> list = new List<string>(); foreach (KeyValuePair<ItemDrop, int> item in cost) { list.Add(Localization.instance.Localize(item.Key.m_itemData.m_shared.m_name) + " ×" + item.Value); } return string.Join(", ", list.ToArray()); } internal static bool NoCost(Player p) { bool flag = default(bool); int num; if (NoCostField != null && (Object)(object)p != (Object)null) { object value = NoCostField.GetValue(p); if (value is bool) { flag = (bool)value; num = 1; } else { num = 0; } } else { num = 0; } return (byte)((uint)num & (flag ? 1u : 0u)) != 0; } private static int Count(Inventory inv, ItemDrop drop) { int num = 0; string name = drop.m_itemData.m_shared.m_name; foreach (ItemData allItem in inv.GetAllItems()) { if (allItem.m_shared.m_name == name) { num += allItem.m_stack; } } return num; } internal static string Missing(Player p, List<KeyValuePair<ItemDrop, int>> cost) { if (NoCost(p)) { return ""; } Inventory inventory = ((Humanoid)p).GetInventory(); List<string> list = new List<string>(); foreach (KeyValuePair<ItemDrop, int> item in cost) { int num = ((inventory != null) ? Count(inventory, item.Key) : 0); if (num < item.Value) { list.Add(Localization.instance.Localize(item.Key.m_itemData.m_shared.m_name) + $" {num}/{item.Value}"); } } return string.Join(", ", list.ToArray()); } private static void Consume(Inventory inv, List<KeyValuePair<ItemDrop, int>> cost) { foreach (KeyValuePair<ItemDrop, int> item in cost) { int num = item.Value; string name = item.Key.m_itemData.m_shared.m_name; foreach (ItemData item2 in new List<ItemData>(inv.GetAllItems())) { if (num <= 0) { break; } if (!(item2.m_shared.m_name != name) && !item2.m_equipped) { int num2 = Mathf.Min(num, item2.m_stack); inv.RemoveItem(item2, num2); num -= num2; } } } } internal static string Place(Kind kind, Player p, Vector3 pos, Quaternion rot, out bool ok) { //IL_003e: 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_00b1: 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) ok = false; GameObject val = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab(kind.HousePrefab) : null); if ((Object)(object)val == (Object)null) { return L.T("The house prefab was not found (see the log)", "Префаб дома не найден (см. лог)"); } if (!PrivateArea.CheckAccess(pos, 0f, true, false)) { return L.T("Someone else's protected area is here", "Здесь чужая защищённая зона"); } List<KeyValuePair<ItemDrop, int>> cost = ParseCost(kind.Cost()); string text = Missing(p, cost); if (text != "") { return L.T("Missing: ", "Не хватает: ") + text; } bool flag = NoCost(p); if (!flag) { Consume(((Humanoid)p).GetInventory(), cost); } MoonassHouse component = Object.Instantiate<GameObject>(val, pos, rot).GetComponent<MoonassHouse>(); if ((Object)(object)component != (Object)null) { component.Init(p, flag ? "" : kind.Cost()); } ok = true; MoonassesPlugin.Log.LogInfo((object)(L.F("{0} placed at {1}", "{0} поставлен в {1}", kind.Display, pos) + (flag ? L.T(" (no cost)", " (без затрат)") : ""))); return kind.Display + L.T(" built", " построен"); } private void Init(Player p, string cost) { if (!((Object)(object)_nview == (Object)null) && _nview.IsValid()) { ZDO zDO = _nview.GetZDO(); zDO.Set("moonass_house_creator", p.GetPlayerID()); zDO.Set("moonass_house_creator_name", p.GetPlayerName()); zDO.Set("moonass_house_cost", cost); } } internal string Dismantle(Player p) { //IL_0031: 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_00d3: 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_023a: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: 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) if ((Object)(object)_nview == (Object)null || !_nview.IsValid()) { return L.T("The house is unavailable", "Дом недоступен"); } if (!PrivateArea.CheckAccess(((Component)this).transform.position, 0f, true, false)) { return L.T("Someone else's protected area is here", "Здесь чужая защищённая зона"); } List<long> list = AliveMembers(save: true); if (list.Count > 0) { return L.F("First return the {0} to the house: RMB on the house ({1} left)", "Сначала верните {0} в дом: ПКМ на доме (осталось {1})", K.GenPl, list.Count); } _nview.ClaimOwnership(); foreach (ItemData allItem in LoadLost().GetAllItems()) { ItemDrop.DropItem(allItem, allItem.m_stack, ((Component)this).transform.position + Vector3.up, Quaternion.identity); } List<KeyValuePair<ItemDrop, int>> list2 = ParseCost(_nview.GetZDO().GetString("moonass_house_cost", "")); Inventory inventory = ((Humanoid)p).GetInventory(); foreach (KeyValuePair<ItemDrop, int> item in list2) { int num = item.Value; int num2 = Mathf.Max(1, item.Key.m_itemData.m_shared.m_maxStackSize); while (num > 0) { ItemData val = item.Key.m_itemData.Clone(); val.m_dropPrefab = ((Component)item.Key).gameObject; val.m_stack = Mathf.Min(num, num2); num -= val.m_stack; if (inventory != null && inventory.CanAddItem(val, -1)) { inventory.AddItem(val); } else { ItemDrop.DropItem(val, val.m_stack, ((Component)p).transform.position + Vector3.up, Quaternion.identity); } } } string display = K.Display; MoonassesPlugin.Log.LogInfo((object)L.F("{0} dismantled at {1}", "{0} разобран в {1}", display, ((Component)this).transform.position)); ZNetScene.instance.Destroy(((Component)this).gameObject); return display + L.T(" dismantled", " разобран") + ((list2.Count > 0) ? L.T(", resources returned", ", ресурсы возвращены") : ""); } private List<long> LoadMembers() { List<long> list = new List<long>(); if ((Object)(object)_nview == (Object)null || !_nview.IsValid()) { return list; } string text = _nview.GetZDO().GetString("moonass_house_members2", ""); if (text == "") { return list; } string[] array = text.Split(new char[1] { ',' }); for (int i = 0; i < array.Length; i++) { if (long.TryParse(array[i], out var result) && result != 0L && !list.Contains(result)) { list.Add(result); } } return list; } private void SaveMembers(List<long> list) { if ((Object)(object)_nview == (Object)null || !_nview.IsValid()) { return; } List<string> list2 = new List<string>(); foreach (long item in list) { list2.Add(item.ToString()); } _nview.ClaimOwnership(); _nview.GetZDO().Set("moonass_house_members2", string.Join(",", list2.ToArray())); } private static HashSet<long> WorldUids() { if (ZDOMan.instance == null || (Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer()) { return null; } if (_worldUids != null && Time.time - _worldUidsAt < 2f) { return _worldUids; } HashSet<long> hashSet = new HashSet<long>(); try { string[] array = new string[2] { "Moonass", "Karlan" }; foreach (string text in array) { ZdoBuffer.Clear(); int num = 0; int num2 = 0; while (!ZDOMan.instance.GetAllZDOsWithPrefabIterative(text, ZdoBuffer, ref num) && num2++ < 100000) { } foreach (ZDO item in ZdoBuffer) { long num3 = ((item != null) ? item.GetLong("moonass_uid", 0L) : 0); if (num3 != 0L) { hashSet.Add(num3); } } } ZdoBuffer.Clear(); } catch (Exception ex) { MoonassesPlugin.Log.LogWarning((object)(L.T("House: could not list the workers of the world: ", "Дом: не удалось перечислить работников мира: ") + ex.Message)); return null; } _worldUids = hashSet; _worldUidsAt = Time.time; return hashSet; } private List<long> AliveMembers(bool save) { List<long> list = LoadMembers(); if (list.Count == 0) { return list; } HashSet<long> world = WorldUids(); if (world == null) { return list; } int count = list.Count; list.RemoveAll((long id) => !world.Contains(id)); if (save && list.Count != count) { SaveMembers(list); } return list; } internal string Summon(Player p) { //IL_00cf: 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_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: 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_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_nview == (Object)null || !_nview.IsValid()) { return L.T("The house is unavailable", "Дом недоступен"); } Kind k = K; GameObject val = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab(k.Worker) : null); if ((Object)(object)val == (Object)null) { return L.F("The {0} prefab was not found (see the log)", "Префаб {0} не найден (см. лог)", k.Gen); } List<long> list = AliveMembers(save: true); int capacity = Capacity; if (list.Count >= capacity) { return L.F("All {0} of this house are already outside ({1}/{2}). RMB on the house returns one", "Все {0} этого дома уже снаружи ({1}/{2}). ПКМ на доме — вернуть одного", k.NomPl, list.Count, capacity); } Vector3 val2 = ((Component)p).transform.position - ((Component)this).transform.position; val2.y = 0f; val2 = ((((Vector3)(ref val2)).sqrMagnitude > 0.01f) ? ((Vector3)(ref val2)).normalized : ((Component)this).transform.forward); Vector3 val3 = Quaternion.Euler(0f, Random.Range(-40f, 40f), 0f) * val2; Vector3 val4 = GroundAt(((Component)this).transform.position + val3 * 3f); GameObject val5 = Object.Instantiate<GameObject>(val, val4, Quaternion.LookRotation(val3)); ZNetView component = val5.GetComponent<ZNetView>(); if ((Object)(object)component == (Object)null || !component.IsValid()) { MoonassesPlugin.Log.LogError((object)L.F("{0}: the summoned worker has no ZNetView", "{0}: у призванного работника нет ZNetView", k.Display)); return L.F("Could not summon the {0} (see the log)", "Не удалось призвать {0} (см. лог)", k.Gen); } MoonassWorker component2 = val5.GetComponent<MoonassWorker>(); long num = (((Object)(object)component2 != (Object)null) ? component2.Uid : 0); if (num == 0L) { MoonassesPlugin.Log.LogError((object)L.F("{0}: the summoned worker got no number", "{0}: призванному работнику не выдан номер", k.Display)); ZNetScene.instance.Destroy(val5); return L.F("Could not summon the {0} (see the log)", "Не удалось призвать {0} (см. лог)", k.Gen); } list.Add(num); SaveMembers(list); _worldUidsAt = -100f; component2.SetHome(((Component)this).transform.position); component2.Say(MoonassPhrase.Summon); string text = (((Object)(object)component2 != (Object)null) ? component2.Tag : ""); MoonassesPlugin.Log.LogInfo((object)L.F("{0} at {1}: {2} {3} came out ({4}/{5})", "{0} в {1}: вышел {2} {3} ({4}/{5})", k.Display, ((Component)this).transform.position, k.Nom, text, list.Count, capacity)); return L.F("{0} {1} came out of the house ({2}/{3})", "{0} {1} вышел из дома ({2}/{3})", k.Nom, text, list.Count, capacity); } internal string RecallNearest() { //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_nview == (Object)null || !_nview.IsValid()) { return L.T("The house is unavailable", "Дом недоступен"); } List<long> list = AliveMembers(save: true); int capacity = Capacity; if (list.Count == 0) { return L.F("All {0} of this house are at home (0/{1}). LMB summons one", "Все {0} этого дома дома (0/{1}). ЛКМ — призвать", K.NomPl, capacity); } HashSet<long> hashSet = new HashSet<long>(list); MoonassWorker moonassWorker = null; long item = 0L; float num = float.MaxValue; MoonassWorker[] array = Object.FindObjectsByType<MoonassWorker>((FindObjectsSortMode)0); foreach (MoonassWorker moonassWorker2 in array) { ZNetView component = ((Component)moonassWorker2).GetComponent<ZNetView>(); if ((Object)(object)component == (Object)null || !component.IsValid()) { continue; } long num2 = component.GetZDO().GetLong("moonass_uid", 0L); if (num2 != 0L && hashSet.Contains(num2)) { Vector3 val = ((Component)moonassWorker2).transform.position - ((Component)this).transform.position; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; moonassWorker = moonassWorker2; item = num2; } } } if ((Object)(object)moonassWorker == (Object)null) { return L.F("The {0} of this house are far away ({1}/{2}). Come closer to them", "{0} этого дома далеко ({1}/{2}). Подойдите к ним ближе", K.NomPl, list.Count, capacity); } Kind k = K; string tag = moonassWorker.Tag; moonassWorker.Remove(this); MoonassSpeech.Show(((Component)this).gameObject, MoonassSpeech.Pick(MoonassPhrase.Recall, k.Karlan), 2f); list.Remove(item); SaveMembers(list); MoonassesPlugin.Log.LogInfo((object)L.F("{0} at {1}: {2} {3} came back ({4}/{5})", "{0} в {1}: вернулся {2} {3} ({4}/{5})", k.Display, ((Component)this).transform.position, k.Nom, tag, list.Count, capacity)); return L.F("{0} {1} went back into the house ({2}/{3})", "{0} {1} вернулся в дом ({2}/{3})", k.Nom, tag, list.Count, capacity); } private Vector3 GroundAt(Vector3 p) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_0058: 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_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(p.x, p.y + 5f, p.z); float num = float.NaN; float num2 = float.MaxValue; int mask = LayerMask.GetMask(new string[4] { "terrain", "static_solid", "piece", "Default" }); RaycastHit[] array = Physics.RaycastAll(val, Vector3.down, 15f, mask, (QueryTriggerInteraction)1); for (int i = 0; i < array.Length; i++) { RaycastHit val2 = array[i]; if (!((Object)(object)((RaycastHit)(ref val2)).collider == (Object)null) && !((Component)((RaycastHit)(ref val2)).collider).transform.IsChildOf(((Component)this).transform) && ((RaycastHit)(ref val2)).distance < num2) { num2 = ((RaycastHit)(ref val2)).distance; num = ((RaycastHit)(ref val2)).point.y; } } if (!float.IsNaN(num)) { p.y = num; } return p + Vector3.up * 0.3f; } internal static GameObject CreateGhost(Kind kind) { GameObject val = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab(kind.HousePrefab) : null); if ((Object)(object)val == (Object)null) { return null; } ZNetView.m_forceDisableInit = true; GameObject val2; try { val2 = Object.Instantiate<GameObject>(val); } finally { ZNetView.m_forceDisableInit = false; } ((Object)val2).name = kind.HousePrefab + "Ghost"; Collider[] componentsInChildren = val2.GetComponentsInChildren<Collider>(true); foreach (Collider obj in componentsInChildren) { obj.enabled = false; Object.Destroy((Object)(object)obj); } Rigidbody[] componentsInChildren2 = val2.GetComponentsInChildren<Rigidbody>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.Destroy((Object)(object)componentsInChildren2[i]); } MoonassHouse component = val2.GetComponent<MoonassHouse>(); if ((Object)(object)component != (Object)null) { ((Behaviour)component).enabled = false; } return val2; } private Inventory LoadLost() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown Inventory val = new Inventory("moonass_lost", (Sprite)null, 8, 4); if ((Object)(object)_nview == (Object)null || !_nview.IsValid()) { return val; } string text = _nview.GetZDO().GetString("moonass_house_lost", ""); if (text == "") { return val; } try { val.Load(new ZPackage(text)); } catch (Exception ex) { MoonassesPlugin.Log.LogWarning((object)(L.F("{0}: the lost-and-found store could not be read: ", "{0}: склад потерянного не прочитан: ", K.Display) + ex.Message)); } return val; } private void SaveLost(Inventory inv) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown if (!((Object)(object)_nview == (Object)null) && _nview.IsValid()) { string text = ""; if (inv.GetAllItems().Count > 0) { ZPackage val = new ZPackage(); inv.Save(val); text = val.GetBase64(); } _nview.ClaimOwnership(); _nview.GetZDO().Set("moonass_house_lost", text); } } internal bool StoreLost(ItemData item) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) if (item == null || (Object)(object)_nview == (Object)null || !_nview.IsValid()) { return false; } Inventory val = LoadLost(); if (!val.CanAddItem(item, -1) || !val.AddItem(item)) { return false; } SaveLost(