Please disclose if your mod was created primarily 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 AuroraSacrificialAltar v1.0.0
plugins/AuroraSacrificialAltar.dll
Decompiled 3 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("aurora")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Sacrificial Altar - Trophy sacrifice with casino-style rewards")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("AuroraSacrificialAltar")] [assembly: AssemblyTitle("AuroraSacrificialAltar")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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 AuroraSacrificialAltar { [HarmonyPatch] public static class AltarPiece { public const string PrefabName = "piece_aurora_sacrificial_altar"; private static GameObject _altarPrefab; private static bool _registered; [HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")] [HarmonyPostfix] public static void ObjectDB_CopyOtherDB(ObjectDB __instance) { RegisterLocalization(); } [HarmonyPatch(typeof(ZNetScene), "Awake")] [HarmonyPostfix] public static void ZNetScene_Awake(ZNetScene __instance) { if (!_registered) { CreateAltarPrefab(__instance); if ((Object)(object)_altarPrefab != (Object)null) { RegisterInPieceTable(); } } } private static void CreateAltarPrefab(ZNetScene zNetScene) { //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Expected O, but got Unknown //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Expected O, but got Unknown //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Expected O, but got Unknown if ((Object)(object)_altarPrefab != (Object)null) { return; } GameObject prefab = zNetScene.GetPrefab("piece_brazierfloor01"); if ((Object)(object)prefab == (Object)null) { Plugin.Log.LogWarning((object)"AltarPiece: piece_brazierfloor01 not found"); return; } bool activeSelf = prefab.activeSelf; prefab.SetActive(false); _altarPrefab = Object.Instantiate<GameObject>(prefab); ((Object)_altarPrefab).name = "piece_aurora_sacrificial_altar"; Object.DontDestroyOnLoad((Object)(object)_altarPrefab); prefab.SetActive(activeSelf); Fireplace component = _altarPrefab.GetComponent<Fireplace>(); if ((Object)(object)component != (Object)null) { Object.DestroyImmediate((Object)(object)component); } Piece component2 = _altarPrefab.GetComponent<Piece>(); if ((Object)(object)component2 != (Object)null) { component2.m_name = "$piece_aurora_sacrificial_altar"; component2.m_description = "$piece_aurora_sacrificial_altar_desc"; component2.m_category = (PieceCategory)0; component2.m_canBeRemoved = true; component2.m_enabled = true; List<Requirement> list = new List<Requirement>(); ItemDrop itemDrop = GetItemDrop("Coal"); ItemDrop itemDrop2 = GetItemDrop("Copper"); ItemDrop itemDrop3 = GetItemDrop("SurtlingCore"); if ((Object)(object)itemDrop != (Object)null) { list.Add(new Requirement { m_resItem = itemDrop, m_amount = 100, m_recover = true }); } if ((Object)(object)itemDrop2 != (Object)null) { list.Add(new Requirement { m_resItem = itemDrop2, m_amount = 10, m_recover = true }); } if ((Object)(object)itemDrop3 != (Object)null) { list.Add(new Requirement { m_resItem = itemDrop3, m_amount = 10, m_recover = true }); } component2.m_resources = list.ToArray(); CraftingStation craftingStation = GetCraftingStation("forge"); if ((Object)(object)craftingStation != (Object)null) { component2.m_craftingStation = craftingStation; } } _altarPrefab.transform.localScale = Vector3.one * 4f; DisableFireEffects(_altarPrefab); _altarPrefab.AddComponent<AltarInteract>(); _altarPrefab.SetActive(true); ZNetView component3 = _altarPrefab.GetComponent<ZNetView>(); if ((Object)(object)component3 != (Object)null && (Object)(object)ZNetScene.instance != (Object)null) { BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; string[] array = new string[1] { "m_instances" }; foreach (string name in array) { FieldInfo field = typeof(ZNetScene).GetField(name, bindingAttr); if (field == null) { continue; } object value = field.GetValue(ZNetScene.instance); if (value == null) { continue; } MethodInfo method = value.GetType().GetMethod("Clear"); try { if (!(value is Dictionary<ZDO, ZNetView> dictionary)) { break; } ZDO val = null; foreach (KeyValuePair<ZDO, ZNetView> item in dictionary) { if ((Object)(object)item.Value == (Object)(object)component3) { val = item.Key; break; } } if (val != null) { dictionary.Remove(val); Plugin.Log.LogInfo((object)"AltarPiece: Removed prefab from ZNetScene.m_instances"); } } catch { } break; } } int stableHashCode = StringExtensionMethods.GetStableHashCode("piece_aurora_sacrificial_altar"); BindingFlags bindingAttr2 = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; string[] array2 = new string[2] { "m_namedPrefabs", "m_prefabsByHash" }; foreach (string name2 in array2) { FieldInfo field2 = typeof(ZNetScene).GetField(name2, bindingAttr2); if (!(field2 == null) && field2.GetValue(ZNetScene.instance) is Dictionary<int, GameObject> dictionary2) { dictionary2[stableHashCode] = _altarPrefab; break; } } Plugin.Log.LogInfo((object)"AltarPiece: Sacrificial Altar prefab created"); } private static void RegisterInPieceTable() { if (_registered || (Object)(object)_altarPrefab == (Object)null) { return; } foreach (GameObject item in ObjectDB.instance.m_items) { if ((Object)(object)item == (Object)null) { continue; } ItemDrop component = item.GetComponent<ItemDrop>(); if ((Object)(object)component?.m_itemData?.m_shared?.m_buildPieces == (Object)null || ((Object)item).name != "Hammer") { continue; } PieceTable buildPieces = component.m_itemData.m_shared.m_buildPieces; if (!buildPieces.m_pieces.Contains(_altarPrefab)) { buildPieces.m_pieces.Add(_altarPrefab); _registered = true; Plugin.Log.LogInfo((object)"AltarPiece: Registered in Hammer piece table"); } break; } } private static void RegisterLocalization() { Localization instance = Localization.instance; if (instance == null) { return; } BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; Dictionary<string, string> dictionary = null; string[] array = new string[2] { "m_translations", "m_words" }; foreach (string name in array) { FieldInfo field = typeof(Localization).GetField(name, bindingAttr); if (!(field == null)) { dictionary = field.GetValue(instance) as Dictionary<string, string>; if (dictionary != null) { break; } } } if (dictionary != null) { dictionary["piece_aurora_sacrificial_altar"] = "Sacrificial Altar"; dictionary["piece_aurora_sacrificial_altar_desc"] = "An ancient altar for offering trophies to the Allfather. Place your trophies and begin the sacrifice to earn Odin's Favor."; } } private static ItemDrop GetItemDrop(string prefabName) { ObjectDB instance = ObjectDB.instance; GameObject val = ((instance != null) ? instance.GetItemPrefab(prefabName) : null); return (val != null) ? val.GetComponent<ItemDrop>() : null; } private static CraftingStation GetCraftingStation(string name) { foreach (Recipe recipe in ObjectDB.instance.m_recipes) { if ((Object)(object)recipe?.m_craftingStation != (Object)null && ((Object)recipe.m_craftingStation).name.ToLower().Contains(name)) { return recipe.m_craftingStation; } } return null; } private static void DisableFireEffects(GameObject obj) { ParticleSystem[] componentsInChildren = obj.GetComponentsInChildren<ParticleSystem>(true); foreach (ParticleSystem val in componentsInChildren) { ((Component)val).gameObject.SetActive(false); } Light[] componentsInChildren2 = obj.GetComponentsInChildren<Light>(true); foreach (Light val2 in componentsInChildren2) { ((Component)val2).gameObject.SetActive(false); } } } public class AltarInteract : MonoBehaviour, Interactable, Hoverable { public string GetHoverText() { return Localization.instance.Localize("[<color=yellow><b>$KEY_Use</b></color>] Sacrifice Trophies"); } public string GetHoverName() { return "Sacrificial Altar"; } public bool Interact(Humanoid user, bool hold, bool alt) { if (hold) { return false; } if ((Object)(object)user != (Object)(object)Player.m_localPlayer) { return false; } AltarUI.Instance?.OpenAltar(this); return true; } public bool UseItem(Humanoid user, ItemData item) { return false; } public void SetFireActive(bool active) { ParticleSystem[] componentsInChildren = ((Component)this).GetComponentsInChildren<ParticleSystem>(true); foreach (ParticleSystem val in componentsInChildren) { ((Component)val).gameObject.SetActive(active); if (active) { val.Play(); } } Light[] componentsInChildren2 = ((Component)this).GetComponentsInChildren<Light>(true); foreach (Light val2 in componentsInChildren2) { ((Component)val2).gameObject.SetActive(active); } } } public class AltarUI : MonoBehaviour { private enum SacrificeState { Idle, Converting, Flickering, Done } private class TrophySlot { public string PrefabName; public string DisplayName; public int Amount; public bool Selected; public int FavorValue; public bool IsBoss; } private bool _isOpen = false; private AltarInteract _currentAltar; private Rect _windowRect; private int _windowId; private List<TrophySlot> _slots = new List<TrophySlot>(); private Vector2 _scrollPos; private SacrificeState _state = SacrificeState.Idle; private float _stateTimer = 0f; private float _convertDuration = 3.5f; private float _flickerDuration = 7f; private List<SacrificeReward> _flickerOptions; private int _flickerIndex = 0; private float _flickerSpeed = 0.1f; private float _flickerTimer = 0f; private SacrificeReward _finalReward; private string _odinDialogue; private GUIStyle _winStyle; private GUIStyle _headerStyle; private GUIStyle _labelStyle; private GUIStyle _goldStyle; private GUIStyle _btnStyle; private GUIStyle _btnHighStyle; private GUIStyle _boxStyle; private GUIStyle _hintStyle; private GUIStyle _dialogueStyle; private GUIStyle _closeStyle; private Texture2D _woodPanelTex; private Texture2D _woodDarkTex; private Texture2D _woodBtnTex; private Texture2D _woodBtnHoverTex; private Texture2D _goldBarTex; private Texture2D _slotBgTex; private bool _stylesInit = false; private Font _valheimFont; private Dictionary<string, Sprite> _spriteCache = new Dictionary<string, Sprite>(); public static AltarUI Instance { get; private set; } private void Awake() { Instance = this; _windowId = ((Object)this).GetInstanceID(); } public void OpenAltar(AltarInteract altar) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) _currentAltar = altar; _isOpen = true; if ((Object)(object)GameCamera.instance != (Object)null) { ((Behaviour)GameCamera.instance).enabled = false; } _state = SacrificeState.Idle; _finalReward = null; _odinDialogue = null; _slots.Clear(); _scrollPos = Vector2.zero; float num = 580f; float num2 = 480f; _windowRect = new Rect(((float)Screen.width - num) / 2f, ((float)Screen.height - num2) / 2f, num, num2); ScanTrophies(); } public void CloseAltar() { _isOpen = false; _state = SacrificeState.Idle; _finalReward = null; _currentAltar?.SetFireActive(active: false); _currentAltar = null; if ((Object)(object)GameCamera.instance != (Object)null) { ((Behaviour)GameCamera.instance).enabled = true; } } public static bool IsAltarOpen() { return (Object)(object)Instance != (Object)null && Instance._isOpen; } private void Update() { if (_isOpen) { if (Input.GetKeyDown((KeyCode)27) && (_state == SacrificeState.Idle || _state == SacrificeState.Done)) { CloseAltar(); } Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; if (ZInput.instance != null) { ZInput.ResetButtonStatus("Attack"); ZInput.ResetButtonStatus("SecondaryAttack"); ZInput.ResetButtonStatus("Block"); ZInput.ResetButtonStatus("Use"); ZInput.ResetButtonStatus("Jump"); } } } private void LateUpdate() { if (!_isOpen) { return; } Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; if (_state != SacrificeState.Converting && _state != SacrificeState.Flickering) { return; } _stateTimer -= Time.deltaTime; if (_state == SacrificeState.Flickering) { float num = 1f - _stateTimer / _flickerDuration; _flickerSpeed = Mathf.Lerp(0.05f, 0.5f, num * num); _flickerTimer -= Time.deltaTime; if (_flickerTimer <= 0f) { _flickerTimer = _flickerSpeed; _flickerIndex = (_flickerIndex + 1) % (_flickerOptions?.Count ?? 1); } } if (_stateTimer <= 0f) { if (_state == SacrificeState.Converting) { StartFlicker(); return; } _state = SacrificeState.Done; _currentAltar?.SetFireActive(active: false); SpawnReward(); } } private void ScanTrophies() { _slots.Clear(); Player localPlayer = Player.m_localPlayer; Inventory val = ((localPlayer != null) ? ((Humanoid)localPlayer).GetInventory() : null); if (val == null) { return; } foreach (ItemData allItem in val.GetAllItems()) { GameObject dropPrefab = allItem.m_dropPrefab; string prefab = ((dropPrefab != null) ? ((Object)dropPrefab).name : null) ?? ""; if (TrophyData.IsTrophy(prefab)) { TrophySlot trophySlot = _slots.Find((TrophySlot s) => s.PrefabName == prefab); if (trophySlot != null) { trophySlot.Amount += allItem.m_stack; continue; } Localization instance = Localization.instance; string displayName = ((instance != null) ? instance.Localize(allItem.m_shared?.m_name ?? prefab) : null) ?? prefab; _slots.Add(new TrophySlot { PrefabName = prefab, DisplayName = displayName, Amount = allItem.m_stack, Selected = false, FavorValue = TrophyData.GetFavorValue(prefab), IsBoss = TrophyData.IsBossTrophy(prefab) }); } } _slots.Sort((TrophySlot a, TrophySlot b) => (a.IsBoss != b.IsBoss) ? b.IsBoss.CompareTo(a.IsBoss) : b.FavorValue.CompareTo(a.FavorValue)); } private void SelectAll() { foreach (TrophySlot slot in _slots) { slot.Selected = true; } } private void DeselectAll() { foreach (TrophySlot slot in _slots) { slot.Selected = false; } } private void BeginSacrifice() { List<TrophySlot> list = _slots.FindAll((TrophySlot s) => s.Selected && s.Amount > 0); if (list.Count == 0) { return; } List<string> list2 = new List<string>(); bool hasBoss = false; int num = 0; foreach (TrophySlot item in list) { for (int i = 0; i < item.Amount; i++) { list2.Add(item.PrefabName); } if (item.IsBoss) { hasBoss = true; } num += item.FavorValue * item.Amount; } Player localPlayer = Player.m_localPlayer; Inventory val = ((localPlayer != null) ? ((Humanoid)localPlayer).GetInventory() : null); if (val == null) { return; } foreach (TrophySlot item2 in list) { int num2 = item2.Amount; List<ItemData> list3 = new List<ItemData>(val.GetAllItems()); foreach (ItemData item3 in list3) { if (num2 <= 0) { break; } GameObject dropPrefab = item3.m_dropPrefab; string text = ((dropPrefab != null) ? ((Object)dropPrefab).name : null) ?? ""; if (!(text != item2.PrefabName)) { if (item3.m_stack <= num2) { num2 -= item3.m_stack; val.RemoveItem(item3); } else { item3.m_stack -= num2; num2 = 0; } } } } _finalReward = SacrificeManager.CalculateReward(list2); _flickerOptions = SacrificeManager.GenerateFlickerOptions(12, num, hasBoss); if (_finalReward != null && _flickerOptions.Count > 0) { _flickerOptions[_flickerOptions.Count - 1] = _finalReward; } _odinDialogue = OdinDialogue.GetDialogue(list2.Count, hasBoss); _state = SacrificeState.Converting; _stateTimer = _convertDuration; _currentAltar?.SetFireActive(active: true); } private void StartFlicker() { _state = SacrificeState.Flickering; _stateTimer = _flickerDuration; _flickerIndex = 0; _flickerTimer = 0f; } private void SpawnReward() { //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0105: 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) if (_finalReward == null) { return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } ObjectDB instance = ObjectDB.instance; GameObject val = ((instance != null) ? instance.GetItemPrefab(_finalReward.PrefabName) : null); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)("AltarUI: Reward prefab '" + _finalReward.PrefabName + "' not found!")); MessageHud instance2 = MessageHud.instance; if (instance2 != null) { instance2.ShowMessage((MessageType)2, "<color=#ff4444>The gods could not manifest your reward (" + _finalReward.PrefabName + ")</color>", 0, (Sprite)null, false); } return; } Vector3 val2 = (((Object)(object)_currentAltar != (Object)null) ? (((Component)_currentAltar).transform.position + Vector3.up * 1.5f) : (((Component)localPlayer).transform.position + Vector3.up * 0.5f)); try { GameObject val3 = Object.Instantiate<GameObject>(val, val2, Quaternion.identity); ItemDrop component = val3.GetComponent<ItemDrop>(); if ((Object)(object)component != (Object)null) { component.m_itemData.m_stack = _finalReward.Amount; } val3.SetActive(true); } catch (Exception ex) { Plugin.Log.LogError((object)("AltarUI: Failed to spawn reward: " + ex.Message)); } MessageHud instance3 = MessageHud.instance; if (instance3 != null) { instance3.ShowMessage((MessageType)1, "<color=#88ccff>Remember: spend your Favor at a Pagan Ritual checkpoint!</color>", 0, (Sprite)null, false); } } private void OnGUI() { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Invalid comparison between Unknown and I4 //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Invalid comparison between Unknown and I4 //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Expected O, but got Unknown //IL_00ee: 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) if (!_isOpen) { return; } if ((Object)(object)Player.m_localPlayer == (Object)null) { CloseAltar(); return; } if (_stylesInit && ((Object)(object)_woodPanelTex == (Object)null || (Object)(object)_woodBtnTex == (Object)null)) { _stylesInit = false; } InitStyles(); Event current = Event.current; if (((int)current.type == 4 || (int)current.type == 5) && (int)current.keyCode != 27) { current.Use(); } if ((int)current.type == 6) { current.Use(); } Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; _windowRect = GUI.Window(_windowId, _windowRect, new WindowFunction(DrawWindow), "", _winStyle); } private void DrawWindow(int id) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0069: 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_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) float width = ((Rect)(ref _windowRect)).width; GUI.DrawTexture(new Rect(6f, 6f, width - 12f, 38f), (Texture)(object)_woodDarkTex); GUI.color = new Color(0.75f, 0.6f, 0.25f, 0.7f); GUI.DrawTexture(new Rect(6f, 43f, width - 12f, 2f), (Texture)(object)Texture2D.whiteTexture); GUI.DrawTexture(new Rect(6f, 4f, width - 12f, 2f), (Texture)(object)Texture2D.whiteTexture); GUI.color = Color.white; GUI.Label(new Rect(0f, 10f, width, 30f), "SACRIFICIAL ALTAR", _headerStyle); if ((_state == SacrificeState.Idle || _state == SacrificeState.Done) && GUI.Button(new Rect(width - 42f, 10f, 30f, 28f), "X", _closeStyle)) { CloseAltar(); } GUI.DragWindow(new Rect(0f, 0f, width - 48f, 44f)); float num = 52f; Rect area = default(Rect); ((Rect)(ref area))..ctor(12f, num, width - 24f, ((Rect)(ref _windowRect)).height - num - 12f); switch (_state) { case SacrificeState.Idle: DrawIdleState(area); break; case SacrificeState.Converting: DrawConvertingState(area); break; case SacrificeState.Flickering: DrawFlickerState(area); break; case SacrificeState.Done: DrawDoneState(area); break; } } private void DrawIdleState(Rect area) { //IL_002f: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0405: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_046a: Unknown result type (might be due to invalid IL or missing references) //IL_04a2: Unknown result type (might be due to invalid IL or missing references) //IL_04d9: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Unknown result type (might be due to invalid IL or missing references) float y = ((Rect)(ref area)).y; float width = ((Rect)(ref area)).width; float x = ((Rect)(ref area)).x; float num = (width - 12f) / 3f; if (GUI.Button(new Rect(x, y, num, 30f), "Put All Trophies", _btnStyle)) { SelectAll(); } if (GUI.Button(new Rect(x + num + 4f, y, num, 30f), "Remove All", _btnStyle)) { DeselectAll(); } if (GUI.Button(new Rect(x + (num + 4f) * 2f, y, num, 30f), "Refresh", _btnStyle)) { ScanTrophies(); } y += 36f; int num2 = 0; int num3 = 0; bool flag = false; foreach (TrophySlot slot in _slots) { if (slot.Selected) { num2 += slot.Amount; num3 += slot.FavorValue * slot.Amount; if (slot.IsBoss) { flag = true; } } } float num4 = ((Rect)(ref area)).yMax - y - 70f; Rect val = default(Rect); ((Rect)(ref val))..ctor(x, y, width, num4); GUI.Box(val, "", _boxStyle); Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(0f, 0f, width - 20f, (float)(_slots.Count * 38 + 8)); _scrollPos = GUI.BeginScrollView(val, _scrollPos, val2); for (int i = 0; i < _slots.Count; i++) { TrophySlot trophySlot = _slots[i]; float num5 = 4 + i * 38; if (trophySlot.Selected) { GUI.color = new Color(0.45f, 0.35f, 0.15f, 0.4f); GUI.DrawTexture(new Rect(2f, num5, ((Rect)(ref val2)).width - 4f, 36f), (Texture)(object)Texture2D.whiteTexture); GUI.color = Color.white; } Sprite sprite = GetSprite(trophySlot.PrefabName); if ((Object)(object)sprite != (Object)null) { DrawSprite(new Rect(6f, num5 + 3f, 30f, 30f), sprite); } string text = (trophySlot.IsBoss ? "#ffd700" : "#e8dcc8"); string text2 = (trophySlot.IsBoss ? " <color=#ff6600>[BOSS]</color>" : ""); GUI.Label(new Rect(42f, num5 + 2f, 220f, 32f), $"<color={text}>{trophySlot.DisplayName}</color>{text2} x{trophySlot.Amount}", _labelStyle); GUI.Label(new Rect(280f, num5 + 2f, 90f, 32f), $"<color=#6eb8e0>{trophySlot.FavorValue * trophySlot.Amount} Favor</color>", _labelStyle); string text3 = (trophySlot.Selected ? "Remove" : "Add"); if (GUI.Button(new Rect(((Rect)(ref val2)).width - 82f, num5 + 4f, 72f, 28f), text3, trophySlot.Selected ? _btnHighStyle : _btnStyle)) { trophySlot.Selected = !trophySlot.Selected; } } if (_slots.Count == 0) { GUI.Label(new Rect(20f, 20f, ((Rect)(ref val2)).width - 40f, 30f), "No trophies in your inventory.", _hintStyle); } GUI.EndScrollView(); y += num4 + 6f; string text4 = $"Selected: {num2} trophies | ~{num3} Favor"; if (flag) { text4 += " | <color=#ffd700>BOSS TROPHY!</color>"; } GUI.Label(new Rect(x, y, width - 170f, 28f), text4, _labelStyle); GUI.enabled = num2 > 0; if (GUI.Button(new Rect(x + width - 160f, y - 2f, 160f, 34f), "Begin Sacrifice", _btnHighStyle)) { BeginSacrifice(); } GUI.enabled = true; GUI.Label(new Rect(x, y + 32f, width, 20f), "<color=#8a7e6a>Place your trophies on the altar and let the Allfather judge your offering.</color>", _hintStyle); } private void DrawConvertingState(Rect area) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: 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_011e: 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) float num = ((Rect)(ref area)).x + ((Rect)(ref area)).width / 2f; float num2 = ((Rect)(ref area)).y + ((Rect)(ref area)).height / 2f - 50f; GUI.Label(new Rect(((Rect)(ref area)).x + 20f, num2 - 30f, ((Rect)(ref area)).width - 40f, 60f), _odinDialogue, _dialogueStyle); float num3 = 0.7f + 0.3f * Mathf.Sin(Time.time * 3f); GUI.color = new Color(1f, 0.6f, 0.2f, num3); GUI.Label(new Rect(((Rect)(ref area)).x, num2 + 40f, ((Rect)(ref area)).width, 30f), "The trophies burn upon the altar...", _headerStyle); GUI.color = Color.white; float progress = 1f - _stateTimer / _convertDuration; DrawProgressBar(new Rect(((Rect)(ref area)).x + 40f, num2 + 80f, ((Rect)(ref area)).width - 80f, 22f), progress, new Color(0.7f, 0.35f, 0.1f)); } private void DrawFlickerState(Rect area) { //IL_002f: 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_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0272: 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_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) float num = ((Rect)(ref area)).y + 20f; GUI.Label(new Rect(((Rect)(ref area)).x + 20f, num, ((Rect)(ref area)).width - 40f, 50f), _odinDialogue, _dialogueStyle); num += 60f; if (_flickerOptions != null && _flickerOptions.Count > 0) { SacrificeReward sacrificeReward = _flickerOptions[_flickerIndex % _flickerOptions.Count]; Rect val = default(Rect); ((Rect)(ref val))..ctor(((Rect)(ref area)).x + ((Rect)(ref area)).width / 2f - 160f, num, 320f, 80f); GUI.Box(val, "", _boxStyle); float num2 = 0.5f + 0.5f * Mathf.Sin(Time.time * 8f); GUI.color = new Color(0.85f, 0.7f, 0.25f, num2); DrawBorder(val, 2); GUI.color = Color.white; Sprite sprite = GetSprite(sacrificeReward.PrefabName); if ((Object)(object)sprite != (Object)null) { DrawSprite(new Rect(((Rect)(ref val)).x + 14f, ((Rect)(ref val)).y + 14f, 52f, 52f), sprite); } GUI.Label(new Rect(((Rect)(ref val)).x + 76f, ((Rect)(ref val)).y + 14f, 220f, 24f), "<color=#ffd700>" + sacrificeReward.DisplayName + "</color>", _goldStyle); GUI.Label(new Rect(((Rect)(ref val)).x + 76f, ((Rect)(ref val)).y + 40f, 220f, 24f), $"x{sacrificeReward.Amount}", _goldStyle); } num += 100f; DrawProgressBar(new Rect(((Rect)(ref area)).x + 40f, num, ((Rect)(ref area)).width - 80f, 20f), 1f - _stateTimer / _flickerDuration, new Color(0.85f, 0.65f, 0.12f)); GUI.Label(new Rect(((Rect)(ref area)).x, num + 28f, ((Rect)(ref area)).width, 20f), "Odin deliberates your fate...", _hintStyle); } private void DrawDoneState(Rect area) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: 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_012f: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Expected O, but got Unknown //IL_015e: 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_0190: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Expected O, but got Unknown //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) float num = ((Rect)(ref area)).y + 10f; GUI.Label(new Rect(((Rect)(ref area)).x + 20f, num, ((Rect)(ref area)).width - 40f, 60f), _odinDialogue, _dialogueStyle); num += 70f; if (_finalReward != null) { Rect val = default(Rect); ((Rect)(ref val))..ctor(((Rect)(ref area)).x + ((Rect)(ref area)).width / 2f - 170f, num, 340f, 90f); GUI.Box(val, "", _boxStyle); GUI.color = new Color(0.85f, 0.7f, 0.25f, 0.9f); DrawBorder(val, 2); GUI.color = Color.white; Sprite sprite = GetSprite(_finalReward.PrefabName); if ((Object)(object)sprite != (Object)null) { DrawSprite(new Rect(((Rect)(ref val)).x + 14f, ((Rect)(ref val)).y + 18f, 54f, 54f), sprite); } GUIStyle val2 = new GUIStyle(_goldStyle) { fontSize = 18 }; GUI.Label(new Rect(((Rect)(ref val)).x + 80f, ((Rect)(ref val)).y + 16f, 240f, 28f), "<color=#ffd700>" + _finalReward.DisplayName + "</color>", val2); GUIStyle val3 = new GUIStyle(_goldStyle) { fontSize = 22 }; GUI.Label(new Rect(((Rect)(ref val)).x + 80f, ((Rect)(ref val)).y + 48f, 240f, 30f), $"x{_finalReward.Amount}", val3); } num += 110f; GUI.Label(new Rect(((Rect)(ref area)).x, num, ((Rect)(ref area)).width, 24f), "<color=#6eb8e0>Spend your Favor at a Pagan Ritual checkpoint!</color>", _hintStyle); num += 34f; float num2 = 160f; if (GUI.Button(new Rect(((Rect)(ref area)).x + ((Rect)(ref area)).width / 2f - num2 / 2f, num, num2, 36f), "Close", _btnStyle)) { CloseAltar(); } } private void DrawProgressBar(Rect rect, float progress, Color fill) { //IL_0001: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) GUI.DrawTexture(rect, (Texture)(object)_slotBgTex); GUI.color = fill; GUI.DrawTexture(new Rect(((Rect)(ref rect)).x + 2f, ((Rect)(ref rect)).y + 2f, (((Rect)(ref rect)).width - 4f) * Mathf.Clamp01(progress), ((Rect)(ref rect)).height - 4f), (Texture)(object)Texture2D.whiteTexture); GUI.color = new Color(0.55f, 0.42f, 0.2f, 0.6f); DrawBorder(rect, 1); GUI.color = Color.white; } private void DrawBorder(Rect r, int t) { //IL_0018: 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_0069: 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) GUI.DrawTexture(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width, (float)t), (Texture)(object)Texture2D.whiteTexture); GUI.DrawTexture(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).yMax - (float)t, ((Rect)(ref r)).width, (float)t), (Texture)(object)Texture2D.whiteTexture); GUI.DrawTexture(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, (float)t, ((Rect)(ref r)).height), (Texture)(object)Texture2D.whiteTexture); GUI.DrawTexture(new Rect(((Rect)(ref r)).xMax - (float)t, ((Rect)(ref r)).y, (float)t, ((Rect)(ref r)).height), (Texture)(object)Texture2D.whiteTexture); } private Texture2D MakeTex(int w, int h, Color c) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(w, h) { hideFlags = (HideFlags)61 }; Color[] array = (Color[])(object)new Color[w * h]; for (int i = 0; i < array.Length; i++) { array[i] = c; } val.SetPixels(array); val.Apply(); return val; } private Texture2D MakeWoodPanel(int w, int h) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_011d: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(w, h) { hideFlags = (HideFlags)61, filterMode = (FilterMode)1 }; Random random = new Random(42); for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { float num = Mathf.PerlinNoise((float)j * 0.15f, (float)i * 0.05f) * 0.12f; float num2 = (float)(random.NextDouble() * 0.03 - 0.015); float num3 = 0.18f + num + num2; float num4 = 0.13f + num * 0.8f + num2; float num5 = 0.07f + num * 0.4f + num2; if (j < 4 || j >= w - 4 || i < 4 || i >= h - 4) { num3 = 0.06f; num4 = 0.04f; num5 = 0.02f; } else if (j < 6 || j >= w - 6 || i < 6 || i >= h - 6) { num3 = 0.5f; num4 = 0.38f; num5 = 0.15f; } val.SetPixel(j, i, new Color(num3, num4, num5, 0.97f)); } } val.Apply(); return val; } private Texture2D MakeWoodButton(int w, int h, bool highlight) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_011c: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(w, h) { hideFlags = (HideFlags)61 }; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { float num = (float)i / (float)h; float num2; float num3; float num4; if (highlight) { num2 = 0.35f + num * 0.08f; num3 = 0.25f + num * 0.06f; num4 = 0.1f + num * 0.03f; } else { num2 = 0.22f + num * 0.06f; num3 = 0.16f + num * 0.04f; num4 = 0.08f + num * 0.02f; } if (i >= h - 1) { num2 = 0.45f; num3 = 0.35f; num4 = 0.18f; } else if (i < 1) { num2 = 0.08f; num3 = 0.05f; num4 = 0.03f; } if (j < 1 || j >= w - 1) { num2 *= 0.6f; num3 *= 0.6f; num4 *= 0.6f; } val.SetPixel(j, i, new Color(num2, num3, num4, 0.95f)); } } val.Apply(); return val; } private void InitStyles() { //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Expected O, but got Unknown //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_018f: Expected O, but got Unknown //IL_0195: Expected O, but got Unknown //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Expected O, but got Unknown //IL_021a: 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_0228: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Expected O, but got Unknown //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Expected O, but got Unknown //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_0328: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_0361: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Expected O, but got Unknown //IL_0371: Expected O, but got Unknown //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_03a1: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_03c8: Unknown result type (might be due to invalid IL or missing references) //IL_03d8: Expected O, but got Unknown //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) //IL_03f2: Expected O, but got Unknown //IL_03fd: Unknown result type (might be due to invalid IL or missing references) //IL_0402: Unknown result type (might be due to invalid IL or missing references) //IL_0414: Unknown result type (might be due to invalid IL or missing references) //IL_0419: Unknown result type (might be due to invalid IL or missing references) //IL_0423: Expected O, but got Unknown //IL_0429: Expected O, but got Unknown //IL_0434: Unknown result type (might be due to invalid IL or missing references) //IL_0439: Unknown result type (might be due to invalid IL or missing references) //IL_0442: Unknown result type (might be due to invalid IL or missing references) //IL_044a: Unknown result type (might be due to invalid IL or missing references) //IL_0452: Unknown result type (might be due to invalid IL or missing references) //IL_045a: Unknown result type (might be due to invalid IL or missing references) //IL_046f: Unknown result type (might be due to invalid IL or missing references) //IL_047f: Expected O, but got Unknown //IL_04ae: Unknown result type (might be due to invalid IL or missing references) //IL_04b3: Unknown result type (might be due to invalid IL or missing references) //IL_04bc: Unknown result type (might be due to invalid IL or missing references) //IL_04c4: Unknown result type (might be due to invalid IL or missing references) //IL_04cc: Unknown result type (might be due to invalid IL or missing references) //IL_04d4: Unknown result type (might be due to invalid IL or missing references) //IL_04dc: Unknown result type (might be due to invalid IL or missing references) //IL_04f1: Unknown result type (might be due to invalid IL or missing references) //IL_0501: Expected O, but got Unknown if (_stylesInit) { return; } if ((Object)(object)_valheimFont == (Object)null) { try { Font[] array = Resources.FindObjectsOfTypeAll<Font>(); foreach (Font val in array) { string text = ((Object)val).name.ToLower(); if (text.Contains("norse") || text.Contains("averia") || text.Contains("valheim")) { _valheimFont = val; break; } } } catch { } } _woodPanelTex = MakeWoodPanel(64, 64); _woodDarkTex = MakeTex(1, 1, new Color(0.1f, 0.07f, 0.04f, 0.95f)); _woodBtnTex = MakeWoodButton(32, 32, highlight: false); _woodBtnHoverTex = MakeWoodButton(32, 32, highlight: true); _goldBarTex = MakeTex(1, 1, new Color(0.65f, 0.5f, 0.2f, 0.8f)); _slotBgTex = MakeTex(1, 1, new Color(0.06f, 0.04f, 0.03f, 0.85f)); GUIStyle val2 = new GUIStyle(GUI.skin.window); val2.normal.background = _woodPanelTex; val2.onNormal.background = _woodPanelTex; val2.border = new RectOffset(12, 12, 48, 12); val2.padding = new RectOffset(0, 0, 0, 0); _winStyle = val2; GUIStyle val3 = new GUIStyle(GUI.skin.label) { fontSize = 20, fontStyle = (FontStyle)1, alignment = (TextAnchor)4, richText = true }; val3.normal.textColor = new Color(0.95f, 0.82f, 0.4f); _headerStyle = val3; if ((Object)(object)_valheimFont != (Object)null) { _headerStyle.font = _valheimFont; } GUIStyle val4 = new GUIStyle(GUI.skin.label) { fontSize = 14, richText = true, wordWrap = true }; val4.normal.textColor = new Color(0.88f, 0.83f, 0.72f); _labelStyle = val4; if ((Object)(object)_valheimFont != (Object)null) { _labelStyle.font = _valheimFont; } GUIStyle val5 = new GUIStyle(_labelStyle) { fontStyle = (FontStyle)1, fontSize = 16 }; val5.normal.textColor = new Color(0.95f, 0.82f, 0.4f); _goldStyle = val5; GUIStyle val6 = new GUIStyle(GUI.skin.button) { fontSize = 14, fontStyle = (FontStyle)1 }; val6.normal.background = _woodBtnTex; val6.normal.textColor = new Color(0.9f, 0.82f, 0.6f); val6.hover.background = _woodBtnHoverTex; val6.hover.textColor = new Color(1f, 0.95f, 0.8f); val6.active.background = _woodBtnHoverTex; val6.padding = new RectOffset(10, 10, 8, 8); _btnStyle = val6; if ((Object)(object)_valheimFont != (Object)null) { _btnStyle.font = _valheimFont; } GUIStyle val7 = new GUIStyle(_btnStyle); val7.normal.background = _woodBtnHoverTex; val7.normal.textColor = new Color(1f, 0.9f, 0.5f); _btnHighStyle = val7; _closeStyle = new GUIStyle(_btnStyle) { fontSize = 15 }; GUIStyle val8 = new GUIStyle(GUI.skin.box); val8.normal.background = _slotBgTex; val8.padding = new RectOffset(4, 4, 4, 4); _boxStyle = val8; GUIStyle val9 = new GUIStyle(GUI.skin.label) { fontSize = 12, fontStyle = (FontStyle)2, alignment = (TextAnchor)4, richText = true }; val9.normal.textColor = new Color(0.6f, 0.55f, 0.42f); _hintStyle = val9; if ((Object)(object)_valheimFont != (Object)null) { _hintStyle.font = _valheimFont; } GUIStyle val10 = new GUIStyle(GUI.skin.label) { fontSize = 17, fontStyle = (FontStyle)2, alignment = (TextAnchor)4, richText = true, wordWrap = true }; val10.normal.textColor = new Color(0.95f, 0.85f, 0.5f); _dialogueStyle = val10; if ((Object)(object)_valheimFont != (Object)null) { _dialogueStyle.font = _valheimFont; } _stylesInit = true; } private Sprite GetSprite(string prefabName) { if (string.IsNullOrEmpty(prefabName)) { return null; } if (_spriteCache.TryGetValue(prefabName, out var value)) { return value; } try { ObjectDB instance = ObjectDB.instance; GameObject val = ((instance != null) ? instance.GetItemPrefab(prefabName) : null); if ((Object)(object)val != (Object)null) { ItemDrop component = val.GetComponent<ItemDrop>(); if (component?.m_itemData?.m_shared?.m_icons != null && component.m_itemData.m_shared.m_icons.Length != 0) { Sprite val2 = component.m_itemData.m_shared.m_icons[0]; if ((Object)(object)val2 != (Object)null) { _spriteCache[prefabName] = val2; } return val2; } } } catch { } return null; } private void DrawSprite(Rect pos, Sprite sprite) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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) if (!((Object)(object)((sprite != null) ? sprite.texture : null) == (Object)null)) { Rect textureRect = sprite.textureRect; GUI.DrawTextureWithTexCoords(pos, (Texture)(object)sprite.texture, new Rect(((Rect)(ref textureRect)).x / (float)((Texture)sprite.texture).width, ((Rect)(ref textureRect)).y / (float)((Texture)sprite.texture).height, ((Rect)(ref textureRect)).width / (float)((Texture)sprite.texture).width, ((Rect)(ref textureRect)).height / (float)((Texture)sprite.texture).height)); } } } public static class OdinDialogue { private static readonly string[] SmallLines = new string[10] { "A humble offering... but Odin sees your devotion.", "The Allfather accepts your meager tribute.", "Even the smallest sacrifice feeds the World Tree.", "Your offering is noted, mortal. Bring more next time.", "The ravens watched you struggle for these. Odin is... amused.", "A trickle of blood upon the altar. It will do... for now.", "Odin's one eye turns toward you. You have his attention — barely.", "The spirits stir. A modest offering, but not unwelcome.", "Better a small gift freely given than a great one taken by force.", "The crows will feast. You may yet earn the Allfather's favor." }; private static readonly string[] MediumLines = new string[10] { "A worthy offering! The gods take notice.", "Blood and bone upon the altar. Odin is pleased.", "The Valkyries sing your name... quietly, but they sing.", "Your trophies burn bright. The Allfather nods in approval.", "A respectable tribute. You walk the warrior's path well.", "The flames leap higher! The gods feast on your sacrifice.", "Odin whispers: 'This one knows the old ways.'", "The World Tree trembles with the weight of your devotion.", "Your enemies' trophies adorn the Allfather's hall. Well done.", "The ravens carry word of your deeds to Asgard." }; private static readonly string[] LargeLines = new string[10] { "A GLORIOUS offering! Odin raises his horn to you!", "The altar blazes! The gods themselves pause to watch!", "Such slaughter! Such devotion! You honor the old ways, warrior!", "Odin speaks: 'This one is worthy of Valhalla's gates.'", "The ground shakes with the power of your sacrifice!", "The Valkyries descend to witness your devotion!", "Even Thor pauses his thunder to hear your offering!", "Your name echoes through the nine realms this day!", "The World Serpent stirs at the magnitude of your tribute!", "Odin's wolves howl in celebration of your sacrifice!" }; private static readonly string[] BossLines = new string[10] { "A BOSS TROPHY! The Allfather is greatly honored!", "You have slain a great evil and offered its essence! MAGNIFICENT!", "The gods war over who shall reward you! Such is the power of your offering!", "A trophy of legend burns upon the altar! Odin grants you a special boon!", "The very foundations of Yggdrasil quake! A boss trophy! GLORY!", "Odin rises from Hlidskjalf! 'This warrior has earned my personal attention!'", "The Norns reweave your fate! Such an offering changes destiny itself!", "Freya weeps golden tears at the beauty of your sacrifice!", "The einherjar of Valhalla raise their cups! A champion walks among mortals!", "Odin speaks: 'Few mortals dare to sacrifice the heads of gods. You are EXCEPTIONAL.'" }; public static string GetDialogue(int trophyCount, bool hasBoss) { if (hasBoss) { return BossLines[Random.Range(0, BossLines.Length)]; } if (trophyCount >= 11) { return LargeLines[Random.Range(0, LargeLines.Length)]; } if (trophyCount >= 4) { return MediumLines[Random.Range(0, MediumLines.Length)]; } return SmallLines[Random.Range(0, SmallLines.Length)]; } } [BepInPlugin("aurora.sacrificial.altar", "Aurora Sacrificial Altar", "1.0.0")] [BepInProcess("valheim.exe")] [BepInProcess("valheim_server.exe")] public class Plugin : BaseUnityPlugin { private Harmony _harmony; private GameObject _managerObj; public static Plugin Instance { get; private set; } public static ManualLogSource Log { get; private set; } private void Awake() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Invalid comparison between Unknown and I4 //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; Log.LogInfo((object)"Aurora Sacrificial Altar loading..."); _harmony = new Harmony("aurora.sacrificial.altar"); _harmony.PatchAll(typeof(Plugin).Assembly); if ((int)SystemInfo.graphicsDeviceType != 4) { _managerObj = new GameObject("AuroraSacrificialAltarUI"); Object.DontDestroyOnLoad((Object)(object)_managerObj); _managerObj.AddComponent<AltarUI>(); } Log.LogInfo((object)"Aurora Sacrificial Altar loaded!"); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } if ((Object)(object)_managerObj != (Object)null) { Object.Destroy((Object)(object)_managerObj); } } } [HarmonyPatch(typeof(Player), "TakeInput")] public static class AltarPlayerInputPatch { public static bool Prefix() { if (AltarUI.IsAltarOpen()) { return false; } return true; } } [HarmonyPatch(typeof(PlayerController), "TakeInput")] public static class AltarControllerInputPatch { public static bool Prefix() { if (AltarUI.IsAltarOpen()) { return false; } return true; } } [HarmonyPatch(typeof(ZInput), "GetMouseScrollWheel")] public static class AltarScrollPatch { public static bool Prefix(ref float __result) { if (AltarUI.IsAltarOpen()) { __result = 0f; return false; } return true; } } public class SacrificeReward { public string PrefabName; public string DisplayName; public int Amount; } public static class SacrificeManager { private static readonly (string prefab, string display, int minBase, int maxBase)[] RareRewards = new(string, string, int, int)[20] { ("Veridium", "Veridium", 1, 3), ("GoldIngot", "Gold Ingot", 1, 3), ("Coins", "Coins", 50, 150), ("Amber", "Amber", 5, 15), ("Ruby", "Ruby", 3, 10), ("SilverNecklace", "Silver Necklace", 2, 5), ("Iron", "Iron", 5, 15), ("Bronze", "Bronze", 5, 15), ("Tin", "Tin", 5, 15), ("Copper", "Copper", 5, 15), ("Silver", "Silver", 3, 10), ("Wood", "Wood", 50, 150), ("Stone", "Stone", 50, 150), ("FineWood", "Fine Wood", 30, 80), ("RevivePotion", "Revive Potion", 3, 5), ("freyja_vaultkey_bronze", "Bronze Vault Key", 1, 1), ("freyja_vaultkey_silver", "Silver Vault Key", 1, 1), ("freyja_vaultkey_gold", "Gold Vault Key", 1, 1), ("JF_ItemsRepairKit", "Repair Kit", 5, 15), ("JF_ArmorRepairKit", "Armor Repair Kit", 5, 15) }; public static SacrificeReward CalculateReward(List<string> trophyPrefabs) { if (trophyPrefabs == null || trophyPrefabs.Count == 0) { return null; } int num = 0; int num2 = 0; foreach (string trophyPrefab in trophyPrefabs) { num += TrophyData.GetFavorValue(trophyPrefab); if (TrophyData.IsBossTrophy(trophyPrefab)) { num2++; } } if (num2 == 0) { return new SacrificeReward { PrefabName = "Favor", DisplayName = "Odin's Favor", Amount = num }; } float value = Random.value; if (value < 0.8f) { return new SacrificeReward { PrefabName = "Favor", DisplayName = "Odin's Favor", Amount = num }; } int num3 = Random.Range(0, RareRewards.Length); (string, string, int, int) tuple = RareRewards[num3]; int count = trophyPrefabs.Count; float num4 = 1f + (float)(count - 1) * 0.1f; int num5 = Random.Range(tuple.Item3, tuple.Item4 + 1); int num6 = Mathf.RoundToInt((float)num5 * num4); int num7 = 1 + num2; int amount = num6 * num7; return new SacrificeReward { PrefabName = tuple.Item1, DisplayName = tuple.Item2, Amount = amount }; } public static List<SacrificeReward> GenerateFlickerOptions(int count, int favorAmount, bool hasBoss) { List<SacrificeReward> list = new List<SacrificeReward>(); for (int i = 0; i < count; i++) { if (!hasBoss || Random.value < 0.6f) { list.Add(new SacrificeReward { PrefabName = "Favor", DisplayName = "Odin's Favor", Amount = Random.Range(favorAmount / 2, favorAmount * 2) }); } else { int num = Random.Range(0, RareRewards.Length); (string, string, int, int) tuple = RareRewards[num]; list.Add(new SacrificeReward { PrefabName = tuple.Item1, DisplayName = tuple.Item2, Amount = Random.Range(tuple.Item3, tuple.Item4 + 1) }); } } return list; } } public static class TrophyData { public static readonly HashSet<string> BossTrophies = new HashSet<string> { "TrophyEikthyr", "TrophyTheElder", "TrophyBonemass", "TrophyDragonQueen", "TrophyGoblinKing", "TrophySeekerQueen", "TrophyFader" }; public static readonly Dictionary<string, int> TrophyFavorValues = new Dictionary<string, int> { { "TrophyBoar", 1 }, { "TrophyDeer", 1 }, { "TrophyNeck", 2 }, { "TrophyGreydwarf", 2 }, { "TrophyGreydwarfShaman", 5 }, { "TrophyGreydwarfBrute", 6 }, { "TrophyEikthyr", 10 }, { "TrophySkeleton", 3 }, { "TrophySkeletonPoison", 5 }, { "TrophyGhost", 30 }, { "TrophyFrostTroll", 10 }, { "TrophyTheElder", 30 }, { "TrophyLeech", 6 }, { "TrophyDraugr", 6 }, { "TrophyDraugrElite", 12 }, { "TrophyBlob", 4 }, { "TrophySurtling", 7 }, { "TrophyWraith", 20 }, { "TrophyAbomination", 25 }, { "TrophyBonemass", 60 }, { "TrophyWolf", 15 }, { "TrophyHatchling", 16 }, { "TrophyUlv", 17 }, { "TrophyFenring", 18 }, { "TrophySGolem", 22 }, { "TrophyDragonQueen", 75 }, { "TrophyDeathsquito", 10 }, { "TrophyGrowth", 11 }, { "TrophyGoblin", 12 }, { "TrophyLox", 15 }, { "TrophyGoblinShaman", 18 }, { "TrophyGoblinBrute", 50 }, { "TrophyGoblinKing", 100 }, { "TrophyHare", 12 }, { "TrophyTick", 15 }, { "TrophySeeker", 25 }, { "TrophyDvergr", 30 }, { "TrophySeekerBrute", 40 }, { "TrophyGjall", 60 }, { "TrophySeekerQueen", 200 }, { "TrophyAsksvin", 30 }, { "TrophyCharredArcher", 60 }, { "TrophyCharredMage", 60 }, { "TrophyCharredMelee", 60 }, { "TrophyVolture", 70 }, { "TrophyFallenValkyrie", 75 }, { "TrophyMorgen", 85 }, { "TrophyBonemawSerpent", 90 }, { "TrophyFader", 300 }, { "TrophySerpent", 35 } }; public static int GetFavorValue(string prefabName) { int value; return TrophyFavorValues.TryGetValue(prefabName, out value) ? value : 3; } public static bool IsTrophy(string prefabName) { return prefabName?.StartsWith("Trophy") ?? false; } public static bool IsBossTrophy(string prefabName) { return BossTrophies.Contains(prefabName); } } }