using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using FishNet.Managing; using FishNet.Managing.Object; using FishNet.Object; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using TMPro; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("MoreFish")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.2.0")] [assembly: AssemblyInformationalVersion("1.0.2")] [assembly: AssemblyProduct("MoreFish")] [assembly: AssemblyTitle("MoreFish")] [assembly: AssemblyVersion("1.0.2.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace MoreFish { internal sealed class Ability { internal string Name; internal string Blurb; internal float Heal = 1f; internal float Fullness = 1f; internal float Hp = 1f; internal bool PoisonOnEat; internal bool FireOnEat; internal float Prestige; internal int ShootDamage; internal float ShootInterval = 2.5f; internal float ShootRange = 18f; internal string WeaponName = "pistol"; internal float Accuracy = 0.75f; internal int BurstCount = 1; internal float BurstSpacing = 0.09f; internal bool Aggressive; internal float ChaseForce = 6f; internal float LungeDuration = 0.28f; internal float LungeMinDelay = 1.2f; internal float LungeMaxDelay = 3.2f; internal float KeepDistance = 2.2f; internal bool IsArmed => ShootDamage > 0; internal float Worth => 1f + 1.1f * (Heal - 1f) + 0.7f * (Fullness - 1f) + 0.9f * (Hp - 1f) + (PoisonOnEat ? 1.2f : 0f) + (FireOnEat ? 1.6f : 0f) + (IsArmed ? (1f + (float)(ShootDamage * BurstCount) * Accuracy * 0.14f + (Aggressive ? 0.5f : 0f)) : 0f) + Prestige; } internal static class AbilityCatalog { private static readonly Dictionary ByKey = new Dictionary { ["albino"] = new Ability { Name = "Tender", Blurb = "Fills you up", Fullness = 1.6f, Prestige = 0.3f }, ["melanistic"] = new Ability { Name = "Lean", Blurb = "Restores health", Heal = 1.5f, Prestige = 0.3f }, ["ember"] = new Ability { Name = "Warming", Blurb = "Hearty meal", Heal = 1.3f, Fullness = 1.3f, Prestige = 0.3f }, ["tidal"] = new Ability { Name = "Refreshing", Blurb = "Very filling", Fullness = 1.8f, Prestige = 0.3f }, ["coral"] = new Ability { Name = "Rich", Blurb = "Restores health", Heal = 1.6f, Fullness = 1.1f, Prestige = 0.3f }, ["tiger"] = new Ability { Name = "Gamey", Blurb = "Puts up a fight", Heal = 1.2f, Fullness = 1.2f, Hp = 1.6f, Prestige = 0.6f }, ["spotted"] = new Ability { Name = "Plump", Blurb = "A whole meal", Fullness = 2.2f, Prestige = 0.5f }, ["marbled"] = new Ability { Name = "Prime Cut", Blurb = "The best eating in the sea", Heal = 1.8f, Fullness = 1.8f, Prestige = 0.6f }, ["camo"] = new Ability { Name = "Wily", Blurb = "Hard to put down", Heal = 1.1f, Fullness = 1.1f, Hp = 1.8f, Prestige = 0.6f }, ["harlequin"] = new Ability { Name = "Curious", Blurb = "Collectors pay for these", Heal = 1.2f, Fullness = 1.2f, Hp = 1.2f, Prestige = 1.2f }, ["hazard"] = new Ability { Name = "Toxic", Blurb = "Do not eat. Sells well.", Heal = 0.5f, Fullness = 0.8f, PoisonOnEat = true, Prestige = 1.4f }, ["polka"] = new Ability { Name = "Bubbly", Blurb = "Surprisingly good", Heal = 1.2f, Fullness = 1.4f, Prestige = 0.8f }, ["golden"] = new Ability { Name = "Priceless", Blurb = "Worth a fortune", Hp = 1.3f, Prestige = 3.2f }, ["chrome"] = new Ability { Name = "Armoured", Blurb = "Takes a beating", Hp = 2.5f, Prestige = 2f }, ["verdant"] = new Ability { Name = "Medicinal", Blurb = "Heals you right up", Heal = 2.6f, Fullness = 1.2f, Prestige = 1.2f }, ["ruby"] = new Ability { Name = "Vital", Blurb = "Restores a lot of health", Heal = 2.2f, Fullness = 1.4f, Prestige = 1.4f }, ["glacial"] = new Ability { Name = "Preserved", Blurb = "Keeps you going for hours", Heal = 1.4f, Fullness = 2.4f, Hp = 1.2f, Prestige = 1.2f }, ["molten"] = new Ability { Name = "Scalding", Blurb = "Eating this will burn you", Heal = 1.6f, Fullness = 1.2f, Hp = 1.4f, FireOnEat = true, Prestige = 2.2f }, ["spectral"] = new Ability { Name = "Haunting", Blurb = "Something is wrong with it", Heal = 0.6f, Fullness = 0.6f, PoisonOnEat = true, Prestige = 3f }, ["prismatic"] = new Ability { Name = "Fabled", Blurb = "The catch of a lifetime", Heal = 3f, Fullness = 2f, Hp = 1.5f, Prestige = 4.5f }, ["armed"] = new Ability { Name = "Armed", Blurb = "It has a pistol. It will use it.", Heal = 1.2f, Fullness = 1.2f, Hp = 1.6f, Prestige = 1.5f, ShootDamage = 6, ShootInterval = 2.6f, ShootRange = 16f, WeaponName = "pistol", Accuracy = 0.7f, BurstCount = 1, Aggressive = true, ChaseForce = 5f, LungeMinDelay = 1.6f, LungeMaxDelay = 3.6f, KeepDistance = 2.4f }, ["outlaw"] = new Ability { Name = "Outlaw", Blurb = "Wanted in several islands", Heal = 1.4f, Fullness = 1.3f, Hp = 2.2f, Prestige = 3f, ShootDamage = 5, ShootInterval = 2f, ShootRange = 22f, WeaponName = "smg", Accuracy = 0.42f, BurstCount = 4, BurstSpacing = 0.08f, Aggressive = true, ChaseForce = 8f, LungeMinDelay = 1f, LungeMaxDelay = 2.4f, KeepDistance = 3f } }; private static readonly Ability None = new Ability { Name = "", Blurb = "" }; internal static Ability For(Morph morph) { if (morph == null) { return None; } if (!ByKey.TryGetValue(morph.Key, out var value)) { return None; } return value; } internal static Ability For(Item item) { return For(MorphState.Of(item)); } internal static void LogTable() { Plugin.Log.LogInfo((object)"Variant abilities (sale value is derived from them):"); foreach (Morph item in MorphCatalog.All) { Ability ability = For(item); Plugin.Log.LogInfo((object)($" {item.Key,-11} {ability.Name,-11} heal x{ability.Heal:0.0} food x{ability.Fullness:0.0} hp x{ability.Hp:0.0}" + (ability.PoisonOnEat ? " poison" : "") + (ability.FireOnEat ? " fire" : "") + string.Format("{0} -> ${1:0.00}x", ability.IsArmed ? $" ARMED {ability.WeaponName} {ability.ShootDamage}x{ability.BurstCount}dmg {ability.Accuracy:P0}acc" : "", ability.Worth))); } } } internal sealed class ArmedBehaviour : MonoBehaviour { private Creature _creature; private Ability _ability; private Transform _muzzle; private float _lungeUntil; private float _nextLunge; private float _nextShot; private int _burstLeft; private float _nextBurstShot; private Player _burstTarget; private static readonly List Scratch = new List(); private bool IsDead { get { if (!((Object)(object)_creature == (Object)null) && _creature._hp.Value > 0) { return _creature.IsDead; } return true; } } internal void Bind(Creature creature, Ability ability) { _creature = creature; _ability = ability; if ((Object)(object)_muzzle == (Object)null) { _muzzle = AttachWeapon(((Component)creature).transform, ability, WorldSizeOf((Component)(object)creature), creature.HeadPos); } float num = (float)((NetworkBehaviour)creature).ObjectId * 0.6180339f % 1f; _nextShot = Time.time + ability.ShootInterval * (0.5f + num); } internal static float WorldSizeOf(Component c) { //IL_0021: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) float num = 0f; Renderer[] componentsInChildren = c.GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren) { if ((Object)(object)val != (Object)null) { float num2 = num; Bounds bounds = val.bounds; Vector3 size = ((Bounds)(ref bounds)).size; num = Mathf.Max(num2, ((Vector3)(ref size)).magnitude); } } if (!(num > 0.001f)) { return 0.5f; } return num; } internal static Transform AttachWeapon(Transform parent, Ability ability, float fishWorldSize, float headPos = 0f) { //IL_002b: 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_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_0053: 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_0086: Expected O, but got Unknown //IL_00a3: 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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) Item spawnable = GameInfo.GetSpawnable(ability.WeaponName); if ((Object)(object)spawnable == (Object)null || (Object)(object)spawnable.Mesh == (Object)null) { return null; } Bounds bounds = spawnable.Mesh.bounds; Vector3 size = ((Bounds)(ref bounds)).size; float magnitude = ((Vector3)(ref size)).magnitude; if (magnitude < 0.0001f) { return null; } float num = Mathf.Max(0.0001f, parent.lossyScale.x); float num2 = fishWorldSize * Plugin.HostileWeaponScale / magnitude / num; float num3 = fishWorldSize * 0.1f / num; GameObject val = new GameObject("Weapon"); val.transform.SetParent(parent, false); val.transform.localPosition = new Vector3(0f, num3, headPos); val.transform.localRotation = Quaternion.Euler(0f, 90f, 0f); val.transform.localScale = Vector3.one * num2; val.AddComponent().sharedMesh = spawnable.Mesh; MeshRenderer val2 = val.AddComponent(); Renderer[] componentsInChildren = ((Component)spawnable).GetComponentsInChildren(true); foreach (Renderer val3 in componentsInChildren) { if ((Object)(object)val3 != (Object)null && (Object)(object)val3.sharedMaterial != (Object)null) { ((Renderer)val2).sharedMaterial = val3.sharedMaterial; break; } } return val.transform; } private void Update() { //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.HostileVariants || (Object)(object)_creature == (Object)null || _ability == null) { return; } if (IsDead) { _burstLeft = 0; } else if (_burstLeft > 0) { if (!(Time.time < _nextBurstShot)) { _burstLeft--; _nextBurstShot = Time.time + _ability.BurstSpacing; if ((Object)(object)_burstTarget != (Object)null && (Object)(object)_burstTarget.Transform != (Object)null) { Fire(_burstTarget, _burstTarget.Transform.position + Vector3.up * 0.9f); } } } else if (!(Time.time < _nextShot)) { Vector3 aimPoint; Player val = FindTarget(out aimPoint); if ((Object)(object)val == (Object)null) { _nextShot = Time.time + 0.5f; return; } _nextShot = Time.time + _ability.ShootInterval; _burstTarget = val; _burstLeft = Mathf.Max(1, _ability.BurstCount) - 1; _nextBurstShot = Time.time + _ability.BurstSpacing; Fire(val, aimPoint); } } internal bool Charge() { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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_0113: 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_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.HostileVariants || _ability == null || !_ability.Aggressive) { return false; } if (IsDead) { return false; } Rigidbody rig = ((Item)_creature).Rig; if ((Object)(object)rig == (Object)null || rig.isKinematic) { return false; } Vector3 aimPoint; Player val = FindTarget(out aimPoint); if ((Object)(object)val == (Object)null || (Object)(object)val.Transform == (Object)null) { return false; } Vector3 val2 = val.Transform.position + Vector3.up * 0.4f - rig.worldCenterOfMass; float magnitude = ((Vector3)(ref val2)).magnitude; if (magnitude <= _ability.KeepDistance) { return false; } if (Time.time > _lungeUntil) { if (Time.time < _nextLunge) { return false; } _lungeUntil = Time.time + _ability.LungeDuration; _nextLunge = _lungeUntil + Random.Range(_ability.LungeMinDelay, _ability.LungeMaxDelay); } if (magnitude < 0.2f) { return true; } val2 /= magnitude; int num; float num2; if (!(((Component)_creature).transform.position.y < WaterManager.WaterHeight)) { num = (Physics.Raycast(((Component)_creature).transform.position, Vector3.down, 0.5f, LayerMask.op_Implicit(GameInfo.LevelLayer)) ? 1 : 0); if (num == 0) { num2 = _ability.ChaseForce * 0.35f; goto IL_0184; } } else { num = 1; } num2 = _ability.ChaseForce; goto IL_0184; IL_0184: float num3 = num2; rig.linearVelocity *= 0.55f; rig.linearVelocity += val2 * num3; if (num != 0) { rig.linearVelocity += Vector3.up * (_ability.ChaseForce * 0.35f); } return true; } private Player FindTarget(out Vector3 aimPoint) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) aimPoint = Vector3.zero; Vector3 val = MuzzlePosition(); Player result = null; float num = _ability.ShootRange; Scratch.Clear(); Scratch.AddRange(PlayerManager.AlivePlayers); foreach (Player item in Scratch) { if (!((Object)(object)item == (Object)null) && !((Object)(object)item.Transform == (Object)null)) { Vector3 val2 = item.Transform.position + Vector3.up * 0.9f; float num2 = Vector3.Distance(val, val2); if (!(num2 > num) && !Physics.Linecast(val, val2, LayerMask.op_Implicit(GameInfo.LevelLayer))) { num = num2; result = item; aimPoint = val2; } } } return result; } private Vector3 MuzzlePosition() { //IL_0034: 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_0019: 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_0028: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_muzzle != (Object)null)) { return ((Component)this).transform.position + Vector3.up * 0.2f; } return _muzzle.position; } private void Fire(Player target, Vector3 aimPoint) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: 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) Vector3 val = MuzzlePosition(); bool num = Random.value < _ability.Accuracy; Vector3 val2 = aimPoint; if (!num) { float num2 = Mathf.Lerp(1.6f, 0.4f, _ability.Accuracy); val2 += Random.onUnitSphere * num2; } Vector3 val3 = val2 - val; Vector3 normalized = ((Vector3)(ref val3)).normalized; if ((Object)(object)_muzzle != (Object)null) { _muzzle.rotation = Quaternion.LookRotation(normalized) * Quaternion.Euler(0f, 90f, 0f); } ShotEffect.Spawn(val, val2); if (num && (Object)(object)Server.Instance != (Object)null && ((NetworkBehaviour)Server.Instance).IsServerInitialized && (Object)(object)target.Vitals != (Object)null) { target.Vitals.TakeDamage(_ability.ShootDamage, aimPoint, normalized * 4f, false); } } } internal static class ShotEffect { private static Material _tracer; private static Material _flash; internal static void Spawn(Vector3 from, Vector3 to) { //IL_0013: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) EnsureMaterials(); if (!((Object)(object)_tracer == (Object)null)) { float num = Vector3.Distance(from, to); if (!(num < 0.05f)) { GameObject obj = GameObject.CreatePrimitive((PrimitiveType)2); Strip(obj); ((Object)obj).name = "MoreFish_Tracer"; obj.transform.position = (from + to) * 0.5f; obj.transform.rotation = Quaternion.LookRotation(to - from) * Quaternion.Euler(90f, 0f, 0f); obj.transform.localScale = new Vector3(0.02f, num * 0.5f, 0.02f); obj.GetComponent().sharedMaterial = _tracer; Object.Destroy((Object)(object)obj, 0.05f); GameObject obj2 = GameObject.CreatePrimitive((PrimitiveType)0); Strip(obj2); ((Object)obj2).name = "MoreFish_MuzzleFlash"; obj2.transform.position = from; obj2.transform.localScale = Vector3.one * 0.12f; obj2.GetComponent().sharedMaterial = _flash; Object.Destroy((Object)(object)obj2, 0.05f); } } } private static void Strip(GameObject go) { Collider component = go.GetComponent(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } } private static void EnsureMaterials() { //IL_0041: 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) if (!((Object)(object)_tracer != (Object)null)) { Shader val = Shader.Find("Universal Render Pipeline/Lit") ?? Shader.Find("Standard"); if (!((Object)(object)val == (Object)null)) { _tracer = Make(val, new Color(1f, 0.85f, 0.35f), 3f); _flash = Make(val, new Color(1f, 0.72f, 0.2f), 6f); } } } private static Material Make(Shader shader, Color color, float emission) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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) Material val = new Material(shader); if (val.HasProperty("_BaseColor")) { val.SetColor("_BaseColor", color); } if (val.HasProperty("_Color")) { val.SetColor("_Color", color); } if (val.HasProperty("_EmissionColor")) { val.EnableKeyword("_EMISSION"); val.SetColor("_EmissionColor", color * emission); } return val; } } [Serializable] public class CaughtFile { public List Caught = new List(); } internal static class CaughtLog { private static HashSet _caught; private static bool _dirty; private static string Path => Application.persistentDataPath + "/Saves/morefish-caught.json"; internal static int Total { get { EnsureLoaded(); return _caught.Count; } } private static void EnsureLoaded() { if (_caught != null) { return; } _caught = new HashSet(StringComparer.Ordinal); try { if (!File.Exists(Path)) { return; } CaughtFile caughtFile = JsonConvert.DeserializeObject(File.ReadAllText(Path)); if (caughtFile?.Caught == null) { return; } foreach (string item in caughtFile.Caught) { _caught.Add(item); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not read caught variants: " + ex.Message)); } } internal static bool Has(string key) { if (string.IsNullOrEmpty(key)) { return false; } EnsureLoaded(); return _caught.Contains(key); } internal static int CountFor(Creature species) { EnsureLoaded(); if ((Object)(object)species == (Object)null) { return 0; } int num = 0; foreach (Morph item in MorphCatalog.All) { if (_caught.Contains(MorphState.KeyFor(species, item))) { num++; } } return num; } internal static void Record(Creature creature) { if ((Object)(object)creature == (Object)null || MorphState.Of((Item)(object)creature) == null) { return; } string text = MorphState.KeyFor(creature); if (string.IsNullOrEmpty(text)) { Plugin.Log.LogWarning((object)("Caught a variant of '" + ((Object)creature).name + "' but could not build its key - the species is not in the registry.")); return; } EnsureLoaded(); if (_caught.Add(text)) { _dirty = true; Plugin.Log.LogInfo((object)$"New variant caught: {((Item)creature).GetName()} ({_caught.Count} total)."); Flush(); } } internal static void Flush() { if (!_dirty || _caught == null) { return; } _dirty = false; try { string path = Application.persistentDataPath + "/Saves/"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } CaughtFile caughtFile = new CaughtFile { Caught = new List(_caught) }; caughtFile.Caught.Sort(StringComparer.Ordinal); File.WriteAllText(Path, JsonConvert.SerializeObject((object)caughtFile, (Formatting)1)); } catch (Exception ex) { Plugin.Log.LogError((object)("Could not write caught variants: " + ex.Message)); } } } internal static class CreatureMeshFactory { internal static Mesh Build(SpeciesShape s) { //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) MeshBuilder meshBuilder = new MeshBuilder(); if (s.R != null && s.R.Length > 1) { SweptBody(meshBuilder, s, Z, Lift, Bend); } if (s.WingSpan > 0f) { Wings(meshBuilder, s, Z, Lift); } if (s.DomeRadius > 0f) { Dome(meshBuilder, s); } if (s.DorsalHeight > 0f) { Dorsal(meshBuilder, s, Z, Lift, Bend); } if (s.PectoralSpan > 0f) { Pectorals(meshBuilder, s, Z, Lift, Bend); } if (s.TailSpan > 0f && s.R != null) { Tail(meshBuilder, s, Z, Lift, Bend); } if (s.BillLength > 0f) { Bill(meshBuilder, s, Z, Lift, Bend); } if (s.HammerSpan > 0f) { Hammer(meshBuilder, s, Z, Lift, Bend); } if (s.MantleFinSpan > 0f) { MantleFins(meshBuilder, s, Z, Lift, Bend); } if (s.HeadRadius > 0f) { Head(meshBuilder, s); } if (s.Flippers > 0) { Flippers(meshBuilder, s); } if (s.Tentacles > 0) { Tentacles(meshBuilder, s); } Mesh val = meshBuilder.Build("MoreFish_" + s.Name); ManualLogSource log = Plugin.Log; string name = s.Name; object arg = meshBuilder.TriangleCount; Bounds bounds = val.bounds; log.LogInfo((object)$" {name,-14} {arg,4} tris {((Bounds)(ref bounds)).size}"); return val; float Bend(float t) { if (!(s.Curve <= 0f)) { return Mathf.Sin((t - 0.5f) * MathF.PI * s.CurveWaves) * s.Curve; } return 0f; } float Lift(float t) { return Mathf.Sin(t * MathF.PI) * 0.01f + Mathf.Max(0f, t - s.MelonAt) * s.MelonLift; } float Z(float t) { return (t - 0.5f) * s.Length; } } private static Vector3 Ring(SpeciesShape s, int i, int seg, Func Z, Func Lift, Func Bend) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) float num = (float)seg / (float)s.Segments * MathF.PI * 2f; return new Vector3(Bend(s.T[i]) + Mathf.Sin(num) * s.R[i] * s.WidthRatio, Mathf.Cos(num) * s.R[i] * s.HeightRatio + Lift(s.T[i]), Z(s.T[i])); } private static void SweptBody(MeshBuilder b, SpeciesShape s, Func Z, Func Lift, Func Bend) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: 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_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) Vector3 inside = default(Vector3); for (int i = 0; i < s.T.Length - 1; i++) { for (int j = 0; j < s.Segments; j++) { int seg = (j + 1) % s.Segments; ((Vector3)(ref inside))..ctor(Bend(s.T[i]), Lift(s.T[i]), Z(s.T[i])); b.QuadOut(Ring(s, i, j, Z, Lift, Bend), Ring(s, i, seg, Z, Lift, Bend), Ring(s, i + 1, seg, Z, Lift, Bend), Ring(s, i + 1, j, Z, Lift, Bend), inside); } } Vector3 b2 = default(Vector3); ((Vector3)(ref b2))..ctor(Bend(1f), Lift(1f), Z(1f) + s.Length * 0.03f); Vector3 b3 = default(Vector3); ((Vector3)(ref b3))..ctor(Bend(0f), Lift(0f), Z(0f) - s.Length * 0.02f); int i2 = s.T.Length - 1; Vector3 inside2 = default(Vector3); Vector3 inside3 = default(Vector3); for (int k = 0; k < s.Segments; k++) { int seg2 = (k + 1) % s.Segments; ((Vector3)(ref inside2))..ctor(Bend(1f), Lift(1f), Z(1f)); ((Vector3)(ref inside3))..ctor(Bend(0f), Lift(0f), Z(0f)); b.TriOut(Ring(s, i2, k, Z, Lift, Bend), b2, Ring(s, i2, seg2, Z, Lift, Bend), inside2); b.TriOut(Ring(s, 0, seg2, Z, Lift, Bend), b3, Ring(s, 0, k, Z, Lift, Bend), inside3); } } private static void Dorsal(MeshBuilder b, SpeciesShape s, Func Z, Func Lift, Func Bend) { //IL_00b5: 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_00b8: Unknown result type (might be due to invalid IL or missing references) float num = Radius(s, s.DorsalAt) * s.HeightRatio; float num2 = Bend(s.DorsalAt); Vector3 a = default(Vector3); ((Vector3)(ref a))..ctor(num2, num + Lift(s.DorsalAt) - 0.004f, Z(s.DorsalAt + 0.06f)); Vector3 c = default(Vector3); ((Vector3)(ref c))..ctor(num2, num + Lift(s.DorsalAt) - 0.004f, Z(s.DorsalAt - 0.08f)); Vector3 b2 = default(Vector3); ((Vector3)(ref b2))..ctor(num2, num + Lift(s.DorsalAt) + s.DorsalHeight, Z(s.DorsalAt - 0.08f) - s.DorsalSweep); b.TriDouble(a, b2, c); } private static void Pectorals(MeshBuilder b, SpeciesShape s, Func Z, Func Lift, Func Bend) { //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) float num = Radius(s, s.PectoralAt); float num2 = Lift(s.PectoralAt) - num * 0.25f; Vector3 a = default(Vector3); Vector3 c = default(Vector3); Vector3 b2 = default(Vector3); for (int i = -1; i <= 1; i += 2) { float num3 = Bend(s.PectoralAt); ((Vector3)(ref a))..ctor(num3 + (float)i * num * 0.8f, num2, Z(s.PectoralAt + 0.04f)); ((Vector3)(ref c))..ctor(num3 + (float)i * num * 0.8f, num2 - num * 0.25f, Z(s.PectoralAt - 0.05f)); ((Vector3)(ref b2))..ctor(num3 + (float)i * (num + s.PectoralSpan), num2 - num * 0.5f, Z(s.PectoralAt - 0.12f)); b.TriDouble(a, b2, c); } } private static void MantleFins(MeshBuilder b, SpeciesShape s, Func Z, Func Lift, Func Bend) { //IL_00d7: 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_00db: Unknown result type (might be due to invalid IL or missing references) float mantleFinAt = s.MantleFinAt; float num = s.MantleFinLength * 0.5f; float num2 = Bend(mantleFinAt); float num3 = Lift(mantleFinAt); float num4 = Radius(s, Mathf.Max(0f, mantleFinAt - num)) * s.WidthRatio; float num5 = Radius(s, mantleFinAt) * s.WidthRatio; float num6 = Radius(s, Mathf.Min(1f, mantleFinAt + num)) * s.WidthRatio; Vector3 a = default(Vector3); Vector3 c = default(Vector3); Vector3 b2 = default(Vector3); for (int i = -1; i <= 1; i += 2) { ((Vector3)(ref a))..ctor(num2 + (float)i * num4, num3, Z(Mathf.Max(0f, mantleFinAt - num))); ((Vector3)(ref c))..ctor(num2 + (float)i * num6, num3, Z(Mathf.Min(1f, mantleFinAt + num))); ((Vector3)(ref b2))..ctor(num2 + (float)i * (num5 + s.MantleFinSpan), num3, Z(mantleFinAt)); b.TriDouble(a, b2, c); } } private static void Tail(MeshBuilder b, SpeciesShape s, Func Z, Func Lift, Func Bend) { //IL_00b7: 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_00bc: 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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) float num = Lift(0.03f); float num2 = Bend(0.05f); Vector3 a = default(Vector3); ((Vector3)(ref a))..ctor(Bend(0.1f), num, Z(0.1f)); Vector3 c = default(Vector3); ((Vector3)(ref c))..ctor(num2, num, Z(0.02f) - s.TailSweep); for (int i = -1; i <= 1; i += 2) { Vector3 b2 = (s.HorizontalTail ? new Vector3(num2 + (float)i * s.TailSpan, num + 0.01f, Z(0.02f) - s.TailSweep * 1.4f) : new Vector3(num2, num + (float)i * s.TailSpan, Z(0.02f) - s.TailSweep * 1.4f)); b.TriDouble(a, b2, c); } } private static void Bill(MeshBuilder b, SpeciesShape s, Func Z, Func Lift, Func Bend) { //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) float num = Lift(1f); float num2 = Bend(1f); Vector3 b2 = default(Vector3); ((Vector3)(ref b2))..ctor(num2, num, Z(1f) + s.BillLength); Vector3 a = default(Vector3); Vector3 c = default(Vector3); for (int i = 0; i < 4; i++) { float num3 = (float)i / 4f * MathF.PI * 2f; float num4 = (float)(i + 1) / 4f * MathF.PI * 2f; ((Vector3)(ref a))..ctor(num2 + Mathf.Sin(num3) * s.BillRadius, num + Mathf.Cos(num3) * s.BillRadius, Z(1f)); ((Vector3)(ref c))..ctor(num2 + Mathf.Sin(num4) * s.BillRadius, num + Mathf.Cos(num4) * s.BillRadius, Z(1f)); b.Tri(a, b2, c); } } private static void Hammer(MeshBuilder b, SpeciesShape s, Func Z, Func Lift, Func Bend) { //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) float num = Lift(0.94f); float num2 = Z(0.98f); float num3 = Z(0.86f); float num4 = Radius(s, 0.92f) * 0.7f; Vector3 a = default(Vector3); Vector3 d = default(Vector3); Vector3 val = default(Vector3); Vector3 val2 = default(Vector3); for (int i = -1; i <= 1; i += 2) { float num5 = (float)i * s.HammerSpan; ((Vector3)(ref a))..ctor(0f, num + num4, num2); ((Vector3)(ref d))..ctor(0f, num + num4, num3); ((Vector3)(ref val))..ctor(num5, num + num4 * 0.7f, num3); ((Vector3)(ref val2))..ctor(num5, num + num4 * 0.7f, num2); b.Quad(a, val2, val, d); b.Quad(new Vector3(0f, num - num4, num2), new Vector3(0f, num - num4, num3), new Vector3(num5, num - num4 * 0.7f, num3), new Vector3(num5, num - num4 * 0.7f, num2)); b.Quad(val2, new Vector3(num5, num - num4 * 0.7f, num2), new Vector3(num5, num - num4 * 0.7f, num3), val); } } private static void Wings(MeshBuilder b, SpeciesShape s, Func Z, Func Lift) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) float num = Lift(0.5f); Vector3 a = default(Vector3); ((Vector3)(ref a))..ctor(0f, num, Z(0.86f)); Vector3 c = default(Vector3); ((Vector3)(ref c))..ctor(0f, num, Z(0.16f)); Vector3 b2 = default(Vector3); for (int i = -1; i <= 1; i += 2) { ((Vector3)(ref b2))..ctor((float)i * s.WingSpan, num - 0.01f, Z(0.5f) - s.WingSweep); b.TriDouble(a, b2, c); } } private static void Head(MeshBuilder b, SpeciesShape s) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: 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_0084: 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_009c: 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_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) float num = ((s.DomeRadius > 0f) ? (s.DomeRadius * 0.92f) : 0f); Vector3 centre = new Vector3(0f, s.DomeHeight * 0.28f, num); int seg = 6; for (int i = 0; i < 2; i++) { for (int j = 0; j < seg; j++) { int i2 = (j + 1) % seg; b.QuadOut(P(i, j), P(i, i2), P(i + 1, i2), P(i + 1, j), centre); } } Vector3 b2 = centre + Vector3.down * s.HeadRadius * 0.8f; for (int k = 0; k < seg; k++) { b.Tri(P(0, (k + 1) % seg), b2, P(0, k)); } Vector3 P(int r, int num4) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) float num2 = (float)r / 2f * MathF.PI * 0.5f; float num3 = (float)num4 / (float)seg * MathF.PI * 2f; return centre + new Vector3(Mathf.Sin(num3) * Mathf.Cos(num2) * s.HeadRadius, Mathf.Sin(num2) * s.HeadRadius, Mathf.Cos(num3) * Mathf.Cos(num2) * s.HeadRadius * 1.5f); } } private static void Dome(MeshBuilder b, SpeciesShape s) { //IL_0031: 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_0047: 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_00b2: 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_00bd: Unknown result type (might be due to invalid IL or missing references) int rings = 4; int seg = 8; for (int i = 0; i < rings; i++) { for (int j = 0; j < seg; j++) { int i2 = (j + 1) % seg; b.QuadOut(P(i, j), P(i, i2), P(i + 1, i2), P(i + 1, j), Vector3.zero); } } Vector3 b2 = default(Vector3); ((Vector3)(ref b2))..ctor(0f, (0f - s.DomeHeight) * 0.22f, 0f); for (int k = 0; k < seg; k++) { b.TriDouble(P(0, (k + 1) % seg), b2, P(0, k)); } Vector3 P(int r, int num3) { //IL_0072: Unknown result type (might be due to invalid IL or missing references) float num = (float)r / (float)rings * MathF.PI * 0.5f; float num2 = (float)num3 / (float)seg * MathF.PI * 2f; return new Vector3(Mathf.Sin(num2) * Mathf.Cos(num) * s.DomeRadius, Mathf.Sin(num) * s.DomeHeight, Mathf.Cos(num2) * Mathf.Cos(num) * s.DomeRadius); } } private static void Flippers(MeshBuilder b, SpeciesShape s) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_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_00a8: 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_00ab: Unknown result type (might be due to invalid IL or missing references) Vector3 val = default(Vector3); for (int i = 0; i < s.Flippers; i++) { float num = ((float)i + 0.5f) / (float)s.Flippers * MathF.PI * 2f; ((Vector3)(ref val))..ctor(Mathf.Sin(num) * s.DomeRadius * 0.85f, 0f, Mathf.Cos(num) * s.DomeRadius * 0.85f); Vector3 b2 = val * 1.85f + Vector3.down * 0.02f; Vector3 val2 = Vector3.Cross(((Vector3)(ref val)).normalized, Vector3.up) * s.DomeRadius * 0.22f; b.TriDouble(val + val2, b2, val - val2); } } private static void Tentacles(MeshBuilder b, SpeciesShape s) { //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_0025: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: 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) //IL_00ff: 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_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: 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) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0198: 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) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: 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_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) Vector3 normalized = ((Vector3)(ref s.TentacleDir)).normalized; Vector3 val = Vector3.Cross((Mathf.Abs(normalized.y) > 0.9f) ? Vector3.forward : Vector3.up, normalized); Vector3 normalized2 = ((Vector3)(ref val)).normalized; val = Vector3.Cross(normalized, normalized2); Vector3 normalized3 = ((Vector3)(ref val)).normalized; float num = ((s.DomeRadius > 0f) ? (s.DomeRadius * 0.72f) : (Radius(s, s.TentacleAt) * 0.85f)); float num2 = ((s.DomeRadius > 0f) ? 0f : ((s.TentacleAt - 0.5f) * s.Length)); Vector3 val2 = (Vector3)((s.DomeRadius > 0f) ? Vector3.zero : new Vector3(0f, 0f, num2)); for (int i = 0; i < s.Tentacles; i++) { float num3 = (float)i / (float)s.Tentacles * MathF.PI * 2f; Vector3 val3 = normalized2 * Mathf.Sin(num3) + normalized3 * Mathf.Cos(num3); Vector3 val4 = val2 + val3 * num; Vector3 val5 = val4 + normalized * (s.TentacleLength * 0.55f) + val3 * (s.TentacleLength * 0.1f); Vector3 c = val4 + normalized * s.TentacleLength + val3 * (s.TentacleLength * 0.26f); val = Vector3.Cross(normalized, val3); Vector3 val6 = ((Vector3)(ref val)).normalized * s.TentacleWidth; b.Quad(val4 + val6, val4 - val6, val5 - val6 * 0.6f, val5 + val6 * 0.6f); b.TriDouble(val5 + val6 * 0.6f, val5 - val6 * 0.6f, c); } } private static float Radius(SpeciesShape s, float t) { if (s.R == null || s.R.Length == 0) { return 0.05f; } for (int i = 0; i < s.T.Length - 1; i++) { if (t <= s.T[i + 1]) { float num = Mathf.InverseLerp(s.T[i], s.T[i + 1], t); return Mathf.Lerp(s.R[i], s.R[i + 1], num); } } return s.R[s.R.Length - 1]; } } internal sealed class CustomSpeciesTag : MonoBehaviour { [SerializeField] internal string DisplayName; [SerializeField] internal float BodyScale = 1f; } internal static class CustomSpecies { private const byte FirstId = 200; private static GameObject _root; private static bool _built; private static bool _registeredFishNet; private static bool _registeredGameInfo; internal static readonly List Added = new List(); private static readonly Dictionary _rarityByName = new Dictionary(); private static readonly Dictionary _shapeByName = new Dictionary(); internal static SpeciesShape ShapeFor(Creature c) { if ((Object)(object)c == (Object)null) { return null; } if (_shapeByName.TryGetValue(SpeciesRegistry.Normalize(((Object)c).name), out var value)) { return value; } CustomSpeciesTag component = ((Component)c).GetComponent(); if ((Object)(object)component != (Object)null && !string.IsNullOrEmpty(component.DisplayName) && _shapeByName.TryGetValue(SpeciesRegistry.Normalize(component.DisplayName), out value)) { return value; } return null; } private static Bounds LocalBounds(Transform root) { //IL_0004: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_007d: Unknown result type (might be due to invalid IL or missing references) bool flag = false; Bounds result = default(Bounds); MeshFilter[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); Bounds val4 = default(Bounds); foreach (MeshFilter val in componentsInChildren) { if (!((Object)(object)val.sharedMesh == (Object)null)) { Bounds bounds = val.sharedMesh.bounds; Vector3 val2 = root.InverseTransformPoint(((Component)val).transform.TransformPoint(((Bounds)(ref bounds)).center)); Vector3 val3 = Vector3.Scale(((Bounds)(ref bounds)).size, ((Component)val).transform.lossyScale); ((Bounds)(ref val4))..ctor(val2, val3); if (!flag) { result = val4; flag = true; } else { ((Bounds)(ref result)).Encapsulate(val4); } } } if (!flag) { return new Bounds(Vector3.zero, Vector3.one * 0.2f); } return result; } internal static bool IsCustom(Creature c) { if ((Object)(object)c != (Object)null) { return (Object)(object)((Component)c).GetComponent() != (Object)null; } return false; } internal static void EnsureBuilt() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown if (_built) { return; } _built = true; SpeciesRegistry.EnsureLoaded(); if (SpeciesRegistry.Count == 0) { Plugin.Log.LogError((object)"No creatures loaded; custom species cannot be built."); return; } _root = new GameObject("MoreFish_SpeciesRoot"); _root.SetActive(false); Object.DontDestroyOnLoad((Object)(object)_root); Plugin.Log.LogInfo((object)$"Building {SpeciesCatalog.All.Count} new species:"); byte b = 200; foreach (SpeciesShape item in SpeciesCatalog.All) { Creature val = FindDonor(item.Donor); if (!((Object)(object)val == (Object)null)) { Creature val2 = BuildOne(val, item, b++); if ((Object)(object)val2 != (Object)null) { Added.Add(val2); } } } Plugin.Log.LogInfo((object)$"Built {Added.Count} custom species."); } private static Creature FindDonor(params string[] preferred) { SpeciesRegistry.EnsureLoaded(); foreach (string text in preferred) { foreach (Creature item in SpeciesRegistry.Species) { if (SpeciesRegistry.Normalize(((Object)item).name) == text) { return item; } } } if (SpeciesRegistry.Count <= 0) { return null; } return SpeciesRegistry.At(0); } private static Creature BuildOne(Creature donor, SpeciesShape shape, byte id) { //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_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0111: 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_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0148: 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_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0181: 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_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate(((Component)donor).gameObject, _root.transform); ((Object)val).name = shape.Name; Creature component = val.GetComponent(); if ((Object)(object)component == (Object)null) { Object.Destroy((Object)(object)val); return null; } Bounds val2 = LocalBounds(val.transform); Plugin.Log.LogInfo((object)$" {shape.Name,-14} donor '{((Object)donor).name}'"); MeshFilter[] componentsInChildren = val.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].sharedMesh = null; } SkinnedMeshRenderer[] componentsInChildren2 = val.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren2.Length; i++) { componentsInChildren2[i].sharedMesh = null; } Renderer[] componentsInChildren3 = val.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren3.Length; i++) { componentsInChildren3[i].enabled = false; } Mesh val3 = CreatureMeshFactory.Build(shape); GameObject val4 = new GameObject("Model"); val4.transform.SetParent(val.transform, false); val4.AddComponent().sharedMesh = val3; ((Renderer)val4.AddComponent()).sharedMaterial = MakeMaterial(shape.Colour); EyeBuilder.Attach(val4.transform, shape, val3); Transform transform = val4.transform; float x = ((Bounds)(ref val2)).center.x; Bounds bounds = val3.bounds; float num = x - ((Bounds)(ref bounds)).center.x; float y = ((Bounds)(ref val2)).min.y; bounds = val3.bounds; float num2 = y - ((Bounds)(ref bounds)).min.y; float z = ((Bounds)(ref val2)).center.z; bounds = val3.bounds; transform.localPosition = new Vector3(num, num2, z - ((Bounds)(ref bounds)).center.z); int worth = shape.Worth; float weight = shape.Weight; int hp = shape.Hp; Reflect.Set(component, "_mesh", val3); Reflect.Set(component, "_dripMesh", val3); Reflect.Set(component, "_id", id); Reflect.Set(component, "_worth", worth); Reflect.Set(component, "_weight", weight); Reflect.Set(component, "_maxHp", hp); Reflect.Set(component, "_excludeFromJournal", false); CustomSpeciesTag customSpeciesTag = val.AddComponent(); customSpeciesTag.DisplayName = shape.Name; customSpeciesTag.BodyScale = shape.BodyScale; _rarityByName[SpeciesRegistry.Normalize(shape.Name)] = shape.Rarity; _shapeByName[SpeciesRegistry.Normalize(shape.Name)] = shape; return component; } private static Material MakeMaterial(Color colour) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) Material val = new Material(Shader.Find("Universal Render Pipeline/Lit") ?? Shader.Find("Standard")); if (val.HasProperty("_BaseColor")) { val.SetColor("_BaseColor", colour); } if (val.HasProperty("_Color")) { val.SetColor("_Color", colour); } if (val.HasProperty("_Smoothness")) { val.SetFloat("_Smoothness", 0.45f); } return val; } internal static void RegisterWithFishNet(NetworkManager manager) { if (_registeredFishNet || (Object)(object)manager == (Object)null) { return; } PrefabObjects spawnablePrefabs = manager.SpawnablePrefabs; if ((Object)(object)spawnablePrefabs == (Object)null) { return; } EnsureBuilt(); if (Added.Count == 0) { return; } int objectCount = spawnablePrefabs.GetObjectCount(); for (int i = 0; i < objectCount; i++) { NetworkObject val = spawnablePrefabs.GetObject(true, i); if ((Object)(object)val != (Object)null && (Object)(object)((Component)val).GetComponent() != (Object)null) { _registeredFishNet = true; return; } } foreach (Creature item in Added) { NetworkObject component = ((Component)item).GetComponent(); if ((Object)(object)component != (Object)null) { spawnablePrefabs.AddObject(component, false, true); } } _registeredFishNet = true; Plugin.Log.LogInfo((object)$"Registered {Added.Count} custom species with FishNet."); } internal static void RegisterWithGame() { if (_registeredGameInfo) { return; } EnsureBuilt(); if (Added.Count == 0) { return; } _registeredGameInfo = true; Dictionary dictionary = Reflect.GetStatic>(typeof(GameInfo), "_nameToSpawnable"); Dictionary dictionary2 = Reflect.GetStatic>(typeof(GameInfo), "_idToSpawnable"); Dictionary dictionary3 = Reflect.GetStatic>(typeof(GameInfo), "_allItems"); List list = Reflect.GetStatic>(typeof(GameInfo), "_allCreatures"); foreach (Creature item in Added) { if (dictionary3 != null && dictionary3.ContainsKey(((Item)item).ID)) { Plugin.Log.LogWarning((object)$"Item id {((Item)item).ID} is taken; '{((Object)item).name}' will not survive a save."); continue; } string key = SpeciesRegistry.Normalize(((Object)item).name); if (dictionary != null && !dictionary.ContainsKey(key)) { dictionary[key] = (Item)(object)item; } if (dictionary2 != null) { dictionary2[((Item)item).ID] = (Item)(object)item; } if (dictionary3 != null) { dictionary3[((Item)item).ID] = (Item)(object)item; } if (list != null && !list.Contains(item)) { list.Add(item); } SpeciesRegistry.Add(item); } InjectIntoBaits(); Plugin.Log.LogInfo((object)$"Registered {Added.Count} custom species with the game."); } private static void InjectIntoBaits() { //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Expected O, but got Unknown BaitInfo[] array = Resources.LoadAll("Baits"); if (array == null) { return; } int num = 0; BaitInfo[] array2 = array; foreach (BaitInfo val in array2) { List list = (((Object)(object)val != (Object)null) ? val.ItemWeights : null); if (list == null || list.Count == 0) { continue; } bool flag = false; float num2 = 0f; foreach (ItemInfoWeight item in list) { Item val2 = (((Object)(object)((item != null) ? item.Fishable : null) != (Object)null) ? item.Fishable.ItemToSpawn : null); if (!((Object)(object)val2 == (Object)null)) { if ((Object)(object)((Component)val2).GetComponent() != (Object)null) { flag = true; break; } num2 = Mathf.Max(num2, item.Weight); } } if (flag || num2 <= 0f) { continue; } foreach (Creature item2 in Added) { Fishable val3 = ScriptableObject.CreateInstance(); ((Object)val3).name = "MoreFish_" + ((Object)item2).name; ((Object)val3).hideFlags = (HideFlags)61; Reflect.Set(val3, "_itemToSpawn", item2); ItemInfoWeight val4 = new ItemInfoWeight(); Reflect.Set(val4, "fishable", val3); _rarityByName.TryGetValue(SpeciesRegistry.Normalize(((Object)item2).name), out var value); if (value <= 0f) { value = 0.1f; } Reflect.Set(val4, "_weight", num2 * value * Plugin.CustomSpeciesRarity); list.Add(val4); num++; } } Plugin.Log.LogInfo((object)$"Custom species added to {num} bait entries."); } } internal sealed class DebugPanel : MonoBehaviour { private bool _open; private int _species; private int _morph; private GUIStyle _box; private GUIStyle _title; private GUIStyle _line; private GUIStyle _hint; private void Update() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.DebugEnabled) { return; } if (Input.GetKeyDown(Plugin.DebugPanelKey)) { _open = !_open; } if (_open) { int num = Mathf.Max(1, SpeciesRegistry.Count); int count = MorphCatalog.All.Count; if (Input.GetKeyDown((KeyCode)275)) { _species = (_species + 1) % num; } if (Input.GetKeyDown((KeyCode)276)) { _species = (_species - 1 + num) % num; } if (Input.GetKeyDown((KeyCode)274)) { _morph = (_morph + 1) % count; } if (Input.GetKeyDown((KeyCode)273)) { _morph = (_morph - 1 + count) % count; } if (Input.GetKeyDown((KeyCode)13) || Input.GetKeyDown((KeyCode)271)) { Spawn(); } if (Input.GetKeyDown((KeyCode)102)) { MorphState.ForcedMorph = ((MorphState.ForcedMorph == _morph) ? (-1) : _morph); Plugin.Log.LogInfo((object)((MorphState.ForcedMorph < 0) ? "Debug: catches are random again." : ("Debug: every catch is now '" + MorphCatalog.At(_morph).Key + "'."))); } if (Input.GetKeyDown((KeyCode)99)) { MorphState.ForcedMorph = -1; } } } private void Spawn() { //IL_006f: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: 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) Creature val = SpeciesRegistry.At(_species); if ((Object)(object)val == (Object)null) { return; } if ((Object)(object)Server.Instance == (Object)null || !((NetworkBehaviour)Server.Instance).IsServerInitialized || (Object)(object)ItemManager.Instance == (Object)null) { Plugin.Log.LogWarning((object)"Debug: spawning needs you to be the host."); return; } Player localPlayer = Player.LocalPlayer; Camera curCamera = GameInfo.CurCamera; if ((Object)(object)localPlayer == (Object)null || (Object)(object)curCamera == (Object)null) { return; } Vector3 val2 = ((Component)curCamera).transform.position + ((Component)curCamera).transform.forward * 2f; try { Item val3 = ItemManager.Instance.SpawnNewItem(((Component)val).GetComponent(), val2, Quaternion.identity); Creature val4 = (((Object)(object)val3 == (Object)null) ? null : ((Component)val3).GetComponent()); if (!((Object)(object)val4 == (Object)null)) { ((Item)val4)._curSkin.Value = (byte)(_morph + 1); Plugin.Log.LogInfo((object)("Debug: spawned " + MorphCatalog.At(_morph).Key + " " + ((Object)val).name + ".")); } } catch (Exception ex) { Plugin.Log.LogError((object)("Debug: spawn failed: " + ex.Message)); } } private void OnGUI() { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) if (Plugin.DebugEnabled && _open) { EnsureStyles(); Creature val = SpeciesRegistry.At(_species); Morph morph = MorphCatalog.At(_morph); if (!((Object)(object)val == (Object)null) && morph != null) { Ability ability = AbilityCatalog.For(morph); bool num = MorphState.ForcedMorph == _morph; Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(20f, 20f, 430f, 232f); GUI.Box(val2, GUIContent.none, _box); GUILayout.BeginArea(new Rect(((Rect)(ref val2)).x + 14f, ((Rect)(ref val2)).y + 12f, ((Rect)(ref val2)).width - 28f, ((Rect)(ref val2)).height - 24f)); GUILayout.Label("More Fish — debug", _title, Array.Empty()); GUILayout.Space(6f); GUILayout.Label($"Species {((Object)val).name} ({_species + 1}/{SpeciesRegistry.Count})", _line, Array.Empty()); GUILayout.Label($"Morph {morph.Key} ({_morph + 1}/{MorphCatalog.All.Count})", _line, Array.Empty()); GUILayout.Label("Ability " + ability.Name + " — " + ability.Blurb, _line, Array.Empty()); GUILayout.Label($"Value ${ability.Worth:0.00}x" + (ability.IsArmed ? $" ARMED {ability.WeaponName}, {ability.ShootDamage} dmg" : ""), _line, Array.Empty()); GUILayout.Space(6f); GUILayout.Label(num ? "FORCING every catch to this morph" : "catches are random", _line, Array.Empty()); GUILayout.Space(8f); GUILayout.Label("←/→ species ↑/↓ morph Enter spawn", _hint, Array.Empty()); GUILayout.Label($"F force this morph C clear {Plugin.DebugPanelKey} close", _hint, Array.Empty()); GUILayout.EndArea(); } } } private void EnsureStyles() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_0064: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Expected O, but got Unknown //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Expected O, but got Unknown //IL_012e: Unknown result type (might be due to invalid IL or missing references) if (_box == null) { Texture2D val = new Texture2D(1, 1); val.SetPixel(0, 0, new Color(0.04f, 0.09f, 0.13f, 0.92f)); val.Apply(); GUIStyle val2 = new GUIStyle(GUI.skin.box); val2.normal.background = val; _box = val2; _title = new GUIStyle(GUI.skin.label) { fontSize = 15, fontStyle = (FontStyle)1, richText = true }; _title.normal.textColor = new Color(0.9f, 0.94f, 0.96f); _line = new GUIStyle(GUI.skin.label) { fontSize = 13, richText = true }; _line.normal.textColor = new Color(0.85f, 0.9f, 0.93f); _hint = new GUIStyle(GUI.skin.label) { fontSize = 12, richText = true }; _hint.normal.textColor = new Color(0.6f, 0.68f, 0.73f); } } } internal sealed class MorphExempt : MonoBehaviour { } internal static class EyeBuilder { private static Mesh _sphere; private static Material _white; private static Material _pupil; private static Material _shine; internal static void Attach(Transform parent, SpeciesShape s, Mesh body) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: 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) if (!s.Eyes) { return; } EnsureAssets(); float radius; Vector3 val = EyePosition(s, body, out radius); radius *= s.EyeScale; if (!(radius <= 0.001f)) { Vector3 val2 = default(Vector3); for (int i = -1; i <= 1; i += 2) { ((Vector3)(ref val2))..ctor(val.x + (float)i * val.z * 0f + (float)i * s.EyeSpread * radius, val.y, val.z); Ball(parent, "Eye", val2, radius, _white); Vector3 val3 = val2 + new Vector3((float)i * radius * 0.28f, (0f - radius) * 0.06f, radius * 0.74f); Ball(parent, "Pupil", val3, radius * 0.52f, _pupil); Vector3 pos = val3 + new Vector3((float)i * radius * 0.1f, radius * 0.2f, radius * 0.24f); Ball(parent, "Shine", pos, radius * 0.2f, _shine); } } } private static Vector3 EyePosition(SpeciesShape s, Mesh body, out float radius) { //IL_009f: 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) if (s.R != null && s.R.Length > 1) { float num = Mathf.Clamp01(s.EyeAt); float num2 = RadiusAt(s, num); radius = Mathf.Max(0.022f, num2 * 0.52f); float num3 = (num - 0.5f) * s.Length; float num4 = Mathf.Sin(num * MathF.PI) * 0.01f + Mathf.Max(0f, num - s.MelonAt) * s.MelonLift; return new Vector3(num2 * s.WidthRatio * 0.62f, num4 + num2 * s.HeightRatio * 0.42f, num3); } radius = Mathf.Max(0.022f, s.DomeRadius * 0.2f); float num5 = ((s.HeadRadius > 0f) ? (s.DomeHeight * 0.34f) : (s.DomeHeight * 0.55f)); float num6 = ((s.HeadRadius > 0f) ? (s.DomeRadius * 1.02f) : (s.DomeRadius * 0.72f)); return new Vector3(radius * 0.9f, num5, num6); } private static float RadiusAt(SpeciesShape s, float t) { for (int i = 0; i < s.T.Length - 1; i++) { if (t <= s.T[i + 1]) { return Mathf.Lerp(s.R[i], s.R[i + 1], Mathf.InverseLerp(s.T[i], s.T[i + 1], t)); } } return s.R[s.R.Length - 1]; } private static void Ball(Transform parent, string name, Vector3 pos, float radius, Material mat) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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) GameObject val = new GameObject(name); val.transform.SetParent(parent, false); val.transform.localPosition = pos; val.transform.localScale = Vector3.one * radius; val.AddComponent().sharedMesh = _sphere; ((Renderer)val.AddComponent()).sharedMaterial = mat; val.AddComponent(); } private static void EnsureAssets() { //IL_002d: 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_0072: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_sphere == (Object)null) { _sphere = UnitSphere(); } if (_white == null) { _white = Paint(new Color(0.97f, 0.96f, 0.93f), 0.55f); } if (_pupil == null) { _pupil = Paint(new Color(0.06f, 0.06f, 0.08f), 0.75f); } if (_shine == null) { _shine = Paint(Color.white, 0.9f); } } private static Material Paint(Color c, float smoothness) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) Material val = new Material(Shader.Find("Universal Render Pipeline/Lit") ?? Shader.Find("Standard")); if (val.HasProperty("_BaseColor")) { val.SetColor("_BaseColor", c); } if (val.HasProperty("_Color")) { val.SetColor("_Color", c); } if (val.HasProperty("_Smoothness")) { val.SetFloat("_Smoothness", smoothness); } return val; } private static Mesh UnitSphere() { //IL_0017: 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_0027: 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_0035: Unknown result type (might be due to invalid IL or missing references) MeshBuilder meshBuilder = new MeshBuilder(); for (int i = 0; i < 5; i++) { for (int j = 0; j < 8; j++) { int i2 = (j + 1) % 8; meshBuilder.QuadOut(P(i, j), P(i, i2), P(i + 1, i2), P(i + 1, j), Vector3.zero); } } return meshBuilder.Build("MoreFish_Eyeball"); static Vector3 P(int r, int num3) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) float num = MathF.PI * ((float)r / 5f) - MathF.PI / 2f; float num2 = (float)num3 / 8f * MathF.PI * 2f; return new Vector3(Mathf.Sin(num2) * Mathf.Cos(num), Mathf.Sin(num), Mathf.Cos(num2) * Mathf.Cos(num)); } } } internal sealed class JournalClickDriver : MonoBehaviour { private void Update() { if (!Plugin.JournalVariantBrowser) { return; } if (!PlayerThinking.IsThinking) { if (VariantBrowser.Active) { VariantBrowser.Exit(); } } else if (RightClicked()) { VariantBrowser.Exit(); } else { if (!LeftClicked() || VariantBrowser.Active) { return; } ThinkingUI val = VariantBrowser.FindThinkingUI(); if (!((Object)(object)val == (Object)null)) { Creature val2 = SlotUnderCursor(val); if ((Object)(object)val2 != (Object)null) { VariantBrowser.Enter(val2); } } } } private static bool LeftClicked() { return Pressed(0); } private static bool RightClicked() { return Pressed(1); } private static bool Pressed(int button) { try { if (Input.GetMouseButtonDown(button)) { return true; } } catch { } try { Mouse current = Mouse.current; if (current == null) { return false; } return (button == 0) ? current.leftButton.wasPressedThisFrame : current.rightButton.wasPressedThisFrame; } catch { return false; } } private static Vector2 CursorPosition() { //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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) try { Mouse current = Mouse.current; if (current != null) { return ((InputControl)(object)((Pointer)current).position).ReadValue(); } } catch { } return Vector2.op_Implicit(Input.mousePosition); } private static Creature SlotUnderCursor(ThinkingUI ui) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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) List list = Reflect.Get>(ui, "_slots"); if (list == null || list.Count == 0) { return null; } Vector2 val = CursorPosition(); for (int i = 0; i < list.Count; i++) { RectTransform val2 = SlotRect(list[i]); if (!((Object)(object)val2 == (Object)null)) { Canvas componentInParent = ((Component)val2).GetComponentInParent(); Camera val3 = (((Object)(object)componentInParent != (Object)null && (int)componentInParent.renderMode != 0) ? componentInParent.worldCamera : null); if (RectTransformUtility.RectangleContainsScreenPoint(val2, val, val3)) { return GameInfo.GetCreature(Reflect.Get(ui, "_curPage", 0) * list.Count + i); } } } return null; } private static RectTransform SlotRect(JournalSlot slot) { if ((Object)(object)slot == (Object)null) { return null; } Graphic val = Reflect.Get(slot, "_image"); if ((Object)(object)val != (Object)null && (Object)(object)val.rectTransform != (Object)null) { return val.rectTransform; } Transform transform = ((Component)slot).transform; return (RectTransform)(object)((transform is RectTransform) ? transform : null); } } internal static class JournalHeader { private static TMP_Text _title; private static string _original; private static bool _searched; private static void FindTitle(ThinkingUI ui) { if (_searched) { return; } _searched = true; CanvasGroup val = Reflect.Get(ui, "_thinkingCanvas"); Transform obj = (((Object)(object)val != (Object)null) ? ((Component)val).transform : ((Component)ui).transform); TMP_Text val2 = Reflect.Get(ui, "_progressText"); TMP_Text val3 = Reflect.Get(ui, "_dripProgressText"); float num = 0f; TMP_Text[] componentsInChildren = ((Component)obj).GetComponentsInChildren(true); foreach (TMP_Text val4 in componentsInChildren) { if (!((Object)(object)val4 == (Object)null) && !((Object)(object)val4 == (Object)(object)val2) && !((Object)(object)val4 == (Object)(object)val3) && !(val4.fontSize <= num)) { num = val4.fontSize; _title = val4; } } if ((Object)(object)_title != (Object)null) { _original = _title.text; } } internal static void Set(ThinkingUI ui, string text) { if (!((Object)(object)ui == (Object)null)) { FindTitle(ui); if (!((Object)(object)_title == (Object)null)) { _title.text = text ?? _original; } } } } internal sealed class MeshBuilder { private readonly List _verts = new List(); private readonly List _tris = new List(); private readonly List _uvs = new List(); internal Vector2 Uv = new Vector2(0.5f, 0.5f); internal int TriangleCount => _tris.Count / 3; internal void Tri(Vector3 a, Vector3 b, Vector3 c) { //IL_0012: 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_002a: 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_0048: 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) int count = _verts.Count; _verts.Add(a); _verts.Add(b); _verts.Add(c); _uvs.Add(Uv); _uvs.Add(Uv); _uvs.Add(Uv); _tris.Add(count); _tris.Add(count + 1); _tris.Add(count + 2); } internal void Quad(Vector3 a, Vector3 b, Vector3 c, Vector3 d) { //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_0003: 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) Tri(a, b, c); Tri(a, c, d); } internal void TriDouble(Vector3 a, Vector3 b, Vector3 c) { //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_0003: 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) Tri(a, b, c); Tri(a, c, b); } internal void TriOut(Vector3 a, Vector3 b, Vector3 c, Vector3 inside) { //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_0008: 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_000e: 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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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_0025: 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_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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_0040: 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_0042: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.Cross(b - a, c - a); Vector3 val2 = (a + b + c) / 3f - inside; if (Vector3.Dot(val, val2) < 0f) { Tri(a, c, b); } else { Tri(a, b, c); } } internal void QuadOut(Vector3 a, Vector3 b, Vector3 c, Vector3 d, Vector3 inside) { //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_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: 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_000e: 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) TriOut(a, b, c, inside); TriOut(a, c, d, inside); } internal Mesh Build(string name) { //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_000c: 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_0025: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown Mesh val = new Mesh { name = name }; val.SetVertices(_verts); val.SetUVs(0, _uvs); val.SetTriangles(_tris, 0); val.RecalculateNormals(); val.RecalculateBounds(); return val; } } internal static class DolphinMesh { private static readonly float[] T = new float[10] { 0f, 0.1f, 0.22f, 0.35f, 0.5f, 0.62f, 0.74f, 0.84f, 0.92f, 1f }; private static readonly float[] R = new float[10] { 0.014f, 0.032f, 0.058f, 0.078f, 0.088f, 0.085f, 0.072f, 0.052f, 0.03f, 0.009f }; private const int Segments = 8; private const float Length = 0.95f; internal static Mesh Build() { //IL_001d: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) MeshBuilder meshBuilder = new MeshBuilder(); for (int i = 0; i < T.Length - 1; i++) { for (int j = 0; j < 8; j++) { int s = (j + 1) % 8; meshBuilder.Quad(Ring(i, j), Ring(i, s), Ring(i + 1, s), Ring(i + 1, j)); } } Vector3 b = default(Vector3); ((Vector3)(ref b))..ctor(0f, Lift(1f), Z(1f) + 0.03f); Vector3 b2 = default(Vector3); ((Vector3)(ref b2))..ctor(0f, Lift(0f), Z(0f) - 0.02f); for (int k = 0; k < 8; k++) { int s2 = (k + 1) % 8; meshBuilder.Tri(Ring(T.Length - 1, k), b, Ring(T.Length - 1, s2)); meshBuilder.Tri(Ring(0, s2), b2, Ring(0, k)); } AddDorsal(meshBuilder, Z, Lift); AddPectorals(meshBuilder, Z, Lift); AddFlukes(meshBuilder, Z, Lift); Mesh val = meshBuilder.Build("MoreFish_Dolphin"); ManualLogSource log = Plugin.Log; object arg = meshBuilder.TriangleCount; Bounds bounds = val.bounds; log.LogInfo((object)$"Built dolphin mesh: {arg} triangles, bounds {((Bounds)(ref bounds)).size}."); return val; static float Lift(float t) { return Mathf.Sin(t * MathF.PI) * 0.012f + Mathf.Max(0f, t - 0.72f) * 0.1f; } static Vector3 Ring(int num4, int num2) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) float num = (float)num2 / 8f * MathF.PI * 2f; float num3 = Mathf.Cos(num) * R[num4] * 1.15f + Lift(T[num4]); return new Vector3(Mathf.Sin(num) * R[num4] * 0.92f, num3, Z(T[num4])); } static float Z(float t) { return (t - 0.5f) * 0.95f; } } private static void AddDorsal(MeshBuilder b, Func Z, Func Lift) { //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_00a0: Unknown result type (might be due to invalid IL or missing references) float arg = 0.58f; float arg2 = 0.44f; Vector3 a = default(Vector3); ((Vector3)(ref a))..ctor(0f, R[4] * 1.15f + Lift(arg) - 0.005f, Z(arg)); Vector3 c = default(Vector3); ((Vector3)(ref c))..ctor(0f, R[3] * 1.15f + Lift(arg2) - 0.005f, Z(arg2)); Vector3 b2 = default(Vector3); ((Vector3)(ref b2))..ctor(0f, R[4] * 1.15f + Lift(arg) + 0.085f, Z(arg2) - 0.03f); b.TriDouble(a, b2, c); } private static void AddPectorals(MeshBuilder b, Func Z, Func Lift) { //IL_0097: 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) float num = 0.7f; float num2 = Lift(num) - 0.02f; Vector3 a = default(Vector3); Vector3 c = default(Vector3); Vector3 b2 = default(Vector3); for (int i = -1; i <= 1; i += 2) { ((Vector3)(ref a))..ctor((float)i * R[6] * 0.75f, num2, Z(num + 0.04f)); ((Vector3)(ref c))..ctor((float)i * R[6] * 0.75f, num2 - 0.02f, Z(num - 0.05f)); ((Vector3)(ref b2))..ctor((float)i * (R[6] + 0.1f), num2 - 0.05f, Z(num - 0.11f)); b.TriDouble(a, b2, c); } } private static void AddFlukes(MeshBuilder b, Func Z, Func Lift) { //IL_006c: 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_006f: Unknown result type (might be due to invalid IL or missing references) float num = 0.03f; float num2 = Lift(num); Vector3 c = default(Vector3); ((Vector3)(ref c))..ctor(0f, num2, Z(num) - 0.02f); Vector3 a = default(Vector3); ((Vector3)(ref a))..ctor(0f, num2, Z(num + 0.09f)); Vector3 b2 = default(Vector3); for (int i = -1; i <= 1; i += 2) { ((Vector3)(ref b2))..ctor((float)i * 0.155f, num2 + 0.012f, Z(num) - 0.055f); b.TriDouble(a, b2, c); } } } internal sealed class Morph { internal string Key; internal string NameFormat; internal Vector2 ColorOffset; internal Vector2 ColorOffset2; internal bool UseSkin = true; internal bool Rainbow; internal SkinNoise Noise; internal SkinAffects Affects = (SkinAffects)2; internal Vector2 SmoothStep = new Vector2(0.5f, 0.5f); internal float NoiseScale = 0.5f; internal float NoiseRotation; internal float UVRotation = -89.44f; internal Vector2 UVScale = Vector2.one; internal float MetallicMetallicness = 0.02f; internal float MetallicSmoothness = 0.02f; internal float PlasticMetallicness; internal float PlasticSmoothness; internal float Emission; internal Color FallbackTint = Color.white; internal float Scale = 1f; internal float WorthMultiplier = 2f; internal float WeightMultiplier = 1f; internal float Rarity = 0.07f; } internal static class MorphCatalog { internal static readonly List All = new List { new Morph { Key = "albino", NameFormat = "Albino {0}", ColorOffset = new Vector2(0f, 0.56f), SmoothStep = new Vector2(0f, 1f), NoiseScale = 11.19f, PlasticSmoothness = 0.3f, FallbackTint = new Color(0.96f, 0.93f, 0.9f), Scale = 1.12f, WorthMultiplier = 2.5f, WeightMultiplier = 1.12f, Rarity = 0.085f }, new Morph { Key = "melanistic", NameFormat = "Melanistic {0}", ColorOffset = new Vector2(-2.8f, 1.59f), SmoothStep = new Vector2(0.4f, 0.4f), NoiseScale = 0.4f, UVRotation = 40.24f, PlasticSmoothness = 0.15f, FallbackTint = new Color(0.16f, 0.17f, 0.2f), Scale = 1.1f, WorthMultiplier = 2.5f, WeightMultiplier = 1.1f, Rarity = 0.085f }, new Morph { Key = "ember", NameFormat = "Ember {0}", ColorOffset = new Vector2(1.1f, 0.35f), PlasticSmoothness = 0.3f, FallbackTint = new Color(0.85f, 0.35f, 0.16f), Scale = 1.08f, WorthMultiplier = 2.5f, WeightMultiplier = 1.08f, Rarity = 0.085f }, new Morph { Key = "tidal", NameFormat = "Tidal {0}", ColorOffset = new Vector2(1.62f, 0.35f), PlasticSmoothness = 0.3f, FallbackTint = new Color(0.22f, 0.45f, 0.82f), Scale = 1.08f, WorthMultiplier = 2.5f, WeightMultiplier = 1.08f, Rarity = 0.085f }, new Morph { Key = "coral", NameFormat = "Coral {0}", ColorOffset = new Vector2(1.96f, 0.35f), ColorOffset2 = new Vector2(0f, 0.03f), PlasticSmoothness = 0.35f, FallbackTint = new Color(0.93f, 0.45f, 0.55f), Scale = 1.06f, WorthMultiplier = 2.5f, WeightMultiplier = 1.06f, Rarity = 0.08f }, new Morph { Key = "tiger", NameFormat = "Tiger {0}", ColorOffset = new Vector2(-2.8f, 0.66f), ColorOffset2 = new Vector2(0f, 0.67f), NoiseScale = 5.23f, UVRotation = 140.96f, UVScale = new Vector2(18.79f, 1f), FallbackTint = new Color(0.91f, 0.59f, 0.16f), Scale = 1.2f, WorthMultiplier = 3f, WeightMultiplier = 1.2f, Rarity = 0.055f }, new Morph { Key = "spotted", NameFormat = "Spotted {0}", ColorOffset = new Vector2(-2.8f, 1.59f), ColorOffset2 = new Vector2(0f, 0.04f), SmoothStep = new Vector2(0.4f, 0.4f), NoiseScale = 42.8f, UVRotation = 40.24f, FallbackTint = new Color(0.9f, 0.9f, 0.92f), Scale = 1.1f, WorthMultiplier = 3f, WeightMultiplier = 1.1f, Rarity = 0.055f }, new Morph { Key = "marbled", NameFormat = "Marbled {0}", ColorOffset = new Vector2(-5.88f, 3.02f), ColorOffset2 = new Vector2(0f, -2.11f), Affects = (SkinAffects)2, SmoothStep = new Vector2(-2.3f, 2.7f), NoiseScale = 15f, UVRotation = 90f, UVScale = new Vector2(7.11f, 1f), FallbackTint = new Color(0.55f, 0.45f, 0.34f), Scale = 1.15f, WorthMultiplier = 3f, WeightMultiplier = 1.15f, Rarity = 0.055f }, new Morph { Key = "camo", NameFormat = "Camo {0}", ColorOffset = new Vector2(1.12f, -0.06f), ColorOffset2 = new Vector2(0f, 0.96f), NoiseScale = 84f, UVRotation = 0f, FallbackTint = new Color(0.36f, 0.44f, 0.28f), Scale = 1.12f, WorthMultiplier = 3f, WeightMultiplier = 1.12f, Rarity = 0.055f }, new Morph { Key = "harlequin", NameFormat = "Harlequin {0}", ColorOffset = new Vector2(0f, 1.74f), ColorOffset2 = new Vector2(0f, 0.45f), Noise = (SkinNoise)1, SmoothStep = new Vector2(0.35f, 1.05f), NoiseScale = 24.36f, UVRotation = 45f, FallbackTint = new Color(0.85f, 0.85f, 0.88f), Scale = 1.1f, WorthMultiplier = 3.5f, WeightMultiplier = 1.1f, Rarity = 0.045f }, new Morph { Key = "hazard", NameFormat = "Hazard {0}", ColorOffset = new Vector2(1.31f, 18.33f), ColorOffset2 = new Vector2(0f, 2.08f), Noise = (SkinNoise)1, SmoothStep = new Vector2(0.3f, 0.3f), NoiseScale = 33.22f, UVRotation = 45f, UVScale = new Vector2(0.001f, 1f), FallbackTint = new Color(0.95f, 0.78f, 0.16f), Scale = 1.1f, WorthMultiplier = 3.5f, WeightMultiplier = 1.1f, Rarity = 0.045f }, new Morph { Key = "polka", NameFormat = "Polka {0}", ColorOffset = new Vector2(-1.18f, 0.27f), ColorOffset2 = new Vector2(2.96f, 4.1f), Noise = (SkinNoise)1, SmoothStep = new Vector2(0f, 1f), NoiseScale = 4f, UVRotation = 45f, UVScale = new Vector2(15f, 0.1f), FallbackTint = new Color(0.92f, 0.55f, 0.72f), Scale = 1.08f, WorthMultiplier = 3.5f, WeightMultiplier = 1.08f, Rarity = 0.045f }, new Morph { Key = "golden", NameFormat = "Golden {0}", ColorOffset = new Vector2(3.23f, 0.1f), Affects = (SkinAffects)2, SmoothStep = new Vector2(0f, 1f), NoiseScale = 11.19f, MetallicMetallicness = 1f, MetallicSmoothness = 0.5f, PlasticMetallicness = 1f, PlasticSmoothness = 0.5f, FallbackTint = new Color(0.91f, 0.73f, 0.24f), Scale = 1.18f, WorthMultiplier = 4.5f, WeightMultiplier = 1.18f, Rarity = 0.03f }, new Morph { Key = "chrome", NameFormat = "Chrome {0}", ColorOffset = new Vector2(0.58f, 0.1f), Affects = (SkinAffects)2, SmoothStep = new Vector2(0f, 1f), NoiseScale = 29.6f, UVRotation = 0f, MetallicMetallicness = 1f, MetallicSmoothness = 0.9f, PlasticMetallicness = 1f, PlasticSmoothness = 0.9f, FallbackTint = new Color(0.84f, 0.87f, 0.9f), Scale = 1.14f, WorthMultiplier = 4.5f, WeightMultiplier = 1.14f, Rarity = 0.03f }, new Morph { Key = "verdant", NameFormat = "Verdant {0}", ColorOffset = new Vector2(2.39f, 1.32f), SmoothStep = new Vector2(0f, 1f), NoiseScale = 0.36f, UVRotation = 0f, MetallicMetallicness = 1f, MetallicSmoothness = 0.5f, FallbackTint = new Color(0.24f, 0.62f, 0.34f), Scale = 1.14f, WorthMultiplier = 4f, WeightMultiplier = 1.14f, Rarity = 0.035f }, new Morph { Key = "ruby", NameFormat = "Ruby {0}", ColorOffset = new Vector2(-5.96f, 1.35f), SmoothStep = new Vector2(0.4f, 0.61f), NoiseScale = 0.73f, UVRotation = -118.83f, MetallicMetallicness = 1f, MetallicSmoothness = 0.4f, FallbackTint = new Color(0.76f, 0.13f, 0.2f), Scale = 1.14f, WorthMultiplier = 4f, WeightMultiplier = 1.14f, Rarity = 0.035f }, new Morph { Key = "glacial", NameFormat = "Glacial {0}", ColorOffset = new Vector2(5.99f, 1.51f), SmoothStep = new Vector2(0f, 1f), NoiseScale = 3f, UVRotation = 0f, MetallicMetallicness = 0.6f, MetallicSmoothness = 0.95f, PlasticSmoothness = 0.85f, Emission = 1.5f, FallbackTint = new Color(0.78f, 0.9f, 0.96f), Scale = 1.22f, WorthMultiplier = 4f, WeightMultiplier = 1.22f, Rarity = 0.03f }, new Morph { Key = "molten", NameFormat = "Molten {0}", ColorOffset = new Vector2(1.1f, 0.35f), Affects = (SkinAffects)2, SmoothStep = new Vector2(0.2f, 0.8f), NoiseScale = 6f, MetallicMetallicness = 0.4f, MetallicSmoothness = 0.6f, Emission = 7f, FallbackTint = new Color(0.95f, 0.35f, 0.1f), Scale = 1.18f, WorthMultiplier = 5f, WeightMultiplier = 1.18f, Rarity = 0.02f }, new Morph { Key = "spectral", NameFormat = "Spectral {0}", ColorOffset = new Vector2(-4.82f, 4.21f), Noise = (SkinNoise)2, SmoothStep = new Vector2(0.4f, 0.61f), NoiseScale = 3.08f, UVRotation = -138.13f, MetallicMetallicness = 1f, MetallicSmoothness = 0.4f, PlasticMetallicness = 1f, PlasticSmoothness = 0.4f, Emission = 5f, FallbackTint = new Color(0.6f, 0.44f, 0.94f), Scale = 1.05f, WorthMultiplier = 5.5f, WeightMultiplier = 1f, Rarity = 0.015f }, new Morph { Key = "prismatic", NameFormat = "Prismatic {0}", ColorOffset = new Vector2(-1.81f, -1.13f), ColorOffset2 = new Vector2(8.82f, 0.44f), Rainbow = true, SmoothStep = new Vector2(0f, 1f), NoiseScale = 0.27f, UVRotation = -301.4f, MetallicMetallicness = 1f, MetallicSmoothness = 0.6f, Emission = 2f, FallbackTint = new Color(0.95f, 0.45f, 0.85f), Scale = 1.1f, WorthMultiplier = 7f, WeightMultiplier = 1.1f, Rarity = 0.008f }, new Morph { Key = "armed", NameFormat = "Armed {0}", ColorOffset = new Vector2(1.12f, -0.06f), ColorOffset2 = new Vector2(0f, 0.96f), Affects = (SkinAffects)2, NoiseScale = 30f, UVRotation = 0f, MetallicMetallicness = 0.5f, MetallicSmoothness = 0.4f, PlasticSmoothness = 0.3f, FallbackTint = new Color(0.3f, 0.34f, 0.26f), Scale = 1.15f, WeightMultiplier = 1.15f, Rarity = 0.03f }, new Morph { Key = "outlaw", NameFormat = "Outlaw {0}", ColorOffset = new Vector2(3.23f, 0.1f), ColorOffset2 = new Vector2(0f, 0.67f), Affects = (SkinAffects)2, SmoothStep = new Vector2(0.35f, 0.9f), NoiseScale = 5.23f, UVRotation = 140.96f, UVScale = new Vector2(18.79f, 1f), MetallicMetallicness = 1f, MetallicSmoothness = 0.55f, PlasticMetallicness = 0.4f, PlasticSmoothness = 0.4f, Emission = 1.5f, FallbackTint = new Color(0.72f, 0.58f, 0.2f), Scale = 1.25f, WeightMultiplier = 1.25f, Rarity = 0.012f } }; internal static Morph At(int index) { if (index < 0 || index >= All.Count) { return null; } return All[index]; } internal static int IndexOf(string key) { for (int i = 0; i < All.Count; i++) { if (All[i].Key == key) { return i; } } return -1; } } internal static class MorphSkin { private const BindingFlags All = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; private static bool _warnedNoShaderManager; internal static ItemSkin Build(Morph morph) { //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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) object obj = (object)default(ItemSkin); Type? typeFromHandle = typeof(ItemSkin); Set(typeFromHandle, obj, "_name", "MoreFish_" + morph.Key); Set(typeFromHandle, obj, "_rarity", (object)(Rarity)2); Set(typeFromHandle, obj, "_useSkin", morph.UseSkin); Set(typeFromHandle, obj, "_isRainbowSkin", morph.Rainbow); Set(typeFromHandle, obj, "_colorOffset", morph.ColorOffset); Set(typeFromHandle, obj, "_colorOffset2", morph.ColorOffset2); Set(typeFromHandle, obj, "_skinAffects", morph.Affects); Set(typeFromHandle, obj, "_noiseType", morph.Noise); Set(typeFromHandle, obj, "_skinSmoothStep", morph.SmoothStep); Set(typeFromHandle, obj, "_skinNoiseScale", morph.NoiseScale); Set(typeFromHandle, obj, "_noiseRotation", morph.NoiseRotation); Set(typeFromHandle, obj, "_uvRotation", morph.UVRotation); Set(typeFromHandle, obj, "_skinUVScale", morph.UVScale); Set(typeFromHandle, obj, "_metallicMetallicness", morph.MetallicMetallicness); Set(typeFromHandle, obj, "_metallicSmoothness", morph.MetallicSmoothness); Set(typeFromHandle, obj, "_plasticMetallicness", morph.PlasticMetallicness); Set(typeFromHandle, obj, "_plasticSmoothness", morph.PlasticSmoothness); return (ItemSkin)obj; } private static void Set(Type t, object boxed, string field, object value) { FieldInfo field2 = t.GetField(field, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field2 == null) { Plugin.Log.LogWarning((object)("ItemSkin field '" + field + "' not found - the game may have been updated.")); } else { field2.SetValue(boxed, value); } } internal static bool UsesSkinShader(Renderer r) { Material sharedMaterial = r.sharedMaterial; if ((Object)(object)sharedMaterial != (Object)null && (Object)(object)sharedMaterial.shader != (Object)null) { return ((Object)sharedMaterial.shader).name.Contains("DefaultShader"); } return false; } internal static void ApplyTo(GameObject go, Morph morph) { Renderer[] componentsInChildren = go.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { ApplyToRenderer(componentsInChildren[i], morph); } } internal static void ApplyToRenderer(Renderer r, Morph morph) { //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_0027: 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_006a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)r != (Object)null && (Object)(object)((Component)r).GetComponent() != (Object)null) { return; } ItemSkin val = Build(morph); try { if (UsesSkinShader(r)) { ShaderManager.ApplyItemSkin(val, r, false); } else { Material material = r.material; if (material.HasProperty("_BaseColor")) { material.SetColor("_BaseColor", morph.FallbackTint); } if (material.HasProperty("_Color")) { material.SetColor("_Color", morph.FallbackTint); } } if (morph.Emission > 0f) { Material material2 = r.material; if (material2.HasProperty("_Emission")) { material2.SetFloat("_Emission", morph.Emission); } } } catch (Exception ex) { if (!_warnedNoShaderManager) { _warnedNoShaderManager = true; Plugin.Log.LogWarning((object)("Could not apply skin to '" + ((Object)r).name + "': " + ex.Message + ". ShaderManager may not be initialised yet.")); } } } } internal static class MorphState { internal const byte Unassigned = 0; internal const byte Plain = byte.MaxValue; internal static int ForcedMorph = -1; internal static int IndexOf(Item item) { if ((Object)(object)item == (Object)null) { return -1; } if ((Object)(object)item.Creature == (Object)null) { return -1; } byte value = item._curSkin.Value; if (value == 0 || value == byte.MaxValue) { return -1; } int num = value - 1; if (num >= MorphCatalog.All.Count) { return -1; } return num; } internal static Morph Of(Item item) { return MorphCatalog.At(IndexOf(item)); } internal static void RollIfNeeded(Creature creature) { if (!((Object)(object)creature == (Object)null) && ((Item)creature)._curSkin.Value == 0) { if (!SpeciesRegistry.IsMorphable(creature)) { ((Item)creature)._curSkin.Value = byte.MaxValue; } else { ((Item)creature)._curSkin.Value = Roll(); } } } private static byte Roll() { if (ForcedMorph >= 0 && ForcedMorph < MorphCatalog.All.Count) { return (byte)(ForcedMorph + 1); } float num = Mathf.Clamp01(Plugin.MorphChance * Plugin.RarityMultiplier); if (Random.value >= num) { return byte.MaxValue; } float num2 = 0f; foreach (Morph item in MorphCatalog.All) { if (Plugin.IsMorphEnabled(item.Key)) { num2 += item.Rarity; } } if (num2 <= 0f) { return byte.MaxValue; } float num3 = Random.Range(0f, num2); float num4 = 0f; for (int i = 0; i < MorphCatalog.All.Count; i++) { Morph morph = MorphCatalog.All[i]; if (Plugin.IsMorphEnabled(morph.Key)) { num4 += morph.Rarity; if (num3 <= num4) { return (byte)(i + 1); } } } return byte.MaxValue; } internal static float ScaleFor(Creature creature) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)creature == (Object)null) { return 1f; } float num = Of((Item)(object)creature)?.Scale ?? 1f; CustomSpeciesTag component = ((Component)creature).GetComponent(); if ((Object)(object)component != (Object)null) { num *= component.BodyScale; } float num2 = 1f; if (Plugin.SizeVariation && (int)creature.BossType == 0) { num2 = 1f + (((Item)creature).RandomizedWeight - 1f) * Plugin.SizeVariationStrength; } return Mathf.Clamp(num * num2, 0.35f, 9f); } internal static void Apply(Creature creature) { //IL_0011: 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) if ((Object)(object)creature == (Object)null) { return; } try { ((Component)creature).transform.localScale = Vector3.one * ScaleFor(creature); Morph morph = Of((Item)(object)creature); if (morph != null) { MorphSkin.ApplyTo(((Component)creature).gameObject, morph); Ability ability = AbilityCatalog.For(morph); if (ability.IsArmed && Plugin.HostileVariants) { (((Component)creature).GetComponent() ?? ((Component)creature).gameObject.AddComponent()).Bind(creature, ability); } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not apply morph to '" + ((Object)creature).name + "': " + ex.Message)); } } internal static string NameFor(Item item, string speciesName) { Morph morph = Of(item); if (morph != null) { return string.Format(morph.NameFormat, speciesName); } return speciesName; } internal static string KeyFor(Creature creature) { Morph morph = Of((Item)(object)creature); if (morph == null) { return null; } if (SpeciesRegistry.IndexOf(creature) < 0) { return null; } return SpeciesRegistry.Normalize(((Object)creature).name) + "/" + morph.Key; } internal static string KeyFor(Creature species, Morph morph) { if ((Object)(object)species == (Object)null || morph == null) { return null; } return SpeciesRegistry.Normalize(((Object)species).name) + "/" + morph.Key; } } [HarmonyPatch(typeof(Creature), "OnStartServer")] internal static class CreatureOnStartServerPatch { private static void Postfix(Creature __instance) { SpeciesRegistry.EnsureLoaded(); MorphState.RollIfNeeded(__instance); } } [HarmonyPatch(typeof(Creature), "OnStartClient")] internal static class CreatureOnStartClientPatch { private static void Postfix(Creature __instance) { if (!((Object)(object)__instance == (Object)null)) { (((Component)__instance).GetComponent() ?? ((Component)__instance).gameObject.AddComponent()).Bind(__instance); } } } [HarmonyPatch(typeof(Creature), "LoadFromSave")] internal static class CreatureLoadFromSavePatch { private static void Postfix(Creature __instance, SavedItem savedItem) { if (!((Object)(object)__instance == (Object)null) && savedItem != null) { ((Item)__instance)._curSkin.Value = savedItem.SkinIndex; } } } [HarmonyPatch(typeof(Creature), "OnDeath")] internal static class CreatureOnDeathPatch { private static void Postfix(Creature __instance) { CaughtLog.Record(__instance); } } [HarmonyPatch(typeof(NetworkManager), "Awake")] internal static class CustomSpeciesNetworkPatch { private static void Postfix(NetworkManager __instance) { CustomSpecies.RegisterWithFishNet(__instance); } } [HarmonyPatch(typeof(GameInfo), "Awake")] internal static class CustomSpeciesGamePatch { private static void Postfix() { CustomSpecies.RegisterWithGame(); } } [HarmonyPatch(typeof(GameInfo), "HasKilledAllCreatures")] internal static class HasKilledAllCreaturesPatch { private static void Postfix(bool checkDrip, ref bool __result) { if (CustomSpecies.Added.Count == 0) { return; } List list = Reflect.GetStatic>(typeof(GameInfo), "_allCreatures"); if (list == null) { return; } foreach (Creature item in list) { if (!((Object)(object)item == (Object)null) && !item.ExcludeFromJournal && !CustomSpecies.IsCustom(item) && !SaveManager.HasKilledCreature(((Item)item).ID, checkDrip)) { __result = false; return; } } __result = true; } } [HarmonyPatch(typeof(Item), "GetName")] internal static class ItemGetNamePatch { private static void Postfix(Item __instance, ref string __result) { CustomSpeciesTag customSpeciesTag = (((Object)(object)__instance == (Object)null) ? null : ((Component)__instance).GetComponent()); if ((Object)(object)customSpeciesTag != (Object)null && !string.IsNullOrEmpty(customSpeciesTag.DisplayName)) { __result = customSpeciesTag.DisplayName; } __result = MorphState.NameFor(__instance, __result); } } [HarmonyPatch(/*Could not decode attribute arguments.*/)] internal static class ItemTotalWorthPatch { private static void Postfix(Item __instance, ref int __result) { if (MorphState.Of(__instance) != null) { __result = Mathf.Max(1, Mathf.RoundToInt((float)__result * AbilityCatalog.For(__instance).Worth)); } } } [HarmonyPatch(typeof(Item), "PickUp")] internal static class ItemPickUpPatch { private static void Postfix(Item __instance) { Creature val = (((Object)(object)__instance == (Object)null) ? null : ((Component)__instance).GetComponent()); if ((Object)(object)val != (Object)null) { MorphState.Apply(val); } } } internal sealed class MorphApplier : MonoBehaviour { private Creature _creature; private bool _subscribed; internal void Bind(Creature creature) { _creature = creature; if (!((Object)(object)_creature == (Object)null)) { if (!_subscribed) { ((Item)_creature)._curSkin.OnChange += OnMorphChanged; _subscribed = true; } MorphState.Apply(_creature); } } private void OnMorphChanged(byte prev, byte next, bool asServer) { MorphState.Apply(_creature); } private void OnDestroy() { if (_subscribed && (Object)(object)_creature != (Object)null) { ((Item)_creature)._curSkin.OnChange -= OnMorphChanged; } } } [HarmonyPatch(/*Could not decode attribute arguments.*/)] internal static class HpToRestorePatch { private static void Postfix(Creature __instance, ref int __result) { Ability ability = AbilityCatalog.For((Item)(object)__instance); if (ability.Heal != 1f) { __result = Mathf.Max(0, Mathf.RoundToInt((float)__result * ability.Heal)); } } } [HarmonyPatch(/*Could not decode attribute arguments.*/)] internal static class FullnessToRestorePatch { private static void Postfix(Creature __instance, ref int __result) { Ability ability = AbilityCatalog.For((Item)(object)__instance); if (ability.Fullness != 1f) { __result = Mathf.Max(0, Mathf.RoundToInt((float)__result * ability.Fullness)); } } } [HarmonyPatch(/*Could not decode attribute arguments.*/)] internal static class MaxHpPatch { private static void Postfix(Creature __instance, ref int __result) { Ability ability = AbilityCatalog.For((Item)(object)__instance); if (ability.Hp != 1f) { __result = Mathf.Max(1, Mathf.RoundToInt((float)__result * ability.Hp)); } } } [HarmonyPatch(typeof(Server), "RpcLogic___FinishEatingCreature___1039939981")] internal static class FinishEatingCreaturePatch { private static void Postfix(Creature __0, Player __1) { if ((Object)(object)__0 == (Object)null || (Object)(object)__1 == (Object)null || (Object)(object)__1.Vitals == (Object)null) { return; } Ability ability = AbilityCatalog.For((Item)(object)__0); try { if (ability.PoisonOnEat) { __1.Vitals.ApplyNewPoison(); } if (ability.FireOnEat) { __1.Vitals.ApplyNewFire(); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not apply an eat effect: " + ex.Message)); } } } [HarmonyPatch(typeof(Item), "Hover")] internal static class ItemHoverPatch { internal static Item Current; private static void Prefix(Item __instance) { Current = __instance; } private static void Postfix() { Current = null; } } [HarmonyPatch(typeof(PlayerUI), "SetLookAtText")] internal static class SetLookAtTextPatch { internal static string LastOriginal; internal static string LastInjected; private static void Prefix(ref string text) { if (!Plugin.ShowAbilityOnHover || string.IsNullOrEmpty(text)) { return; } Item current = ItemHoverPatch.Current; if (!((Object)(object)current == (Object)null)) { Ability ability = AbilityCatalog.For(current); if (!string.IsNullOrEmpty(ability.Name)) { string lastOriginal = text; int num = text.IndexOf('\n'); string text2 = "\n" + ability.Name + " " + ability.Blurb + ""; text = ((num < 0) ? (text + text2) : text.Insert(num, text2)); LastOriginal = lastOriginal; LastInjected = text; } } } } [HarmonyPatch(typeof(PlayerUI), "HideLookAtText")] internal static class HideLookAtTextPatch { private static void Prefix(ref string text) { if (text != null && text == SetLookAtTextPatch.LastOriginal) { text = SetLookAtTextPatch.LastInjected; } } } [HarmonyPatch(typeof(Fish), "UpdateMovement")] internal static class FishUpdateMovementPatch { private static bool Prefix(Fish __instance) { ArmedBehaviour component = ((Component)__instance).GetComponent(); if (!((Object)(object)component == (Object)null)) { return !component.Charge(); } return true; } } [HarmonyPatch(typeof(Crab), "UpdateMovement")] internal static class CrabUpdateMovementPatch { private static bool Prefix(Crab __instance) { ArmedBehaviour component = ((Component)__instance).GetComponent(); if (!((Object)(object)component == (Object)null)) { return !component.Charge(); } return true; } } [BepInPlugin("com.scarletttech.howtofish.morefish", "More Fish", "1.0.2")] public class Plugin : BaseUnityPlugin { internal const string Guid = "com.scarletttech.howtofish.morefish"; internal static ManualLogSource Log; private static ConfigEntry _rarityMultiplier; private static ConfigEntry _sizeVariation; private static ConfigEntry _sizeVariationStrength; private static ConfigEntry _hueVariationDegrees; private static ConfigEntry _morphChance; private static ConfigEntry _showAbilityOnHover; private static ConfigEntry _hostileVariants; private static ConfigEntry _customSpeciesRarity; private static ConfigEntry _hostileWeaponScale; private static ConfigEntry _debugEnabled; private static ConfigEntry _debugPanelKey; private static ConfigEntry _journalVariantBrowser; private static ConfigEntry _journalDiagnostics; private static ConfigEntry _journalClickRadius; private static ConfigEntry _trophiesEnabled; private static ConfigEntry _trophyKey; private static ConfigEntry _trophyConsumesFish; private static ConfigEntry _trophySizeFromWeight; private static ConfigEntry _trophyScale; private static ConfigEntry _trophyReach; private static ConfigEntry _trophyLabels; private static ConfigEntry _trophyLabelDrop; private static ConfigEntry _trophySurfaceOffset; private static ConfigEntry _trophyCustomScale; private static ConfigEntry _trophyReturnsFish; private static ConfigEntry _trophyAutoOrient; private static ConfigEntry _trophyPrompt; private static ConfigEntry _trophyWallsOnly; private static ConfigEntry _trophyWallTolerance; private static ConfigEntry _trophyShowPlaque; private static ConfigEntry _trophyPlaqueColorHex; private static readonly Dictionary> MorphToggles = new Dictionary>(); internal static float RarityMultiplier => _rarityMultiplier?.Value ?? 1f; internal static bool SizeVariation => _sizeVariation?.Value ?? true; internal static float SizeVariationStrength => _sizeVariationStrength?.Value ?? 0.45f; internal static float HueVariationDegrees => _hueVariationDegrees?.Value ?? 8f; internal static float MorphChance => _morphChance?.Value ?? 0.22f; internal static bool ShowAbilityOnHover => _showAbilityOnHover?.Value ?? true; internal static bool HostileVariants => _hostileVariants?.Value ?? true; internal static float CustomSpeciesRarity => _customSpeciesRarity?.Value ?? 0.12f; internal static float HostileWeaponScale => _hostileWeaponScale?.Value ?? 0.3f; internal static bool DebugEnabled => _debugEnabled?.Value ?? false; internal static KeyCode DebugPanelKey => (KeyCode)(((??)_debugPanelKey?.Value) ?? 289); internal static bool JournalVariantBrowser => _journalVariantBrowser?.Value ?? true; internal static bool JournalDiagnostics => _journalDiagnostics?.Value ?? false; internal static float JournalClickRadius => _journalClickRadius?.Value ?? 0.12f; internal static bool TrophiesEnabled => _trophiesEnabled?.Value ?? true; internal static KeyCode TrophyKey => (KeyCode)(((??)_trophyKey?.Value) ?? 116); internal static bool TrophyConsumesFish => _trophyConsumesFish?.Value ?? true; internal static bool TrophySizeFromWeight => _trophySizeFromWeight?.Value ?? true; internal static float TrophyScale => _trophyScale?.Value ?? 1f; internal static float TrophyReach => _trophyReach?.Value ?? 5f; internal static bool TrophyLabels => _trophyLabels?.Value ?? true; internal static float TrophyLabelDrop => _trophyLabelDrop?.Value ?? 0.55f; internal static float TrophySurfaceOffset => _trophySurfaceOffset?.Value ?? 0f; internal static float TrophyCustomScale => _trophyCustomScale?.Value ?? 0.35f; internal static bool TrophyReturnsFish => _trophyReturnsFish?.Value ?? true; internal static bool TrophyAutoOrient => _trophyAutoOrient?.Value ?? true; internal static bool TrophyPrompt => _trophyPrompt?.Value ?? true; internal static bool TrophyWallsOnly => _trophyWallsOnly?.Value ?? true; internal static float TrophyWallTolerance => _trophyWallTolerance?.Value ?? 35f; internal static bool TrophyShowPlaque => _trophyShowPlaque?.Value ?? true; internal static Color TrophyPlaqueColor { get { //IL_0035: 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) string text = _trophyPlaqueColorHex?.Value; Color result = default(Color); if (!string.IsNullOrEmpty(text) && ColorUtility.TryParseHtmlString(text, ref result)) { return result; } return new Color(0.36f, 0.24f, 0.14f); } } internal static bool IsMorphEnabled(string morphKey) { if (MorphToggles.TryGetValue(morphKey, out var value)) { return value.Value; } return true; } private void ApplyPatches() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown Harmony val = new Harmony("com.scarletttech.howtofish.morefish"); int num = 0; int num2 = 0; Type[] types = typeof(Plugin).Assembly.GetTypes(); foreach (Type type in types) { if (type.GetCustomAttributes(typeof(HarmonyPatch), inherit: true).Length != 0) { try { val.CreateClassProcessor(type).Patch(); num++; } catch (Exception ex) { num2++; Log.LogError((object)("Patch '" + type.Name + "' failed, that feature is off: " + ex.Message)); } } } Log.LogInfo((object)($"Applied {num} patch classes" + ((num2 > 0) ? $", {num2} FAILED" : "."))); } private void Awake() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Expected O, but got Unknown //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Expected O, but got Unknown //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Expected O, but got Unknown //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Expected O, but got Unknown //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Expected O, but got Unknown //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Expected O, but got Unknown //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Expected O, but got Unknown //IL_03bf: Unknown result type (might be due to invalid IL or missing references) //IL_03c9: Expected O, but got Unknown //IL_0460: Unknown result type (might be due to invalid IL or missing references) //IL_046a: Expected O, but got Unknown //IL_04dd: Unknown result type (might be due to invalid IL or missing references) //IL_04e7: Expected O, but got Unknown //IL_051a: Unknown result type (might be due to invalid IL or missing references) //IL_0524: Expected O, but got Unknown //IL_0602: Unknown result type (might be due to invalid IL or missing references) //IL_0607: Unknown result type (might be due to invalid IL or missing references) //IL_060d: Expected O, but got Unknown //IL_060d: Unknown result type (might be due to invalid IL or missing references) //IL_0614: Unknown result type (might be due to invalid IL or missing references) //IL_061b: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; _rarityMultiplier = ((BaseUnityPlugin)this).Config.Bind("General", "RarityMultiplier", 1f, new ConfigDescription("Scales how often variants are caught. 1 uses the tuned rates, 2 doubles them, 0 disables all of them.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 10f), Array.Empty())); _morphChance = ((BaseUnityPlugin)this).Config.Bind("General", "VariantChance", 0.22f, new ConfigDescription("Base odds that any fish is a variant rather than plain, before RarityMultiplier. Which variant is then picked is weighted by each morph's own rarity.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), Array.Empty())); _sizeVariation = ((BaseUnityPlugin)this).Config.Bind("Individuals", "SizeVariation", true, "Render each fish at a size matching its individual weight. The game already rolls a weight per fish but draws every one at the same size; this makes a heavy fish visibly bigger. Applies to vanilla fish too."); _sizeVariationStrength = ((BaseUnityPlugin)this).Config.Bind("Individuals", "SizeVariationStrength", 0.45f, new ConfigDescription("How much of the weight roll reaches the fish's size. At 0.45 the 0.25x-1.75x weight range renders as roughly 0.66x-1.34x size.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), Array.Empty())); _hueVariationDegrees = ((BaseUnityPlugin)this).Config.Bind("Individuals", "HueVariationDegrees", 8f, new ConfigDescription("Per-fish hue shift in degrees, so no two individuals look quite alike. 0 disables it.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 60f), Array.Empty())); _journalVariantBrowser = ((BaseUnityPlugin)this).Config.Bind("Journal", "VariantBrowser", true, "Click a creature in the Tab journal to page through its variants. Click again or right-click to go back."); _trophiesEnabled = ((BaseUnityPlugin)this).Config.Bind("Trophies", "Enabled", true, "Mount any dead fish on a wall, floor or your boat. Works for every creature, not just bosses."); _trophyKey = ((BaseUnityPlugin)this).Config.Bind("Trophies", "MountKey", (KeyCode)116, "Hold a dead fish, aim at a surface and press this to mount it. Aim at a mounted fish and press it to take it down."); _trophyConsumesFish = ((BaseUnityPlugin)this).Config.Bind("Trophies", "ConsumeFish", true, "Mounting uses up the fish. Only takes effect when you are the host - the game's own destroy call is server-side, so on someone else's world the fish simply stays in hand."); _trophySizeFromWeight = ((BaseUnityPlugin)this).Config.Bind("Trophies", "SizeFromWeight", true, "Mount each fish at a size matching its individual weight, so a record catch is visibly bigger."); _trophyScale = ((BaseUnityPlugin)this).Config.Bind("Trophies", "Scale", 1f, new ConfigDescription("Overall trophy size multiplier.", (AcceptableValueBase)(object)new AcceptableValueRange(0.2f, 5f), Array.Empty())); _trophyReach = ((BaseUnityPlugin)this).Config.Bind("Trophies", "Reach", 5f, new ConfigDescription("How far you can mount or reach a trophy, in metres.", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 20f), Array.Empty())); _trophyLabels = ((BaseUnityPlugin)this).Config.Bind("Trophies", "ShowLabels", true, "Show the fish's name and weight beneath each trophy."); _trophyLabelDrop = ((BaseUnityPlugin)this).Config.Bind("Trophies", "LabelDrop", 0.55f, new ConfigDescription("How far below the fish the label sits, in metres.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 3f), Array.Empty())); _trophySurfaceOffset = ((BaseUnityPlugin)this).Config.Bind("Trophies", "SurfaceOffset", 0f, new ConfigDescription("Gap between the fish and the surface, in metres. 0 sits flush; negative sinks it into the wall.", (AcceptableValueBase)(object)new AcceptableValueRange(-0.5f, 1f), Array.Empty())); _trophyCustomScale = ((BaseUnityPlugin)this).Config.Bind("Trophies", "AddedSpeciesScale", 0.35f, new ConfigDescription("Mounted size of species this mod adds. They keep their relative sizes, so a dolphin still mounts larger than a jellyfish.", (AcceptableValueBase)(object)new AcceptableValueRange(0.05f, 2f), Array.Empty())); _trophyReturnsFish = ((BaseUnityPlugin)this).Config.Bind("Trophies", "ReturnFishOnRemove", true, "Taking a trophy down puts the fish back in the world with its original weight, rather than destroying it. Only takes effect when you are the host, since spawning is server-side."); _trophyAutoOrient = ((BaseUnityPlugin)this).Config.Bind("Trophies", "AutoOrient", true, "Lay each fish flat along the surface instead of reusing its inventory pose, which hangs it at an angle."); _trophyPrompt = ((BaseUnityPlugin)this).Config.Bind("Trophies", "ShowPrompt", true, "Show an on-screen hint when you can mount the fish you are holding, or take down the trophy you are looking at."); _trophyWallsOnly = ((BaseUnityPlugin)this).Config.Bind("Trophies", "WallsOnly", true, "Only allow mounting on walls. Floors and ceilings are what you hit by accident while aiming, and a fish lying flat on the ground is not a trophy."); _trophyWallTolerance = ((BaseUnityPlugin)this).Config.Bind("Trophies", "WallTolerance", 35f, new ConfigDescription("How far a surface may lean from vertical and still count as a wall, in degrees.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 89f), Array.Empty())); _trophyShowPlaque = ((BaseUnityPlugin)this).Config.Bind("Trophies", "ShowPlaque", true, "Hang each fish on a wooden board with a nail, instead of floating it against the wall."); _trophyPlaqueColorHex = ((BaseUnityPlugin)this).Config.Bind("Trophies", "PlaqueColor", "#5C3D24", "Board colour as a hex string."); _journalDiagnostics = ((BaseUnityPlugin)this).Config.Bind("Journal", "ClickDiagnostics", false, "Log the whole journal click path - which input source fired, where the cursor landed, and how far it was from each slot. Turn on only when clicks are not registering."); _journalClickRadius = ((BaseUnityPlugin)this).Config.Bind("Journal", "ClickRadius", 0.12f, new ConfigDescription("How near the cursor must be to a slot's centre, in journal-texture units, for a click to count.", (AcceptableValueBase)(object)new AcceptableValueRange(0.02f, 0.5f), Array.Empty())); _showAbilityOnHover = ((BaseUnityPlugin)this).Config.Bind("General", "ShowAbilityOnHover", true, "Show a variant's ability when you look at it."); _hostileVariants = ((BaseUnityPlugin)this).Config.Bind("General", "HostileVariants", true, "Let Armed and Outlaw variants carry a gun and shoot at players. Turn off for a peaceful sea."); _customSpeciesRarity = ((BaseUnityPlugin)this).Config.Bind("General", "CustomSpeciesRarity", 0.12f, new ConfigDescription("How often species added by this mod are caught, relative to the commonest fish on that bait.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 2f), Array.Empty())); _hostileWeaponScale = ((BaseUnityPlugin)this).Config.Bind("General", "HostileWeaponScale", 0.3f, new ConfigDescription("Gun length as a fraction of the fish's own rendered length. 0.3 means a gun about a third its size.", (AcceptableValueBase)(object)new AcceptableValueRange(0.05f, 1.5f), Array.Empty())); _debugEnabled = ((BaseUnityPlugin)this).Config.Bind("Debug", "Enabled", false, "Enable the in-game debug panel for spawning specific variants and forcing catches."); _debugPanelKey = ((BaseUnityPlugin)this).Config.Bind("Debug", "PanelKey", (KeyCode)289, "Opens and closes the debug panel."); foreach (Morph item in MorphCatalog.All) { MorphToggles[item.Key] = ((BaseUnityPlugin)this).Config.Bind("Morphs", item.Key, true, "Allow the '" + item.Key + "' morph (" + item.NameFormat + ") to be caught, across every species it applies to."); } ApplyPatches(); GameObject val = new GameObject("MoreFish_JournalClickDriver"); Object.DontDestroyOnLoad((Object)val); val.AddComponent(); val.AddComponent(); val.AddComponent(); val.AddComponent(); Log.LogInfo((object)$"More Fish loaded: {MorphCatalog.All.Count} morphs."); AbilityCatalog.LogTable(); } } internal static class Reflect { private const BindingFlags All = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; private static readonly Dictionary Cache = new Dictionary(); internal static FieldInfo Field(Type type, string name) { string key = type.FullName + "." + name; if (Cache.TryGetValue(key, out var value)) { return value; } FieldInfo fieldInfo = null; Type type2 = type; while (type2 != null && fieldInfo == null) { fieldInfo = type2.GetField(name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); type2 = type2.BaseType; } Cache[key] = fieldInfo; return fieldInfo; } internal static bool Set(object target, string name, object value) { if (target == null) { return false; } FieldInfo fieldInfo = Field(target.GetType(), name); if (fieldInfo == null) { Plugin.Log.LogWarning((object)("Field '" + name + "' not found on " + target.GetType().Name + " - the game may have been updated.")); return false; } fieldInfo.SetValue(target, value); return true; } internal static T Get(object target, string name, T fallback = default(T)) { if (target == null) { return fallback; } FieldInfo fieldInfo = Field(target.GetType(), name); if (fieldInfo == null) { Plugin.Log.LogWarning((object)("Field '" + name + "' not found on " + target.GetType().Name + " - the game may have been updated.")); return fallback; } object value = fieldInfo.GetValue(target); if (value is T) { return (T)value; } return fallback; } internal static T GetStatic(Type type, string name) where T : class { FieldInfo fieldInfo = Field(type, name); if (fieldInfo == null) { Plugin.Log.LogWarning((object)("Static field '" + name + "' not found on " + type.Name + " - the game may have been updated.")); return null; } return fieldInfo.GetValue(null) as T; } } internal static class SpeciesCatalog { internal static readonly List All = new List { new SpeciesShape { Name = "Dolphin", EyeAt = 0.88f, EyeScale = 1.15f, Donor = new string[3] { "salmon", "cod", "mackerel" }, Colour = Rgb(112, 128, 145), T = new float[10] { 0f, 0.1f, 0.22f, 0.35f, 0.5f, 0.62f, 0.74f, 0.84f, 0.92f, 1f }, R = new float[10] { 0.02f, 0.046f, 0.082f, 0.11f, 0.124f, 0.12f, 0.101f, 0.073f, 0.042f, 0.013f }, Length = 1.4f, MelonLift = 0.14f, HorizontalTail = true, TailSpan = 0.225f, TailSweep = 0.07f, DorsalHeight = 0.125f, DorsalAt = 0.52f, PectoralSpan = 0.15f, BodyScale = 3f, Worth = 90, Weight = 32f, Hp = 26, Rarity = 0.1f }, new SpeciesShape { Name = "Orca", EyeAt = 0.87f, EyeScale = 1.05f, Donor = new string[3] { "salmon", "cod", "mackerel" }, Colour = Rgb(28, 32, 38), T = new float[10] { 0f, 0.1f, 0.24f, 0.38f, 0.52f, 0.66f, 0.78f, 0.88f, 0.95f, 1f }, R = new float[10] { 0.034f, 0.082f, 0.15f, 0.196f, 0.213f, 0.201f, 0.167f, 0.119f, 0.068f, 0.024f }, Length = 2.45f, MelonLift = 0.15f, MelonAt = 0.78f, HorizontalTail = true, TailSpan = 0.41f, TailSweep = 0.12f, DorsalHeight = 0.44f, DorsalAt = 0.54f, DorsalSweep = 0.09f, PectoralSpan = 0.27f, BodyScale = 1.6f, Worth = 320, Weight = 95f, Hp = 46, Rarity = 0.035f }, new SpeciesShape { Name = "Narwhal", EyeAt = 0.86f, EyeScale = 1.2f, Donor = new string[3] { "salmon", "cod", "mackerel" }, Colour = Rgb(178, 176, 188), T = new float[9] { 0f, 0.12f, 0.26f, 0.4f, 0.55f, 0.7f, 0.84f, 0.94f, 1f }, R = new float[9] { 0.024f, 0.062f, 0.108f, 0.132f, 0.138f, 0.128f, 0.104f, 0.07f, 0.036f }, Length = 1.55f, HeightRatio = 1.02f, WidthRatio = 1f, MelonLift = 0.11f, MelonAt = 0.62f, HorizontalTail = true, TailSpan = 0.25f, TailSweep = 0.08f, PectoralSpan = 0.11f, BillLength = 0.78f, BillRadius = 0.016f, Worth = 380, Weight = 74f, Hp = 38, Rarity = 0.025f }, new SpeciesShape { Name = "Hammerhead", EyeAt = 0.93f, EyeScale = 1.1f, EyeSpread = 2.6f, Donor = new string[3] { "pike", "gar", "salmon" }, Colour = Rgb(122, 132, 138), T = new float[9] { 0f, 0.1f, 0.24f, 0.4f, 0.55f, 0.7f, 0.82f, 0.92f, 1f }, R = new float[9] { 0.014f, 0.036f, 0.07f, 0.09f, 0.092f, 0.08f, 0.06f, 0.04f, 0.02f }, Length = 1.25f, HeightRatio = 1.05f, HorizontalTail = false, TailSpan = 0.19f, TailSweep = 0.07f, DorsalHeight = 0.16f, DorsalAt = 0.5f, PectoralSpan = 0.17f, HammerSpan = 0.2f, Worth = 260, Weight = 82f, Hp = 40, Rarity = 0.035f }, new SpeciesShape { Name = "Swordfish", EyeAt = 0.84f, EyeScale = 1.25f, Donor = new string[3] { "pike", "gar", "salmon" }, Colour = Rgb(46, 62, 96), T = new float[9] { 0f, 0.1f, 0.24f, 0.4f, 0.56f, 0.7f, 0.82f, 0.92f, 1f }, R = new float[9] { 0.012f, 0.03f, 0.058f, 0.076f, 0.078f, 0.064f, 0.044f, 0.026f, 0.01f }, Length = 1.2f, HeightRatio = 1.3f, TailSpan = 0.17f, TailSweep = 0.08f, DorsalHeight = 0.2f, DorsalAt = 0.58f, PectoralSpan = 0.09f, BillLength = 0.42f, Worth = 230, Weight = 58f, Hp = 32, Rarity = 0.045f }, new SpeciesShape { Name = "Manta Ray", EyeAt = 0.82f, EyeScale = 1.3f, Donor = new string[3] { "halibut", "cod", "salmon" }, Colour = Rgb(52, 58, 70), T = new float[5] { 0f, 0.25f, 0.5f, 0.75f, 1f }, R = new float[5] { 0.01f, 0.03f, 0.052f, 0.038f, 0.014f }, Length = 0.7f, WidthRatio = 1.4f, HeightRatio = 0.45f, WingSpan = 0.62f, WingSweep = 0.22f, TailSpan = 0.02f, TailSweep = 0.3f, Worth = 270, Weight = 88f, Hp = 34, Rarity = 0.035f }, new SpeciesShape { Name = "Sea Turtle", EyeScale = 1.15f, Donor = new string[3] { "rockcrab", "browncrab", "lobster" }, Colour = Rgb(78, 96, 58), R = null, TailSpan = 0f, Length = 0.4f, DomeRadius = 0.3f, DomeHeight = 0.16f, Flippers = 4, HeadRadius = 0.075f, Worth = 185, Weight = 48f, Hp = 52, Rarity = 0.045f }, new SpeciesShape { Name = "Giant Squid", EyeAt = 0.93f, EyeScale = 1.5f, Donor = new string[3] { "eel", "oarfish", "salmon" }, Colour = Rgb(148, 82, 112), T = new float[9] { 0f, 0.14f, 0.3f, 0.48f, 0.66f, 0.8f, 0.9f, 0.96f, 1f }, R = new float[9] { 0.003f, 0.022f, 0.044f, 0.062f, 0.074f, 0.078f, 0.074f, 0.068f, 0.06f }, Length = 1.25f, Segments = 6, HeightRatio = 1f, WidthRatio = 1f, TailSpan = 0f, Tentacles = 10, TentacleLength = 0.95f, TentacleWidth = 0.028f, TentacleAt = 1f, TentacleDir = new Vector3(0f, -0.1f, 1f), MantleFinAt = 0.16f, MantleFinSpan = 0.1f, MantleFinLength = 0.26f, BodyScale = 1.4f, Worth = 300, Weight = 52f, Hp = 28, Rarity = 0.03f }, new SpeciesShape { Name = "Moon Jelly", EyeScale = 1.25f, Donor = new string[3] { "shrimp", "goby", "clownfish" }, Colour = Rgb(198, 214, 232), R = null, DomeRadius = 0.19f, DomeHeight = 0.15f, Tentacles = 10, TentacleLength = 0.34f, TailSpan = 0f, Worth = 70, Weight = 5f, Hp = 8, Rarity = 0.09f }, new SpeciesShape { Name = "Sea Serpent", EyeAt = 0.94f, EyeScale = 1.9f, Donor = new string[3] { "eel", "oarfish", "pike" }, Colour = Rgb(38, 84, 66), T = new float[11] { 0f, 0.08f, 0.18f, 0.3f, 0.42f, 0.54f, 0.66f, 0.78f, 0.88f, 0.95f, 1f }, R = new float[11] { 0.01f, 0.024f, 0.038f, 0.046f, 0.05f, 0.05f, 0.048f, 0.044f, 0.04f, 0.03f, 0.012f }, Length = 2.1f, HeightRatio = 1.25f, TailSpan = 0.12f, TailSweep = 0.1f, DorsalHeight = 0.1f, DorsalAt = 0.62f, PectoralSpan = 0.05f, MelonLift = 0.05f, Curve = 0.26f, CurveWaves = 2.4f, Worth = 620, Weight = 130f, Hp = 64, Rarity = 0.012f } }; private static Color Rgb(int r, int g, int b) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) return new Color((float)r / 255f, (float)g / 255f, (float)b / 255f); } } internal static class SpeciesRegistry { private static List _species; private static Dictionary _indexByName; internal static IReadOnlyList Species { get { EnsureLoaded(); return _species; } } internal static int Count { get { EnsureLoaded(); return _species.Count; } } internal static string Normalize(string name) { if (string.IsNullOrEmpty(name)) { return ""; } for (int num = name.IndexOf("(Clone)", StringComparison.OrdinalIgnoreCase); num >= 0; num = name.IndexOf("(Clone)", StringComparison.OrdinalIgnoreCase)) { name = name.Remove(num, "(Clone)".Length); } return name.Replace(" ", "").Trim().ToLowerInvariant(); } internal static void EnsureLoaded() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (_species != null) { return; } _species = new List(); _indexByName = new Dictionary(); Creature[] array = Resources.LoadAll("Items/Creatures"); foreach (Creature val in array) { if (!((Object)(object)val == (Object)null) && (int)val.BossType == 0) { _species.Add(val); } } _species.Sort((Creature a, Creature b) => string.CompareOrdinal(Normalize(((Object)a).name), Normalize(((Object)b).name))); for (int num = 0; num < _species.Count; num++) { _indexByName[Normalize(((Object)_species[num]).name)] = num; } Plugin.Log.LogInfo((object)($"{_species.Count} species x {MorphCatalog.All.Count} morphs = " + $"{_species.Count * MorphCatalog.All.Count} variants, using no item ids.")); } internal static void Add(Creature c) { EnsureLoaded(); if (!((Object)(object)c == (Object)null)) { string key = Normalize(((Object)c).name); if (!_indexByName.ContainsKey(key)) { _indexByName[key] = _species.Count; _species.Add(c); } } } internal static int IndexOf(Creature c) { EnsureLoaded(); if ((Object)(object)c == (Object)null) { return -1; } if (!_indexByName.TryGetValue(Normalize(((Object)c).name), out var value)) { return -1; } return value; } internal static Creature At(int index) { EnsureLoaded(); if (index < 0 || index >= _species.Count) { return null; } return _species[index]; } internal static bool IsMorphable(Creature c) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)c == (Object)null || (int)c.BossType != 0) { return false; } return !Reflect.Get(c, "_skipRandomizedWeight", fallback: false); } } internal sealed class SpeciesShape { internal string Name; internal string[] Donor = new string[3] { "salmon", "cod", "mackerel" }; internal float[] T = new float[5] { 0f, 0.2f, 0.5f, 0.8f, 1f }; internal float[] R = new float[5] { 0.02f, 0.06f, 0.09f, 0.06f, 0.01f }; internal float Length = 0.9f; internal int Segments = 8; internal float WidthRatio = 0.92f; internal float HeightRatio = 1.15f; internal float MelonAt = 0.72f; internal float MelonLift; internal bool HorizontalTail; internal float TailSpan = 0.16f; internal float TailSweep = 0.05f; internal float DorsalAt = 0.52f; internal float DorsalHeight; internal float DorsalSweep = 0.03f; internal float PectoralAt = 0.7f; internal float PectoralSpan; internal float MantleFinAt = 0.12f; internal float MantleFinSpan; internal float MantleFinLength = 0.3f; internal float BillLength; internal float BillRadius = 0.012f; internal float HammerSpan; internal float WingSpan; internal float WingSweep = 0.28f; internal float Curve; internal float CurveWaves = 1.5f; internal float HeadRadius; internal float DomeRadius; internal float DomeHeight; internal int Flippers; internal int Tentacles; internal float TentacleLength; internal float TentacleWidth = 0.014f; internal float TentacleAt = 0.1f; internal Vector3 TentacleDir = Vector3.down; internal float BodyScale = 1f; internal bool Eyes = true; internal float EyeAt = 0.86f; internal float EyeScale = 1f; internal float EyeSpread; internal Color Colour = Color.grey; internal int Worth = 100; internal float Weight = 20f; internal int Hp = 20; internal float Rarity = 0.1f; } [Serializable] public class TrophyRecord { public string Species; public string Morph; public byte ItemID; public float Weight = 1f; public bool IsDrip; public float PX; public float PY; public float PZ; public float RX; public float RY; public float RZ; public float RW = 1f; [JsonIgnore] public Vector3 Position { get { //IL_0012: Unknown result type (might be due to invalid IL or missing references) return new Vector3(PX, PY, PZ); } set { //IL_0001: 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_0019: Unknown result type (might be due to invalid IL or missing references) PX = value.x; PY = value.y; PZ = value.z; } } [JsonIgnore] public Quaternion Rotation { get { //IL_0018: Unknown result type (might be due to invalid IL or missing references) return new Quaternion(RX, RY, RZ, RW); } set { //IL_0001: 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_0019: 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) RX = value.x; RY = value.y; RZ = value.z; RW = value.w; } } } [Serializable] public class TrophyFile { public List Trophies = new List(); } internal static class TrophyStore { private static string PathFor(string worldName) { return Application.persistentDataPath + "/Saves/" + worldName + ".morefish-trophies.json"; } internal static TrophyFile Load(string worldName) { try { string path = PathFor(worldName); if (!File.Exists(path)) { return new TrophyFile(); } TrophyFile trophyFile = JsonConvert.DeserializeObject(File.ReadAllText(path)); if (trophyFile == null) { return new TrophyFile(); } if (trophyFile.Trophies == null) { trophyFile.Trophies = new List(); } return trophyFile; } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not read trophies for '" + worldName + "': " + ex.Message)); return new TrophyFile(); } } internal static void Save(string worldName, TrophyFile file) { try { string path = Application.persistentDataPath + "/Saves/"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } string contents = JsonConvert.SerializeObject((object)file, (Formatting)1); File.WriteAllText(PathFor(worldName), contents); Plugin.Log.LogInfo((object)$"Trophies: saved {file.Trophies.Count} for '{worldName}'."); } catch (Exception ex) { Plugin.Log.LogError((object)("Could not write trophies for '" + worldName + "': " + ex.Message)); } } } internal sealed class TrophyLabelBillboard : MonoBehaviour { private void LateUpdate() { //IL_001c: 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_002c: Unknown result type (might be due to invalid IL or missing references) Camera curCamera = GameInfo.CurCamera; if (!((Object)(object)curCamera == (Object)null)) { ((Component)this).transform.rotation = Quaternion.LookRotation(((Component)curCamera).transform.forward, ((Component)curCamera).transform.up); } } } internal sealed class TrophyDriver : MonoBehaviour { private string _lastWorld; private int _lastScene; private void Update() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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_0078: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.TrophiesEnabled) { return; } TrackWorldChanges(); if (!Input.GetKeyDown(Plugin.TrophyKey) || PauseManager.IsPaused || PlayerThinking.IsThinking || ChatManager.IsTyping) { return; } Player localPlayer = Player.LocalPlayer; Camera curCamera = GameInfo.CurCamera; if (!((Object)(object)localPlayer == (Object)null) && !((Object)(object)curCamera == (Object)null)) { Ray ray = default(Ray); ((Ray)(ref ray))..ctor(((Component)curCamera).transform.position, ((Component)curCamera).transform.forward); if (!TryMount(localPlayer, ray) && TrophyManager.UnmountNearest(ray, Plugin.TrophyReach, 0.45f)) { Plugin.Log.LogInfo((object)"Trophy removed."); } } } private void TrackWorldChanges() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) string text = ((SaveManager.CurServerSave != null) ? SaveManager.CurServerSave.Name : null); Scene activeScene = SceneManager.GetActiveScene(); int num = SceneHandle.op_Implicit(((Scene)(ref activeScene)).handle); if (!(text == _lastWorld) || num != _lastScene) { _lastWorld = text; _lastScene = num; if (string.IsNullOrEmpty(text)) { TrophyManager.Clear(); } else { TrophyManager.LoadForWorld(text); } } } private bool TryMount(Player player, Ray ray) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) Item val = (((Object)(object)player.Holding != (Object)null) ? player.Holding.HeldItem : null); Creature val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent() : null); if ((Object)(object)val2 == (Object)null) { return false; } if (!val2.IsDead) { Plugin.Log.LogInfo((object)"Trophies: that one is still alive."); return true; } RaycastHit val3 = default(RaycastHit); if (!Physics.Raycast(ray, ref val3, Plugin.TrophyReach, LayerMask.op_Implicit(GameInfo.LevelLayer))) { return true; } if (!TrophyManager.IsMountableSurface(((RaycastHit)(ref val3)).normal)) { Plugin.Log.LogInfo((object)"Trophies: that is not a wall."); return true; } if (!TrophyManager.Mount(val2, ((RaycastHit)(ref val3)).point, ((RaycastHit)(ref val3)).normal)) { return true; } Plugin.Log.LogInfo((object)$"Mounted '{((Item)val2).GetName()}' ({TrophyManager.Count} trophies)."); if (Plugin.TrophyConsumesFish) { val.DestroyItem((byte)0, byte.MaxValue); } return true; } } internal static class TrophyManager { private static readonly List Spawned = new List(); private static TrophyFile _file = new TrophyFile(); private static string _worldName; private static TMP_FontAsset _font; private const float PlaqueThickness = 0.03f; private const float PlaqueFrontZ = 0.03f; internal static int Count => _file.Trophies.Count; internal static void LoadForWorld(string worldName) { Clear(); _worldName = worldName; if (string.IsNullOrEmpty(worldName)) { _file = new TrophyFile(); return; } _file = TrophyStore.Load(worldName); int num = 0; foreach (TrophyRecord trophy in _file.Trophies) { GameObject val = Build(trophy); Spawned.Add(val); if ((Object)(object)val != (Object)null) { num++; } } Plugin.Log.LogInfo((object)$"Trophies: restored {num}/{_file.Trophies.Count} in '{worldName}'."); } internal static void Clear() { foreach (GameObject item in Spawned) { if ((Object)(object)item != (Object)null) { Object.Destroy((Object)(object)item); } } Spawned.Clear(); } private static void Persist() { if (!string.IsNullOrEmpty(_worldName)) { TrophyStore.Save(_worldName, _file); } } internal static bool IsMountableSurface(Vector3 normal) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.TrophyWallsOnly) { return true; } return Mathf.Abs(Vector3.Dot(((Vector3)(ref normal)).normalized, Vector3.up)) <= Mathf.Cos((90f - Plugin.TrophyWallTolerance) * (MathF.PI / 180f)); } internal static bool Mount(Creature creature, Vector3 point, Vector3 normal) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_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_0085: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)creature == (Object)null) { return false; } Morph morph = MorphState.Of((Item)(object)creature); TrophyRecord trophyRecord = new TrophyRecord { Species = SpeciesRegistry.Normalize(((Object)creature).name), Morph = (morph?.Key ?? ""), ItemID = ((Item)creature).ID, Weight = ((Item)creature).RandomizedWeight, IsDrip = creature.IsDrip, Position = point + normal * 0.02f, Rotation = Quaternion.LookRotation(normal, Vector3.up) }; GameObject val = Build(trophyRecord); if ((Object)(object)val == (Object)null) { return false; } Spawned.Add(val); _file.Trophies.Add(trophyRecord); Persist(); return true; } internal static bool IsAiming(Ray ray, float maxDistance, float maxOffset, out string name) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) name = null; int num = NearestIndex(ray, maxDistance, maxOffset); if (num < 0) { return false; } TrophyRecord trophyRecord = _file.Trophies[num]; Creature val = ResolveSpecies(trophyRecord); if ((Object)(object)val == (Object)null) { name = "trophy"; return true; } Morph morph = (string.IsNullOrEmpty(trophyRecord.Morph) ? null : MorphCatalog.At(MorphCatalog.IndexOf(trophyRecord.Morph))); name = ((morph == null) ? ((Item)val).GetName() : string.Format(morph.NameFormat, ((Item)val).GetName())); return true; } private static int NearestIndex(Ray ray, float maxDistance, float maxOffset) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) int result = -1; float num = maxOffset; for (int i = 0; i < _file.Trophies.Count; i++) { Vector3 position = _file.Trophies[i].Position; float num2 = Vector3.Dot(position - ((Ray)(ref ray)).origin, ((Ray)(ref ray)).direction); if (!(num2 < 0f) && !(num2 > maxDistance)) { float num3 = Vector3.Distance(((Ray)(ref ray)).origin + ((Ray)(ref ray)).direction * num2, position); if (num3 < num) { num = num3; result = i; } } } return result; } internal static bool UnmountNearest(Ray ray, float maxDistance, float maxOffset) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) int num = NearestIndex(ray, maxDistance, maxOffset); if (num < 0) { return false; } TrophyRecord r = _file.Trophies[num]; if (num < Spawned.Count && (Object)(object)Spawned[num] != (Object)null) { Object.Destroy((Object)(object)Spawned[num]); } Spawned.RemoveAt(num); _file.Trophies.RemoveAt(num); Persist(); if (Plugin.TrophyReturnsFish) { GiveBack(r); } return true; } private static void GiveBack(TrophyRecord r) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //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_006d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Server.Instance == (Object)null || !((NetworkBehaviour)Server.Instance).IsServerInitialized || (Object)(object)ItemManager.Instance == (Object)null) { return; } Creature val = ResolveSpecies(r); Item val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent() : null); if ((Object)(object)val2 == (Object)null) { return; } try { Item val3 = ItemManager.Instance.SpawnNewItem(val2, r.Position + Vector3.up * 0.3f, Quaternion.identity); Creature val4 = (((Object)(object)val3 == (Object)null) ? null : ((Component)val3).GetComponent()); if (!((Object)(object)val4 == (Object)null)) { ((Item)val4)._syncedRandomWeight.Value = r.Weight; int num = (string.IsNullOrEmpty(r.Morph) ? (-1) : MorphCatalog.IndexOf(r.Morph)); ((Item)val4)._curSkin.Value = ((num >= 0) ? ((byte)(num + 1)) : byte.MaxValue); val4.ServerKillOnSpawn(); if (r.IsDrip) { val4.SetDrip(); } Player localPlayer = Player.LocalPlayer; if ((Object)(object)localPlayer != (Object)null && (Object)(object)localPlayer.Holding != (Object)null && (Object)(object)localPlayer.Holding.HeldItem == (Object)null) { val3.PickUp(localPlayer, true, true); } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not return the mounted fish: " + ex.Message)); } } private static GameObject Build(TrophyRecord r) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown //IL_006f: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) Creature val = ResolveSpecies(r); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)("Trophy species '" + r.Species + "' does not resolve; skipping.")); return null; } Morph morph = (string.IsNullOrEmpty(r.Morph) ? null : MorphCatalog.At(MorphCatalog.IndexOf(r.Morph))); GameObject val2 = new GameObject("MoreFish_Trophy_" + ((Object)val).name); val2.transform.SetPositionAndRotation(r.Position, r.Rotation); GameObject val3 = new GameObject("Mesh"); val3.transform.SetParent(val2.transform, false); SpeciesShape speciesShape = CustomSpecies.ShapeFor(val); float num = ((speciesShape != null) ? (speciesShape.BodyScale * Plugin.TrophyCustomScale) : ((Item)val).InventoryMeshScale) * (Plugin.TrophySizeFromWeight ? r.Weight : 1f) * Plugin.TrophyScale; val3.transform.localScale = Vector3.one * num; Mesh val4 = (val3.AddComponent().sharedMesh = ((r.IsDrip && (Object)(object)((Item)val).DripMesh != (Object)null) ? ((Item)val).DripMesh : ((Item)val).Mesh)); float halfWidth = 0.25f; float halfHeight = 0.12f; float halfDepth = 0.05f; bool flag = Plugin.TrophyAutoOrient && (Object)(object)val4 != (Object)null; if (flag) { val3.transform.rotation = OrientForSurface(val4, val2.transform.forward, out halfWidth, out halfHeight, out halfDepth); Transform transform = val3.transform; Bounds bounds = val4.bounds; Vector3 val6 = transform.TransformPoint(((Bounds)(ref bounds)).center); Transform transform2 = val3.transform; transform2.position += val2.transform.position - val6; Transform transform3 = val3.transform; transform3.localPosition += Vector3.forward * (0.03f + halfDepth * num); } else { val3.transform.localPosition = ((Item)val).InventoryMeshPos; val3.transform.localEulerAngles = ((Item)val).InventoryMeshRot; } MeshRenderer val7 = val3.AddComponent(); ((Renderer)val7).sharedMaterials = SourceMaterials(val, val4); if ((Object)(object)((Renderer)val7).sharedMaterial != (Object)null && (Object)(object)((Renderer)val7).sharedMaterial.shader != (Object)null) { Plugin.Log.LogInfo((object)("Trophy '" + ((Object)val).name + "': material '" + ((Object)((Renderer)val7).sharedMaterial).name + "' shader '" + ((Object)((Renderer)val7).sharedMaterial.shader).name + "'.")); } if (morph != null) { MorphSkin.ApplyToRenderer((Renderer)(object)val7, morph); Ability ability = AbilityCatalog.For(morph); if (ability.IsArmed) { ArmedBehaviour.AttachWeapon(val3.transform, ability, ArmedBehaviour.WorldSizeOf((Component)(object)val3.transform), val.HeadPos); } } if (!flag) { PushClearOfSurface(val2.transform, (Renderer)(object)val7, r.Position); } float plaqueHalfHeight = AddPlaque(val2.transform, halfWidth * num, halfHeight * num, halfDepth * num); AddLabel(val2.transform, val, morph, r, plaqueHalfHeight); return val2; } private static Quaternion OrientForSurface(Mesh mesh, Vector3 normal, out float halfWidth, out float halfHeight, out float halfDepth) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_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_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00db: 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_00e5: 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_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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_014a: 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_015b: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) Bounds bounds = mesh.bounds; Vector3 extents = ((Bounds)(ref bounds)).extents; int num = ((!(extents.x >= extents.y) || !(extents.x >= extents.z)) ? ((extents.y >= extents.z) ? 1 : 2) : 0); int num2 = ((!(extents.x <= extents.y) || !(extents.x <= extents.z)) ? ((extents.y <= extents.z) ? 1 : 2) : 0); if (num2 == num) { num2 = (num + 1) % 3; } int num3 = 3 - num - num2; Vector3 val = Vector3.Cross(Vector3.up, normal); if (((Vector3)(ref val)).sqrMagnitude < 0.0001f) { val = Vector3.Cross(Vector3.forward, normal); } ((Vector3)(ref val)).Normalize(); Vector3 val2 = Vector3.Cross(normal, val); Vector3 normalized = ((Vector3)(ref val2)).normalized; Vector3[] array = (Vector3[])(object)new Vector3[3]; array[num] = val; array[num3] = normalized; array[num2] = normal; if (Vector3.Dot(Vector3.Cross(array[0], array[1]), array[2]) < 0f) { array[num3] = -array[num3]; } halfWidth = ((Vector3)(ref extents))[num]; halfHeight = ((Vector3)(ref extents))[num3]; halfDepth = ((Vector3)(ref extents))[num2]; Matrix4x4 val3 = default(Matrix4x4); ((Matrix4x4)(ref val3)).SetColumn(0, Vector4.op_Implicit(array[0])); ((Matrix4x4)(ref val3)).SetColumn(1, Vector4.op_Implicit(array[1])); ((Matrix4x4)(ref val3)).SetColumn(2, Vector4.op_Implicit(array[2])); ((Matrix4x4)(ref val3)).SetColumn(3, new Vector4(0f, 0f, 0f, 1f)); return ((Matrix4x4)(ref val3)).rotation; } private static void PushClearOfSurface(Transform root, Renderer renderer, Vector3 surfacePoint) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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) if ((Object)(object)renderer == (Object)null) { return; } Vector3 forward = root.forward; MeshFilter component = ((Component)renderer).GetComponent(); Mesh val = ((component != null) ? component.sharedMesh : null); if ((Object)(object)val == (Object)null) { return; } Bounds bounds = val.bounds; Transform transform = ((Component)renderer).transform; float num = float.MaxValue; for (int i = 0; i < 8; i++) { Vector3 val2 = ((Bounds)(ref bounds)).center + Vector3.Scale(((Bounds)(ref bounds)).extents, new Vector3(((i & 1) == 0) ? (-1f) : 1f, ((i & 2) == 0) ? (-1f) : 1f, ((i & 4) == 0) ? (-1f) : 1f)); float num2 = Vector3.Dot(transform.TransformPoint(val2) - surfacePoint, forward); if (num2 < num) { num = num2; } } float trophySurfaceOffset = Plugin.TrophySurfaceOffset; root.position += forward * (trophySurfaceOffset - num); } private static Creature ResolveSpecies(TrophyRecord r) { if (!string.IsNullOrEmpty(r.Species)) { foreach (Creature item in SpeciesRegistry.Species) { if (SpeciesRegistry.Normalize(((Object)item).name) == r.Species) { return item; } } } Item spawnable = GameInfo.GetSpawnable(r.ItemID); if (!((Object)(object)spawnable == (Object)null)) { return ((Component)spawnable).GetComponent(); } return null; } private static Material[] SourceMaterials(Creature creature, Mesh mesh) { Material[] array = SourceMaterialArray(creature); int num = Mathf.Max(1, (!((Object)(object)mesh != (Object)null)) ? 1 : mesh.subMeshCount); Material[] array2 = (Material[])(object)new Material[num]; for (int i = 0; i < num; i++) { array2[i] = ((array.Length != 0) ? array[Mathf.Min(i, array.Length - 1)] : null); } if ((Object)(object)array2[0] == (Object)null) { Plugin.Log.LogWarning((object)($"Trophy '{((Object)creature).name}': no usable material found on {((Component)creature).GetComponentsInChildren(true).Length} " + "renderers - it will render magenta.")); } return array2; } private static Material[] SourceMaterialArray(Creature creature) { Material[] array = Array.Empty(); Renderer[] componentsInChildren = ((Component)creature).GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val.sharedMaterial == (Object)null) && !((Object)(object)((Component)val).GetComponent() != (Object)null) && DrawsSomething(val)) { if (MorphSkin.UsesSkinShader(val)) { return val.sharedMaterials; } if (array.Length == 0) { array = val.sharedMaterials; } } } return array; } private static bool DrawsSomething(Renderer r) { SkinnedMeshRenderer val = (SkinnedMeshRenderer)(object)((r is SkinnedMeshRenderer) ? r : null); if (val != null) { return (Object)(object)val.sharedMesh != (Object)null; } MeshFilter component = ((Component)r).GetComponent(); if ((Object)(object)component != (Object)null) { return (Object)(object)component.sharedMesh != (Object)null; } return false; } private static Material SourceMaterial(Creature creature) { Material val = null; Renderer[] componentsInChildren = ((Component)creature).GetComponentsInChildren(true); foreach (Renderer val2 in componentsInChildren) { if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2.sharedMaterial == (Object)null) && !((Object)(object)((Component)val2).GetComponent() != (Object)null) && DrawsSomething(val2)) { if (MorphSkin.UsesSkinShader(val2)) { return val2.sharedMaterial; } if ((Object)(object)val == (Object)null) { val = val2.sharedMaterial; } } } return val; } private static float AddPlaque(Transform root, float fishHalfWidth, float fishHalfHeight, float fishHalfDepth) { //IL_006a: 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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Max(fishHalfHeight * 1.55f, 0.12f); if (!Plugin.TrophyShowPlaque) { return 0f; } float num2 = Mathf.Max(fishHalfWidth * 1.25f, 0.16f); GameObject obj = GameObject.CreatePrimitive((PrimitiveType)3); ((Object)obj).name = "Plaque"; StripCollider(obj); obj.transform.SetParent(root, false); obj.transform.localPosition = new Vector3(0f, 0f, 0.015f); obj.transform.localScale = new Vector3(num2 * 2f, num * 2f, 0.03f); Paint(obj, Plugin.TrophyPlaqueColor, 0.15f); float num3 = 0.03f + fishHalfDepth * 2f; float num4 = 0.0105f; float num5 = num3 + 0.02f; GameObject obj2 = GameObject.CreatePrimitive((PrimitiveType)2); ((Object)obj2).name = "Nail"; StripCollider(obj2); obj2.transform.SetParent(root, false); obj2.transform.localRotation = Quaternion.Euler(90f, 0f, 0f); obj2.transform.localPosition = new Vector3(0f, 0f, (num4 + num5) * 0.5f); obj2.transform.localScale = new Vector3(0.018f, (num5 - num4) * 0.5f, 0.018f); Paint(obj2, new Color(0.62f, 0.6f, 0.56f), 0.75f); return num; } private static void StripCollider(GameObject go) { Collider component = go.GetComponent(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } } private static void Paint(GameObject go, Color color, float smoothness) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_004e: 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) Renderer component = go.GetComponent(); if ((Object)(object)component == (Object)null) { return; } Shader val = Shader.Find("Universal Render Pipeline/Lit") ?? Shader.Find("Standard"); if (!((Object)(object)val == (Object)null)) { Material val2 = new Material(val); if (val2.HasProperty("_BaseColor")) { val2.SetColor("_BaseColor", color); } if (val2.HasProperty("_Color")) { val2.SetColor("_Color", color); } if (val2.HasProperty("_Smoothness")) { val2.SetFloat("_Smoothness", smoothness); } if (val2.HasProperty("_Metallic")) { val2.SetFloat("_Metallic", (smoothness > 0.5f) ? 0.8f : 0f); } component.sharedMaterial = val2; } } private static void AddLabel(Transform parent, Creature creature, Morph morph, TrophyRecord r, float plaqueHalfHeight) { //IL_0064: 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_0076: 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_009f: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.TrophyLabels) { return; } if ((Object)(object)_font == (Object)null) { TMP_Text[] array = Resources.FindObjectsOfTypeAll(); foreach (TMP_Text val in array) { if ((Object)(object)val != (Object)null && (Object)(object)val.font != (Object)null) { _font = val.font; break; } } } if (!((Object)(object)_font == (Object)null)) { GameObject val2 = new GameObject("Label"); val2.transform.SetParent(parent, false); val2.transform.localPosition = new Vector3(0f, 0f - (plaqueHalfHeight + Plugin.TrophyLabelDrop * 0.35f), 0.03f); val2.AddComponent(); TextMeshPro obj = val2.AddComponent(); ((TMP_Text)obj).font = _font; string arg = ((string.IsNullOrEmpty(r.Morph) || morph == null) ? ((Item)creature).GetName() : string.Format(morph.NameFormat, ((Item)creature).GetName())); ((TMP_Text)obj).text = string.Format("{0}\n{1:0.##} kg", arg, Reflect.Get(creature, "_weight", 1f) * r.Weight); ((TMP_Text)obj).fontSize = 1.4f; ((TMP_Text)obj).alignment = (TextAlignmentOptions)514; ((TMP_Text)obj).enableWordWrapping = false; ((TMP_Text)obj).rectTransform.sizeDelta = new Vector2(4f, 1.2f); } } } internal sealed class TrophyPrompt : MonoBehaviour { private TextMeshProUGUI _text; private bool _built; private void Build() { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Expected O, but got Unknown //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0145: 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_016f: 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) _built = true; TMP_FontAsset val = null; TMP_Text[] array = Resources.FindObjectsOfTypeAll(); foreach (TMP_Text val2 in array) { if ((Object)(object)val2 != (Object)null && (Object)(object)val2.font != (Object)null) { val = val2.font; break; } } if (!((Object)(object)val == (Object)null)) { GameObject val3 = new GameObject("MoreFish_TrophyPrompt"); val3.transform.SetParent(((Component)this).transform, false); Canvas obj = val3.AddComponent(); obj.renderMode = (RenderMode)0; obj.sortingOrder = 500; CanvasScaler obj2 = val3.AddComponent(); obj2.uiScaleMode = (ScaleMode)1; obj2.referenceResolution = new Vector2(1920f, 1080f); GameObject val4 = new GameObject("Text"); val4.transform.SetParent(val3.transform, false); _text = val4.AddComponent(); ((TMP_Text)_text).font = val; ((TMP_Text)_text).fontSize = 26f; ((TMP_Text)_text).alignment = (TextAlignmentOptions)514; ((Graphic)_text).raycastTarget = false; ((TMP_Text)_text).text = ""; RectTransform rectTransform = ((TMP_Text)_text).rectTransform; rectTransform.anchorMin = new Vector2(0.5f, 0f); rectTransform.anchorMax = new Vector2(0.5f, 0f); rectTransform.pivot = new Vector2(0.5f, 0f); rectTransform.anchoredPosition = new Vector2(0f, 220f); rectTransform.sizeDelta = new Vector2(900f, 60f); } } private void LateUpdate() { if (!Plugin.TrophiesEnabled || !Plugin.TrophyPrompt) { if ((Object)(object)_text != (Object)null) { ((TMP_Text)_text).text = ""; } return; } if (!_built) { Build(); } if (!((Object)(object)_text == (Object)null)) { ((TMP_Text)_text).text = CurrentHint(); } } private static string CurrentHint() { //IL_0047: 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_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_010d: 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_00c0: 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) if (PauseManager.IsPaused || PlayerThinking.IsThinking || ChatManager.IsTyping) { return ""; } Player localPlayer = Player.LocalPlayer; Camera curCamera = GameInfo.CurCamera; if ((Object)(object)localPlayer == (Object)null || (Object)(object)curCamera == (Object)null) { return ""; } Ray val = default(Ray); ((Ray)(ref val))..ctor(((Component)curCamera).transform.position, ((Component)curCamera).transform.forward); string text = ((object)Plugin.TrophyKey/*cast due to .constrained prefix*/).ToString(); Item val2 = (((Object)(object)localPlayer.Holding != (Object)null) ? localPlayer.Holding.HeldItem : null); Creature val3 = (((Object)(object)val2 != (Object)null) ? ((Component)val2).GetComponent() : null); if ((Object)(object)val3 != (Object)null && val3.IsDead) { RaycastHit val4 = default(RaycastHit); if (!Physics.Raycast(val, ref val4, Plugin.TrophyReach, LayerMask.op_Implicit(GameInfo.LevelLayer))) { return ""; } if (!TrophyManager.IsMountableSurface(((RaycastHit)(ref val4)).normal)) { return ""; } return "[" + text + "] Mount " + ((Item)val3).GetName(); } if ((Object)(object)val3 == (Object)null && TrophyManager.IsAiming(val, Plugin.TrophyReach, 0.45f, out var name)) { return "[" + text + "] Take down " + name; } return ""; } } internal static class VariantBrowser { internal static bool Active; internal static Creature Species; internal static int PendingMorph = -1; internal static int ViewCount { get { if (!Active) { return 0; } return MorphCatalog.All.Count; } } internal static void Enter(Creature species) { if (!((Object)(object)species == (Object)null) && SpeciesRegistry.IndexOf(species) >= 0) { Active = true; Species = species; Refresh(); ApplyHeader(); } } internal static void Exit() { if (Active) { Active = false; Species = null; PendingMorph = -1; Refresh(); ApplyHeader(); } } private static void Refresh() { PlayerUI.ScrollThinkingPage(0); } internal static void ApplyHeader() { ThinkingUI val = FindThinkingUI(); if (!((Object)(object)val == (Object)null)) { JournalHeader.Set(val, (Active && (Object)(object)Species != (Object)null) ? (((Item)Species).GetName() + " Variants") : null); AccessTools.Method(typeof(ThinkingUI), "SetProgressTexts", (Type[])null, (Type[])null)?.Invoke(val, null); } } internal static ThinkingUI FindThinkingUI() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_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) ThinkingUI val = null; ThinkingUI[] array = Resources.FindObjectsOfTypeAll(); foreach (ThinkingUI val2 in array) { if ((Object)(object)val2 == (Object)null) { continue; } if ((Object)(object)val == (Object)null) { val = val2; } Scene scene = ((Component)val2).gameObject.scene; if (((Scene)(ref scene)).IsValid()) { scene = ((Component)val2).gameObject.scene; if (((Scene)(ref scene)).isLoaded) { return val2; } } } return val; } } [HarmonyPatch(/*Could not decode attribute arguments.*/)] internal static class AllCreatureCountPatch { private static void Postfix(ref int __result) { if (VariantBrowser.Active) { __result = VariantBrowser.ViewCount; } } } [HarmonyPatch(typeof(GameInfo), "GetCreature")] internal static class GetCreaturePatch { private static bool Prefix(int index, ref Creature __result) { if (!VariantBrowser.Active) { VariantBrowser.PendingMorph = -1; return true; } VariantBrowser.PendingMorph = ((index >= 0 && index < MorphCatalog.All.Count) ? index : (-1)); __result = ((VariantBrowser.PendingMorph >= 0) ? VariantBrowser.Species : null); return false; } } [HarmonyPatch(typeof(JournalSlot), "SetCreature")] internal static class JournalSlotSetCreaturePatch { private static void Postfix(JournalSlot __instance, Creature creature) { //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) MeshFilter val = Reflect.Get(__instance, "_filter"); Renderer val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent() : null); Morph morph = MorphCatalog.At(VariantBrowser.Active ? VariantBrowser.PendingMorph : (-1)); if (morph == null || (Object)(object)creature == (Object)null) { if ((Object)(object)val2 != (Object)null) { ShaderManager.ResetItemSkin(val2); } return; } if ((Object)(object)val2 != (Object)null) { MorphSkin.ApplyToRenderer(val2, morph); } bool flag = CaughtLog.Has(MorphState.KeyFor(creature, morph)); Graphic val3 = Reflect.Get(__instance, "_image"); if ((Object)(object)val3 != (Object)null) { val3.color = (flag ? Color.white : Color.black); } SetText(__instance, "_nameText", flag ? (string.Format(morph.NameFormat, ((Item)creature).GetName()) + "\n" + AbilityCatalog.For(morph).Name + "") : "???"); SetText(__instance, "_worthText", flag ? ("$" + Mathf.Max(1, Mathf.RoundToInt((float)((Item)creature).DefaultWorth * AbilityCatalog.For(morph).Worth))) : "-"); } private static void SetText(JournalSlot slot, string field, string value) { TMP_Text val = Reflect.Get(slot, field); if ((Object)(object)val != (Object)null) { val.text = value; } } } [HarmonyPatch(typeof(ThinkingUI), "SetProgressTexts")] internal static class SetProgressTextsPatch { private static void Postfix(ThinkingUI __instance) { int count = MorphCatalog.All.Count; if (VariantBrowser.Active && (Object)(object)VariantBrowser.Species != (Object)null) { int num = CaughtLog.CountFor(VariantBrowser.Species); SetText(__instance, "_progressText", $"{num} / {count} variants"); SetText(__instance, "_dripProgressText", "right-click to go back"); } else { int num2 = SpeciesRegistry.Count * count; SetText(__instance, "_dripProgressText", $"{CaughtLog.Total} / {num2} variants"); } } private static void SetText(ThinkingUI ui, string fieldName, string value) { TMP_Text val = Reflect.Get(ui, fieldName); if ((Object)(object)val != (Object)null) { val.text = value; } } } [HarmonyPatch(typeof(ThinkingUI), "ScrollThinkingPage")] internal static class ScrollThinkingPagePatch { private static void Postfix() { if (VariantBrowser.Active) { VariantBrowser.ApplyHeader(); } } } }