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 Mapless v0.0.5
BepInEx/plugins/mapless.dll
Decompiled 2 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")] [assembly: AssemblyCompany("adamnew123456")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Adds tools useful for nomap runs")] [assembly: AssemblyFileVersion("0.0.3.0")] [assembly: AssemblyInformationalVersion("0.0.3+4a2aa609762f3c0146e51321ababfd1ca3f56f49")] [assembly: AssemblyProduct("mapless")] [assembly: AssemblyTitle("mapless")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.3.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 mapless { public class CompassStatusEffect : StatusEffect { private const string ItemName = "kb_Compass"; private const string ItemLabel = "Compass"; private const string ItemShortDesc = "Equip this to know which way you are facing."; private const string SpriteName = "Assets/Sprites/compass.png"; private const string PrefabName = "Assets/Prefabs/compass.prefab"; private Player _player; public static void InitializeItem(AssetBundle assets) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Expected O, but got Unknown //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Expected O, but got Unknown Sprite val = Plugin.LoadSprite(assets, "Assets/Sprites/compass.png"); CompassStatusEffect compassStatusEffect = ScriptableObject.CreateInstance<CompassStatusEffect>(); ((StatusEffect)compassStatusEffect).m_icon = val; CustomStatusEffect val2 = new CustomStatusEffect((StatusEffect)(object)compassStatusEffect, false); ItemManager.Instance.AddStatusEffect(val2); GameObject val3 = Plugin.BuildUtilityItem(assets, "Assets/Prefabs/compass.prefab", "kb_Compass", "Equip this to know which way you are facing."); val3.GetComponent<ItemDrop>().m_itemData.m_shared.m_equipStatusEffect = val2.StatusEffect; ItemConfig val4 = new ItemConfig(); val4.Name = "Compass"; val4.Description = "The Deep North was once a green and verdant land, before the frost came. The greydwarves remember."; val4.CraftingStation = CraftingStations.Workbench; val4.MinStationLevel = 3; val4.Icons = (Sprite[])(object)new Sprite[1] { val }; ItemConfig val5 = val4; val5.AddRequirement(new RequirementConfig("GreydwarfEye", 2, 0, true)); val5.AddRequirement(new RequirementConfig("Flint", 2, 0, true)); val5.AddRequirement(new RequirementConfig("ArrowWood", 1, 0, true)); CustomItem val6 = new CustomItem(val3, false, val5); ItemManager.Instance.AddItem(val6); Plugin.ClearKeyHints("kb_Compass"); } public CompassStatusEffect() { //IL_0029: 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) ((Object)this).name = "Compass"; base.m_tooltip = "Equip this to know which way you are facing."; base.m_startMessage = "The compass needle quivers."; base.m_startMessageType = (MessageType)2; base.m_stopMessage = "You put the compass away."; base.m_stopMessageType = (MessageType)2; } public override string GetIconText() { return "Compass"; } public override bool CanAdd(Character character) { if ((Object)(object)character == (Object)(object)Player.m_localPlayer) { return ((StatusEffect)this).CanAdd(character); } return false; } public override void Setup(Character character) { _player = Player.m_localPlayer; Plugin.MeasureLabel.SetActive(true); ((StatusEffect)this).Setup(character); } public override void Stop() { if (!Plugin.IsNewMeasureLabel) { Plugin.MeasureLabel.SetActive(false); } _player = null; ((StatusEffect)this).Stop(); } public override void UpdateStatusEffect(float dt) { if (Plugin.IsNewMeasureLabel) { Plugin.MeasureLabel.SetActive(true); Plugin.IsNewMeasureLabel = false; } double num = Math.Atan2(((Character)_player).m_lookDir.x, ((Character)_player).m_lookDir.z); if (num < 0.0) { num += Math.PI * 2.0; } Plugin.MeasureLabel.GetComponent<Text>().text = $"{(int)(num / (Math.PI * 2.0) * 360.0)}°"; ((StatusEffect)this).UpdateStatusEffect(dt); } } public class Debug { public static void DumpComponents(string filename, GameObject obj) { using StreamWriter streamWriter = File.CreateText(filename); for (int i = 0; i < obj.GetComponentCount(); i++) { Component componentAtIndex = obj.GetComponentAtIndex(i); streamWriter.WriteLine("Component: {0} ({1})", ((Object)componentAtIndex).name, ((object)componentAtIndex).GetType()); } streamWriter.Flush(); } } public class StaminaInfoCommand : ConsoleCommand { public override string Name => "dbg_StaminaInfo"; public override string Help => "Shows player stamina information"; public override bool IsCheat => false; public override bool IsNetwork => false; public override bool OnlyServer => false; public override bool IsSecret => false; public override void Run(string[] args) { ((ConsoleCommand)this).Run(args, (Terminal)(object)Chat.instance); } public override void Run(string[] args, Terminal context) { Player localPlayer = Player.m_localPlayer; context.AddString($"Current stamina: {localPlayer.GetStamina()}"); context.AddString($"Max stamina: {((Character)localPlayer).GetMaxStamina()}"); if (args.Length != 0 && float.TryParse(args[0], out var result)) { localPlayer.SetMaxStamina(result, true); } if (args.Length > 1 && float.TryParse(args[1], out var result2)) { localPlayer.m_stamina = result2; } context.AddString($"New max stamina: {((Character)localPlayer).GetMaxStamina()}"); context.AddString($"New stamina: {localPlayer.GetStamina()}"); } public override List<string> CommandOptionList() { return new List<string>(); } } public class ForgetMapFireBehavior : MonoBehaviour, Interactable, Hoverable { private const string ItemName = "kb_ForgetMapFire"; private const string ItemLabel = "Gentle Brazier"; private const string SpriteName = "Assets/Sprites/brazier.png"; private const string PrefabName = "fire_pit_iron"; public static void InitializePiece(AssetBundle assets) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown PieceConfig val = new PieceConfig { Name = "Gentle Brazier", Description = "Produces an herbal vapor that takes your troubles away.", Icon = Plugin.LoadSprite(assets, "Assets/Sprites/brazier.png"), PieceTable = PieceTables.Hammer, Category = PieceCategories.Misc, AllowedInDungeons = false, CraftingStation = CraftingStations.Workbench }; val.AddRequirement("SurtlingCore", 1, true); val.AddRequirement("FineWood", 5, true); CustomPiece val2 = new CustomPiece("kb_ForgetMapFire", "fire_pit_iron", val); val2.Piece.m_comfort = 0; val2.Piece.m_noInWater = true; Object.Destroy((Object)(object)val2.PiecePrefab.GetComponent<Fireplace>()); val2.PiecePrefab.AddComponent<ForgetMapFireBehavior>(); PieceManager.Instance.AddPiece(val2); } public bool Interact(Humanoid user, bool hold, bool alt) { if (hold) { return false; } ((Character)user).Message((MessageType)2, "Gazing into the brazier, you forget the world outside...", 0, (Sprite)null); Minimap instance = Minimap.instance; instance.Reset(); instance.ResetSharedMapData(); for (int i = 0; i < instance.m_visibleIconTypes.Length; i++) { if (instance.m_visibleIconTypes[i]) { instance.ToggleIconFilter((PinType)i); } } return true; } public bool UseItem(Humanoid user, ItemData item) { return false; } public string GetHoverText() { return Localization.instance.Localize("[<color=yellow><b>$KEY_Use</b></color>] Inhale"); } public string GetHoverName() { return "Gentle Brazier"; } } [BepInPlugin("com.kidneybone.mapless", "Mapless", "0.0.5")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public static string ModBasePath; public const double TwoPi = Math.PI * 2.0; public static GameObject MeasureLabel; public static bool IsNewMeasureLabel; private void Awake() { ModBasePath = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); PrefabManager.OnVanillaPrefabsAvailable += AddNewItems; GUIManager.OnCustomGUIAvailable += RebindLabel; } private static void AddNewItems() { AssetBundle assets = AssetUtils.LoadAssetBundle(Path.Combine(ModBasePath, "bundle")); CompassStatusEffect.InitializeItem(assets); WalkingRollerStatusEffect.InitializeItem(assets); ForgetMapFireBehavior.InitializePiece(assets); PrefabManager.OnVanillaPrefabsAvailable -= AddNewItems; } private static void RebindLabel() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) if (GUIManager.IsHeadless() || GUIManager.Instance == null || (Object)(object)GUIManager.CustomGUIBack == (Object)null) { MeasureLabel = null; return; } MeasureLabel = GUIManager.Instance.CreateText("", GUIManager.CustomGUIBack.transform, new Vector2(0.51f, 0.45f), new Vector2(0.51f, 0.45f), new Vector2(0f, 0f), GUIManager.Instance.AveriaSerif, 24, GUIManager.Instance.ValheimOrange, true, Color.black, 0f, 0f, true); MeasureLabel.SetActive(false); IsNewMeasureLabel = true; } public static Sprite LoadSprite(AssetBundle assets, string name) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) Texture2D val = assets.LoadAsset<Texture2D>(name); return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), Vector2.zero); } public static GameObject BuildUtilityItem(AssetBundle assets, string prefabName, string itemName, string itemDescription) { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: 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_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Expected O, but got Unknown //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Expected O, but got Unknown //IL_0155: Expected O, but got Unknown GameObject obj = assets.LoadAsset<GameObject>(prefabName); ((Object)obj).name = itemName; Rigidbody obj2 = obj.AddComponent<Rigidbody>(); obj2.mass = 1f; obj2.linearDamping = 0f; obj2.angularDamping = 0.05f; obj2.automaticCenterOfMass = true; obj2.automaticInertiaTensor = true; obj2.useGravity = true; obj2.interpolation = (RigidbodyInterpolation)0; obj2.collisionDetectionMode = (CollisionDetectionMode)1; obj.AddComponent<ZSyncTransform>(); obj.AddComponent<ZNetView>().m_persistent = true; obj.AddComponent<ItemDrop>().m_itemData.m_shared = new SharedData { m_name = itemName, m_itemType = (ItemType)3, m_description = itemDescription, m_blockPower = 1f, m_timedBlockBonus = 0f, m_canBeReparied = false, m_useDurability = false, m_attackForce = 0f, m_backstabBonus = 0f, m_equipDuration = 0.5f, m_blockAdrenaline = 0f, m_perfectBlockAdrenaline = 0f, m_attack = new Attack { m_attackType = (AttackType)3, m_attackAnimation = "unarmed_attack", m_attackStamina = 0f, m_attackAdrenaline = 0f }, m_secondaryAttack = new Attack { m_attackType = (AttackType)3, m_attackAnimation = "unarmed_kick", m_attackStamina = 0f, m_attackAdrenaline = 0f } }; return obj; } public static void ClearKeyHints(string itemName) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown KeyHintConfig val = new KeyHintConfig { Item = itemName, ButtonConfigs = Array.Empty<ButtonConfig>() }; KeyHintManager.Instance.AddKeyHint(val); } } public class WalkingRollerStatusEffect : StatusEffect { private const string ItemName = "kb_WalkingRoller"; private const string ItemLabel = "Walking Roller"; private const string ItemShortDesc = "Measures your steps as you walk."; private const string SpriteName = "Assets/Sprites/roller.png"; private const string PrefabName = "Assets/Prefabs/roller.prefab"; private Player _player; private Vector2 _startPos; public static void InitializeItem(AssetBundle assets) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Expected O, but got Unknown //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Expected O, but got Unknown Sprite val = Plugin.LoadSprite(assets, "Assets/Sprites/roller.png"); WalkingRollerStatusEffect walkingRollerStatusEffect = ScriptableObject.CreateInstance<WalkingRollerStatusEffect>(); ((StatusEffect)walkingRollerStatusEffect).m_icon = val; CustomStatusEffect val2 = new CustomStatusEffect((StatusEffect)(object)walkingRollerStatusEffect, false); ItemManager.Instance.AddStatusEffect(val2); GameObject val3 = Plugin.BuildUtilityItem(assets, "Assets/Prefabs/roller.prefab", "kb_WalkingRoller", "Measures your steps as you walk."); val3.GetComponent<ItemDrop>().m_itemData.m_shared.m_equipStatusEffect = val2.StatusEffect; ItemConfig val4 = new ItemConfig(); val4.Name = "Walking Roller"; val4.Description = "Click. Click. Click. The sound is mesmerizing, you could do this all day!"; val4.CraftingStation = CraftingStations.Workbench; val4.MinStationLevel = 3; val4.Icons = (Sprite[])(object)new Sprite[1] { val }; ItemConfig val5 = val4; val5.AddRequirement(new RequirementConfig("FineWood", 5, 0, true)); val5.AddRequirement(new RequirementConfig("Flint", 1, 0, true)); val5.AddRequirement(new RequirementConfig("NeckTail", 1, 0, true)); CustomItem val6 = new CustomItem(val3, false, val5); ItemManager.Instance.AddItem(val6); Plugin.ClearKeyHints("kb_WalkingRoller"); } public WalkingRollerStatusEffect() { //IL_0029: 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) ((Object)this).name = "Walking Roller"; base.m_tooltip = "Measures your steps as you walk."; base.m_startMessage = "The roller clicks."; base.m_startMessageType = (MessageType)2; base.m_stopMessage = "You put the roller away."; base.m_stopMessageType = (MessageType)2; } public override string GetIconText() { return "Walking Roller"; } public override bool CanAdd(Character character) { if ((Object)(object)character == (Object)(object)Player.m_localPlayer) { return ((StatusEffect)this).CanAdd(character); } return false; } public override void Setup(Character character) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) _player = Player.m_localPlayer; Plugin.MeasureLabel.SetActive(true); _startPos = Player2DPos(); ((StatusEffect)this).Setup(character); } public override void Stop() { if (!Plugin.IsNewMeasureLabel) { Plugin.MeasureLabel.SetActive(false); } _player = null; ((StatusEffect)this).Stop(); } public override void UpdateStatusEffect(float dt) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) if (Plugin.IsNewMeasureLabel) { Plugin.MeasureLabel.SetActive(true); Plugin.IsNewMeasureLabel = false; } Vector2 val = Player2DPos(); float num = 0.6f * Vector2.Distance(_startPos, val); Plugin.MeasureLabel.GetComponent<Text>().text = $"{(int)num} paces"; ((StatusEffect)this).UpdateStatusEffect(dt); } private Vector2 Player2DPos() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) return new Vector2(((Component)_player).transform.position.x, ((Component)_player).transform.position.z); } } public static class PluginInfo { public const string PLUGIN_GUID = "mapless"; public const string PLUGIN_NAME = "mapless"; public const string PLUGIN_VERSION = "0.0.3"; } }