Decompiled source of MoreFish v1.0.2
BepInEx/plugins/MoreFish/MoreFish.dll
Decompiled a day ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.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<string, Ability> ByKey = new Dictionary<string, Ability> { ["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<Player> Scratch = new List<Player>(); 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<Renderer>(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<MeshFilter>().sharedMesh = spawnable.Mesh; MeshRenderer val2 = val.AddComponent<MeshRenderer>(); Renderer[] componentsInChildren = ((Component)spawnable).GetComponentsInChildren<Renderer>(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<Renderer>().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<Renderer>().sharedMaterial = _flash; Object.Destroy((Object)(object)obj2, 0.05f); } } } private static void Strip(GameObject go) { Collider component = go.GetComponent<Collider>(); 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<string> Caught = new List<string>(); } internal static class CaughtLog { private static HashSet<string> _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<string>(StringComparer.Ordinal); try { if (!File.Exists(Path)) { return; } CaughtFile caughtFile = JsonConvert.DeserializeObject<CaughtFile>(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<string>(_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<float, float> Z, Func<float, float> Lift, Func<float, float> 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<float, float> Z, Func<float, float> Lift, Func<float, float> 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<float, float> Z, Func<float, float> Lift, Func<float, float> 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<float, float> Z, Func<float, float> Lift, Func<float, float> 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<float, float> Z, Func<float, float> Lift, Func<float, float> 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<float, float> Z, Func<float, float> Lift, Func<float, float> 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<float, float> Z, Func<float, float> Lift, Func<float, float> 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<float, float> Z, Func<float, float> Lift, Func<float, float> 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<float, float> Z, Func<float, float> 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<Creature> Added = new List<Creature>(); private static readonly Dictionary<string, float> _rarityByName = new Dictionary<string, float>(); private static readonly Dictionary<string, SpeciesShape> _shapeByName = new Dictionary<string, SpeciesShape>(); 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<CustomSpeciesTag>(); 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<MeshFilter>(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<CustomSpeciesTag>() != (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<GameObject>(((Component)donor).gameObject, _root.transform); ((Object)val).name = shape.Name; Creature component = val.GetComponent<Creature>(); 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<MeshFilter>(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].sharedMesh = null; } SkinnedMeshRenderer[] componentsInChildren2 = val.GetComponentsInChildren<SkinnedMeshRenderer>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { componentsInChildren2[i].sharedMesh = null; } Renderer[] componentsInChildren3 = val.GetComponentsInChildren<Renderer>(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<MeshFilter>().sharedMesh = val3; ((Renderer)val4.AddComponent<MeshRenderer>()).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>(); 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<CustomSpeciesTag>() != (Object)null) { _registeredFishNet = true; return; } } foreach (Creature item in Added) { NetworkObject component = ((Component)item).GetComponent<NetworkObject>(); 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<string, Item> dictionary = Reflect.GetStatic<Dictionary<string, Item>>(typeof(GameInfo), "_nameToSpawnable"); Dictionary<byte, Item> dictionary2 = Reflect.GetStatic<Dictionary<byte, Item>>(typeof(GameInfo), "_idToSpawnable"); Dictionary<byte, Item> dictionary3 = Reflect.GetStatic<Dictionary<byte, Item>>(typeof(GameInfo), "_allItems"); List<Creature> list = Reflect.GetStatic<List<Creature>>(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<BaitInfo>("Baits"); if (array == null) { return; } int num = 0; BaitInfo[] array2 = array; foreach (BaitInfo val in array2) { List<ItemInfoWeight> 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<CustomSpeciesTag>() != (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<Fishable>(); ((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<Item>(), val2, Quaternion.identity); Creature val4 = (((Object)(object)val3 == (Object)null) ? null : ((Component)val3).GetComponent<Creature>()); 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<GUILayoutOption>()); GUILayout.Space(6f); GUILayout.Label($"Species <color=#E8C15E>{((Object)val).name}</color> ({_species + 1}/{SpeciesRegistry.Count})", _line, Array.Empty<GUILayoutOption>()); GUILayout.Label($"Morph <color=#E8C15E>{morph.Key}</color> ({_morph + 1}/{MorphCatalog.All.Count})", _line, Array.Empty<GUILayoutOption>()); GUILayout.Label("Ability " + ability.Name + " — " + ability.Blurb, _line, Array.Empty<GUILayoutOption>()); GUILayout.Label($"Value ${ability.Worth:0.00}x" + (ability.IsArmed ? $" <color=#E86A5E>ARMED {ability.WeaponName}, {ability.ShootDamage} dmg</color>" : ""), _line, Array.Empty<GUILayoutOption>()); GUILayout.Space(6f); GUILayout.Label(num ? "<color=#7FBE95>FORCING every catch to this morph</color>" : "<color=#9AA7B0>catches are random</color>", _line, Array.Empty<GUILayoutOption>()); GUILayout.Space(8f); GUILayout.Label("←/→ species ↑/↓ morph Enter spawn", _hint, Array.Empty<GUILayoutOption>()); GUILayout.Label($"F force this morph C clear {Plugin.DebugPanelKey} close", _hint, Array.Empty<GUILayoutOption>()); 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<MeshFilter>().sharedMesh = _sphere; ((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = mat; val.AddComponent<MorphExempt>(); } 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<Vector2>)(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<JournalSlot> list = Reflect.Get<List<JournalSlot>>(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<Canvas>(); 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<Graphic>(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<CanvasGroup>(ui, "_thinkingCanvas"); Transform obj = (((Object)(object)val != (Object)null) ? ((Component)val).transform : ((Component)ui).transform); TMP_Text val2 = Reflect.Get<TMP_Text>(ui, "_progressText"); TMP_Text val3 = Reflect.Get<TMP_Text>(ui, "_dripProgressText"); float num = 0f; TMP_Text[] componentsInChildren = ((Component)obj).GetComponentsInChildren<TMP_Text>(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<Vector3> _verts = new List<Vector3>(); private readonly List<int> _tris = new List<int>(); private readonly List<Vector2> _uvs = new List<Vector2>(); 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<float, float> Z, Func<float, float> 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(V