Decompiled source of Guinea Pigs and Their Treats v0.9.10
plugins/CavyCrew.GuineaPigsAndTreats.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using GuineaPigsAndTreats.Audio; using GuineaPigsAndTreats.Food; using GuineaPigsAndTreats.Models; using GuineaPigsAndTreats.Net; using GuineaPigsAndTreats.Pigs; using GuineaPigsAndTreats.Riding; using GuineaPigsAndTreats.Treats; using GuineaPigsAndTreats.UI; using GuineaPigsAndTreats.Visuals; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using PEAKLib.Core; using PEAKLib.Items; using PEAKLib.Items.ItemAcceptor; using Peak.Afflictions; using Photon.Pun; using Photon.Realtime; using TMPro; using Unity.Collections; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.InputSystem.Utilities; using UnityEngine.Rendering; using UnityEngine.Rendering.Universal; using UnityEngine.SceneManagement; using UnityEngine.UI; using Zorro.Core; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("CavyCrew.GuineaPigsAndTreats")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.9.10.0")] [assembly: AssemblyInformationalVersion("0.9.10")] [assembly: AssemblyProduct("CavyCrew.GuineaPigsAndTreats")] [assembly: AssemblyTitle("Guinea Pigs and Their Treats")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.9.10.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [CompilerGenerated] internal sealed class <>z__ReadOnlyArray<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T> { int ICollection.Count => _items.Length; bool ICollection.IsSynchronized => false; object ICollection.SyncRoot => this; object IList.this[int index] { get { return _items[index]; } set { throw new NotSupportedException(); } } bool IList.IsFixedSize => true; bool IList.IsReadOnly => true; int IReadOnlyCollection<T>.Count => _items.Length; T IReadOnlyList<T>.this[int index] => _items[index]; int ICollection<T>.Count => _items.Length; bool ICollection<T>.IsReadOnly => true; T IList<T>.this[int index] { get { return _items[index]; } set { throw new NotSupportedException(); } } public <>z__ReadOnlyArray(T[] items) { _items = items; } IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)_items).GetEnumerator(); } void ICollection.CopyTo(Array array, int index) { ((ICollection)_items).CopyTo(array, index); } int IList.Add(object value) { throw new NotSupportedException(); } void IList.Clear() { throw new NotSupportedException(); } bool IList.Contains(object value) { return ((IList)_items).Contains(value); } int IList.IndexOf(object value) { return ((IList)_items).IndexOf(value); } void IList.Insert(int index, object value) { throw new NotSupportedException(); } void IList.Remove(object value) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } IEnumerator<T> IEnumerable<T>.GetEnumerator() { return ((IEnumerable<T>)_items).GetEnumerator(); } void ICollection<T>.Add(T item) { throw new NotSupportedException(); } void ICollection<T>.Clear() { throw new NotSupportedException(); } bool ICollection<T>.Contains(T item) { return ((ICollection<T>)_items).Contains(item); } void ICollection<T>.CopyTo(T[] array, int arrayIndex) { ((ICollection<T>)_items).CopyTo(array, arrayIndex); } bool ICollection<T>.Remove(T item) { throw new NotSupportedException(); } int IList<T>.IndexOf(T item) { return ((IList<T>)_items).IndexOf(item); } void IList<T>.Insert(int index, T item) { throw new NotSupportedException(); } void IList<T>.RemoveAt(int index) { throw new NotSupportedException(); } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 BepInEx { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] [Embedded] internal sealed class BepInAutoPluginAttribute : Attribute { public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace BepInEx.Preloader.Core.Patching { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] [Embedded] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace Microsoft.CodeAnalysis { [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace GuineaPigsAndTreats { internal static class Lang { public const string Auto = "auto"; private const string Fallback = "en"; private static Dictionary<string, Dictionary<string, string>>? s_tables; private static readonly Regex s_particles = new Regex("(.)(이/가|은/는|을/를|과/와|이랑/랑|아/야|으로/로|이에요/예요)", RegexOptions.Compiled); private static readonly int[] s_digitFinals = new int[10] { 21, 8, 0, 16, 0, 0, 1, 8, 8, 0 }; public static IReadOnlyList<string> Available { get { List<string> list = Tables.Keys.ToList(); list.Sort((string a, string b) => (!(a == "en")) ? ((b == "en") ? 1 : string.CompareOrdinal(a, b)) : (-1)); return list; } } public static string Current { get { string text = Plugin.Language.Value.Trim().ToLowerInvariant(); if (text != "auto" && Tables.ContainsKey(text)) { return text; } string text2 = FromGame(); if (!Tables.ContainsKey(text2)) { return "en"; } return text2; } } public static bool IsAuto => Plugin.Language.Value.Trim().ToLowerInvariant() == "auto"; private static Dictionary<string, Dictionary<string, string>> Tables => s_tables ?? (s_tables = LoadTables()); public static string NativeName(string code) { if (!Tables.TryGetValue(code, out Dictionary<string, string> value) || !value.TryGetValue("_language", out var value2)) { return code; } return value2; } public static string Get(string key, params (string name, object value)[] args) { return Format(Lookup(key, null), args); } public static string ForPig(PigDefinition pig, string key, params (string name, object value)[] args) { string text = Lookup(key, pig.Gender); text = text.Replace("{pig}", PigName(pig)); return Format(text, args); } public static string PigName(PigDefinition pig) { return pig.CustomName ?? Lookup("pig." + pig.Key + ".name", null); } public static string InLanguage(string code, string key, char gender = 'f') { return Lookup(code.Trim().ToLowerInvariant(), key, gender); } public static string FoodRefusal(PigDefinition pig, string item, FoodVerdict verdict) { return ForPig(pig, verdict switch { FoodVerdict.Mushroom => "food.refuse.mushroom", FoodVerdict.Packaged => "food.refuse.packaged", FoodVerdict.Sweet => "food.refuse.sweet", FoodVerdict.Animal => "food.refuse.animal", FoodVerdict.Spicy => "food.refuse.spicy", FoodVerdict.Thorny => "food.refuse.thorny", FoodVerdict.Fatty => "food.refuse.fatty", FoodVerdict.Poisonous => "food.refuse.poisonous", FoodVerdict.Sleepy => "food.refuse.sleepy", FoodVerdict.Suspicious => "food.refuse.suspicious", FoodVerdict.Cooked => "food.refuse.cooked", _ => "food.refuse.not_food", }, ("item", item)); } public static bool Has(string key) { if (!TryLookup(Current, key, out string text)) { string text2 = Parent(Current); if (text2 == null || !TryLookup(text2, key, out text)) { return TryLookup("en", key, out text); } } return true; } private static string? Parent(string code) { int num = code.IndexOf('-'); if (num <= 0 || !Tables.ContainsKey(code.Substring(0, num))) { return null; } return code.Substring(0, num); } internal static IEnumerable<string> AllTexts(string code) { if (!Tables.TryGetValue(code, out Dictionary<string, string> value)) { return Array.Empty<string>(); } return value.Values; } private static string Lookup(string key, char? gender) { return Lookup(Current, key, gender); } private static string Lookup(string language, string key, char? gender) { object obj = Find(language); if (obj == null) { string text = Parent(language); obj = ((text != null) ? Find(text) : null) ?? Find("en") ?? key; } return (string)obj; string? Find(string code) { if (gender.HasValue && gender.Value != 'f' && TryLookup(code, $"{key}#{gender.Value}", out string text2)) { return text2; } if (!TryLookup(code, key, out string text3)) { return null; } return text3; } } private static bool TryLookup(string language, string key, out string text) { text = ""; if (Tables.TryGetValue(language, out Dictionary<string, string> value) && value.TryGetValue(key, out text)) { return !string.IsNullOrEmpty(text); } return false; } private static string Format(string text, (string name, object value)[] args) { for (int i = 0; i < args.Length; i++) { (string name, object value) tuple = args[i]; string item = tuple.name; object item2 = tuple.value; text = text.Replace("{" + item + "}", item2?.ToString() ?? ""); } return Particles(text); } internal static string Particles(string text) { if (text.IndexOf('/') >= 0) { return s_particles.Replace(text, (Match m) => m.Groups[1].Value + Particle(m.Groups[1].Value[0], m.Groups[2].Value)); } return text; } private static string Particle(char before, string pair) { int num = pair.IndexOf('/'); string text = pair.Substring(0, num); string text2 = pair.Substring(num + 1); int num2 = ((before >= '가' && before <= '힣') ? ((before - 44032) % 28) : ((before >= '0' && before <= '9') ? s_digitFinals[before - 48] : (-1))); if (num2 < 0) { if (!text.EndsWith(text2, StringComparison.Ordinal)) { return text + "(" + text2 + ")"; } return "(" + text.Substring(0, text.Length - text2.Length) + ")" + text2; } if (num2 == 0 || (num2 == 8 && text2 == "로")) { return text2; } return text; } public static string ForGameLanguage(Language language, string key) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (!TryLookup(CodeFor(language), key, out string text) && !TryLookup("en", key, out text)) { return key; } return text; } private static string FromGame() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return CodeFor(LocalizedText.CURRENT_LANGUAGE); } private static string CodeFor(Language language) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected I4, but got Unknown return (int)language switch { 0 => "en", 1 => "fr", 2 => "it", 3 => "de", 4 => "es", 5 => "es-419", 6 => "pt-br", 7 => "ru", 8 => "uk", 9 => "zh-hans", 10 => "zh-hant", 11 => "ja", 12 => "ko", 13 => "pl", 14 => "tr", _ => "en", }; } private static Dictionary<string, Dictionary<string, string>> LoadTables() { Dictionary<string, Dictionary<string, string>> dictionary = new Dictionary<string, Dictionary<string, string>>(StringComparer.OrdinalIgnoreCase); Assembly executingAssembly = Assembly.GetExecutingAssembly(); string[] manifestResourceNames = executingAssembly.GetManifestResourceNames(); foreach (string text in manifestResourceNames) { if (!text.StartsWith("Lang.", StringComparison.Ordinal) || !text.EndsWith(".json", StringComparison.Ordinal)) { continue; } string code = text.Substring(5, text.Length - 10).ToLowerInvariant(); using Stream stream = executingAssembly.GetManifestResourceStream(text); using StreamReader streamReader = new StreamReader(stream); Merge(dictionary, code, streamReader.ReadToEnd(), text); } string path = Path.Combine(Path.GetDirectoryName(executingAssembly.Location) ?? "", "Lang"); if (Directory.Exists(path)) { string[] files = Directory.GetFiles(path, "*.json"); foreach (string text2 in files) { Merge(dictionary, Path.GetFileNameWithoutExtension(text2).ToLowerInvariant(), File.ReadAllText(text2), text2); } } Plugin.Log.LogInfo((object)("Languages: " + string.Join(", ", dictionary.Keys))); return dictionary; } private static void Merge(Dictionary<string, Dictionary<string, string>> tables, string code, string json, string source) { try { Dictionary<string, string> dictionary = JsonConvert.DeserializeObject<Dictionary<string, string>>(json) ?? new Dictionary<string, string>(); if (!tables.TryGetValue(code, out Dictionary<string, string> value)) { value = (tables[code] = new Dictionary<string, string>()); } foreach (KeyValuePair<string, string> item in dictionary) { value[item.Key] = item.Value; } } catch (Exception ex) { Plugin.Log.LogError((object)("Could not read translation " + source + ": " + ex.Message)); } } public static void CycleOverride() { List<string> list = new List<string> { "auto" }; list.AddRange(Available); string item = Plugin.Language.Value.Trim().ToLowerInvariant(); int num = list.IndexOf(item); Plugin.Language.Value = list[(num + 1) % list.Count]; } public static string MenuLanguageLabel() { string text = NativeName(Current); return Get("menu.language", ("lang", IsAuto ? Get("menu.language_auto", ("lang", text)) : text)); } } public enum PigDoing { Idle, Walking, Resting, Sleeping, Riding, Begging, BeingPetted } public enum PigHappening { Summoned, Ate, AteFavourite, Refused, Petted, HadEnough, Nipped, Argument, Snuggle } public sealed class PigInfo { public string Name { get; internal set; } = ""; public string Key { get; internal set; } = ""; public bool Female { get; internal set; } = true; public string Traits { get; internal set; } = ""; public bool PlayerMade { get; internal set; } public Character? Owner { get; internal set; } public Vector3 Position { get; internal set; } public PigDoing Doing { get; internal set; } public Character? BeggingFrom { get; internal set; } public bool WantsTreat { get; internal set; } public float? SecondsSinceFed { get; internal set; } public float SecondsSinceSummoned { get; internal set; } } public sealed class PigNews { public PigHappening What { get; internal set; } public PigInfo Pig { get; internal set; } public PigInfo? Other { get; internal set; } public Character? By { get; internal set; } public string? Food { get; internal set; } public string? Reason { get; internal set; } } public static class PigsApi { public const int Version = 1; internal static string NewsLanguage { get; private set; } = "en"; public static event Action<PigNews>? News; public static IReadOnlyList<PigInfo> Pigs(string language = "en") { return (from p in GuineaPig.All where (Object)(object)p != (Object)null && p.IsReady select p.Info(language)).ToList(); } public static void SetNewsLanguage(string language) { NewsLanguage = (string.IsNullOrWhiteSpace(language) ? "en" : language); } internal static void Tell(PigHappening what, GuineaPig pig, Character? by = null, GuineaPig? other = null, string? food = null, string? reason = null) { Action<PigNews> news = PigsApi.News; if (news == null) { return; } try { news(new PigNews { What = what, Pig = pig.Info(NewsLanguage), Other = (((Object)(object)other != (Object)null) ? other.Info(NewsLanguage) : null), By = by, Food = food, Reason = reason }); } catch (Exception arg) { Plugin.Log.LogWarning((object)$"A pig news listener failed: {arg}"); } } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("CavyCrew.GuineaPigsAndTreats", "Guinea Pigs and Their Treats", "0.9.10")] public class Plugin : BaseUnityPlugin { public const string Id = "CavyCrew.GuineaPigsAndTreats"; internal static ManualLogSource Log { get; private set; } internal static ModDefinition Mod { get; private set; } internal static ConfigEntry<string> SummonKey { get; private set; } internal static ConfigEntry<bool> VerboseLogging { get; private set; } internal static ConfigEntry<string> Language { get; private set; } internal static ConfigEntry<string> MenuLayout { get; private set; } internal static ConfigEntry<bool> ShowMenuTip { get; private set; } internal static ConfigEntry<float> PigSize { get; private set; } internal static ConfigEntry<string> RearViewKey { get; private set; } internal static ConfigEntry<string> CommandKey { get; private set; } internal static ConfigEntry<bool> TreatsGrow { get; private set; } public static string Name => "Guinea Pigs and Their Treats"; public static string Version => "0.9.10"; private void Awake() { //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Expected O, but got Unknown //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; SummonKey = ((BaseUnityPlugin)this).Config.Bind<string>("Controls", "SummonKey", "G", "Keyboard key that opens the guinea pig menu (call a pig or send it home). Uses Unity Input System key names, e.g. G, H, F6, Numpad5."); RearViewKey = ((BaseUnityPlugin)this).Config.Bind<string>("Controls", "LookBackKey", "J", "Hold to see your own back in a small window - with your guinea pigs riding in the backpack. Empty = off."); CommandKey = ((BaseUnityPlugin)this).Config.Bind<string>("Controls", "CommandKey", "H", "Hold for the command wheel: come here, wait here, lie down, nap, wash, beg, popcorn, into or out of the basket. Point with the mouse and let go. Goes to the pig you look at, or to all your pigs. Empty = off."); MenuLayout = ((BaseUnityPlugin)this).Config.Bind<string>("General", "MenuLayout", "list", new ConfigDescription("How the guinea pig menu shows the pigs: 'list' (one under another, scrolling) or 'carousel' (three side by side, with arrows). Can also be switched in the menu.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[2] { "list", "carousel" }), Array.Empty<object>())); ShowMenuTip = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowMenuTip", true, "Show a tip in the airport about the key that opens the guinea pig menu. Turns itself off once you have opened the menu; set it back to true to see the tip again."); Language = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Language", "auto", "Language of the mod's texts: 'auto' follows the game's language; or a code such as en, ru, de. Can also be switched in the guinea pig menu."); PigSize = ((BaseUnityPlugin)this).Config.Bind<float>("General", "PigSize", 1.3f, new ConfigDescription("How big your guinea pigs are (1 = real-life size, about 30 cm). Other players see your pigs at your size.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.8f, 2f), Array.Empty<object>())); TreatsGrow = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "TreatsGrowOnBushes", true, "Iceberg lettuce, cucumbers and zucchini sometimes grow on the berry bushes of the Shore and the Tropics. Only the host's setting matters (the host spawns the items). Restart the game after changing it."); VerboseLogging = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "VerboseLogging", false, "Write extra diagnostic messages to the BepInEx log."); Mod = ModDefinition.GetOrCreate(((BaseUnityPlugin)this).Info.Metadata); PigNetwork.RegisterPrefab(); try { TreatItems.Register(); } catch (Exception arg) { Log.LogError((object)$"Treats could not be set up: {arg}"); } GameObject val = new GameObject("GuineaPigsAndTreats"); Object.DontDestroyOnLoad((Object)(object)val); ((Object)val).hideFlags = (HideFlags)61; val.AddComponent<PigSummoner>(); val.AddComponent<CarrierBaskets>(); val.AddComponent<RidingHud>(); val.AddComponent<RearView>(); val.AddComponent<PigStudio>(); Log.LogInfo((object)("Plugin " + Name + " " + Version + " is loaded!")); } internal static void Verbose(string message) { if (VerboseLogging.Value) { Log.LogInfo((object)message); } } } } namespace GuineaPigsAndTreats.Visuals { internal static class PeakMaterials { private const string PeakShaderName = "W/Peak_Standard"; private static readonly int BaseTexture = Shader.PropertyToID("_BaseTexture"); private static readonly int Tint = Shader.PropertyToID("_Tint"); private static readonly int BaseTexAmount = Shader.PropertyToID("_BaseTexAmount"); private static readonly int BaseSmooth = Shader.PropertyToID("_BaseSmooth"); private static readonly Dictionary<(Color, bool), Material> s_byColor = new Dictionary<(Color, bool), Material>(); private static Shader? s_shader; private static bool s_loggedShader; private static Shader GetShader() { if ((Object)(object)s_shader != (Object)null) { return s_shader; } s_shader = Shader.Find("W/Peak_Standard"); if ((Object)(object)s_shader == (Object)null) { Plugin.Log.LogWarning((object)"Shader W/Peak_Standard not found, falling back to URP Lit."); s_shader = Shader.Find("Universal Render Pipeline/Lit") ?? Shader.Find("Standard"); } else if (!s_loggedShader) { s_loggedShader = true; LogShaderProperties(s_shader); } return s_shader; } public static Material Solid(Color color, float smoothness = 0.2f, bool linear = false) { //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_000e: 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_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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) (Color, bool) key = (new Color(color.r, color.g, color.b, Mathf.Round(smoothness * 100f) / 100f), linear); if (s_byColor.TryGetValue(key, out Material value) && (Object)(object)value != (Object)null) { return value; } Texture2D val = new Texture2D(4, 4, (TextureFormat)4, false, linear) { name = "GuineaPig_" + ColorUtility.ToHtmlStringRGB(color) }; Color[] array = (Color[])(object)new Color[16]; for (int i = 0; i < array.Length; i++) { array[i] = color; } val.SetPixels(array); val.Apply(); Material val2 = Textured(val, smoothness, ((Object)val).name); s_byColor[key] = val2; return val2; } public static Material Textured(Texture2D texture, float smoothness, string name) { //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_0012: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) Material val = new Material(GetShader()) { name = name }; if (val.HasProperty(BaseTexture)) { val.SetTexture(BaseTexture, (Texture)(object)texture); } if (val.HasProperty(BaseTexAmount)) { val.SetFloat(BaseTexAmount, 1f); } if (val.HasProperty(Tint)) { val.SetColor(Tint, Color.white); } if (val.HasProperty(BaseSmooth)) { val.SetFloat(BaseSmooth, Mathf.Clamp01(smoothness)); } val.mainTexture = (Texture)(object)texture; return val; } public static void SetTexture(Material material, Texture2D texture) { if (material.HasProperty(BaseTexture)) { material.SetTexture(BaseTexture, (Texture)(object)texture); } material.mainTexture = (Texture)(object)texture; } private static void LogShaderProperties(Shader shader) { //IL_0019: 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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Invalid comparison between Unknown and I4 //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Invalid comparison between Unknown and I4 //IL_0074: Unknown result type (might be due to invalid IL or missing references) if (Plugin.VerboseLogging.Value) { List<string> list = new List<string>(); for (int i = 0; i < shader.GetPropertyCount(); i++) { ShaderPropertyType propertyType = shader.GetPropertyType(i); string text = (((int)propertyType <= 1) ? ((object)shader.GetPropertyDefaultVectorValue(i)/*cast due to .constrained prefix*/).ToString() : ((propertyType - 2 > 1) ? "" : shader.GetPropertyDefaultFloatValue(i).ToString("0.###"))); string arg = text; list.Add($"{shader.GetPropertyName(i)}:{shader.GetPropertyType(i)}={arg}"); } Plugin.Log.LogInfo((object)(((Object)shader).name + " properties: " + string.Join(", ", list))); } } public static GameObject Primitive(PrimitiveType type, Transform parent, Color color, string name) { //IL_0000: 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) GameObject val = GameObject.CreatePrimitive(type); ((Object)val).name = name; Object.DestroyImmediate((Object)(object)val.GetComponent<Collider>()); val.transform.SetParent(parent, false); MeshRenderer component = val.GetComponent<MeshRenderer>(); ((Renderer)component).sharedMaterial = Solid(color); ((Renderer)component).shadowCastingMode = (ShadowCastingMode)1; return val; } } internal enum PigGesture : byte { ChinUp, HeadDown, Chatter, RumbleStrut, Groom, Sniff, LookUp, Beg } [DefaultExecutionOrder(31010)] internal sealed class PigVisual : MonoBehaviour { private const float HopDuration = 0.32f; private const float HopHeight = 0.09f; private const float ShakeDuration = 0.6f; private const float PopDuration = 0.2f; private Transform _pivot; private Renderer[] _renderers = Array.Empty<Renderer>(); private MaterialPropertyBlock? _block; private static readonly int InteractableId = Shader.PropertyToID("_Interactable"); private PigRig? _rig; private PigAnimator? _animator; private Transform? _headBone; private Transform? _hipsBone; private float _walkPhase; private float _hopTimer = -1f; private int _hopsLeft; private float _shakeTimer = -1f; private float _popTimer = -1f; private float _lungeTimer = -1f; private bool _shown = true; private float _baseScale = 1f; private Vector3 _headLocal = new Vector3(0f, 0.11f, 0.15f); private readonly float[] _gestureUntil = new float[Enum.GetValues(typeof(PigGesture)).Length]; private Transform? _noseBone; private Transform? _flake; private float _flakeSize; private int _popcornsLeft; public float Speed { get; set; } public PigState State { get; set; } public float Purr { get; set; } public Vector3? LookTarget { get; set; } public bool Begging { get; set; } public bool Stretched { get; set; } public float ReachUp { get; set; } public float CurrentReachUp { get; private set; } public float? HeadPitchOverride { get; set; } public Vector3 Nose { get { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_noseBone != (Object)null)) { return ((Component)this).transform.TransformPoint(new Vector3(0f, 0.1f, 0.23f) * _baseScale); } return _noseBone.position; } } public bool HasModel => (Object)(object)_rig != (Object)null; public bool Riding { get; private set; } public Vector3 Center => _pivot.position + Vector3.up * 0.09f * _baseScale; public Vector3 BackFront { get { //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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_headBone != (Object)null)) { return ((Component)this).transform.TransformPoint(new Vector3(0f, 0.17f, 0.08f) * _baseScale); } return _headBone.position + Vector3.up * 0.06f * _baseScale; } } public Vector3 BackRear { get { //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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_hipsBone != (Object)null)) { return ((Component)this).transform.TransformPoint(new Vector3(0f, 0.15f, -0.15f) * _baseScale); } return _hipsBone.position + Vector3.up * 0.06f * _baseScale; } } public void Build(PigDefinition def, float size = 1f) { //IL_0014: 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_0046: 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_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: 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) _baseScale = def.Scale * size; _pivot = new GameObject("Pivot").transform; _pivot.SetParent(((Component)this).transform, false); _pivot.localScale = Vector3.one * _baseScale; _rig = PigRig.Create(_pivot, def); if ((Object)(object)_rig != (Object)null) { if (def.Look != null) { CoatTextures.Dress(_rig, def.Look); } _animator = new PigAnimator(_rig); _animator.Play("Idle", 0f); _headBone = _rig.Bone("head"); _noseBone = _rig.Bone("nose"); _hipsBone = _rig.Bone("body"); if ((Object)(object)_headBone != (Object)null) { _headLocal = ((Component)this).transform.InverseTransformPoint(_headBone.position); } } else { PlaceholderModel.Build(_pivot, def); _headLocal = new Vector3(0f, 0.11f, 0.15f) * _baseScale; } _renderers = ((Component)this).GetComponentsInChildren<Renderer>(true); } public void SetShown(bool shown) { if (_shown != shown) { _shown = shown; ((Component)this).gameObject.SetActive(shown); if (shown) { _popTimer = 0f; } } } public void SetHighlighted(bool highlighted) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown if (_block == null) { _block = new MaterialPropertyBlock(); } Renderer[] renderers = _renderers; foreach (Renderer val in renderers) { val.GetPropertyBlock(_block); _block.SetFloat(InteractableId, highlighted ? 1f : 0f); val.SetPropertyBlock(_block); } } public void SetRidingPose(Vector3 headTarget, Quaternion rotation, float scale) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_003b: Unknown result type (might be due to invalid IL or missing references) Riding = true; ((Component)this).transform.localScale = Vector3.one * scale; ((Component)this).transform.SetPositionAndRotation(headTarget - rotation * (_headLocal * scale), rotation); } public void ClearRiding() { //IL_0016: 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_0036: Unknown result type (might be due to invalid IL or missing references) if (Riding) { Riding = false; ((Component)this).transform.localPosition = Vector3.zero; ((Component)this).transform.localRotation = Quaternion.identity; ((Component)this).transform.localScale = Vector3.one; } } public bool Popcorn(int count) { if (_animator == null || !_animator.HasClip("Popcorn")) { return false; } _popcornsLeft = Mathf.Max(_popcornsLeft, count); return true; } public void Hop(int count = 1) { _hopsLeft = Mathf.Max(_hopsLeft, count); if (_hopTimer < 0f) { _hopTimer = 0f; } } public void Shake() { _shakeTimer = 0f; } public void Lunge() { _lungeTimer = 0f; } public void Chew(float seconds) { _animator?.Chew(seconds); } public void Gesture(PigGesture gesture, float seconds) { _gestureUntil[(uint)gesture] = Time.time + seconds; } private bool Doing(PigGesture gesture) { return Time.time < _gestureUntil[(uint)gesture]; } private void LateUpdate() { float deltaTime = Time.deltaTime; if (_animator != null) { AnimateModel(deltaTime); } ApplyReactions(deltaTime); PlaceFlake(); } public void HoldFlake(Mesh mesh, Material? material) { //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_0022: Expected O, but got Unknown //IL_0060: Unknown result type (might be due to invalid IL or missing references) DropFlake(); GameObject val = new GameObject("Flake") { layer = ((Component)this).gameObject.layer }; val.transform.SetParent(((Component)this).transform, false); val.AddComponent<MeshFilter>().sharedMesh = mesh; MeshRenderer val2 = val.AddComponent<MeshRenderer>(); ((Renderer)val2).sharedMaterial = (Material)(((Object)(object)material != (Object)null) ? ((object)material) : ((object)PeakMaterials.Solid(new Color(0.68f, 0.82f, 0.4f), 0.2f, linear: true))); ((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0; _flake = val.transform; _flakeSize = 0.013f * _baseScale / 1.3f; SetFlakeLeft(1f); PlaceFlake(); } public void SetFlakeLeft(float share) { //IL_0024: 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_0051: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_flake == (Object)null)) { if (share <= 0.02f) { DropFlake(); } else { _flake.localScale = Vector3.one * (_flakeSize * Mathf.Sqrt(share) / Mathf.Max(((Component)this).transform.lossyScale.x, 0.0001f)); } } } public void DropFlake() { if ((Object)(object)_flake != (Object)null) { Object.Destroy((Object)(object)((Component)_flake).gameObject); } _flake = null; } private void PlaceFlake() { //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) //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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_flake == (Object)null)) { _flake.position = Nose + ((Component)this).transform.forward * (0.006f * _baseScale) - ((Component)this).transform.up * (0.012f * _baseScale); _flake.rotation = ((Component)this).transform.rotation * Quaternion.Euler(80f, 0f, 0f); } } private void AnimateModel(float dt) { //IL_03a0: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Unknown result type (might be due to invalid IL or missing references) //IL_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) PigAnimator animator = _animator; string currentName = animator.CurrentName; bool flag = ((currentName == "LieDown_Tucked" || currentName == "Rest_Tucked") ? true : false); bool flag2 = flag; flag = ((currentName == "LieDown_Stretched" || currentName == "Rest_Stretched") ? true : false); bool flag3 = flag; bool flag4 = flag2 || flag3; bool flag5 = Stretched && animator.HasClip("LieDown_Stretched") && animator.HasClip("Rest_Stretched") && animator.HasClip("GetUp_Stretched"); if (Riding) { animator.Play("Rest_Tucked", 0.15f); animator.EyesClosed = 0f; animator.Awake = true; animator.HeadYaw = Mathf.Sin(Time.time * 0.6f + (float)((Object)this).GetInstanceID() * 0.37f) * 30f; animator.Tick(dt); return; } PigState state = State; if (state - 4 <= PigState.Walk) { string text = (flag5 ? "LieDown_Stretched" : "LieDown_Tucked"); string text2 = (flag5 ? "Rest_Stretched" : "Rest_Tucked"); if (flag5 ? flag2 : flag3) { animator.Play(flag3 ? "GetUp_Stretched" : "GetUp_Tucked", 0.15f, 1.6f); } else { flag = ((currentName == "GetUp_Tucked" || currentName == "GetUp_Stretched") ? true : false); if (flag && !animator.CurrentFinished) { goto IL_037f; } if (currentName != text && currentName != text2) { animator.Play(text, 0.2f); } else if (currentName == text && animator.CurrentFinished) { animator.Play(text2, 0.4f); } } animator.EyesClosed = ((State == PigState.Sleeping) ? 1f : 0f); animator.Awake = State != PigState.Sleeping; } else { animator.EyesClosed = 0f; animator.Awake = true; if (flag4) { animator.Play(flag3 ? "GetUp_Stretched" : "GetUp_Tucked", 0.15f, 1.6f); } else { flag = ((currentName == "GetUp_Tucked" || currentName == "GetUp_Stretched") ? true : false); if ((!flag || animator.CurrentFinished) && (!(currentName == "Popcorn") || animator.CurrentFinished)) { if (_popcornsLeft > 0) { _popcornsLeft--; animator.Play("Popcorn", 0.08f, 1f, restart: true); } else if (Doing(PigGesture.Groom) && animator.HasClip("Groom")) { animator.Play("Groom"); } else if ((Begging || Doing(PigGesture.Beg)) && Speed < 0.08f && animator.HasClip("Beg")) { animator.Play("Beg", 0.35f); } else if (Speed > 0.08f) { animator.Play("Walk_InPlace", 0.15f, Mathf.Clamp(Speed * 2.2f, 1f, 4.5f)); } else { animator.Play("Idle", 0.3f); } } } } goto IL_037f; IL_037f: if (LookTarget.HasValue) { Vector3 val = ((Component)this).transform.InverseTransformPoint(LookTarget.Value); float num = Mathf.Atan2(val.x, val.z) * 57.29578f; animator.HeadYaw = Mathf.Clamp(num, -40f, 40f); } else { animator.HeadYaw = 0f; } ApplyGestures(animator); animator.Tick(dt); } private void ApplyGestures(PigAnimator animator) { float time = Time.time; float num = 0f; float num2 = 0f; if (Doing(PigGesture.ChinUp)) { num = 26f; } else if (Doing(PigGesture.HeadDown)) { num = -16f; num2 = 0.9f; } else if (Doing(PigGesture.LookUp)) { num = 15f; } if (Doing(PigGesture.Sniff)) { num = Mathf.Min(num, -6f); animator.Sniff(0.2f); } if (Doing(PigGesture.Groom) && !animator.HasClip("Groom")) { num = -24f + Mathf.Sin(time * MathF.PI * 2f * 3f) * 7f; animator.HeadYaw += Mathf.Sin(time * MathF.PI * 2f * 1.4f) * 14f; } bool flag = Doing(PigGesture.Chatter); animator.HeadPitch = HeadPitchOverride ?? num; animator.EarsBack = Mathf.Max(num2, flag ? 0.5f : 0f); animator.Chattering = flag; animator.HipSway = (Doing(PigGesture.RumbleStrut) ? 1f : 0f); } private void ApplyReactions(float dt) { //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_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_000c: 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) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Unknown result type (might be due to invalid IL or missing references) //IL_0387: Unknown result type (might be due to invalid IL or missing references) //IL_0447: Unknown result type (might be due to invalid IL or missing references) //IL_0453: Unknown result type (might be due to invalid IL or missing references) //IL_045f: Unknown result type (might be due to invalid IL or missing references) //IL_03ca: Unknown result type (might be due to invalid IL or missing references) //IL_03f8: Unknown result type (might be due to invalid IL or missing references) //IL_03fd: Unknown result type (might be due to invalid IL or missing references) Vector3 zero = Vector3.zero; Quaternion val = Quaternion.identity; Vector3 val2 = Vector3.one * _baseScale; float num = Mathf.Clamp01(Speed / 1.2f); if (_animator == null) { _walkPhase += Speed * dt * 44.879894f; zero.y += Mathf.Abs(Mathf.Sin(_walkPhase)) * 0.012f * num * _baseScale; val *= Quaternion.Euler(Mathf.Sin(_walkPhase) * 3f * num, 0f, 0f); float num2 = Mathf.Sin(Time.time * 2.4f + (float)((Object)this).GetInstanceID()) * 0.025f * (1f - num); val2.y *= 1f + num2; val2.x *= 1f - num2 * 0.4f; } else if (Speed > 2f) { _walkPhase += dt * MathF.PI * 2f * 5f; zero.y += Mathf.Abs(Mathf.Sin(_walkPhase)) * 0.008f * _baseScale; } if (_hopTimer >= 0f) { _hopTimer += dt; float num3 = _hopTimer / 0.32f; zero.y += 0.36f * _baseScale * num3 * (1f - num3); val *= Quaternion.Euler(-12f * Mathf.Sin(num3 * MathF.PI), Mathf.Sin(num3 * MathF.PI) * 20f, 0f); if (num3 >= 1f) { _hopsLeft--; _hopTimer = ((_hopsLeft > 0) ? 0f : (-1f)); } } if (_shakeTimer >= 0f) { _shakeTimer += dt; float num4 = _shakeTimer / 0.6f; val *= Quaternion.Euler(0f, Mathf.Sin(_shakeTimer * 28f) * 18f * (1f - num4), 0f); if (num4 >= 1f) { _shakeTimer = -1f; } } if (Purr > 0.01f) { float num5 = Mathf.Sin(Time.time * MathF.PI * 2f * 24f) * 0.0018f * Purr * _baseScale; zero.y += num5; val2.y *= 1f - 0.05f * Purr; val2.x *= 1f + 0.025f * Purr; } if (_lungeTimer >= 0f) { _lungeTimer += dt; float num6 = _lungeTimer / 0.25f; zero.z += Mathf.Sin(Mathf.Clamp01(num6) * MathF.PI) * 0.06f * _baseScale; val *= Quaternion.Euler(-10f * Mathf.Sin(Mathf.Clamp01(num6) * MathF.PI), 0f, 0f); if (num6 >= 1f) { _lungeTimer = -1f; } } if (_popTimer >= 0f) { _popTimer += dt; float num7 = Mathf.Clamp01(_popTimer / 0.2f); val2 *= Mathf.Sin(num7 * MathF.PI * 0.5f) * (1f + 0.15f * Mathf.Sin(num7 * MathF.PI)); if (num7 >= 1f) { _popTimer = -1f; } } CurrentReachUp = Mathf.MoveTowards(CurrentReachUp, ReachUp, dt * 0.25f); zero.y += CurrentReachUp; _pivot.localPosition = zero; _pivot.localRotation = val; _pivot.localScale = val2; } } internal static class PlaceholderModel { public static void Build(Transform pivot, PigDefinition def) { //IL_0033: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_00a7: 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_00cf: 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_00f0: 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_0138: Unknown result type (might be due to invalid IL or missing references) //IL_014b: 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_015a: 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_0183: 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_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) Color color = default(Color); ((Color)(ref color))..ctor(0.95f, 0.66f, 0.66f); Color color2 = default(Color); ((Color)(ref color2))..ctor(0.04f, 0.04f, 0.04f); Part(pivot, "Body", def.Fur, new Vector3(0f, 0.085f, -0.02f), new Vector3(0.2f, 0.15f, 0.3f)); Part(pivot, "Head", def.Fur, new Vector3(0f, 0.1f, 0.13f), new Vector3(0.15f, 0.13f, 0.15f)); Part(pivot, "Muzzle", def.Fur, new Vector3(0f, 0.08f, 0.195f), new Vector3(0.09f, 0.07f, 0.07f)); Part(pivot, "Nose", color, new Vector3(0f, 0.095f, 0.228f), new Vector3(0.025f, 0.018f, 0.015f)); float[] array = new float[2] { -1f, 1f }; foreach (float num in array) { Part(pivot, "Eye", color2, new Vector3(num * 0.072f, 0.125f, 0.168f), Vector3.one * 0.032f); Part(pivot, "Ear", def.Ears, new Vector3(num * 0.068f, 0.168f, 0.105f), new Vector3(0.014f, 0.05f, 0.045f)).localRotation = Quaternion.Euler(0f, 0f, (0f - num) * 40f); Part(pivot, "FrontFoot", color, new Vector3(num * 0.06f, 0.01f, 0.09f), new Vector3(0.04f, 0.02f, 0.05f)); Part(pivot, "HindFoot", color, new Vector3(num * 0.065f, 0.01f, -0.11f), new Vector3(0.045f, 0.02f, 0.06f)); } Part(pivot, "Patch", def.Patch, new Vector3(0f, 0.095f, -0.09f), new Vector3(0.205f, 0.14f, 0.17f)); } private static Transform Part(Transform pivot, string name, Color color, Vector3 position, Vector3 scale) { //IL_0002: 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_0017: Unknown result type (might be due to invalid IL or missing references) Transform transform = PeakMaterials.Primitive((PrimitiveType)0, pivot, color, name).transform; transform.localPosition = position; transform.localScale = scale; return transform; } } } namespace GuineaPigsAndTreats.UI { internal sealed class CommandWheel : MenuWindow { private sealed class Item { public Image Wedge; public Image Icon; public TextMeshProUGUI Label; public PigCommand Command; public bool Enabled; } private const float Outer = 300f; private const float Inner = 112f; private const float ItemRadius = 202f; private const float PointerRadius = 284f; private static CommandWheel? s_instance; private static Key s_key = (Key)22; private static string s_parsedKey = "\0"; private static readonly Dictionary<string, Sprite?> s_icons = new Dictionary<string, Sprite>(); private Canvas _canvas; private readonly Item[] _items = new Item[7]; private RectTransform _portraits; private TextMeshProUGUI _names; private TextMeshProUGUI _chosen; private TextMeshProUGUI _hint; private RectTransform _paw; private Vector2 _pointer; private int _hovered = -1; private int _openedFrame; private readonly List<GuineaPig> _targets = new List<GuineaPig>(); public override bool openOnStart => false; public override bool closeOnPause => true; public override bool closeOnUICancel => true; public override bool blocksPlayerInput => true; public override bool showCursorWhileOpen => false; public override bool selectOnOpen => false; public static bool IsActive { get { if ((Object)(object)s_instance != (Object)null) { return ((MenuWindow)s_instance).isOpen; } return false; } } public static void Tick() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Invalid comparison between Unknown and I4 RefreshKey(); Keyboard current = Keyboard.current; if ((int)s_key == 0 || current == null || !((ButtonControl)current[s_key]).wasPressedThisFrame || IsActive) { return; } Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null || localCharacter.data.dead || (int)Cursor.lockState != 1 || ((Object)(object)GUIManager.instance != (Object)null && GUIManager.instance.windowBlockingInput) || PettingWindow.IsActive || PigCreatorWindow.IsOpenNow || ((Object)(object)PigMenuWindow.Instance != (Object)null && ((MenuWindow)PigMenuWindow.Instance).isOpen)) { return; } List<GuineaPig> list = PigSummoner.MyPigs().ToList(); if (list.Count == 0) { PigSummoner.ShowMessage(Lang.Get("wheel.no_pigs", ("key", Plugin.SummonKey.Value.ToUpperInvariant()))); return; } if (s_instance == null) { s_instance = Create(); } s_instance.Show(TargetsFor(list)); } private static void RefreshKey() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) string value = Plugin.CommandKey.Value; if (!(value == s_parsedKey)) { s_parsedKey = value; s_key = (Key)(Enum.TryParse<Key>(value.Trim(), ignoreCase: true, out Key result) ? ((int)result) : 0); } } private static List<GuineaPig> TargetsFor(List<GuineaPig> mine) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: 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) Camera val = (((Object)(object)MainCamera.instance != (Object)null) ? MainCamera.instance.cam : Camera.main); GuineaPig guineaPig = null; if ((Object)(object)val != (Object)null) { float num = float.MaxValue; Vector3 position = ((Component)val).transform.position; foreach (GuineaPig item in mine) { if (item.IsRiding) { continue; } Vector3 val2 = item.Center() - position; float magnitude = ((Vector3)(ref val2)).magnitude; if (!(magnitude > 40f) && !(magnitude < 0.01f)) { float num2 = Vector3.Angle(((Component)val).transform.forward, val2); float num3 = Mathf.Max(5f, Mathf.Atan2(0.35f * item.SizeFactor, magnitude) * 57.29578f); if (num2 < num3 && num2 < num && !Physics.Linecast(position, item.Center(), LayerMask.GetMask(new string[2] { "Terrain", "Map" }), (QueryTriggerInteraction)1)) { guineaPig = item; num = num2; } } } } if (!((Object)(object)guineaPig != (Object)null)) { return mine; } return new List<GuineaPig>(1) { guineaPig }; } private static Sprite? Icon(string name) { //IL_008b: 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 (s_icons.TryGetValue(name, out Sprite value)) { return value; } string path = Path.Combine(Path.GetDirectoryName(typeof(CommandWheel).Assembly.Location) ?? "", "UI", "Commands", name + ".png"); Texture2D val = PigAssets.LoadTexture(path, "GuineaPigs command " + name); Sprite val2 = null; if ((Object)(object)val != (Object)null) { ((Texture)val).wrapMode = (TextureWrapMode)1; val2 = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f); } s_icons[name] = val2; return val2; } private static CommandWheel Create() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown Canvas val = UiKit.CreateCanvas("GuineaPigCommandWheel", 560); CommandWheel commandWheel = ((Component)val).gameObject.AddComponent<CommandWheel>(); commandWheel._canvas = val; commandWheel.Build((RectTransform)((Component)val).transform); return commandWheel; } private static Image Disc(Transform parent, string name, float diameter, Color colour) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) RectTransform val = UiKit.Rect(parent, name); val.sizeDelta = new Vector2(diameter, diameter); Image val2 = ((Component)val).gameObject.AddComponent<Image>(); val2.sprite = UiKit.LargeCircleSprite; ((Graphic)val2).color = colour; ((Graphic)val2).raycastTarget = false; return val2; } private void Build(RectTransform root) { //IL_001f: 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_002e: 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_0059: 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_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0141: 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_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0191: 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_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_0377: Unknown result type (might be due to invalid IL or missing references) //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_03d3: Unknown result type (might be due to invalid IL or missing references) //IL_03e9: Unknown result type (might be due to invalid IL or missing references) //IL_0412: Unknown result type (might be due to invalid IL or missing references) //IL_0431: Unknown result type (might be due to invalid IL or missing references) //IL_0473: Unknown result type (might be due to invalid IL or missing references) //IL_049c: Unknown result type (might be due to invalid IL or missing references) //IL_04bb: Unknown result type (might be due to invalid IL or missing references) //IL_0517: Unknown result type (might be due to invalid IL or missing references) //IL_053c: Unknown result type (might be due to invalid IL or missing references) //IL_0557: Unknown result type (might be due to invalid IL or missing references) //IL_0582: Unknown result type (might be due to invalid IL or missing references) //IL_05f8: Unknown result type (might be due to invalid IL or missing references) //IL_0623: Unknown result type (might be due to invalid IL or missing references) //IL_0670: Unknown result type (might be due to invalid IL or missing references) RectTransform val = UiKit.Rect((Transform)(object)root, "Wheel"); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0.5f, 0.5f); val.anchorMax = val2; val.anchorMin = val2; val.sizeDelta = Vector2.zero; Disc((Transform)(object)val, "Rim", 614f, UiKit.BadgeRing); Disc((Transform)(object)val, "Face", 600f, UiKit.Paper); int num = _items.Length; float num2 = 360f / (float)num; Image[] array = (Image[])(object)new Image[num]; for (int i = 0; i < num; i++) { Image val3 = Disc((Transform)(object)val, $"Wedge{i}", 592f, UiKit.Accent); val3.type = (Type)3; val3.fillMethod = (FillMethod)4; val3.fillOrigin = 2; val3.fillClockwise = true; val3.fillAmount = 1f / (float)num; ((Transform)((Graphic)val3).rectTransform).localEulerAngles = new Vector3(0f, 0f, 0f - ((float)i * num2 - num2 / 2f)); array[i] = val3; } for (int j = 0; j < num; j++) { RectTransform val4 = UiKit.Rect((Transform)(object)val, $"Line{j}"); val4.pivot = new Vector2(0.5f, 0f); val4.sizeDelta = new Vector2(3f, 182f); ((Transform)val4).localEulerAngles = new Vector3(0f, 0f, 0f - ((float)j * num2 - num2 / 2f)); val4.anchoredPosition = Rotate(new Vector2(0f, 115f), (float)j * num2 - num2 / 2f); Image val5 = ((Component)val4).gameObject.AddComponent<Image>(); ((Graphic)val5).color = new Color(UiKit.Ink.r, UiKit.Ink.g, UiKit.Ink.b, 0.18f); ((Graphic)val5).raycastTarget = false; } for (int k = 0; k < num; k++) { RectTransform val6 = UiKit.Rect((Transform)(object)val, $"Item{k}"); val6.sizeDelta = new Vector2(160f, 130f); val6.anchoredPosition = Rotate(new Vector2(0f, 202f), (float)k * num2); RectTransform val7 = UiKit.Rect((Transform)(object)val6, "Icon"); val7.sizeDelta = new Vector2(76f, 76f); val7.anchoredPosition = new Vector2(0f, 25f); Image val8 = ((Component)val7).gameObject.AddComponent<Image>(); ((Graphic)val8).raycastTarget = false; val8.preserveAspect = true; TextMeshProUGUI val9 = UiKit.Text((Transform)(object)val6, "", 21f, UiKit.Ink, (TextAlignmentOptions)258); ((TMP_Text)val9).rectTransform.sizeDelta = new Vector2(156f, 50f); ((TMP_Text)val9).rectTransform.anchoredPosition = new Vector2(0f, -45f); ((TMP_Text)val9).textWrappingMode = (TextWrappingModes)1; ((TMP_Text)val9).lineSpacing = -12f; ((TMP_Text)val9).enableAutoSizing = true; ((TMP_Text)val9).fontSizeMin = 14f; ((TMP_Text)val9).fontSizeMax = 21f; _items[k] = new Item { Wedge = array[k], Icon = val8, Label = val9 }; } Disc((Transform)(object)val, "MiddleRim", 234f, UiKit.BadgeRing); Disc((Transform)(object)val, "Middle", 224f, UiKit.Paper); _portraits = UiKit.Rect((Transform)(object)val, "Portraits"); _portraits.anchoredPosition = new Vector2(0f, 34f); _portraits.sizeDelta = new Vector2(200f, 84f); _names = UiKit.Text((Transform)(object)val, "", 19f, UiKit.Accent, (TextAlignmentOptions)514); ((TMP_Text)_names).rectTransform.sizeDelta = new Vector2(190f, 30f); ((TMP_Text)_names).rectTransform.anchoredPosition = new Vector2(0f, -30f); ((TMP_Text)_names).enableAutoSizing = true; ((TMP_Text)_names).fontSizeMin = 12f; ((TMP_Text)_names).fontSizeMax = 19f; _chosen = UiKit.Text((Transform)(object)val, "", 24f, UiKit.Ink, (TextAlignmentOptions)514); ((TMP_Text)_chosen).rectTransform.sizeDelta = new Vector2(196f, 44f); ((TMP_Text)_chosen).rectTransform.anchoredPosition = new Vector2(0f, -62f); ((TMP_Text)_chosen).textWrappingMode = (TextWrappingModes)1; ((TMP_Text)_chosen).enableAutoSizing = true; ((TMP_Text)_chosen).fontSizeMin = 13f; ((TMP_Text)_chosen).fontSizeMax = 24f; Image val10 = UiKit.Panel((Transform)(object)val, "HintBack", new Color(0.12f, 0.08f, 0.05f, 0.6f)); ((Graphic)val10).raycastTarget = false; ((Graphic)val10).rectTransform.sizeDelta = new Vector2(700f, 76f); ((Graphic)val10).rectTransform.anchoredPosition = new Vector2(0f, -362f); _hint = UiKit.Text((Transform)(object)((Graphic)val10).rectTransform, "", 20f, new Color(1f, 0.95f, 0.85f), (TextAlignmentOptions)514); UiKit.Stretch(((TMP_Text)_hint).rectTransform); ((TMP_Text)_hint).textWrappingMode = (TextWrappingModes)1; ((TMP_Text)_hint).enableAutoSizing = true; ((TMP_Text)_hint).fontSizeMin = 13f; ((TMP_Text)_hint).fontSizeMax = 20f; ((TMP_Text)_hint).margin = new Vector4(16f, 4f, 16f, 4f); _paw = UiKit.Rect((Transform)(object)val, "Paw"); _paw.sizeDelta = new Vector2(46f, 46f); Image val11 = ((Component)_paw).gameObject.AddComponent<Image>(); val11.sprite = UiKit.PawSprite; ((Graphic)val11).color = new Color(UiKit.Ink.r, UiKit.Ink.g, UiKit.Ink.b, 0.85f); ((Graphic)val11).raycastTarget = false; } private static Vector2 Rotate(Vector2 v, float degrees) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_003f: Unknown result type (might be due to invalid IL or missing references) float num = (0f - degrees) * (MathF.PI / 180f); return new Vector2(v.x * Mathf.Cos(num) - v.y * Mathf.Sin(num), v.x * Mathf.Sin(num) + v.y * Mathf.Cos(num)); } private void Show(List<GuineaPig> targets) { //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) _targets.Clear(); _targets.AddRange(targets); _pointer = Vector2.zero; _hovered = -1; _openedFrame = Time.frameCount; bool flag = _targets.All((GuineaPig p) => p.IsRiding); bool flag2 = _targets.All((GuineaPig p) => p.IsHeldInBasket); SetItem(0, PigCommand.Come, "cmd.come", "come", enabled: true); SetItem(1, PigCommand.Lie, "viewer.lie", "lie", !flag); SetItem(2, PigCommand.Sleep, "viewer.sleep", "sleep", !flag); SetItem(3, flag2 ? PigCommand.BasketOut : PigCommand.BasketIn, flag2 ? "cmd.basket_out" : "cmd.basket_in", flag2 ? "basket_out" : "basket_in", enabled: true); SetItem(4, PigCommand.Popcorn, "viewer.popcorn", "popcorn", !flag); SetItem(5, PigCommand.Beg, "viewer.beg", "beg", !flag); SetItem(6, PigCommand.Groom, "viewer.groom", "groom", !flag); ShowPortraits(); ((TMP_Text)_names).text = UiKit.KeepKoreanWords(string.Join(Lang.Get("punct.list"), _targets.Select((GuineaPig p) => Lang.PigName(p.Def)))); ((TMP_Text)_chosen).text = ""; string item = Plugin.CommandKey.Value.Trim().ToUpperInvariant(); ((TMP_Text)_hint).text = UiKit.KeepKoreanWords(Lang.Get("wheel.hint", ("key", item)) + "\n" + Lang.Get("wheel.look_hint")); UiKit.ApplyGameFont(((Component)this).gameObject); foreach (GuineaPig target in _targets) { target.Visual.SetHighlighted(highlighted: true); } Refresh(); ((MenuWindow)this).Open(); } private void SetItem(int index, PigCommand command, string labelKey, string icon, bool enabled) { Item item = _items[index]; item.Command = command; item.Enabled = enabled; ((TMP_Text)item.Label).text = UiKit.KeepKoreanWords(Lang.Get(labelKey)); item.Icon.sprite = Icon(icon); ((Behaviour)item.Icon).enabled = (Object)(object)item.Icon.sprite != (Object)null; } private void ShowPortraits() { //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) for (int num = ((Transform)_portraits).childCount - 1; num >= 0; num--) { Object.Destroy((Object)(object)((Component)((Transform)_portraits).GetChild(num)).gameObject); } int count = _targets.Count; float num2 = count switch { 2 => 72f, 1 => 84f, _ => 56f, }; float num3 = 8f; float num4 = (float)count * num2 + (float)(count - 1) * num3; for (int i = 0; i < count; i++) { PigDefinition def = _targets[i].Def; RectTransform val = UiKit.Rect((Transform)(object)_portraits, "Portrait_" + def.Key); val.sizeDelta = new Vector2(num2, num2); val.anchoredPosition = new Vector2((0f - num4) / 2f + num2 / 2f + (float)i * (num2 + num3), 0f); Texture texture = (Texture)(def.IsCustom ? ((object)PigStudio.Portrait(def)) : ((object)PigAssets.Portrait(def))); UiKit.Portrait(val, texture, PigStudio.BadgeColour(def)); } } public override void Update() { //IL_00a6: 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_00b8: 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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_017f: 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_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) ((MenuWindow)this).Update(); if (!((MenuWindow)this).isOpen) { return; } _targets.RemoveAll((GuineaPig p) => (Object)(object)p == (Object)null); Keyboard current = Keyboard.current; if (_targets.Count == 0 || current == null || (Object)(object)Character.localCharacter == (Object)null || Character.localCharacter.data.dead) { ((MenuWindow)this).Close(); return; } Mouse current2 = Mouse.current; if (current2 != null) { float num = ((_canvas.scaleFactor > 0f) ? _canvas.scaleFactor : 1f); _pointer += ((InputControl<Vector2>)(object)((Pointer)current2).delta).ReadValue() / num; if (((Vector2)(ref _pointer)).magnitude > 284f) { _pointer = ((Vector2)(ref _pointer)).normalized * 284f; } } if (((Vector2)(ref _pointer)).magnitude > 112f) { float num2 = Mathf.Atan2(_pointer.x, _pointer.y) * 57.29578f; if (num2 < 0f) { num2 += 360f; } _hovered = Mathf.RoundToInt(num2 / (360f / (float)_items.Length)) % _items.Length; } else { _hovered = -1; } Refresh(); bool flag = Time.frameCount > _openedFrame && !((ButtonControl)current[s_key]).isPressed; bool flag2 = current2 != null && current2.leftButton.wasPressedThisFrame; if (flag || flag2) { Choose(); ((MenuWindow)this).Close(); } } public override void OnClose() { foreach (GuineaPig target in _targets) { if ((Object)(object)target != (Object)null) { target.Visual.SetHighlighted(highlighted: false); } } } private void Refresh() { //IL_0108: 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_0048: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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) for (int i = 0; i < _items.Length; i++) { Item item = _items[i]; bool flag = i == _hovered && item.Enabled; ((Behaviour)item.Wedge).enabled = flag; float num = (item.Enabled ? 1f : 0.35f); Color val = (flag ? Color.white : UiKit.Ink); ((Graphic)item.Icon).color = new Color(val.r, val.g, val.b, num); ((Graphic)item.Label).color = new Color(val.r, val.g, val.b, num); } bool flag2 = _hovered >= 0 && _items[_hovered].Enabled; ((TMP_Text)_chosen).text = (flag2 ? ((TMP_Text)_items[_hovered].Label).text : ""); _paw.anchoredPosition = _pointer; } private void Choose() { if (_hovered >= 0 && _items[_hovered].Enabled) { PigCommand command = _items[_hovered].Command; List<GuineaPig> list = _targets.Where((GuineaPig p) => p.Command(command)).ToList(); if (list.Count > 0 && command == PigCommand.BasketIn) { PigSummoner.ShowMessage((list.Count == 1) ? Lang.ForPig(list[0].Def, "msg.basket_held") : Lang.Get("msg.basket_held_all")); } } } } internal sealed class KeysOverlay : MonoBehaviour { private sealed class Row { public ConfigEntry<string> Entry; public bool MayBeOff; public TextMeshProUGUI Value; } private static readonly HashSet<Key> GameKeys = new HashSet<Key> { (Key)37, (Key)15, (Key)33, (Key)18, (Key)19, (Key)31, (Key)32, (Key)34, (Key)36, (Key)1, (Key)3, (Key)51, (Key)55, (Key)60, (Key)2, (Key)4, (Key)63, (Key)64, (Key)61, (Key)62, (Key)41, (Key)42, (Key)43, (Key)44, (Key)45, (Key)46, (Key)47, (Key)48, (Key)49 }; private static KeysOverlay? s_open; private readonly List<Row> _rows = new List<Row>(); private Row? _listening; private int _listenFrame; private TextMeshProUGUI _note; private Action? _onClosed; public static bool IsOpen => (Object)(object)s_open != (Object)null; public static bool Listening { get { if ((Object)(object)s_open != (Object)null) { return s_open._listening != null; } return false; } } public static void Show(RectTransform root, Action onClosed) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)s_open != (Object)null)) { RectTransform val = UiKit.Rect((Transform)(object)root, "Keys"); UiKit.Stretch(val); Image val2 = ((Component)val).gameObject.AddComponent<Image>(); ((Graphic)val2).color = new Color(0f, 0f, 0f, 0.55f); s_open = ((Component)val).gameObject.AddComponent<KeysOverlay>(); s_open._onClosed = onClosed; s_open.Build(val); } } private void Build(RectTransform overlay) { //IL_0006: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Expected O, but got Unknown Image val = UiKit.Panel((Transform)(object)overlay, "Box", UiKit.Paper); RectTransform rectTransform = ((Graphic)val).rectTransform; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0.5f, 0.5f); rectTransform.anchorMax = val2; rectTransform.anchorMin = val2; rectTransform.pivot = new Vector2(0.5f, 0.5f); VerticalLayoutGroup val3 = ((Component)val).gameObject.AddComponent<VerticalLayoutGroup>(); ((LayoutGroup)val3).padding = new RectOffset(34, 34, 26, 26); ((HorizontalOrVerticalLayoutGroup)val3).spacing = 16f; ((LayoutGroup)val3).childAlignment = (TextAnchor)1; ((HorizontalOrVerticalLayoutGroup)val3).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)val3).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)val3).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)val3).childForceExpandHeight = false; ContentSizeFitter val4 = ((Component)val).gameObject.AddComponent<ContentSizeFitter>(); val4.horizontalFit = (FitMode)2; val4.verticalFit = (FitMode)2; TextMeshProUGUI val5 = UiKit.Text((Transform)(object)rectTransform, Lang.Get("keys.title"), 34f, UiKit.Ink, (TextAlignmentOptions)514); ((TMP_Text)val5).characterSpacing = 1f; AddRow((Transform)(object)rectTransform, "keys.menu", Plugin.SummonKey, mayBeOff: false); AddRow((Transform)(object)rectTransform, "keys.commands", Plugin.CommandKey, mayBeOff: true); AddRow((Transform)(object)rectTransform, "keys.look_back", Plugin.RearViewKey, mayBeOff: true); _note = UiKit.Text((Transform)(object)rectTransform, "", 18f, new Color(0.45f, 0.35f, 0.25f), (TextAlignmentOptions)514); ((TMP_Text)_note).textWrappingMode = (TextWrappingModes)1; ((Component)_note).gameObject.AddComponent<LayoutElement>().preferredWidth = 640f; ShowNote(null); TextMeshProUGUI text; Button val6 = UiKit.Button((Transform)(object)rectTransform, Lang.Get("keys.done"), 200f, new UnityAction(Close), out text); UiKit.Fit(val6, text); ((Component)val6).gameObject.GetComponent<LayoutElement>().flexibleWidth = 0f; UiKit.ApplyGameFont(((Component)this).gameObject); Refresh(); UIInputHandler.SetSelectedObject(((Component)val6).gameObject); } private void AddRow(Transform parent, string labelKey, ConfigEntry<string> entry, bool mayBeOff) { //IL_006a: 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_00de: Expected O, but got Unknown RectTransform val = UiKit.Rect(parent, "Row_" + labelKey); HorizontalLayoutGroup val2 = ((Component)val).gameObject.AddComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)val2).spacing = 20f; ((LayoutGroup)val2).childAlignment = (TextAnchor)3; ((HorizontalOrVerticalLayoutGroup)val2).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)val2).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)val2).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)val2).childForceExpandHeight = false; TextMeshProUGUI val3 = UiKit.Text((Transform)(object)val, Lang.Get(labelKey), 23f, UiKit.Ink, (TextAlignmentOptions)4097); ((TMP_Text)val3).textWrappingMode = (TextWrappingModes)1; LayoutElement val4 = ((Component)val3).gameObject.AddComponent<LayoutElement>(); val4.preferredWidth = 440f; val4.minHeight = 52f; Row row = new Row { Entry = entry, MayBeOff = mayBeOff }; TextMeshProUGUI text; Button button = UiKit.Button((Transform)(object)val, "", 180f, (UnityAction)delegate { StartListening(row); }, out text); UiKit.Fit(button, text); row.Value = text; _rows.Add(row); } private void StartListening(Row row) { if (_listening == row) { _listening = null; Refresh(); return; } _listening = row; _listenFrame = Time.frameCount; ShowNote(null); Refresh(); } private unsafe void Update() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Invalid comparison between Unknown and I4 //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Invalid comparison between Unknown and I4 //IL_00c1: Unknown result type (might be due to invalid IL or missing references) if (_listening == null || Time.frameCount <= _listenFrame) { return; } Keyboard current = Keyboard.current; if (current == null) { return; } KeyControl val = null; Enumerator<KeyControl> enumerator = current.allKeys.GetEnumerator(); try { while (enumerator.MoveNext()) { KeyControl current2 = enumerator.Current; if (current2 != null && ((ButtonControl)current2).wasPressedThisFrame) { val = current2; break; } } } finally { ((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } if (val == null) { return; } Row listening = _listening; Key keyCode = val.keyCode; _listening = null; if (((int)keyCode == 65 || (int)keyCode == 71) ? true : false) { if (listening.MayBeOff) { listening.Entry.Value = ""; } ShowNote(null); } else if (GameKeys.Contains(keyCode)) { ShowNote(Lang.Get("keys.taken", ("key", ((object)(*(Key*)(&keyCode))/*cast due to .constrained prefix*/).ToString()))); } else { string value = listening.Entry.Value; foreach (Row row in _rows) { if (row != listening && string.Equals(row.Entry.Value.Trim(), ((object)(*(Key*)(&keyCode))/*cast due to .constrained prefix*/).ToString(), StringComparison.OrdinalIgnoreCase)) { row.Entry.Value = value; } } listening.Entry.Value = ((object)(*(Key*)(&keyCode))/*cast due to .constrained prefix*/).ToString(); ShowNote(null); } Refresh(); } private void ShowNote(string? warning) { ((TMP_Text)_note).text = UiKit.KeepKoreanWords((warning != null) ? ("<color=#B4372B>" + warning + "</color>") : Lang.Get("keys.hint")); } private void Refresh() { //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) foreach (Row row in _rows) { string text = row.Entry.Value.Trim(); ((TMP_Text)row.Value).text = UiKit.KeepKoreanWords((row == _listening) ? Lang.Get("keys.press") : ((text.Length == 0) ? Lang.Get("keys.off") : text.ToUpperInvariant())); ((Graphic)row.Value).color = ((row == _listening) ? UiKit.Accent : UiKit.Ink); } } public static void Dismiss() { if (!((Object)(object)s_open == (Object)null)) { s_open._onClosed = null; Object.Destroy((Object)(object)((Component)s_open).gameObject); s_open = null; } } private void Close() { if ((Object)(object)s_open == (Object)(object)this) { s_open = null; } Object.Destroy((Object)(object)((Component)this).gameObject); _onClosed?.Invoke(); } private void OnDestroy() { if ((Object)(object)s_open == (Object)(object)this) { s_open = null; } } } internal sealed class PettingWindow : MenuWindow { private const float MaxPettingDistance = 2.8f; private const float IdealStrokeSpeed = 0.35f; private const float TooFastSpeed = 1.3f; private const float NetworkInterval = 0.2f; private const float RestartCooldown = 0.4f; private const float CalmReturnRatio = 2.5f; private const float LiftHoldSeconds = 0.3f; private const float WarnAt = 0.5f; private const float WarningSeconds = 1.8f; private const float GuideSeconds = 4f; private const float AgainstFurTipSeconds = 3.5f; private static PettingWindow? s_instance; private static float s_lastEnded = -10f; private GuineaPig? _pig; private int _startFrame; private RectTransform _canvasRect; private RectTransform _hand; private Image _handImage; private RectTransform _guide; private Image _guideImage; private TextMeshProUGUI _hint; private string _hintKey = ""; private RectTransform _heartLayer; private readonly List<(RectTransform rect, Image image, float born)> _hearts = new List<(RectTransform, Image, float)>(); private Vector2 _handScreen; private Vector2 _lastDelta; private float _contentment; private float _irritation; private float _recentBad; private float _elapsed; private float _blissTime; private bool _blissAnnounced; private float _nextNetwork; private float _nextHeart; private float _sentPurr = -1f; private bool _lifted; private float _liftedUntil; private float _handLift; private float _warnedAt; private float _guideUntil; private float _tipUntil; private float _nextTip; public static bool IsActive { get { if ((Object)(object)s_instance != (Object)null) { return ((MenuWindow)s_instance).isOpen; } return false; } } public static bool CanStart { get { if (!IsActive) { return Time.time - s_lastEnded > 0.4f; } return false; } } public override bool openOnStart => false; public override bool closeOnPause => true; public override bool blocksPlayerInput => true; public override bool showCursorWhileOpen => false; public override bool selectOnOpen => false; public static void Begin(GuineaPig pig) { if (s_instance == null) { s_instance = Create(); } s_instance.StartSession(pig); } private static PettingWindow Create() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown Canvas val = UiKit.CreateCanvas("GuineaPigPetting", 550); PettingWindow pettingWindow = ((Component)val).gameObject.AddComponent<PettingWindow>(); pettingWindow.Build((RectTransform)((Component)val).transform); return pettingWindow; } private void Build(RectTransform root) { //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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0144: 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_016a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: 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_0218: Unknown result type (might be due to invalid IL or missing references) _canvasRect = root; _heartLayer = UiKit.Rect((Transform)(object)root, "Hearts"); UiKit.Stretch(_heartLayer); _guide = UiKit.Rect((Transform)(object)root, "StrokeGuide"); Vector2 val = (_guide.anchorMin = (_guide.anchorMax = Vector2.zero)); _guideImage = ((Component)_guide).gameObject.AddComponent<Image>(); _guideImage.sprite = UiKit.ArrowSprite; ((Graphic)_guideImage).raycastTarget = false; _hand = UiKit.Rect((Transform)(object)root, "Hand"); val = (_hand.anchorMin = (_hand.anchorMax = Vector2.zero)); _hand.sizeDelta = new Vector2(84f, 84f); _handImage = ((Component)_hand).gameObject.AddComponent<Image>(); _handImage.sprite = UiKit.PawSprite; ((Graphic)_handImage).raycastTarget = false; Image val4 = UiKit.Panel((Transform)(object)root, "HintBack", new Color(0.12f, 0.08f, 0.05f, 0.55f)); RectTransform rectTransform = ((Graphic)val4).rectTransform; ((Vector2)(ref val))..ctor(0.5f, 0f); rectTransform.anchorMax = val; rectTransform.anchorMin = val; rectTransform.pivot = new Vector2(0.5f, 0f); rectTransform.anchoredPosition = new Vector2(0f, 150f); rectTransform.sizeDelta = new Vector2(1000f, 56f); _hint = UiKit.Text((Transform)(object)rectTransform, Lang.Get("petting.hint"), 26f, new Color(1f, 0.95f, 0.85f), (TextAlignmentOptions)514); UiKit.Stretch(((TMP_Text)_hint).rectTransform); ((TMP_Text)_hint).enableAutoSizing = true; ((TMP_Text)_hint).fontSizeMin = 17f; ((TMP_Text)_hint).fontSizeMax = 26f; ((TMP_Text)_hint).margin = new Vector4(16f, 0f, 16f, 0f); } private void StartSession(GuineaPig pig) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) _pig = pig; _startFrame = Time.frameCount; _contentment = 0.05f; _irritation = 0f; _recentBad = 0f; _elapsed = 0f; _blissTime = 0f; _blissAnnounced = false; _sentPurr = -1f; _lastDelta = Vector2.zero; _lifted = false; _liftedUntil = 0f; _handLift = 1f; _warnedAt = -1f; _guideUntil = 4f; _tipUntil = 0f; _nextTip = 0f; ClearHearts(); UiKit.ApplyGameFont(((Component)this).gameObject); _hintKey = "petting.hint"; ((TMP_Text)_hint).text = UiKit.KeepKoreanWords(Lang.Get(_hintKey)); if (TryGetStrokeLine(out var head, out var _)) { _handScreen = head; } else { _handScreen = new Vector2((float)Screen.width * 0.5f, (float)Screen.height * 0.5f); } ((MenuWindow)this).Open(); pig.SendPetting(0f); } public override void Update() { //IL_005e: 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_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0123: 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) //IL_0143: 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) ((MenuWindow)this).Update(); if (!((MenuWindow)this).isOpen) { return; } if ((Object)(object)_pig == (Object)null || !_pig.CanBePetted || (Object)(object)Character.localCharacter == (Object)null || Character.localCharacter.data.dead) { End(null); return; } if (Vector3.Distance(Character.localCharacter.Center, _pig.Center()) > 2.8f) { End(null); return; } if (Time.frameCount > _startFrame + 1 && CharacterInput.action_interact != null && CharacterInput.action_interact.WasPressedThisFrame()) { End(null); return; } if (!TryGetStrokeLine(out var head, out var tail)) { End(null); return; } float num = Mathf.Max(Time.unscaledDeltaTime, 0.0001f); _elapsed += num; Vector2 delta = ReadPointerDelta(num); bool flag = CharacterInput.action_usePrimary != null && CharacterInput.action_usePrimary.IsPressed(); MoveHand(delta, head, tail); Score(delta, flag, head, tail, num); UpdateHand(flag && !_lifted, num); UpdateGuide(head, tail); UpdateHearts(flag && !_lifted, num); float num2 = Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(0.12f, 1f, _contentment)); if (Time.unscaledTime >= _nextNetwork || Mathf.Abs(num2 - _sentPurr) > 0.08f) { _nextNetwork = Time.unscaledTime + 0.2f; _sentPurr = num2; _pig.SendPetting(num2); } CheckMood(num); } private static Vector2 ReadPointerDelta(float dt) { //IL_000f: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_0057: Unknown result type (might be due to invalid IL or missing references) Mouse current = Mouse.current; if (current != null) { Vector2 result = ((InputControl<Vector2>)(object)((Pointer)current).delta).ReadValue(); if (((Vector2)(ref result)).sqrMagnitude > 0f) { return result; } } Gamepad current2 = Gamepad.current; if (current2 != null) { Vector2 val = ((InputControl<Vector2>)(object)current2.rightStick).ReadValue(); if (((Vector2)(ref val)).sqrMagnitude > 0.02f) { return val * ((float)Screen.height * 0.6f * dt); } } return Vector2.zero; } private bool TryGetStrokeLine(out Vector2 head, out Vector2 tail) { //IL_0004: 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_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0013: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_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) head = (tail = default(Vector2)); if ((Object)(object)_pig == (Object)null) { return false; } Camera val = (((Object)(object)MainCamera.instance != (Object)null) ? MainCamera.instance.cam : Camera.main); if ((Object)(object)val == (Object)null) { return false; } Vector3 val2 = val.WorldToScreenPoint(_pig.Visual.BackFront); Vector3 val3 = val.WorldToScreenPoint(_pig.Visual.BackRear); if (val2.z <= 0f || val3.z <= 0f) { return false; } head = Vector2.op_Implicit(val2); tail = Vector2.op_Implicit(val3); return true; } private void MoveHand(Vector2 delta, Vector2 head, Vector2 tail) { //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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) /