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 A Really Ethical No Map Mod v0.3.0
TheTrueEthicalMod.dll
Decompiled 2 weeks agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("assembly_guiutils")] [assembly: IgnoresAccessChecksTo("assembly_utils")] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [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 TheTrueEthicalMod { internal static class CompassVisuals { private const string IconResource = "compass_icon.png"; private static Texture2D LoadIcon() { using Stream stream = typeof(CompassVisuals).Assembly.GetManifestResourceStream("compass_icon.png"); if (stream == null) { return null; } using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); Texture2D val = AssetUtils.LoadImage(memoryStream.ToArray()); if ((Object)(object)val != (Object)null) { ((Texture)val).filterMode = (FilterMode)1; } return val; } internal static void Apply(ItemDrop item) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) Texture2D val = LoadIcon(); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)"Compass icon resource not found; keeping the placeholder icon."); return; } SharedData shared = item.m_itemData.m_shared; shared.m_icons = (Sprite[])(object)new Sprite[1] { Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)) }; StripWishbone(shared); ReplaceModel(((Component)item).gameObject, BuildModelTexture(val)); } private static void StripWishbone(SharedData shared) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown shared.m_equipStatusEffect = null; shared.m_setStatusEffect = null; shared.m_consumeStatusEffect = null; shared.m_fullAdrenalineSE = null; shared.m_appendToolTip = null; shared.m_equipEffect = new EffectList(); shared.m_unequipEffect = new EffectList(); shared.m_holdStartEffect = new EffectList(); shared.m_startEffect = new EffectList(); shared.m_triggerEffect = new EffectList(); shared.m_trailStartEffect = new EffectList(); } private static Texture2D BuildModelTexture(Texture2D icon) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown Color val = default(Color); ((Color)(ref val))..ctor(0.72f, 0.5f, 0.1f, 1f); Color[] pixels = icon.GetPixels(); for (int i = 0; i < pixels.Length; i++) { Color val2 = pixels[i]; Color val3 = Color.Lerp(val, new Color(val2.r, val2.g, val2.b, 1f), val2.a); val3.a = 1f; pixels[i] = val3; } Texture2D val4 = new Texture2D(((Texture)icon).width, ((Texture)icon).height, (TextureFormat)4, false) { filterMode = (FilterMode)1 }; val4.SetPixels(pixels); val4.Apply(); return val4; } private static Mesh BuildDisc(float radius, float thickness) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Expected O, but got Unknown //IL_00d0: Unknown result type (might be due to invalid IL or missing references) List<Vector3> list = new List<Vector3>(); List<Vector2> list2 = new List<Vector2>(); List<int> list3 = new List<int>(); float num = thickness / 2f; for (int i = 0; i < 2; i++) { float num2 = ((i == 0) ? num : (0f - num)); int count = list.Count; list.Add(new Vector3(0f, 0f, num2)); list2.Add(new Vector2(0.5f, 0.5f)); for (int j = 0; j <= 32; j++) { float num3 = (float)j * (float)Math.PI * 2f / 32f; float num4 = Mathf.Cos(num3); float num5 = Mathf.Sin(num3); list.Add(new Vector3(num4 * radius, num5 * radius, num2)); list2.Add(new Vector2((i == 0) ? (0.5f + num4 * 0.5f) : (0.5f - num4 * 0.5f), 0.5f + num5 * 0.5f)); } for (int k = 0; k < 32; k++) { if (i == 0) { list3.Add(count); list3.Add(count + k + 2); list3.Add(count + k + 1); } else { list3.Add(count); list3.Add(count + k + 1); list3.Add(count + k + 2); } } } int count2 = list.Count; for (int l = 0; l <= 32; l++) { float num6 = (float)l * (float)Math.PI * 2f / 32f; float num7 = Mathf.Cos(num6) * radius; float num8 = Mathf.Sin(num6) * radius; list.Add(new Vector3(num7, num8, num)); list.Add(new Vector3(num7, num8, 0f - num)); list2.Add(new Vector2(0.5f + Mathf.Cos(num6) * 0.5f, 0.5f + Mathf.Sin(num6) * 0.5f)); list2.Add(new Vector2(0.5f + Mathf.Cos(num6) * 0.5f, 0.5f + Mathf.Sin(num6) * 0.5f)); } for (int m = 0; m < 32; m++) { int num9 = count2 + m * 2; list3.Add(num9); list3.Add(num9 + 2); list3.Add(num9 + 1); list3.Add(num9 + 1); list3.Add(num9 + 2); list3.Add(num9 + 3); } Mesh val = new Mesh { name = "TTEM_CompassDisc" }; val.SetVertices(list); val.SetUVs(0, list2); val.SetTriangles(list3, 0); val.RecalculateNormals(); val.RecalculateBounds(); return val; } private static void ReplaceModel(GameObject prefab, Texture2D texture) { //IL_003d: 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_0052: Unknown result type (might be due to invalid IL or missing references) Mesh sharedMesh = BuildDisc(0.06f, 0.012f); MeshFilter[] componentsInChildren = prefab.GetComponentsInChildren<MeshFilter>(true); foreach (MeshFilter obj in componentsInChildren) { obj.sharedMesh = sharedMesh; Transform transform = ((Component)obj).transform; transform.localPosition = Vector3.zero; transform.localRotation = Quaternion.identity; transform.localScale = Vector3.one; MeshRenderer component = ((Component)obj).GetComponent<MeshRenderer>(); if (!((Object)(object)component == (Object)null)) { Material[] sharedMaterials = ((IEnumerable<Material>)((Renderer)component).sharedMaterials).Select((Func<Material, Material>)((Material m) => new Material(m) { name = "TTEM_CompassMaterial", mainTexture = (Texture)(object)texture, color = Color.white })).ToArray(); ((Renderer)component).sharedMaterials = sharedMaterials; } } SkinnedMeshRenderer[] componentsInChildren2 = prefab.GetComponentsInChildren<SkinnedMeshRenderer>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.Destroy((Object)(object)componentsInChildren2[i]); } Light[] componentsInChildren3 = prefab.GetComponentsInChildren<Light>(true); for (int i = 0; i < componentsInChildren3.Length; i++) { Object.Destroy((Object)(object)componentsInChildren3[i]); } ParticleSystem[] componentsInChildren4 = prefab.GetComponentsInChildren<ParticleSystem>(true); foreach (ParticleSystem val in componentsInChildren4) { Object.Destroy((Object)(((Object)(object)((Component)val).gameObject == (Object)(object)prefab) ? ((object)val) : ((object)((Component)val).gameObject))); } } } internal class DevAutoStart : MonoBehaviour { private const float TimeoutSeconds = 120f; private string _character; private string _world; internal static void Create() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown string[] commandLineArgs = Environment.GetCommandLineArgs(); string arg = GetArg(commandLineArgs, "-ttem-character"); string arg2 = GetArg(commandLineArgs, "-ttem-world"); if (!string.IsNullOrEmpty(arg) && !string.IsNullOrEmpty(arg2)) { GameObject val = new GameObject("TTEM_DevAutoStart"); DevAutoStart devAutoStart = val.AddComponent<DevAutoStart>(); devAutoStart._character = arg; devAutoStart._world = arg2; Object.DontDestroyOnLoad((Object)val); } } private static string GetArg(string[] args, string name) { int num = Array.IndexOf(args, name); if (num < 0 || num + 1 >= args.Length) { return null; } return args[num + 1]; } private IEnumerator Start() { Plugin.Log.LogInfo((object)("Auto-start: character '" + _character + "', world '" + _world + "'.")); float deadline = Time.realtimeSinceStartup + 120f; while ((Object)(object)FejdStartup.m_instance == (Object)null || !FejdStartup.m_instance.m_mainMenu.activeInHierarchy) { if (Time.realtimeSinceStartup > deadline) { Fail("start menu never appeared"); yield break; } yield return null; } FejdStartup menu = FejdStartup.m_instance; if (menu.m_profiles == null) { menu.m_profiles = SaveSystem.GetAllPlayerProfiles(); } PlayerProfile val = ((IEnumerable<PlayerProfile>)menu.m_profiles).FirstOrDefault((Func<PlayerProfile, bool>)((PlayerProfile p) => p.GetName() == _character)); if (val == null) { Fail("character '" + _character + "' not found"); yield break; } menu.SetSelectedProfile(val.GetFilename()); menu.OnCharacterStart(); while (menu.m_worlds == null || !menu.m_worlds.Any((World w) => w.m_name == _world)) { if (Time.realtimeSinceStartup > deadline) { Fail("world '" + _world + "' not found"); yield break; } yield return null; } menu.SetSelectedWorld(menu.m_worlds.FindIndex((World w) => w.m_name == _world), true); menu.OnWorldStart(); Object.Destroy((Object)(object)((Component)this).gameObject); } private void Fail(string reason) { Plugin.Log.LogWarning((object)("Auto-start aborted: " + reason + ".")); Object.Destroy((Object)(object)((Component)this).gameObject); } } internal class NavigationHud : MonoBehaviour { private Texture2D _dialTexture; private Texture2D _needleTexture; private GUIStyle _markStyle; private const int TextureSize = 256; private static Texture2D BuildDial() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(256, 256, (TextureFormat)5, false) { filterMode = (FilterMode)1 }; float num = 127.5f; Color clear = default(Color); for (int i = 0; i < 256; i++) { for (int j = 0; j < 256; j++) { float num2 = Mathf.Sqrt(((float)j - num) * ((float)j - num) + ((float)i - num) * ((float)i - num)); if (num2 > num) { clear = Color.clear; } else if (num2 > num - 8f) { ((Color)(ref clear))..ctor(0.25f, 0.25f, 0.27f, 1f); } else { ((Color)(ref clear))..ctor(0.78f, 0.78f, 0.8f, 0.92f); } val.SetPixel(j, i, clear); } } val.Apply(); return val; } private static Texture2D BuildNeedle() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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) Texture2D val = new Texture2D(256, 256, (TextureFormat)5, false) { filterMode = (FilterMode)1 }; float num = 127.5f; float num2 = num * 0.72f; float num3 = num * 0.13f; for (int i = 0; i < 256; i++) { for (int j = 0; j < 256; j++) { float num4 = Mathf.Abs((float)j - num); float num5 = (float)i - num; Color val2 = Color.clear; if (Mathf.Abs(num5) <= num2 && num4 <= num3 * (1f - Mathf.Abs(num5) / num2)) { val2 = ((num5 > 0f) ? new Color(0.85f, 0.1f, 0.1f, 1f) : new Color(0.3f, 0.3f, 0.32f, 1f)); } val.SetPixel(j, i, val2); } } val.Apply(); return val; } private void DrawDial(float yaw) { //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0123: 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_0131: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_dialTexture == (Object)null) { _dialTexture = BuildDial(); } if ((Object)(object)_needleTexture == (Object)null) { _needleTexture = BuildNeedle(); } if (_markStyle == null) { _markStyle = new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)4, fontStyle = (FontStyle)1 }; _markStyle.normal.textColor = new Color(0.15f, 0.15f, 0.17f); } float num = Plugin.DialSize.Value; float num2 = Mathf.Clamp((float)Screen.width * Plugin.PositionX.Value / 100f - num / 2f, 0f, Mathf.Max(0f, (float)Screen.width - num)); float num3 = Mathf.Clamp((float)Screen.height * Plugin.PositionY.Value / 100f - num / 2f, 0f, Mathf.Max(0f, (float)Screen.height - num)); Rect val = default(Rect); ((Rect)(ref val))..ctor(num2, num3, num, num); Matrix4x4 matrix = GUI.matrix; Color color = GUI.color; GUI.color = new Color(color.r, color.g, color.b, color.a * (float)Plugin.Opacity.Value / 100f); if (Plugin.RotatingDial.Value) { GUIUtility.RotateAroundPivot(0f - yaw, ((Rect)(ref val)).center); } GUI.DrawTexture(val, (Texture)(object)_dialTexture); if (Plugin.Markings.Value != Plugin.DialMarkings.None) { _markStyle.fontSize = Mathf.Max(10, Mathf.RoundToInt(num * 0.16f)); float num4 = num * 0.2f; GUI.Label(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y + num * 0.05f, num, num4), "N", _markStyle); if (Plugin.Markings.Value == Plugin.DialMarkings.Cardinals) { GUI.Label(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).yMax - num * 0.05f - num4, num, num4), "S", _markStyle); GUI.Label(new Rect(((Rect)(ref val)).x + num * 0.05f, ((Rect)(ref val)).y + (num - num4) / 2f, num4, num4), "W", _markStyle); GUI.Label(new Rect(((Rect)(ref val)).xMax - num * 0.05f - num4, ((Rect)(ref val)).y + (num - num4) / 2f, num4, num4), "E", _markStyle); } } GUI.matrix = matrix; if (!Plugin.RotatingDial.Value) { GUIUtility.RotateAroundPivot(0f - yaw, ((Rect)(ref val)).center); } GUI.DrawTexture(val, (Texture)(object)_needleTexture); GUI.matrix = matrix; GUI.color = color; } private static bool HasCompass(Player player, bool requireEquipped) { return ((Humanoid)player).GetInventory().GetAllItems().Any((ItemData i) => (Object)(object)i.m_dropPrefab != (Object)null && ((Object)i.m_dropPrefab).name == "TTEM_Compass" && (!requireEquipped || i.m_equipped)); } private void OnGUI() { //IL_0064: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if (Plugin.ShowHud.Value && !((Object)(object)localPlayer == (Object)null) && !((Object)(object)Hud.instance == (Object)null) && Hud.instance.m_rootObject.activeSelf && HasCompass(localPlayer, Plugin.RequireItems.Value) && (Object)(object)GameCamera.instance != (Object)null) { DrawDial(((Component)GameCamera.instance).transform.eulerAngles.y); } } } [BepInPlugin("com.thetrueethicalmod", "A Really Ethical No Map Mod", "0.3.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { internal enum DialMarkings { None, NorthMark, Cardinals } public const string PluginGuid = "com.thetrueethicalmod"; public const string PluginName = "A Really Ethical No Map Mod"; public const string PluginVersion = "0.3.0"; internal const string CompassPrefab = "TTEM_Compass"; internal static ConfigEntry<bool> ShowHud; internal static ConfigEntry<bool> RequireItems; internal static ConfigEntry<DialMarkings> Markings; internal static ConfigEntry<int> DialSize; internal static ConfigEntry<int> Opacity; internal static ConfigEntry<float> PositionX; internal static ConfigEntry<float> PositionY; internal static ConfigEntry<bool> RotatingDial; internal static ManualLogSource Log; private void Awake() { //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Expected O, but got Unknown //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Expected O, but got Unknown //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Expected O, but got Unknown //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Expected O, but got Unknown //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; ShowHud = ((BaseUnityPlugin)this).Config.Bind<bool>("HUD", "Enabled", true, "Show the compass heading HUD."); RequireItems = ((BaseUnityPlugin)this).Config.Bind<bool>("HUD", "RequireItems", true, "If true, show the HUD only while the compass is equipped; if false, show it while the compass is in your inventory."); Markings = ((BaseUnityPlugin)this).Config.Bind<DialMarkings>("HUD", "DialMarkings", DialMarkings.NorthMark, "Markings on the graphical compass dial: None, NorthMark (N only) or Cardinals (N, E, S, W)."); DialSize = ((BaseUnityPlugin)this).Config.Bind<int>("HUD", "DialSize", 96, new ConfigDescription("Size in pixels of the graphical compass dial.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(48, 256), Array.Empty<object>())); Opacity = ((BaseUnityPlugin)this).Config.Bind<int>("HUD", "Opacity", 85, new ConfigDescription("Opacity of the compass in percent (100 = fully visible, 0 = invisible).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); PositionX = ((BaseUnityPlugin)this).Config.Bind<float>("HUD", "PositionX", 50f, new ConfigDescription("Horizontal position of the compass center, as a percentage of the screen width (0 = left, 100 = right).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>())); PositionY = ((BaseUnityPlugin)this).Config.Bind<float>("HUD", "PositionY", 5.4f, new ConfigDescription("Vertical position of the compass center, as a percentage of the screen height (0 = top, 100 = bottom).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>())); RotatingDial = ((BaseUnityPlugin)this).Config.Bind<bool>("HUD", "RotatingDial", false, "If true, the needle stays fixed pointing up and the dial rotates; if false, the dial is fixed and the needle rotates to point north."); new Harmony("com.thetrueethicalmod").PatchAll(); AddLocalization(); PrefabManager.OnVanillaPrefabsAvailable += AddContent; GameObject val = new GameObject("TTEM_Hud"); val.AddComponent<NavigationHud>(); Object.DontDestroyOnLoad((Object)val); DevAutoStart.Create(); } private static void AddLocalization() { CustomLocalization localization = LocalizationManager.Instance.GetLocalization(); Dictionary<string, string> dictionary = new Dictionary<string, string> { { "ttem_vendor_haldor", "Haldor" }, { "ttem_vendor_bogwitch", "Bog Witch" }, { "ttem_vendor_hildir", "Hildir" }, { "ttem_vendor_forge", "the Forge of Potential" }, { "ttem_vendor_notfound", "The mead shows nothing." }, { "item_ttem_compass", "Compass" }, { "item_ttem_compass_desc", "A one-handed compass that shows which way you are facing while equipped." } }; VendorLocator.Vendor[] vendors = VendorLocator.Vendors; foreach (VendorLocator.Vendor vendor in vendors) { string text = "item_ttem_meadbase_" + vendor.Id.ToLowerInvariant(); string text2 = "item_ttem_locator_" + vendor.Id.ToLowerInvariant(); dictionary[text] = "Mead base of " + VendorName(vendor); dictionary[text + "_desc"] = "Ferment it to obtain 3 meads.\n\nFermented mead: drink it to turn your gaze toward " + VendorName(vendor) + "."; dictionary[text2] = "Mead of " + VendorName(vendor); dictionary[text2 + "_desc"] = "Drink to turn your gaze toward " + VendorName(vendor) + "."; } string text3 = "English"; localization.AddTranslation(ref text3, dictionary); } private static string VendorName(VendorLocator.Vendor v) { if (!(v.Id == "BogWitch")) { if (!(v.Id == "Forge")) { return v.Id; } return "the Forge of Potential"; } return "the Bog Witch"; } private static RequirementConfig[] BuildRequirements(VendorLocator.Vendor v) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown List<RequirementConfig> list = new List<RequirementConfig> { new RequirementConfig(v.Trophy, 3, 0, true) }; (string, int)[] extras = v.Extras; for (int i = 0; i < extras.Length; i++) { (string, int) tuple = extras[i]; list.Add(new RequirementConfig(tuple.Item1, tuple.Item2, 0, true)); } return list.ToArray(); } private static void AddVendorItems() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Expected O, but got Unknown //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Expected O, but got Unknown //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0199: 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_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Expected O, but got Unknown //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Expected O, but got Unknown VendorLocator.Vendor[] vendors = VendorLocator.Vendors; foreach (VendorLocator.Vendor vendor in vendors) { string text = vendor.Id.ToLowerInvariant(); CustomItem val = new CustomItem(VendorLocator.BasePrefab(vendor), "MeadBaseTasty", new ItemConfig { Name = "$item_ttem_meadbase_" + text, Description = "$item_ttem_meadbase_" + text + "_desc", CraftingStation = "piece_MeadCauldron", Amount = 1, Requirements = BuildRequirements(vendor) }); SharedData shared = val.ItemDrop.m_itemData.m_shared; shared.m_consumeStatusEffect = null; shared.m_food = 0f; shared.m_foodStamina = 0f; shared.m_foodEitr = 0f; ItemManager.Instance.AddItem(val); CustomItem val2 = new CustomItem(VendorLocator.LocatorPrefab(vendor), "MeadTasty", new ItemConfig { Name = "$item_ttem_locator_" + text, Description = "$item_ttem_locator_" + text + "_desc", Enabled = false }); SharedData shared2 = val2.ItemDrop.m_itemData.m_shared; shared2.m_consumeStatusEffect = null; Sprite val3 = VendorLocator.LoadIcon(vendor); if ((Object)(object)val3 != (Object)null) { shared2.m_icons = (Sprite[])(object)new Sprite[1] { val3 }; } else { Log.LogWarning((object)("Icon missing for " + vendor.Id)); } shared2.m_food = 0f; shared2.m_foodStamina = 0f; shared2.m_foodEitr = 0f; ItemManager.Instance.AddItem(val2); ItemManager.Instance.AddItemConversion(new CustomItemConversion((ConversionConfig)new FermenterConversionConfig { FromItem = VendorLocator.BasePrefab(vendor), ToItem = VendorLocator.LocatorPrefab(vendor), ProducedItems = 3 })); } } private static void AddContent() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown //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_00d3: Expected O, but got Unknown //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) PrefabManager.OnVanillaPrefabsAvailable -= AddContent; AddVendorItems(); ItemConfig val = new ItemConfig(); val.Name = "$item_ttem_compass"; val.Description = "$item_ttem_compass_desc"; val.CraftingStation = CraftingStations.Workbench; val.Requirements = (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("FineWood", 2, 0, true), new RequirementConfig("Copper", 2, 0, true) }; CustomItem val2 = new CustomItem("TTEM_Compass", "Wishbone", val); SharedData shared = val2.ItemDrop.m_itemData.m_shared; shared.m_itemType = (ItemType)3; shared.m_attachOverride = (ItemType)3; shared.m_attack = new Attack { m_attackStamina = 0f }; shared.m_secondaryAttack = new Attack { m_attackStamina = 0f }; shared.m_animationState = (AnimationState)1; shared.m_damages = default(DamageTypes); shared.m_damagesPerLevel = default(DamageTypes); shared.m_attackForce = 0f; shared.m_backstabBonus = 0f; shared.m_attackStaminaModifier = 0f; shared.m_blockStaminaModifier = 0f; shared.m_blockPower = 0f; shared.m_blockPowerPerLevel = 0f; shared.m_deflectionForce = 0f; shared.m_deflectionForcePerLevel = 0f; shared.m_timedBlockBonus = 0f; shared.m_perfectBlockStaminaRegen = 0f; shared.m_perfectBlockStatusEffect = null; shared.m_blockAdrenaline = 0f; shared.m_perfectBlockAdrenaline = 0f; shared.m_maxAdrenaline = 0f; shared.m_maxBlockCharges = 0; shared.m_buildBlockCharges = false; shared.m_useDurability = false; CompassVisuals.Apply(val2.ItemDrop); ItemManager.Instance.AddItem(val2); } } internal static class VendorLocator { internal class Vendor { public string Id; public string Location; public string DisplayKey; public string Trophy; public (string Prefab, int Amount)[] Extras; } internal static readonly Vendor[] Vendors = new Vendor[4] { new Vendor { Id = "Haldor", Location = "Vendor_BlackForest", DisplayKey = "$ttem_vendor_haldor", Trophy = "TrophyGreydwarf", Extras = new(string, int)[3] { ("Carrot", 30), ("Thistle", 30), ("Blueberries", 30) } }, new Vendor { Id = "BogWitch", Location = "BogWitch_Camp", DisplayKey = "$ttem_vendor_bogwitch", Trophy = "TrophyDraugr", Extras = new(string, int)[3] { ("Turnip", 30), ("Thistle", 30), ("Guck", 30) } }, new Vendor { Id = "Hildir", Location = "Hildir_camp", DisplayKey = "$ttem_vendor_hildir", Trophy = "TrophyGoblin", Extras = new(string, int)[3] { ("Onion", 30), ("Thistle", 30), ("Cloudberry", 30) } }, new Vendor { Id = "Forge", Location = "AncientUpgradeStation", DisplayKey = "$ttem_vendor_forge", Trophy = "TrophyWolf", Extras = new(string, int)[3] { ("DragonEgg", 1), ("Crystal", 30), ("Thistle", 30) } } }; internal static Sprite LoadIcon(Vendor v) { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) using Stream stream = typeof(VendorLocator).Assembly.GetManifestResourceStream("locator_" + v.Id.ToLowerInvariant() + ".png"); if (stream == null) { return null; } using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); Texture2D val = AssetUtils.LoadImage(memoryStream.ToArray()); if ((Object)(object)val == (Object)null) { return null; } ((Texture)val).filterMode = (FilterMode)1; return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)); } internal static string BasePrefab(Vendor v) { return "TTEM_MeadBase_" + v.Id; } internal static string LocatorPrefab(Vendor v) { return "TTEM_Locator_" + v.Id; } internal static Vendor FromPrefab(string name) { Vendor[] vendors = Vendors; foreach (Vendor vendor in vendors) { if (LocatorPrefab(vendor) == name) { return vendor; } } return null; } private static bool TryFind(Vendor v, Vector3 from, out Vector3 pos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) pos = default(Vector3); ZoneSystem instance = ZoneSystem.instance; if ((Object)(object)instance == (Object)null) { return false; } bool result = false; bool flag = false; float num = float.MaxValue; foreach (LocationInstance value in instance.m_locationInstances.Values) { if (!(value.m_location.m_prefab.Name != v.Location)) { float num2 = Vector3.Distance(value.m_position, from); if ((value.m_placed && !flag) || (value.m_placed == flag && num2 < num)) { num = num2; pos = value.m_position; result = true; flag = value.m_placed; } } } return result; } internal static bool Locate(Player player, Vendor v) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)player).transform.position; if (TryFind(v, position, out var pos)) { ((Character)player).SetLookDir(pos - position, 3.5f); return true; } if ((Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.m_locationInstances.Count == 0 && (Object)(object)ZNet.instance != (Object)null && !ZNet.instance.IsServer()) { Game.instance.DiscoverClosestLocation(v.Location, position, "", 3, false, false); return true; } Plugin.Log.LogWarning((object)("No location named " + v.Location + " found.")); return false; } } [HarmonyPatch(typeof(Player), "ConsumeItem")] internal static class ConsumeLocatorPatch { private static bool Prefix(Player __instance, Inventory inventory, ItemData item, ref bool __result) { VendorLocator.Vendor vendor = VendorLocator.FromPrefab(((Object)(object)item?.m_dropPrefab != (Object)null) ? ((Object)item.m_dropPrefab).name : null); if (vendor == null) { return true; } __result = false; if (!VendorLocator.Locate(__instance, vendor)) { ((Character)__instance).Message((MessageType)2, "$ttem_vendor_notfound", 0, (Sprite)null, false); return false; } inventory.RemoveOneItem(item); __result = true; return false; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }