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 PoV Marketplace Link v1.1.0
plugins/PoVMarketplaceLink.dll
Decompiled 4 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Microsoft.CodeAnalysis; using UnityEngine; using Valheiman.Api; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("PoVMarketplaceLink")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.1.0.0")] [assembly: AssemblyInformationalVersion("1.1.0")] [assembly: AssemblyProduct("PoVMarketplaceLink")] [assembly: AssemblyTitle("PoVMarketplaceLink")] [assembly: AssemblyVersion("1.1.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; } } } [AttributeUsage(AttributeTargets.All, Inherited = false)] internal sealed class PublicAPIAttribute : Attribute { } [PublicAPI] public static class Marketplace_API { [Flags] public enum TerritoryFlags { None = 0, PushAway = 1, NoBuild = 2, NoPickaxe = 4, NoInteract = 8, NoAttack = 0x10, PvpOnly = 0x20, PveOnly = 0x40, PeriodicHeal = 0x80, PeriodicDamage = 0x100, IncreasedPlayerDamage = 0x200, IncreasedMonsterDamage = 0x400, NoMonsters = 0x800, CustomEnvironment = 0x1000, MoveSpeedMultiplier = 0x2000, NoDeathPenalty = 0x4000, NoPortals = 0x8000, PeriodicHealALL = 0x10000, ForceGroundHeight = 0x20000, ForceBiome = 0x40000, AddGroundHeight = 0x80000, NoBuildDamage = 0x100000, MonstersAddStars = 0x200000, InfiniteFuel = 0x400000, NoInteractItems = 0x800000, NoInteractCraftingStation = 0x1000000, NoInteractItemStands = 0x2000000, NoInteractChests = 0x4000000, NoInteractDoors = 0x8000000, NoStructureSupport = 0x10000000, NoInteractPortals = 0x20000000, CustomPaint = 0x40000000, LimitZoneHeight = int.MinValue } [Flags] public enum AdditionalTerritoryFlags { None = 0, NoItemLoss = 1, SnowMask = 2, NoMist = 4, InfiniteEitr = 8, InfiniteStamina = 0x10, DropMultiplier = 0x20, ForceWind = 0x40, GodMode = 0x80, OnlyForGuild = 0x100, CustomJereSpawner = 0x200, JoinOtherServer = 0x400, RevealOnMap = 0x800, OnlyForFaction = 0x1000, ZoneMusic = 0x2000 } public enum API_NPCType { None, Trader, Info, Teleporter, Feedback, Banker, Gambler, Quests, Buffer, Transmog, Marketplace, Mail } private static readonly bool _IsInstalled; private static readonly MethodInfo MI_IsPlayerInsideTerritory; private static readonly MethodInfo MI_IsObjectInsideTerritoryWithFlag; private static readonly MethodInfo MI_IsObjectInsideTerritoryWithFlag_Additional; private static readonly MethodInfo MI_ResetTraderItems; private static readonly MethodInfo MI_OpenQuestJournal; private static readonly MethodInfo MI_RegisterQuestReward; private static readonly MethodInfo MI_RegisterDialogueCondition; private static readonly MethodInfo MI_RegisterDialogueCommand; private static readonly MethodInfo MI_RegisterGroupHandler; private static readonly MethodInfo MI_RegisterGroupChatCommand; private static readonly MethodInfo MI_RegisterGuildHandler; public static bool IsInstalled() { return _IsInstalled; } public static bool IsPlayerInsideTerritory(out string name, out TerritoryFlags flags, out AdditionalTerritoryFlags additionalFlags) { flags = TerritoryFlags.None; additionalFlags = AdditionalTerritoryFlags.None; name = ""; if (!_IsInstalled || MI_IsPlayerInsideTerritory == null) { return false; } object[] array = new object[3] { "", 0, 0 }; bool result = (bool)MI_IsPlayerInsideTerritory.Invoke(null, array); name = (string)array[0]; flags = (TerritoryFlags)array[1]; additionalFlags = (AdditionalTerritoryFlags)array[2]; return result; } public static bool IsObjectInsideTerritoryWithFlag(GameObject go, TerritoryFlags flag, out string name, out TerritoryFlags flags, out AdditionalTerritoryFlags additionalFlags) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return IsPointInsideTerritoryWithFlag(go.transform.position, flag, out name, out flags, out additionalFlags); } public static bool IsObjectInsideTerritoryWithFlag(GameObject go, AdditionalTerritoryFlags flag, out string name, out TerritoryFlags flags, out AdditionalTerritoryFlags additionalFlags) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return IsPointInsideTerritoryWithFlag(go.transform.position, flag, out name, out flags, out additionalFlags); } public static bool IsPointInsideTerritoryWithFlag(Vector3 pos, TerritoryFlags flag, out string name, out TerritoryFlags flags, out AdditionalTerritoryFlags additionalFlags) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) name = ""; flags = TerritoryFlags.None; additionalFlags = AdditionalTerritoryFlags.None; if (!_IsInstalled || MI_IsObjectInsideTerritoryWithFlag == null) { return false; } object[] array = new object[5] { pos, (int)flag, "", 0, 0 }; bool result = (bool)MI_IsObjectInsideTerritoryWithFlag.Invoke(null, array); name = (string)array[2]; flags = (TerritoryFlags)array[3]; additionalFlags = (AdditionalTerritoryFlags)array[4]; return result; } public static bool IsPointInsideTerritoryWithFlag(Vector3 pos, AdditionalTerritoryFlags flag, out string name, out TerritoryFlags flags, out AdditionalTerritoryFlags additionalFlags) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) name = ""; flags = TerritoryFlags.None; additionalFlags = AdditionalTerritoryFlags.None; if (!_IsInstalled || MI_IsObjectInsideTerritoryWithFlag_Additional == null) { return false; } object[] array = new object[5] { pos, (int)flag, "", 0, 0 }; bool result = (bool)MI_IsObjectInsideTerritoryWithFlag_Additional.Invoke(null, array); name = (string)array[2]; flags = (TerritoryFlags)array[3]; additionalFlags = (AdditionalTerritoryFlags)array[4]; return result; } public static void ResetTraderItems() { if (_IsInstalled && !(MI_ResetTraderItems == null)) { MI_ResetTraderItems.Invoke(null, null); } } public static void OpenQuestJournal() { if (_IsInstalled && !(MI_OpenQuestJournal == null)) { MI_OpenQuestJournal.Invoke(null, null); } } public static void RegisterQuestReward(string name, string displayName, Action<string[]> give, Sprite icon = null, Func<string[], string> description = null) { if (_IsInstalled && !(MI_RegisterQuestReward == null)) { MI_RegisterQuestReward.Invoke(null, new object[5] { name, displayName, give, icon, description }); } } public static void RegisterDialogueCondition(string name, Func<string[], (bool met, string error)> check) { if (_IsInstalled && !(MI_RegisterDialogueCondition == null)) { MI_RegisterDialogueCondition.Invoke(null, new object[2] { name, check }); } } public static void RegisterDialogueCommand(string name, Action<string[]> command) { if (_IsInstalled && !(MI_RegisterDialogueCommand == null)) { MI_RegisterDialogueCommand.Invoke(null, new object[2] { name, command }); } } public static void RegisterGroupHandler(Func<List<long>> getMembers) { if (_IsInstalled && !(MI_RegisterGroupHandler == null)) { MI_RegisterGroupHandler.Invoke(null, new object[1] { getMembers }); } } public static void RegisterGroupChatCommand(string chatCommand) { if (_IsInstalled && !(MI_RegisterGroupChatCommand == null)) { MI_RegisterGroupChatCommand.Invoke(null, new object[1] { chatCommand }); } } public static void RegisterGuildHandler(string chatCommand, Func<string> getCurrentGuildName, Action<Action> registerOnGuildChanged) { if (_IsInstalled && !(MI_RegisterGuildHandler == null)) { MI_RegisterGuildHandler.Invoke(null, new object[3] { chatCommand, getCurrentGuildName, registerOnGuildChanged }); } } public static void SET_NPC_Type(this ZDO zdo, API_NPCType type) { zdo.Set("KGmarketNPC", (int)type); } public static void SET_NPC_Profile(this ZDO zdo, string profile) { zdo.Set("KGnpcProfile", profile); } public static void SET_NPC_Model(this ZDO zdo, string prefab) { zdo.Set("KGnpcModelOverride", prefab); } public static void SET_NPC_Name(this ZDO zdo, string name) { zdo.Set("KGnpcNameOverride", name); } public static void SET_NPC_Dialogue(this ZDO zdo, string dialogue) { zdo.Set("KGnpcDialogue", dialogue); } public static void SET_NPC_PatrolData(this ZDO zdo, string patrolData) { zdo.Set("KGmarket PatrolData", patrolData); } public static void SET_NPC_UseNavMesh(this ZDO zdo, int type) { zdo.Set("KGnpcNavMesh", type); } public static void SET_NPC_LeftItem(this ZDO zdo, string prefab) { zdo.Set("KGleftItem", prefab); } public static void SET_NPC_RightItem(this ZDO zdo, string prefab) { zdo.Set("KGrightItem", prefab); } public static void SET_NPC_HelmetItem(this ZDO zdo, string prefab) { zdo.Set("KGhelmetItem", prefab); } public static void SET_NPC_ChestItem(this ZDO zdo, string prefab) { zdo.Set("KGchestItem", prefab); } public static void SET_NPC_LegsItem(this ZDO zdo, string prefab) { zdo.Set("KGlegsItem", prefab); } public static void SET_NPC_CapeItem(this ZDO zdo, string prefab) { zdo.Set("KGcapeItem", prefab); } public static void SET_NPC_HairItem(this ZDO zdo, string prefab) { zdo.Set("KGhairItem", prefab); } public static void SET_NPC_HairColor(this ZDO zdo, string color) { zdo.Set("KGhairItemColor", color); } public static void SET_NPC_LeftItemBack(this ZDO zdo, string prefab) { zdo.Set("KGLeftItemBack", prefab); } public static void SET_NPC_RightItemBack(this ZDO zdo, string prefab) { zdo.Set("KGRightItemBack", prefab); } public static void SET_NPC_InteractAnimation(this ZDO zdo, string animation) { zdo.Set("KGinteractAnimation", animation); } public static void SET_NPC_GreetingAnimation(this ZDO zdo, string animation) { zdo.Set("KGgreetingAnimation", animation); } public static void SET_NPC_ByeAnimation(this ZDO zdo, string animation) { zdo.Set("KGbyeAnimation", animation); } public static void SET_NPC_GreetingText(this ZDO zdo, string text) { zdo.Set("KGgreetingText", text); } public static void SET_NPC_ByeText(this ZDO zdo, string text) { zdo.Set("KGbyeText", text); } public static void SET_NPC_SkinColor(this ZDO zdo, string color) { zdo.Set("KGskinColor", color); } public static void SET_NPC_CraftingAnimation(this ZDO zdo, string animation) { zdo.Set("KGcraftingAnimation", animation); } public static void SET_NPC_BeardItem(this ZDO zdo, string prefab) { zdo.Set("KGbeardItem", prefab); } public static void SET_NPC_BeardColor(this ZDO zdo, string color) { zdo.Set("KGbeardColor", color); } public static void SET_NPC_InteractSound(this ZDO zdo, string sound) { zdo.Set("KGinteractSound", sound); } public static void SET_NPC_TextSize(this ZDO zdo, string size) { zdo.Set("KGtextSize", float.TryParse(size, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var result) ? result : 3f); } public static void SET_NPC_TextHeight(this ZDO zdo, string height) { zdo.Set("KGtextHeight", float.TryParse(height, NumberStyles.Float | NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out var result) ? result : 0f); } public static void SET_NPC_PeriodicAnimation(this ZDO zdo, string animation) { zdo.Set("KGperiodicAnimation", animation); } public static void SET_NPC_PeriodicAnimationTime(this ZDO zdo, string time) { zdo.Set("KGperiodicAnimationTime", float.TryParse(time, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var result) ? result : 0f); } public static void SET_NPC_PeriodicSound(this ZDO zdo, string sound) { zdo.Set("KGperiodicSound", sound); } public static void SET_NPC_PeriodicSoundTime(this ZDO zdo, string time) { zdo.Set("KGperiodicSoundTime", float.TryParse(time, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var result) ? result : 0f); } public static void SET_NPC_NPCScale(this ZDO zdo, string scale) { zdo.Set("KGnpcScale", float.TryParse(scale, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var result) ? result : 1f); } public static void SET_NPC_IsPinned(this ZDO zdo, bool pinned) { zdo.Set("KGmarketPinned", pinned); } public static void SET_NPC_PinIcon(this ZDO zdo, string pinIcon) { zdo.Set("KGmarketPinIcon", string.IsNullOrWhiteSpace(pinIcon) ? "" : pinIcon); } public static void SET_NPC_ShowCondition(this ZDO zdo, string condition) { zdo.Set("KGnpcShowCondition", condition); } public static API_NPCType GET_NPC_Type(this ZDO zdo) { return (API_NPCType)zdo.GetInt("KGmarketNPC", 0); } public static string GET_NPC_Profile(this ZDO zdo) { return zdo.GetString("KGnpcProfile", "default"); } public static string GET_NPC_ShowCondition(this ZDO zdo) { return zdo.GetString("KGnpcShowCondition", ""); } public static string GET_NPC_Model(this ZDO zdo) { return zdo.GetString("KGnpcModelOverride", ""); } public static string GET_NPC_Name(this ZDO zdo) { return zdo.GetString("KGnpcNameOverride", ""); } public static string GET_NPC_Dialogue(this ZDO zdo) { return zdo.GetString("KGnpcDialogue", ""); } public static string GET_NPC_PatrolData(this ZDO zdo) { return zdo.GetString("KGmarket PatrolData", ""); } public static bool GET_NPC_IsPinned(this ZDO zdo) { return zdo.GetBool("KGmarketPinned", false); } public static string GET_NPC_PinIcon(this ZDO zdo) { return zdo.GetString("KGmarketPinIcon", ""); } public static AgentType GET_NPC_UseNavMesh(this ZDO zdo) { return (AgentType)zdo.GetInt("KGnpcNavMesh", 0); } public static string GET_NPC_LeftItem(this ZDO zdo) { return zdo.GetString("KGleftItem", ""); } public static string GET_NPC_RightItem(this ZDO zdo) { return zdo.GetString("KGrightItem", ""); } public static string GET_NPC_HelmetItem(this ZDO zdo) { return zdo.GetString("KGhelmetItem", ""); } public static string GET_NPC_ChestItem(this ZDO zdo) { return zdo.GetString("KGchestItem", ""); } public static string GET_NPC_LegsItem(this ZDO zdo) { return zdo.GetString("KGlegsItem", ""); } public static string GET_NPC_CapeItem(this ZDO zdo) { return zdo.GetString("KGcapeItem", ""); } public static string GET_NPC_HairItem(this ZDO zdo) { return zdo.GetString("KGhairItem", ""); } public static string GET_NPC_HairColor(this ZDO zdo) { return zdo.GetString("KGhairItemColor", ""); } public static string GET_NPC_LeftItemBack(this ZDO zdo) { return zdo.GetString("KGLeftItemBack", ""); } public static string GET_NPC_RightItemBack(this ZDO zdo) { return zdo.GetString("KGRightItemBack", ""); } public static string GET_NPC_InteractAnimation(this ZDO zdo) { return zdo.GetString("KGinteractAnimation", ""); } public static string GET_NPC_GreetingAnimation(this ZDO zdo) { return zdo.GetString("KGgreetingAnimation", ""); } public static string GET_NPC_ByeAnimation(this ZDO zdo) { return zdo.GetString("KGbyeAnimation", ""); } public static string GET_NPC_GreetingText(this ZDO zdo) { return zdo.GetString("KGgreetingText", ""); } public static string GET_NPC_ByeText(this ZDO zdo) { return zdo.GetString("KGbyeText", ""); } public static string GET_NPC_SkinColor(this ZDO zdo) { return zdo.GetString("KGskinColor", ""); } public static string GET_NPC_CraftingAnimation(this ZDO zdo) { return zdo.GetString("KGcraftingAnimation", ""); } public static string GET_NPC_BeardItem(this ZDO zdo) { return zdo.GetString("KGbeardItem", ""); } public static string GET_NPC_BeardColor(this ZDO zdo) { return zdo.GetString("KGbeardColor", ""); } public static string GET_NPC_InteractSound(this ZDO zdo) { return zdo.GetString("KGinteractSound", ""); } public static float GET_NPC_TextSize(this ZDO zdo) { return zdo.GetFloat("KGtextSize", 3f); } public static float GET_NPC_TextHeight(this ZDO zdo) { return zdo.GetFloat("KGtextHeight", 0f); } public static string GET_NPC_PeriodicAnimation(this ZDO zdo) { return zdo.GetString("KGperiodicAnimation", ""); } public static float GET_NPC_PeriodicAnimationTime(this ZDO zdo) { return zdo.GetFloat("KGperiodicAnimationTime", 0f); } public static string GET_NPC_PeriodicSound(this ZDO zdo) { return zdo.GetString("KGperiodicSound", ""); } public static float GET_NPC_PeriodicSoundTime(this ZDO zdo) { return zdo.GetFloat("KGperiodicSoundTime", 0f); } public static float GET_NPC_NPCScale(this ZDO zdo) { return zdo.GetFloat("KGnpcScale", 1f); } static Marketplace_API() { Type type = Type.GetType("API.ClientSide, kg.Marketplace"); if ((object)type == null) { _IsInstalled = false; return; } _IsInstalled = true; MI_IsPlayerInsideTerritory = type.GetMethod("IsPlayerInsideTerritory", BindingFlags.Static | BindingFlags.Public); MI_IsObjectInsideTerritoryWithFlag = type.GetMethod("IsObjectInsideTerritoryWithFlag", BindingFlags.Static | BindingFlags.Public); MI_IsObjectInsideTerritoryWithFlag_Additional = type.GetMethod("IsObjectInsideTerritoryWithFlag_Additional", BindingFlags.Static | BindingFlags.Public); MI_ResetTraderItems = type.GetMethod("ResetTraderItems", BindingFlags.Static | BindingFlags.Public); MI_OpenQuestJournal = type.GetMethod("OpenQuestJournal", BindingFlags.Static | BindingFlags.Public); MI_RegisterQuestReward = type.GetMethod("RegisterQuestReward", BindingFlags.Static | BindingFlags.Public); MI_RegisterDialogueCondition = type.GetMethod("RegisterDialogueCondition", BindingFlags.Static | BindingFlags.Public); MI_RegisterDialogueCommand = type.GetMethod("RegisterDialogueCommand", BindingFlags.Static | BindingFlags.Public); MI_RegisterGroupHandler = type.GetMethod("RegisterGroupHandler", BindingFlags.Static | BindingFlags.Public); MI_RegisterGuildHandler = type.GetMethod("RegisterGuildHandler", BindingFlags.Static | BindingFlags.Public); MI_RegisterGroupChatCommand = type.GetMethod("RegisterGroupChatCommand", BindingFlags.Static | BindingFlags.Public); } } namespace PoVMarketplaceLink { internal static class ExactXp { private const BindingFlags AnyMember = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; private const string SourceLabel = "Marketplace"; private static bool _initDone; private static bool _available; private static PropertyInfo _progressCurrent; private static FieldInfo _progressCraft; private static MethodInfo _addXp; private static MethodInfo _sourceXpMultiplier; private static MethodInfo _shareAt; private static MethodInfo _boost; private static MethodInfo _awardProfession; private static MethodInfo _points; private static MethodInfo _kindName; private static FieldInfo _xpMultiplier; private static FieldInfo _combatMultiplier; private static FieldInfo _workMultiplier; private static FieldInfo _travelMultiplier; private static FieldInfo _craftMultiplier; internal static bool Available { get { if (!_initDone) { Init(); } return _available; } } private static void Init() { _initDone = true; try { Assembly assembly = typeof(Grant).Assembly; Type type = assembly.GetType("PassiveTree.Progress"); Type type2 = assembly.GetType("PassiveTree.CraftProgress"); Type type3 = assembly.GetType("PassiveTree.BiomeLevels"); Type type4 = assembly.GetType("PassiveTree.CraftProfessionRates"); Type type5 = assembly.GetType("PassiveTree.Plugin"); _progressCurrent = type?.GetProperty("Current", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _progressCraft = type?.GetField("Craft", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _addXp = type?.GetMethod("AddXp", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[6] { typeof(float), typeof(string), typeof(bool), typeof(Vector3?), typeof(bool), typeof(string) }, null); _sourceXpMultiplier = type?.GetMethod("SourceXpMultiplier", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[4] { typeof(string), typeof(float), typeof(float), typeof(float) }, null); _shareAt = type3?.GetMethod("ShareAt", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[2] { typeof(Vector3), typeof(int) }, null); _boost = type2?.GetMethod("Boost", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null); _awardProfession = type2?.GetMethod("AwardProfession", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[3] { typeof(string), typeof(double), typeof(bool) }, null); _points = type4?.GetMethod("Points", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(string) }, null); _kindName = typeof(Grant).GetMethod("Kind", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(XpKind) }, null); _xpMultiplier = type5?.GetField("XpMultiplier", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _combatMultiplier = type5?.GetField("CombatXpMultiplier", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _workMultiplier = type5?.GetField("WorkXpMultiplier", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _travelMultiplier = type5?.GetField("TravelXpMultiplier", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _craftMultiplier = type5?.GetField("CraftXpMultiplier", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); List<string> missing = new List<string>(); Need(_progressCurrent, "Progress.Current"); Need(_progressCraft, "Progress.Craft"); Need(_addXp, "Progress.AddXp"); Need(_sourceXpMultiplier, "Progress.SourceXpMultiplier"); Need(_shareAt, "BiomeLevels.ShareAt"); Need(_boost, "CraftProgress.Boost"); Need(_awardProfession, "CraftProgress.AwardProfession"); Need(_points, "CraftProfessionRates.Points"); Need(_xpMultiplier, "Plugin.XpMultiplier"); Need(_craftMultiplier, "Plugin.CraftXpMultiplier"); _available = missing.Count == 0; if (_available) { Plugin.Log.LogInfo((object)"Exact XP enabled (PoV multipliers are compensated)."); } else { Plugin.Log.LogWarning((object)("Exact XP NOT available, PoV internals changed (" + string.Join(", ", missing) + "). Rewards will follow PoV's normal rules (biome, night, multipliers). Update PoV Marketplace Link.")); } void Need(object member, string name) { if (member == null) { missing.Add(name); } } } catch (Exception ex) { _available = false; Plugin.Log.LogWarning((object)("Exact XP NOT available: " + ex.Message + ". Rewards will follow PoV's normal rules.")); } } internal static bool GiveTreeXp(float amount, XpKind kind) { //IL_0043: 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) if (!Available || amount <= 0f) { return false; } object value = _progressCurrent.GetValue(null, null); Player localPlayer = Player.m_localPlayer; if (value == null || (Object)(object)localPlayer == (Object)null) { return false; } object value2 = _progressCraft.GetValue(value); if (value2 == null) { return false; } string text = KindName(kind); float num = (float)_shareAt.Invoke(null, new object[2] { ((Component)localPlayer).transform.position, Progression.Level }); float num2 = (float)_sourceXpMultiplier.Invoke(null, new object[4] { text, Value(_combatMultiplier), Value(_workMultiplier), Value(_travelMultiplier) }); double num3 = (double)_boost.Invoke(value2, null); double num4 = (double)(num * Value(_xpMultiplier) * num2) * num3; if (!(num4 > 0.0001) || double.IsInfinity(num4)) { Plugin.Log.LogWarning((object)$"Exact XP: PoV factor is {num4} (XP disabled on the server?). Nothing compensated."); return false; } int level = Progression.Level; float xp = Progression.Xp; _addXp.Invoke(value, new object[6] { (float)((double)amount / num4), "Marketplace", false, null, false, text }); if (Progression.Level == level && Progression.XpToNextLevel - Progression.Xp > 0.5f) { float num5 = Progression.Xp - xp; if (Math.Abs(num5 - amount) > Math.Max(1f, amount * 0.02f)) { Plugin.Log.LogWarning((object)$"Exact XP: asked {amount}, PoV gave {num5:0.##}. PoV's XP formula may have changed."); } } return true; } internal static bool GiveProfessionXp(string profession, double amount) { if (!Available || amount <= 0.0) { return false; } object value = _progressCurrent.GetValue(null, null); if (value == null) { return false; } object value2 = _progressCraft.GetValue(value); if (value2 == null) { return false; } double num = (double)_boost.Invoke(value2, null); double num2 = (double)_points.Invoke(null, new object[1] { profession }); double num3 = num * (double)Math.Max(0f, Value(_xpMultiplier)) * (double)Math.Max(0f, Value(_craftMultiplier)) * num2; if (!(num3 > 1E-06) || double.IsInfinity(num3)) { Plugin.Log.LogWarning((object)$"Exact XP: PoV profession factor for '{profession}' is {num3}. Nothing compensated."); return false; } double totalXp = Crafting.TotalXp; _awardProfession.Invoke(value2, new object[3] { profession, amount / num3, false }); double num4 = Crafting.TotalXp - totalXp; if (Math.Abs(num4 - amount) > Math.Max(1.0, amount * 0.02)) { Plugin.Log.LogWarning((object)$"Exact XP: asked {amount} for '{profession}', PoV gave {num4:0.##}. PoV's formula may have changed."); } return true; } private static string KindName(XpKind kind) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) try { if (_kindName?.Invoke(null, new object[1] { kind }) is string { Length: >0 } text) { return text; } } catch { } return "бой"; } private static float Value(FieldInfo field) { object? obj = field?.GetValue(null); ConfigEntryBase val = (ConfigEntryBase)((obj is ConfigEntryBase) ? obj : null); if (val != null) { object boxedValue = val.BoxedValue; if (boxedValue is float) { return (float)boxedValue; } } return 1f; } } internal static class InfoCommand { internal static void Register() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) new ConsoleCommand("povlink_info", "[nodes] - PoV Marketplace Link: shows your PoV level, path, ascendancy and professions (nodes = list taken node ids)", new ConsoleEvent(Run), false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); } private static void Run(ConsoleEventArgs args) { Terminal context = args.Context; if ((Object)(object)Player.m_localPlayer == (Object)null) { context.AddString("PoV Marketplace Link: no local player loaded."); return; } context.AddString($"PoV level: {Progression.Level} (XP {Progression.Xp:0}/{Progression.XpToNextLevel:0}, points free {Progression.FreePoints}, spent {Progression.SpentPoints})"); context.AddString("Path: '" + Build.Path + "' title: '" + Build.PathTitle + "' -> PoVPath, " + Registrations.Normalize(Build.Path)); AscendancyInfo active = Ascendancies.Active; string text = ((active != null) ? active.Key : null) ?? ""; string text2 = ((active != null) ? active.Name : null) ?? ""; context.AddString("Ascendancy class: '" + Build.AscendancyClass + "' key: '" + text + "' name: '" + text2 + "' -> PoVAscendancy, " + Registrations.Normalize(string.IsNullOrEmpty(text) ? Build.AscendancyClass : text)); context.AddString("Professions: " + string.Join(", ", Registrations.Professions()) + " -> PoV_ProfessionEXP: <profession>, <amount>"); IReadOnlyCollection<string> nodes = Progression.Nodes; int num = nodes?.Count ?? 0; if (args.Args.Length > 1 && string.Equals(args.Args[1], "nodes", StringComparison.OrdinalIgnoreCase)) { context.AddString(string.Format("Taken nodes ({0}): {1}", num, (nodes == null) ? "" : string.Join(", ", nodes))); } else { context.AddString($"Taken nodes: {num} (use 'povlink_info nodes' to list the ids for PoVHasNode)"); } } } [BepInPlugin("glitnir.povmarketplacelink", "PoV Marketplace Link", "1.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string Guid = "glitnir.povmarketplacelink"; public const string Name = "PoV Marketplace Link"; public const string Version = "1.1.0"; private const string MarketplaceGuid = "MarketplaceAndServerNPCs"; private const string PoVGuid = "treextr.pathofvalheiman"; internal static ManualLogSource Log; private void Awake() { Log = ((BaseUnityPlugin)this).Logger; if (!Marketplace_API.IsInstalled()) { Log.LogWarning((object)"Marketplace not found: nothing was registered."); } else if (!MarketplaceHasModApi()) { Log.LogWarning((object)"Marketplace is older than 10.0.9 (no mod API): nothing was registered. Update Marketplace."); } else { Registrations.RegisterAll(); } } private static bool MarketplaceHasModApi() { Type type = Type.GetType("API.ClientSide, kg.Marketplace"); if (type?.GetMethod("RegisterQuestReward", BindingFlags.Static | BindingFlags.Public) != null && type.GetMethod("RegisterDialogueCondition", BindingFlags.Static | BindingFlags.Public) != null) { return type.GetMethod("RegisterDialogueCommand", BindingFlags.Static | BindingFlags.Public) != null; } return false; } } internal static class Registrations { private const string XpSource = "marketplace"; internal static void RegisterAll() { Marketplace_API.RegisterQuestReward("PoV_EXP", "PoV XP", Safe("PoV_EXP", (Action<string[]>)GiveTreeXp), null, DescribeTreeXp); Marketplace_API.RegisterQuestReward("PoV_ProfessionEXP", "PoV Profession XP", Safe("PoV_ProfessionEXP", (Action<string[]>)GiveProfessionXp), null, DescribeProfessionXp); Marketplace_API.RegisterDialogueCommand("AddPoVExp", Safe("AddPoVExp", (Action<string[]>)GiveTreeXp)); Marketplace_API.RegisterDialogueCommand("AddPoVProfessionExp", Safe("AddPoVProfessionExp", (Action<string[]>)GiveProfessionXp)); Marketplace_API.RegisterDialogueCondition("PoVLevelMore", Safe("PoVLevelMore", (Func<string[], (bool met, string error)>)LevelMore)); Marketplace_API.RegisterDialogueCondition("PoVLevelLess", Safe("PoVLevelLess", (Func<string[], (bool met, string error)>)LevelLess)); Marketplace_API.RegisterDialogueCondition("PoVHasNode", Safe("PoVHasNode", (string[] a) => Nodes(a, wanted: true))); Marketplace_API.RegisterDialogueCondition("PoVNotHasNode", Safe("PoVNotHasNode", (string[] a) => Nodes(a, wanted: false))); Marketplace_API.RegisterDialogueCondition("PoVPath", Safe("PoVPath", (string[] a) => PathIs(a, wanted: true))); Marketplace_API.RegisterDialogueCondition("PoVNotPath", Safe("PoVNotPath", (string[] a) => PathIs(a, wanted: false))); Marketplace_API.RegisterDialogueCondition("PoVAscendancy", Safe("PoVAscendancy", (string[] a) => AscendancyIs(a, wanted: true))); Marketplace_API.RegisterDialogueCondition("PoVNotAscendancy", Safe("PoVNotAscendancy", (string[] a) => AscendancyIs(a, wanted: false))); InfoCommand.Register(); _ = ExactXp.Available; Plugin.Log.LogInfo((object)"Registered in Marketplace -> rewards: PoV_EXP, PoV_ProfessionEXP | commands: AddPoVExp, AddPoVProfessionExp | conditions: PoVLevelMore, PoVLevelLess, PoVHasNode, PoVNotHasNode, PoVPath, PoVNotPath, PoVAscendancy, PoVNotAscendancy"); } private static void GiveTreeXp(string[] args) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_00b3: Unknown result type (might be due to invalid IL or missing references) if (!TryFloat(Arg(args, 0), out var v) || v <= 0f) { Plugin.Log.LogWarning((object)("PoV XP: invalid amount '" + Arg(args, 0) + "'. Use e.g. PoV_EXP: 500")); return; } XpKind kind = (XpKind)0; string text = Arg(args, 1); if (text.Length > 0 && !TryParseKind(text, out kind)) { Plugin.Log.LogWarning((object)("PoV XP: unknown XP kind '" + text + "', using Combat. Valid: " + string.Join(", ", Enum.GetNames(typeof(XpKind))))); kind = (XpKind)0; } if (!ExactXp.GiveTreeXp(v, kind) && !Grant.TreeXp(v, kind, "marketplace")) { Plugin.Log.LogWarning((object)$"PoV refused {v} tree XP ({kind}). Is the player loaded?"); } } private static string DescribeTreeXp(string[] args) { return "+" + Arg(args, 0) + " PoV XP"; } private static void GiveProfessionXp(string[] args) { string text = Arg(args, 0); if (text.Length == 0 || !TryDouble(Arg(args, 1), out var v) || v <= 0.0) { Plugin.Log.LogWarning((object)("PoV profession XP: use e.g. PoV_ProfessionEXP: miner, 200 (got '" + string.Join(",", args ?? Array.Empty<string>()) + "')")); return; } string text2 = MatchProfession(text); if (text2 == null) { Plugin.Log.LogWarning((object)("PoV profession '" + text + "' not found. Known: " + string.Join(", ", Professions()))); } else if (!ExactXp.GiveProfessionXp(text2, v) && !Grant.ProfessionXp(text2, v)) { Plugin.Log.LogWarning((object)$"PoV refused {v} XP for profession '{text2}'."); } } private static string DescribeProfessionXp(string[] args) { return "+" + Arg(args, 1) + " " + Arg(args, 0) + " XP"; } private static (bool met, string error) LevelMore(string[] args) { if (!TryInt(Arg(args, 0), out var v)) { return BadArgs("PoVLevelMore", args); } return (met: Progression.Level >= v, error: $"Requires PoV level <color=#00ff00>{v}</color>"); } private static (bool met, string error) LevelLess(string[] args) { if (!TryInt(Arg(args, 0), out var v)) { return BadArgs("PoVLevelLess", args); } return (met: Progression.Level < v, error: $"Only for PoV level below <color=#ff5555>{v}</color>"); } private static (bool met, string error) Nodes(string[] args, bool wanted) { if (Arg(args, 0).Length == 0) { return BadArgs(wanted ? "PoVHasNode" : "PoVNotHasNode", args); } bool flag = false; for (int i = 0; i < args.Length; i++) { string text = args[i].Trim(); if (text.Length > 0 && (Progression.HasNode(text) || Crafting.HasNode(text))) { flag = true; break; } } string text2 = string.Join(" / ", args); if (!wanted) { return (met: !flag, error: "Not available with PoV node: " + text2); } return (met: flag, error: "Requires PoV node: " + text2); } private static (bool met, string error) PathIs(string[] args, bool wanted) { if (Arg(args, 0).Length == 0) { return BadArgs(wanted ? "PoVPath" : "PoVNotPath", args); } bool flag = MatchesAny(args, Build.Path, Build.PathTitle); string text = string.Join(" / ", args); if (!wanted) { return (met: !flag, error: "Not available for path: " + text); } return (met: flag, error: "Only for path: " + text); } private static (bool met, string error) AscendancyIs(string[] args, bool wanted) { if (Arg(args, 0).Length == 0) { return BadArgs(wanted ? "PoVAscendancy" : "PoVNotAscendancy", args); } AscendancyInfo active = Ascendancies.Active; bool flag = MatchesAny(args, Build.AscendancyClass, (active != null) ? active.Key : null, (active != null) ? active.Name : null); string text = string.Join(" / ", args); if (!wanted) { return (met: !flag, error: "Not available for ascendancy: " + text); } return (met: flag, error: "Only for ascendancy: " + text); } private static Action<string[]> Safe(string name, Action<string[]> action) { return delegate(string[] args) { try { action(args ?? Array.Empty<string>()); } catch (Exception arg) { Plugin.Log.LogError((object)$"{name} failed: {arg}"); } }; } private static Func<string[], (bool met, string error)> Safe(string name, Func<string[], (bool met, string error)> check) { return delegate(string[] args) { try { return ((bool met, string error))check(args ?? Array.Empty<string>()); } catch (Exception arg) { Plugin.Log.LogError((object)$"{name} failed: {arg}"); return (met: false, error: "Error checking PoV (see log)"); } }; } private static (bool met, string error) BadArgs(string name, string[] args) { Plugin.Log.LogWarning((object)(name + ": invalid arguments '" + string.Join(",", args ?? Array.Empty<string>()) + "'.")); return (met: false, error: "Invalid config: " + name); } private static string Arg(string[] args, int index) { if (args == null || args.Length <= index || args[index] == null) { return ""; } return args[index].Trim(); } private static bool TryInt(string s, out int v) { return int.TryParse(s, NumberStyles.Integer, CultureInfo.InvariantCulture, out v); } private static bool TryFloat(string s, out float v) { return float.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out v); } private static bool TryDouble(string s, out double v) { return double.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out v); } private static bool TryParseKind(string s, out XpKind kind) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected I4, but got Unknown foreach (XpKind value in Enum.GetValues(typeof(XpKind))) { if (string.Equals(((object)value/*cast due to .constrained prefix*/).ToString(), s, StringComparison.OrdinalIgnoreCase)) { kind = (XpKind)(int)value; return true; } } kind = (XpKind)0; return false; } internal static IReadOnlyList<string> Professions() { return Crafting.Professions ?? Array.Empty<string>(); } private static string MatchProfession(string wanted) { string text = Normalize(wanted); foreach (string item in Professions()) { if (Normalize(item) == text) { return item; } } return null; } private static bool MatchesAny(string[] wanted, params string[] candidates) { for (int i = 0; i < wanted.Length; i++) { string text = Normalize(wanted[i]); if (text.Length == 0) { continue; } foreach (string text2 in candidates) { if (!string.IsNullOrEmpty(text2) && Normalize(text2) == text) { return true; } } } return false; } internal static string Normalize(string s) { if (string.IsNullOrEmpty(s)) { return ""; } StringBuilder stringBuilder = new StringBuilder(s.Length); foreach (char c in s) { if (char.IsLetterOrDigit(c)) { stringBuilder.Append(char.ToLowerInvariant(c)); } } return stringBuilder.ToString(); } } }