Decompiled source of Guinea Pigs and Their Treats v0.9.2
plugins/CavyCrew.GuineaPigsAndTreats.dll
Decompiled a day ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.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 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 UnityEngine; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Rendering; 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.2.0")] [assembly: AssemblyInformationalVersion("0.9.2")] [assembly: AssemblyProduct("CavyCrew.GuineaPigsAndTreats")] [assembly: AssemblyTitle("Guinea Pigs and Their Treats")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.9.2.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; 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 Lookup("pig." + pig.Key + ".name", null); } 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.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)); } private static string Lookup(string key, char? gender) { string current = Current; if (gender.HasValue && gender.Value != 'f' && (TryLookup(current, $"{key}#{gender.Value}", out string text) || TryLookup("en", $"{key}#{gender.Value}", out text))) { return text; } if (TryLookup(current, key, out string text2) || TryLookup("en", key, out text2)) { return text2; } return key; } 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 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)); } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("CavyCrew.GuineaPigsAndTreats", "Guinea Pigs and Their Treats", "0.9.2")] 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<float> PigSize { get; private set; } internal static ConfigEntry<string> RearViewKey { 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.2"; private void Awake() { //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0138: 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."); 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>(); 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, Material> s_byColor = new Dictionary<Color, 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) { //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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) Color key = default(Color); ((Color)(ref key))..ctor(color.r, color.g, color.b, Mathf.Round(smoothness * 100f) / 100f); if (s_byColor.TryGetValue(key, out Material value) && (Object)(object)value != (Object)null) { return value; } Texture2D val = new Texture2D(4, 4, (TextureFormat)4, false) { 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; } 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 } [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[7]; 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 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_0113: 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_0123: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) _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) { _animator = new PigAnimator(_rig); _animator.Play("Idle", 0f); _headBone = _rig.Bone("head"); _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); } private void AnimateModel(float dt) { //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) PigAnimator animator = _animator; string currentName = animator.CurrentName; bool flag = ((currentName == "LieDown_Tucked" || currentName == "Rest_Tucked") ? true : false); bool flag2 = flag; 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) { if (!flag2) { animator.Play("LieDown_Tucked", 0.2f); } else if (currentName == "LieDown_Tucked" && animator.CurrentFinished) { animator.Play("Rest_Tucked", 0.4f); } animator.EyesClosed = ((State == PigState.Sleeping) ? 1f : 0f); animator.Awake = State != PigState.Sleeping; } else { animator.EyesClosed = 0f; animator.Awake = true; if (flag2) { animator.Play("GetUp_Tucked", 0.15f, 1.6f); } else if ((!(currentName == "GetUp_Tucked") || 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 && 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); } } } 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 = 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_0418: Unknown result type (might be due to invalid IL or missing references) //IL_0424: Unknown result type (might be due to invalid IL or missing references) //IL_0430: Unknown result type (might be due to invalid IL or missing references) //IL_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; } } _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 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 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 TextMeshProUGUI _hint; 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; 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_0062: 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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) _canvasRect = root; _heartLayer = UiKit.Rect((Transform)(object)root, "Hearts"); UiKit.Stretch(_heartLayer); _hand = UiKit.Rect((Transform)(object)root, "Hand"); Vector2 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 val3 = UiKit.Panel((Transform)(object)root, "HintBack", new Color(0.12f, 0.08f, 0.05f, 0.55f)); RectTransform rectTransform = ((Graphic)val3).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(820f, 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); } 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_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) _pig = pig; _startFrame = Time.frameCount; _contentment = 0.05f; _irritation = 0f; _recentBad = 0f; _elapsed = 0f; _blissTime = 0f; _blissAnnounced = false; _sentPurr = -1f; _lastDelta = Vector2.zero; ClearHearts(); UiKit.ApplyGameFont(((Component)this).gameObject); ((TMP_Text)_hint).text = Lang.Get("petting.hint"); 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) ((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 touching = CharacterInput.action_usePrimary != null && CharacterInput.action_usePrimary.IsPressed(); MoveHand(delta, head, tail); Score(delta, touching, head, tail, num); UpdateHand(touching); UpdateHearts(touching, 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) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) _handScreen += delta; float num = Mathf.Max(Vector2.Distance(head, tail) * 0.45f, (float)Screen.height * 0.035f); Vector2 val = ClosestOnSegment(_handScreen, head, tail); Vector2 val2 = _handScreen - val; if (((Vector2)(ref val2)).magnitude > num) { _handScreen = val + ((Vector2)(ref val2)).normalized * num; } } private void UpdateHand(bool touching) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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_00a2: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); RectTransformUtility.ScreenPointToLocalPointInRectangle(_canvasRect, _handScreen, (Camera)null, ref val); RectTransform hand = _hand; Vector2 val2 = val; Rect rect = _canvasRect.rect; hand.anchoredPosition = val2 + ((Rect)(ref rect)).size * 0.5f + new Vector2(0f, touching ? 10f : 34f); ((Transform)_hand).localScale = Vector3.one * (touching ? 0.9f : 1f); ((Graphic)_handImage).color = (Color)(touching ? Color.white : new Color(1f, 1f, 1f, 0.75f)); } private static Vector2 ClosestOnSegment(Vector2 p, Vector2 a, Vector2 b) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_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_001d: 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_001f: 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_0038: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) Vector2 val = b - a; float num = ((((Vector2)(ref val)).sqrMagnitude > 0.001f) ? Mathf.Clamp01(Vector2.Dot(p - a, val) / ((Vector2)(ref val)).sqrMagnitude) : 0f); return a + val * num; } private void Score(Vector2 delta, bool touching, Vector2 head, Vector2 tail, float dt) { //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: 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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) PigDefinition def = _pig.Def; float num = (def.MayNip ? 0.06f : 0.03f); if (!touching || ((Vector2)(ref delta)).sqrMagnitude < 0.25f) { _contentment -= num * dt; _irritation = Mathf.Max(0f, _irritation - 0.08f * dt); _recentBad = Mathf.Max(0f, _recentBad - 0.5f * dt); _lastDelta = (touching ? _lastDelta : Vector2.zero); return; } Vector2 val = tail - head; Vector2 val2; if (!(((Vector2)(ref val)).sqrMagnitude > 1f)) { val2 = Vector2.down; } else { val = tail - head; val2 = ((Vector2)(ref val)).normalized; } Vector2 val3 = val2; float num2 = ((Vector2)(ref delta)).magnitude / dt / (float)Screen.height; float num3 = Vector2.Dot(((Vector2)(ref delta)).normalized, val3); float num4 = Mathf.Max(num2 / 0.35f, 0.01f); float num5 = Mathf.Exp((0f - Mathf.Pow(Mathf.Log(num4), 2f)) / 0.72f); float num6 = 1f; if (((Vector2)(ref _lastDelta)).sqrMagnitude > 1f) { num6 = 1f - Mathf.Clamp01(Vector2.Angle(_lastDelta, delta) / 100f); } _lastDelta = delta; float num7 = ((num3 > 0.3f) ? (num3 * num5 * (0.4f + 0.6f * num6)) : 0f); float num8 = 0f; if (num3 < -0.35f) { num8 += (0f - num3) * Mathf.Clamp(num4, 0.5f, 3f); } if (num2 > 1.3f) { num8 += (num2 - 1.3f) * 1.5f; } if (num6 < 0.3f && num2 > 0.35f) { num8 += 0.4f; } _contentment += num7 * def.PettingGain * 0.2f * dt; _contentment -= num8 * 0.12f * dt; float num9 = (def.LearnsTrust ? _pig.Trust : 0f); _irritation += num8 * def.PettingSensitivity * 0.22f * (1f - 0.5f * num9) * dt; _recentBad = Mathf.Clamp01(_recentBad + num8 * dt * 0.8f); _contentment = Mathf.Clamp01(_contentment); _irritation = Mathf.Max(0f, _irritation); } private void CheckMood(float dt) { PigDefinition def = _pig.Def; float num = (def.LearnsTrust ? _pig.Trust : 0f); if (def.PettingPatience > 0f && _elapsed > def.PettingPatience * (1f + 2f * num)) { _irritation += 0.07f * dt; } if (_contentment > 0.92f) { _blissTime += dt; if (_blissTime > 3f && !_blissAnnounced) { _blissAnnounced = true; PigSummoner.ShowMessage(Lang.ForPig(def, "petting.blissful")); } } else { _blissTime = 0f; } if (!(_irritation < 1f)) { if (def.MayNip && _recentBad > 0.25f + 0.5f * num) { PigSummoner.ShowMessage(Lang.ForPig(def, "petting.nipped")); End(GuineaPig.Reaction.Nipped); } else { PigSummoner.ShowMessage(Lang.ForPig(def, "petting.had_enough")); End(GuineaPig.Reaction.HadEnough); } } } private void UpdateHearts(bool touching, float dt) { //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) if (touching && _contentment > 0.65f && Time.unscaledTime >= _nextHeart) { _nextHeart = Time.unscaledTime + Mathf.Lerp(0.9f, 0.35f, Mathf.InverseLerp(0.65f, 1f, _contentment)); SpawnHeart(); } for (int num = _hearts.Count - 1; num >= 0; num--) { (RectTransform rect, Image image, float born) tuple = _hearts[num]; RectTransform item = tuple.rect; Image item2 = tuple.image; float item3 = tuple.born; float num2 = Time.unscaledTime - item3; if (num2 > 1.4f) { Object.Destroy((Object)(object)((Component)item).gameObject); _hearts.RemoveAt(num); } else { item.anchoredPosition += new Vector2(Mathf.Sin(num2 * 5f + item3) * 20f * dt, 70f * dt); ((Graphic)item2).color = new Color(1f, 1f, 1f, 1f - num2 / 1.4f); ((Transform)item).localScale = Vector3.one * Mathf.Lerp(0.6f, 1.1f, Mathf.Min(num2 * 3f, 1f)); } } } private void SpawnHeart() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) RectTransform val = UiKit.Rect((Transform)(object)_heartLayer, "Heart"); Vector2 anchorMin = (val.anchorMax = Vector2.zero); val.anchorMin = anchorMin; val.sizeDelta = new Vector2(34f, 34f); val.anchoredPosition = _hand.anchoredPosition + new Vector2(Random.Range(-30f, 30f), 30f); Image val2 = ((Component)val).gameObject.AddComponent<Image>(); val2.sprite = UiKit.HeartSprite; ((Graphic)val2).raycastTarget = false; _hearts.Add((val, val2, Time.unscaledTime)); } private void ClearHearts() { foreach (var heart in _hearts) { RectTransform item = heart.rect; if ((Object)(object)item != (Object)null) { Object.Destroy((Object)(object)((Component)item).gameObject); } } _hearts.Clear(); } private void End(GuineaPig.Reaction? reaction) { GuineaPig pig = _pig; _pig = null; s_lastEnded = Time.time; ClearHearts(); if (((MenuWindow)this).isOpen) { ((MenuWindow)this).Close(); } if ((Object)(object)pig != (Object)null) { pig.SendPetting(0f, active: false); if (reaction.HasValue) { pig.React(reaction.Value); } } } public override void OnClose() { if ((Object)(object)_pig != (Object)null) { GuineaPig pig = _pig; _pig = null; s_lastEnded = Time.time; pig.SendPetting(0f, active: false); } ClearHearts(); } } internal sealed class PigMenuWindow : MenuWindow { private sealed class Card { public PigDefinition Def; public TextMeshProUGUI Status; public TextMeshProUGUI ButtonLabel; public Button Button; public RectTransform Arrow; public GameObject Bio; } private const float CardWidth = 720f; private readonly List<Card> _cards = new List<Card>(); private RectTransform _root; private RectTransform? _panel; private TextMeshProUGUI? _warning; private Selectable? _firstButton; public static PigMenuWindow? Instance { get; private set; } public override bool openOnStart => false; public override bool closeOnPause => true; public override bool closeOnUICancel => true; public override bool blocksPlayerInput => true; public override bool showCursorWhileOpen => true; public override Selectable objectToSelectOnOpen => _firstButton; public static void Toggle() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown if ((Object)(object)Instance == (Object)null) { Canvas val = UiKit.CreateCanvas("GuineaPigMenu", 600); Instance = ((Component)val).gameObject.AddComponent<PigMenuWindow>(); Instance._root = (RectTransform)((Component)val).transform; } if (((MenuWindow)Instance).isOpen) { ((MenuWindow)Instance).Close(); } else { ((MenuWindow)Instance).Open(); } } public override void OnOpen() { Rebuild(); } public override void Update() { ((MenuWindow)this).Update(); if (((MenuWindow)this).isOpen && Time.frameCount % 15 == 0) { Refresh(); } } private void Rebuild() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Expected O, but got Unknown //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Expected O, but got Unknown //IL_022d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_panel != (Object)null) { Object.Destroy((Object)(object)((Component)_panel).gameObject); } _cards.Clear(); _firstButton = null; Image val = UiKit.Panel((Transform)(object)_root, "Panel", UiKit.Paper); _panel = ((Graphic)val).rectTransform; RectTransform? panel = _panel; RectTransform? panel2 = _panel; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0.5f, 0.5f); panel2.anchorMax = val2; panel.anchorMin = val2; _panel.pivot = new Vector2(0.5f, 0.5f); _panel.anchoredPosition = Vector2.zero; VerticalLayoutGroup val3 = ((Component)val).gameObject.AddComponent<VerticalLayoutGroup>(); ((LayoutGroup)val3).padding = new RectOffset(32, 32, 24, 24); ((HorizontalOrVerticalLayoutGroup)val3).spacing = 14f; ((LayoutGroup)val3).childAlignment = (TextAnchor)1; ((HorizontalOrVerticalLayoutGroup)val3).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)val3).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)val3).childForceExpandHeight = false; ((HorizontalOrVerticalLayoutGroup)val3).childForceExpandWidth = false; ContentSizeFitter val4 = ((Component)val).gameObject.AddComponent<ContentSizeFitter>(); val4.horizontalFit = (FitMode)2; val4.verticalFit = (FitMode)2; BuildHeader((Transform)(object)_panel); PigDefinition[] all = PigDefinitions.All; foreach (PigDefinition def in all) { BuildCard((Transform)(object)_panel, def); } _warning = UiKit.Text((Transform)(object)_panel, "", 22f, new Color(0.7f, 0.15f, 0.1f), (TextAlignmentOptions)514); ((TMP_Text)_warning).textWrappingMode = (TextWrappingModes)1; ((Component)_warning).gameObject.AddComponent<LayoutElement>().preferredWidth = 720f; RectTransform parent = Row((Transform)(object)_panel, "Bottom", 18f, (TextAnchor)4); UiKit.Button((Transform)(object)parent, Lang.Get("menu.close"), 220f, new UnityAction(base.Close), out TextMeshProUGUI _); TextMeshProUGUI val5 = UiKit.Text((Transform)(object)_panel, Lang.Get("menu.hint", ("key", Plugin.SummonKey.Value.ToUpperInvariant())), 20f, new Color(0.45f, 0.35f, 0.25f), (TextAlignmentOptions)514); ((Component)val5).gameObject.AddComponent<LayoutElement>().preferredWidth = 720f; UiKit.ApplyGameFont(((Component)this).gameObject); Refresh(); if ((Object)(object)_firstButton != (Object)null) { UIInputHandler.SetSelectedObject(((Component)_firstButton).gameObject); } } private void BuildHeader(Transform parent) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown RectTransform val = Row(parent, "Header", 12f, (TextAnchor)4); ((Component)val).gameObject.AddComponent<LayoutElement>().preferredWidth = 720f; TextMeshProUGUI val2 = UiKit.Text((Transform)(object)val, Lang.Get("menu.title"), 46f, UiKit.Ink, (TextAlignmentOptions)4097); ((TMP_Text)val2).characterSpacing = 2f; ((Component)val2).gameObject.AddComponent<LayoutElement>().flexibleWidth = 1f; TextMeshProUGUI text; Button val3 = UiKit.Button((Transform)(object)val, Lang.MenuLanguageLabel(), 300f, new UnityAction(OnLanguageButton), out text); ((TMP_Text)text).fontSize = 22f; ((Component)val3).GetComponent<LayoutElement>().preferredHeight = 44f; } private void BuildCard(Transform parent, PigDefinition def) { //IL_003e: 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_0068: Expected O, but got Unknown //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Expected O, but got Unknown //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Expected O, but got Unknown //IL_0341: Unknown result type (might be due to invalid IL or missing references) Image val = UiKit.Panel(parent, "Card_" + def.Key, new Color(1f, 0.97f, 0.9f, 1f)); VerticalLayoutGroup val2 = ((Component)val).gameObject.AddComponent<VerticalLayoutGroup>(); ((LayoutGroup)val2).padding = new RectOffset(16, 16, 14, 14); ((HorizontalOrVerticalLayoutGroup)val2).spacing = 8f; ((HorizontalOrVerticalLayoutGroup)val2).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)val2).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)val2).childForceExpandHeight = false; ((Component)val).gameObject.AddComponent<LayoutElement>().preferredWidth = 720f; RectTransform parent2 = Row(((Component)val).transform, "Top", 18f, (TextAnchor)3); RectTransform val3 = UiKit.Rect((Transform)(object)parent2, "Portrait"); LayoutElement val4 = ((Component)val3).gameObject.AddComponent<LayoutElement>(); float minWidth = (val4.preferredWidth = 112f); val4.minWidth = minWidth; minWidth = (val4.preferredHeight = 112f); val4.minHeight = minWidth; val4.flexibleWidth = 0f; Texture2D val5 = PigAssets.Portrait(def); if ((Object)(object)val5 != (Object)null) { RawImage val6 = ((Component)val3).gameObject.AddComponent<RawImage>(); val6.texture = (Texture)(object)val5; ((Graphic)val6).raycastTarget = false; } else { Image val7 = ((Component)val3).gameObject.AddComponent<Image>(); val7.sprite = UiKit.RoundedSprite; val7.type = (Type)1; ((Graphic)val7).color = def.Patch; TextMeshProUGUI val8 = UiKit.Text((Transform)(object)val3, def.DisplayName.Substring(0, 1), 56f, Color.white, (TextAlignmentOptions)514); UiKit.Stretch(((TMP_Text)val8).rectTransform); } RectTransform val9 = UiKit.Rect((Transform)(object)parent2, "Info"); VerticalLayoutGroup val10 = ((Component)val9).gameObject.AddComponent<VerticalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)val10).spacing = 2f; ((HorizontalOrVerticalLayoutGroup)val10).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)val10).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)val10).childForceExpandHeight = false; LayoutElement val11 = ((Component)val9).gameObject.AddComponent<LayoutElement>(); val11.preferredWidth = 330f; val11.flexibleWidth = 1f; RectTransform parent3 = Row((Transform)(object)val9, "NameRow", 14f, (TextAnchor)6); UiKit.Text((Transform)(object)parent3, def.DisplayName, 38f, UiKit.Ink, (TextAlignmentOptions)1025); TextMeshProUGUI status = UiKit.Text((Transform)(object)parent3, "", 24f, UiKit.Accent, (TextAlignmentOptions)1025); TextMeshProUGUI val12 = UiKit.Text((Transform)(object)val9, Lang.Get("pig." + def.Key + ".traits"), 21f, new Color(0.4f, 0.3f, 0.22f), (TextAlignmentOptions)257); ((TMP_Text)val12).textWrappingMode = (TextWrappingModes)1; UiKit.ExpandButton((Transform)(object)val9, Lang.Get("menu.personality"), 21f, (UnityAction)delegate { ToggleBio(def); }, out RectTransform arrow); TextMeshProUGUI text; Button val13 = UiKit.Button((Transform)(object)parent2, "", 210f, (UnityAction)delegate { OnPigButton(def); }, out text); if (_firstButton == null) { _firstButton = (Selectable?)(object)val13; } TextMeshProUGUI val14 = UiKit.Text(((Component)val).transform, Lang.Get("pig." + def.Key + ".bio"), 21f, UiKit.Ink, (TextAlignmentOptions)257); ((TMP_Text)val14).textWrappingMode = (TextWrappingModes)1; ((Component)val14).gameObject.AddComponent<LayoutElement>().preferredWidth = 688f; ((Component)val14).gameObject.SetActive(false); _cards.Add(new Card { Def = def, Status = status, ButtonLabel = text, Button = val13, Arrow = arrow, Bio = ((Component)val14).gameObject }); } private static RectTransform Row(Transform parent, string name, float spacing, TextAnchor alignment) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) RectTransform val = UiKit.Rect(parent, name); HorizontalLayoutGroup val2 = ((Component)val).gameObject.AddComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)val2).spacing = spacing; ((LayoutGroup)val2).childAlignment = alignment; ((HorizontalOrVerticalLayoutGroup)val2).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)val2).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)val2).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)val2).childForceExpandHeight = false; return val; } private void OnPigButton(PigDefinition def) { PigSummoner.Instance?.SetWanted(def, !PigSummoner.IsWanted(def)); Refresh(); } private void ToggleBio(PigDefinition def) { foreach (Card card in _cards) { if (card.Def == def) { card.Bio.SetActive(!card.Bio.activeSelf); } } Refresh(); } private void OnLanguageButton() { Lang.CycleOverride(); Rebuild(); } private void Refresh() { //IL_00dc: Unknown result type (might be due to invalid IL or missing references) foreach (Card card in _cards) { bool flag = PigSummoner.IsWanted(card.Def); ((TMP_Text)card.Status).text = (flag ? Lang.Get("menu.with_you") : Lang.Get("menu.at_home")); ((TMP_Text)card.ButtonLabel).text = (flag ? Lang.Get("menu.send_home") : Lang.Get("menu.call")); bool flag2 = PigSummoner.CanCall(card.Def); ((Selectable)card.Button).interactable = flag2; ((TMP_Text)card.ButtonLabel).alpha = (flag2 ? 1f : 0.4f); ((Transform)card.Arrow).localRotation = Quaternion.Euler(0f, 0f, card.Bio.activeSelf ? (-90f) : 0f); } if ((Object)(object)_warning != (Object)null) { string text = PigSummoner.MissingModWarning(); if (string.IsNullOrEmpty(text) && _cards.Exists((Card c) => !PigSummoner.CanCall(c.Def))) { text = Lang.Get("menu.max_pigs", ("max", 2)); } ((TMP_Text)_warning).text = text; ((Component)_warning).gameObject.SetActive(!string.IsNullOrEmpty(text)); } } } internal sealed class RidingHud : MonoBehaviour { private const float IconSize = 62f; private RectTransform _row; private readonly Dictionary<byte, RectTransform> _icons = new Dictionary<byte, RectTransform>(); private CanvasGroup _group; private void Start() { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) Canvas val = UiKit.CreateCanvas("GuineaPigRidingHud", 400); ((Component)val).transform.SetParent(((Component)this).transform, false); _group = ((Component)val).gameObject.AddComponent<CanvasGroup>(); _group.blocksRaycasts = false; _group.interactable = false; _row = UiKit.Rect(((Component)val).transform, "Row"); RectTransform row = _row; RectTransform row2 = _row; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0f, 0f); row2.anchorMax = val2; row.anchorMin = val2; _row.pivot = new Vector2(0f, 0f); _row.anchoredPosition = new Vector2(720f, 42f); HorizontalLayoutGroup val3 = ((Component)_row).gameObject.AddComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)val3).spacing = 6f; ((HorizontalOrVerticalLayoutGroup)val3).childControlWidth = false; ((HorizontalOrVerticalLayoutGroup)val3).childControlHeight = false; ((Component)_row).gameObject.AddComponent<ContentSizeFitter>().horizontalFit = (FitMode)2; } private void LateUpdate() { //IL_00e6: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_row == (Object)null) { return; } bool flag = false; float time = Time.time; int num = 0; PigDefinition[] all = PigDefinitions.All; foreach (PigDefinition pigDefinition in all) { bool flag2 = false; foreach (GuineaPig item in PigSummoner.MyPigs()) { if (item.Def == pigDefinition && item.State == PigState.InBackpack) { flag2 = true; } } RectTransform icon = GetIcon(pigDefinition); if (!((Object)(object)icon == (Object)null)) { if (((Component)icon).gameObject.activeSelf != flag2) { ((Component)icon).gameObject.SetActive(flag2); } if (flag2) { flag = true; float num2 = Mathf.Abs(Mathf.Sin(time * 3f + (float)num * 1.3f)) * 4f; ((Transform)icon).GetChild(0).localPosition = new Vector3(0f, num2, 0f); } num++; } } bool flag3 = (Object)(object)GUIManager.instance != (Object)null && GUIManager.instance.windowBlockingInput; bool flag4 = flag && (Object)(object)Character.localCharacter != (Object)null && !flag3; _group.alpha = Mathf.MoveTowards(_group.alpha, flag4 ? 0.95f : 0f, Time.deltaTime * 4f); } private RectTransform? GetIcon(PigDefinition def) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) if (_icons.TryGetValue(def.Id, out RectTransform value)) { return value; } Texture2D val = PigAssets.Portrait(def); RectTransform val2 = UiKit.Rect((Transform)(object)_row, "Riding_" + def.Key); val2.sizeDelta = new Vector2(62f, 62f); RectTransform val3 = UiKit.Rect((Transform)(object)val2, "Portrait"); val3.sizeDelta = new Vector2(62f, 62f); if ((Object)(object)val != (Object)null) { RawImage val4 = ((Component)val3).gameObject.AddComponent<RawImage>(); val4.texture = (Texture)(object)val; ((Graphic)val4).raycastTarget = false; } else { Image val5 = ((Component)val3).gameObject.AddComponent<Image>(); val5.sprite = UiKit.RoundedSprite; ((Graphic)val5).color = def.Patch; ((Graphic)val5).raycastTarget = false; } ((Component)val2).gameObject.SetActive(false); _icons[def.Id] = val2; return val2; } } internal static class UiKit { public static readonly Color Paper = new Color(0.96f, 0.91f, 0.8f, 0.97f); public static readonly Color PaperDark = new Color(0.87f, 0.78f, 0.62f, 1f); public static readonly Color Ink = new Color(0.24f, 0.16f, 0.1f, 1f); public static readonly Color Accent = new Color(0.85f, 0.48f, 0.2f, 1f); private static Sprite? s_rounded; private static Sprite? s_paw; private static Sprite? s_heart; private static Sprite? s_triangle; public static TMP_FontAsset? GameFont { get { if (!((Object)(object)GUIManager.instance != (Object)null) || !((Object)(object)GUIManager.instance.interactPromptText != (Object)null)) { return null; } return ((TMP_Text)GUIManager.instance.interactPromptText).font; } } public static Sprite RoundedSprite => s_rounded ?? (s_rounded = MakeSprite(64, delegate(int x, int y) { //IL_0070: Unknown result type (might be due to invalid IL or missing references) float num = 18f; float num2 = Mathf.Max(Mathf.Abs((float)x - 31.5f) - (31.5f - num), 0f); float num3 = Mathf.Max(Mathf.Abs((float)y - 31.5f) - (31.5f - num), 0f); float num4 = Mathf.Sqrt(num2 * num2 + num3 * num3) - num; return new Color(1f, 1f, 1f, Mathf.Clamp01(0.5f - num4)); }, new Vector4(22f, 22f, 22f, 22f))); public static Sprite PawSprite => s_paw ?? (s_paw = MakeSprite(96, delegate(int x, int y) { //IL_00f9: 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_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: 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_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) float inside = 0f; float outline = 0f; Blob(48f, 36f, 24f, 20f); Blob(22f, 62f, 9f, 11f); Blob(38f, 72f, 9f, 11f); Blob(58f, 72f, 9f, 11f); Blob(74f, 62f, 9f, 11f); Color val = default(Color); ((Color)(ref val))..ctor(1f, 0.93f, 0.85f); Color val2 = default(Color); ((Color)(ref val2))..ctor(0.3f, 0.18f, 0.12f); Color result; if (!(inside > 0f)) { result = val2; result.a = outline; return result; } result = Color.Lerp(val2, val, Mathf.Clamp01(inside * 3f)); result.a = 1f; return result; void Blob(float cx, float cy, float rx, float ry) { float num = Mathf.Sqrt(Sq(((float)x - cx) / rx) + Sq(((float)y - cy) / ry)); inside = Mathf.Max(inside, Mathf.Clamp01((1f - num) * rx)); outline = Mathf.Max(outline, Mathf.Clamp01((1.18f - num) * rx * 0.85f)); } })); public static Sprite HeartSprite => s_heart ?? (s_heart = MakeSprite(64, delegate(int x, int y) { //IL_0070: Unknown result type (might be due to invalid IL or missing references) float num = ((float)x - 31.5f) / 26f; float num2 = ((float)y - 28f) / 26f; float num3 = Mathf.Pow(num * num + num2 * num2 - 1f, 3f) - num * num * num2 * num2 * num2; return new Color(0.93f, 0.3f, 0.38f, (num3 <= 0f) ? 1f : Mathf.Clamp01(1f - num3 * 40f)); })); public static Sprite TriangleSprite => s_triangle ?? (s_triangle = MakeSprite(48, delegate(int x, int y) { //IL_0091: Unknown result type (might be due to invalid IL or missing references) float num = (float)x + 0.5f; float num2 = (float)y + 0.5f; float num3 = Mathf.Sqrt(1224f); float num4 = num - 10f; float num5 = (0f - (18f * (num - 10f) + 30f * (num2 - 42f))) / num3; float num6 = (30f * (num2 - 6f) - 18f * (num - 10f)) / num3; float num7 = Mathf.Min(num4, Mathf.Min(num5, num6)); return new Color(1f, 1f, 1f, Mathf.Clamp01(num7 + 0.5f)); })); public static Canvas CreateCanvas(string name, int sortingOrder) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) }); Object.DontDestroyOnLoad((Object)(object)val); Canvas val2 = val.AddComponent<Canvas>(); val2.renderMode = (RenderMode)0; val2.sortingOrder = sortingOrder; CanvasScaler val3 = val.AddComponent<CanvasScaler>(); val3.uiScaleMode = (ScaleMode)1; val3.referenceResolution = new Vector2(1920f, 1080f); val3.matchWidthOrHeight = 0.5f; val.AddComponent<GraphicRaycaster>(); return val2; } public static RectTransform Rect(Transform parent, string name) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parent, false); return (RectTransform)val.transform; } public static Image Panel(Transform parent, string name, Color color) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) RectTransform val = Rect(parent, name); Image val2 = ((Component)val).gameObject.AddComponent<Image>(); val2.sprite = RoundedSprite; val2.type = (Type)1; ((Graphic)val2).color = color; return val2; } public static TextMeshProUGUI Text(Transform parent, string text, float size, Color color, TextAlignmentOptions alignment) { //IL_003d: 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) RectTransform val = Rect(parent, "Text"); TextMeshProUGUI val2 = ((Component)val).gameObject.AddComponent<TextMeshProUGUI>(); TMP_FontAsset gameFont = GameFont; if ((Object)(object)gameFont != (Object)null) { ((TMP_Text)val2).font = gameFont; } ((TMP_Text)val2).text = text; ((TMP_Text)val2).fontSize = size; ((Graphic)val2).color = color; ((TMP_Text)val2).alignment = alignment; ((TMP_Text)val2).textWrappingMode = (TextWrappingModes)0; ((Graphic)val2).raycastTarget = false; return val2; } public static Button Button(Transform parent, string label, float width, UnityAction onClick, out TextMeshProUGUI text) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) Image val = Panel(parent, "Button", PaperDark); LayoutElement val2 = ((Component)val).gameObject.AddComponent<LayoutElement>(); float minWidth = (val2.preferredWidth = width); val2.minWidth = minWidth; val2.flexibleWidth = 0f; val2.preferredHeight = 52f; Button val3 = ((Component)val).gameObject.AddComponent<Button>(); ColorBlock colors = ((Selectable)val3).colors; ((ColorBlock)(ref colors)).normalColor = Color.white; ((ColorBlock)(ref colors)).highlightedColor = new Color(1f, 0.93f, 0.8f); ((ColorBlock)(ref colors)).selectedColor = new Color(1f, 0.93f, 0.8f); ((ColorBlock)(ref colors)).pressedColor = new Color(0.85f, 0.75f, 0.6f); ((Selectable)val3).colors = colors; ((UnityEvent)val3.onClick).AddListener(onClick); text = Text(((Component)val).transform, label, 28f, Ink, (TextAlignmentOptions)514); Stretch(((TMP_Text)text).rectTransform); return val3; } public static Button ExpandButton(Transform parent, string label, float size, UnityAction onClick, out RectTransform arrow) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) RectTransform val = Rect(parent, "ExpandButton"); Image val2 = ((Component)val).gameObject.AddComponent<Image>(); ((Graphic)val2).color = new Color(1f, 1f, 1f, 0f); HorizontalLayoutGroup val3 = ((Component)val).gameObject.AddComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)val3).spacing = 8f; ((LayoutGroup)val3).childAlignment = (TextAnchor)3; ((HorizontalOrVerticalLayoutGroup)val3).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)val3).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)val3).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)val3).childForceExpandHeight = false; ((Component)val).gameObject.AddComponent<LayoutElement>().preferredHeight = size + 8f; Button val4 = ((Component)val).gameObject.AddComponent<Button>(); ColorBlock colors = ((Selectable)val4).colors; ((ColorBlock)(ref colors)).normalColor = Color.white; ((ColorBlock)(ref colors)).highlightedColor = new Color(1f, 1f, 1f, 0.8f); ((ColorBlock)(ref colors)).pressedColor = new Color(1f, 1f, 1f, 0.6f); ((Selectable)val4).colors = colors; ((Selectable)val4).targetGraphic = (Graphic)(object)val2; ((UnityEvent)val4.onClick).AddListener(onClick); RectTransform val5 = Rect((Transform)(object)val, "ArrowSlot"); LayoutElement val6 = ((Component)val5).gameObject.AddComponent<LayoutElement>(); float minWidth = (val6.preferredWidth = size * 0.75f); val6.minWidth = minWidth; minWidth = (val6.preferredHeight = size * 0.75f); val6.minHeight = minWidth; arrow = Rect((Transform)(object)val5, "Arrow"); Stretch(arrow); Image val7 = ((Component)arrow).gameObject.AddComponent<Image>(); val7.sprite = TriangleSprite; ((Graphic)val7).color = Accent; ((Graphic)val7).raycastTarget = false; Text((Transform)(object)val, label, size, Accent, (TextAlignmentOptions)4097); return val4; } public static void Stretch(RectTransform rect) { //IL_0001: 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_0022: Unknown result type (might be due to invalid IL or missing references) rect.anchorMin = Vector2.zero; rect.anchorMax = Vector2.one; rect.offsetMin = Vector2.zero; rect.offsetMax = Vector2.zero; } public static void ApplyGameFont(GameObject root) { TMP_FontAsset gameFont = GameFont; if ((Object)(object)gameFont == (Object)null) { return; } TextMeshProUGUI[] componentsInChildren = root.GetComponentsInChildren<TextMeshProUGUI>(true); foreach (TextMeshProUGUI val in componentsInChildren) { if ((Object)(object)((TMP_Text)val).font != (Object)(object)gameFont) { ((TMP_Text)val).font = gameFont; } } } private static float Sq(float v) { return v * v; } private static Sprite MakeSprite(int size, Func<int, int, Color> pixel, Vector4 border = default(Vector4)) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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) Texture2D val = new Texture2D(size, size, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1 }; Color[] array = (Color[])(object)new Color[size * size]; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { array[i * size + j] = pixel(j, i); } } val.SetPixels(array); val.Apply(); return Sprite.Create(val, new Rect(0f, 0f, (float)size, (float)size), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, border); } } } namespace GuineaPigsAndTreats.Treats { internal enum TreatKind : byte { Iceberg, Cucumber, Zucchini } internal readonly struct TreatStats { public readonly float Hunger; public readonly float Stamina; public readonly float Cooling; public readonly float Poison; public readonly float PoisonOverTime; public TreatStats(float hunger, float stamina, float cooling, float poison, float poisonOverTime) { Hunger = hunger; Stamina = stamina; Cooling = cooling; Poison = poison; PoisonOverTime = poisonOverTime; } } internal sealed class TreatDefinition { private const float CucumberCooling = 0.3f; public const float RawZucchiniPoisonPerSecond = 0.01f; public const float RawZucchiniPoisonSeconds = 6f; public static readonly TreatDefinition Iceberg = new TreatDefinition { Kind = TreatKind.Iceberg, Key = "iceberg", Folder = "Iceberg", Pools = (SpawnPool)24, Rarity = (Rarity)3 }; public static readonly TreatDefinition Cucumber = new TreatDefinition { Kind = TreatKind.Cucumber, Key = "cucumber", Folder = "Cucumber", Pools = (SpawnPool)24, Rarity = (Rarity)3 }; public static readonly TreatDefinition Zucchini = new TreatDefinition { Kind = TreatKind.Zucchini, Key = "zucchini", Folder = "Zucchini", Pools = (SpawnPool)24, Rarity = (Rarity)3 }; public static readonly TreatDefinition[] All = new TreatDefinition[3] { Iceberg, Cucumber, Zucchini }; public TreatKind Kind { get; init; } public string Key { get; init; } = ""; public string Folder { get; init; } = ""; public SpawnPool Pools { get; init; } public Rarity Rarity { get; init; } public float ModelScale { get; init; } = 1f; public string ItemName => "GuineaPigs " + Folder; public TreatStats Stats(int cooked) { float poison = ((cooked >= 4) ? (0.1f * (float)(cooked - 3)) : 0f); switch (Kind) { case TreatKind.Iceberg: { TreatStats result; switch (cooked) { case 0: result = new TreatStats(0.1f, 0f, 0f, 0f, 0f); break; case 1: case 2: result = new TreatStats(0.15f, 0f, 0f, 0f, 0f); break; case 3: result = new TreatStats(0.06f, 0f, 0f, 0f, 0f); break; default: result = new TreatStats(0.03f, 0f, 0f, poison, 0f); break; } return result; } case TreatKind.Cucumber: { TreatStats result; switch (cooked) { case 0: result = new TreatStats(0.08f, 0.1f, 0.3f, 0f, 0f); break; case 1: case 2: result = new TreatStats(0.1f, 0.1f, 0f, 0f, 0f); break; case 3: result = new TreatStats(0.04f, 0f, 0f, 0f, 0f); break; default: result = new TreatStats(0.02f, 0f, 0f, poison, 0f); break; } return result; } default: { TreatStats result; switch (cooked) { case 0: result = new TreatStats(0.08f, 0.05f, 0f, 0f, 0.06f); break; case 1: case 2: result = new TreatStats(0.5f, 0.05f, 0f, 0f, 0f); break; case 3: result = new TreatStats(0.2f, 0f, 0f, 0f, 0f); break; default: result = new TreatStats(0.08f, 0f, 0f, poison, 0f); break; } return result; } } } } internal static class TreatItems { [HarmonyPatch(typeof(LootData), "GetRandomItem")] private static class SpawnPatch { [HarmonyPostfix] private static void Postfix(ref GameObject __result) { Item val = default(Item); if (!((Object)(object)__result == (Object)null) && !((Object)(object)s_source == (Object)null) && __result.TryGetComponent<Item>(ref val) && IsTreat(val) && !PigNetwork.EveryoneHasSameMod()) { Plugin.Verbose("Treats: " + ((Object)val).name + " replaced by " + ((Object)s_source).name + " (someone in the lobby lacks the mod)"); __result = ((Compon