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 ShrinkTotem v0.2.3
plugins/ShrinkTotem.dll
Decompiled 13 hours 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.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.AI; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyMetadata("PlanetRadialRewrite", "off")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [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 ShrinkTotem { [BepInPlugin("chistix.shrinktotem", "ShrinkTotem", "0.2.3")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { public const string Guid = "chistix.shrinktotem"; public const string Version = "0.2.3"; private void Awake() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) string text = OtherCopy(); if (text != null) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("the shrinking totem already runs inside " + text + ": this copy stays off")); return; } Module.Init(((BaseUnityPlugin)this).Config, ((BaseUnityPlugin)this).Logger); new Harmony("chistix.shrinktotem").PatchAll(typeof(Plugin).Assembly); } private static string OtherCopy() { bool flag = default(bool); foreach (Assembly item in from a in AppDomain.CurrentDomain.GetAssemblies() where a != typeof(Plugin).Assembly select a) { try { Type type = item.GetType("ShrinkTotem.Module", throwOnError: false); if (!(type == null)) { object obj = AccessTools.Field(type, "Initialized")?.GetValue(null); int num; if (obj is bool) { flag = (bool)obj; num = 1; } else { num = 0; } if (((uint)num & (flag ? 1u : 0u)) != 0) { return item.GetName().Name; } } } catch { } } return null; } } internal static class Agents { private static List<ShrinkMath.Agent> list; private static readonly Dictionary<(AgentType, int), AgentType> picked = new Dictionary<(AgentType, int), AgentType>(); internal static AgentType Pick(AgentType own, double factor) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Invalid comparison between I4 and Unknown //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) if (Math.Abs(factor - 1.0) < 1E-06 || !Read()) { return own; } (AgentType, int) key = (own, (int)Math.Round(factor * 1000.0)); if (picked.TryGetValue(key, out var value)) { return value; } ShrinkMath.Agent? agent = null; foreach (ShrinkMath.Agent item in list) { if (item.Type == (int)own) { agent = item; } } AgentType val = (AgentType)(agent.HasValue ? ShrinkMath.PickAgent(agent.Value, factor, list) : ((int)own)); picked[key] = val; return val; } private static bool Read() { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected I4, but got Unknown if (list != null) { return list.Count > 0; } Pathfinding instance = Pathfinding.instance; if ((Object)(object)instance == (Object)null || instance.m_agentSettings == null || instance.m_agentSettings.Count == 0) { return false; } list = new List<ShrinkMath.Agent>(); foreach (AgentSettings agentSetting in instance.m_agentSettings) { if (agentSetting != null) { list.Add(new ShrinkMath.Agent((int)agentSetting.m_agentType, ((NavMeshBuildSettings)(ref agentSetting.m_build)).agentRadius, ((NavMeshBuildSettings)(ref agentSetting.m_build)).agentHeight, agentSetting.m_canWalk, agentSetting.m_canSwim, agentSetting.m_avoidWater)); } } Module.Debug("path agents: " + string.Join(", ", list.ConvertAll((ShrinkMath.Agent a) => $"{(object)(AgentType)a.Type} r{a.Radius} h{a.Height}"))); return list.Count > 0; } } [HarmonyPatch(typeof(ZNetScene), "Awake")] internal static class ShrinkTotemScene { private static void Postfix(ZNetScene __instance) { if (Module.Initialized) { Totem.Register(__instance); } } } [HarmonyPatch(typeof(ObjectDB), "Awake")] internal static class ShrinkTotemDB { private static void Postfix(ObjectDB __instance) { if (Module.Initialized) { Totem.AddToHammer(__instance); } } } [HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")] internal static class ShrinkTotemDBCopy { private static void Postfix(ObjectDB __instance) { if (Module.Initialized) { Totem.AddToHammer(__instance); } } } [HarmonyPatch(typeof(Localization), "SetupLanguage")] internal static class ShrinkTotemWords { private static void Postfix(Localization __instance, string language) { if (Module.Initialized) { Module.Describe(language); Totem.Words(__instance, language == "Russian"); } } } [HarmonyPatch(typeof(Character), "Awake")] internal static class ShrinkTotemCreature { private static void Postfix(Character __instance) { if (Module.Initialized && !(__instance is Player) && !((Object)(object)((Component)__instance).GetComponent<ZNetView>() == (Object)null) && !((Object)(object)((Component)__instance).GetComponent<Shrunk>() != (Object)null)) { ((Component)__instance).gameObject.AddComponent<Shrunk>(); } } } [HarmonyPatch(typeof(GameCamera), "UpdateMouseCapture")] internal static class ShrinkTotemCursor { private static void Postfix() { if (TotemWindow.Open) { ZCursor.LockState = (CursorLockMode)0; ZCursor.Show(); } } } [HarmonyPatch(typeof(PlayerController), "TakeInput")] internal static class ShrinkTotemControllerInput { private static void Postfix(ref bool __result) { if (TotemWindow.Blocks) { __result = false; } } } [HarmonyPatch(typeof(Player), "TakeInput")] internal static class ShrinkTotemPlayerInput { private static void Postfix(ref bool __result) { if (TotemWindow.Blocks) { __result = false; } } } [HarmonyPatch(typeof(Menu), "Update")] internal static class ShrinkTotemEscape { private static bool Prefix() { if (!TotemWindow.Open || !ZInput.GetKeyDown((KeyCode)27, false)) { return true; } TotemWindow.Close(); return false; } } public sealed class Mark : MonoBehaviour, Hoverable, Interactable { public enum Kind { Corner1, Corner2, Radius } public Kind kind; private static readonly string[] Names = new string[3] { "chistix_shrink_mark_corner1", "chistix_shrink_mark_corner2", "chistix_shrink_mark_radius" }; private static readonly string[] Tokens = new string[3] { "$piece_chistix_shrinkmark_c1", "$piece_chistix_shrinkmark_c2", "$piece_chistix_shrinkmark_r" }; private static readonly Color[] Tints = (Color[])(object)new Color[3] { new Color(1f, 0.45f, 0.35f), new Color(0.45f, 0.6f, 1f), new Color(0.45f, 1f, 0.55f) }; private static readonly GameObject[] prefabs = (GameObject[])(object)new GameObject[3]; internal static Kind? Picked; internal static Vector3 PickedAt; internal static float PickedUntil; private const float Wait = 120f; private ZNetView nview; private Material tinted; internal static bool Waiting { get { if (Picked.HasValue) { return Time.time < PickedUntil; } return false; } } private void Awake() { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) nview = ((Component)this).GetComponent<ZNetView>(); try { MeshRenderer componentInChildren = ((Component)this).GetComponentInChildren<MeshRenderer>(); if ((Object)(object)componentInChildren != (Object)null && (Object)(object)((Renderer)componentInChildren).sharedMaterial != (Object)null && ((Renderer)componentInChildren).sharedMaterial.HasProperty("_Color")) { tinted = new Material(((Renderer)componentInChildren).sharedMaterial); tinted.color = ((Renderer)componentInChildren).sharedMaterial.color * Tints[(int)kind]; ((Renderer)componentInChildren).sharedMaterial = tinted; } } catch (Exception ex) { Module.Debug("mark tint: " + ex.Message); } } private void OnDestroy() { if ((Object)(object)tinted != (Object)null) { Object.Destroy((Object)(object)tinted); } } internal static string KindName(Kind k) { return Localization.instance.Localize(Tokens[(int)k]); } public string GetHoverText() { if ((Object)(object)nview == (Object)null || !nview.IsValid()) { return ""; } string text = KindName(kind) + "\n[<color=yellow><b>$KEY_Use</b></color>] " + Module.T("выбрать, затем нажать E на тотеме", "pick, then press E on the totem"); return Localization.instance.Localize(text); } public string GetHoverName() { return KindName(kind); } public float GetHoverOffset() { return 0f; } public bool Interact(Humanoid user, bool hold, bool alt) { //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) if (hold || (Object)(object)user != (Object)(object)Player.m_localPlayer || (Object)(object)nview == (Object)null || !nview.IsValid()) { return false; } Picked = kind; PickedAt = ((Component)this).transform.position; PickedUntil = Time.time + 120f; ((Character)Player.m_localPlayer).Message((MessageType)2, Module.T("Метка «" + KindName(kind) + "» выбрана — теперь нажмите E на тотеме", "Mark \"" + KindName(kind) + "\" picked - now press E on the totem"), 0, (Sprite)null, false); return true; } public bool UseItem(Humanoid user, ItemData item) { return false; } internal static void Clear() { Picked = null; } internal static void Register(ZNetScene scene) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //IL_0086: 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_00b2: 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) if ((Object)(object)prefabs[0] == (Object)null) { GameObject val = scene.GetPrefab("wood_pole2") ?? scene.GetPrefab("wood_pole"); if ((Object)(object)val == (Object)null) { Module.Warn("no wood_pole2: the zone marks are not made"); return; } GameObject val2 = new GameObject("ShrinkTotemMarks"); val2.SetActive(false); Object.DontDestroyOnLoad((Object)(object)val2); for (int i = 0; i < 3; i++) { GameObject val3 = Object.Instantiate<GameObject>(val, val2.transform); ((Object)val3).name = Names[i]; val3.transform.localScale = new Vector3(val.transform.localScale.x * 1.4f, val.transform.localScale.y * 0.6f, val.transform.localScale.z * 1.4f); val3.AddComponent<Mark>().kind = (Kind)i; Piece component = val3.GetComponent<Piece>(); component.m_name = Tokens[i]; component.m_description = Tokens[i] + "_desc"; prefabs[i] = val3; } } GameObject[] array = prefabs; foreach (GameObject val4 in array) { int stableHashCode = StringExtensionMethods.GetStableHashCode(((Object)val4).name); if (!scene.m_namedPrefabs.ContainsKey(stableHashCode)) { scene.m_prefabs.Add(val4); scene.m_namedPrefabs.Add(stableHashCode, val4); } } } internal static void AddToHammer(ObjectDB db, PieceTable table, CraftingStation station) { GameObject[] array = prefabs; foreach (GameObject val in array) { if (!((Object)(object)val == (Object)null)) { Piece component = val.GetComponent<Piece>(); component.m_resources = Totem.Requirements(db, Module.MarkIngredients.Value, "mark"); component.m_craftingStation = station; if (!table.m_pieces.Contains(val)) { table.m_pieces.Add(val); } } } } internal static void Words(MethodInfo add, Localization localization, bool ru) { string[] array = new string[3] { "Метка зоны: угол 1", "Метка зоны: угол 2", "Метка зоны: радиус" }; string[] array2 = new string[3] { "Zone mark: corner 1", "Zone mark: corner 2", "Zone mark: radius" }; string text = "Метка для зоны тотема уменьшения: нажми E на метке, затем E на тотеме. Радиус — круг через метку; угол 1 и угол 2 — прямоугольник между ними вдоль сторон тотема. После этого метку можно убрать."; string text2 = "A mark for the shrinking totem's zone: E on the mark, then E on the totem. Radius: a circle through the mark; corner 1 and corner 2: the rectangle between them along the totem's sides. The mark may be taken down afterwards."; for (int i = 0; i < 3; i++) { add.Invoke(localization, new object[2] { Tokens[i].Substring(1), ru ? array[i] : array2[i] }); add.Invoke(localization, new object[2] { Tokens[i].Substring(1) + "_desc", ru ? text : text2 }); } } } public sealed class RectProjector : MonoBehaviour { public GameObject prefab; public LayerMask mask; internal ShrinkMath.Zone zone; internal Quaternion turn = Quaternion.identity; private readonly List<GameObject> segments = new List<GameObject>(); private ShrinkMath.Zone built; private bool any; private void OnDisable() { foreach (GameObject segment in segments) { if ((Object)(object)segment != (Object)null) { segment.SetActive(false); } } } private void Update() { //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: 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_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0192: 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_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: 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_01a5: 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) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_0211: 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_025a: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)prefab == (Object)null) { return; } List<(double, double)> list = ShrinkMath.Outline(zone, 2.5); if (!any || built.MinX != zone.MinX || built.MaxX != zone.MaxX || built.MinZ != zone.MinZ || built.MaxZ != zone.MaxZ || segments.Count != list.Count) { foreach (GameObject segment in segments) { if ((Object)(object)segment != (Object)null) { Object.Destroy((Object)(object)segment); } } segments.Clear(); foreach (var item3 in list) { _ = item3; segments.Add(Object.Instantiate<GameObject>(prefab, ((Component)this).transform.position, Quaternion.identity, ((Component)this).transform)); } built = zone; any = true; } Vector3 position = ((Component)this).transform.position; RaycastHit val2 = default(RaycastHit); for (int i = 0; i < list.Count; i++) { (double, double) tuple = list[i]; double item = tuple.Item1; double item2 = tuple.Item2; Vector3 val = position + turn * new Vector3((float)item, 0f, (float)item2); if (Physics.Raycast(val + Vector3.up * 500f, Vector3.down, ref val2, 1000f, ((LayerMask)(ref mask)).value)) { val.y = ((RaycastHit)(ref val2)).point.y; } GameObject val3 = segments[i]; if (!val3.activeSelf) { val3.SetActive(true); } val3.transform.position = val; } for (int j = 0; j < list.Count; j++) { Vector3 position2 = segments[(j + list.Count - 1) % list.Count].transform.position; Vector3 val4 = segments[(j + 1) % list.Count].transform.position - position2; if (((Vector3)(ref val4)).sqrMagnitude > 1E-06f) { segments[j].transform.rotation = Quaternion.LookRotation(((Vector3)(ref val4)).normalized, Vector3.up); } } } } public static class Module { private sealed class Runner : MonoBehaviour { private void Update() { try { TotemWindow.Tick(); } catch (Exception ex) { Warn("window: " + ex.Message); TotemWindow.Close(); } } private void OnGUI() { try { TotemWindow.Fallback(); } catch (Exception ex) { Warn("window: " + ex.Message); TotemWindow.Close(); } } } public const string Version = "0.2.3"; public const string Section = "ShrinkTotem"; public static bool Initialized; internal static ConfigEntry<bool> Enabled; internal static ConfigEntry<bool> AnyoneCanChange; internal static ConfigEntry<bool> PathBySize; internal static ConfigEntry<bool> ByKind; internal static ConfigEntry<bool> DebugLog; internal static ConfigEntry<int> Radius; internal static ConfigEntry<int> MaxZone; internal static ConfigEntry<float> Step; internal static ConfigEntry<float> Min; internal static ConfigEntry<float> Max; internal static ConfigEntry<string> Ingredients; internal static ConfigEntry<string> Station; internal static ConfigEntry<string> MarkIngredients; private static ManualLogSource log; private static Func<bool> hostAllows; private static readonly int[] Radii = new int[10] { 8, 10, 12, 16, 20, 24, 32, 40, 48, 64 }; private static readonly float[] Steps = new float[4] { 0.05f, 0.1f, 0.2f, 0.25f }; private static readonly float[] Mins = new float[10] { 0.2f, 0.25f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1f }; private static readonly float[] Maxes = new float[8] { 1f, 1.1f, 1.2f, 1.25f, 1.3f, 1.5f, 1.75f, 2f }; private static readonly Dictionary<ConfigEntryBase, (string ru, string en)> texts = new Dictionary<ConfigEntryBase, (string, string)>(); private static readonly FieldRef<ConfigEntryBase, ConfigDescription> Description = AccessTools.FieldRefAccess<ConfigEntryBase, ConfigDescription>("<Description>k__BackingField"); private static string described; internal static bool Active { get { if (Initialized && Enabled.Value) { if (hostAllows != null) { return SafeHost(); } return true; } return false; } } internal static bool Russian { get { if (Localization.instance != null) { return Localization.instance.GetSelectedLanguage() == "Russian"; } return false; } } private static bool SafeHost() { try { return hostAllows(); } catch { return true; } } public static void Init(ConfigFile config, ManualLogSource logger, Func<bool> hostSwitch = null) { //IL_02fa: 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_0305: Expected O, but got Unknown if (Initialized) { return; } log = logger; hostAllows = hostSwitch; Enabled = Bind(config, "Enabled", value: true, "Тотем уменьшает ручных зверей в своём радиусе. Выключено — все звери своего размера (тотемы стоят, размеры в них запомнены).", "The totem shrinks tamed creatures within its radius. Off: every creature has its own size (the totems stay, the sizes set in them are kept)."); Radius = Bind(config, "Radius", 32, "Радиус тотема без своей зоны, м (у оберега 32). Своя зона задаётся метками: «радиус» — круг, «угол 1» и «угол 2» — прямоугольник.", "The radius of a totem without its own zone, m (a ward has 32). Its own zone is set by marks: radius - a circle, corner 1 and corner 2 - a rectangle.", (AcceptableValueBase)(object)new AcceptableValueList<int>(Radii)); MaxZone = Bind(config, "MaxZone", 64, "Своя зона тотема (по меткам) не дальше этого от тотема, м.", "A totem's own zone (by marks) reaches no farther than this from it, m.", (AcceptableValueBase)(object)new AcceptableValueList<int>(new int[6] { 16, 24, 32, 48, 64, 96 })); MarkIngredients = Bind(config, "MarkIngredients", "Wood:2", "Из чего строится метка зоны (угол 1, угол 2, радиус): «Предмет:количество» через запятую.", "What a zone mark (corner 1, corner 2, radius) is built from: \"Item:amount\" separated by commas."); Step = Bind(config, "Step", 0.1f, "На сколько меняют размер кнопки − и +.", "How much the − and + buttons change the size.", (AcceptableValueBase)(object)new AcceptableValueList<float>(Steps)); Min = Bind(config, "Min", 0.3f, "Самый маленький размер (доля родного).", "The smallest size (part of the creature's own).", (AcceptableValueBase)(object)new AcceptableValueList<float>(Mins)); Max = Bind(config, "Max", 1.5f, "Самый большой размер (доля родного).", "The largest size (part of the creature's own).", (AcceptableValueBase)(object)new AcceptableValueList<float>(Maxes)); AnyoneCanChange = Bind(config, "AnyoneCanChange", value: false, "Размеры у тотема меняет любой игрок. Выключено — только поставивший тотем и те, кому можно у оберега, под которым стоит тотем (владелец и разрешённые).", "Anyone may change the sizes at a totem. Off: only who built it and the ones a ward over the totem lets in (its owner and the permitted)."); PathBySize = Bind(config, "PathBySize", value: true, "Поиск пути по размеру: уменьшенный зверь ищет путь как меньший зверь игры (проходит в узкие ворота загона), увеличенный — как больший. Выключено — всегда как свой вид (так игра делает при своём «размере врагов»).", "Paths by size: a shrunk creature finds its way like a smaller creature of the game (through a narrow pen gate), a grown one like a larger one. Off: always like its own kind (as the game does with its own enemy size setting)."); Ingredients = Bind(config, "Ingredients", "Stone:10,Wood:5,Resin:5,GreydwarfEye:3", "Из чего строится тотем: «Предмет:количество» через запятую (имена префабов игры).", "What the totem is built from: \"Item:amount\" separated by commas (the game's prefab names)."); Station = Bind(config, "Station", "piece_workbench", "Какая станция нужна рядом (имя префаба; пусто — без станции).", "The station needed near (prefab name; empty: none)."); ByKind = Bind(config, "ListByKind", value: false, "Окно тотема: список по видам (строка на вид: сколько, размер, − / + для всех этого вида). Выключено — каждое существо отдельно. Меняется и кнопкой в окне; у каждого игрока своё.", "The totem window: a list by kinds (a row per kind: how many, the size, − / + for all of that kind). Off: each creature on its own. Also switched by the window's button; each player has their own."); DebugLog = Bind(config, "DebugLog", value: false, "Подробности в журнал.", "Details in the log."); Ingredients.SettingChanged += delegate { Totem.AddToHammer(ObjectDB.instance); }; Station.SettingChanged += delegate { Totem.AddToHammer(ObjectDB.instance); }; MarkIngredients.SettingChanged += delegate { Totem.AddToHammer(ObjectDB.instance); }; MaxZone.SettingChanged += delegate { Totem.RadiusChanged(); }; Radius.SettingChanged += delegate { Totem.RadiusChanged(); }; Initialized = true; Localization instance = Localization.instance; Describe((instance != null) ? instance.GetSelectedLanguage() : null); try { Localization instance2 = Localization.instance; if (instance2 != null) { Totem.Words(instance2, instance2.GetSelectedLanguage() == "Russian"); } } catch (Exception ex) { Warn("words: " + ex.Message); } GameObject val = new GameObject("ShrinkTotem"); Object.DontDestroyOnLoad((Object)val); val.AddComponent<Runner>(); Log("shrinking totem 0.2.3"); } private static ConfigEntry<T> Bind<T>(ConfigFile config, string key, T value, string ru, string en, AcceptableValueBase accept = null) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown ConfigEntry<T> val = config.Bind<T>("ShrinkTotem", key, value, new ConfigDescription(ru, accept, Array.Empty<object>())); texts[(ConfigEntryBase)(object)val] = (ru, en); return val; } internal static void Describe(string language) { //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown if (!Initialized) { return; } if (string.IsNullOrEmpty(language)) { language = PlayerPrefs.GetString("language", "English"); } if (language == described) { return; } described = language; bool flag = language == "Russian"; foreach (KeyValuePair<ConfigEntryBase, (string, string)> text2 in texts) { ConfigDescription description = text2.Key.Description; string text = (flag ? text2.Value.Item1 : text2.Value.Item2); if (description != null && !(description.Description == text)) { try { Description.Invoke(text2.Key) = new ConfigDescription(text, description.AcceptableValues, description.Tags ?? new object[0]); } catch (Exception ex) { Warn("setting text: " + ex.Message); break; } } } } internal static string T(string ru, string en) { if (!Russian) { return en; } return ru; } internal static void Log(string text) { ManualLogSource obj = log; if (obj != null) { obj.LogInfo((object)text); } } internal static void Warn(string text) { ManualLogSource obj = log; if (obj != null) { obj.LogWarning((object)text); } } internal static void Debug(string text) { if (DebugLog != null && DebugLog.Value) { ManualLogSource obj = log; if (obj != null) { obj.LogInfo((object)text); } } } } internal static class ShrinkMath { internal sealed class ScaleState { public double Bx = 1.0; public double By = 1.0; public double Bz = 1.0; public double Wx; public double Wy; public double Wz; public double Shown = 1.0; public bool Written; public bool Settled; private const double Tolerance = 1E-05; private static bool Same(double ax, double ay, double az, double bx, double by, double bz) { return (ax - bx) * (ax - bx) + (ay - by) * (ay - by) + (az - bz) * (az - bz) < 1.0000000000000002E-10; } public bool Step(double ox, double oy, double oz, double target, double dt, out double x, out double y, out double z) { x = ox; y = oy; z = oz; Settled = false; if (!Written && target == 1.0 && Shown == 1.0) { return false; } if (!Written || !Same(ox, oy, oz, Wx, Wy, Wz)) { Bx = ox; By = oy; Bz = oz; } double num = Approach(Shown, target, dt); Settled = num == target && Shown != target; Shown = num; if (Shown == 1.0 && target == 1.0) { bool written = Written; Written = false; x = Bx; y = By; z = Bz; if (written) { return !Same(ox, oy, oz, Bx, By, Bz); } return false; } x = (float)Compose(Bx, Shown); y = (float)Compose(By, Shown); z = (float)Compose(Bz, Shown); bool result = !Written || !Same(ox, oy, oz, x, y, z); Wx = x; Wy = y; Wz = z; Written = true; return result; } } internal struct Agent { public int Type; public double Radius; public double Height; public bool Walk; public bool Swim; public bool AvoidWater; public Agent(int type, double radius, double height, bool walk = true, bool swim = true, bool avoidWater = false) { Type = type; Radius = radius; Height = height; Walk = walk; Swim = swim; AvoidWater = avoidWater; } } internal sealed class Row { public string Kind = ""; public string KindKey = ""; public string Name = ""; public long User; public uint Id; public double Factor = 1.0; public object Tag; } internal sealed class Group { public string Kind; public string KindKey; public readonly List<Row> Rows = new List<Row>(); public double Lo = double.MaxValue; public double Hi = double.MinValue; } internal enum Shape { Default, Circle, Rect } internal struct Zone { public Shape Shape; public double Radius; public double MinX; public double MaxX; public double MinZ; public double MaxZ; public const double Height = 30.0; public double Width => MaxX - MinX; public double Length => MaxZ - MinZ; public bool Contains(double x, double y, double z, double defaultRadius) { if (Shape == Shape.Rect) { if (x >= MinX && x <= MaxX && z >= MinZ && z <= MaxZ) { return Math.Abs(y) <= 30.0; } return false; } double num = ((Shape == Shape.Circle) ? Radius : defaultRadius); if (x * x + z * z <= num * num) { return Math.Abs(y) <= Math.Max(num, 30.0); } return false; } public double Reach(double defaultRadius) { if (Shape == Shape.Rect) { return Math.Sqrt(Math.Max(MinX * MinX, MaxX * MaxX) + Math.Max(MinZ * MinZ, MaxZ * MaxZ)); } if (Shape != Shape.Circle) { return defaultRadius; } return Radius; } } internal static double Clamp(double value, double min, double max) { if (double.IsNaN(value) || double.IsInfinity(value)) { return 1.0; } if (min > max) { double num = min; min = max; max = num; } return Math.Max(min, Math.Min(max, value)); } internal static double Round(double value, double step) { if (!(step <= 0.0)) { return Math.Round(value / step) * step; } return value; } internal static double Step(double value, int dir, double step, double min, double max) { if (step <= 0.0) { step = 0.1; } double num = Clamp(value, min, max); double num2 = Round(num, step); return Math.Round(Clamp((Math.Abs(num2 - num) > 1E-06 && Math.Sign(num2 - num) == Math.Sign(dir)) ? num2 : (num2 + (double)dir * step), min, max), 4); } internal static double Effective(double stored, bool inside, double min, double max) { if (!inside) { return 1.0; } return Math.Round(Clamp(stored, min, max), 4); } internal static double Approach(double shown, double target, double dt, double rate = 1.5) { if (shown <= 0.0 || target <= 0.0) { return target; } double num = Math.Log(shown); double num2 = Math.Log(target); double num3 = rate * Math.Max(0.0, dt); if (Math.Abs(num2 - num) <= num3) { return target; } return Math.Exp(num + (double)Math.Sign(num2 - num) * num3); } internal static double Compose(double otherBase, double factor) { return otherBase * factor; } internal static bool MayChange(bool creator, bool underWard, bool wardPermits, bool anyone) { if (!(anyone || creator)) { return underWard && wardPermits; } return true; } internal static bool Inside(double distance, double radius) { return distance <= radius; } internal static string Format(double factor) { return "×" + Math.Round(factor, 2).ToString("0.0#", CultureInfo.InvariantCulture); } internal static List<KeyValuePair<string, int>> ParseRecipe(string text, List<string> errors) { List<KeyValuePair<string, int>> list = new List<KeyValuePair<string, int>>(); string[] array = (text ?? "").Split(','); for (int i = 0; i < array.Length; i++) { string text2 = array[i].Trim(); if (text2.Length != 0) { string[] array2 = text2.Split(':'); string text3 = array2[0].Trim(); int result = 1; if (text3.Length == 0 || (array2.Length > 1 && (!int.TryParse(array2[1].Trim(), NumberStyles.Integer, CultureInfo.InvariantCulture, out result) || result <= 0)) || array2.Length > 2) { errors?.Add(text2); } else { list.Add(new KeyValuePair<string, int>(text3, result)); } } } return list; } internal static int PickAgent(Agent own, double factor, IEnumerable<Agent> agents) { if (factor <= 0.0 || Math.Abs(factor - 1.0) < 1E-06 || !own.Walk || agents == null) { return own.Type; } double num = own.Radius * factor - 0.0001; double num2 = own.Height * factor - 0.0001; Agent agent = own; bool flag = false; foreach (Agent agent2 in agents) { if (agent2.Walk && agent2.Swim == own.Swim && agent2.AvoidWater == own.AvoidWater && !(agent2.Radius < num) && !(agent2.Height < num2) && (!(factor < 1.0) || (!(agent2.Radius > own.Radius + 1E-06) && !(agent2.Height > own.Height + 1E-06))) && (!(factor > 1.0) || (!(agent2.Radius < own.Radius - 1E-06) && !(agent2.Height < own.Height - 1E-06))) && (!flag || agent2.Radius < agent.Radius - 1E-06 || (Math.Abs(agent2.Radius - agent.Radius) < 1E-06 && (agent2.Height < agent.Height - 1E-06 || (Math.Abs(agent2.Height - agent.Height) < 1E-06 && agent2.Type == own.Type))))) { agent = agent2; flag = true; } } if (!flag) { return own.Type; } return agent.Type; } internal static List<Row> Ordered(IEnumerable<Row> rows) { return rows.OrderBy<Row, string>((Row r) => r.Kind ?? "", StringComparer.OrdinalIgnoreCase).ThenBy<Row, string>((Row r) => r.KindKey ?? "", StringComparer.Ordinal).ThenBy<Row, string>((Row r) => r.Name ?? "", StringComparer.OrdinalIgnoreCase) .ThenBy((Row r) => r.User) .ThenBy((Row r) => r.Id) .ToList(); } internal static List<Group> Groups(IEnumerable<Row> rows) { List<Group> list = new List<Group>(); Dictionary<string, Group> dictionary = new Dictionary<string, Group>(); foreach (Row item in Ordered(rows)) { string key = item.KindKey + "\n" + item.Kind; if (!dictionary.TryGetValue(key, out var value)) { value = (dictionary[key] = new Group { Kind = item.Kind, KindKey = item.KindKey }); list.Add(value); } value.Rows.Add(item); value.Lo = Math.Min(value.Lo, item.Factor); value.Hi = Math.Max(value.Hi, item.Factor); } return list; } internal static string FormatRange(double lo, double hi) { if (lo > hi) { return Format(1.0); } if (Math.Abs(Math.Round(lo, 2) - Math.Round(hi, 2)) < 1E-09) { return Format(lo); } return Format(lo) + "–" + Math.Round(hi, 2).ToString("0.0#", CultureInfo.InvariantCulture); } internal static Zone CircleTo(double x, double z, double max) { return new Zone { Shape = Shape.Circle, Radius = Math.Round(Clamp(Math.Sqrt(x * x + z * z), 1.0, max), 1) }; } internal static Zone RectBetween(double ax, double az, double bx, double bz, double max) { double num = Clamp(Math.Min(ax, bx), 0.0 - max, max); double num2 = Clamp(Math.Max(ax, bx), 0.0 - max, max); double num3 = Clamp(Math.Min(az, bz), 0.0 - max, max); double num4 = Clamp(Math.Max(az, bz), 0.0 - max, max); if (num2 - num < 1.0) { double num5 = (num2 + num) / 2.0; num = num5 - 0.5; num2 = num5 + 0.5; } if (num4 - num3 < 1.0) { double num6 = (num4 + num3) / 2.0; num3 = num6 - 0.5; num4 = num6 + 0.5; } return new Zone { Shape = Shape.Rect, MinX = Math.Round(num, 2), MaxX = Math.Round(num2, 2), MinZ = Math.Round(num3, 2), MaxZ = Math.Round(num4, 2) }; } internal static List<(double x, double z)> Outline(Zone zone, double spacing) { List<(double, double)> list = new List<(double, double)>(); (double, double)[] array = new(double, double)[4] { (zone.MinX, zone.MinZ), (zone.MaxX, zone.MinZ), (zone.MaxX, zone.MaxZ), (zone.MinX, zone.MaxZ) }; for (int i = 0; i < 4; i++) { (double, double) tuple = array[i]; double item = tuple.Item1; double item2 = tuple.Item2; (double, double) tuple2 = array[(i + 1) % 4]; double item3 = tuple2.Item1; double item4 = tuple2.Item2; double num = Math.Sqrt((item3 - item) * (item3 - item) + (item4 - item2) * (item4 - item2)); int num2 = Math.Max(1, (int)Math.Ceiling(num / Math.Max(0.1, spacing))); for (int j = 0; j < num2; j++) { list.Add((item + (item3 - item) * (double)j / (double)num2, item2 + (item4 - item2) * (double)j / (double)num2)); } } return list; } internal static int Pages(int count, int perPage) { if (perPage > 0) { return Math.Max(1, (count + perPage - 1) / perPage); } return 1; } internal static int Page(int page, int count, int perPage) { return Math.Max(0, Math.Min(Pages(count, perPage) - 1, page)); } } public sealed class Shrunk : MonoBehaviour { public static readonly int KScale = StringExtensionMethods.GetStableHashCode("chistix_shrink_scale"); internal const string RpcSet = "chistix_shrink_set"; internal static readonly List<Shrunk> All = new List<Shrunk>(); private ZNetView nview; private Character character; private BaseAI ai; private AgentType ownAgent; private bool syncScale; private bool registered; private bool agentSet; private readonly ShrinkMath.ScaleState state = new ShrinkMath.ScaleState(); private double target = 1.0; private float nextCheck; internal float Stored { get { if (!((Object)(object)nview != (Object)null) || !nview.IsValid()) { return 1f; } return nview.GetZDO().GetFloat(KScale, 1f); } } public static event Action<Character, float> Settled; public static float FactorOf(Character c) { Shrunk shrunk = (((Object)(object)c != (Object)null) ? ((Component)c).GetComponent<Shrunk>() : null); if (!((Object)(object)shrunk != (Object)null)) { return 1f; } return (float)shrunk.state.Shown; } private void Awake() { //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) nview = ((Component)this).GetComponent<ZNetView>(); character = ((Component)this).GetComponent<Character>(); ai = ((Component)this).GetComponent<BaseAI>(); if ((Object)(object)ai != (Object)null) { ownAgent = ai.m_pathAgentType; } ZSyncTransform component = ((Component)this).GetComponent<ZSyncTransform>(); syncScale = (Object)(object)component != (Object)null && component.m_syncScale; nextCheck = Time.time + Random.Range(0.3f, 1.2f); All.Add(this); Register(); } private void Register() { if (registered || (Object)(object)nview == (Object)null || !nview.IsValid()) { return; } registered = true; nview.Register<float>("chistix_shrink_set", (Action<long, float>)delegate(long sender, float value) { if (nview.IsValid() && nview.IsOwner()) { float num = (float)ShrinkMath.Clamp(value, Module.Min.Value, Module.Max.Value); if (Mathf.Approximately(num, 1f)) { nview.GetZDO().RemoveFloat(KScale); } else { nview.GetZDO().Set(KScale, num); } Module.Debug($"size of {((Object)this).name} set to {num}"); } }); } private void OnDestroy() { All.Remove(this); } internal void Set(float value) { Register(); if (!((Object)(object)nview == (Object)null) && nview.IsValid()) { nview.InvokeRPC("chistix_shrink_set", new object[1] { value }); } } private void Update() { //IL_00aa: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) if (Time.time >= nextCheck) { nextCheck = Time.time + 0.5f; if (!registered) { Register(); } target = Target(); PathAgent(); } if ((!state.Written && target == 1.0 && state.Shown == 1.0) || (syncScale && (Object)(object)nview != (Object)null && nview.IsValid() && !nview.IsOwner())) { return; } Vector3 localScale = ((Component)this).transform.localScale; if (state.Step(localScale.x, localScale.y, localScale.z, target, Time.deltaTime, out var x, out var y, out var z)) { ((Component)this).transform.localScale = new Vector3((float)x, (float)y, (float)z); } if (state.Settled && (Object)(object)character != (Object)null) { try { Shrunk.Settled?.Invoke(character, (float)state.Shown); } catch (Exception ex) { Module.Warn("size listener: " + ex.Message); } } } private void PathAgent() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_0075: 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_009a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ai == (Object)null) { return; } AgentType val = ((Module.Active && Module.PathBySize.Value) ? Agents.Pick(ownAgent, target) : ownAgent); if (val != ownAgent || agentSet) { agentSet = val != ownAgent; if (ai.m_pathAgentType != val) { ai.m_pathAgentType = val; Module.Debug($"{((Object)this).name}: path agent {val} (own {ownAgent}, ×{target:0.##})"); } } } private double Target() { //IL_0079: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)character != (Object)null && character.IsDead()) { return state.Shown; } if (!Module.Active || (Object)(object)character == (Object)null || !character.IsTamed()) { return 1.0; } float stored = Stored; if (Mathf.Approximately(stored, 1f)) { return 1.0; } return ShrinkMath.Effective(stored, Totem.InAny(((Component)this).transform.position), Module.Min.Value, Module.Max.Value); } } public sealed class Totem : MonoBehaviour, Hoverable, Interactable { public const string PrefabName = "chistix_shrink_totem"; public const string NameToken = "$piece_chistix_shrinktotem"; internal static readonly List<Totem> All = new List<Totem>(); private static GameObject prefab; private static readonly Color Green = new Color(0.35f, 1f, 0.5f); public GameObject marker; public GameObject glow; public Renderer model; public float hoverOffset; private ZNetView nview; private Piece piece; private CircleProjector projector; private Material tinted; private bool real; private float showUntil; public static readonly int KShape = StringExtensionMethods.GetStableHashCode("chistix_shrink_zone"); public static readonly int KRadius = StringExtensionMethods.GetStableHashCode("chistix_shrink_zone_r"); public static readonly int KCornerA = StringExtensionMethods.GetStableHashCode("chistix_shrink_zone_a"); public static readonly int KCornerB = StringExtensionMethods.GetStableHashCode("chistix_shrink_zone_b"); public static readonly int KHasA = StringExtensionMethods.GetStableHashCode("chistix_shrink_zone_has_a"); public static readonly int KHasB = StringExtensionMethods.GetStableHashCode("chistix_shrink_zone_has_b"); private ShrinkMath.Zone zone; private uint zoneRevision = uint.MaxValue; private RectProjector rect; internal Vector3 Center => ((Component)this).transform.position; internal static float Radius => (Module.Radius != null) ? Module.Radius.Value : 32; internal ShrinkMath.Zone Zone { get { //IL_00aa: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) if (!real || (Object)(object)nview == (Object)null || !nview.IsValid()) { return zone; } ZDO zDO = nview.GetZDO(); if (zDO.DataRevision == zoneRevision) { return zone; } zoneRevision = zDO.DataRevision; ShrinkMath.Shape shape = (ShrinkMath.Shape)Mathf.Clamp(zDO.GetInt(KShape, 0), 0, 2); switch (shape) { case ShrinkMath.Shape.Circle: zone = new ShrinkMath.Zone { Shape = shape, Radius = zDO.GetFloat(KRadius, Radius) }; break; case ShrinkMath.Shape.Rect: { Vector3 vec = zDO.GetVec3(KCornerA, Vector3.zero); Vector3 vec2 = zDO.GetVec3(KCornerB, Vector3.zero); zone = ShrinkMath.RectBetween(vec.x, vec.z, vec2.x, vec2.z, Module.MaxZone.Value); break; } default: zone = new ShrinkMath.Zone { Shape = ShrinkMath.Shape.Default }; break; } ShowZone(); return zone; } } internal float Reach => (float)Zone.Reach(Radius); private void Awake() { nview = ((Component)this).GetComponent<ZNetView>(); piece = ((Component)this).GetComponent<Piece>(); real = (Object)(object)nview != (Object)null && nview.IsValid(); projector = (((Object)(object)marker != (Object)null) ? marker.GetComponent<CircleProjector>() : null); if ((Object)(object)projector != (Object)null) { projector.m_radius = Radius; } if ((Object)(object)marker != (Object)null) { marker.SetActive(!real); } if ((Object)(object)glow != (Object)null) { glow.SetActive(real); } if (real) { All.Add(this); } Tint(); } private void OnDestroy() { All.Remove(this); if ((Object)(object)TotemWindow.Of == (Object)(object)this) { TotemWindow.Close(); } if ((Object)(object)tinted != (Object)null) { Object.Destroy((Object)(object)tinted); } } private void Update() { if (real) { bool flag = Zone.Shape == ShrinkMath.Shape.Rect; bool flag2 = Time.time < showUntil || (Object)(object)TotemWindow.Of == (Object)(object)this; if ((Object)(object)marker != (Object)null && marker.activeSelf != (flag2 && !flag)) { marker.SetActive(flag2 && !flag); } if ((Object)(object)rect != (Object)null && ((Component)rect).gameObject.activeSelf != (flag2 && flag)) { ((Component)rect).gameObject.SetActive(flag2 && flag); } } } internal static void RadiusChanged() { foreach (Totem item in All) { if ((Object)(object)item != (Object)null) { item.zoneRevision = uint.MaxValue; } } } private void Tint() { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_0062: 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_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)model != (Object)null && (Object)(object)model.sharedMaterial != (Object)null && model.sharedMaterial.HasProperty("_EmissionColor")) { tinted = new Material(model.sharedMaterial); tinted.SetColor("_EmissionColor", Green * 1.6f); tinted.EnableKeyword("_EMISSION"); Material[] sharedMaterials = model.sharedMaterials; for (int i = 0; i < sharedMaterials.Length; i++) { if ((Object)(object)sharedMaterials[i] == (Object)(object)model.sharedMaterial) { sharedMaterials[i] = tinted; } } model.sharedMaterials = sharedMaterials; } if ((Object)(object)glow != (Object)null) { Light[] componentsInChildren = glow.GetComponentsInChildren<Light>(true); for (int j = 0; j < componentsInChildren.Length; j++) { componentsInChildren[j].color = Green; } ParticleSystem[] componentsInChildren2 = glow.GetComponentsInChildren<ParticleSystem>(true); for (int j = 0; j < componentsInChildren2.Length; j++) { MainModule main = componentsInChildren2[j].main; ((MainModule)(ref main)).startColor = new MinMaxGradient(Green); } } } catch (Exception ex) { Module.Debug("totem tint: " + ex.Message); } } private Vector3 Local(Vector3 world) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) return Quaternion.Inverse(((Component)this).transform.rotation) * (world - Center); } internal bool Contains(Vector3 point) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Local(point); return Zone.Contains(val.x, val.y, val.z, Radius); } private void ShowZone() { //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)marker == (Object)null)) { bool num = zone.Shape == ShrinkMath.Shape.Rect; if ((Object)(object)projector != (Object)null) { projector.m_radius = ((zone.Shape == ShrinkMath.Shape.Circle) ? ((float)zone.Radius) : Radius); } if (num && (Object)(object)rect == (Object)null && (Object)(object)projector != (Object)null && (Object)(object)projector.m_prefab != (Object)null) { GameObject val = new GameObject("rect"); val.SetActive(false); val.transform.SetParent(((Component)this).transform, false); rect = val.AddComponent<RectProjector>(); rect.prefab = projector.m_prefab; rect.mask = projector.m_mask; } if ((Object)(object)rect != (Object)null) { rect.zone = zone; rect.turn = ((Component)this).transform.rotation; } } } private bool UseMark() { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_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_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: 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_01d1: 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_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) if (!Mark.Waiting) { return false; } Mark.Kind value = Mark.Picked.Value; Player localPlayer = Player.m_localPlayer; if (!MayChange()) { ((Character)localPlayer).Message((MessageType)2, Module.T("Зону этого тотема менять нельзя: только поставивший или разрешённые у оберега", "You may not change this totem's zone: only who built it or the ward's permitted"), 0, (Sprite)null, false); return true; } Vector3 val = Local(Mark.PickedAt); float num = Module.MaxZone.Value; Vector2 val2 = new Vector2(val.x, val.z); if (((Vector2)(ref val2)).magnitude > num * 1.5f) { ((Character)localPlayer).Message((MessageType)2, Module.T($"Метка слишком далеко от тотема (больше {num} м)", $"The mark is too far from the totem (over {num} m)"), 0, (Sprite)null, false); return true; } if (!nview.IsOwner()) { nview.ClaimOwnership(); } ZDO zDO = nview.GetZDO(); string text; if (value == Mark.Kind.Radius) { ShrinkMath.Zone zone = ShrinkMath.CircleTo(val.x, val.z, num); zDO.Set(KShape, 1, false); zDO.Set(KRadius, (float)zone.Radius); text = Module.T($"Зона тотема: круг радиусом {zone.Radius:0.#} м", $"Totem zone: a circle of {zone.Radius:0.#} m"); } else { bool flag = value == Mark.Kind.Corner1; zDO.Set(flag ? KCornerA : KCornerB, new Vector3(val.x, 0f, val.z)); zDO.Set(flag ? KHasA : KHasB, true); if (zDO.GetBool(flag ? KHasB : KHasA, false)) { Vector3 vec = zDO.GetVec3(KCornerA, Vector3.zero); Vector3 vec2 = zDO.GetVec3(KCornerB, Vector3.zero); ShrinkMath.Zone zone2 = ShrinkMath.RectBetween(vec.x, vec.z, vec2.x, vec2.z, num); zDO.Set(KShape, 2, false); text = Module.T($"Зона тотема: прямоугольник {zone2.Width:0.#} × {zone2.Length:0.#} м", $"Totem zone: a rectangle {zone2.Width:0.#} × {zone2.Length:0.#} m"); } else { text = Module.T($"Угол {(flag ? 1 : 2)} запомнен — теперь метка «угол {((!flag) ? 1 : 2)}» и снова E на тотеме", $"Corner {(flag ? 1 : 2)} kept - now the corner {((!flag) ? 1 : 2)} mark and E on the totem again"); } } Mark.Clear(); showUntil = Time.time + 4f; ((Character)localPlayer).Message((MessageType)2, text + Module.T(". Метку можно убрать.", ". The mark may be taken down."), 0, (Sprite)null, false); return true; } internal void ResetZone() { if (real && MayChange()) { if (!nview.IsOwner()) { nview.ClaimOwnership(); } ZDO zDO = nview.GetZDO(); zDO.Set(KShape, 0, false); zDO.Set(KHasA, false); zDO.Set(KHasB, false); } } internal string ZoneText() { ShrinkMath.Zone zone = Zone; if (zone.Shape != ShrinkMath.Shape.Rect) { if (zone.Shape != ShrinkMath.Shape.Circle) { return Module.T($"круг {Radius} м (из настроек)", $"a circle of {Radius} m (settings)"); } return Module.T($"круг {zone.Radius:0.#} м (по метке)", $"a circle of {zone.Radius:0.#} m (by a mark)"); } return Module.T($"прямоугольник {zone.Width:0.#} × {zone.Length:0.#} м", $"a rectangle {zone.Width:0.#} × {zone.Length:0.#} m"); } internal static bool InAny(Vector3 point) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < All.Count; i++) { Totem totem = All[i]; if ((Object)(object)totem != (Object)null && totem.Contains(point)) { return true; } } return false; } internal List<Character> Tamed() { //IL_005b: Unknown result type (might be due to invalid IL or missing references) List<Character> list = new List<Character>(); foreach (Character allCharacter in Character.GetAllCharacters()) { if (!((Object)(object)allCharacter == (Object)null) && !allCharacter.IsPlayer() && !allCharacter.IsDead() && allCharacter.IsTamed()) { ZNetView component = ((Component)allCharacter).GetComponent<ZNetView>(); if (!((Object)(object)component == (Object)null) && component.IsValid() && Contains(((Component)allCharacter).transform.position)) { list.Add(allCharacter); } } } return list; } internal bool MayChange() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) bool creator = (Object)(object)piece != (Object)null && piece.IsCreator(); Vector3 at = Center; bool flag = PrivateArea.m_allAreas.Any((PrivateArea a) => (Object)(object)a != (Object)null && a.IsEnabled() && a.IsInside(at, 0f)); bool wardPermits = flag && PrivateArea.CheckAccess(at, 0f, false, false); return ShrinkMath.MayChange(creator, flag, wardPermits, Module.AnyoneCanChange.Value); } public string GetHoverText() { if (!real) { return ""; } showUntil = Time.time + 0.6f; string text = Localization.instance.Localize("$piece_chistix_shrinktotem"); if (!Module.Active) { return text + "\n" + Module.T("(выключен в настройках)", "(off in the settings)"); } string text2 = "\n[<color=yellow><b>$KEY_Use</b></color>] "; if (Mark.Waiting) { return Localization.instance.Localize(text + text2 + Module.T("задать зону по метке «" + Mark.KindName(Mark.Picked.Value) + "»", "set the zone by the mark \"" + Mark.KindName(Mark.Picked.Value) + "\"")); } int count = Tamed().Count; return Localization.instance.Localize(text + text2 + Module.T($"Размеры ручных зверей ({count} в зоне: {ZoneText()})", $"Sizes of tamed creatures ({count} in the zone: {ZoneText()})")); } public string GetHoverName() { return Localization.instance.Localize("$piece_chistix_shrinktotem"); } public float GetHoverOffset() { return hoverOffset; } public bool Interact(Humanoid user, bool hold, bool alt) { if (hold || !real || (Object)(object)user != (Object)(object)Player.m_localPlayer) { return false; } if (UseMark()) { return true; } TotemWindow.Show(this); return true; } public bool UseItem(Humanoid user, ItemData item) { return false; } internal static void Register(ZNetScene scene) { if ((Object)(object)scene == (Object)null) { return; } if ((Object)(object)prefab == (Object)null) { GameObject val = scene.GetPrefab("guard_stone"); if ((Object)(object)val == (Object)null) { Module.Warn("no guard_stone: the totem is not made"); return; } Make(val); } int stableHashCode = StringExtensionMethods.GetStableHashCode(((Object)prefab).name); if (!scene.m_namedPrefabs.ContainsKey(stableHashCode)) { scene.m_prefabs.Add(prefab); scene.m_namedPrefabs.Add(stableHashCode, prefab); } Mark.Register(scene); if ((Object)(object)ObjectDB.instance != (Object)null) { AddToHammer(ObjectDB.instance); } } private static void Make(GameObject ward) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0048: 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) GameObject val = new GameObject("ShrinkTotemPieces"); val.SetActive(false); Object.DontDestroyOnLoad((Object)(object)val); prefab = Object.Instantiate<GameObject>(ward, val.transform); ((Object)prefab).name = "chistix_shrink_totem"; prefab.transform.localScale = ward.transform.localScale * 0.85f; Totem totem = prefab.AddComponent<Totem>(); PrivateArea component = prefab.GetComponent<PrivateArea>(); if ((Object)(object)component != (Object)null) { totem.marker = (((Object)(object)component.m_areaMarker != (Object)null) ? ((Component)component.m_areaMarker).gameObject : null); totem.glow = component.m_enabledEffect; totem.model = (Renderer)(object)component.m_model; totem.hoverOffset = component.m_hoverOffset; Object.DestroyImmediate((Object)(object)component); } Piece component2 = prefab.GetComponent<Piece>(); component2.m_name = "$piece_chistix_shrinktotem"; component2.m_description = "$piece_chistix_shrinktotem_desc"; Module.Log("totem piece made from " + ((Object)ward).name); } internal static void AddToHammer(ObjectDB db) { if ((Object)(object)db == (Object)null || (Object)(object)prefab == (Object)null) { return; } GameObject itemPrefab = db.GetItemPrefab("Hammer"); PieceTable val = ((itemPrefab == null) ? null : itemPrefab.GetComponent<ItemDrop>()?.m_itemData.m_shared.m_buildPieces); if (!((Object)(object)val == (Object)null)) { Piece component = prefab.GetComponent<Piece>(); CraftingStation val2 = Station(db, Module.Station.Value); component.m_resources = Requirements(db, Module.Ingredients.Value, "totem"); component.m_craftingStation = val2; if (!val.m_pieces.Contains(prefab)) { val.m_pieces.Add(prefab); } Mark.AddToHammer(db, val, val2); } } internal static Requirement[] Requirements(ObjectDB db, string text, string what) { //IL_0059: 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_0066: 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) //IL_007f: Expected O, but got Unknown //IL_00d4: 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_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Expected O, but got Unknown List<string> list = new List<string>(); List<Requirement> list2 = new List<Requirement>(); foreach (KeyValuePair<string, int> item in ShrinkMath.ParseRecipe(text, list)) { GameObject itemPrefab = db.GetItemPrefab(item.Key); ItemDrop val = ((itemPrefab != null) ? itemPrefab.GetComponent<ItemDrop>() : null); if ((Object)(object)val == (Object)null) { list.Add(item.Key); continue; } list2.Add(new Requirement { m_resItem = val, m_amount = item.Value, m_recover = true }); } if (list.Count > 0) { Module.Warn(what + " recipe: skipped " + string.Join(", ", list)); } if (list2.Count == 0) { GameObject itemPrefab2 = db.GetItemPrefab("Stone"); if (itemPrefab2 != null) { list2.Add(new Requirement { m_resItem = itemPrefab2.GetComponent<ItemDrop>(), m_amount = 10, m_recover = true }); } } return list2.ToArray(); } private static CraftingStation Station(ObjectDB db, string name) { if (string.IsNullOrWhiteSpace(name)) { return null; } name = name.Trim(); ZNetScene instance = ZNetScene.instance; object obj; if (instance == null) { obj = null; } else { GameObject obj2 = instance.GetPrefab(name); obj = ((obj2 != null) ? obj2.GetComponent<CraftingStation>() : null); } CraftingStation val = (CraftingStation)obj; if ((Object)(object)val == (Object)null) { val = db.m_recipes.Select((Recipe r) => r?.m_craftingStation).FirstOrDefault((Func<CraftingStation, bool>)((CraftingStation s) => (Object)(object)s != (Object)null && ((Object)s).name == name)); } if ((Object)(object)val == (Object)null) { Module.Warn("no crafting station " + name + ": built without one"); } return val; } internal static void Words(Localization localization, bool ru) { MethodInfo methodInfo = AccessTools.Method(typeof(Localization), "AddWord", (Type[])null, (Type[])null); if (!(methodInfo == null)) { methodInfo.Invoke(localization, new object[2] { "$piece_chistix_shrinktotem".Substring(1), ru ? "Тотем уменьшения" : "Shrinking totem" }); methodInfo.Invoke(localization, new object[2] { "$piece_chistix_shrinktotem".Substring(1) + "_desc", ru ? "Ручные звери в зоне тотема становятся меньше или больше: размер каждого задаётся у тотема (E). Вышел из зоны — снова своего размера. Зона — круг из настроек или своя: метки «радиус» или «угол 1» и «угол 2» (E на метке, затем E на тотеме)." : "Tamed creatures in the totem's zone get smaller or larger: set each one's size at the totem (E). Out of the zone they have their own size again. The zone: the settings' circle or its own, from the radius mark or the corner 1 and corner 2 marks (E on the mark, then E on the totem)." }); Mark.Words(methodInfo, localization, ru); } } } internal static class TotemWindow { [CompilerGenerated] private static class <>O { public static Func<Character, float> <0>__Value; public static Action <1>__Close; public static Action <2>__ResetAll; public static WindowFunction <3>__PlainBody; } internal static Totem Of; private const int PerPage = 10; private static int page; private static bool failed; private static RectTransform root; private static RectTransform panel; private static RectTransform rows; private static CanvasScaler scaler; private static CanvasScaler gameScaler; private static TMP_FontAsset font; private static Material fontMaterial; private static Sprite white; private static TMP_Text title; private static TMP_Text status; private static TMP_Text pageText; private static TMP_Text zoneText; private static Button zoneReset; private static Button prev; private static Button next; private static Button modeButton; private static Color Gold = new Color(1f, 0.718f, 0.361f); private static Color Label = Color.white; private static Color Dim = Color.white; private static Color Item = new Color(1f, 0.808f, 0f); private static TMP_FontAsset titleFont; private static TMP_FontAsset sansFont; private static Material titleMaterial; private static Material sansMaterial; private static Image boardSample; private static Image rowSample; private static readonly List<(List<Character> members, TMP_Text size)> shownRows = new List<(List<Character>, TMP_Text)>(); private static string shownKey; private static float nextRefresh; private static List<Character> list = new List<Character>(); private static List<List<Character>> lines = new List<List<Character>>(); private static bool may; private static int openedFrame; private static readonly Dictionary<Character, (float value, float until)> pending = new Dictionary<Character, (float, float)>(); internal static int ClosedFrame = -1; private static Rect plain = new Rect(0f, 0f, 600f, 10f); private static GUIStyle label; private static GUIStyle button; private static GUIStyle small; internal static bool Open => (Object)(object)Of != (Object)null; internal static bool Blocks { get { if (!Open) { return Time.frameCount == ClosedFrame; } return true; } } private static bool ByKind { get { if (Module.ByKind != null) { return Module.ByKind.Value; } return false; } } private static string ModeText { get { if (!ByKind) { return Module.T("Показать по видам", "Show by kinds"); } return Module.T("Показать по одному", "Show one by one"); } } private static int AboveGame() { int top = 0; Scan((Component)(object)Hud.instance); Scan((Component)(object)InventoryGui.instance); return Mathf.Clamp(top + 1, 60, 32767); void Scan(Component c) { if (!((Object)(object)c == (Object)null)) { Canvas[] componentsInParent = c.GetComponentsInParent<Canvas>(true); foreach (Canvas val in componentsInParent) { top = Mathf.Max(top, val.sortingOrder); } componentsInParent = c.GetComponentsInChildren<Canvas>(true); foreach (Canvas val2 in componentsInParent) { top = Mathf.Max(top, val2.sortingOrder); } } } } internal static void Show(Totem totem) { if ((Object)(object)totem == (Object)null) { return; } Of = totem; openedFrame = Time.frameCount; page = 0; shownKey = null; if (!failed && (Object)(object)root == (Object)null) { try { Build(); } catch (Exception ex) { Module.Warn("totem window: " + ex?.ToString() + " - the plain window is used"); failed = true; if ((Object)(object)root != (Object)null) { Object.Destroy((Object)(object)((Component)root).gameObject); } root = null; } } if ((Object)(object)root != (Object)null) { ((Component)root).GetComponent<Canvas>().sortingOrder = AboveGame(); ((Component)root).gameObject.SetActive(true); } Refresh(now: true); } internal static void Close() { if ((Object)(object)Of != (Object)null) { ClosedFrame = Time.frameCount; } Of = null; pending.Clear(); if ((Object)(object)root != (Object)null) { ((Component)root).gameObject.SetActive(false); } } internal static void Tick() { //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)gameScaler != (Object)null && (Object)(object)scaler != (Object)null) { scaler.scaleFactor = gameScaler.scaleFactor; } if (!Open) { if ((Object)(object)root != (Object)null && ((Component)root).gameObject.activeSelf) { ((Component)root).gameObject.SetActive(false); } return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)Of == (Object)null || (Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead() || Vector3.Distance(((Component)localPlayer).transform.position, Of.Center) > Of.Reach + 10f) { Close(); } else if (Time.frameCount > openedFrame && ZInput.GetButtonDown("Use")) { Close(); } else if (Time.unscaledTime >= nextRefresh) { Refresh(now: false); } } private static void Collect() { //IL_003b: 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_0048: Unknown result type (might be due to invalid IL or missing references) List<ShrinkMath.Row> list = new List<ShrinkMath.Row>(); foreach (Character item in Of.Tamed()) { ZNetView component = ((Component)item).GetComponent<ZNetView>(); ZDOID val = (((Object)(object)component != (Object)null && component.IsValid()) ? component.GetZDO().m_uid : ZDOID.None); list.Add(new ShrinkMath.Row { Kind = KindOf(item), KindKey = Utils.GetPrefabName(((Component)item).gameObject), Name = OwnName(item), User = ((ZDOID)(ref val)).UserID, Id = ((ZDOID)(ref val)).ID, Factor = Value(item), Tag = item }); } TotemWindow.list = ((IEnumerable<ShrinkMath.Row>)ShrinkMath.Ordered(list)).Select((Func<ShrinkMath.Row, Character>)((ShrinkMath.Row r) => (Character)r.Tag)).ToList(); lines = (ByKind ? (from g in ShrinkMath.Groups(list) select ((IEnumerable<ShrinkMath.Row>)g.Rows).Select((Func<ShrinkMath.Row, Character>)((ShrinkMath.Row r) => (Character)r.Tag)).ToList()).ToList() : TotemWindow.list.Select((Character c) => new List<Character> { c }).ToList()); } private static void Refresh(bool now) { nextRefresh = Time.unscaledTime + 0.3f; if ((Object)(object)Of == (Object)null) { return; } Collect(); may = Of.MayChange(); page = ShrinkMath.Page(page, lines.Count, 10); if ((Object)(object)root == (Object)null) { return; } List<List<Character>> list = lines.Skip(page * 10).Take(10).ToList(); string text = page + ":" + may + ":" + ByKind + ":" + string.Join(";", list.Select((List<Character> l) => string.Join(",", l.Select((Character c) => ((Object)c).GetInstanceID())))); if (text != shownKey) { shownKey = text; Rows(list); } foreach (var (members, val) in shownRows) { if ((Object)(object)val != (Object)null) { val.text = SizeText(members); } } title.text = Module.T("Тотем уменьшения", "Shrinking totem"); zoneText.text = Module.T("Зона: ", "Zone: ") + Of.ZoneText() + Module.T(". Своя зона: E на метке «радиус» или «угол 1» / «угол 2», затем E на тотеме.", ". Own zone: E on a radius or corner 1 / corner 2 mark, then E on the totem."); ((Component)zoneReset).gameObject.SetActive(may && Of.Zone.Shape != ShrinkMath.Shape.Default); status.text = ((TotemWindow.list.Count == 0) ? Module.T("Ручных зверей в зоне тотема нет.", "No tamed creatures in the totem's zone.") : (Module.T($"Ручных зверей в зоне: {TotemWindow.list.Count}. Размер действует, пока зверь в зоне тотема.", $"Tamed creatures in the zone: {TotemWindow.list.Count}. The size holds while a creature is in a totem's zone.") + (may ? "" : Module.T("\nМенять размеры может поставивший тотем или те, кому можно у оберега над ним.", "\nSizes are changed by who built the totem or the ones a ward over it lets in.")) + (Module.Active ? "" : Module.T("\nТотемы выключены в настройках.", "\nTotems are off in the settings.")))); int num = ShrinkMath.Pages(lines.Count, 10); pageText.text = $"{page + 1}/{num}"; ((Component)((Component)prev).transform.parent).gameObject.SetActive(num > 1); TMP_Text[] componentsInChildren = ((Component)modeButton).GetComponentsInChildren<TMP_Text>(true); for (int num2 = 0; num2 < componentsInChildren.Length; num2++) { componentsInChildren[num2].text = ModeText; } } internal static float Stored(Character c) { ZNetView val = (((Object)(object)c != (Object)null) ? ((Component)c).GetComponent<ZNetView>() : null); if (!((Object)(object)val != (Object)null) || !val.IsValid()) { return 1f; } return (float)ShrinkMath.Clamp(val.GetZDO().GetFloat(Shrunk.KScale, 1f), Module.Min.Value, Module.Max.Value); } private static float Value(Character c) { float num = Stored(c); if ((Object)(object)c != (Object)null && pending.TryGetValue(c, out (float, float) value)) { if (Time.unscaledTime < value.Item2 && !Mathf.Approximately(value.Item1, num)) { return value.Item1; } pending.Remove(c); } return num; } private static string SizeText(List<Character> members) { List<Character> list = members.Where((Character c) => (Object)(object)c != (Object)null).ToList(); if (list.Count == 0) { return ""; } return ShrinkMath.FormatRange(((IEnumerable<Character>)list).Min((Func<Character, float>)Value), ((IEnumerable<Character>)list).Max((Func<Character, float>)Value)); } private static void StepOne(Character c, int dir) { if (!((Object)(object)c == (Object)null)) { Shrunk component = ((Component)c).GetComponent<Shrunk>(); if (!((Object)(object)component == (Object)null)) { float num = (float)ShrinkMath.Step(Value(c), dir, Module.Step.Value, Module.Min.Value, Module.Max.Value); component.Set(num); pending[c] = (num, Time.unscaledTime + 2f); } } } internal static void Step(List<Character> members, int dir) { if ((Object)(object)Of == (Object)null || !Of.MayChange()) { return; } foreach (Character item in members.ToList()) { StepOne(item, dir); } Shown(); } internal static void StepAll(int dir) { Step(list, dir); } internal static void ResetAll() { if ((Object)(object)Of == (Object)null || !Of.MayChange()) { return; } foreach (Character item in list.ToList()) { Shrunk shrunk = (((Object)(object)item != (Object)null) ? ((Component)item).GetComponent<Shrunk>() : null); if (!((Object)(object)shrunk == (Object)null)) { shrunk.Set(1f); pending[item] = (1f, Time.unscaledTime + 2f); } } Shown(); } private static void Shown() { foreach (var (members, val) in shownRows) { if ((Object)(object)val != (Object)null) { val.text = SizeText(members); } } nextRefresh = Time.unscaledTime + 0.6f; } private static string KindOf(Character c) { return Localization.instance.Localize(c.m_name); } private static string OwnName(Character c) { Tameable component = ((Component)c).GetComponent<Tameable>(); string text = (((Object)(object)component != (Object)null) ? component.GetText() : ""); object obj; if (!(text == KindOf(c))) { obj = text; if (obj == null) { return ""; } } else { obj = ""; } return (string)obj; } internal static string NameOf(Character c) { string text = KindOf(c); string text2 = OwnName(c); if (!string.IsNullOrEmpty(text2)) { return text2 + " (" + text + ")"; } return text; } private static string LineName(List<Character> members) { Character val = ((IEnumerable<Character>)members).FirstOrDefault((Func<Character, bool>)((Character c) => (Object)(object)c != (Object)null)); if ((Object)(object)val == (Object)null) { return ""; } if (!ByKind) { return NameOf(val); } return $"{KindOf(val)} — {members.Count}"; } private static RectTransform Rect(Transform parent, string name) { //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) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parent, false); return (RectTransform)val.transform; } private static void Fit(GameObject go, float width, float height) { LayoutElement val = go.GetComponent<LayoutElement>() ?? go.AddComponent<LayoutElement>(); if (width >= 0f) { val.preferredWidth = width; val.minWidth = width; } if (height >= 0f) { val.preferredHeight = height; val.minHeight = height; } } private static RectTransform Row(Transform parent, float spacing = 8f) { RectTransform obj = Rect(parent, "row"); HorizontalLayoutGroup obj2 = ((Component)obj).gameObject.AddComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)obj2).spacing = spacing; ((LayoutGroup)obj2).childAlignment = (TextAnchor)3; ((HorizontalOrVerticalLayoutGroup)obj2).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)obj2).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandHeight = false; return obj; } private static TMP_Text Text(Transform parent, string text, float size, Color colour, float width, TextAlignmentOptions align = (TextAlignmentOptions)4097, bool wrap = false, TMP_FontAsset face = null, Material faceMaterial = null) { //IL_0018: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected O, but got Unknown GameObject val = new GameObject("text", new Type[1] { typeof(RectTransform) }); val.SetActive(false); val.transform.SetParent(parent, false); TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>(); TMP_FontAsset val3 = face ?? font; Material val4 = (((Object)(object)face != (Object)null) ? faceMaterial : fontMaterial); ((TMP_Text)val2).font = val3; if ((Object)(object)val4 != (Object)null) { ((TMP_Text)val2).fontSharedMaterial = val4; } val.SetActive(true); ((TMP_Text)val2).fontSize = size; ((Graphic)val2).color = colour; ((TMP_Text)val2).alignment = align; ((Graphic)val2).raycastTarget = false; ((TMP_Text)val2).richText = true; ((TMP_Text)val2).textWrappingMode = (TextWrappingModes)(wrap ? 1 : 0); ((TMP_Text)val2).overflowMode = (TextOverflowModes)3; ((TMP_Text)val2).text = text; Fit(val, width, -1f); return (TMP_Text)(object)val2; } private static Button Copy(Button source, Transform parent, string name) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown GameObject val = Object.Instantiate<GameObject>(((Component)source).gameObject, parent); ((Object)val).name = name; val.SetActive(true); UITooltip[] componentsInChildren = val.GetComponentsInChildren<UITooltip>(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren[i]); } Button component = val.GetComponent<Button>(); component.onClick = new ButtonClickedEvent(); ((Selectable)component).interactable = true; return component; } private static RectTransform Strip(RectTransform row) { //IL_007b: 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) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Expected O, but got Unknown Image val = ((Component)row).gameObject.AddComponent<Image>(); if ((Object)(object)rowSample != (Object)null) { val.sprite = rowSample.sprite; val.type = rowSample.type; ((Graphic)val).color = ((Graphic)rowSample).color; ((Graphic)val).material = ((Graphic)rowSample).material; } else { val.sprite = white; ((Graphic)val).color = new Color(0f, 0f, 0f, 0.56f); } ((Graphic)val).raycastTarget = false; HorizontalLayoutGroup component = ((Component)row).GetComponent<HorizontalLayoutGroup>(); if ((Object)(object)component != (Object)null) { ((LayoutGroup)component).padding = new RectOffset(10, 6, 3, 3); } return row; } private static Button Wide(Transform parent, string text, float width, Action click) { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown InventoryGui instance = InventoryGui.instance; Button val = Copy(((Object)(object)instance.m_takeAllButton != (Object)null) ? instance.m_takeAllButton : instance.m_craftButton, parent, "ShrinkTotem " + text); TMP_Text[] componentsInChildren = ((Component)val).GetComponentsInChildren<TMP_Text>(true); foreach (TMP_Text obj in componentsInChildren) { obj.text = text; obj.fontSize = 18f; obj.textWrappingMode = (TextWrappingModes)0; obj.alignment = (TextAlignmentOptions)514; } Fit(((Component)val).gameObject, width, 36f); ((UnityEvent)val.onClick).AddListener((UnityAction)delegate { click(); Refresh(now: true); }); return val; } private static Button Small(Transform parent, string text, Action click) { //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: 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_00d1: 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) Button val = Copy(InventoryGui.instance.m_qualityLevelDown, parent, "ShrinkTotem small"); Image[] componentsInChildren = ((Component)val).GetComponentsInChildren<Image>(true); foreach (Image val2 in componentsInChildren) { if ((Object)(object)val2 != (Object)(object)((Selectable)val).image) { ((Behaviour)val2).enabled = false; } } TMP_Text[] componentsInChildren2 = ((Component)val).GetComponentsInChildren<TMP_Text>(true); for (int j = 0; j < componentsInChildren2.Length; j++) { componentsInChildren2[j].text = ((j == 0) ? text : ""); } if (componentsInChildren2.Length == 0) { RectTransform rectTransform = Text(((Component)val).transform, text, 22f, Gold, -1f, (TextAlignmentOptions)514).rectTransform; rectTransform.anchorMin = Vector2.zero; rectTransform.anchorMax = Vector2.one; Vector2 offsetMin = (rectTransform.offsetMax = Vector2.zero); rectTransform.offsetMin = offsetMin; } Fit(((Component)val).gameObject, 34f, 34f); ((UnityEvent)val.onClick).AddListener((UnityAction)delegate { click(); }); return val; } private static void Build() { //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_0099: Expected O, but got Unknown //IL_00bd: 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_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Expected O, but got Unknown //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Expected O, but got Unknown //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: 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_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_03a6: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_03d0: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_040f: Unknown result type (might be due to invalid IL or missing references) //IL_0419: Expected O, but got Unknown //IL_046a: 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_04f4: Unknown result type (might be due to invalid IL or missing references) //IL_05c2: Unknown result type (might be due to invalid IL or missing references) //IL_061c: Unknown result type (might be due to invalid IL or missing references) //IL_06d1: Unknown result type (might be due to invalid IL or missing references) InventoryGui instance = InventoryGui.instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.m_craftButton == (Object)null || (Object)(object)instance.m_qualityLevelDown == (Object)null) { throw new Exception("no inventory window yet"); } TMP_Text componentInChildren = ((Component)instance.m_craftButton).GetComponentInChildren<TMP_Text>(true); font = (((Object)(object)componentInChildren != (Object)null) ? componentInChildren.font : null); fontMaterial = (((Object)(object)componentInChildren != (Object)null) ? componentInChildren.fontSharedMaterial : null); if ((Object)(object)font == (Object)null) { throw new Exception("no game font"); } Texture2D val = new Texture2D(4, 4) { hideFlags = (HideFlags)61 }; Color32[] array = (Color32[])(object)new Color32[16]; for (int i = 0; i < 16; i++) { array[i] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue); } val.SetPixels32(array); val.Apply(); white = Sprite.Create(val, new Rect(0f, 0f, 4f, 4f), new Vector2(0.5f, 0.5f), 100f); GameObject val2 = new GameObject("ShrinkTotem window", new Type[4] { typeof(RectTransform), typeof(Canvas), typeof(CanvasScaler), typeof(GraphicRaycaster) }); Object.DontDestroyOnLoad((Object)val2); Canvas component = val2.GetComponent<Canvas>(); component.renderMode = (RenderMode)0; component.sortingOrder = AboveGame(); scaler = val2.GetComponent<CanvasScaler>(); gameScaler = ((Component)instance).GetComponentInParent<CanvasScaler>(); if ((Object)(object)gameScaler != (Object)null) { scaler.uiScaleMode = gameScaler.uiScaleMode; scaler.referenceResolution = gameScaler.referenceResolution; scaler.screenMatchMode = gameScaler.screenMatchMode; scaler.matchWidthOrHeight = gameScaler.matchWidthOrHeight; scaler.scaleFactor = gameScaler.scaleFactor; } root = (RectTransform)val2.transform; panel = Rect((Transform)(object)root, "panel"); Image val3 = ((Component)panel).gameObject.AddComponent<Image>(); object obj; if (!((Object)(object)instance.m_crafting != (Object)null)) { obj = null; } else { Transform obj2 = ((Transform)instance.m_crafting).Find("Bkg"); obj = ((obj2 != null) ? ((Component)obj2).GetComponent<Image>() : null); } boardSample = (Image)obj; rowSample = (((Object)(object)instance.m_recipeDecription != (Object)null) ? ((Component)instance.m_recipeDecription.transform.parent).GetComponent<Image>() : null); if ((Object)(object)instance.m_craftingStationName != (Object)null) { titleFont = instance.m_craftingStationName.font; titleMaterial = instance.m_craftingStationName.fontSharedMaterial; Gold = ((Graphic)instance.m_craftingStationName).color; } if ((Object)(object)instance.m_recipeDecription != (Object)null) { sansFont = instance.m_recipeDecription.font; sansMaterial = instance.m_recipeDecription.fontSharedMaterial; Label = (Dim = ((Graphic)instance.m_recipeDecription).color); } if ((Object)(object)instance.m_recipeName != (Object)null) { Item = ((Graphic)instance.m_recipeName).color; } if ((Object)(object)boardSample != (Object)null) { val3.sprite = boardSample.sprite; val3.type = boardSample.type; ((Graphic)val3).color = ((Graphic)boardSample).color; ((Graphic)val3).material = ((Graphic)boardSample).material; } else { val3.sprite = white; ((Graphic)val3).color = new Color(0.12f, 0.09f, 0.06f, 0.96f); } RectTransform obj3 = panel; RectTransform obj4 = panel; RectTransform obj5 = panel; Vector2 val4 = default(Vector2); ((Vector2)(ref val4))..ctor(0.5f, 0.5f); obj5.pivot = val4; Vector2 anchorMin = (obj4.anchorMax = val4); obj3.anchorMin = anchorMin; panel.anchoredPosition = Vector2.zero; VerticalLayoutGroup obj6 = ((Component)panel).gameObject.AddComponent<VerticalLayoutGroup>(); ((LayoutGroup)obj6).padding = new RectOffset(28, 28, 18, 22); ((HorizontalOrVerticalLayoutGroup)obj6).spacing = 6f; ((HorizontalOrVerticalLayoutGroup)obj6).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)obj6).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)obj6).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)obj6).childForceExpandHeight = false; ContentSizeFitter obj7 = ((Component)panel).gameObject.AddComponent<ContentSizeFitter>(); obj7.horizontalFit = (FitMode)2; obj7.verticalFit = (FitMode)2; title = Text((Transform)(object)panel, "", 32f, Gold, 640f, (TextAlignmentOptions)514, wrap: false, titleFont, titleMaterial); Fit(((Component)title).gameObject, 640f, 44f); status = Text((Transform)(object)panel, "", 17f, Dim, 640f, (TextAlignmentOptions)257, wrap: true, sansFont, sansMaterial); RectTransform parent = Row((Transform)(object)panel, 10f); zoneText = Text((Transform)(object)parent, "", 17f, Label, 390f, (TextAlignmentOptions)4097, wrap: true, sansFont, sansMaterial); zoneReset = Wide((Transform)(object)parent, Module.T("Зона по умолчанию", "Default zone"), 240f, delegate { Of?.ResetZone(); }); rows = Rect((Transform)(object)panel, "rows"); VerticalLayoutGroup obj8 = ((Component)rows).gameObject.AddComponent<VerticalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)obj8).spacing = 4f; ((HorizontalOrVerticalLayoutGroup)obj8).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)obj8).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)obj8).childFor