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 Fylgja The Second Flame Individual Resurrection v0.5.1
BepInEx/plugins/Fylgja/Fylgja.dll
Decompiled 3 weeks 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.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("Enoq")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Individual Resurrection for Valheim. By Enoq.")] [assembly: AssemblyFileVersion("0.5.1.0")] [assembly: AssemblyInformationalVersion("0.5.1")] [assembly: AssemblyProduct("Fylgja: The Second Flame")] [assembly: AssemblyTitle("Fylgja: The Second Flame - Individual Resurrection")] [assembly: AssemblyVersion("0.5.1.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 Fylgja { internal static class DeathController { private sealed class PendingDeath { internal readonly DeathDecision Decision = new DeathDecision(); internal Player Player; internal ZNetView View; internal long CharacterId; internal Vector3 Position; internal Quaternion Rotation; internal Rigidbody Body; internal RigidbodyConstraints Constraints; internal bool Kinematic; internal bool Collisions; internal RevivalAudit.Snapshot Audit; internal float Deadline; internal float ShowAt; } private static PendingDeath pending; private static Player protectedPlayer; private static float protectionUntil; private static bool runningVanilla; private static Player observedPlayer; private static bool hadCooldownAtDeath; internal static bool HadStoneAtDeath { get; private set; } internal static bool HasChoice { get { if (pending != null) { return pending.Decision.Phase == DeathPhase.Pending; } return false; } } internal static bool ChoiceVisible { get { if (HasChoice) { return Time.unscaledTime >= pending.ShowAt; } return false; } } internal static int DecisionRemaining { get { if (pending != null) { return Mathf.Max(0, Mathf.CeilToInt(pending.Deadline - Time.unscaledTime)); } return 0; } } internal static bool Observed(Player player) { if (Object.op_Implicit((Object)(object)player)) { return (Object)(object)observedPlayer == (Object)(object)player; } return false; } internal static bool HasDeathStone(Player player) { if (Observed(player)) { return HadStoneAtDeath; } return false; } internal static bool ShouldShowPanel(Player player) { if (HasDeathStone(player)) { if (!IsWaiting((Character)(object)player)) { return hadCooldownAtDeath; } return true; } return false; } internal static long Remaining(Player player) { player.m_customData.TryGetValue("com.enoq.fylgja.cooldown.utc.v1", out var value); return CooldownClock.Remaining(value, DateTimeOffset.UtcNow.ToUnixTimeSeconds()); } internal static bool Owned(Player player) { if (!Object.op_Implicit((Object)(object)player) || (Object)(object)player != (Object)(object)Player.m_localPlayer) { return false; } ZNetView component = ((Component)player).GetComponent<ZNetView>(); if (Object.op_Implicit((Object)(object)component) && component.IsValid()) { return component.IsOwner(); } return false; } internal static bool IsWaiting(Character character) { if (pending != null) { return (Object)(object)pending.Player == (Object)(object)character; } return false; } internal static bool IsProtected(Character character) { if (Object.op_Implicit((Object)(object)character) && (Object)(object)character == (Object)(object)protectedPlayer && (Object)(object)character == (Object)(object)Player.m_localPlayer) { return Time.unscaledTime < protectionUntil; } return false; } internal static bool BeforeDeath(Player player) { //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) if (runningVanilla) { return true; } if (IsWaiting((Character)(object)player)) { return false; } if (Owned(player) && !((Character)player).IsDead()) { observedPlayer = player; HadStoneAtDeath = Stone.Find(player) != null; hadCooldownAtDeath = Remaining(player) > 0; } if (!Settings.Enabled.Value || !Owned(player) || ((Character)player).IsDead() || ((Character)player).GetHealth() > 0f || Stone.Find(player) == null || Remaining(player) != 0L || !DeathScreen.Ready || !Object.op_Implicit((Object)(object)Game.instance) || Game.instance.WaitingForRespawn() || Game.instance.IsShuttingDown()) { return true; } Rigidbody component = ((Component)player).GetComponent<Rigidbody>(); if (!Object.op_Implicit((Object)(object)component)) { return true; } (pending = new PendingDeath { Player = player, View = ((Component)player).GetComponent<ZNetView>(), CharacterId = player.GetPlayerID(), Position = ((Component)player).transform.position, Rotation = ((Component)player).transform.rotation, Body = component, Constraints = component.constraints, Deadline = Time.unscaledTime + (float)Settings.ChoiceSeconds.Value, Kinematic = component.isKinematic, Collisions = component.detectCollisions, Audit = RevivalAudit.Capture(player), ShowAt = Time.unscaledTime + 1.25f }).View.GetZDO().Set(ZDOVars.s_dead, true); try { DeathPresentation.Begin(player); } catch (Exception ex) { Plugin.Warn("Could not present pending death; continuing native death: " + ex); NormalDeath(); return false; } component.linearVelocity = Vector3.zero; component.angularVelocity = Vector3.zero; component.constraints = (RigidbodyConstraints)126; ((Character)player).Message((MessageType)2, "$msg_youdied", 0, (Sprite)null, false); Plugin.Info("Player death deferred; stone available; awaiting explicit choice."); return false; } internal static void Tick() { if (Object.op_Implicit((Object)(object)observedPlayer) && !((Character)observedPlayer).IsDead() && pending == null) { observedPlayer = null; HadStoneAtDeath = false; hadCooldownAtDeath = false; } if (pending == null) { return; } if (!Object.op_Implicit((Object)(object)pending.Player)) { pending = null; DeathScreen.Close(); } else if (HasChoice) { if (!Owned(pending.Player)) { RestoreBody(pending); pending = null; DeathScreen.Close(); } else if (!((Character)pending.Player).IsDead()) { PendingDeath pendingDeath = pending; pending = null; RestoreBody(pendingDeath); DeathPresentation.Restore(pendingDeath.Player); DeathScreen.Close(); } else if (!Settings.Enabled.Value || Time.unscaledTime >= pending.Deadline) { NormalDeath(); } } } internal static void NormalDeath() { //IL_005b: 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_0072: 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) PendingDeath pendingDeath = pending; if (pendingDeath == null || !pendingDeath.Decision.ChooseNormal()) { return; } pending = null; DeathScreen.Close(); RestoreBody(pendingDeath); if (!Owned(pendingDeath.Player)) { return; } if (!((Character)pendingDeath.Player).IsDead()) { DeathPresentation.Restore(pendingDeath.Player); return; } ((Component)pendingDeath.Player).transform.SetPositionAndRotation(pendingDeath.Position, pendingDeath.Rotation); pendingDeath.Body.position = pendingDeath.Position; pendingDeath.Body.rotation = pendingDeath.Rotation; runningVanilla = true; try { DeathPresentation.BeginNormal(pendingDeath.Player); ((Character)pendingDeath.Player).OnDeath(); Plugin.Info("Normal death selected; vanilla inventory and skill consequences applied."); } finally { runningVanilla = false; DeathPresentation.EndNormal(pendingDeath.Player); } } internal unsafe static void TryRevive() { //IL_0216: 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_027c: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) PendingDeath pendingDeath = pending; if (pendingDeath == null || pendingDeath.Decision.Phase != DeathPhase.Pending) { return; } Player player = pendingDeath.Player; if (!Settings.Enabled.Value || !Owned(player) || !Object.op_Implicit((Object)(object)pendingDeath.View) || !pendingDeath.View.IsValid() || (Object)(object)pendingDeath.View != (Object)(object)((Component)player).GetComponent<ZNetView>() || player.GetPlayerID() != pendingDeath.CharacterId || !((Character)player).IsDead() || Game.instance.WaitingForRespawn() || Game.instance.IsShuttingDown() || Time.unscaledTime >= pendingDeath.Deadline || Remaining(player) != 0L) { Reject("invalid"); return; } ItemData val = Stone.Find(player); if (val == null) { Reject("invalid"); return; } if (!SafePosition.TryFind(player, pendingDeath.Position, out var result)) { Reject("unsafe"); return; } string value = CooldownClock.Start(DateTimeOffset.UtcNow.ToUnixTimeSeconds(), Settings.Cooldown.Value); if (!pendingDeath.Decision.TryBegin(Owned(player), ((Character)player).IsDead(), ((Humanoid)player).GetInventory().ContainsItem(val), Remaining(player))) { return; } int stack = val.m_stack; bool flag = false; try { try { flag = ((Humanoid)player).GetInventory().RemoveItem(val, 1); } catch (Exception ex) { flag = !((Humanoid)player).GetInventory().ContainsItem(val) || val.m_stack == stack - 1; if (!flag) { throw; } Plugin.Warn("Inventory callback failed after consumption: " + ex); } if (!flag) { pendingDeath.Decision.Abort(); Reject("invalid"); return; } player.m_customData["com.enoq.fylgja.cooldown.utc.v1"] = value; CompleteRevive(pendingDeath, result); } catch (Exception ex2) { Plugin.Warn("Revival error: " + ex2); if (!flag) { pendingDeath.Decision.Abort(); Reject("invalid"); return; } player.m_customData["com.enoq.fylgja.cooldown.utc.v1"] = value; try { FinishCore(pendingDeath, result); } catch (Exception ex3) { Plugin.Warn("Critical recovery failure after stone consumption; continuing normal death. " + ex3); pendingDeath.Decision.Abort(); NormalDeath(); return; } } pendingDeath.Decision.Complete(); pending = null; DeathScreen.Close(); RevivalAudit.Finish(player, pendingDeath.Audit); Vector3 val2 = result; Plugin.Info("Consumed one Fylgja Stone; inventory/equipment and skills retained; food cleared; revived at " + ((object)(*(Vector3*)(&val2))/*cast due to .constrained prefix*/).ToString() + "."); try { Game.instance.SavePlayerProfile(false, false); } catch (Exception ex4) { Plugin.Warn("Could not save revived character; native save will retry: " + ex4); } try { DeathPresentation.Revive(player); ((Character)player).Message((MessageType)2, "$fylgja_called", 0, (Sprite)null, false); } catch (Exception ex5) { Plugin.Warn("Revive succeeded, but feedback failed: " + ex5.Message); } } private static void CompleteRevive(PendingDeath state, Vector3 destination) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) state.Player.StopDoodadControl(); ((Character)state.Player).AttachStop(); ((Character)state.Player).GetSEMan().RemoveAllStatusEffects(false); FinishCore(state, destination); } private static void FinishCore(PendingDeath state, Vector3 destination) { //IL_0013: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) Player player = state.Player; GameAccess.RestoreBaseStats(player); ((Component)player).transform.SetPositionAndRotation(destination, state.Rotation); state.Body.position = destination; state.Body.rotation = state.Rotation; state.Body.linearVelocity = Vector3.zero; state.Body.angularVelocity = Vector3.zero; GameAccess.ResetMotion(player, destination); protectedPlayer = player; protectionUntil = Time.unscaledTime + Settings.Protection.Value; state.View.GetZDO().Set(ZDOVars.s_dead, false); state.View.GetZDO().Set(ZDOVars.s_stamina, player.GetStamina()); RestoreBody(state); try { ZSyncTransform component = ((Component)player).GetComponent<ZSyncTransform>(); if (component != null) { component.SyncNow(); } } catch (Exception ex) { Plugin.Warn("Immediate position sync failed; normal ZDO synchronization will retry: " + ex.Message); } } private static void RestoreBody(PendingDeath state) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)state.Body)) { state.Body.constraints = state.Constraints; state.Body.isKinematic = state.Kinematic; state.Body.detectCollisions = state.Collisions; } } private static void Reject(string reason) { Plugin.Info("Revive rejected: " + reason + "; stone/cooldown unchanged."); Player val = pending?.Player; NormalDeath(); if (Object.op_Implicit((Object)(object)val)) { ((Character)val).Message((MessageType)1, "$fylgja_" + reason, 0, (Sprite)null, false); } } } internal static class DeathPresentation { private static Player owner; private static Ragdoll corpse; private static Player handingOff; private static bool normalNotified; internal static void Begin(Player player) { owner = player; normalNotified = false; corpse = GameAccess.CreateVisualCorpse(player); if (!Object.op_Implicit((Object)(object)corpse)) { throw new InvalidOperationException("Native player ragdoll was not created"); } ((MonoBehaviour)corpse).CancelInvoke("DestroyNow"); ((MonoBehaviour)corpse).InvokeRepeating("DestroyNow", (float)Settings.ChoiceSeconds.Value + 15f, 1f); Ensure(player).SetPending(value: true); } internal static void BeginNormal(Player player) { handingOff = player; Ensure(player).SetPending(value: false); } internal static bool CreateNativeEffects(Player player) { if ((Object)(object)handingOff != (Object)(object)player || (Object)(object)owner != (Object)(object)player || !Object.op_Implicit((Object)(object)corpse) || (Object)(object)player.GetRagdoll() != (Object)(object)corpse) { return true; } if (!normalNotified) { normalNotified = true; ((MonoBehaviour)corpse).CancelInvoke("DestroyNow"); ((MonoBehaviour)corpse).InvokeRepeating("DestroyNow", corpse.m_ttl, 1f); try { GameAccess.NotifyNormalCorpse(player, corpse); } catch (Exception ex) { Plugin.Warn("A normal corpse callback failed: " + ex); } } return false; } internal static void EndNormal(Player player) { if ((Object)(object)owner == (Object)(object)player) { owner = null; corpse = null; } handingOff = null; } internal static void Restore(Player player) { if ((Object)(object)owner == (Object)(object)player) { if (Object.op_Implicit((Object)(object)corpse)) { if ((Object)(object)player.GetRagdoll() == (Object)(object)corpse) { GameAccess.RagdollField.SetValue(player, null); } ZNetView component = ((Component)corpse).GetComponent<ZNetView>(); if (Object.op_Implicit((Object)(object)component) && component.IsValid()) { if (component.IsOwner() && Object.op_Implicit((Object)(object)ZNetScene.instance)) { ZNetScene.instance.Destroy(((Component)corpse).gameObject); } } else { Object.Destroy((Object)(object)((Component)corpse).gameObject); } } owner = null; corpse = null; } Ensure(player).SetPending(value: false); } internal static void Revive(Player player) { Restore(player); Ensure(player).PublishReturn(); } internal static bool IsReturning(Player player) { FylgjaPresentation component = ((Component)player).GetComponent<FylgjaPresentation>(); if (Object.op_Implicit((Object)(object)component)) { return component.Returning; } return false; } internal static FylgjaPresentation Ensure(Player player) { FylgjaPresentation component = ((Component)player).GetComponent<FylgjaPresentation>(); if (!Object.op_Implicit((Object)(object)component)) { return ((Component)player).gameObject.AddComponent<FylgjaPresentation>(); } return component; } } internal static class DeathScreen { [CompilerGenerated] private static class <>O { public static UnityAction <0>__TryRevive; public static UnityAction <1>__NormalDeath; } private static GameObject root; private static Button revive; private static Button normal; private static TMP_Text reviveLabel; private static TMP_Text normalLabel; private static TMP_Text status; private static TMP_Text title; private static TMP_Text description; private static RectTransform progress; private static bool blocked; private static readonly Vector2 Center = new Vector2(0.5f, 0.5f); private static readonly Color Gold = new Color(1f, 0.72f, 0.28f); internal static bool Ready { get { if (!GUIManager.IsHeadless() && Object.op_Implicit((Object)(object)GUIManager.CustomGUIFront)) { return Object.op_Implicit((Object)(object)Hud.instance); } return false; } } internal static void Tick() { //IL_00cd: 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_01f6: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if (!Settings.Enabled.Value || !Ready || !Object.op_Implicit((Object)(object)localPlayer) || !((Character)localPlayer).IsDead() || !DeathController.Owned(localPlayer) || !DeathController.ShouldShowPanel(localPlayer) || (DeathController.HasChoice && !DeathController.ChoiceVisible) || !Object.op_Implicit((Object)(object)Game.instance) || Game.instance.WaitingForRespawn() || Game.instance.IsShuttingDown()) { Close(); return; } bool hasChoice = DeathController.HasChoice; if (hasChoice && Stone.Find(localPlayer) == null) { Close(); return; } if (!Object.op_Implicit((Object)(object)root)) { Build(); } long num = DeathController.Remaining(localPlayer); ((Selectable)revive).interactable = hasChoice && num == 0; ((Graphic)reviveLabel).color = (((Selectable)revive).interactable ? Gold : Color.grey); reviveLabel.text = ((num > 0) ? (Texts.Get("cooldown") + (Settings.ShowTimer.Value ? (" · " + CooldownClock.Display(num)) : "")) : (hasChoice ? Texts.Get("return") : Texts.Get("unavailable"))); ((Component)normal).gameObject.SetActive(hasChoice); normalLabel.text = Texts.Get("normal"); title.text = Texts.Get("title"); description.text = Texts.Get(hasChoice ? "offer" : "resting"); status.text = (hasChoice ? string.Format(Texts.Get("choice"), DeathController.DecisionRemaining) : ""); ((Component)((Transform)progress).parent).gameObject.SetActive(hasChoice); progress.anchorMax = new Vector2(hasChoice ? Mathf.Clamp01((float)DeathController.DecisionRemaining / (float)Settings.ChoiceSeconds.Value) : 0f, 1f); } private static void Build() { //IL_0020: 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_002c: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Expected O, but got Unknown //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Expected O, but got Unknown //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_038a: 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_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Expected O, but got Unknown GUIManager instance = GUIManager.Instance; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0.5f, 0f); root = instance.CreateWoodpanel(GUIManager.CustomGUIFront.transform, val, val, new Vector2(0f, 22f), 510f, 252f, false); ((Object)root).name = "Fylgja_DeathChoice"; RectTransform component = root.GetComponent<RectTransform>(); component.pivot = val; component.anchoredPosition = new Vector2(0f, 22f); GameObject val2 = new GameObject("FylgjaStoneIcon", new Type[2] { typeof(RectTransform), typeof(Image) }); val2.transform.SetParent(root.transform, false); RectTransform component2 = val2.GetComponent<RectTransform>(); Vector2 anchorMin = (component2.anchorMax = Center); component2.anchorMin = anchorMin; component2.sizeDelta = new Vector2(76f, 76f); component2.anchoredPosition = new Vector2(-188f, 70f); val2.GetComponent<Image>().sprite = Stone.Icon; val2.GetComponent<Image>().preserveAspect = true; ((Graphic)val2.GetComponent<Image>()).raycastTarget = false; title = Label(new Vector2(40f, 85f), 364, 38, 28, Gold); description = Label(new Vector2(40f, 35f), 364, 56, 17, new Color(0.8f, 0.94f, 1f)); revive = ButtonAt(new Vector2(0f, -18f), 452, 45, out reviveLabel); ButtonClickedEvent onClick = revive.onClick; object obj = <>O.<0>__TryRevive; if (obj == null) { UnityAction val3 = DeathController.TryRevive; <>O.<0>__TryRevive = val3; obj = (object)val3; } ((UnityEvent)onClick).AddListener((UnityAction)obj); normal = ButtonAt(new Vector2(0f, -66f), 260, 37, out normalLabel); ButtonClickedEvent onClick2 = normal.onClick; object obj2 = <>O.<1>__NormalDeath; if (obj2 == null) { UnityAction val4 = DeathController.NormalDeath; <>O.<1>__NormalDeath = val4; obj2 = (object)val4; } ((UnityEvent)onClick2).AddListener((UnityAction)obj2); status = Label(new Vector2(0f, -100f), 460, 22, 15, new Color(0.85f, 0.84f, 0.8f)); GameObject val5 = new GameObject("ChoiceTime", new Type[2] { typeof(RectTransform), typeof(Image) }); val5.transform.SetParent(root.transform, false); RectTransform component3 = val5.GetComponent<RectTransform>(); anchorMin = (component3.anchorMax = Center); component3.anchorMin = anchorMin; component3.anchoredPosition = new Vector2(0f, -116f); component3.sizeDelta = new Vector2(450f, 3f); ((Graphic)val5.GetComponent<Image>()).color = new Color(0f, 0f, 0f, 0.35f); ((Graphic)val5.GetComponent<Image>()).raycastTarget = false; GameObject val6 = new GameObject("SpiritTime", new Type[2] { typeof(RectTransform), typeof(Image) }); val6.transform.SetParent(val5.transform, false); progress = val6.GetComponent<RectTransform>(); progress.anchorMin = Vector2.zero; progress.anchorMax = Vector2.one; RectTransform obj3 = progress; anchorMin = (progress.offsetMax = Vector2.zero); obj3.offsetMin = anchorMin; ((Graphic)val6.GetComponent<Image>()).color = new Color(0.15f, 0.68f, 0.95f, 0.85f); ((Graphic)val6.GetComponent<Image>()).raycastTarget = false; GUIManager.BlockInput(true); blocked = true; if (DeathController.HasChoice) { ((Selectable)revive).Select(); } } private static Button ButtonAt(Vector2 position, int width, int height, out TMP_Text label) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) Button component = GUIManager.Instance.CreateButton("", root.transform, Center, Center, position, (float)width, (float)height).GetComponent<Button>(); Text componentInChildren = ((Component)component).GetComponentInChildren<Text>(); if (Object.op_Implicit((Object)(object)componentInChildren)) { ((Component)componentInChildren).gameObject.SetActive(false); Object.Destroy((Object)(object)((Component)componentInChildren).gameObject); } label = CreateText(((Component)component).transform, Vector2.zero, width - 24, height - 4, 20, Gold); return component; } private static TMP_Text Label(Vector2 position, int width, int height, int size, Color color) { //IL_000a: 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) return CreateText(root.transform, position, width, height, size, color); } private static TMP_Text CreateText(Transform parent, Vector2 position, int width, int height, int size, Color color) { //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_0037: 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_0044: 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_004b: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("FylgjaText", new Type[2] { typeof(RectTransform), typeof(TextMeshProUGUI) }); val.transform.SetParent(parent, false); RectTransform component = val.GetComponent<RectTransform>(); Vector2 anchorMin = (component.anchorMax = Center); component.anchorMin = anchorMin; component.sizeDelta = new Vector2((float)width, (float)height); component.anchoredPosition = position; TextMeshProUGUI component2 = val.GetComponent<TextMeshProUGUI>(); TMP_Text pieceDescription = Hud.instance.m_pieceDescription; ((TMP_Text)component2).font = ((Object.op_Implicit((Object)(object)pieceDescription) && Object.op_Implicit((Object)(object)pieceDescription.font)) ? pieceDescription.font : TMP_Settings.defaultFontAsset); if (Object.op_Implicit((Object)(object)pieceDescription) && Object.op_Implicit((Object)(object)pieceDescription.font)) { ((TMP_Text)component2).fontSharedMaterial = pieceDescription.fontSharedMaterial; } ((TMP_Text)component2).fontSize = size; ((TMP_Text)component2).enableAutoSizing = true; ((TMP_Text)component2).fontSizeMin = ((size >= 28) ? 20 : 13); ((TMP_Text)component2).fontSizeMax = size; ((TMP_Text)component2).alignment = (TextAlignmentOptions)514; ((TMP_Text)component2).textWrappingMode = (TextWrappingModes)1; ((TMP_Text)component2).overflowMode = (TextOverflowModes)3; ((Graphic)component2).color = color; ((Graphic)component2).raycastTarget = false; ((TMP_Text)component2).richText = false; ((TMP_Text)component2).text = ""; return (TMP_Text)(object)component2; } internal static void Close() { if (Object.op_Implicit((Object)(object)root)) { root.SetActive(false); Object.Destroy((Object)(object)root); } root = null; if (blocked) { GUIManager.BlockInput(false); blocked = false; } } } internal sealed class FylgjaPresentation : MonoBehaviour { private const string PendingKey = "com.enoq.fylgja.pending"; private const string SequenceKey = "com.enoq.fylgja.return.sequence"; private const string TimeKey = "com.enoq.fylgja.return.time"; private Player player; private ZNetView view; private GameObject visual; private bool hiddenByUs; private int seenSequence; private float returnUntil; private bool powerSoundPlayed; internal bool Returning => Time.unscaledTime < returnUntil; private void Awake() { player = ((Component)this).GetComponent<Player>(); view = ((Component)this).GetComponent<ZNetView>(); Transform val = ((Component)this).transform.Find("Visual"); if (Object.op_Implicit((Object)(object)val)) { visual = ((Component)val).gameObject; } } internal void SetPending(bool value) { if (Object.op_Implicit((Object)(object)view) && view.IsValid() && view.IsOwner()) { view.GetZDO().Set("com.enoq.fylgja.pending", value); UpdateVisual(value); } } internal void PublishReturn() { if (Object.op_Implicit((Object)(object)view) && view.IsValid() && view.IsOwner()) { ZDO zDO = view.GetZDO(); seenSequence = zDO.GetInt("com.enoq.fylgja.return.sequence", 0) + 1; zDO.Set("com.enoq.fylgja.return.sequence", seenSequence); zDO.Set("com.enoq.fylgja.return.time", (long)(ZNet.instance.GetTimeSeconds() * 1000.0)); ZSyncAnimation component = ((Component)this).GetComponent<ZSyncAnimation>(); if (component != null) { component.SetBool("dead", false); } PlayReturn(); } } private void Update() { if (!Object.op_Implicit((Object)(object)player) || !Object.op_Implicit((Object)(object)view) || !view.IsValid()) { return; } ZDO zDO = view.GetZDO(); bool flag = zDO.GetBool("com.enoq.fylgja.pending", false); if (flag && view.IsOwner() && (Object)(object)player == (Object)(object)Player.m_localPlayer && !DeathController.IsWaiting((Character)(object)player)) { zDO.Set("com.enoq.fylgja.pending", false); flag = false; } UpdateVisual(flag); int num = zDO.GetInt("com.enoq.fylgja.return.sequence", 0); if (num == seenSequence) { return; } double num2 = ZNet.instance.GetTimeSeconds() - (double)zDO.GetLong("com.enoq.fylgja.return.time", 0L) / 1000.0; if (!(num2 < -0.5) && (!(num2 < 3.5) || !((Character)player).IsDead())) { seenSequence = num; if (num != 0 && num2 < 3.5) { PlayReturn(); } } } private void UpdateVisual(bool waiting) { if (Object.op_Implicit((Object)(object)visual)) { if (waiting) { visual.SetActive(false); hiddenByUs = true; } else if (hiddenByUs && !((Character)player).IsDead()) { visual.SetActive(true); hiddenByUs = false; } } } private void PlayReturn() { returnUntil = Time.unscaledTime + 4f; powerSoundPlayed = false; if (Object.op_Implicit((Object)(object)visual)) { visual.SetActive(true); } hiddenByUs = false; Animator componentInChildren = ((Component)this).GetComponentInChildren<Animator>(true); if (Object.op_Implicit((Object)(object)componentInChildren)) { componentInChildren.SetBool("dead", false); componentInChildren.SetTrigger("gpower"); } try { SpiritEffects.Revival(((Component)this).transform); } catch (Exception ex) { Plugin.Warn("Spiritual aura could not be displayed: " + ex.Message); } } internal void PlayPowerSound() { if (!Returning || powerSoundPlayed) { return; } powerSoundPlayed = true; try { SpiritEffects.PowerSound(((Component)this).transform); } catch (Exception ex) { Plugin.Warn("Guardian-power sound failed: " + ex.Message); } } } internal static class GameAccess { internal static readonly MethodInfo UpdateFood = RequireMethod(typeof(Player), "UpdateFood", typeof(float), typeof(bool)); private static readonly FieldInfo Eitr = RequireField(typeof(Player), "m_eitr", typeof(float)); private static readonly FieldInfo IsDead = RequireField(typeof(Character), "m_isDead", typeof(bool)); private static readonly FieldInfo MaxAir = RequireField(typeof(Character), "m_maxAirAltitude", typeof(float)); private static readonly FieldInfo Push = RequireField(typeof(Character), "m_pushForce", typeof(Vector3)); internal static readonly MethodInfo CreateDeathEffects = RequireMethod(typeof(Player), "CreateDeathEffects"); internal static readonly FieldInfo RagdollField = RequireField(typeof(Player), "m_ragdoll", typeof(Ragdoll)); private static readonly MethodInfo SetupVisual = RequireMethod(typeof(Humanoid), "SetupVisEquipment", typeof(VisEquipment), typeof(bool)); private static readonly MethodInfo RagdollCreated = RequireMethod(typeof(Humanoid), "OnRagdollCreated", typeof(Ragdoll)); internal static void Verify() { _ = UpdateFood; _ = Eitr; _ = IsDead; _ = MaxAir; _ = Push; _ = CreateDeathEffects; _ = RagdollField; _ = SetupVisual; _ = RagdollCreated; } internal static bool InternalDead(Player player) { return (bool)IsDead.GetValue(player); } internal static Ragdoll CreateVisualCorpse(Player player) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_00ab: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) GameObject[] array = ((Character)player).m_deathEffects.Create(((Component)player).transform.position, ((Component)player).transform.rotation, ((Component)player).transform, 1f, -1, default(ZDOID)); Ragdoll result = null; GameObject[] array2 = array; for (int i = 0; i < array2.Length; i++) { Ragdoll component = array2[i].GetComponent<Ragdoll>(); if (Object.op_Implicit((Object)(object)component)) { result = component; RagdollField.SetValue(player, component); Vector3 val = ((Component)player).GetComponent<Rigidbody>().linearVelocity; Vector3 val2 = (Vector3)Push.GetValue(player); if (((Vector3)(ref val2)).magnitude * 0.5f > ((Vector3)(ref val)).magnitude) { val = val2 * 0.5f; } component.Setup(val, 0f, 0f, 0f, (CharacterDrop)null, 1, false); VisEquipment component2 = ((Component)component).GetComponent<VisEquipment>(); if (Object.op_Implicit((Object)(object)component2)) { SetupVisual.Invoke(player, new object[2] { component2, true }); } } } return result; } internal static void NotifyNormalCorpse(Player player, Ragdoll corpse) { RagdollCreated.Invoke(player, new object[1] { corpse }); } private static FieldInfo RequireField(Type owner, string name, Type type) { FieldInfo fieldInfo = AccessTools.Field(owner, name); if (fieldInfo == null || fieldInfo.FieldType != type) { throw new MissingFieldException(owner.FullName, name); } return fieldInfo; } private static MethodInfo RequireMethod(Type owner, string name, params Type[] args) { return AccessTools.Method(owner, name, args, (Type[])null) ?? throw new MissingMethodException(owner.FullName, name); } internal static void RestoreBaseStats(Player player) { player.ClearFood(); UpdateFood.Invoke(player, new object[2] { 0f, true }); Eitr.SetValue(player, 0f); ((Character)player).SetHealth(((Character)player).GetMaxHealth()); ((Character)player).AddStamina(((Character)player).GetMaxStamina()); } internal static void ResetMotion(Player player, Vector3 position) { //IL_0017: 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) IsDead.SetValue(player, false); MaxAir.SetValue(player, position.y); Push.SetValue(player, Vector3.zero); } } internal sealed class ModelData { internal sealed class Group { internal string Name; internal float[] Material; internal float[] Vertices; } internal sealed class Geometry { internal float[] Vertices; internal float[] UV; internal int[] Triangles; } internal readonly List<Group> Groups = new List<Group>(); internal Geometry Combine() { int num = 0; foreach (Group group in Groups) { num += group.Vertices.Length / 8; } Geometry geometry = new Geometry { Vertices = new float[num * 6], UV = new float[num * 2], Triangles = new int[num] }; int num2 = 0; for (int i = 0; i < Groups.Count; i++) { Group obj = Groups[i]; int num3 = 0; while (num3 < obj.Vertices.Length / 8) { Array.Copy(obj.Vertices, num3 * 8, geometry.Vertices, num2 * 6, 6); geometry.UV[num2 * 2] = obj.Vertices[num3 * 8 + 6]; geometry.UV[num2 * 2 + 1] = obj.Vertices[num3 * 8 + 7]; geometry.Triangles[num2] = num2; num3++; num2++; } } return geometry; } internal static ModelData Read(Stream stream) { using BinaryReader binaryReader = new BinaryReader(stream); if (new string(binaryReader.ReadChars(4)) != "FYL3") { throw new InvalidDataException("Invalid Fylgja model header"); } int num = binaryReader.ReadInt32(); if (num < 1 || num > 64) { throw new InvalidDataException("Invalid material count"); } ModelData modelData = new ModelData(); for (int i = 0; i < num; i++) { Group obj = new Group { Name = binaryReader.ReadString(), Material = new float[7] }; for (int j = 0; j < 7; j++) { obj.Material[j] = Finite(binaryReader.ReadSingle()); } int num2 = binaryReader.ReadInt32(); if (num2 < 3 || num2 > 60000 || num2 % 3 != 0) { throw new InvalidDataException("Invalid triangle count"); } obj.Vertices = new float[num2 * 8]; for (int k = 0; k < obj.Vertices.Length; k++) { obj.Vertices[k] = Finite(binaryReader.ReadSingle()); } for (int l = 0; l < num2; l++) { if (obj.Vertices[l * 8 + 6] < 0f || obj.Vertices[l * 8 + 6] > 1f || obj.Vertices[l * 8 + 7] < 0f || obj.Vertices[l * 8 + 7] > 1f) { throw new InvalidDataException("Atlas coordinate out of range"); } } modelData.Groups.Add(obj); } if (stream.Position != stream.Length) { throw new InvalidDataException("Unexpected trailing model data"); } return modelData; } private static float Finite(float value) { if (float.IsNaN(value) || float.IsInfinity(value)) { throw new InvalidDataException("Non-finite model coordinate"); } return value; } } [HarmonyPatch(typeof(Player), "Awake")] internal static class PlayerPresentationPatch { private static void Postfix(Player __instance) { DeathPresentation.Ensure(__instance); } } [HarmonyPatch(typeof(Player), "CreateDeathEffects")] internal static class DeathEffectsPatch { private static bool Prefix(Player __instance) { return DeathPresentation.CreateNativeEffects(__instance); } } [HarmonyPatch(typeof(Player), "ActivateGuardianPower")] internal static class SpiritualGesturePatch { private static bool Prefix(Player __instance, ref bool __result) { if (!DeathPresentation.IsReturning(__instance)) { return true; } ((Component)__instance).GetComponent<FylgjaPresentation>()?.PlayPowerSound(); __result = false; return false; } } [HarmonyPatch(typeof(Hud), "UpdateBlackScreen")] internal static class PendingDeathFadePatch { private static void Postfix(Hud __instance) { if (DeathController.HasChoice && Object.op_Implicit((Object)(object)__instance.m_loadingScreen)) { __instance.m_loadingScreen.alpha = Mathf.Min(__instance.m_loadingScreen.alpha, 0.5f); } } } [HarmonyPatch(typeof(Player), "OnDeath")] internal static class PlayerDeathPatch { [HarmonyPriority(800)] private static bool Prefix(Player __instance) { return DeathController.BeforeDeath(__instance); } } [HarmonyPatch(typeof(Character), "CustomFixedUpdate")] internal static class PendingSimulationPatch { private static bool Prefix(Character __instance) { return !DeathController.IsWaiting(__instance); } } [HarmonyPatch(typeof(Character), "RPC_Damage")] internal static class ProtectionRpcPatch { private static bool Prefix(Character __instance) { return !DeathController.IsProtected(__instance); } } [HarmonyPatch(typeof(Character), "ApplyDamage")] internal static class ProtectionDamagePatch { private static bool Prefix(Character __instance) { return !DeathController.IsProtected(__instance); } } [HarmonyPatch(typeof(Player), "Save")] internal static class PendingSavePatch { private static void Prefix(Player __instance) { if (DeathController.IsWaiting((Character)(object)__instance)) { DeathController.NormalDeath(); } } } [HarmonyPatch(typeof(Game), "_RequestRespawn")] internal static class ExternalRespawnPatch { private static void Prefix(Game __instance) { if (DeathController.HasChoice) { DeathController.NormalDeath(); ((MonoBehaviour)__instance).CancelInvoke("_RequestRespawn"); } } } [HarmonyPatch(typeof(Game), "ContinueLogout")] internal static class LogoutPatch { private static void Prefix() { DeathController.NormalDeath(); } } [BepInPlugin("com.enoq.fylgja", "Fylgja: The Second Flame - Individual Resurrection", "0.5.1")] [BepInDependency("com.jotunn.jotunn", "2.30.2")] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { public const string Guid = "com.enoq.fylgja"; public const string ModName = "Fylgja: The Second Flame - Individual Resurrection"; public const string ModAuthor = "Enoq"; public const string ModVersion = "0.5.1"; private Harmony harmony; private bool updateFailureReported; internal static Plugin Instance; internal static void Info(string text) { Plugin instance = Instance; if (instance != null) { ((BaseUnityPlugin)instance).Logger.LogInfo((object)text); } } internal static void Warn(string text) { Plugin instance = Instance; if (instance != null) { ((BaseUnityPlugin)instance).Logger.LogWarning((object)text); } } private void Awake() { //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Expected O, but got Unknown Instance = this; Settings.Bind(((BaseUnityPlugin)this).Config); Texts.Register(); RevivalAudit.RegisterCommand(); StoneVisualLod.RegisterCommand(); PrefabManager.OnVanillaPrefabsAvailable += Stone.Register; ItemManager.OnItemsRegistered += Stone.RefreshRecipe; SynchronizationManager.OnConfigurationSynchronized += ConfigSynchronized; ((BaseUnityPlugin)this).Config.SettingChanged += SettingChanged; GameAccess.Verify(); harmony = new Harmony("com.enoq.fylgja"); harmony.PatchAll(typeof(Plugin).Assembly); Info("Fylgja: The Second Flame - Individual Resurrection 0.5.1 | Enoq | Valheim " + Version.GetVersionString(false)); } private void ConfigSynchronized(object sender, ConfigurationSynchronizationEventArgs args) { Stone.RefreshRecipe(); } private void SettingChanged(object sender, SettingChangedEventArgs args) { Stone.RefreshRecipe(); } private void Update() { try { Stone.Tick(); StoneVisualLod.Tick(); DeathController.Tick(); DeathScreen.Tick(); updateFailureReported = false; } catch (Exception ex) { if (!updateFailureReported) { Warn("Fylgja update failed; continuing normal death: " + ex); } updateFailureReported = true; DeathScreen.Close(); DeathController.NormalDeath(); } } private void OnDestroy() { DeathController.NormalDeath(); DeathScreen.Close(); StoneVisualLod.Shutdown(); PrefabManager.OnVanillaPrefabsAvailable -= Stone.Register; ItemManager.OnItemsRegistered -= Stone.RefreshRecipe; SynchronizationManager.OnConfigurationSynchronized -= ConfigSynchronized; ((BaseUnityPlugin)this).Config.SettingChanged -= SettingChanged; Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } Instance = null; } } internal static class RevivalAudit { internal sealed class Snapshot { internal string Skills; internal int Items; internal bool Available; } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Func<Skill, int> <>9__3_0; public static Func<Skill, string> <>9__3_1; public static Func<ItemData, int> <>9__4_0; public static ConsoleEvent <>9__6_0; internal int <SkillState>b__3_0(Skill s) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected I4, but got Unknown return (int)s.m_info.m_skill; } internal string <SkillState>b__3_1(Skill s) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected I4, but got Unknown return (int)s.m_info.m_skill + ":" + s.m_level.ToString("R", CultureInfo.InvariantCulture) + ":" + s.m_accumulator.ToString("R", CultureInfo.InvariantCulture); } internal int <Capture>b__4_0(ItemData i) { return i.m_stack; } internal void <RegisterCommand>b__6_0(ConsoleEventArgs args) { Player localPlayer = Player.m_localPlayer; string text = (Object.op_Implicit((Object)(object)localPlayer) ? Describe(localPlayer) : "Fylgja: no local player."); if (Object.op_Implicit((Object)(object)localPlayer) && (Object)(object)lastPlayer == (Object)(object)localPlayer) { text = text + "; lastRevival: " + lastResult; } args.Context.AddString(text); Plugin.Info(text); } } private static Player lastPlayer; private static string lastResult; private static string SkillState(Player player) { return string.Join(";", from s in ((Character)player).GetSkills().GetSkillList() orderby (int)s.m_info.m_skill select (int)s.m_info.m_skill + ":" + s.m_level.ToString("R", CultureInfo.InvariantCulture) + ":" + s.m_accumulator.ToString("R", CultureInfo.InvariantCulture)); } internal static Snapshot Capture(Player player) { try { return new Snapshot { Skills = SkillState(player), Items = ((Humanoid)player).GetInventory().GetAllItems().Sum((ItemData i) => i.m_stack), Available = true }; } catch (Exception ex) { Plugin.Warn("State audit unavailable: " + ex.Message); return new Snapshot(); } } internal static void Finish(Player player, Snapshot before) { try { Snapshot snapshot = Capture(player); if (!before.Available || !snapshot.Available) { Plugin.Warn("Revival audit incomplete; no skill-retention claim can be made."); return; } bool flag = before.Skills == snapshot.Skills; lastPlayer = player; lastResult = "skillsUnchanged=" + flag + ", itemUnits=" + before.Items + "->" + snapshot.Items; string text = "Revival audit: " + Describe(player) + "; " + lastResult; if (!((Character)player).IsDead() && !GameAccess.InternalDead(player) && flag && snapshot.Items == before.Items - 1) { Plugin.Info(text); } else { Plugin.Warn(text); } } catch (Exception ex) { Plugin.Warn("Could not audit completed revival: " + ex.Message); } } internal static void RegisterCommand() { //IL_0033: 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_0029: Expected O, but got Unknown object obj = <>c.<>9__6_0; if (obj == null) { ConsoleEvent val = delegate(ConsoleEventArgs args) { Player localPlayer = Player.m_localPlayer; string text = (Object.op_Implicit((Object)(object)localPlayer) ? Describe(localPlayer) : "Fylgja: no local player."); if (Object.op_Implicit((Object)(object)localPlayer) && (Object)(object)lastPlayer == (Object)(object)localPlayer) { text = text + "; lastRevival: " + lastResult; } args.Context.AddString(text); Plugin.Info(text); }; <>c.<>9__6_0 = val; obj = (object)val; } new ConsoleCommand("fylgja_status", "Show live Fylgja state and the last revival audit (read-only).", (ConsoleEvent)obj, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); } private static string Describe(Player player) { //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) Rigidbody component = ((Component)player).GetComponent<Rigidbody>(); return "Fylgja: IsDead=" + ((Character)player).IsDead() + ", internalDead=" + GameAccess.InternalDead(player) + ", waiting=" + DeathController.IsWaiting((Character)(object)player) + ", HP=" + ((Character)player).GetHealth().ToString("0.##", CultureInfo.InvariantCulture) + "/" + ((Character)player).GetMaxHealth().ToString("0.##", CultureInfo.InvariantCulture) + ", stamina=" + player.GetStamina().ToString("0.##", CultureInfo.InvariantCulture) + ", food=" + player.GetFoods().Count + ", cooldown=" + DeathController.Remaining(player) + "s, kinematic=" + component.isKinematic + ", collisions=" + component.detectCollisions + ", constraints=" + ((object)component.constraints/*cast due to .constrained prefix*/).ToString(); } } internal enum DeathPhase { Pending, Committing, Revived, Normal } internal sealed class DeathDecision { internal DeathPhase Phase { get; private set; } internal bool TryBegin(bool owner, bool dead, bool hasStone, long remaining) { if (Phase != DeathPhase.Pending || !owner || !dead || !hasStone || remaining != 0L) { return false; } Phase = DeathPhase.Committing; return true; } internal bool ChooseNormal() { if (Phase != DeathPhase.Pending) { return false; } Phase = DeathPhase.Normal; return true; } internal void Abort() { if (Phase != DeathPhase.Committing) { throw new InvalidOperationException("No revive in progress"); } Phase = DeathPhase.Pending; } internal void Complete() { if (Phase != DeathPhase.Committing) { throw new InvalidOperationException("No revive in progress"); } Phase = DeathPhase.Revived; } } internal static class CooldownClock { internal const string Key = "com.enoq.fylgja.cooldown.utc.v1"; internal const long MaximumTimestamp = 253402300799L; internal static long Remaining(string stored, long now) { if (stored == null) { return 0L; } if (!long.TryParse(stored, NumberStyles.None, CultureInfo.InvariantCulture, out var result) || result < 0 || result > 253402300799L) { return long.MaxValue; } if (result > now) { return result - Math.Max(0L, now); } return 0L; } internal static string Start(long now, int seconds) { return checked(now + Math.Max(0, seconds)).ToString(CultureInfo.InvariantCulture); } internal static string Display(long remaining) { if (remaining != long.MaxValue) { return (remaining / 60).ToString("00", CultureInfo.InvariantCulture) + ":" + (remaining % 60).ToString("00", CultureInfo.InvariantCulture); } return "?"; } } internal static class SafePosition { internal static bool TryFind(Player player, Vector3 death, out Vector3 result) { //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_0014: 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_0091: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: 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_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: 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_0202: 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_0216: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_023c: 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_0246: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_0250: 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_026b: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) result = death; if (!Finite(death.x) || !Finite(death.y) || !Finite(death.z)) { return false; } int mask = LayerMask.GetMask(new string[7] { "Default", "static_solid", "Default_small", "piece", "terrain", "blocker", "vehicle" }); if (mask == 0) { return false; } CapsuleCollider collider = ((Character)player).GetCollider(); float num = Mathf.Max(0.2f, collider.radius * Mathf.Max(((Component)player).transform.lossyScale.x, ((Component)player).transform.lossyScale.z)); float num2 = Mathf.Max(num * 2f, collider.height * ((Component)player).transform.lossyScale.y); float[] array = new float[5] { 0f, 1.5f, 3f, 5f, 8f }; RaycastHit val2 = default(RaycastHit); foreach (float num3 in array) { int num4 = ((num3 == 0f) ? 1 : 12); for (int j = 0; j < num4; j++) { float num5 = (float)j * (float)Math.PI * 2f / (float)num4; Vector3 val = death + new Vector3(Mathf.Cos(num5) * num3, 0f, Mathf.Sin(num5) * num3); float[] array2 = new float[3] { 0.5f, 3f, 8f }; foreach (float num6 in array2) { if (!Physics.Raycast(val + Vector3.up * num6, Vector3.down, ref val2, num6 + 8f, mask, (QueryTriggerInteraction)1) || ((RaycastHit)(ref val2)).normal.y < 0.6f) { continue; } Vector3 val3 = ((RaycastHit)(ref val2)).point + Vector3.up * 0.08f; if (!(Vector3.Distance(val3, death) > 11.4f) && !(Floating.GetLiquidLevel(val3, 1f, (LiquidType)10) > val3.y + 0.15f)) { Heightmap val4 = Heightmap.FindHeightmap(val3); if ((!Object.op_Implicit((Object)(object)val4) || !val4.IsLava(val3, 0.05f)) && !Object.op_Implicit((Object)(object)EffectArea.IsPointInsideArea(val3, (Type)8, num)) && !Physics.CheckCapsule(val3 + Vector3.up * num, val3 + Vector3.up * (num2 - num), num * 0.95f, mask, (QueryTriggerInteraction)1)) { result = val3; return true; } } } } } return false; } private static bool Finite(float number) { if (!float.IsNaN(number)) { return !float.IsInfinity(number); } return false; } } internal static class Settings { internal static ConfigEntry<bool> Enabled; internal static ConfigEntry<bool> ShowTimer; internal static ConfigEntry<int> CoreAmount; internal static ConfigEntry<int> EyeAmount; internal static ConfigEntry<int> IronAmount; internal static ConfigEntry<int> StationLevel; internal static ConfigEntry<int> Cooldown; internal static ConfigEntry<int> ChoiceSeconds; internal static ConfigEntry<float> Protection; internal static ConfigEntry<string> Station; internal static void Bind(ConfigFile config) { Enabled = Sync(config, "General", "Enabled", value: true, "Enable crafting and revival / Activar fabricación y resurrección."); CoreAmount = Sync(config, "Recipe", "SurtlingCoreAmount", 10, "Surtling cores / Núcleos de surtling.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 999)); EyeAmount = Sync(config, "Recipe", "GreydwarfEyeAmount", 10, "Greydwarf eyes / Ojos de enano gris.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 999)); IronAmount = Sync(config, "Recipe", "IronAmount", 10, "Iron / Hierro.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 999)); Station = Sync(config, "Recipe", "CraftingStation", "Forge", "Crafting station / Estación de fabricación.", (AcceptableValueBase)(object)CraftingStations.GetAcceptableValueList()); StationLevel = Sync(config, "Recipe", "CraftingStationLevel", 1, "Required station level / Nivel necesario.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 10)); Cooldown = Sync(config, "Revive", "CooldownSeconds", 900, "Real time, per character / Tiempo real por personaje.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 604800)); Protection = Sync(config, "Revive", "ReviveProtectionSeconds", 2.5f, "Damage immunity; 0 disables / Inmunidad; 0 la desactiva.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 30f)); ChoiceSeconds = Sync(config, "Revive", "DecisionSeconds", 30, "Time to choose before normal death / Tiempo para elegir antes de la muerte normal.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 120)); ShowTimer = config.Bind<bool>("UI", "ShowCooldownTimer", true, "Show remaining cooldown / Mostrar tiempo restante."); } private static ConfigEntry<T> Sync<T>(ConfigFile file, string section, string key, T value, string help, AcceptableValueBase range = null) { //IL_0010: 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_001d: Expected O, but got Unknown //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown return file.Bind<T>(section, key, value, new ConfigDescription(help, range, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); } } internal static class SpiritEffects { internal static readonly Color Cyan = new Color(0.06f, 0.68f, 1f); internal static readonly Color Red = new Color(1f, 0.045f, 0.015f); private static readonly Color StoneBlue = new Color(0.015f, 0.2f, 1f); private static readonly Color StoneRed = new Color(1f, 0.012f, 0.006f); private static readonly Vector3 RedFocus = new Vector3(0.105f, 0.17f, 0.12f); private static readonly Vector3 BlueFocus = new Vector3(-0.105f, -0.14f, 0.12f); private static Material glintMaterial; private static ParticleSystem cryptKeyGlow; private static ParticleSystem nativeCinders; private static ParticleSystem nativeWisps; private static GameObject powerActivation; internal static void Prepare(GameObject fallback) { //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Expected O, but got Unknown //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Expected O, but got Unknown //IL_022d: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)glintMaterial)) { return; } GameObject prefab = PrefabManager.Instance.GetPrefab("CryptKey"); Transform val = (Object.op_Implicit((Object)(object)prefab) ? prefab.transform.Find("attach/Particle System") : null); if (Object.op_Implicit((Object)(object)val)) { cryptKeyGlow = ((Component)val).GetComponent<ParticleSystem>(); } powerActivation = PrefabManager.Instance.GetPrefab("fx_GP_Activation"); object obj; if (!Object.op_Implicit((Object)(object)powerActivation)) { obj = null; } else { Transform obj2 = powerActivation.transform.Find("Particle System _expl"); obj = ((obj2 != null) ? ((Component)obj2).GetComponent<ParticleSystem>() : null); } nativeCinders = (ParticleSystem)obj; GameObject prefab2 = PrefabManager.Instance.GetPrefab("Wisp"); object obj3; if (!Object.op_Implicit((Object)(object)prefab2)) { obj3 = null; } else { Transform obj4 = prefab2.transform.Find("sparcs_front"); obj3 = ((obj4 != null) ? ((Component)obj4).GetComponent<ParticleSystem>() : null); } nativeWisps = (ParticleSystem)obj3; string[] array = new string[3] { "Thistle", "GoblinTotem", "SurtlingCore" }; foreach (string text in array) { GameObject prefab3 = PrefabManager.Instance.GetPrefab(text); if (Object.op_Implicit((Object)(object)prefab3)) { ParticleSystemRenderer val2 = (from r in prefab3.GetComponentsInChildren<ParticleSystemRenderer>(true) where Object.op_Implicit((Object)(object)((Renderer)r).sharedMaterial) orderby Score(((Object)r).name + " " + ((Object)((Renderer)r).sharedMaterial).name) descending select r).FirstOrDefault(); if (Object.op_Implicit((Object)(object)val2)) { glintMaterial = new Material(((Renderer)val2).sharedMaterial) { name = "Fylgja_PickupGlint" }; break; } } } if (!Object.op_Implicit((Object)(object)glintMaterial)) { ParticleSystemRenderer componentInChildren = fallback.GetComponentInChildren<ParticleSystemRenderer>(true); if (Object.op_Implicit((Object)(object)componentInChildren) && Object.op_Implicit((Object)(object)((Renderer)componentInChildren).sharedMaterial)) { glintMaterial = new Material(((Renderer)componentInChildren).sharedMaterial); } } if (!Object.op_Implicit((Object)(object)glintMaterial)) { throw new InvalidOperationException("Native pickup sparkle material unavailable"); } array = new string[2] { "_Color", "_TintColor" }; foreach (string text2 in array) { if (glintMaterial.HasProperty(text2)) { glintMaterial.SetColor(text2, Color.white); } } } private static int Score(string name) { name = name.ToLowerInvariant(); if (!name.Contains("glow") && !name.Contains("flare") && !name.Contains("glint")) { if (!name.Contains("spark")) { return 0; } return 2; } return 3; } internal static void AddStoneGlow(Transform parent) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_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_0038: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: 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_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_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) if (!GUIManager.IsHeadless()) { Halo(parent, "Fylgja_RedHalo", RedFocus, StoneRed); Halo(parent, "Fylgja_BlueHalo", BlueFocus, StoneBlue); Glint(parent, "Fylgja_RedGlint", RedFocus, WithAlpha(StoneRed, 0.45f), 0.22f); Glint(parent, "Fylgja_BlueGlint", BlueFocus, WithAlpha(StoneBlue, 0.45f), 0.22f); Sparkles(parent, "RedSpiritMotes", WithAlpha(StoneRed, 0.65f), RedFocus); Sparkles(parent, "BlueSpiritMotes", WithAlpha(StoneBlue, 0.65f), BlueFocus); NativeMotes(parent, nativeCinders, "Fylgja_NativeRedCinders", RedFocus, StoneRed); NativeMotes(parent, nativeWisps, "Fylgja_NativeBlueWisps", BlueFocus, StoneBlue); LightAt(parent, "RedLight", RedFocus + Vector3.forward * 0.15f, StoneRed, 1.8f, 3.25f, forcePixel: true); LightAt(parent, "BlueLight", BlueFocus + Vector3.forward * 0.15f, StoneBlue, 1.8f, 3.25f, forcePixel: true); ((Component)parent).gameObject.AddComponent<StoneVisualLod>(); } } private static Color WithAlpha(Color color, float alpha) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) return new Color(color.r, color.g, color.b, alpha); } internal static void ConfigureDroppedPickup(GameObject prefab) { //IL_003a: 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_0047: Expected O, but got Unknown //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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_00e5: 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_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) ParticleSystem component = prefab.GetComponent<ParticleSystem>(); if (!Object.op_Implicit((Object)(object)component)) { Plugin.Warn("Native dropped-item sparkle emitter unavailable."); return; } component.Stop(true, (ParticleSystemStopBehavior)0); if (GUIManager.IsHeadless()) { MainModule main = component.main; ((MainModule)(ref main)).playOnAwake = false; return; } Gradient val = new Gradient { mode = (GradientMode)1 }; val.SetKeys((GradientColorKey[])(object)new GradientColorKey[3] { new GradientColorKey(new Color(0.9f, 0.1f, 0.055f), 0f), new GradientColorKey(new Color(0.08f, 0.4f, 0.95f), 0.5f), new GradientColorKey(new Color(0.08f, 0.4f, 0.95f), 1f) }, (GradientAlphaKey[])(object)new GradientAlphaKey[2] { new GradientAlphaKey(0.65f, 0f), new GradientAlphaKey(0.65f, 1f) }); MainModule main2 = component.main; MinMaxGradient startColor = default(MinMaxGradient); ((MinMaxGradient)(ref startColor))..ctor(val); ((MinMaxGradient)(ref startColor)).mode = (ParticleSystemGradientMode)4; ((MainModule)(ref main2)).startColor = startColor; ((MainModule)(ref main2)).loop = true; ((MainModule)(ref main2)).playOnAwake = true; ((MainModule)(ref main2)).prewarm = true; ((MainModule)(ref main2)).startLifetime = MinMaxCurve.op_Implicit(2f); ((MainModule)(ref main2)).startSpeed = MinMaxCurve.op_Implicit(0f); ((MainModule)(ref main2)).startSize3D = false; ((MainModule)(ref main2)).startSize = new MinMaxCurve(0.2f, 0.32f); ((MainModule)(ref main2)).maxParticles = 4; ((MainModule)(ref main2)).gravityModifier = MinMaxCurve.op_Implicit(0f); ((MainModule)(ref main2)).simulationSpace = (ParticleSystemSimulationSpace)1; ShapeModule shape = component.shape; ((ShapeModule)(ref shape)).enabled = true; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0; ((ShapeModule)(ref shape)).radius = 0.15f; ((ShapeModule)(ref shape)).position = Vector3.zero; EmissionModule emission = component.emission; ((EmissionModule)(ref emission)).enabled = true; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(1.5f); ((EmissionModule)(ref emission)).rateOverDistance = MinMaxCurve.op_Implicit(0f); ((EmissionModule)(ref emission)).SetBursts((Burst[])(object)new Burst[0]); VelocityOverLifetimeModule velocityOverLifetime = component.velocityOverLifetime; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = true; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).space = (ParticleSystemSimulationSpace)1; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).x = new MinMaxCurve(0f, 0f); ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).y = new MinMaxCurve(0.22f, 0.38f); ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).z = new MinMaxCurve(0f, 0f); Fade(component); ParticleSystemRenderer component2 = ((Component)component).GetComponent<ParticleSystemRenderer>(); ((Renderer)component2).sharedMaterial = glintMaterial; ((Renderer)component2).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)component2).receiveShadows = false; component.Play(); } private static void Halo(Transform parent, string name, Vector3 position, Color color) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0110: 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) if (!Object.op_Implicit((Object)(object)cryptKeyGlow)) { Plugin.Warn("CryptKey's native glow was unavailable."); return; } GameObject obj = Object.Instantiate<GameObject>(((Component)cryptKeyGlow).gameObject, parent, false); ((Object)obj).name = name; obj.transform.localPosition = position; obj.transform.localRotation = Quaternion.identity; obj.transform.localScale = Vector3.one; ParticleSystem component = obj.GetComponent<ParticleSystem>(); component.Stop(true, (ParticleSystemStopBehavior)0); MainModule main = component.main; ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(1f, 1f, 1f, 0.1f)); ((MainModule)(ref main)).startSize3D = false; ((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(0.64f); ((MainModule)(ref main)).maxParticles = 2; ((MainModule)(ref main)).loop = true; ((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(2f); ((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(0f); ((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)0; ((MainModule)(ref main)).prewarm = true; ShapeModule shape = component.shape; ((ShapeModule)(ref shape)).radius = 0.008f; EmissionModule emission = component.emission; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(1f); ((EmissionModule)(ref emission)).SetBursts((Burst[])(object)new Burst[0]); ParticleSystemRenderer component2 = ((Component)component).GetComponent<ParticleSystemRenderer>(); ((Renderer)component2).sharedMaterial = TintedMaterial(((Renderer)component2).sharedMaterial, name, color, 0f); component.Play(); } private static void Sparkles(Transform parent, string name, Color color, Vector3 position) { //IL_0002: 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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a5: 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_00b5: 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) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) ParticleSystem obj = Particle(parent, name, color); ((Component)obj).transform.localPosition = position; MainModule main = obj.main; ((MainModule)(ref main)).loop = true; ((MainModule)(ref main)).startLifetime = new MinMaxCurve(1.2f, 2.3f); ((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(0f); ((MainModule)(ref main)).startSize = new MinMaxCurve(0.04f, 0.08f); ((MainModule)(ref main)).maxParticles = 16; ((MainModule)(ref main)).prewarm = true; ShapeModule shape = obj.shape; ((ShapeModule)(ref shape)).enabled = true; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0; ((ShapeModule)(ref shape)).radius = 0.085f; ((ShapeModule)(ref shape)).scale = new Vector3(0.8f, 1.2f, 0.6f); VelocityOverLifetimeModule velocityOverLifetime = obj.velocityOverLifetime; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = true; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).space = (ParticleSystemSimulationSpace)1; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).y = MinMaxCurve.op_Implicit(0.09f); EmissionModule emission = obj.emission; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(5f); Fade(obj); obj.Play(); } private static Material TintedMaterial(Material source, string name, Color color, float emission) { //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_0018: Expected O, but got Unknown //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_005b: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) Material val = new Material(source) { name = name + "_Material" }; if (val.HasProperty("_Color")) { val.SetColor("_Color", color); } if (val.HasProperty("_TintColor")) { val.SetColor("_TintColor", new Color(color.r, color.g, color.b, 0.5f)); } if (val.HasProperty("_EmisColor")) { val.SetColor("_EmisColor", new Color(color.r, color.g, color.b, 0f)); } if (val.HasProperty("_EmissionColor")) { val.SetColor("_EmissionColor", color * emission); } return val; } private static void NativeMotes(Transform parent, ParticleSystem template, string name, Vector3 position, Color color) { //IL_002f: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: 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_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: 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_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: 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_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_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_025b: 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_028b: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: 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_02c8: 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_02dc: Expected O, but got Unknown //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)template)) { Plugin.Warn("Native particle source unavailable: " + name); return; } ParticleSystem val = Object.Instantiate<ParticleSystem>(template, parent, false); ((Object)val).name = name; ((Component)val).transform.localPosition = position; ((Component)val).transform.localRotation = Quaternion.identity; ((Component)val).transform.localScale = Vector3.one; val.Stop(true, (ParticleSystemStopBehavior)0); MainModule main = val.main; ((MainModule)(ref main)).loop = true; ((MainModule)(ref main)).duration = 3f; ((MainModule)(ref main)).prewarm = true; ((MainModule)(ref main)).playOnAwake = true; ((MainModule)(ref main)).stopAction = (ParticleSystemStopAction)0; ((MainModule)(ref main)).startLifetime = new MinMaxCurve(1.3f, 2.3f); ((MainModule)(ref main)).startSize3D = false; ((MainModule)(ref main)).startSize = new MinMaxCurve(0.045f, 0.095f); ((MainModule)(ref main)).startSpeed = new MinMaxCurve(0.015f, 0.04f); ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(WithAlpha(Color.white, 0.65f)); ((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(0f); ((MainModule)(ref main)).maxParticles = 28; ((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)0; ((MainModule)(ref main)).scalingMode = (ParticleSystemScalingMode)0; ShapeModule shape = val.shape; ((ShapeModule)(ref shape)).enabled = true; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0; ((ShapeModule)(ref shape)).radius = 0.09f; ((ShapeModule)(ref shape)).scale = new Vector3(0.8f, 1.2f, 0.6f); EmissionModule emission = val.emission; ((EmissionModule)(ref emission)).enabled = true; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(10f); ((EmissionModule)(ref emission)).rateOverDistance = MinMaxCurve.op_Implicit(0f); ((EmissionModule)(ref emission)).SetBursts((Burst[])(object)new Burst[0]); VelocityOverLifetimeModule velocityOverLifetime = val.velocityOverLifetime; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = true; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).space = (ParticleSystemSimulationSpace)0; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).x = new MinMaxCurve(-0.025f, 0.025f); ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).y = new MinMaxCurve(0.045f, 0.11f); ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).z = new MinMaxCurve(-0.015f, 0.015f); ForceOverLifetimeModule forceOverLifetime = val.forceOverLifetime; ((ForceOverLifetimeModule)(ref forceOverLifetime)).enabled = false; ExternalForcesModule externalForces = val.externalForces; ((ExternalForcesModule)(ref externalForces)).enabled = false; CollisionModule collision = val.collision; ((CollisionModule)(ref collision)).enabled = false; SubEmittersModule subEmitters = val.subEmitters; ((SubEmittersModule)(ref subEmitters)).enabled = false; TrailModule trails = val.trails; ((TrailModule)(ref trails)).enabled = false; ColorBySpeedModule colorBySpeed = val.colorBySpeed; ((ColorBySpeedModule)(ref colorBySpeed)).enabled = false; SizeOverLifetimeModule sizeOverLifetime = val.sizeOverLifetime; ((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true; ((SizeOverLifetimeModule)(ref sizeOverLifetime)).separateAxes = false; ((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, new AnimationCurve((Keyframe[])(object)new Keyframe[4] { new Keyframe(0f, 0.45f), new Keyframe(0.2f, 1f), new Keyframe(0.75f, 0.8f), new Keyframe(1f, 0.1f) })); Fade(val); ParticleSystemRenderer component = ((Component)val).GetComponent<ParticleSystemRenderer>(); ((Renderer)component).sharedMaterial = TintedMaterial(((Renderer)component).sharedMaterial, name, color, 1f); ((Renderer)component).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)component).receiveShadows = false; val.Play(); } internal static void PowerSound(Transform player) { //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) if (GUIManager.IsHeadless()) { return; } if (!Object.op_Implicit((Object)(object)powerActivation)) { powerActivation = PrefabManager.Instance.GetPrefab("fx_GP_Activation"); } if (!Object.op_Implicit((Object)(object)powerActivation) && Object.op_Implicit((Object)(object)ObjectDB.instance)) { StatusEffect statusEffect = ObjectDB.instance.GetStatusEffect(StringExtensionMethods.GetStableHashCode("GP_Eikthyr")); if (Object.op_Implicit((Object)(object)statusEffect)) { powerActivation = statusEffect.m_startEffects.m_effectPrefabs.Select((EffectData e) => e.m_prefab).FirstOrDefault((Func<GameObject, bool>)((GameObject p) => Object.op_Implicit((Object)(object)p) && ((Object)p).name == "fx_GP_Activation")); } } if (!Object.op_Implicit((Object)(object)powerActivation)) { Plugin.Warn("Native guardian-power audio prefab is unavailable."); return; } AudioSource[] componentsInChildren = powerActivation.GetComponentsInChildren<AudioSource>(true); foreach (AudioSource val in componentsInChildren) { if (!val.mute && Object.op_Implicit((Object)(object)((Component)val).GetComponent<ZSFX>())) { GameObject obj = Object.Instantiate<GameObject>(((Component)val).gameObject, player.position + Vector3.up, Quaternion.identity); ((Object)obj).name = "Fylgja_GPowerSound"; Object.Destroy((Object)(object)obj, 15f); } } } private static void Glint(Transform parent, string name, Vector3 offset, Color color, float size) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Expected O, but got Unknown //IL_0102: Unknown result type (might be due to invalid IL or missing references) ParticleSystem val = Particle(parent, name, color); ((Component)val).transform.localPosition = offset; MainModule main = val.main; ((MainModule)(ref main)).loop = true; ((MainModule)(ref main)).duration = 2.4f; ((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(2.4f); ((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(0f); ((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(size); ((MainModule)(ref main)).maxParticles = 2; EmissionModule emission = val.emission; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f); ((EmissionModule)(ref emission)).SetBursts((Burst[])(object)new Burst[1] { new Burst(0f, (short)1) }); SizeOverLifetimeModule sizeOverLifetime = val.sizeOverLifetime; ((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true; ((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, new AnimationCurve((Keyframe[])(object)new Keyframe[3] { new Keyframe(0f, 0.55f), new