Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of WispFairy v0.5.2
BepInEx/plugins/WispFairy/WispFairy.dll
Decompiled 2 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.Audio; using UnityEngine.Rendering; [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("WispFairy")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.5.2.0")] [assembly: AssemblyInformationalVersion("0.5.2")] [assembly: AssemblyProduct("WispFairy")] [assembly: AssemblyTitle("WispFairy")] [assembly: InternalsVisibleTo("WispFairy.WorldTests")] [assembly: AssemblyVersion("0.5.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 Zephyrfit.WispFairy { internal enum CampPose { Flying, Perched, Dancing } internal sealed class CampFlight { private Transform shoulder; private Animator rig; private readonly List<AnimatorClipInfo> clips = new List<AnimatorClipInfo>(); private ZNetView ownerView; private float stillTime; private float nextHeatCheck; private float beat; private bool warm; internal CampPose Pose { get; private set; } internal bool RestingByFire { get { if (warm) { return Pose == CampPose.Perched; } return false; } } internal void Update(Player player, float dt, bool threatened) { //IL_006c: 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_0072: 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_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_0094: 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_0166: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)ownerView)) { ownerView = ((Component)player).GetComponent<ZNetView>(); } ZDO obj = (Object.op_Implicit((Object)(object)ownerView) ? ownerView.GetZDO() : null); string text = ((obj != null) ? obj.GetString(ZDOVars.s_emote, "") : null) ?? ""; bool flag = ((Character)player).IsSitting() || text == "sit"; Vector3 velocity = ((Character)player).GetVelocity(); Vector2 val = new Vector2(velocity.x, velocity.z); int num; if (!(((Vector2)(ref val)).sqrMagnitude > 0.09f)) { Vector3 moveDir = ((Character)player).GetMoveDir(); num = ((((Vector3)(ref moveDir)).sqrMagnitude > 0.04f) ? 1 : 0); } else { num = 1; } bool flag2 = (byte)num != 0; if (threatened || flag2 || ((Character)player).IsDead() || ((Character)player).IsTeleporting() || ((Character)player).IsSwimming() || ((Character)player).InAttack() || ((Character)player).IsDrawingBow() || ((Character)player).IsBlocking()) { stillTime = (beat = 0f); Pose = CampPose.Flying; return; } if (text.StartsWith("dance", StringComparison.OrdinalIgnoreCase) && ((Character)player).InEmote() && DancePlaying(player)) { if (Pose != CampPose.Dancing) { beat = 0f; } stillTime = 0f; Pose = CampPose.Dancing; return; } if (Time.time >= nextHeatCheck) { nextHeatCheck = Time.time + 0.3f; warm = Object.op_Implicit((Object)(object)EffectArea.IsPointInsideArea(((Character)player).GetCenterPoint(), (Type)1, 0.15f)); } stillTime = ((warm && ((Character)player).IsOnGround()) ? (stillTime + dt) : 0f); Pose = ((flag || stillTime >= 2f) ? CampPose.Perched : CampPose.Flying); } private bool DancePlaying(Player player) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)rig)) { rig = ((Component)player).GetComponentInChildren<Animator>(); } if (!Object.op_Implicit((Object)(object)rig)) { return true; } for (int i = 0; i < rig.layerCount; i++) { AnimatorStateInfo currentAnimatorStateInfo = rig.GetCurrentAnimatorStateInfo(i); if (!((AnimatorStateInfo)(ref currentAnimatorStateInfo)).loop && ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).normalizedTime >= 1f) { continue; } rig.GetCurrentAnimatorClipInfo(i, clips); foreach (AnimatorClipInfo clip in clips) { AnimatorClipInfo current = clip; if (((AnimatorClipInfo)(ref current)).weight > 0.05f && Object.op_Implicit((Object)(object)((AnimatorClipInfo)(ref current)).clip) && ((Object)((AnimatorClipInfo)(ref current)).clip).name.IndexOf("dance", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } } } return false; } internal Vector3 Goal(Player player, float dt, float tempo) { //IL_0137: 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_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: 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_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) if (Pose == CampPose.Perched) { if (!Object.op_Implicit((Object)(object)shoulder)) { if (!Object.op_Implicit((Object)(object)rig)) { rig = ((Component)player).GetComponentInChildren<Animator>(); } if (Object.op_Implicit((Object)(object)rig) && rig.isHuman) { shoulder = rig.GetBoneTransform((HumanBodyBones)14); } } if (!Object.op_Implicit((Object)(object)shoulder)) { return ((Character)player).GetEyePoint() + ((Component)player).transform.right * 0.26f - Vector3.up * 0.2f; } return shoulder.position + Vector3.up * 0.12f + ((Component)player).transform.right * 0.045f; } beat += dt * tempo; float num = beat * 2.4f + 0.18f * Mathf.Sin(beat * 4.8f); float num2 = 1.04f + 0.17f * Mathf.Sin(2f * num); float num3 = Mathf.Sin(2f * num); return ((Character)player).GetCenterPoint() + ((Component)player).transform.right * (Mathf.Cos(num) * num2) + ((Component)player).transform.forward * (Mathf.Sin(num) * num2) + Vector3.up * (0.55f + 0.38f * num3 + 0.09f * Mathf.Sin(4f * num)); } } internal static class CreatureTips { private static readonly (DamageType type, string topic)[] Weaknesses = new(DamageType, string)[8] { ((DamageType)1, "TipBlunt"), ((DamageType)4, "TipPierce"), ((DamageType)2, "TipSlash"), ((DamageType)32, "TipFire"), ((DamageType)64, "TipFrost"), ((DamageType)128, "TipLightning"), ((DamageType)512, "TipSpirit"), ((DamageType)256, "TipPoison") }; internal static IEnumerable<(string topic, int priority)> Eligible(Player player, Character subject, bool camp) { BaseAI ai = subject.GetBaseAI(); if (!Object.op_Implicit((Object)(object)ai)) { ai = ((Component)subject).GetComponent<BaseAI>(); } if (!Object.op_Implicit((Object)(object)ai)) { yield break; } object obj; if (!((Object)(object)player == (Object)(object)Player.m_localPlayer) || !Object.op_Implicit((Object)(object)Game.instance)) { obj = null; } else { PlayerProfile playerProfile = Game.instance.GetPlayerProfile(); if (playerProfile == null) { obj = null; } else { PlayerStats obj2 = playerProfile.m_playerStats[0]; obj = ((obj2 != null) ? obj2.m_enemyStats[0] : null); } } Dictionary<string, float> dictionary = (Dictionary<string, float>)obj; float value; bool experienced = dictionary != null && !string.IsNullOrEmpty(subject.m_name) && dictionary.TryGetValue(subject.m_name, out value) && value >= 3f; List<ItemData> items = ((Humanoid)player).GetInventory().GetAllItems(); bool readyBow = items.Exists(CanShoot); if (ai is AnimalAI) { if (!experienced) { if (readyBow) { yield return (topic: "TipHuntBow", priority: 2); } else if (camp && KnowsRecipe(player, "Bow") && KnowsRecipe(player, "ArrowWood")) { yield return (topic: "TipPrepareBow", priority: 2); } yield return (topic: "TipQuiet", priority: 1); } yield break; } if (Object.op_Implicit((Object)(object)((Component)subject).GetComponent<Tameable>())) { MonsterAI val = (MonsterAI)(object)((ai is MonsterAI) ? ai : null); if (val != null && val.m_consumeItems != null && val.m_consumeItems.Exists((ItemDrop food) => Object.op_Implicit((Object)(object)food) && player.IsKnownMaterial(food.m_itemData.m_shared.m_name))) { yield return (topic: "TipTame", priority: 2); } } if (ai.m_afraidOfFire && (KnowsRecipe(player, "Torch") || items.Exists((ItemData i) => Usable(i) && (int)i.m_shared.m_itemType == 15))) { yield return (topic: "TipFlame", priority: 2); } if (readyBow && ai.m_randomFly) { yield return (topic: "TipFlying", priority: 2); } (DamageType type, string topic)[] weaknesses = Weaknesses; for (int num = 0; num < weaknesses.Length; num++) { (DamageType type, string topic) tuple = weaknesses[num]; DamageType item = tuple.type; string item2 = tuple.topic; DamageModifier modifier = ((DamageModifiers)(ref subject.m_damageModifiers)).GetModifier(item); if ((int)modifier != 2 && (int)modifier != 6 && (int)modifier != 8) { continue; } foreach (ItemData item3 in items) { if (!Usable(item3)) { continue; } SharedData shared = item3.m_shared; if ((int)shared.m_itemType == 9) { if (!items.Exists((ItemData bow) => Usable(bow) && (int)bow.m_shared.m_itemType == 4 && bow.m_shared.m_ammoType == shared.m_ammoType)) { continue; } } else if (!item3.IsWeapon() || ((int)shared.m_itemType == 4 && !CanShoot(item3))) { continue; } if (!(Damage(item3.GetDamage(), item) <= 0f)) { yield return (topic: item2, priority: 2); break; } } } if (!camp && !experienced) { yield return (topic: "TipWatch", priority: 0); } bool CanShoot(ItemData bow) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Invalid comparison between Unknown and I4 if (Usable(bow) && (int)bow.m_shared.m_itemType == 4) { return items.Exists((ItemData ammo) => Usable(ammo) && (int)ammo.m_shared.m_itemType == 9 && ammo.m_shared.m_ammoType == bow.m_shared.m_ammoType); } return false; } } private static bool Usable(ItemData item) { if (item?.m_shared != null && item.m_stack > 0) { if (item.m_shared.m_useDurability) { return item.m_durability > 0f; } return true; } return false; } private static bool KnowsRecipe(Player player, string prefab) { GameObject val = (Object.op_Implicit((Object)(object)ObjectDB.instance) ? ObjectDB.instance.GetItemPrefab(prefab) : null); ItemDrop val2 = default(ItemDrop); if (Object.op_Implicit((Object)(object)val) && val.TryGetComponent<ItemDrop>(ref val2)) { return player.IsRecipeKnown(val2.m_itemData.m_shared.m_name); } return false; } private static float Damage(DamageTypes damage, DamageType type) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Invalid comparison between Unknown and I4 //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected I4, but got Unknown //IL_0070: 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_0037: Invalid comparison between Unknown and I4 //IL_0043: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Invalid comparison between Unknown and I4 //IL_0082: 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_003f: Invalid comparison between Unknown and I4 //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Invalid comparison between Unknown and I4 //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) if ((int)type <= 64) { switch (type - 1) { default: if ((int)type != 32) { if ((int)type != 64) { break; } return damage.m_frost; } return damage.m_fire; case 0: return damage.m_blunt; case 3: return damage.m_pierce; case 1: return damage.m_slash; case 2: break; } } else { if ((int)type == 128) { return damage.m_lightning; } if ((int)type == 256) { return damage.m_poison; } if ((int)type == 512) { return damage.m_spirit; } } return 0f; } } internal sealed class EnemyAnnouncements { private sealed class Encounter { internal bool Voice; internal bool Chime; internal float Seen; internal float LastRear = float.NegativeInfinity; } internal const float LostContact = 3f; private readonly Dictionary<ZDOID, Encounter> encounters = new Dictionary<ZDOID, Encounter>(); private readonly List<ZDOID> expired = new List<ZDOID>(); private float nextCleanup; internal void Touch(ZDOID target, float now) { //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_0013: 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_0097: 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_00cf: 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) if (target != ZDOID.None && encounters.TryGetValue(target, out var value)) { if (now - value.Seen <= 3f) { value.Seen = now; } else { encounters.Remove(target); } } if (now < nextCleanup) { return; } nextCleanup = now + 1f; expired.Clear(); foreach (KeyValuePair<ZDOID, Encounter> encounter in encounters) { if (now - encounter.Value.Seen > 3f) { expired.Add(encounter.Key); } } foreach (ZDOID item in expired) { encounters.Remove(item); } } internal bool Claim(ZDOID target, float now, bool chime, bool markedEarlier, bool newRearApproach) { //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_0015: 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) if (target == ZDOID.None) { return true; } if (!encounters.TryGetValue(target, out var value) || now - value.Seen > 3f) { value = new Encounter(); encounters[target] = value; } bool flag = (chime ? value.Chime : value.Voice) || markedEarlier; value.Seen = now; if (chime) { value.Chime = true; } else { value.Voice = true; } if (newRearApproach && now - value.LastRear >= 3f) { value.LastRear = now; return true; } return !flag; } } internal sealed class FairyAdvice { internal const string Observed = "Zephyrfit.WispFairy.Observed."; internal const string NextAdvice = "Zephyrfit.WispFairy.NextAdviceUtc"; internal const string Heard = "Zephyrfit.WispFairy.Heard."; private const string LastSubject = "Zephyrfit.WispFairy.LastSubject"; private static readonly Dictionary<(string, FairyLanguage), string> speciesNames = new Dictionary<(string, FairyLanguage), string>(); private readonly List<(string topic, string name)> choices = new List<(string, string)>(); private Character watching; private float nextLook; private float since; private float fieldAt; private float campAt = -1f; private float nextAttempt; private bool observed; private bool toldInField; private bool toldAtFire; internal void Suspend() { watching = null; observed = (toldInField = (toldAtFire = false)); campAt = -1f; nextAttempt = 0f; } internal void Observe(Player player, Character focus, bool byFire, float now) { if (!Plugin.CreatureTips.Value) { Suspend(); return; } if (!byFire) { campAt = -1f; toldAtFire = false; } else if (campAt < 0f) { campAt = now + Random.Range(12f, 26f); nextAttempt = 0f; } if (now < nextLook) { return; } nextLook = now + 0.25f; Character val = FindSubject(player, focus); if ((Object)(object)val != (Object)(object)watching) { watching = val; observed = (toldInField = false); since = now; fieldAt = now + Random.Range(5f, 12f); nextAttempt = 0f; } if (Object.op_Implicit((Object)(object)val) && !observed && !(now - since < 3f)) { observed = true; string prefabName = Utils.GetPrefabName(((Component)val).gameObject); if (!player.m_customData.ContainsKey("Zephyrfit.WispFairy.Observed." + prefabName)) { string text = ((val.GetBaseAI() is AnimalAI) ? "TipQuiet" : "TipWatch"); player.m_customData["Zephyrfit.WispFairy.Observed." + prefabName] = text + "\n" + NameToken(val, prefabName); } player.m_customData["Zephyrfit.WispFairy.LastSubject"] = prefabName; } } private Character FindSubject(Player player, Character focus) { //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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) Vector3 eyePoint = ((Character)player).GetEyePoint(); Vector3 lookDir = ((Character)player).GetLookDir(); Character hoverCreature = player.GetHoverCreature(); if (Visible(hoverCreature, eyePoint)) { return hoverCreature; } if (Visible(focus, eyePoint)) { return focus; } if (Visible(watching, eyePoint)) { Vector3 val = watching.GetCenterPoint() - eyePoint; if (Vector3.Dot(lookDir, ((Vector3)(ref val)).normalized) >= 0.57f) { return watching; } } Character result = null; float num = 0.57f; foreach (Character allCharacter in Character.GetAllCharacters()) { if (!Object.op_Implicit((Object)(object)allCharacter) || allCharacter.IsPlayer()) { continue; } Vector3 val2 = allCharacter.GetCenterPoint() - eyePoint; if (!(((Vector3)(ref val2)).sqrMagnitude > 100f)) { float num2 = Vector3.Dot(lookDir, ((Vector3)(ref val2)).normalized); if (!(num2 <= num) && Visible(allCharacter, eyePoint)) { result = allCharacter; num = num2; } } } return result; } private static bool Visible(Character subject, Vector3 eyes) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)subject) && !subject.IsPlayer() && !subject.IsDead() && !subject.IsTamed() && Object.op_Implicit((Object)(object)subject.GetBaseAI())) { return FairyFlight.InSight(eyes, subject); } return false; } internal (string topic, string words)? Take(Player player, float now) { //IL_01d0: Unknown result type (might be due to invalid IL or missing references) Player player2 = player; FairyAdvice fairyAdvice = this; bool camp = campAt >= 0f; bool num; if (Plugin.CreatureTips.Value && !(now < nextAttempt)) { if (!camp) { if (!toldInField && observed && Object.op_Implicit((Object)(object)watching)) { num = now < fieldAt; goto IL_0083; } } else if (!toldAtFire) { num = now < campAt; goto IL_0083; } } goto IL_0085; IL_0083: long utc; int best; if (!num) { nextAttempt = now + 2f; utc = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); long num2 = Stamp(player2, "Zephyrfit.WispFairy.NextAdviceUtc") - utc; if (num2 > 0 && num2 <= 120) { return null; } choices.Clear(); best = -1; if (camp && Object.op_Implicit((Object)(object)ZNetScene.instance)) { player2.m_customData.TryGetValue("Zephyrfit.WispFairy.LastSubject", out var value); Character creature = default(Character); foreach (string key in player2.m_customData.Keys) { if (key.StartsWith("Zephyrfit.WispFairy.Observed.", StringComparison.Ordinal)) { string text = key.Substring("Zephyrfit.WispFairy.Observed.".Length); GameObject prefab = ZNetScene.instance.GetPrefab(text); if (Object.op_Implicit((Object)(object)prefab) && prefab.TryGetComponent<Character>(ref creature)) { Consider(creature, text, (text == value) ? 1 : 0); } } } } else if (!camp && Visible(watching, ((Character)player2).GetEyePoint())) { Consider(watching, Utils.GetPrefabName(((Component)watching).gameObject), 0); } if (choices.Count == 0) { nextAttempt = now + 12f; return null; } (string, string) tuple = choices[Random.Range(0, choices.Count)]; if (camp) { toldAtFire = true; } else { toldInField = true; } int num3 = Mathf.Max(Random.Range(60, 101), Mathf.CeilToInt(Plugin.CallInterval.Value)); player2.m_customData["Zephyrfit.WispFairy.NextAdviceUtc"] = (utc + num3).ToString(CultureInfo.InvariantCulture); player2.m_customData["Zephyrfit.WispFairy.Heard." + tuple.Item1] = utc.ToString(CultureInfo.InvariantCulture); string text2 = FairyWords.Ui(tuple.Item1); if (camp) { text2 = string.Format(FairyWords.Ui("CampSubject"), SpeciesName(tuple.Item2), text2); } return (tuple.Item1, text2); } goto IL_0085; IL_0085: return null; void Consider(Character subject, string fallback, int recency) { foreach (var item2 in CreatureTips.Eligible(player2, subject, camp)) { string item = item2.topic; int num4 = item2.priority * 2 + recency; long num5 = utc - Stamp(player2, "Zephyrfit.WispFairy.Heard." + item); if (num4 >= best && (num5 < 0 || num5 >= 300)) { if (num4 > best) { choices.Clear(); best = num4; } choices.Add((item, NameToken(subject, fallback))); } } } } private static long Stamp(Player player, string key) { if (!player.m_customData.TryGetValue(key, out var value) || !long.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result)) { return 0L; } return result; } private static string NameToken(Character subject, string fallback) { return (string.IsNullOrWhiteSpace(subject.m_name) ? fallback : subject.m_name).Replace('\n', ' ').Replace('\r', ' ').Replace('<', '‹') .Replace('>', '›'); } internal static string SpeciesName(string token) { FairyLanguage fairyLanguage = FairyWords.Resolve(Plugin.TextLanguage.Value); if (speciesNames.TryGetValue((token, fairyLanguage), out var value)) { return value; } Localization instance = Localization.instance; if (instance == null) { return token; } value = instance.Localize(token); if (token.StartsWith("$", StringComparison.Ordinal) && fairyLanguage != FairyWords.FromGame(instance.GetSelectedLanguage())) { string text = instance.TranslateSingleId(token, fairyLanguage.ToString()); if (!string.IsNullOrWhiteSpace(text)) { value = text; } } return speciesNames[(token, fairyLanguage)] = value; } } internal sealed class FairyAudio { private readonly float[] samples; private readonly int rate; private FairyAudio(float[] samples, int rate) { this.samples = samples; this.rate = rate; } internal AudioClip Clip(string name) { AudioClip obj = AudioClip.Create(name, samples.Length, 1, rate, false); obj.SetData(samples, 0); return obj; } internal static FairyAudio Studio(string code, Call call) { return Studio((code == "en" && call <= Call.WatchOut) ? ("Fairy." + call) : ("Fairy.voices." + code + "_" + call)); } internal static FairyAudio Studio(string name) { using Stream stream = typeof(FairyAudio).Assembly.GetManifestResourceStream(name + ".wav"); if (stream == null) { throw new FileNotFoundException(name); } using BinaryReader binaryReader = new BinaryReader(stream); stream.Position = 24L; int num = binaryReader.ReadInt32(); stream.Position = 40L; float[] array = new float[binaryReader.ReadInt32() / 2]; for (int i = 0; i < array.Length; i++) { array[i] = (float)binaryReader.ReadInt16() / 32768f; } return new FairyAudio(array, num); } internal static FairyAudio ReadGameVoice(FairyLanguage lang, string cue) { return ReadOriginal("Fairy.originals." + FairyWords.Codes[(int)lang] + "_" + cue + ".bwav", trimSilence: true); } internal static AudioClip ReadTargetSound() { return ReadOriginal("Fairy.sfx.SE_Navi_LockOnEnemy.bwav", trimSilence: false).Clip("SE_Navi_LockOnEnemy"); } private static FairyAudio ReadOriginal(string resource, bool trimSilence) { using Stream stream = typeof(FairyAudio).Assembly.GetManifestResourceStream(resource); if (stream == null) { throw new InvalidDataException("Missing original recording " + resource); } using BinaryReader binaryReader = new BinaryReader(stream); if (stream.Length < 92 || binaryReader.ReadUInt32() != 1447122754 || binaryReader.ReadUInt16() != 65279) { throw new InvalidDataException("BWAV header"); } stream.Position = 14L; if (binaryReader.ReadUInt16() != 1 || binaryReader.ReadUInt16() != 1) { throw new InvalidDataException("Expected mono DSP recording"); } stream.Position = 20L; int num = binaryReader.ReadInt32(); stream.Position = 28L; int num2 = binaryReader.ReadInt32(); short[] array = new short[16]; for (int i = 0; i < array.Length; i++) { array[i] = binaryReader.ReadInt16(); } stream.Position = 68L; long num3 = binaryReader.ReadUInt32(); if (num < 8000 || num > 96000 || num2 <= 0 || num2 > num * 12 || num3 < 92 || num3 + (num2 + 13) / 14 * 8 > stream.Length) { throw new InvalidDataException("BWAV sample bounds"); } stream.Position = 86L; int num4 = binaryReader.ReadInt16(); int num5 = binaryReader.ReadInt16(); stream.Position = num3; float[] array2 = new float[num2]; int num6 = 0; while (num6 < num2) { byte b = binaryReader.ReadByte(); int num7 = 2 * (b >> 4); int num8 = 1 << (b & 0xF); if (num7 >= array.Length) { throw new InvalidDataException("DSP predictor"); } for (int j = 0; j < 7; j++) { int num9 = binaryReader.ReadByte(); int num10 = 4; while (num10 >= 0 && num6 < num2) { int num11 = (num9 >> num10) & 0xF; if (num11 >= 8) { num11 -= 16; } long val = (long)num11 * (long)num8 * 2048 + (long)array[num7] * (long)num4 + (long)array[num7 + 1] * (long)num5 + 1024 >> 11; num5 = num4; num4 = (int)Math.Max(-32768L, Math.Min(32767L, val)); array2[num6++] = (float)num4 / 32768f; num10 -= 4; } } } if (!trimSilence) { return new FairyAudio(array2, num); } int k = 0; int num12; for (num12 = num2 - 1; k < num12 && Mathf.Abs(array2[k]) < 0.004f; k++) { } while (num12 > k && Mathf.Abs(array2[num12]) < 0.004f) { num12--; } k = Math.Max(0, k - num / 35); num12 = Math.Min(num2 - 1, num12 + num / 15); float[] array3 = new float[num12 - k + 1]; Array.Copy(array2, k, array3, 0, array3.Length); return new FairyAudio(array3, num); } internal FairyAudio Then(FairyAudio next) { int num = samples.Length + rate / 10; int num2 = Mathf.RoundToInt((float)next.samples.Length * (float)rate / (float)next.rate); float[] array = new float[num + num2]; Array.Copy(samples, array, samples.Length); for (int i = 0; i < num2; i++) { double num3 = (double)i * (double)next.rate / (double)rate; int num4 = Math.Min((int)num3, next.samples.Length - 1); array[num + i] = Mathf.Lerp(next.samples[num4], next.samples[Math.Min(num4 + 1, next.samples.Length - 1)], (float)(num3 - (double)num4)); } return new FairyAudio(array, rate); } } internal enum Call { HeyListen = 1, Look, WatchOut, Behind, Left, Right, Mechanism, Concern, Dungeon } internal static class FairyDialogue { internal const float Range = 16f; internal const float BubbleDuration = 3f; internal const float LocalRange = 13f; internal const string LastListen = "Zephyrfit.WispFairy.LastListenUtc"; private static readonly Func<Chat, GameObject, NpcText> FindBubble = AccessTools.MethodDelegate<Func<Chat, GameObject, NpcText>>(AccessTools.Method(typeof(Chat), "FindNpcText", (Type[])null, (Type[])null), (object)null, true); private static TMP_FontAsset[] fonts; internal static bool TakeListen(Player wearer) { long num = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); if (wearer.m_customData.TryGetValue("Zephyrfit.WispFairy.LastListenUtc", out var value) && long.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result) && result <= num && result > num - 60) { return false; } wearer.m_customData["Zephyrfit.WispFairy.LastListenUtc"] = num.ToString(CultureInfo.InvariantCulture); return true; } internal static AudioSource CreateSource(GameObject orb) { AudioSource val = orb.AddComponent<AudioSource>(); val.playOnAwake = false; val.spatialBlend = 0.85f; val.dopplerLevel = 0f; val.minDistance = 2f; val.maxDistance = 16f; val.rolloffMode = (AudioRolloffMode)1; if (Object.op_Implicit((Object)(object)AudioMan.instance) && Object.op_Implicit((Object)(object)AudioMan.instance.m_masterMixer)) { AudioMixerGroup[] array = AudioMan.instance.m_masterMixer.FindMatchingGroups("SFX"); foreach (AudioMixerGroup val2 in array) { if (string.Equals(((Object)val2).name, "SFX", StringComparison.OrdinalIgnoreCase)) { val.outputAudioMixerGroup = val2; break; } } } return val; } internal static void Show(GameObject orb, AudioSource source, Call call, bool wearer = false) { Present(orb, source, FairyWords.Ui(call.ToString()), call, wearer, 3f); } internal static void Personal(GameObject orb, AudioSource source, string words, Call? sound, float duration, AudioClip narration = null) { Present(orb, source, words, sound, wearer: true, duration, narration); } private static void Present(GameObject orb, AudioSource source, string words, Call? sound, bool wearer, float duration, AudioClip narration = null) { //IL_0018: 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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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) Player localPlayer = Player.m_localPlayer; if (!Object.op_Implicit((Object)(object)localPlayer)) { return; } if (!wearer) { Vector3 val = orb.transform.position - ((Character)localPlayer).GetCenterPoint(); if (((Vector3)(ref val)).sqrMagnitude > 256f) { return; } } if (Plugin.SpeechBubbles.Value && Object.op_Implicit((Object)(object)Chat.instance) && Object.op_Implicit((Object)(object)Hud.instance)) { Chat.instance.SetNpcText(orb, Vector3.up * 0.35f, wearer ? 29f : 16f, duration, "", words, false); NpcText val2 = FindBubble(Chat.instance, orb); if (val2 != null) { EnsureGlyphs((TMP_Text)(object)val2.m_textField, words); FairyOrb fairyOrb = default(FairyOrb); if (wearer && orb.TryGetComponent<FairyOrb>(ref fairyOrb)) { fairyOrb.TrackBubble(val2); } } } float num = Plugin.VoiceVolume.Value; if ((sound.HasValue || Object.op_Implicit((Object)(object)narration)) && !(num <= 0f)) { if (!Object.op_Implicit((Object)(object)source.outputAudioMixerGroup) && Object.op_Implicit((Object)(object)AudioMan.instance)) { num *= AudioMan.GetSFXVolume(); } source.spatialBlend = (wearer ? 0.52f : 0.95f); source.PlayOneShot(Object.op_Implicit((Object)(object)narration) ? narration : GameVoices.Clip(sound.Value), num); } } internal static void ReplaceCaption(GameObject orb, string words) { NpcText val = (Object.op_Implicit((Object)(object)Chat.instance) ? FindBubble(Chat.instance, orb) : null); if (val != null && !(val.m_text == words)) { EnsureGlyphs((TMP_Text)(object)val.m_textField, words); val.m_text = words; ((TMP_Text)val.m_textField).text = words; } } private static void EnsureGlyphs(TMP_Text field, string words) { uint[] array = default(uint[]); if (field.font.HasCharacters(words, ref array, true, true)) { return; } if (fonts == null) { fonts = Resources.FindObjectsOfTypeAll<TMP_FontAsset>(); } TMP_FontAsset[] array2 = fonts; foreach (TMP_FontAsset val in array2) { if (Object.op_Implicit((Object)(object)val) && (Object)(object)val != (Object)(object)field.font && val.HasCharacters(words, ref array, true, true)) { field.font = val; break; } } } } internal sealed class FairyFlight { private sealed class Threat { internal float Seen; internal float LastWarning = -100f; internal float LastFocused = -100f; internal Call Sector; internal Call LastSectorAnnounced; internal bool Pending; internal bool Accepted; internal bool Ambush; internal bool NewRearApproach; internal Vector3 LastPosition; internal bool ReachedOrbit; internal float Sweep; internal float HoverTime; } private static readonly int Solid = LayerMask.GetMask(new string[6] { "Default", "Default_small", "static_solid", "piece", "terrain", "vehicle" }); internal const float ThreatRange = 10f; private readonly Dictionary<Character, Threat> threats = new Dictionary<Character, Threat>(); private readonly List<Character> expired = new List<Character>(); private readonly ShoulderFlight shoulder = new ShoulderFlight(); private readonly CampFlight camp = new CampFlight(); private Transform lastTarget; private Character enemy; private Threat flightTarget; private Collider surface; private bool started; private bool remarkedOnDungeon; private bool sawHostile; private Vector3 position; private Vector3 speed; private Vector3 lastCenter; private Vector3 shoulderRight; private float nextScan; private float lastSeen; private float focusUntil; private float entryAngle; private float combatUntil; internal FocusKind Focus { get; private set; } internal bool AcquiredEnemy { get; private set; } internal Character WarningTarget { get; private set; } internal bool NewRearApproach { get; private set; } internal Character ObservedEnemy { get { if (Focus != FocusKind.Enemy) { return null; } return enemy; } } internal CampPose Pose => camp.Pose; internal bool RestingByFire => camp.RestingByFire; internal bool DangerNearby { get { if (!sawHostile) { return Time.time < combatUntil; } return true; } } internal bool IgnoredInCombat(ZDOID target) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) GameObject val = (Object.op_Implicit((Object)(object)ZNetScene.instance) ? ZNetScene.instance.FindInstance(target) : null); Character key = default(Character); if (Object.op_Implicit((Object)(object)val) && val.TryGetComponent<Character>(ref key) && threats.TryGetValue(key, out var value) && !value.Accepted) { return Time.time - value.Seen < 1.25f; } return false; } internal bool HasSpotted(Character creature) { if (Object.op_Implicit((Object)(object)creature) && threats.TryGetValue(creature, out var value) && value.Accepted) { return Time.time - value.Seen < 1.25f; } return false; } internal Vector3 Step(Player player, float dt, float phase, Vector3 vanillaPosition, bool canWarn, bool canSpeak, out Call? noticed, float tempo = 1f) { //IL_001e: 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_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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: 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) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Unknown result type (might be due to invalid IL or missing references) //IL_036a: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_035d: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_03a4: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_0399: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_03a6: Unknown result type (might be due to invalid IL or missing references) //IL_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_0447: Unknown result type (might be due to invalid IL or missing references) //IL_03e7: Unknown result type (might be due to invalid IL or missing references) //IL_03ec: Unknown result type (might be due to invalid IL or missing references) //IL_0402: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Unknown result type (might be due to invalid IL or missing references) //IL_040a: Unknown result type (might be due to invalid IL or missing references) //IL_040b: Unknown result type (might be due to invalid IL or missing references) //IL_040d: Unknown result type (might be due to invalid IL or missing references) //IL_0412: Unknown result type (might be due to invalid IL or missing references) //IL_0418: Unknown result type (might be due to invalid IL or missing references) //IL_041d: Unknown result type (might be due to invalid IL or missing references) //IL_041f: Unknown result type (might be due to invalid IL or missing references) //IL_0424: Unknown result type (might be due to invalid IL or missing references) //IL_0435: Unknown result type (might be due to invalid IL or missing references) //IL_043a: Unknown result type (might be due to invalid IL or missing references) noticed = null; AcquiredEnemy = false; NewRearApproach = false; WarningTarget = null; Vector3 centerPoint = ((Character)player).GetCenterPoint(); Vector3 eyePoint = ((Character)player).GetEyePoint(); float time = Time.time; Vector3 val; int num; if (started) { val = centerPoint - lastCenter; if (!(((Vector3)(ref val)).sqrMagnitude > 25f)) { val = centerPoint - position; num = ((((Vector3)(ref val)).sqrMagnitude > 225f) ? 1 : 0); goto IL_0074; } } num = 1; goto IL_0074; IL_0074: bool flag = (byte)num != 0; lastCenter = centerPoint; if (flag) { lastTarget = null; enemy = null; flightTarget = null; threats.Clear(); sawHostile = false; combatUntil = 0f; Focus = FocusKind.None; speed = Vector3.zero; nextScan = time + 0.65f; } if (time >= nextScan) { nextScan = time + 0.25f; noticed = Notice(player, eyePoint, time, canWarn, canSpeak); } if ((Focus == FocusKind.Object && (time >= focusUntil || !Object.op_Implicit((Object)(object)lastTarget))) || (Focus == FocusKind.Enemy && (!Object.op_Implicit((Object)(object)enemy) || enemy.IsDead()))) { Focus = FocusKind.None; } camp.Update(player, dt, sawHostile || Focus == FocusKind.Enemy); if (camp.Pose != CampPose.Flying && Focus == FocusKind.Object) { Focus = FocusKind.None; if (noticed == Call.Look || noticed == Call.Mechanism) { noticed = null; } } PlacementPreset value = Plugin.Placement.Value; Camera mainCamera = Utils.GetMainCamera(); Vector3 val2 = ShoulderFlight.Right(player, mainCamera); bool flag2 = value != PlacementPreset.Vanilla && Focus == FocusKind.None && camp.Pose == CampPose.Flying; if (flag2 && !flag && shoulderRight != Vector3.zero) { Quaternion val3 = ShoulderFlight.Turn(shoulderRight, val2); position = centerPoint + val3 * (position - centerPoint); speed = val3 * speed; } shoulderRight = (flag2 ? val2 : Vector3.zero); Vector3 destination = ((value == PlacementPreset.Vanilla) ? vanillaPosition : shoulder.Goal(player, mainCamera, val2, dt, phase, value == PlacementPreset.Variable)); if (Focus == FocusKind.Enemy) { Vector3 val4 = VisitEnemy(dt * tempo, phase); destination = centerPoint + Vector3.ClampMagnitude(val4 - centerPoint, 13f); } else if (camp.Pose != CampPose.Flying) { destination = camp.Goal(player, dt, tempo); } else if (Focus == FocusKind.Object) { Vector3 val5 = SurfacePoint(eyePoint) - eyePoint; if (((Vector3)(ref val5)).sqrMagnitude > 49f) { Focus = FocusKind.None; } else { destination = eyePoint + Vector3.ClampMagnitude(val5 - ((Vector3)(ref val5)).normalized * 0.32f, 2.35f) + Vector3.up * (0.24f + 0.08f * Mathf.Sin(phase * 5f)) + ((Component)player).transform.right * (0.14f * Mathf.Cos(phase * 4f)); } } destination = ClearPath(centerPoint, destination); if (flag || (value == PlacementPreset.Vanilla && Focus == FocusKind.None && camp.Pose == CampPose.Flying)) { position = (flag ? destination : Vector3.Lerp(position, destination, tempo)); speed = Vector3.zero; } else { float num2 = ((camp.Pose == CampPose.Perched) ? 0.065f : ((Focus == FocusKind.None) ? 0.19f : 0.135f)); Vector3 val6 = Vector3.SmoothDamp(position, destination, ref speed, num2 / tempo, 14f * tempo, dt); position = ClearPath(centerPoint, val6); val = position - val6; if (((Vector3)(ref val)).sqrMagnitude > 0.001f) { speed = Vector3.zero; } } started = true; return position; } internal Vector3 DisplayPosition(Player player, Camera camera, Vector3 simulated) { //IL_0015: 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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_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_0056: 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_0079: 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_0076: Unknown result type (might be due to invalid IL or missing references) if (Focus != FocusKind.None || camp.Pose != CampPose.Flying) { return simulated; } Vector3 centerPoint = ((Character)player).GetCenterPoint(); Vector3 val = simulated; if (shoulderRight != Vector3.zero) { val = centerPoint + ShoulderFlight.Turn(shoulderRight, ShoulderFlight.Right(player, camera)) * (val - centerPoint); } val = ShoulderFlight.KeepInView(player, camera, val); Vector3 val2 = val - simulated; if (!(((Vector3)(ref val2)).sqrMagnitude > 1E-06f)) { return simulated; } return ClearPath(centerPoint, val); } private Vector3 VisitEnemy(float dt, float phase) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_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_00b2: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_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_0158: 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_0182: 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_023a: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp(enemy.GetRadius() + 0.46f, 0.76f, 3.2f); Vector3 topPoint = enemy.GetTopPoint(); Vector3 val = (Object.op_Implicit((Object)(object)enemy.m_eye) ? enemy.GetEyePoint() : topPoint); val.y = Mathf.Max(val.y, topPoint.y) + 0.31f; Vector3 val2 = Vector3.Lerp(enemy.GetCenterPoint(), val, 0.5f); Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(Mathf.Cos(entryAngle), 0f, Mathf.Sin(entryAngle)); if (!flightTarget.ReachedOrbit) { Vector3 val4 = val2 + val3 * num; Threat threat = flightTarget; Vector3 val5 = position - val4; threat.ReachedOrbit = ((Vector3)(ref val5)).sqrMagnitude < 0.24f; if (!flightTarget.ReachedOrbit) { return val4; } } if (flightTarget.Sweep < MathF.PI * 2f) { float num2 = Mathf.Min(2.7f, 3.8f / num); flightTarget.Sweep = Mathf.Min(MathF.PI * 2f, flightTarget.Sweep + dt * num2); float num3 = entryAngle + flightTarget.Sweep; return val2 + new Vector3(Mathf.Cos(num3) * num, 0.095f * Mathf.Sin(phase * 3.6f), Mathf.Sin(num3) * num); } float num4 = (flightTarget.HoverTime += dt); Vector3 val6 = new Vector3(0f - val3.z, 0f, val3.x); float num5 = Mathf.Max(0f, num4 - 2.3f) / 4.6f; float num6 = Mathf.Clamp01((num5 - Mathf.Floor(num5)) * 4.6f / 1.22f); float num7 = Mathf.Sin(MathF.PI * num6); num7 *= num7; float num8 = (((Mathf.FloorToInt(num5) & 1) == 0) ? 1f : (-1f)); Vector3 val7 = val6 * (0.065f * Mathf.Sin(num4 * 1.6f) + num8 * 0.38f * num7) + val3 * (0.065f + 0.04f * Mathf.Sin(num4 * 2.1f) + 0.12f * num7 * Mathf.Sin(num6 * 2f * MathF.PI)) + Vector3.up * (0.075f * Mathf.Sin(num4 * 2.8f) + 0.08f * num7); return Vector3.Lerp(val2 + val3 * num, val + val7, Mathf.SmoothStep(0f, 1f, num4 / 0.72f)); } private Call? Notice(Player player, Vector3 eyes, float now, bool canWarn, bool canSpeak) { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_03e8: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_03f3: Unknown result type (might be due to invalid IL or missing references) //IL_03f8: Unknown result type (might be due to invalid IL or missing references) //IL_0427: Unknown result type (might be due to invalid IL or missing references) //IL_042e: Unknown result type (might be due to invalid IL or missing references) Character val = null; Character val2 = null; float num = float.MaxValue; float num2 = float.NegativeInfinity; if (sawHostile && ((Character)player).InAttack()) { combatUntil = now + 6f; } bool flag = now < combatUntil || (sawHostile && (player.IsTargeted() || !player.CanSwitchPVP())); sawHostile = false; foreach (Character allCharacter in Character.GetAllCharacters()) { if (!Object.op_Implicit((Object)(object)allCharacter) || (Object)(object)allCharacter == (Object)(object)player) { continue; } Vector3 val3 = ((Component)allCharacter).transform.position - ((Component)player).transform.position; float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude; if (sqrMagnitude > 100f || !IsThreat(player, allCharacter) || !InSight(eyes, allCharacter)) { continue; } sawHostile = true; Call call = Direction(((Component)player).transform, ((Component)allCharacter).transform.position); if (!threats.TryGetValue(allCharacter, out var value)) { float value2 = Plugin.CombatChance.Value; bool flag2 = !flag || call == Call.Behind || value2 >= 1f || (value2 > 0f && Random.value < value2); value = new Threat { Accepted = flag2, Pending = flag2, Ambush = (call == Call.Behind) }; threats.Add(allCharacter, value); } else { bool flag3 = now - value.Seen > 1.25f; bool flag4 = value.Sector != Call.Behind && call == Call.Behind && Direction(((Component)player).transform, value.LastPosition) != Call.Behind; if (call == Call.Behind && (flag3 || (flag4 && (value.LastSectorAnnounced != Call.Behind || now - value.LastWarning >= 3f)))) { value.Accepted = (value.Pending = (value.Ambush = (value.NewRearApproach = true))); } else if (flag3) { value.Pending = value.Accepted; } } value.Seen = now; value.Sector = call; value.LastPosition = ((Component)allCharacter).transform.position; if (!value.Accepted) { continue; } if (sqrMagnitude < num) { val = allCharacter; num = sqrMagnitude; } if (call != Call.Behind) { value.Ambush = (value.NewRearApproach = false); } if (call != Call.WatchOut && call != value.LastSectorAnnounced && now - value.LastWarning >= 5f) { value.Pending = true; } if ((canWarn || value.Ambush) && value.Pending) { float num3 = (value.Ambush ? 600f : (call switch { Call.WatchOut => 0f, Call.Behind => 300f, _ => 150f, })) - sqrMagnitude; if (num3 > num2) { num2 = num3; val2 = allCharacter; } } } expired.Clear(); foreach (KeyValuePair<Character, Threat> threat2 in threats) { if (!Object.op_Implicit((Object)(object)threat2.Key) || threat2.Key.IsDead() || now - threat2.Value.Seen > 15f) { expired.Add(threat2.Key); } } foreach (Character item in expired) { threats.Remove(item); } if (Object.op_Implicit((Object)(object)val)) { if ((Object)(object)val != (Object)(object)enemy) { Vector3 val4 = position - val.GetCenterPoint(); flightTarget = threats[val]; AcquiredEnemy = now - flightTarget.LastFocused > 1f; entryAngle = Mathf.Atan2(val4.z, val4.x) - flightTarget.Sweep; } flightTarget.LastFocused = now; enemy = val; lastTarget = null; Focus = FocusKind.Enemy; if (!Object.op_Implicit((Object)(object)val2)) { return null; } Threat threat = threats[val2]; NewRearApproach = threat.NewRearApproach; threat.NewRearApproach = false; threat.Pending = false; threat.Ambush = false; threat.LastWarning = now; threat.LastSectorAnnounced = threat.Sector; WarningTarget = val2; return threat.Sector; } if (Focus == FocusKind.Enemy) { Focus = FocusKind.None; } enemy = null; flightTarget = null; bool flag5 = ((Character)player).InInterior(); if (!flag5) { remarkedOnDungeon = false; } Component val5 = null; Collider val6 = null; GameObject hoverObject = ((Humanoid)player).GetHoverObject(); if (Object.op_Implicit((Object)(object)hoverObject)) { Interactable componentInParent = hoverObject.GetComponentInParent<Interactable>(); Component val7 = (Component)(object)((componentInParent is Component) ? componentInParent : null); if (val7 != null && !val7.transform.IsChildOf(((Component)player).transform)) { val5 = val7; val6 = hoverObject.GetComponent<Collider>(); } } Transform val8 = (Object.op_Implicit((Object)(object)val5) ? val5.transform : null); if (!Object.op_Implicit((Object)(object)val8)) { if (now - lastSeen > 0.65f) { lastTarget = null; Focus = FocusKind.None; } if (canSpeak && flag5 && !remarkedOnDungeon) { remarkedOnDungeon = true; return Call.Dungeon; } return null; } lastSeen = now; if ((Object)(object)val8 == (Object)(object)lastTarget) { return null; } lastTarget = val8; surface = val6; Focus = FocusKind.Object; focusUntil = now + 2.8f; return (val5 is Switch) ? Call.Mechanism : Call.Look; } private static bool IsThreat(Player player, Character other) { BaseAI baseAI = other.GetBaseAI(); MonsterAI val = (MonsterAI)(object)((baseAI is MonsterAI) ? baseAI : null); if (Object.op_Implicit((Object)(object)val) && !other.IsDead() && !other.IsTamed() && !((BaseAI)val).IsSleeping() && BaseAI.IsEnemy((Character)(object)player, other)) { if (!Object.op_Implicit((Object)(object)((BaseAI)val).GetTargetCreature()) && !((BaseAI)val).HaveTarget()) { return ((BaseAI)val).IsAlerted(); } return true; } return false; } internal static Call Direction(Transform wearer, Vector3 threatPosition) { //IL_0000: 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_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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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) Vector3 val = Vector3.ProjectOnPlane(threatPosition - wearer.position, Vector3.up); if (((Vector3)(ref val)).sqrMagnitude < 0.0064f) { return Call.WatchOut; } Vector3 val2 = Vector3.ProjectOnPlane(wearer.forward, Vector3.up); if (((Vector3)(ref val2)).sqrMagnitude < 0.0001f) { val2 = Vector3.Cross(wearer.right, Vector3.up); } ((Vector3)(ref val2)).Normalize(); float num = Vector3.Dot(((Vector3)(ref val)).normalized, val2); if (num < -0.57f) { return Call.Behind; } if (num > 0.57f) { return Call.WatchOut; } if (!(Vector3.Dot(val, Vector3.Cross(Vector3.up, val2)) < 0f)) { return Call.Right; } return Call.Left; } internal static bool InSight(Vector3 eyes, Character other) { //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_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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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) Vector3 centerPoint = other.GetCenterPoint(); Vector3 val = eyes - centerPoint; if (((Vector3)(ref val)).sqrMagnitude <= 100f && !ParticleMist.IsMistBlocked(eyes, centerPoint)) { return !Physics.Linecast(eyes, centerPoint, Solid, (QueryTriggerInteraction)1); } return false; } private Vector3 SurfacePoint(Vector3 eyes) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)surface)) { return lastTarget.position; } Bounds bounds = surface.bounds; return ((Bounds)(ref bounds)).ClosestPoint(eyes); } private static Vector3 ClearPath(Vector3 origin, Vector3 destination) { //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_005f: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) Vector3 val = destination - origin; float magnitude = ((Vector3)(ref val)).magnitude; RaycastHit val2 = default(RaycastHit); if (magnitude > 0.001f && Physics.SphereCast(origin, 0.115f, val / magnitude, ref val2, magnitude, Solid, (QueryTriggerInteraction)1)) { return origin + val / magnitude * Mathf.Max(0f, ((RaycastHit)(ref val2)).distance - 0.025f); } return destination; } } internal sealed class FairyHealth { private sealed class Threshold { private readonly float limit; private bool armed = true; private float recoveredAt = -1f; internal bool Pending; internal Threshold(float limit) { this.limit = limit; } internal void Suspend() { recoveredAt = -1f; } internal void Update(float value, float now) { if (value <= limit) { Pending |= armed; armed = false; recoveredAt = -1f; return; } Pending = false; if (recoveredAt < 0f) { recoveredAt = now; } if (now - recoveredAt >= 45f) { armed = true; } } } internal const float RecoverySeconds = 45f; private readonly Threshold half = new Threshold(0.5f); private readonly Threshold quarter = new Threshold(0.25f); internal void Update(float fraction, float now) { half.Update(fraction, now); quarter.Update(fraction, now); } internal string Take() { if (quarter.Pending) { quarter.Pending = (half.Pending = false); return "CriticalHealth"; } if (half.Pending) { half.Pending = false; return "WoundedHealth"; } return null; } internal void Suspend() { half.Suspend(); quarter.Suspend(); } } internal sealed class FairyMenu : MonoBehaviour { [HarmonyPatch(typeof(GameCamera), "UpdateMouseCapture")] private static class MouseCapture { private static bool Prefix() { return !Open; } } [HarmonyPatch(typeof(Menu), "Update")] private static class PauseMenu { private static bool Prefix() { if (!Open) { return Time.frameCount != closedFrame; } return false; } } [HarmonyPatch] private static class InputCapture { private static IEnumerable<MethodBase> TargetMethods() { yield return AccessTools.Method(typeof(PlayerController), "TakeInput", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(Player), "TakeInput", (Type[])null, (Type[])null); } private static bool Prefix(ref bool __result) { if (!Open) { return true; } __result = false; return false; } } private static int closedFrame = -1; private CursorLockMode previousLock; private bool previousCursor; private Vector2 position; private Vector2 scroll; private Vector2 titleGrab; private AudioSource preview; private Font font; private GUIStyle titleStyle; private GUIStyle caption; private GUIStyle value; private float width; private int lastWidth; private int lastHeight; private float lastScale; private const int WindowId = 1465077830; internal static bool Open { get; private set; } private void Update() { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) if (Open && (!Object.op_Implicit((Object)(object)Player.m_localPlayer) || ((Character)Player.m_localPlayer).IsDead() || Input.GetKeyDown((KeyCode)27))) { SetOpen(show: false); } else if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { KeyboardShortcut val = Plugin.MenuKey.Value; if (((KeyboardShortcut)(ref val)).IsDown() && (Open || !Object.op_Implicit((Object)(object)Chat.instance) || !Chat.instance.HasFocus())) { SetOpen(!Open); } } } internal void SetOpen(bool show) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) if (show == Open) { return; } if (show) { previousLock = Cursor.lockState; previousCursor = Cursor.visible; position = Plugin.WindowPosition.Value; lastScale = 0f; Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } else { Plugin.WindowPosition.Value = position; closedFrame = Time.frameCount; if (Object.op_Implicit((Object)(object)preview)) { preview.Stop(); } Cursor.lockState = previousLock; Cursor.visible = previousCursor; } Open = show; } private void OnEnable() { Plugin.Bank.SettingChanged += OnBankChanged; } private void OnBankChanged(object sender, EventArgs args) { if (Object.op_Implicit((Object)(object)preview)) { preview.Stop(); } FairyOrb.StopVoices(); } private void OnDisable() { Plugin.Bank.SettingChanged -= OnBankChanged; if (Open) { SetOpen(show: false); } } private void OnGUI() { //IL_0264: 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_00c1: 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_013a: 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_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: 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_0170: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Expected O, but got Unknown //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Expected O, but got Unknown //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Expected O, but got Unknown //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Expected O, but got Unknown //IL_025c: Unknown result type (might be due to invalid IL or missing references) if (!Open) { return; } float num = Mathf.Min(new float[3] { Plugin.Scale.Value, (float)Screen.width / 472f, (float)Screen.height / 200f }); width = Mathf.Min(520f, (float)Screen.width / num - 12f); float height = Mathf.Min(560f, (float)Screen.height / num - 12f); float num2 = Mathf.Max(0f, (float)Screen.width / num - width); float num3 = Mathf.Max(0f, (float)Screen.height / num - height); Matrix4x4 matrix = GUI.matrix; Font val = GUI.skin.font; if (!Object.op_Implicit((Object)(object)font)) { font = Font.CreateDynamicFontFromOSFont(new string[5] { "Microsoft YaHei UI", "Yu Gothic", "Noto Sans CJK SC", "Arial", "DejaVu Sans" }, 15); } if (Object.op_Implicit((Object)(object)font)) { GUI.skin.font = font; } GUI.matrix = Matrix4x4.Scale(Vector3.one * num); try { if (titleStyle == null) { titleStyle = new GUIStyle(GUI.skin.label) { fontSize = 19, fontStyle = (FontStyle)1, alignment = (TextAnchor)3 }; caption = new GUIStyle(GUI.skin.label) { fontSize = 14, alignment = (TextAnchor)3 }; value = new GUIStyle(caption) { alignment = (TextAnchor)4 }; } if (lastWidth != Screen.width || lastHeight != Screen.height || !Mathf.Approximately(lastScale, num)) { position = Plugin.WindowPosition.Value; lastWidth = Screen.width; lastHeight = Screen.height; lastScale = num; } Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(Mathf.Clamp01(position.x) * num2, Mathf.Clamp01(position.y) * num3, width, height); GUI.Window(1465077830, val2, (WindowFunction)delegate { Contents(height); }, ""); } finally { GUI.matrix = matrix; GUI.skin.font = val; } } private void Contents(float height) { //IL_0000: 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_0040: 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_00a4: 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_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_041f: Unknown result type (might be due to invalid IL or missing references) //IL_0537: Unknown result type (might be due to invalid IL or missing references) Color color = GUI.color; GUI.color = new Color(0.065f, 0.075f, 0.08f, 0.9f); GUI.DrawTexture(new Rect(2f, 2f, width - 4f, height - 4f), (Texture)(object)Texture2D.whiteTexture); GUI.color = color; GUI.Label(new Rect(16f, 6f, width - 116f, 32f), FairyWords.Ui("Title"), titleStyle); if (GUI.Button(new Rect(width - 100f, 9f, 85f, 27f), FairyWords.Ui("Close"))) { SetOpen(show: false); } DragTitle(height); float num = width - 52f; bool flag = Plugin.Bank.Value == VoiceBank.Studio; bool flag2 = flag && FairyWords.Resolve(Plugin.VoiceLanguage.Value) == FairyLanguage.English; float y = 0f; scroll = GUI.BeginScrollView(new Rect(12f, 46f, width - 23f, height - 108f), scroll, new Rect(0f, 0f, num, (float)(flag2 ? 606 : 568))); try { Toggle(ref y, num, "Winged", Plugin.Winged); if (Plugin.Winged.Value) { Choice(ref y, num, "Palette", Plugin.Palette, (FairyPalette p) => FairyWords.Ui(p.ToString())); Toggle(ref y, num, "Context", Plugin.React); Choice(ref y, num, "Wake", Plugin.Wake, (WakeStyle w) => FairyWords.Ui(w.ToString())); } else { Choice(ref y, num, "WispPalette", Plugin.WispPalette, (WispColour p) => FairyWords.Ui(p.ToString())); Toggle(ref y, num, "Context", Plugin.WispReact); Choice(ref y, num, "Wake", Plugin.WispWake, (WakeStyle w) => FairyWords.Ui(w.ToString())); } Choice(ref y, num, "Placement", Plugin.Placement, (PlacementPreset p) => FairyWords.Ui(p.ToString())); Toggle(ref y, num, "TargetSound", Plugin.TargetSound); Choice<FairyLanguage>(ref y, num, "Captions", Plugin.TextLanguage, FairyWords.Label); Choice(ref y, num, "Bank", Plugin.Bank, (VoiceBank b) => FairyWords.Ui((b == VoiceBank.Studio) ? "Studio" : "Official"), GameVoices.Banks); Choice(ref y, num, "Voice", Plugin.VoiceLanguage, flag ? new Func<FairyLanguage, string>(GameVoices.StudioLabel) : new Func<FairyLanguage, string>(FairyWords.Label)); if (flag2) { Choice(ref y, num, "EnglishAccent", Plugin.EnglishAccent, (EnglishVoice a) => FairyWords.Ui(a.ToString())); } (VoiceBank, FairyLanguage) tuple = GameVoices.Selection(); GUI.Label(new Rect(2f, y, num - 149f, 31f), FairyWords.Ui("Using") + " · " + ((tuple.Item1 == VoiceBank.Studio) ? GameVoices.StudioLabel(tuple.Item2) : (FairyWords.Ui("Official") + " · " + FairyWords.Label(tuple.Item2))), caption); if (GUI.Button(new Rect(num - 145f, y, 145f, 30f), FairyWords.Ui("Play"))) { Play(); } y += 40f; Slider(ref y, num, "Level", Plugin.VoiceVolume, 0f, 1f, Plugin.VoiceVolume.Value.ToString("P0")); Slider(ref y, num, "Interval", Plugin.CallInterval, 4f, 120f, Mathf.RoundToInt(Plugin.CallInterval.Value) + " s"); Toggle(ref y, num, "Speech", Plugin.SpeechBubbles); Slider(ref y, num, "CombatChance", Plugin.CombatChance, 0f, 1f, Plugin.CombatChance.Value.ToString("P0")); Toggle(ref y, num, "CreatureTips", Plugin.CreatureTips); } finally { GUI.EndScrollView(); } GUI.BeginGroup(new Rect(15f, height - 50f, width - 30f, 43f)); float y2 = 0f; Slider(ref y2, width - 33f, "Size", Plugin.Scale, 0.65f, 1.7f, Plugin.Scale.Value.ToString("P0")); GUI.EndGroup(); } private void DragTitle(float height) { //IL_002e: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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: Invalid comparison between Unknown and I4 //IL_004b: 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_008d: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Invalid comparison between Unknown and I4 //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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_0120: Invalid comparison between Unknown and I4 //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) Rect val = default(Rect); ((Rect)(ref val))..ctor(0f, 0f, width - 105f, 42f); Event current = Event.current; int controlID = GUIUtility.GetControlID(1465077831, (FocusType)2, val); EventType typeForControl = current.GetTypeForControl(controlID); if ((int)typeForControl == 0 && current.button == 0 && ((Rect)(ref val)).Contains(current.mousePosition)) { titleGrab = current.mousePosition; GUIUtility.hotControl = controlID; current.Use(); } else if (GUIUtility.hotControl == controlID && ((int)typeForControl == 3 || (int)typeForControl == 1)) { Vector2 val2 = current.mousePosition - titleGrab; float num = (float)Screen.width / lastScale - width; float num2 = (float)Screen.height / lastScale - height; if (num > 0.01f) { position.x = Mathf.Clamp01(position.x + val2.x / num); } if (num2 > 0.01f) { position.y = Mathf.Clamp01(position.y + val2.y / num2); } if ((int)typeForControl == 1) { GUIUtility.hotControl = 0; Plugin.WindowPosition.Value = position; } current.Use(); } } private void Choice<T>(ref float y, float w, string key, ConfigEntry<T> entry, Func<T, string> label, T[] options = null) where T : struct, Enum { //IL_0020: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Floor(w * 0.4f); GUI.Label(new Rect(2f, y, num - 3f, 30f), FairyWords.Ui(key), caption); int num2 = (GUI.Button(new Rect(num, y, 30f, 28f), "‹") ? (-1) : 0); GUI.Label(new Rect(num + 31f, y, w - num - 62f, 29f), label(entry.Value), value); if (GUI.Button(new Rect(w - 30f, y, 30f, 28f), "›")) { num2 = 1; } if (num2 != 0) { T[] array = options ?? ((T[])Enum.GetValues(typeof(T))); int num3 = Mathf.Max(0, Array.IndexOf(array, entry.Value)); entry.Value = array[(num3 + num2 + array.Length) % array.Length]; } y += 38f; } private void Slider(ref float y, float w, string key, ConfigEntry<float> entry, float min, float max, string current) { //IL_001a: 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_0095: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Floor(w * 0.4f); GUI.Label(new Rect(2f, y, num, 30f), FairyWords.Ui(key), caption); float num2 = GUI.HorizontalSlider(new Rect(num + 4f, y + 10f, w - num - 73f, 20f), entry.Value, min, max); if (!Mathf.Approximately(num2, entry.Value)) { entry.Value = (float)Math.Round(num2, 2); } GUI.Label(new Rect(w - 67f, y, 66f, 29f), current, value); y += 37f; } private void Toggle(ref float y, float w, string key, ConfigEntry<bool> entry) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) bool flag = GUI.Toggle(new Rect(3f, y + 2f, w - 5f, 28f), entry.Value, " " + FairyWords.Ui(key)); if (flag != entry.Value) { entry.Value = flag; } y += 36f; } private void Play() { if (!Object.op_Implicit((Object)(object)preview)) { preview = FairyDialogue.CreateSource(((Component)this).gameObject); preview.spatialBlend = 0f; } preview.Stop(); float num = Plugin.VoiceVolume.Value; if (!Object.op_Implicit((Object)(object)preview.outputAudioMixerGroup) && Object.op_Implicit((Object)(object)AudioMan.instance)) { num *= AudioMan.GetSFXVolume(); } if (num > 0f) { preview.PlayOneShot(GameVoices.Clip(Call.HeyListen), num); } } } [DisallowMultipleComponent] [DefaultExecutionOrder(9000)] internal sealed class FairyOrb : MonoBehaviour { private static readonly int CallKey = StringExtensionMethods.GetStableHashCode("Zephyrfit.WispFairy.Call"); private static readonly int DialogueKey = StringExtensionMethods.GetStableHashCode("Zephyrfit.WispFairy.Dialogue"); internal const string WarningTargetKey = "Zephyrfit.WispFairy.WarningTarget"; internal const string TrackedTargetKey = "Zephyrfit.WispFairy.TrackedTarget"; private static readonly int TrackedSinceKey = StringExtensionMethods.GetStableHashCode("Zephyrfit.WispFairy.TrackedSince"); private static readonly int WearerNameKey = StringExtensionMethods.GetStableHashCode("Zephyrfit.WispFairy.WearerName"); private static readonly int FocusKey = StringExtensionMethods.GetStableHashCode("Zephyrfit.WispFairy.Focus"); internal static readonly int TargetSoundKey = StringExtensionMethods.GetStableHashCode("Zephyrfit.WispFairy.HostileLock"); private static readonly int StyleKey = StringExtensionMethods.GetStableHashCode("Zephyrfit.WispFairy.Style"); internal static readonly int PresenceKey = StringExtensionMethods.GetStableHashCode("Zephyrfit.WispFairy.VitalityAndPose"); private const int DefaultStyle = 112; internal const int NativeForm = 128; private static Player lastWearer; private static FairyHealth healthWarnings; private static FairyAdvice advice; private static float nextCall; private static float nextWarning; private static AudioClip targetClip; private static readonly List<FairyOrb> nearby = new List<FairyOrb>(); private static EnemyAnnouncements announcements = new EnemyAnnouncements(); private static FairyOrb worn; private ZNetView view; private FairySkin skin; private AudioSource voice; private AudioSource targetAudio; private NpcText ownBubble; private FairyFlight flight; private Vector3 flightPosition; private Vector3 viewPosition; private bool adjustedForView; private float greetingAt; private bool greeted; private FocusKind focus; private long heard; private long heardTarget; private ZDOID spokenTarget; private ZDOID queuedTarget; private ZDOID trackedTarget; private long trackedSince; private float nextContact; private string spokenLine; private string wearerName; private Call queuedCall; private float spokenUntil; private float queuedAt; private long queuedStamp; private ZDOID pendingChime; private float chimeAt; private int style = 112; private int presence = 100; private float flightClock; private float visualClock; private float visualHealth = 1f; private float personalUntil; private string healthLine; private float healthUntil; internal static FairyOrb Attach(GameObject orb) { FairyOrb result = default(FairyOrb); if (!orb.TryGetComponent<FairyOrb>(ref result)) { return orb.AddComponent<FairyOrb>(); } return result; } private void Awake() { view = ((Component)this).GetComponent<ZNetView>(); skin = new FairySkin(((Component)this).gameObject); voice = FairyDialogue.CreateSource(((Component)this).gameObject); flightClock = (visualClock = Time.time + (float)(((Object)this).GetInstanceID() & 0xFF) / 29f); } private void OnEnable() { nearby.Add(this); } internal static void StopVoices() { foreach (FairyOrb item in nearby) { if (Object.op_Implicit((Object)(object)item) && Object.op_Implicit((Object)(object)item.voice)) { item.voice.Stop(); } } } internal static void BeforeNativeStep(GameObject orb) { if (Object.op_Implicit((Object)(object)worn) && (Object)(object)((Component)worn).gameObject == (Object)(object)orb) { worn.RestoreFlightPosition(); } } private void RestoreFlightPosition() { //IL_000f: 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_0028: Unknown result type (might be due to invalid IL or missing references) if (adjustedForView) { if (((Component)this).transform.position == viewPosition) { ((Component)this).transform.position = flightPosition; } adjustedForView = false; } } private void PlaceInView(Player wearer, Camera camera) { //IL_001e: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) RestoreFlightPosition(); if (Object.op_Implicit((Object)(object)camera) && Object.op_Implicit((Object)(object)wearer)) { flightPosition = ((Component)this).transform.position; viewPosition = flight.DisplayPosition(wearer, camera, flightPosition); adjustedForView = viewPosition != flightPosition; if (adjustedForView) { ((Component)this).transform.position = viewPosition; } } } internal void Follow(Player wearer, float dt) { //IL_019e: 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_0267: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_04e4: Unknown result type (might be due to invalid IL or missing references) //IL_04d2: Unknown result type (might be due to invalid IL or missing references) //IL_04e9: Unknown result type (might be due to invalid IL or missing references) //IL_056c: Unknown result type (might be due to invalid IL or missing references) //IL_052a: Unknown result type (might be due to invalid IL or missing references) ZDO val = ((Object.op_Implicit((Object)(object)view) && view.IsValid()) ? view.GetZDO() : null); if (val != null && !view.IsOwner()) { return; } worn = this; if (flight == null) { flight = new FairyFlight(); wearerName = wearer.GetPlayerName(); if (val != null) { val.Set(WearerNameKey, wearerName); } greetingAt = Time.time + 0.35f; if ((Object)(object)lastWearer != (Object)(object)wearer) { lastWearer = wearer; nextCall = (nextWarning = 0f); healthWarnings = new FairyHealth(); advice = new FairyAdvice(); } } int num = (Plugin.Winged.Value ? ((int)((uint)Plugin.Palette.Value | (uint)(Plugin.React.Value ? 16 : 0)) | ((int)Plugin.Wake.Value << 5)) : ((int)((uint)((WispColour)128 | Plugin.WispPalette.Value) | (uint)(Plugin.WispReact.Value ? 16 : 0)) | ((int)Plugin.WispWake.Value << 5))); if (num != style) { style = num; if (val != null) { val.Set(St