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 PapysLand Modpack v1.0.5
plugins/PapysLandVSGVisual.dll
Decompiled 2 weeks agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Logging; using Jotunn.Managers; using Microsoft.CodeAnalysis; using Newtonsoft.Json.Linq; using UnityEngine; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.UI; using ValheimServerGuide; using ValheimServerGuide.Config; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("PapysLandVSGVisual")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("PapysLandVSGVisual")] [assembly: AssemblyTitle("PapysLandVSGVisual")] [assembly: AssemblyVersion("1.0.0.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 PapysLandVSGVisual { [BepInPlugin("papydiablo.papysland.vsgvisual", "PapysLand VSG Visual", "0.3.7")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { private sealed class ReferenceEqualityComparer : IEqualityComparer<object> { public static readonly ReferenceEqualityComparer Instance = new ReferenceEqualityComparer(); public new bool Equals(object x, object y) { return x == y; } public int GetHashCode(object obj) { return RuntimeHelpers.GetHashCode(obj); } } public const string PluginGuid = "papydiablo.papysland.vsgvisual"; public const string PluginName = "PapysLand VSG Visual"; public const string PluginVersion = "0.3.7"; internal static ManualLogSource Log; private const string CodexRootName = "VSG_CodexRoot"; private const string CodexPanelName = "VSG_CodexPanel"; private const string VisualRootName = "PapysLand_VSG_VisualRoot"; private const string HeaderObjectName = "PapysLand_GrandLivre_Header"; private const string HeaderResourceName = "PapysLandVSGVisual.Assets.PapysLand_GrandLivre_Header.png"; private const string LanguagePopupRootName = "PapysLand_QuestLanguage_Popup"; private const string LanguageSelectionResourceName = "PapysLandVSGVisual.Assets.PapysLand_Language_Selection.png"; private const string EnglishCatalogueResourceName = "PapysLandVSGVisual.Assets.Languages.PapysLand_GrandLivre_V8_EN.json"; private const float HeaderWidthFactor = 0.82f; private const float HeaderOverlapFactor = 0.04f; private float _nextCheckTime; private bool _codexWasOpen; private bool _missingHeaderWarningShown; private string _lastObjectiveText = string.Empty; private GameObject _objectiveIconObject; private Component _scaledBodyTextComponent; private float _originalBodyFontSize; private bool _guidanceCodexDumped; private string _lastLiveSelectedSignature = string.Empty; private GameObject _currentCodexRoot; private GameObject _visualRoot; private GameObject _languagePopupRoot; private int _currentPlayerInstanceId = -1; private bool _languageChoiceMadeThisSession; private string _selectedQuestLanguage = string.Empty; private string _currentLanguageStorageKey = string.Empty; private float _languagePopupReadySince = -1f; private bool _languagePopupPausedGame; private bool _languagePopupGameWasAlreadyPaused; private bool _languagePopupInputBlocked; private CursorLockMode _languagePopupPreviousCursorLockState = (CursorLockMode)1; private bool _languagePopupPreviousCursorVisible; private Texture2D _headerTexture; private Sprite _headerSprite; private Texture2D _languageSelectionTexture; private Sprite _languageSelectionSprite; private string _englishCatalogueJson = string.Empty; private bool _englishCatalogueLoaded; private JObject _englishCatalogueRoot; private object _lastLanguageAppliedConfig; private string _lastLanguageAppliedCode = string.Empty; private void Awake() { Log = ((BaseUnityPlugin)this).Logger; Log.LogInfo((object)"======================================"); Log.LogInfo((object)" PapysLand VSG Visual 0.3.7 DEV"); Log.LogInfo((object)" made by PapyDiablo"); Log.LogInfo((object)"======================================"); Log.LogInfo((object)"Plugin charge."); LoadHeaderSprite(); LoadLanguageSelectionSprite(); LoadEnglishQuestCatalogue(); Log.LogInfo((object)"Surveillance du Grand Livre active."); } private void Update() { if (Time.unscaledTime < _nextCheckTime) { return; } _nextCheckTime = Time.unscaledTime + 0.5f; UpdateLanguageChoicePopup(); UpdateCurrentVsgConfigLanguage(); GameObject val = GameObject.Find("VSG_CodexRoot"); if ((Object)(object)val != (Object)null && val.activeInHierarchy) { if (!_codexWasOpen) { _codexWasOpen = true; Log.LogInfo((object)"GRAND LIVRE DETECTE : OUVERT"); } if ((Object)(object)_currentCodexRoot != (Object)(object)val || (Object)(object)_visualRoot == (Object)null) { _currentCodexRoot = val; CreatePapysLandVisual(val); } UpdateEmptyBookWelcome(val); UpdateQuestLanguageTest0001(val); UpdateObjectiveIcon(val); return; } if (_codexWasOpen) { _codexWasOpen = false; Log.LogInfo((object)"Grand Livre detecte : FERME"); Transform bodyTransform = null; if ((Object)(object)_currentCodexRoot != (Object)null) { bodyTransform = FindChildRecursive(_currentCodexRoot.transform, "VSG_BodyContent"); } DestroyObjectiveIcon(bodyTransform); } _currentCodexRoot = null; _visualRoot = null; _lastObjectiveText = string.Empty; _guidanceCodexDumped = false; _lastLiveSelectedSignature = string.Empty; } private void UpdateLanguageChoicePopup() { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { ResetLanguageSessionState(); DestroyLanguageChoicePopup(); return; } int instanceID = ((Object)localPlayer).GetInstanceID(); if (_currentPlayerInstanceId != instanceID) { _currentPlayerInstanceId = instanceID; _languageChoiceMadeThisSession = false; _selectedQuestLanguage = string.Empty; _currentLanguageStorageKey = BuildLanguageStorageKey(localPlayer); _languagePopupReadySince = -1f; _lastLanguageAppliedConfig = null; _lastLanguageAppliedCode = string.Empty; DestroyLanguageChoicePopup(); LoadSavedQuestLanguage(); } if (!_languageChoiceMadeThisSession) { if (!IsPlayerReallyInWorld(localPlayer)) { _languagePopupReadySince = -1f; DestroyLanguageChoicePopup(); } else if (_languagePopupReadySince < 0f) { _languagePopupReadySince = Time.unscaledTime; } else if (!(Time.unscaledTime - _languagePopupReadySince < 1f) && !((Object)(object)_languagePopupRoot != (Object)null)) { CreateLanguageChoicePopup(); } } } private void ResetLanguageSessionState() { _currentPlayerInstanceId = -1; _languageChoiceMadeThisSession = false; _selectedQuestLanguage = string.Empty; _currentLanguageStorageKey = string.Empty; _languagePopupReadySince = -1f; _lastLanguageAppliedConfig = null; _lastLanguageAppliedCode = string.Empty; } private bool IsPlayerReallyInWorld(Player localPlayer) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)localPlayer == (Object)null || (Object)(object)((Component)localPlayer).gameObject == (Object)null || !((Component)localPlayer).gameObject.activeInHierarchy) { return false; } Scene activeScene = SceneManager.GetActiveScene(); if (!((Scene)(ref activeScene)).IsValid() || !string.Equals(((Scene)(ref activeScene)).name, "main", StringComparison.OrdinalIgnoreCase)) { return false; } try { MethodInfo method = ((object)localPlayer).GetType().GetMethod("CanMove", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null); if (method != null) { object obj = method.Invoke(localPlayer, null); if (obj is bool && !(bool)obj) { return false; } } } catch { } return true; } private string BuildLanguageStorageKey(Player localPlayer) { string text = string.Empty; try { MethodInfo method = ((object)localPlayer).GetType().GetMethod("GetPlayerID", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null); if (method != null) { object obj = method.Invoke(localPlayer, null); if (obj != null) { text = obj.ToString(); } } } catch { } if (string.IsNullOrWhiteSpace(text)) { try { MethodInfo method2 = ((object)localPlayer).GetType().GetMethod("GetPlayerName", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null); if (method2 != null) { object obj3 = method2.Invoke(localPlayer, null); if (obj3 != null) { text = obj3.ToString(); } } } catch { } } if (string.IsNullOrWhiteSpace(text)) { text = "unknown_" + ((Object)localPlayer).GetInstanceID(); } return "PapysLand.QuestLanguage." + text; } private void LoadSavedQuestLanguage() { if (!string.IsNullOrWhiteSpace(_currentLanguageStorageKey)) { string text = PlayerPrefs.GetString(_currentLanguageStorageKey, string.Empty); if (!(text != "fr") || !(text != "en")) { _selectedQuestLanguage = text; _languageChoiceMadeThisSession = true; Log.LogInfo((object)("CHOIX LANGUE PAPYSLAND : choix sauvegarde charge = " + text)); UpdateCurrentVsgConfigLanguage(); } } } private void CreateLanguageChoicePopup() { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_00d6: 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_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Expected O, but got Unknown //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_019d: 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_0204: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Expected O, but got Unknown //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) try { GameObject val = GameObject.Find("PapysLand_QuestLanguage_Popup"); if ((Object)(object)val != (Object)null) { _languagePopupRoot = val; EnterLanguageChoiceModalState(); return; } if ((Object)(object)_languageSelectionSprite == (Object)null) { Log.LogWarning((object)"CHOIX LANGUE PAPYSLAND : image embarquee indisponible."); return; } _languagePopupRoot = new GameObject("PapysLand_QuestLanguage_Popup", new Type[4] { typeof(RectTransform), typeof(Canvas), typeof(CanvasScaler), typeof(GraphicRaycaster) }); Object.DontDestroyOnLoad((Object)(object)_languagePopupRoot); Canvas component = _languagePopupRoot.GetComponent<Canvas>(); component.renderMode = (RenderMode)0; component.sortingOrder = 32000; CanvasScaler component2 = _languagePopupRoot.GetComponent<CanvasScaler>(); component2.uiScaleMode = (ScaleMode)1; component2.referenceResolution = new Vector2(1920f, 1080f); component2.screenMatchMode = (ScreenMatchMode)0; component2.matchWidthOrHeight = 0.5f; RectTransform component3 = _languagePopupRoot.GetComponent<RectTransform>(); component3.anchorMin = Vector2.zero; component3.anchorMax = Vector2.one; component3.offsetMin = Vector2.zero; component3.offsetMax = Vector2.zero; GameObject val2 = new GameObject("PapysLand_Language_Blocker", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image) }); val2.transform.SetParent(_languagePopupRoot.transform, false); RectTransform component4 = val2.GetComponent<RectTransform>(); component4.anchorMin = Vector2.zero; component4.anchorMax = Vector2.one; component4.offsetMin = Vector2.zero; component4.offsetMax = Vector2.zero; Image component5 = val2.GetComponent<Image>(); ((Graphic)component5).color = new Color(0f, 0f, 0f, 0.78f); ((Graphic)component5).raycastTarget = true; GameObject val3 = new GameObject("PapysLand_Language_Artwork", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image) }); val3.transform.SetParent(val2.transform, false); RectTransform component6 = val3.GetComponent<RectTransform>(); component6.anchorMin = new Vector2(0.5f, 0.5f); component6.anchorMax = new Vector2(0.5f, 0.5f); component6.pivot = new Vector2(0.5f, 0.5f); component6.sizeDelta = new Vector2(1600f, 900f); component6.anchoredPosition = Vector2.zero; Image component7 = val3.GetComponent<Image>(); component7.sprite = _languageSelectionSprite; component7.preserveAspect = true; ((Graphic)component7).raycastTarget = false; CreateTransparentLanguageButton(val3.transform, "PapysLand_Language_FR", new Vector2(-210f, -15f), new Vector2(350f, 165f), "fr"); CreateTransparentLanguageButton(val3.transform, "PapysLand_Language_EN", new Vector2(181f, -15f), new Vector2(360f, 165f), "en"); EnterLanguageChoiceModalState(); Log.LogInfo((object)"CHOIX LANGUE PAPYSLAND : interface image affichee."); } catch (Exception ex) { Log.LogWarning((object)("CHOIX LANGUE PAPYSLAND ERREUR : " + ex.Message)); } } private void CreateTransparentLanguageButton(Transform parent, string objectName, Vector2 anchoredPosition, Vector2 size, string languageCode) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: 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_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Expected O, but got Unknown GameObject val = new GameObject(objectName, new Type[4] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image), typeof(Button) }); val.transform.SetParent(parent, false); RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = new Vector2(0.5f, 0.5f); component.anchorMax = new Vector2(0.5f, 0.5f); component.pivot = new Vector2(0.5f, 0.5f); component.sizeDelta = size; component.anchoredPosition = anchoredPosition; Image component2 = val.GetComponent<Image>(); ((Graphic)component2).color = new Color(1f, 1f, 1f, 0.001f); ((Graphic)component2).raycastTarget = true; Button component3 = val.GetComponent<Button>(); ((Selectable)component3).transition = (Transition)0; ((UnityEvent)component3.onClick).AddListener((UnityAction)delegate { SelectQuestLanguage(languageCode); }); } private void SelectQuestLanguage(string languageCode) { if (!(languageCode != "fr") || !(languageCode != "en")) { _selectedQuestLanguage = languageCode; _languageChoiceMadeThisSession = true; if (!string.IsNullOrWhiteSpace(_currentLanguageStorageKey)) { PlayerPrefs.SetString(_currentLanguageStorageKey, languageCode); PlayerPrefs.Save(); } Log.LogInfo((object)("CHOIX LANGUE PAPYSLAND : " + ((languageCode == "fr") ? "FRANCAIS" : "ENGLISH") + " | sauvegarde par personnage")); UpdateCurrentVsgConfigLanguage(); DestroyLanguageChoicePopup(); } } private void EnterLanguageChoiceModalState() { //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) if (!_languagePopupPausedGame) { _languagePopupGameWasAlreadyPaused = Game.IsPaused(); _languagePopupPreviousCursorLockState = Cursor.lockState; _languagePopupPreviousCursorVisible = Cursor.visible; GUIManager.BlockInput(true); _languagePopupInputBlocked = true; if (!_languagePopupGameWasAlreadyPaused) { Game.Pause(); } _languagePopupPausedGame = true; } } private void RestoreLanguageChoiceModalState() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (_languagePopupPausedGame) { if (!_languagePopupGameWasAlreadyPaused && Game.IsPaused()) { Game.Unpause(); } if (_languagePopupInputBlocked) { GUIManager.BlockInput(false); _languagePopupInputBlocked = false; } Cursor.lockState = _languagePopupPreviousCursorLockState; Cursor.visible = _languagePopupPreviousCursorVisible; _languagePopupPausedGame = false; _languagePopupGameWasAlreadyPaused = false; } } private void DestroyLanguageChoicePopup() { if ((Object)(object)_languagePopupRoot != (Object)null) { Object.Destroy((Object)(object)_languagePopupRoot); _languagePopupRoot = null; } RestoreLanguageChoiceModalState(); } private void LoadEnglishQuestCatalogue() { _englishCatalogueLoaded = false; _englishCatalogueJson = string.Empty; _englishCatalogueRoot = null; try { Assembly executingAssembly = Assembly.GetExecutingAssembly(); using Stream stream = executingAssembly.GetManifestResourceStream("PapysLandVSGVisual.Assets.Languages.PapysLand_GrandLivre_V8_EN.json"); if (stream == null) { Log.LogError((object)"CATALOGUE EN PAPYSLAND : ressource introuvable : PapysLandVSGVisual.Assets.Languages.PapysLand_GrandLivre_V8_EN.json"); LogAvailableResources(executingAssembly); return; } using StreamReader streamReader = new StreamReader(stream, Encoding.UTF8, detectEncodingFromByteOrderMarks: true); _englishCatalogueJson = streamReader.ReadToEnd(); if (string.IsNullOrWhiteSpace(_englishCatalogueJson)) { Log.LogError((object)"CATALOGUE EN PAPYSLAND : ressource vide."); _englishCatalogueJson = string.Empty; return; } bool num = _englishCatalogueJson.IndexOf("PapysLand Grand Livre V8", StringComparison.Ordinal) >= 0; bool flag = _englishCatalogueJson.IndexOf("papysland_v8_main_0001", StringComparison.Ordinal) >= 0; bool flag2 = _englishCatalogueJson.IndexOf("papysland_v8_side_2350", StringComparison.Ordinal) >= 0; if (!num || !flag || !flag2) { Log.LogError((object)"CATALOGUE EN PAPYSLAND : contenu inattendu ou incomplet."); _englishCatalogueJson = string.Empty; return; } _englishCatalogueRoot = JObject.Parse(_englishCatalogueJson); JToken obj = _englishCatalogueRoot["quests"]; JObject val = (JObject)(object)((obj is JObject) ? obj : null); if (val == null || val["papysland_v8_main_0001"] == null) { Log.LogError((object)"CATALOGUE EN PAPYSLAND : structure JSON invalide ou quete 0001 absente."); _englishCatalogueRoot = null; _englishCatalogueJson = string.Empty; return; } _englishCatalogueLoaded = true; Log.LogInfo((object)("CATALOGUE EN PAPYSLAND : JSON parse et charge (" + ((JContainer)val).Count + " quetes, " + _englishCatalogueJson.Length + " caracteres).")); } catch (Exception ex) { _englishCatalogueLoaded = false; _englishCatalogueJson = string.Empty; _englishCatalogueRoot = null; Log.LogError((object)("CATALOGUE EN PAPYSLAND : erreur de chargement : " + ex.Message)); } } private void LoadLanguageSelectionSprite() { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown //IL_010f: 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) try { Assembly executingAssembly = Assembly.GetExecutingAssembly(); using Stream stream = executingAssembly.GetManifestResourceStream("PapysLandVSGVisual.Assets.PapysLand_Language_Selection.png"); if (stream == null) { Log.LogError((object)"Asset introuvable dans la DLL : PapysLandVSGVisual.Assets.PapysLand_Language_Selection.png"); LogAvailableResources(executingAssembly); return; } byte[] array = new byte[stream.Length]; int i; int num; for (i = 0; i < array.Length; i += num) { num = stream.Read(array, i, array.Length - i); if (num <= 0) { break; } } if (i != array.Length) { Log.LogError((object)"Lecture incomplete du PNG de choix de langue PapysLand."); return; } _languageSelectionTexture = new Texture2D(2, 2, (TextureFormat)4, false); ((Object)_languageSelectionTexture).name = "PapysLand_Language_Selection_Texture"; ((Texture)_languageSelectionTexture).wrapMode = (TextureWrapMode)1; ((Texture)_languageSelectionTexture).filterMode = (FilterMode)1; if (!ImageConversion.LoadImage(_languageSelectionTexture, array, false)) { Log.LogError((object)"Unity n'a pas pu decoder le PNG de choix de langue PapysLand."); Object.Destroy((Object)(object)_languageSelectionTexture); _languageSelectionTexture = null; } else { _languageSelectionSprite = Sprite.Create(_languageSelectionTexture, new Rect(0f, 0f, (float)((Texture)_languageSelectionTexture).width, (float)((Texture)_languageSelectionTexture).height), new Vector2(0.5f, 0.5f), 100f); ((Object)_languageSelectionSprite).name = "PapysLand_Language_Selection_Sprite"; Log.LogInfo((object)("CHOIX LANGUE PAPYSLAND : image embarquee chargee " + ((Texture)_languageSelectionTexture).width + "x" + ((Texture)_languageSelectionTexture).height)); } } catch (Exception ex) { Log.LogError((object)("Erreur chargement image choix de langue PapysLand : " + ex.Message)); } } private void LoadHeaderSprite() { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown //IL_010f: 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) try { Assembly executingAssembly = Assembly.GetExecutingAssembly(); using Stream stream = executingAssembly.GetManifestResourceStream("PapysLandVSGVisual.Assets.PapysLand_GrandLivre_Header.png"); if (stream == null) { Log.LogError((object)"Asset introuvable dans la DLL : PapysLandVSGVisual.Assets.PapysLand_GrandLivre_Header.png"); LogAvailableResources(executingAssembly); return; } byte[] array = new byte[stream.Length]; int i; int num; for (i = 0; i < array.Length; i += num) { num = stream.Read(array, i, array.Length - i); if (num <= 0) { break; } } if (i != array.Length) { Log.LogError((object)"Lecture incomplete du PNG PapysLand."); return; } _headerTexture = new Texture2D(2, 2, (TextureFormat)4, false); ((Object)_headerTexture).name = "PapysLand_GrandLivre_Header_Texture"; ((Texture)_headerTexture).wrapMode = (TextureWrapMode)1; ((Texture)_headerTexture).filterMode = (FilterMode)1; if (!ImageConversion.LoadImage(_headerTexture, array, false)) { Log.LogError((object)"Unity n'a pas pu decoder le PNG PapysLand."); Object.Destroy((Object)(object)_headerTexture); _headerTexture = null; return; } _headerSprite = Sprite.Create(_headerTexture, new Rect(0f, 0f, (float)((Texture)_headerTexture).width, (float)((Texture)_headerTexture).height), new Vector2(0.5f, 0.5f), 100f); ((Object)_headerSprite).name = "PapysLand_GrandLivre_Header_Sprite"; Log.LogInfo((object)"======================================"); Log.LogInfo((object)" FRONTON PAPYSLAND CHARGE"); Log.LogInfo((object)(" PNG : " + ((Texture)_headerTexture).width + "x" + ((Texture)_headerTexture).height)); Log.LogInfo((object)(" Ratio : " + ((float)((Texture)_headerTexture).width / (float)((Texture)_headerTexture).height).ToString("0.000"))); Log.LogInfo((object)"======================================"); } catch (Exception ex) { Log.LogError((object)"Erreur pendant le chargement du fronton PapysLand."); Log.LogError((object)ex); } } private void LogAvailableResources(Assembly assembly) { try { string[] manifestResourceNames = assembly.GetManifestResourceNames(); Log.LogWarning((object)"Ressources embarquees dans la DLL :"); string[] array = manifestResourceNames; foreach (string text in array) { Log.LogWarning((object)(" - " + text)); } } catch (Exception ex) { Log.LogError((object)ex); } } private void CreatePapysLandVisual(GameObject codexRoot) { //IL_00ae: 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_00be: 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_0232: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Expected O, but got Unknown //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_0270: 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_028f: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_030d: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_035e: 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_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_headerSprite == (Object)null || (Object)(object)_headerTexture == (Object)null) { if (!_missingHeaderWarningShown) { _missingHeaderWarningShown = true; Log.LogWarning((object)"Fronton PapysLand indisponible."); } return; } Transform val = FindChildRecursive(codexRoot.transform, "VSG_CodexPanel"); if ((Object)(object)val == (Object)null) { Log.LogWarning((object)"VSG_CodexPanel introuvable."); return; } RectTransform component = ((Component)val).GetComponent<RectTransform>(); if ((Object)(object)component == (Object)null) { Log.LogWarning((object)"RectTransform du Codex introuvable."); return; } Transform val2 = val.Find("PapysLand_VSG_VisualRoot"); if ((Object)(object)val2 != (Object)null) { _visualRoot = ((Component)val2).gameObject; return; } Canvas.ForceUpdateCanvases(); Rect rect = component.rect; float width = ((Rect)(ref rect)).width; rect = component.rect; float height = ((Rect)(ref rect)).height; if (width <= 1f || height <= 1f) { Log.LogWarning((object)("Dimensions du Codex invalides : " + width + "x" + height)); return; } float num = (float)((Texture)_headerTexture).width / (float)((Texture)_headerTexture).height; float num2 = width * 0.82f; float num3 = num2 / num; float num4 = num3 * 0.04f; Canvas componentInParent = ((Component)val).GetComponentInParent<Canvas>(); if ((Object)(object)componentInParent != (Object)null) { Vector3[] array = (Vector3[])(object)new Vector3[4]; component.GetWorldCorners(array); Vector2 val3 = RectTransformUtility.WorldToScreenPoint(((int)componentInParent.renderMode == 0) ? null : componentInParent.worldCamera, array[1]); float num5 = Mathf.Max(0.0001f, componentInParent.scaleFactor); float num6 = 8f / num5; float num7 = ((float)Screen.height - val3.y) / num5; num7 = Mathf.Max(0f, num7 - num6); float num8 = 0.96f; float num9 = ((num8 > 0.001f) ? (num7 / num8) : num3); if (num9 > 1f && num3 > num9) { num3 = num9; num2 = num3 * num; num4 = num3 * 0.04f; } } float num10 = height * 0.5f + num3 * 0.5f - num4; _visualRoot = new GameObject("PapysLand_VSG_VisualRoot", new Type[1] { typeof(RectTransform) }); _visualRoot.transform.SetParent(val, false); RectTransform component2 = _visualRoot.GetComponent<RectTransform>(); component2.anchorMin = Vector2.zero; component2.anchorMax = Vector2.one; component2.offsetMin = Vector2.zero; component2.offsetMax = Vector2.zero; component2.pivot = new Vector2(0.5f, 0.5f); GameObject val4 = new GameObject("PapysLand_GrandLivre_Header", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image) }); val4.transform.SetParent(_visualRoot.transform, false); RectTransform component3 = val4.GetComponent<RectTransform>(); component3.anchorMin = new Vector2(0.5f, 0.5f); component3.anchorMax = new Vector2(0.5f, 0.5f); component3.pivot = new Vector2(0.5f, 0.5f); component3.sizeDelta = new Vector2(num2, num3); component3.anchoredPosition = new Vector2(0f, num10); Image component4 = val4.GetComponent<Image>(); component4.sprite = _headerSprite; ((Graphic)component4).color = Color.white; component4.preserveAspect = true; ((Graphic)component4).raycastTarget = false; _visualRoot.transform.SetAsLastSibling(); Log.LogInfo((object)"======================================"); Log.LogInfo((object)" FRONTON PAPYSLAND INJECTE"); Log.LogInfo((object)(" Codex reel : " + width.ToString("0.0") + "x" + height.ToString("0.0"))); Log.LogInfo((object)(" Fronton calcule : " + num2.ToString("0.0") + "x" + num3.ToString("0.0"))); Log.LogInfo((object)(" Chevauchement HAUT : " + num4.ToString("0.0") + " px (4 % du fronton)")); Log.LogInfo((object)(" Centre Y : " + num10.ToString("0.0"))); Log.LogInfo((object)" Ratio PNG conserve."); Log.LogInfo((object)"======================================"); } private void TrackLiveSelectedGuidance(GameObject codexRoot) { try { MonoBehaviour[] array = Resources.FindObjectsOfTypeAll<MonoBehaviour>(); foreach (MonoBehaviour val in array) { if ((Object)(object)val == (Object)null) { continue; } Type type = ((object)val).GetType(); if ((type.FullName ?? type.Name) != "ValheimServerGuide.Display.GuidanceCodex") { continue; } BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; FieldInfo field = type.GetField("_selected", bindingFlags); if (field == null) { break; } object value = field.GetValue(val); if (value == null) { break; } Type type2 = value.GetType(); string text = ReadStringMember(value, type2, "Id", bindingFlags); string text2 = ReadStringMember(value, type2, "Title", bindingFlags); IList list = ReadMemberValue(value, type2, "Steps", bindingFlags) as IList; int displayedStepIndex = GetDisplayedStepIndex(codexRoot); string text3 = string.Empty; string text4 = string.Empty; if (list != null && displayedStepIndex >= 0 && displayedStepIndex < list.Count) { object obj = list[displayedStepIndex]; if (obj != null) { Type type3 = obj.GetType(); object obj2 = ReadMemberValue(obj, type3, "Trigger", bindingFlags); if (obj2 != null) { Type type4 = obj2.GetType(); text4 = ReadStringMember(obj2, type4, "Type", bindingFlags); text3 = ReadStringMember(obj2, type4, "Item", bindingFlags); if (string.IsNullOrWhiteSpace(text3) && ReadMemberValue(obj2, type4, "Goals", bindingFlags) is IList { Count: >0 } list2 && list2[0] != null) { object obj3 = list2[0]; text3 = ReadStringMember(obj3, obj3.GetType(), "Item", bindingFlags); } } } } string text5 = text + "|" + displayedStepIndex + "|" + text4 + "|" + text3; if (text5 != _lastLiveSelectedSignature) { _lastLiveSelectedSignature = text5; Log.LogInfo((object)("VSG LIVE SELECTED : Id=" + text + " | Title=" + text2 + " | Step=" + (displayedStepIndex + 1) + " | Trigger=" + text4 + " | Item=" + (string.IsNullOrWhiteSpace(text3) ? "<aucun>" : text3))); } break; } } catch (Exception ex) { Log.LogWarning((object)("VSG LIVE SELECTED ERREUR : " + ex.Message)); } } private int GetDisplayedStepIndex(GameObject codexRoot) { Transform val = FindChildRecursive(codexRoot.transform, "VSG_BodyContent"); if ((Object)(object)val == (Object)null) { return 0; } Component[] components = ((Component)val).GetComponents<Component>(); foreach (Component val2 in components) { if (!((Object)(object)val2 == (Object)null) && !(((object)val2).GetType().FullName != "TMPro.TextMeshProUGUI")) { PropertyInfo property = ((object)val2).GetType().GetProperty("text", BindingFlags.Instance | BindingFlags.Public); string text = ((property != null) ? (property.GetValue(val2, null) as string) : null); if (string.IsNullOrWhiteSpace(text)) { return 0; } string text2 = text.ToUpperInvariant(); int num = text2.IndexOf("ÉTAPE ", StringComparison.Ordinal); if (num < 0) { num = text2.IndexOf("ETAPE ", StringComparison.Ordinal); } if (num < 0) { num = text2.IndexOf("STEP ", StringComparison.Ordinal); } if (num < 0) { return 0; } int j; for (j = num; j < text2.Length && !char.IsDigit(text2[j]); j++) { } if (j >= text2.Length) { return 0; } int k; for (k = j; k < text2.Length && char.IsDigit(text2[k]); k++) { } if (int.TryParse(text2.Substring(j, k - j), out var result) && result > 0) { return result - 1; } return 0; } } return 0; } private object ReadMemberValue(object instance, Type type, string memberName, BindingFlags flags) { PropertyInfo property = type.GetProperty(memberName, flags); if (property != null && property.CanRead) { try { return property.GetValue(instance, null); } catch { } } FieldInfo fieldInfo = type.GetField(memberName, flags) ?? type.GetField("<" + memberName + ">k__BackingField", flags); if (fieldInfo != null) { try { return fieldInfo.GetValue(instance); } catch { } } return null; } private string ReadStringMember(object instance, Type type, string memberName, BindingFlags flags) { return (ReadMemberValue(instance, type, memberName, flags) as string) ?? string.Empty; } private void DumpGuidanceCodexRuntime(GameObject codexRoot) { if (_guidanceCodexDumped) { return; } try { MonoBehaviour[] array = Resources.FindObjectsOfTypeAll<MonoBehaviour>(); int num = 0; MonoBehaviour[] array2 = array; foreach (MonoBehaviour val in array2) { if ((Object)(object)val == (Object)null) { continue; } Type type = ((object)val).GetType(); string text = type.FullName ?? type.Name; if (text.IndexOf("ValheimServerGuide", StringComparison.OrdinalIgnoreCase) >= 0) { num++; if (text.IndexOf("GuidanceCodex", StringComparison.OrdinalIgnoreCase) >= 0) { _guidanceCodexDumped = true; Log.LogInfo((object)"======================================"); Log.LogInfo((object)"VSG GUIDANCECODEX GLOBAL RUNTIME DIAGNOSTIC"); Log.LogInfo((object)("TYPE : " + text)); Log.LogInfo((object)("GAMEOBJECT : " + (((Object)(object)((Component)val).gameObject != (Object)null) ? ((Object)((Component)val).gameObject).name : "<null>"))); Log.LogInfo((object)("ACTIVE : " + ((Object)(object)((Component)val).gameObject != (Object)null && ((Component)val).gameObject.activeInHierarchy))); DumpObjectMembers(val, type, 0); DumpSelectedGuidanceData(val, type); Log.LogInfo((object)"FIN VSG GUIDANCECODEX GLOBAL RUNTIME DIAGNOSTIC"); Log.LogInfo((object)"======================================"); return; } } } Log.LogWarning((object)("VSG DIAGNOSTIC GLOBAL : aucun GuidanceCodex trouve. " + num + " composant(s) ValheimServerGuide inspecte(s).")); } catch (Exception ex) { Log.LogError((object)("VSG DIAGNOSTIC GLOBAL ERREUR : " + ex)); } } private void DumpSelectedGuidanceData(object codexInstance, Type codexType) { try { BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; FieldInfo field = codexType.GetField("_selected", bindingAttr); if (field == null) { Log.LogWarning((object)"VSG SELECTED DIAGNOSTIC : champ _selected introuvable."); return; } object value = field.GetValue(codexInstance); Log.LogInfo((object)"======================================"); Log.LogInfo((object)"VSG SELECTED GUIDANCEENTRY DEEP DIAGNOSTIC"); if (value == null) { Log.LogWarning((object)"VSG SELECTED DIAGNOSTIC : _selected = null"); } else { HashSet<object> visited = new HashSet<object>(ReferenceEqualityComparer.Instance); DumpVsgObjectRecursive("_selected", value, 0, visited); } Log.LogInfo((object)"FIN VSG SELECTED GUIDANCEENTRY DEEP DIAGNOSTIC"); Log.LogInfo((object)"======================================"); } catch (Exception ex) { Log.LogError((object)("VSG SELECTED DIAGNOSTIC ERREUR : " + ex)); } } private void DumpVsgObjectRecursive(string path, object value, int depth, HashSet<object> visited) { if (value == null) { Log.LogInfo((object)("VSGDATA " + path + " = <null>")); return; } if (depth > 7) { Log.LogInfo((object)("VSGDATA " + path + " = <profondeur max>")); return; } Type type = value.GetType(); if (type == typeof(string) || type.IsPrimitive || type.IsEnum || value is decimal) { Log.LogInfo((object)("VSGDATA " + path + " = " + DescribeRuntimeValue(value))); return; } if (value is IEnumerable enumerable && !(value is string)) { int num = 0; foreach (object item in enumerable) { DumpVsgObjectRecursive(path + "[" + num + "]", item, depth + 1, visited); num++; if (num >= 100) { Log.LogInfo((object)("VSGDATA " + path + " = <liste tronquee a 100 elements>")); break; } } if (num == 0) { Log.LogInfo((object)("VSGDATA " + path + " = <collection vide>")); } return; } string text = type.FullName ?? type.Name; if (text.IndexOf("ValheimServerGuide", StringComparison.OrdinalIgnoreCase) < 0) { Log.LogInfo((object)("VSGDATA " + path + " = <" + text + "> " + value.ToString())); return; } if (visited.Contains(value)) { Log.LogInfo((object)("VSGDATA " + path + " = <deja visite " + text + ">")); return; } visited.Add(value); Log.LogInfo((object)("VSGDATA " + path + " TYPE=" + text)); BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; FieldInfo[] fields = type.GetFields(bindingAttr); foreach (FieldInfo fieldInfo in fields) { if (!fieldInfo.IsStatic) { try { object value2 = fieldInfo.GetValue(value); DumpVsgObjectRecursive(path + ".FIELD:" + fieldInfo.Name, value2, depth + 1, visited); } catch (Exception ex) { Log.LogInfo((object)("VSGDATA " + path + ".FIELD:" + fieldInfo.Name + " = <lecture impossible: " + ex.GetType().Name + ">")); } } } PropertyInfo[] properties = type.GetProperties(bindingAttr); foreach (PropertyInfo propertyInfo in properties) { if (propertyInfo.GetIndexParameters().Length != 0) { continue; } MethodInfo getMethod = propertyInfo.GetGetMethod(nonPublic: true); if (!(getMethod == null) && !getMethod.IsStatic) { try { object value3 = propertyInfo.GetValue(value, null); DumpVsgObjectRecursive(path + ".PROPERTY:" + propertyInfo.Name, value3, depth + 1, visited); } catch (Exception ex2) { Log.LogInfo((object)("VSGDATA " + path + ".PROPERTY:" + propertyInfo.Name + " = <lecture impossible: " + ex2.GetType().Name + ">")); } } } } private void DumpObjectMembers(object instance, Type type, int depth) { if (instance == null || type == null || depth > 1) { return; } BindingFlags bindingAttr = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; Type type2 = type; while (type2 != null && type2 != typeof(MonoBehaviour) && type2 != typeof(Behaviour) && type2 != typeof(Component) && type2 != typeof(Object) && type2 != typeof(object)) { Log.LogInfo((object)("--- MEMBRES DECLARES DANS " + (type2.FullName ?? type2.Name) + " ---")); FieldInfo[] fields = type2.GetFields(bindingAttr); foreach (FieldInfo fieldInfo in fields) { try { object value = fieldInfo.GetValue(instance); Log.LogInfo((object)("FIELD " + fieldInfo.FieldType.FullName + " " + fieldInfo.Name + " = " + DescribeRuntimeValue(value))); } catch (Exception ex) { Log.LogInfo((object)("FIELD " + fieldInfo.Name + " = <lecture impossible: " + ex.GetType().Name + ">")); } } PropertyInfo[] properties = type2.GetProperties(bindingAttr); foreach (PropertyInfo propertyInfo in properties) { if (propertyInfo.GetIndexParameters().Length == 0 && !(propertyInfo.GetGetMethod(nonPublic: true) == null)) { try { object value2 = propertyInfo.GetValue(instance, null); Log.LogInfo((object)("PROPERTY " + propertyInfo.PropertyType.FullName + " " + propertyInfo.Name + " = " + DescribeRuntimeValue(value2))); } catch (Exception ex2) { Log.LogInfo((object)("PROPERTY " + propertyInfo.Name + " = <lecture impossible: " + ex2.GetType().Name + ">")); } } } type2 = type2.BaseType; } } private string DescribeRuntimeValue(object value) { if (value == null) { return "<null>"; } if (value is string text) { return "\"" + text.Replace("\r", "\\r").Replace("\n", "\\n") + "\""; } Type type = value.GetType(); if (type.IsPrimitive || value is decimal || value is Enum) { return value.ToString(); } if (value is ICollection collection) { return "<" + type.FullName + " Count=" + collection.Count + ">"; } string text2 = type.FullName ?? type.Name; if (text2.IndexOf("ValheimServerGuide", StringComparison.OrdinalIgnoreCase) >= 0) { return "<" + text2 + "> " + DescribeSimpleMembers(value); } return "<" + text2 + "> " + value.ToString(); } private string DescribeSimpleMembers(object instance) { if (instance == null) { return "<null>"; } try { Type type = instance.GetType(); BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; StringBuilder stringBuilder = new StringBuilder(); FieldInfo[] fields = type.GetFields(bindingAttr); foreach (FieldInfo fieldInfo in fields) { Type fieldType = fieldInfo.FieldType; if (!(fieldType != typeof(string)) || fieldType.IsPrimitive || fieldType.IsEnum) { object value = fieldInfo.GetValue(instance); if (stringBuilder.Length > 0) { stringBuilder.Append(" | "); } stringBuilder.Append(fieldInfo.Name); stringBuilder.Append("="); stringBuilder.Append((value == null) ? "<null>" : value.ToString()); } } PropertyInfo[] properties = type.GetProperties(bindingAttr); foreach (PropertyInfo propertyInfo in properties) { if (propertyInfo.GetIndexParameters().Length != 0 || !propertyInfo.CanRead) { continue; } Type propertyType = propertyInfo.PropertyType; if (!(propertyType != typeof(string)) || propertyType.IsPrimitive || propertyType.IsEnum) { object value2; try { value2 = propertyInfo.GetValue(instance, null); } catch { continue; } if (stringBuilder.Length > 0) { stringBuilder.Append(" | "); } stringBuilder.Append(propertyInfo.Name); stringBuilder.Append("="); stringBuilder.Append((value2 == null) ? "<null>" : value2.ToString()); } } return (stringBuilder.Length == 0) ? "<aucun membre simple>" : stringBuilder.ToString(); } catch { return "<inspection impossible>"; } } private void UpdateEmptyBookWelcome(GameObject codexRoot) { try { MonoBehaviour[] array = Resources.FindObjectsOfTypeAll<MonoBehaviour>(); foreach (MonoBehaviour val in array) { if ((Object)(object)val == (Object)null) { continue; } Type type = ((object)val).GetType(); if ((type.FullName ?? type.Name) != "ValheimServerGuide.Display.GuidanceCodex") { continue; } BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; FieldInfo field = type.GetField("_selected", bindingAttr); FieldInfo field2 = type.GetField("_guideRows", bindingAttr); object? obj = ((field != null) ? field.GetValue(val) : null); int num = ((((field2 != null) ? field2.GetValue(val) : null) is ICollection collection) ? collection.Count : (-1)); if (obj != null || num != 0) { break; } FieldInfo field3 = type.GetField("_titleText", bindingAttr); FieldInfo field4 = type.GetField("_bodyText", bindingAttr); Component val2 = (Component)((field3 != null) ? /*isinst with value type is only supported in some contexts*/: null); Component val3 = (Component)((field4 != null) ? /*isinst with value type is only supported in some contexts*/: null); if ((Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null) { break; } PropertyInfo property = ((object)val2).GetType().GetProperty("text", BindingFlags.Instance | BindingFlags.Public); PropertyInfo property2 = ((object)val3).GetType().GetProperty("text", BindingFlags.Instance | BindingFlags.Public); if (!(property == null) && property.CanWrite && !(property2 == null) && property2.CanRead && property2.CanWrite) { string text = property2.GetValue(val3, null) as string; if (string.IsNullOrEmpty(text) || !text.Contains("PAPYSLAND_WELCOME_PAGE")) { property.SetValue(val2, "PAPYSLAND — GRAND LIVRE", null); string value = "<size=1><color=#00000000>PAPYSLAND_WELCOME_PAGE</color></size><color=#FFD34E><b>BIENVENUE DANS PAPYSLAND</b></color>\n<color=#FFD34E><b>WELCOME TO PAPYSLAND</b></color>\n\nLe Grand Livre est encore silencieux. Tes premières quêtes se révéleront au fil de tes actions dans le monde. Explore, ramasse tes premières ressources et reviens consulter le Grand Livre : de nouvelles pages apparaîtront automatiquement.\n\nThe Grand Book is still silent. Your first quests will reveal themselves as you act in the world. Explore, gather your first resources, then return to the Grand Book: new pages will appear automatically.\n\n<color=#FFD34E><b>Langues prises en charge / Supported Languages: Français / English</b></color>\nPour garantir le bon fonctionnement et l’affichage correct des quêtes PapysLand, utilisez Valheim en français ou en anglais.\nTo ensure PapysLand quests work correctly and display properly, please use Valheim in French or English."; property2.SetValue(val3, value, null); Log.LogInfo((object)"PAGE ACCUEIL PAPYSLAND : affichee (aucune quete visible)"); } } break; } } catch (Exception ex) { Log.LogWarning((object)("PAGE ACCUEIL PAPYSLAND ERREUR : " + ex.Message)); } } private void UpdateCurrentVsgConfigLanguage() { if ((_selectedQuestLanguage != "fr" && _selectedQuestLanguage != "en") || !_englishCatalogueLoaded || _englishCatalogueRoot == null) { return; } try { GuidanceConfig currentConfig = Plugin.CurrentConfig; if (currentConfig == null || currentConfig.Guidances == null || currentConfig.Guidances.Count == 0 || (currentConfig == _lastLanguageAppliedConfig && string.Equals(_lastLanguageAppliedCode, _selectedQuestLanguage, StringComparison.Ordinal))) { return; } JToken obj = _englishCatalogueRoot["quests"]; JObject val = (JObject)(object)((obj is JObject) ? obj : null); if (val == null) { return; } bool flag = _selectedQuestLanguage == "en"; BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; int num = 0; int num2 = 0; foreach (GuidanceEntry guidance in currentConfig.Guidances) { if (guidance == null) { continue; } Type type = ((object)guidance).GetType(); string text = ReadStringMember(guidance, type, "Id", flags); if (string.IsNullOrWhiteSpace(text)) { continue; } JToken obj2 = val[text]; JObject val2 = (JObject)(object)((obj2 is JObject) ? obj2 : null); if (val2 == null) { continue; } JToken obj3 = val2[flag ? "en" : "source_fr"]; JObject val3 = (JObject)(object)((obj3 is JObject) ? obj3 : null); JToken obj4 = val2["steps"]; JArray val4 = (JArray)(object)((obj4 is JArray) ? obj4 : null); if (val3 == null || val4 == null) { continue; } if (flag && string.IsNullOrWhiteSpace(ReadJsonText(val3, "title"))) { num2++; continue; } string value = ReadJsonText(val3, "title"); string value2 = ReadJsonText(val3, "category"); string value3 = ReadJsonText(val3, "summary"); WriteStringMember(guidance, type, "Title", value, flags); WriteStringMember(guidance, type, "Category", value2, flags); WriteStringMember(guidance, type, "Summary", value3, flags); if (ReadMemberValue(guidance, type, "Steps", flags) is IList list) { int num3 = Math.Min(list.Count, ((JContainer)val4).Count); for (int i = 0; i < num3; i++) { object obj5 = list[i]; JToken obj6 = val4[i]; JObject val5 = (JObject)(object)((obj6 is JObject) ? obj6 : null); if (obj5 != null && val5 != null) { JToken obj7 = val5[flag ? "en" : "source_fr"]; JObject val6 = (JObject)(object)((obj7 is JObject) ? obj7 : null); if (val6 != null) { string value4 = ReadJsonText(val6, "message"); string value5 = ReadJsonText(val6, "description"); string value6 = ReadJsonText(val6, "progress_label"); Type type2 = obj5.GetType(); WriteStringMember(obj5, type2, "Message", value4, flags); WriteStringMember(obj5, type2, "Description", value5, flags); WriteStringMember(obj5, type2, "ProgressLabel", value6, flags); } } } } num++; } _lastLanguageAppliedConfig = currentConfig; _lastLanguageAppliedCode = _selectedQuestLanguage; Log.LogInfo((object)("LANGUE PAPYSLAND PRE-F3 : " + num + " quete(s) appliquee(s) = " + _selectedQuestLanguage.ToUpperInvariant() + " | non traduites EN laissees en FR = " + (flag ? num2 : 0) + " | CurrentConfig.Guidances = " + currentConfig.Guidances.Count)); } catch (Exception ex) { Log.LogWarning((object)("LANGUE PAPYSLAND PRE-F3 ERREUR : " + ex.Message)); } } private void UpdateQuestLanguageTest0001(GameObject codexRoot) { if ((_selectedQuestLanguage != "fr" && _selectedQuestLanguage != "en") || !_englishCatalogueLoaded || _englishCatalogueRoot == null) { return; } try { MonoBehaviour[] array = Resources.FindObjectsOfTypeAll<MonoBehaviour>(); BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; MonoBehaviour[] array2 = array; foreach (MonoBehaviour val in array2) { if ((Object)(object)val == (Object)null) { continue; } Type type = ((object)val).GetType(); if ((type.FullName ?? type.Name) != "ValheimServerGuide.Display.GuidanceCodex") { continue; } FieldInfo field = type.GetField("_selected", bindingFlags); if (field == null) { break; } object value = field.GetValue(val); if (value == null) { break; } Type type2 = value.GetType(); string text = ReadStringMember(value, type2, "Id", bindingFlags); if (!string.Equals(text, "papysland_v8_main_0001", StringComparison.Ordinal)) { break; } JToken obj = _englishCatalogueRoot["quests"]; JObject val2 = (JObject)(object)((obj is JObject) ? obj : null); JObject val3 = (JObject)((val2 != null) ? /*isinst with value type is only supported in some contexts*/: null); if (val3 == null) { break; } bool flag = _selectedQuestLanguage == "en"; JToken obj2 = val3[flag ? "en" : "source_fr"]; JObject val4 = (JObject)(object)((obj2 is JObject) ? obj2 : null); JToken obj3 = val3["steps"]; JArray val5 = (JArray)(object)((obj3 is JArray) ? obj3 : null); if (val4 == null || val5 == null || ((JContainer)val5).Count == 0) { break; } string value2 = ReadJsonText(val4, "title"); string value3 = ReadJsonText(val4, "category"); string value4 = ReadJsonText(val4, "summary"); if (string.IsNullOrWhiteSpace(value2)) { break; } WriteStringMember(value, type2, "Title", value2, bindingFlags); WriteStringMember(value, type2, "Category", value3, bindingFlags); WriteStringMember(value, type2, "Summary", value4, bindingFlags); IList list = ReadMemberValue(value, type2, "Steps", bindingFlags) as IList; int num = GetDisplayedStepIndex(codexRoot); if (num < 0) { num = 0; } if (num >= ((JContainer)val5).Count) { num = ((JContainer)val5).Count - 1; } JToken obj4 = val5[num]; JObject val6 = (JObject)(object)((obj4 is JObject) ? obj4 : null); JObject val7 = (JObject)((val6 != null) ? /*isinst with value type is only supported in some contexts*/: null); if (val7 == null) { break; } string value5 = ReadJsonText(val7, "message"); string value6 = ReadJsonText(val7, "description"); string value7 = ReadJsonText(val7, "progress_label"); if (!string.IsNullOrWhiteSpace(value6)) { if (list != null && num >= 0 && num < list.Count && list[num] != null) { object obj5 = list[num]; Type type3 = obj5.GetType(); WriteStringMember(obj5, type3, "Message", value5, bindingFlags); WriteStringMember(obj5, type3, "Description", value6, bindingFlags); WriteStringMember(obj5, type3, "ProgressLabel", value7, bindingFlags); } FieldInfo field2 = type.GetField("_titleText", bindingFlags); FieldInfo field3 = type.GetField("_bodyText", bindingFlags); Component textComponent = (Component)((field2 != null) ? /*isinst with value type is only supported in some contexts*/: null); Component textComponent2 = (Component)((field3 != null) ? /*isinst with value type is only supported in some contexts*/: null); SetTextComponentValue(textComponent, value2); SetTextComponentValue(textComponent2, value6); } break; } } catch (Exception ex) { Log.LogWarning((object)("CATALOGUE LANGUE PAPYSLAND 0001 ERREUR : " + ex.Message)); } } private string ReadJsonText(JObject objectValue, string propertyName) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Invalid comparison between Unknown and I4 if (objectValue == null || string.IsNullOrWhiteSpace(propertyName)) { return string.Empty; } JToken val = objectValue[propertyName]; if (val == null || (int)val.Type == 10) { return string.Empty; } return ((object)val).ToString(); } private void SetTextComponentValue(Component textComponent, string value) { if (!((Object)(object)textComponent == (Object)null)) { PropertyInfo property = ((object)textComponent).GetType().GetProperty("text", BindingFlags.Instance | BindingFlags.Public); if (!(property == null) && property.CanWrite) { property.SetValue(textComponent, value, null); } } } private void WriteStringMember(object instance, Type type, string memberName, string value, BindingFlags flags) { if (instance == null || type == null) { return; } PropertyInfo property = type.GetProperty(memberName, flags); if (property != null && property.CanWrite && property.PropertyType == typeof(string)) { try { property.SetValue(instance, value, null); return; } catch { } } FieldInfo fieldInfo = type.GetField(memberName, flags) ?? type.GetField("<" + memberName + ">k__BackingField", flags); if (!(fieldInfo != null) || !(fieldInfo.FieldType == typeof(string))) { return; } try { fieldInfo.SetValue(instance, value); } catch { } } private void UpdateObjectiveIcon(GameObject codexRoot) { //IL_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Expected O, but got Unknown //IL_0344: Unknown result type (might be due to invalid IL or missing references) try { Transform val = FindChildRecursive(codexRoot.transform, "VSG_BodyContent"); if ((Object)(object)val == (Object)null) { return; } Component val2 = null; Component[] components = ((Component)val).GetComponents<Component>(); foreach (Component val3 in components) { if (!((Object)(object)val3 == (Object)null) && ((object)val3).GetType().FullName == "TMPro.TextMeshProUGUI") { val2 = val3; break; } } if ((Object)(object)val2 == (Object)null) { return; } Type type = ((object)val2).GetType(); PropertyInfo property = type.GetProperty("fontSize", BindingFlags.Instance | BindingFlags.Public); if (property != null && property.CanRead && property.CanWrite && property.PropertyType == typeof(float)) { if ((Object)(object)_scaledBodyTextComponent != (Object)(object)val2) { _scaledBodyTextComponent = val2; _originalBodyFontSize = (float)property.GetValue(val2, null); } property.SetValue(val2, _originalBodyFontSize * 1.75f, null); } PropertyInfo property2 = type.GetProperty("text", BindingFlags.Instance | BindingFlags.Public); if (property2 == null || !property2.CanRead || !property2.CanWrite) { return; } string text = property2.GetValue(val2, null) as string; if (string.IsNullOrEmpty(text)) { return; } string text2 = null; string value = null; if (text.IndexOf("OBJECTIF :", StringComparison.OrdinalIgnoreCase) >= 0) { text2 = "OBJECTIF :"; value = "<color=#FFD34E><u><b>OBJECTIF :</b></u></color> "; } else if (text.IndexOf("OBJECTIVE :", StringComparison.OrdinalIgnoreCase) >= 0) { text2 = "OBJECTIVE :"; value = "<color=#FFD34E><u><b>OBJECTIVE :</b></u></color> "; } if (text2 == null) { DestroyObjectiveIcon(val); _lastObjectiveText = text; return; } string value2 = "<color=#FFD34E><u><b>" + text2 + "</b></u></color>"; if (text.IndexOf(value2, StringComparison.OrdinalIgnoreCase) < 0) { int num = text.IndexOf(text2, StringComparison.OrdinalIgnoreCase); if (num >= 0) { text = text.Remove(num, text2.Length).Insert(num, value); property2.SetValue(val2, text, null); } } string currentVsgObjectiveItemPrefabName = GetCurrentVsgObjectiveItemPrefabName(codexRoot); Sprite val4 = null; _ = string.Empty; if (!string.IsNullOrWhiteSpace(currentVsgObjectiveItemPrefabName) && (Object)(object)ObjectDB.instance != (Object)null) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(currentVsgObjectiveItemPrefabName); if ((Object)(object)itemPrefab != (Object)null) { ItemDrop component = itemPrefab.GetComponent<ItemDrop>(); if ((Object)(object)component != (Object)null && component.m_itemData != null) { val4 = component.m_itemData.GetIcon(); } } } if ((Object)(object)val4 == (Object)null) { string currentVsgObjectiveCreaturePrefabName = GetCurrentVsgObjectiveCreaturePrefabName(codexRoot); if (!string.IsNullOrWhiteSpace(currentVsgObjectiveCreaturePrefabName)) { val4 = GetCreatureTrophySprite(currentVsgObjectiveCreaturePrefabName); _ = (Object)(object)val4 != (Object)null; } } if ((Object)(object)val4 == (Object)null) { DestroyObjectiveIcon(val); _lastObjectiveText = text; return; } Image val5 = null; if ((Object)(object)_objectiveIconObject == (Object)null) { _objectiveIconObject = new GameObject("PapysLand_Auto_ObjectiveIcon", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image) }); _objectiveIconObject.transform.SetParent(val, false); val5 = _objectiveIconObject.GetComponent<Image>(); val5.preserveAspect = true; ((Graphic)val5).raycastTarget = false; _objectiveIconObject.GetComponent<RectTransform>().sizeDelta = new Vector2(56f, 56f); } else { val5 = _objectiveIconObject.GetComponent<Image>(); } if ((Object)(object)val5 != (Object)null) { val5.sprite = val4; } PositionObjectiveIcon(val2, text); _lastObjectiveText = text; } catch (Exception ex) { Log.LogWarning((object)("Icone objectif automatique : " + ex.Message)); } } private string GetCurrentVsgObjectiveItemPrefabName(GameObject codexRoot) { try { MonoBehaviour[] array = Resources.FindObjectsOfTypeAll<MonoBehaviour>(); BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; MonoBehaviour[] array2 = array; foreach (MonoBehaviour val in array2) { if ((Object)(object)val == (Object)null) { continue; } Type type = ((object)val).GetType(); if ((type.FullName ?? type.Name) != "ValheimServerGuide.Display.GuidanceCodex") { continue; } FieldInfo field = type.GetField("_selected", bindingFlags); if (field == null) { return string.Empty; } object value = field.GetValue(val); if (value == null) { return string.Empty; } Type type2 = value.GetType(); ReadStringMember(value, type2, "Id", bindingFlags); IList list = ReadMemberValue(value, type2, "Steps", bindingFlags) as IList; int displayedStepIndex = GetDisplayedStepIndex(codexRoot); if (list == null || displayedStepIndex < 0 || displayedStepIndex >= list.Count || list[displayedStepIndex] == null) { return string.Empty; } object obj = list[displayedStepIndex]; Type type3 = obj.GetType(); string[] array3 = new string[2] { "Trigger", "ProgressTrigger" }; foreach (string memberName in array3) { object obj2 = ReadMemberValue(obj, type3, memberName, bindingFlags); if (obj2 != null) { Type type4 = obj2.GetType(); string text = ReadStringMember(obj2, type4, "Item", bindingFlags); if (string.IsNullOrWhiteSpace(text) && ReadMemberValue(obj2, type4, "Goals", bindingFlags) is IList { Count: >0 } list2 && list2[0] != null) { text = ReadStringMember(list2[0], list2[0].GetType(), "Item", bindingFlags); } if (!string.IsNullOrWhiteSpace(text)) { return text; } } } return string.Empty; } } catch (Exception ex) { Log.LogWarning((object)("Icone objectif VSG : " + ex.Message)); } return string.Empty; } private string GetCurrentVsgObjectiveCreaturePrefabName(GameObject codexRoot) { try { MonoBehaviour[] array = Resources.FindObjectsOfTypeAll<MonoBehaviour>(); BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; MonoBehaviour[] array2 = array; foreach (MonoBehaviour val in array2) { if ((Object)(object)val == (Object)null) { continue; } Type type = ((object)val).GetType(); if ((type.FullName ?? type.Name) != "ValheimServerGuide.Display.GuidanceCodex") { continue; } FieldInfo field = type.GetField("_selected", bindingFlags); if (field == null) { return string.Empty; } object value = field.GetValue(val); if (value == null) { return string.Empty; } Type type2 = value.GetType(); IList list = ReadMemberValue(value, type2, "Steps", bindingFlags) as IList; int displayedStepIndex = GetDisplayedStepIndex(codexRoot); if (list == null || displayedStepIndex < 0 || displayedStepIndex >= list.Count || list[displayedStepIndex] == null) { return string.Empty; } object obj = list[displayedStepIndex]; Type type3 = obj.GetType(); string[] array3 = new string[2] { "Trigger", "ProgressTrigger" }; foreach (string memberName in array3) { object obj2 = ReadMemberValue(obj, type3, memberName, bindingFlags); if (obj2 != null) { Type type4 = obj2.GetType(); string text = ReadStringMember(obj2, type4, "Creature", bindingFlags); if (!string.IsNullOrWhiteSpace(text)) { return text; } } } return string.Empty; } } catch (Exception ex) { Log.LogWarning((object)("Icone creature VSG : " + ex.Message)); } return string.Empty; } private Sprite GetCreatureTrophySprite(string creatureName) { if (string.IsNullOrWhiteSpace(creatureName) || (Object)(object)ObjectDB.instance == (Object)null) { return null; } string creatureTrophyPrefabName = GetCreatureTrophyPrefabName(creatureName); if (string.IsNullOrWhiteSpace(creatureTrophyPrefabName)) { return null; } GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(creatureTrophyPrefabName); if ((Object)(object)itemPrefab == (Object)null) { return null; } ItemDrop component = itemPrefab.GetComponent<ItemDrop>(); if ((Object)(object)component == (Object)null || component.m_itemData == null) { return null; } return component.m_itemData.GetIcon(); } private string GetCreatureTrophyPrefabName(string creatureName) { return creatureName switch { "Abomination" => "TrophyAbomination", "Blob" => "TrophyBlob", "Boar" => "TrophyBoar", "Bonemass" => "TrophyBonemass", "Charred_Archer" => "TrophyCharredArcher", "Charred_Melee" => "TrophyCharredMelee", "Deathsquito" => "TrophyDeathsquito", "Deer" => "TrophyDeer", "Dragon" => "TrophyDragonQueen", "Draugr" => "TrophyDraugr", "Eikthyr" => "TrophyEikthyr", "Fader" => "TrophyFader", "Gjall" => "TrophyGjall", "Goblin" => "TrophyGoblin", "GoblinKing" => "TrophyGoblinKing", "Greydwarf" => "TrophyGreydwarf", "Hatchling" => "TrophyHatchling", "Lox" => "TrophyLox", "Morgen" => "TrophyMorgen", "Seeker" => "TrophySeeker", "SeekerBrute" => "TrophySeekerBrute", "SeekerQueen" => "TrophySeekerQueen", "Skeleton" => "TrophySkeleton", "StoneGolem" => "TrophySGolem", "Troll" => "TrophyForestTroll", "Wolf" => "TrophyWolf", "gd_king" => "TrophyTheElder", _ => "Trophy" + creatureName, }; } private string ExtractObjectiveText(string text) { int num = text.IndexOf("OBJECTIF", StringComparison.OrdinalIgnoreCase); if (num < 0) { return string.Empty; } int num2 = text.IndexOf("\n\n", num, StringComparison.Ordinal); if (num2 < 0) { num2 = text.Length; } return text.Substring(num, num2 - num); } private bool TryFindObjectiveItemSprite(string objectiveText, out Sprite sprite, out string matchedItemName) { sprite = null; matchedItemName = string.Empty; if ((Object)(object)ObjectDB.instance == (Object)null || string.IsNullOrWhiteSpace(objectiveText)) { return false; } string text = objectiveText.ToLowerInvariant(); FieldInfo field = typeof(ObjectDB).GetField("m_items", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field == null) { return false; } if (!(field.GetValue(ObjectDB.instance) is IEnumerable enumerable)) { return false; } int num = 0; Sprite val = null; string text2 = string.Empty; foreach (object item in enumerable) { GameObject val2 = (GameObject)((item is GameObject) ? item : null); if ((Object)(object)val2 == (Object)null) { continue; } ItemDrop component = val2.GetComponent<ItemDrop>(); if ((Object)(object)component == (Object)null || component.m_itemData == null || component.m_itemData.m_shared == null) { continue; } string name = component.m_itemData.m_shared.m_name; if (string.IsNullOrWhiteSpace(name)) { continue; } string text3 = name; try { Type type = null; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { if (assembly == null) { continue; } try { type = assembly.GetType("Localization", throwOnError: false, ignoreCase: false); if (type != null) { break; } } catch { } } if (type != null) { object obj2 = null; FieldInfo field2 = type.GetField("instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (field2 != null) { obj2 = field2.GetValue(null); } else { PropertyInfo property = type.GetProperty("instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (property != null && property.CanRead) { obj2 = property.GetValue(null, null); } } if (obj2 != null) { MethodInfo method = type.GetMethod("Localize", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(string) }, null); if (method != null && method.Invoke(obj2, new object[1] { name }) is string text4 && !string.IsNullOrWhiteSpace(text4)) { text3 = text4; } } } } catch { text3 = name; } if (string.IsNullOrWhiteSpace(text3)) { continue; } string text5 = text3.Trim().ToLowerInvariant(); if (text5.Length >= 3 && text.IndexOf(text5, StringComparison.OrdinalIgnoreCase) >= 0 && text5.Length > num) { Sprite icon = component.m_itemData.GetIcon(); if (!((Object)(object)icon == (Object)null)) { num = text5.Length; val = icon; text2 = text3 + " [" + ((Object)val2).name + "]"; } } } if ((Object)(object)val == (Object)null) { return false; } sprite = val; matchedItemName = text2; return true; } private void PositionObjectiveIcon(Component textComponent, string text) { //IL_0242: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_objectiveIconObject == (Object)null) { return; } int num = text.IndexOf("</color>", StringComparison.OrdinalIgnoreCase); if (num < 0) { return; } int i; for (i = num + "</color>".Length; i < text.Length && char.IsWhiteSpace(text[i]); i++) { } if (i >= text.Length) { return; } Type type = ((object)textComponent).GetType(); MethodInfo method = type.GetMethod("ForceMeshUpdate", BindingFlags.Instance | BindingFlags.Public, null, Type.EmptyTypes, null); if (method != null) { method.Invoke(textComponent, null); } else { MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Public); foreach (MethodInfo methodInfo in methods) { if (!(methodInfo.Name != "ForceMeshUpdate")) { ParameterInfo[] parameters = methodInfo.GetParameters(); if (parameters.Length == 2 && parameters[0].ParameterType == typeof(bool) && parameters[1].ParameterType == typeof(bool)) { methodInfo.Invoke(textComponent, new object[2] { false, false }); break; } } } } PropertyInfo property = type.GetProperty("textInfo", BindingFlags.Instance | BindingFlags.Public); if (property == null) { return; } object value = property.GetValue(textComponent, null); if (value == null) { return; } FieldInfo field = value.GetType().GetField("characterInfo", BindingFlags.Instance | BindingFlags.Public); if (field == null || !(field.GetValue(value) is Array { Length: not 0 } array)) { return; } object obj = null; for (int k = 0; k < array.Length; k++) { object value2 = array.GetValue(k); if (value2 != null) { Type type2 = value2.GetType(); if (ReadIntMember(value2, type2, "index") >= i) { obj = value2; break; } } } if (obj != null) { Type type3 = obj.GetType(); float num2 = ReadFloatMember(obj, type3, "origin"); float num3 = ReadFloatMember(obj, type3, "ascender"); float num4 = ReadFloatMember(obj, type3, "descender"); float num5 = (num3 + num4) * 0.5f; RectTransform component = _objectiveIconObject.GetComponent<RectTransform>(); ((Transform)component).localPosition = new Vector3(num2 - 36f, num5, 0f); ((Transform)component).SetAsLastSibling(); } } private int ReadIntMember(object instance, Type type, string memberName) { FieldInfo field = type.GetField(memberName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { object value = field.GetValue(instance); if (value is int) { return (int)value; } } PropertyInfo property = type.GetProperty(memberName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property != null && property.CanRead) { object value2 = property.GetValue(instance, null); if (value2 is int) { return (int)value2; } } return -1; } private float ReadFloatMember(object instance, Type type, string memberName) { FieldInfo field = type.GetField(memberName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null && field.FieldType == typeof(float)) { return (float)field.GetValue(instance); } PropertyInfo property = type.GetProperty(memberName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property != null && property.PropertyType == typeof(float) && property.CanRead) { return (float)property.GetValue(instance, null); } return 0f; } private void DestroyObjectiveIcon(Transform bodyTransform = null) { if ((Object)(object)_objectiveIconObject != (Object)null) { Object.Destroy((Object)(object)_objectiveIconObject); _objectiveIconObject = null; } if ((Object)(object)bodyTransform == (Object)null) { return; } Transform[] componentsInChildren = ((Component)bodyTransform).GetComponentsInChildren<Transform>(true); foreach (Transform val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)bodyTransform) && !(((Object)val).name != "PapysLand_Auto_ObjectiveIcon")) { Object.Destroy((Object)(object)((Component)val).gameObject); } } } private Transform FindChildRecursive(Transform parent, string childName) { if ((Object)(object)parent == (Object)null) { return null; } if (((Object)parent).name == childName) { return parent; } for (int i = 0; i < parent.childCount; i++) { Transform val = FindChildRecursive(parent.GetChild(i), childName); if ((Object)(object)val != (Object)null) { return val; } } return null; } private void OnDestroy() { DestroyLanguageChoicePopup(); DestroyObjectiveIcon(); if ((Object)(object)_languageSelectionSprite != (Object)null) { Object.Destroy((Object)(object)_languageSelectionSprite); _languageSelectionSprite = null; } if ((Object)(object)_languageSelectionTexture != (Object)null) { Object.Destroy((Object)(object)_languageSelectionTexture); _languageSelectionTexture = null; } if ((Object)(object)_headerSprite != (Object)null) { Object.Destroy((Object)(object)_headerSprite); _headerSprite = null; } if ((Object)(object)_headerTexture != (Object)null) { Object.Destroy((Object)(object)_headerTexture); _headerTexture = null; } } } }