Please disclose if your mod was created primarily using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of World Advancement Progression v0.3.11
Plugins/VentureValheim.Progression.dll
Decompiled 4 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using JetBrains.Annotations; using Jotunn.Managers; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("VentureValheim.Progression")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("VentureValheim.Progression")] [assembly: AssemblyCopyright("Copyright © 2022")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("C7C3AE76-5385-4FCC-B89C-88205DFE26C7")] [assembly: AssemblyFileVersion("0.3.11")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.3.11.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace VentureValheim.Progression { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.orianaventure.mod.WorldAdvancementProgression", "WorldAdvancementProgression", "0.3.11")] public class ProgressionPlugin : BaseUnityPlugin { private static readonly ProgressionPlugin _instance; private const string ModName = "WorldAdvancementProgression"; private const string ModVersion = "0.3.11"; private const string Author = "com.orianaventure.mod"; private const string ModGUID = "com.orianaventure.mod.WorldAdvancementProgression"; private static string ConfigFileName; private static string ConfigFileFullPath; private readonly Harmony HarmonyInstance = new Harmony("com.orianaventure.mod.WorldAdvancementProgression"); public static readonly ManualLogSource VentureProgressionLogger; public static ConfigEntry<bool> CE_BlockAllGlobalKeys; public static ConfigEntry<string> CE_BlockedGlobalKeys; public static ConfigEntry<string> CE_AllowedGlobalKeys; public static ConfigEntry<string> CE_EnforcedGlobalKeys; public static ConfigEntry<bool> CE_UsePrivateKeys; public static ConfigEntry<string> CE_BlockedPrivateKeys; public static ConfigEntry<string> CE_AllowedPrivateKeys; public static ConfigEntry<string> CE_EnforcedPrivateKeys; public static ConfigEntry<bool> CE_AdminBypass; public static ConfigEntry<bool> CE_UseBlockedActionMessage; public static ConfigEntry<string> CE_BlockedActionMessage; public static ConfigEntry<bool> CE_UseBlockedActionEffect; public static ConfigEntry<bool> CE_LockTaming; public static ConfigEntry<string> CE_OverrideLockTamingDefaults; public static ConfigEntry<bool> CE_LockGuardianPower; public static ConfigEntry<bool> CE_LockBossSummons; public static ConfigEntry<string> CE_OverrideLockBossSummonsDefaults; public static ConfigEntry<bool> CE_UnlockBossSummonsOverTime; public static ConfigEntry<int> CE_UnlockBossSummonsTime; public static ConfigEntry<bool> CE_LockEquipment; public static ConfigEntry<bool> CE_LockCrafting; public static ConfigEntry<bool> CE_LockBuilding; public static ConfigEntry<bool> CE_LockCooking; public static ConfigEntry<bool> CE_LockEating; public static ConfigEntry<string> CE_LockBoatsKey; public static ConfigEntry<string> CE_LockPortalsKey; public static ConfigEntry<string> CE_UnlockPortalCopperTinKey; public static ConfigEntry<string> CE_UnlockPortalIronKey; public static ConfigEntry<string> CE_UnlockPortalSilverKey; public static ConfigEntry<string> CE_UnlockPortalBlackMetalKey; public static ConfigEntry<string> CE_UnlockPortalFlametalKey; public static ConfigEntry<string> CE_UnlockPortalDragonEggKey; public static ConfigEntry<string> CE_UnlockPortalMistlandsKey; public static ConfigEntry<string> CE_UnlockPortalAshlandsKey; public static ConfigEntry<string> CE_UnlockPortalHildirChestsKey; public static ConfigEntry<bool> CE_EnableSkillManager; public static ConfigEntry<bool> CE_AllowSkillDrain; public static ConfigEntry<bool> CE_UseAbsoluteSkillDrain; public static ConfigEntry<int> CE_AbsoluteSkillDrain; public static ConfigEntry<bool> CE_CompareAndSelectDrain; public static ConfigEntry<bool> CE_CompareUseMinimumDrain; public static ConfigEntry<bool> CE_OverrideMaximumSkillLevel; public static ConfigEntry<int> CE_MaximumSkillLevel; public static ConfigEntry<bool> CE_OverrideMinimumSkillLevel; public static ConfigEntry<int> CE_MinimumSkillLevel; public static ConfigEntry<bool> CE_UseBossKeysForSkillLevel; public static ConfigEntry<int> CE_BossKeysSkillPerKey; public static ConfigEntry<bool> CE_UnlockAllHaldorItems; public static ConfigEntry<string> CE_HelmetYuleKey; public static ConfigEntry<string> CE_HelmetDvergerKey; public static ConfigEntry<string> CE_BeltStrengthKey; public static ConfigEntry<string> CE_YmirRemainsKey; public static ConfigEntry<string> CE_FishingRodKey; public static ConfigEntry<string> CE_FishingBaitKey; public static ConfigEntry<string> CE_ThunderstoneKey; public static ConfigEntry<string> CE_ChickenEggKey; public static ConfigEntry<string> CE_BarrelRingsKey; public static ConfigEntry<bool> CE_UnlockAllHildirItems; public static ConfigEntry<string> CE_CryptItemsKey; public static ConfigEntry<string> CE_CaveItemsKey; public static ConfigEntry<string> CE_TowerItemsKey; public static ConfigEntry<bool> CE_UnlockAllBogWitchItems; public static ConfigEntry<string> CE_ScytheHandleKey; public static ConfigEntry<bool> CE_UsePrivateRaids; private readonly ConfigurationManagerAttributes AdminConfig = new ConfigurationManagerAttributes { IsAdminOnly = true }; private readonly ConfigurationManagerAttributes ClientConfig = new ConfigurationManagerAttributes { IsAdminOnly = false }; private DateTime _lastReloadTime; private const long RELOAD_DELAY = 10000000L; public static ProgressionPlugin Instance => _instance; static ProgressionPlugin() { _instance = new ProgressionPlugin(); ConfigFileName = "com.orianaventure.mod.WorldAdvancementProgression.cfg"; string configPath = Paths.ConfigPath; char directorySeparatorChar = Path.DirectorySeparatorChar; ConfigFileFullPath = configPath + directorySeparatorChar + ConfigFileName; VentureProgressionLogger = Logger.CreateLogSource("WorldAdvancementProgression"); CE_BlockAllGlobalKeys = null; CE_BlockedGlobalKeys = null; CE_AllowedGlobalKeys = null; CE_EnforcedGlobalKeys = null; CE_UsePrivateKeys = null; CE_BlockedPrivateKeys = null; CE_AllowedPrivateKeys = null; CE_EnforcedPrivateKeys = null; CE_AdminBypass = null; CE_UseBlockedActionMessage = null; CE_BlockedActionMessage = null; CE_UseBlockedActionEffect = null; CE_LockTaming = null; CE_OverrideLockTamingDefaults = null; CE_LockGuardianPower = null; CE_LockBossSummons = null; CE_OverrideLockBossSummonsDefaults = null; CE_UnlockBossSummonsOverTime = null; CE_UnlockBossSummonsTime = null; CE_LockEquipment = null; CE_LockCrafting = null; CE_LockBuilding = null; CE_LockCooking = null; CE_LockEating = null; CE_LockBoatsKey = null; CE_LockPortalsKey = null; CE_UnlockPortalCopperTinKey = null; CE_UnlockPortalIronKey = null; CE_UnlockPortalSilverKey = null; CE_UnlockPortalBlackMetalKey = null; CE_UnlockPortalFlametalKey = null; CE_UnlockPortalDragonEggKey = null; CE_UnlockPortalMistlandsKey = null; CE_UnlockPortalAshlandsKey = null; CE_UnlockPortalHildirChestsKey = null; CE_EnableSkillManager = null; CE_AllowSkillDrain = null; CE_UseAbsoluteSkillDrain = null; CE_AbsoluteSkillDrain = null; CE_CompareAndSelectDrain = null; CE_CompareUseMinimumDrain = null; CE_OverrideMaximumSkillLevel = null; CE_MaximumSkillLevel = null; CE_OverrideMinimumSkillLevel = null; CE_MinimumSkillLevel = null; CE_UseBossKeysForSkillLevel = null; CE_BossKeysSkillPerKey = null; CE_UnlockAllHaldorItems = null; CE_HelmetYuleKey = null; CE_HelmetDvergerKey = null; CE_BeltStrengthKey = null; CE_YmirRemainsKey = null; CE_FishingRodKey = null; CE_FishingBaitKey = null; CE_ThunderstoneKey = null; CE_ChickenEggKey = null; CE_BarrelRingsKey = null; CE_UnlockAllHildirItems = null; CE_CryptItemsKey = null; CE_CaveItemsKey = null; CE_TowerItemsKey = null; CE_UnlockAllBogWitchItems = null; CE_ScytheHandleKey = null; CE_UsePrivateRaids = null; } private ProgressionPlugin() { }//IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown private void AddConfig<T>(string key, string section, string description, bool synced, T value, ref ConfigEntry<T> configEntry) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown string extendedDescription = GetExtendedDescription(description, synced); configEntry = ((BaseUnityPlugin)this).Config.Bind<T>(section, key, value, new ConfigDescription(extendedDescription, (AcceptableValueBase)null, new object[1] { synced ? AdminConfig : ClientConfig })); } public string GetExtendedDescription(string description, bool synchronizedSetting) { return description + (synchronizedSetting ? " [Synced with Server]" : " [Not Synced with Server]"); } public void Awake() { AddConfig("BlockAllGlobalKeys", "Keys", "True to stop all global keys from being added to the global list (boolean).", synced: true, value: true, ref CE_BlockAllGlobalKeys); AddConfig("BlockedGlobalKeys", "Keys", "Stop only these keys being added to the global list when BlockAllGlobalKeys is false (comma-separated).", synced: true, "", ref CE_BlockedGlobalKeys); AddConfig("AllowedGlobalKeys", "Keys", "Allow only these keys being added to the global list when BlockAllGlobalKeys is true (comma-separated).", synced: true, "", ref CE_AllowedGlobalKeys); AddConfig("EnforcedGlobalKeys", "Keys", "Always add these keys to the global list on startup (comma-separated).", synced: true, "", ref CE_EnforcedGlobalKeys); AddConfig("UsePrivateKeys", "Keys", "True to use private player keys to control game behavior (boolean).", synced: true, value: true, ref CE_UsePrivateKeys); AddConfig("BlockedPrivateKeys", "Keys", "Stop only these keys being added to the player's key list when UsePrivateKeys is true (comma-separated).", synced: true, "", ref CE_BlockedPrivateKeys); AddConfig("AllowedPrivateKeys", "Keys", "Allow only these keys being added to the player's key list when UsePrivateKeys is true (comma-separated).", synced: true, "", ref CE_AllowedPrivateKeys); AddConfig("EnforcedPrivateKeys", "Keys", "Always add these keys to the player's private list on startup (comma-separated).", synced: true, "", ref CE_EnforcedPrivateKeys); AddConfig("AdminBypass", "Locking", "True to allow admins to bypass locking settings (boolean)", synced: true, value: false, ref CE_AdminBypass); AddConfig("UseBlockedActionMessage", "Locking", "True to enable the blocked display message used in this mod (string).", synced: true, value: true, ref CE_UseBlockedActionMessage); AddConfig("BlockedActionMessage", "Locking", "Generic blocked display message used in this mod (string).", synced: true, "The Gods Reject You", ref CE_BlockedActionMessage); AddConfig("UseBlockedActionEffect", "Locking", "True to enable the blocked display effect (fire) used in this mod (string).", synced: true, value: true, ref CE_UseBlockedActionEffect); AddConfig("LockTaming", "Locking", "True to lock the ability to tame creatures based on keys. Uses private key if enabled, global key if not (boolean).", synced: true, value: false, ref CE_LockTaming); AddConfig("OverrideLockTamingDefaults", "Locking", "Override keys needed to Tame creatures. Leave blank to use defaults (comma-separated prefab,key pairs).", synced: true, "", ref CE_OverrideLockTamingDefaults); AddConfig("LockGuardianPower", "Locking", "True to lock the ability to get and use guardian powers based on keys. Uses private key if enabled, global key if not (boolean).", synced: true, value: true, ref CE_LockGuardianPower); AddConfig("LockBossSummons", "Locking", "True to lock the ability to spawn bosses based on keys. Uses private key if enabled, global key if not (boolean).", synced: true, value: true, ref CE_LockBossSummons); AddConfig("OverrideLockBossSummonsDefaults", "Locking", "Override keys needed to summon bosses. Leave blank to use defaults (comma-separated prefab,key pairs).", synced: true, "", ref CE_OverrideLockBossSummonsDefaults); AddConfig("UnlockBossSummonsOverTime", "Locking", "True to unlock the ability to spawn bosses based on in-game days passed when LockBossSummons is True (boolean).", synced: true, value: false, ref CE_UnlockBossSummonsOverTime); AddConfig("UnlockBossSummonsTime", "Locking", "Number of in-game days required to unlock the next boss in the sequence when UnlockBossSummonsOverTime is True (int).", synced: true, 100, ref CE_UnlockBossSummonsTime); AddConfig("LockEquipment", "Locking", "True to lock the ability to equip or use boss items or items made from biome metals/materials based on keys. Uses private key if enabled, global key if not (boolean).", synced: true, value: true, ref CE_LockEquipment); AddConfig("LockCrafting", "Locking", "True to lock the ability to craft items based on boss items and biome metals/materials and keys. Uses private key if enabled, global key if not (boolean).", synced: true, value: true, ref CE_LockCrafting); AddConfig("LockBuilding", "Locking", "True to lock the ability to build based on boss items and biome metals/materials and keys. Uses private key if enabled, global key if not (boolean).", synced: true, value: true, ref CE_LockBuilding); AddConfig("LockCooking", "Locking", "True to lock the ability to cook with biome food materials based on keys. Uses private key if enabled, global key if not (boolean).", synced: true, value: true, ref CE_LockCooking); AddConfig("LockEating", "Locking", "True to lock the ability to eat biome food materials based on keys. Uses private key if enabled, global key if not (boolean).", synced: true, value: true, ref CE_LockEating); AddConfig("LockBoatsKey", "Locking", "Use this key to control player ability to use boats (ex: defeated_eikthyr). Leave blank to allow vanilla boat behavior (string).", synced: true, "", ref CE_LockBoatsKey); AddConfig("LockPortalsKey", "Locking", "Use this key to control player ability to use portals (ex: defeated_eikthyr). Leave blank to allow vanilla portal behavior (string).", synced: true, "", ref CE_LockPortalsKey); AddConfig("UnlockPortalCopperTinKey", "PortalUnlocking", "Use this key to control player ability to teleport copper and tin. Leave blank to allow vanilla portal behavior (string).", synced: true, "", ref CE_UnlockPortalCopperTinKey); AddConfig("UnlockPortalIronKey", "PortalUnlocking", "Use this key to control player ability to teleport iron. Leave blank to allow vanilla portal behavior (string).", synced: true, "", ref CE_UnlockPortalIronKey); AddConfig("UnlockPortalSilverKey", "PortalUnlocking", "Use this key to control player ability to teleport silver. Leave blank to allow vanilla portal behavior (string).", synced: true, "", ref CE_UnlockPortalSilverKey); AddConfig("UnlockPortalBlackMetalKey", "PortalUnlocking", "Use this key to control player ability to teleport black metal. Leave blank to allow vanilla portal behavior (string).", synced: true, "", ref CE_UnlockPortalBlackMetalKey); AddConfig("UnlockPortalFlametalKey", "PortalUnlocking", "Use this key to control player ability to teleport flametal. Leave blank to allow vanilla portal behavior (string).", synced: true, "", ref CE_UnlockPortalFlametalKey); AddConfig("UnlockPortalDragonEggKey", "PortalUnlocking", "Use this key to control player ability to teleport dragon eggs. Leave blank to allow vanilla portal behavior (string).", synced: true, "", ref CE_UnlockPortalDragonEggKey); AddConfig("UnlockPortalMistlandsKey", "PortalUnlocking", "Use this key to control player ability to teleport MechanicalSpring and DvergrNeedle. Leave blank to allow vanilla portal behavior (string).", synced: true, "", ref CE_UnlockPortalMistlandsKey); AddConfig("UnlockPortalAshlandsKey", "PortalUnlocking", "Use this key to control player ability to teleport CharredCogwheel. Leave blank to allow vanilla portal behavior (string).", synced: true, "", ref CE_UnlockPortalAshlandsKey); AddConfig("UnlockPortalHildirChestsKey", "PortalUnlocking", "Use this key to control player ability to teleport Hildir's stolen chests. Leave blank to allow vanilla portal behavior (string).", synced: true, "", ref CE_UnlockPortalHildirChestsKey); AddConfig("EnableSkillManager", "Skills", "Enable the Skill Manager feature (boolean).", synced: true, value: true, ref CE_EnableSkillManager); AddConfig("AllowSkillDrain", "Skills", "Enable skill drain on death (boolean).", synced: true, value: true, ref CE_AllowSkillDrain); AddConfig("UseAbsoluteSkillDrain", "Skills", "Reduce skills by a set number of levels (boolean).", synced: true, value: false, ref CE_UseAbsoluteSkillDrain); AddConfig("AbsoluteSkillDrain", "Skills", "The number of levels (When UseAbsoluteSkillDrain is true) (int).", synced: true, 1, ref CE_AbsoluteSkillDrain); AddConfig("CompareAndSelectDrain", "Skills", "Enable comparing skill drain original vs absolute value (When UseAbsoluteSkillDrain is true) (boolean).", synced: true, value: false, ref CE_CompareAndSelectDrain); AddConfig("CompareUseMinimumDrain", "Skills", "True to use the smaller value (When CompareAndSelectDrain is true) (boolean).", synced: true, value: true, ref CE_CompareUseMinimumDrain); AddConfig("OverrideMaximumSkillLevel", "Skills", "Override the maximum (ceiling) skill level for all skill gain (boolean).", synced: true, value: false, ref CE_OverrideMaximumSkillLevel); AddConfig("MaximumSkillLevel", "Skills", "If overridden, the maximum (ceiling) skill level for all skill gain (int).", synced: true, 100, ref CE_MaximumSkillLevel); AddConfig("OverrideMinimumSkillLevel", "Skills", "Override the minimum (floor) skill level for all skill loss (boolean).", synced: true, value: false, ref CE_OverrideMinimumSkillLevel); AddConfig("MinimumSkillLevel", "Skills", "If overridden, the minimum (floor) skill level for all skill loss (int).", synced: true, 0, ref CE_MinimumSkillLevel); AddConfig("UseBossKeysForSkillLevel", "Skills", "True to use unlocked boss keys to control skill floor/ceiling values (boolean).", synced: true, value: false, ref CE_UseBossKeysForSkillLevel); AddConfig("BossKeysSkillPerKey", "Skills", "Skill drain floor and skill gain ceiling increased this amount per boss defeated (boolean).", synced: true, 10, ref CE_BossKeysSkillPerKey); AddConfig("UnlockAllHaldorItems", "Trader", "True to remove the key check from Haldor entirely and unlock all items (boolean).", synced: true, value: false, ref CE_UnlockAllHaldorItems); AddConfig("HelmetYuleKey", "Trader", "Custom key for unlocking the Yule Hat. Leave blank to use default (string).", synced: true, "", ref CE_HelmetYuleKey); AddConfig("HelmetDvergerKey", "Trader", "Custom key for unlocking the Dverger Circlet. Leave blank to use default (string).", synced: true, "", ref CE_HelmetDvergerKey); AddConfig("BeltStrengthKey", "Trader", "Custom key for unlocking the Megingjord. Leave blank to use default (string).", synced: true, "", ref CE_BeltStrengthKey); AddConfig("YmirRemainsKey", "Trader", "Custom key for unlocking Ymir Flesh. Leave blank to use default (string).", synced: true, "", ref CE_YmirRemainsKey); AddConfig("FishingRodKey", "Trader", "Custom key for unlocking the Fishing Rod. Leave blank to use default (string).", synced: true, "", ref CE_FishingRodKey); AddConfig("FishingBaitKey", "Trader", "Custom key for unlocking Fishing Bait. Leave blank to use default (string).", synced: true, "", ref CE_FishingBaitKey); AddConfig("ThunderstoneKey", "Trader", "Custom key for unlocking the Thunder Stone. Leave blank to use default (string).", synced: true, "", ref CE_ThunderstoneKey); AddConfig("ChickenEggKey", "Trader", "Custom key for unlocking the Egg. Leave blank to use default (string).", synced: true, "", ref CE_ChickenEggKey); AddConfig("BarrelRingsKey", "Trader", "Custom key for unlocking the Barrel Rings. Leave blank to use default (string).", synced: true, "", ref CE_BarrelRingsKey); AddConfig("UnlockAllHildirItems", "Hildir", "True to remove the key check from Hildir entirely and unlock all items (boolean).", synced: true, value: false, ref CE_UnlockAllHildirItems); AddConfig("CryptItemsKey", "Hildir", "Custom key for unlocking the Crypt Dungeon items. Leave blank to use default (string).", synced: true, "", ref CE_CryptItemsKey); AddConfig("CaveItemsKey", "Hildir", "Custom key for unlocking the Cave Dungeon items. Leave blank to use default (string).", synced: true, "", ref CE_CaveItemsKey); AddConfig("TowerItemsKey", "Hildir", "Custom key for unlocking the Tower Dungeon items. Leave blank to use default (string).", synced: true, "", ref CE_TowerItemsKey); AddConfig("UnlockAllBogWitchItems", "BogWitch", "True to remove the key check from Bog Witch entirely and unlock all items (boolean).", synced: true, value: false, ref CE_UnlockAllBogWitchItems); AddConfig("ScytheHandleKey", "BogWitch", "Custom key for unlocking the Scythe Handle. Leave blank to use default (string).", synced: true, "", ref CE_ScytheHandleKey); AddConfig("UsePrivateRaids", "Raids", "True to use this mod's raids feature when using private keys (bool).", synced: true, value: true, ref CE_UsePrivateRaids); Assembly executingAssembly = Assembly.GetExecutingAssembly(); HarmonyInstance.PatchAll(executingAssembly); SetupWatcher(); } private void OnDestroy() { ((BaseUnityPlugin)this).Config.Save(); } private void SetupWatcher() { _lastReloadTime = DateTime.Now; FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath, ConfigFileName); fileSystemWatcher.Changed += ReadConfigValues; fileSystemWatcher.Created += ReadConfigValues; fileSystemWatcher.Renamed += ReadConfigValues; fileSystemWatcher.IncludeSubdirectories = true; fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher.EnableRaisingEvents = true; } private void ReadConfigValues(object sender, FileSystemEventArgs e) { DateTime now = DateTime.Now; long num = now.Ticks - _lastReloadTime.Ticks; if (File.Exists(ConfigFileFullPath) && num >= 10000000) { try { VentureProgressionLogger.LogInfo((object)"Attempting to reload configuration..."); ((BaseUnityPlugin)this).Config.Reload(); } catch { VentureProgressionLogger.LogError((object)("There was an issue loading " + ConfigFileName)); return; } _lastReloadTime = now; KeyManager.Instance.UpdateAllConfigurations(); } } } public interface IProgressionConfiguration { bool GetBlockAllGlobalKeys(); string GetBlockedGlobalKeys(); string GetAllowedGlobalKeys(); string GetEnforcedGlobalKeys(); bool GetUsePrivateKeys(); string GetBlockedPrivateKeys(); string GetAllowedPrivateKeys(); string GetEnforcedPrivateKeys(); bool GetAdminBypass(); bool GetUseBlockedActionMessage(); string GetBlockedActionMessage(); bool GetUseBlockedActionEffect(); bool GetLockTaming(); string GetOverrideLockTamingDefaults(); bool GetLockGuardianPower(); bool GetLockBossSummons(); string GetOverrideLockBossSummonsDefaults(); bool GetUnlockBossSummonsOverTime(); int GetUnlockBossSummonsTime(); bool GetLockEquipment(); bool GetLockCrafting(); bool GetLockBuilding(); bool GetLockCooking(); bool GetLockEating(); string GetLockBoatsKey(); string GetLockPortalsKey(); string GetUnlockPortalCopperTinKey(); string GetUnlockPortalIronKey(); string GetUnlockPortalSilverKey(); string GetUnlockPortalBlackMetalKey(); string GetUnlockPortalFlametalKey(); string GetUnlockPortalDragonEggKey(); string GetUnlockPortalMistlandsKey(); string GetUnlockPortalAshlandsKey(); string GetUnlockPortalHildirChestsKey(); bool GetEnableSkillManager(); bool GetAllowSkillDrain(); bool GetUseAbsoluteSkillDrain(); int GetAbsoluteSkillDrain(); bool GetCompareAndSelectDrain(); bool GetCompareUseMinimumDrain(); bool GetOverrideMaximumSkillLevel(); int GetMaximumSkillLevel(); bool GetOverrideMinimumSkillLevel(); int GetMinimumSkillLevel(); bool GetUseBossKeysForSkillLevel(); int GetBossKeysSkillPerKey(); bool GetUnlockAllHaldorItems(); string GetHelmetYuleKey(); string GetHelmetDvergerKey(); string GetBeltStrengthKey(); string GetYmirRemainsKey(); string GetFishingRodKey(); string GetFishingBaitKey(); string GetThunderstoneKey(); string GetChickenEggKey(); string GetBarrelRingsKey(); bool GetUnlockAllHildirItems(); string GetCryptItemsKey(); string GetCaveItemsKey(); string GetTowerItemsKey(); bool GetUnlockAllBogWitchItems(); string GetScytheHandleKey(); bool GetUsePrivateRaids(); } public class ProgressionConfiguration : IProgressionConfiguration { private static IProgressionConfiguration _instance; public static IProgressionConfiguration Instance => _instance; static ProgressionConfiguration() { _instance = new ProgressionConfiguration(); } public ProgressionConfiguration() { } public ProgressionConfiguration(IProgressionConfiguration progressionConfiguration) { _instance = progressionConfiguration; } public bool GetBlockAllGlobalKeys() { return ProgressionPlugin.CE_BlockAllGlobalKeys.Value; } public string GetBlockedGlobalKeys() { return ProgressionPlugin.CE_BlockedGlobalKeys.Value; } public string GetAllowedGlobalKeys() { return ProgressionPlugin.CE_AllowedGlobalKeys.Value; } public string GetEnforcedGlobalKeys() { return ProgressionPlugin.CE_EnforcedGlobalKeys.Value; } public bool GetUsePrivateKeys() { return ProgressionPlugin.CE_UsePrivateKeys.Value; } public string GetBlockedPrivateKeys() { return ProgressionPlugin.CE_BlockedPrivateKeys.Value; } public string GetAllowedPrivateKeys() { return ProgressionPlugin.CE_AllowedPrivateKeys.Value; } public string GetEnforcedPrivateKeys() { return ProgressionPlugin.CE_EnforcedPrivateKeys.Value; } public bool GetAdminBypass() { return ProgressionPlugin.CE_AdminBypass.Value; } public bool GetUseBlockedActionMessage() { return ProgressionPlugin.CE_UseBlockedActionMessage.Value; } public string GetBlockedActionMessage() { return ProgressionPlugin.CE_BlockedActionMessage.Value; } public bool GetUseBlockedActionEffect() { return ProgressionPlugin.CE_UseBlockedActionEffect.Value; } public bool GetLockTaming() { if (Instance.GetAdminBypass() && SynchronizationManager.Instance.PlayerIsAdmin) { return false; } return ProgressionPlugin.CE_LockTaming.Value; } public string GetOverrideLockTamingDefaults() { return ProgressionPlugin.CE_OverrideLockTamingDefaults.Value; } public bool GetLockGuardianPower() { if (Instance.GetAdminBypass() && SynchronizationManager.Instance.PlayerIsAdmin) { return false; } return ProgressionPlugin.CE_LockGuardianPower.Value; } public bool GetLockBossSummons() { if (Instance.GetAdminBypass() && SynchronizationManager.Instance.PlayerIsAdmin) { return false; } return ProgressionPlugin.CE_LockBossSummons.Value; } public string GetOverrideLockBossSummonsDefaults() { return ProgressionPlugin.CE_OverrideLockBossSummonsDefaults.Value; } public bool GetUnlockBossSummonsOverTime() { return ProgressionPlugin.CE_UnlockBossSummonsOverTime.Value; } public int GetUnlockBossSummonsTime() { return ProgressionPlugin.CE_UnlockBossSummonsTime.Value; } public bool GetLockEquipment() { if (Instance.GetAdminBypass() && SynchronizationManager.Instance.PlayerIsAdmin) { return false; } return ProgressionPlugin.CE_LockEquipment.Value; } public bool GetLockCrafting() { if (Instance.GetAdminBypass() && SynchronizationManager.Instance.PlayerIsAdmin) { return false; } return ProgressionPlugin.CE_LockCrafting.Value; } public bool GetLockBuilding() { if (Instance.GetAdminBypass() && SynchronizationManager.Instance.PlayerIsAdmin) { return false; } return ProgressionPlugin.CE_LockBuilding.Value; } public bool GetLockCooking() { if (Instance.GetAdminBypass() && SynchronizationManager.Instance.PlayerIsAdmin) { return false; } return ProgressionPlugin.CE_LockCooking.Value; } public bool GetLockEating() { if (Instance.GetAdminBypass() && SynchronizationManager.Instance.PlayerIsAdmin) { return false; } return ProgressionPlugin.CE_LockEating.Value; } public string GetLockBoatsKey() { if (Instance.GetAdminBypass() && SynchronizationManager.Instance.PlayerIsAdmin) { return ""; } return ProgressionPlugin.CE_LockBoatsKey.Value; } public string GetLockPortalsKey() { if (Instance.GetAdminBypass() && SynchronizationManager.Instance.PlayerIsAdmin) { return ""; } return ProgressionPlugin.CE_LockPortalsKey.Value; } public string GetUnlockPortalCopperTinKey() { return ProgressionPlugin.CE_UnlockPortalCopperTinKey.Value; } public string GetUnlockPortalIronKey() { return ProgressionPlugin.CE_UnlockPortalIronKey.Value; } public string GetUnlockPortalSilverKey() { return ProgressionPlugin.CE_UnlockPortalSilverKey.Value; } public string GetUnlockPortalBlackMetalKey() { return ProgressionPlugin.CE_UnlockPortalBlackMetalKey.Value; } public string GetUnlockPortalFlametalKey() { return ProgressionPlugin.CE_UnlockPortalFlametalKey.Value; } public string GetUnlockPortalDragonEggKey() { return ProgressionPlugin.CE_UnlockPortalDragonEggKey.Value; } public string GetUnlockPortalMistlandsKey() { return ProgressionPlugin.CE_UnlockPortalMistlandsKey.Value; } public string GetUnlockPortalAshlandsKey() { return ProgressionPlugin.CE_UnlockPortalAshlandsKey.Value; } public string GetUnlockPortalHildirChestsKey() { return ProgressionPlugin.CE_UnlockPortalHildirChestsKey.Value; } public bool GetEnableSkillManager() { return ProgressionPlugin.CE_EnableSkillManager.Value; } public bool GetAllowSkillDrain() { return ProgressionPlugin.CE_AllowSkillDrain.Value; } public bool GetUseAbsoluteSkillDrain() { return ProgressionPlugin.CE_UseAbsoluteSkillDrain.Value; } public int GetAbsoluteSkillDrain() { return ProgressionPlugin.CE_AbsoluteSkillDrain.Value; } public bool GetCompareAndSelectDrain() { return ProgressionPlugin.CE_CompareAndSelectDrain.Value; } public bool GetCompareUseMinimumDrain() { return ProgressionPlugin.CE_CompareUseMinimumDrain.Value; } public bool GetOverrideMaximumSkillLevel() { return ProgressionPlugin.CE_OverrideMaximumSkillLevel.Value; } public int GetMaximumSkillLevel() { return ProgressionPlugin.CE_MaximumSkillLevel.Value; } public bool GetOverrideMinimumSkillLevel() { return ProgressionPlugin.CE_OverrideMinimumSkillLevel.Value; } public int GetMinimumSkillLevel() { return ProgressionPlugin.CE_MinimumSkillLevel.Value; } public bool GetUseBossKeysForSkillLevel() { return ProgressionPlugin.CE_UseBossKeysForSkillLevel.Value; } public int GetBossKeysSkillPerKey() { return ProgressionPlugin.CE_BossKeysSkillPerKey.Value; } public bool GetUnlockAllHaldorItems() { return ProgressionPlugin.CE_UnlockAllHaldorItems.Value; } public string GetHelmetYuleKey() { return ProgressionPlugin.CE_HelmetYuleKey.Value; } public string GetHelmetDvergerKey() { return ProgressionPlugin.CE_HelmetDvergerKey.Value; } public string GetBeltStrengthKey() { return ProgressionPlugin.CE_BeltStrengthKey.Value; } public string GetYmirRemainsKey() { return ProgressionPlugin.CE_YmirRemainsKey.Value; } public string GetFishingRodKey() { return ProgressionPlugin.CE_FishingRodKey.Value; } public string GetFishingBaitKey() { return ProgressionPlugin.CE_FishingBaitKey.Value; } public string GetThunderstoneKey() { return ProgressionPlugin.CE_ThunderstoneKey.Value; } public string GetChickenEggKey() { return ProgressionPlugin.CE_ChickenEggKey.Value; } public string GetBarrelRingsKey() { return ProgressionPlugin.CE_BarrelRingsKey.Value; } public bool GetUnlockAllHildirItems() { return ProgressionPlugin.CE_UnlockAllHildirItems.Value; } public string GetCryptItemsKey() { return ProgressionPlugin.CE_CryptItemsKey.Value; } public string GetCaveItemsKey() { return ProgressionPlugin.CE_CaveItemsKey.Value; } public string GetTowerItemsKey() { return ProgressionPlugin.CE_TowerItemsKey.Value; } public bool GetUnlockAllBogWitchItems() { return ProgressionPlugin.CE_UnlockAllBogWitchItems.Value; } public string GetScytheHandleKey() { return ProgressionPlugin.CE_ScytheHandleKey.Value; } public bool GetUsePrivateRaids() { return ProgressionPlugin.CE_UsePrivateRaids.Value; } } public class KeyManager : IKeyManager { [HarmonyPatch(typeof(Tameable), "DecreaseRemainingTime")] public static class Patch_Tameable_DecreaseRemainingTime { [HarmonyPriority(200)] private static void Prefix(Tameable __instance, ref float time) { if (ProgressionConfiguration.Instance.GetLockTaming() && (Object)(object)__instance.m_character != (Object)null && !Instance.HasTamingKey(Utils.GetPrefabName(((Component)__instance.m_character).gameObject))) { time = 0f; } } } [HarmonyPatch(typeof(ItemStand), "DelayedPowerActivation")] public static class Patch_ItemStand_DelayedPowerActivation { [HarmonyPriority(200)] private static bool Prefix(ItemStand __instance) { if (ProgressionConfiguration.Instance.GetLockGuardianPower()) { KeyManager instance = Instance; StatusEffect guardianPower = __instance.m_guardianPower; if (!instance.HasGuardianKey((guardianPower != null) ? ((Object)guardianPower).name : null)) { Instance.ApplyBlockedActionEffects(Player.m_localPlayer); return false; } } return true; } } [HarmonyPatch(typeof(Player), "ActivateGuardianPower")] public static class Patch_Player_ActivateGuardianPower { [HarmonyPriority(200)] private static bool Prefix(Player __instance, ref bool __result, ref bool __runOriginal) { if (!__runOriginal) { return false; } if (ProgressionConfiguration.Instance.GetLockGuardianPower() && !Instance.HasGuardianKey(__instance.m_guardianPower)) { Instance.ApplyBlockedActionEffects(Player.m_localPlayer); __result = false; return false; } return true; } } [HarmonyPatch(typeof(OfferingBowl), "InitiateSpawnBoss")] public static class Patch_OfferingBowl_InitiateSpawnBoss { [HarmonyPriority(200)] private static bool Prefix(OfferingBowl __instance) { if (ProgressionConfiguration.Instance.GetLockBossSummons() && (Object)(object)__instance.m_bossPrefab != (Object)null && !Instance.HasSummoningKey(Utils.GetPrefabName(__instance.m_bossPrefab.gameObject))) { Instance.ApplyBlockedActionEffects(Player.m_localPlayer); return false; } return true; } } [HarmonyPatch(typeof(Humanoid), "EquipItem")] public static class Patch_Humanoid_EquipItem { [HarmonyPriority(200)] private static bool Prefix(Humanoid __instance, ref bool __result, ItemData item) { if (item == null || (Object)(object)__instance != (Object)(object)Player.m_localPlayer) { return true; } if (ProgressionConfiguration.Instance.GetLockEquipment() && Instance.IsActionBlocked(item, item.m_quality, checkBossItems: true, checkMaterials: true, checkFood: false)) { Instance.ApplyBlockedActionEffects(Player.m_localPlayer); __result = false; return false; } return true; } } [HarmonyPatch(typeof(Inventory), "GetAmmoItem")] public static class Patch_Inventory_GetAmmoItem { private static void Postfix(Inventory __instance, ref ItemData __result) { if (__result != null && __instance == ((Humanoid)Player.m_localPlayer).GetInventory() && ProgressionConfiguration.Instance.GetLockEquipment() && Instance.IsActionBlocked(__result, __result.m_quality, checkBossItems: true, checkMaterials: true, checkFood: false)) { Instance.ApplyBlockedActionEffects(Player.m_localPlayer); __result = null; } } } [HarmonyPatch(typeof(Door), "HaveKey")] public static class Patch_Door_HaveKey { [HarmonyPriority(200)] private static void Postfix(Door __instance, ref bool __result) { if (__result && ProgressionConfiguration.Instance.GetLockEquipment() && (Object)(object)__instance.m_keyItem != (Object)null && !Instance.HasItemKey(Utils.GetPrefabName(((Component)__instance.m_keyItem).gameObject), checkBossItems: true, checkMaterials: false, checkFood: false)) { Instance.ApplyBlockedActionEffects(Player.m_localPlayer); __result = false; } } } [HarmonyPatch(typeof(InventoryGui), "DoCrafting")] public static class Patch_InventoryGui_DoCrafting { [HarmonyPriority(200)] private static bool Prefix(InventoryGui __instance) { bool flag = false; if ((Object)(object)__instance.m_craftRecipe?.m_craftingStation != (Object)null) { string prefabName = Utils.GetPrefabName(((Component)__instance.m_craftRecipe.m_craftingStation).gameObject); flag = prefabName.Equals("piece_cauldron") || prefabName.Equals("piece_preptable") || prefabName.Equals("piece_MeadCauldron"); } bool flag2 = ProgressionConfiguration.Instance.GetLockCrafting() && !flag; bool flag3 = ProgressionConfiguration.Instance.GetLockCooking() && flag; int qualityLevel = ProgressionAPI.GetQualityLevel(__instance.m_craftUpgradeItem); if ((flag2 || flag3) && Instance.IsActionBlocked(__instance.m_craftRecipe, qualityLevel, flag2, flag2, flag3)) { Instance.ApplyBlockedActionEffects(Player.m_localPlayer); return false; } return true; } } [HarmonyPatch(typeof(Player), "TryPlacePiece")] public static class Patch_Player_TryPlacePiece { [HarmonyPriority(200)] private static bool Prefix(ref bool __result, Piece piece) { if (ProgressionConfiguration.Instance.GetLockBuilding() && piece?.m_resources != null) { for (int i = 0; i < piece.m_resources.Length; i++) { if ((Object)(object)piece.m_resources[i]?.m_resItem != (Object)null && !Instance.HasItemKey(Utils.GetPrefabName(((Component)piece.m_resources[i].m_resItem).gameObject), checkBossItems: true, checkMaterials: true, checkFood: false)) { Instance.ApplyBlockedActionEffects(Player.m_localPlayer); __result = false; return false; } } } return true; } } [HarmonyPatch(typeof(CookingStation), "OnUseItem")] public static class Patch_CookingStation_OnUseItem { [HarmonyPriority(200)] private static bool Prefix(ItemData item, ref bool __result) { if (item != null && ProgressionConfiguration.Instance.GetLockCooking() && Instance.IsActionBlocked(item, item.m_quality, checkBossItems: false, checkMaterials: false, checkFood: true)) { Instance.ApplyBlockedActionEffects(Player.m_localPlayer); __result = false; return false; } return true; } } [HarmonyPatch(typeof(Fermenter), "AddItem")] public static class Patch_Fermenter_AddItem { [HarmonyPriority(200)] private static bool Prefix(Fermenter __instance, ItemData item, ref bool __result) { if (item != null && ProgressionConfiguration.Instance.GetLockCooking() && Instance.IsActionBlocked(item, item.m_quality, checkBossItems: false, checkMaterials: false, checkFood: true)) { Instance.ApplyBlockedActionEffects(Player.m_localPlayer); __result = false; return false; } return true; } } [HarmonyPatch(typeof(Player), "CanEat")] public static class Patch_Player_CanEat { [HarmonyPriority(200)] private static bool Prefix(ItemData item, ref bool __result) { if (item != null && ProgressionConfiguration.Instance.GetLockEating() && Instance.IsActionBlocked(item, item.m_quality, checkBossItems: false, checkMaterials: false, checkFood: true)) { Instance.ApplyBlockedActionEffects(Player.m_localPlayer); __result = false; return false; } return true; } } [HarmonyPatch(typeof(ShipControlls), "Interact")] public static class Patch_ShipControlls_Interact { private static bool Prefix() { if (!Instance.HasKey(ProgressionConfiguration.Instance.GetLockBoatsKey())) { Instance.ApplyBlockedActionEffects(Player.m_localPlayer); return false; } return true; } } [HarmonyPatch(typeof(TeleportWorld), "Teleport")] public static class Patch_TeleportWorld_Teleport { private static bool Prefix(Player player) { if ((Object)(object)player == (Object)(object)Player.m_localPlayer && !Instance.HasKey(ProgressionConfiguration.Instance.GetLockPortalsKey())) { Instance.ApplyBlockedActionEffects(Player.m_localPlayer); return false; } return true; } } [HarmonyPriority(600)] [HarmonyPatch(typeof(Inventory), "IsTeleportable")] public static class Patch_Inventory_IsTeleportable { private static void Postfix(Inventory __instance, ref bool __result) { if (__result) { return; } foreach (ItemData item in __instance.m_inventory) { if (!((Object)(object)item.m_dropPrefab == (Object)null) && !Instance.IsTeleportable(((Object)item.m_dropPrefab).name, item.m_shared.m_teleportable)) { return; } } __result = true; } } [HarmonyPatch(typeof(ZoneSystem), "SetGlobalKey", new Type[] { typeof(string) })] public static class Patch_ZoneSystem_SetGlobalKey { [HarmonyPriority(200)] private static bool Prefix(string name) { return Instance.SkipAddKeyMethod(name.ToLower()); } private static void Postfix(string name, bool __runOriginal) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) bool flag = __runOriginal; name = name.ToLower(); if ((Object)(object)Player.m_localPlayer != (Object)null && !Instance.BlockPrivateKey(name)) { flag = true; List<Player> list = new List<Player>(); Player.GetPlayersInRange(((Component)Player.m_localPlayer).transform.position, 100f, list); if (list != null && list.Count == 0) { ProgressionPlugin.VentureProgressionLogger.LogDebug((object)"No players in range to send key!"); } else { for (int i = 0; i < list.Count; i++) { string playerName = list[i].GetPlayerName(); ProgressionPlugin.VentureProgressionLogger.LogDebug((object)("Attempting to send private key: " + name + " to \"" + playerName + "\".")); Instance.SendPrivateKey(playerName, name); } } } else { ProgressionPlugin.VentureProgressionLogger.LogDebug((object)("Skipping adding private key: " + name + ".")); } if (flag) { Instance.UpdateSkillConfigurations(); } } } [HarmonyPatch(typeof(ZoneSystem), "RPC_SetGlobalKey")] public static class Patch_ZoneSystem_RPC_SetGlobalKey { [HarmonyPriority(200)] private static bool Prefix(string name) { ProgressionPlugin.VentureProgressionLogger.LogDebug((object)("RPC_SetGlobalKey called for: " + name + ".")); bool num = Instance.SkipAddKeyMethod(name.ToLower()); if (!num) { ZoneSystem.instance.SendGlobalKeys(ZRoutedRpc.Everybody); } return num; } } [HarmonyPatch(typeof(ZoneSystem), "RPC_GlobalKeys")] public static class Patch_ZoneSystem_RPC_GlobalKeys { private static void Postfix() { Instance.UpdateSkillConfigurations(); } } [HarmonyPatch(typeof(ZoneSystem), "GetGlobalKey", new Type[] { typeof(string) })] public static class Patch_ZoneSystem_GetGlobalKey { private static bool Prefix(string name, ref bool __result) { name = name.ToLower(); if (ProgressionConfiguration.Instance.GetUsePrivateKeys() && !ZNet.instance.IsDedicated() && !Instance.IsWorldModifier(name)) { __result = Instance.HasPrivateKey(name); return !__result; } return true; } } [HarmonyPatch(typeof(ZoneSystem), "GetGlobalKeys")] public static class Patch_ZoneSystem_GetGlobalKeys { private static void Postfix(ref List<string> __result) { if (ProgressionConfiguration.Instance.GetUsePrivateKeys() && !ZNet.instance.IsDedicated()) { List<string> list = new List<string>(Instance.PrivateKeysList); __result = ProgressionAPI.MergeLists(__result, list); } } } [HarmonyPatch(typeof(ZoneSystem), "RPC_RemoveGlobalKey")] public static class Patch_ZoneSystem_RPC_RemoveGlobalKey { private static void Postfix(string name) { ProgressionPlugin.VentureProgressionLogger.LogDebug((object)("RPC_RemoveGlobalKey called for: " + name + ".")); if (ProgressionConfiguration.Instance.GetUsePrivateKeys() && !ZNet.instance.IsDedicated()) { Instance.RemovePrivateKey(name); } } } [HarmonyPatch(typeof(Player), "Save")] public static class Patch_Player_Save { private static void Prefix(Player __instance) { if (!ProgressionAPI.IsInTheMainScene()) { Instance.ResetPlayer(); } else if (__instance.m_customData.ContainsKey("VV_PrivateKeys")) { __instance.m_customData["VV_PrivateKeys"] = Instance.GetPrivateKeysString(); } else { __instance.m_customData.Add("VV_PrivateKeys", Instance.GetPrivateKeysString()); } } } [HarmonyPatch(typeof(Player), "EquipInventoryItems")] public static class Patch_Player_EquipInventoryItems { private static void Prefix(Player __instance) { if (!ProgressionAPI.IsInTheMainScene()) { return; } ProgressionPlugin.VentureProgressionLogger.LogInfo((object)"Starting Player Key Management. Cleaning up private keys!"); Instance.ResetPlayer(); Instance.UpdateConfigurations(); HashSet<string> hashSet = new HashSet<string>(); if (__instance.m_customData.ContainsKey("VV_PrivateKeys")) { hashSet = ProgressionAPI.StringToSet(__instance.m_customData["VV_PrivateKeys"]); } foreach (string item in hashSet) { if (!Instance.BlockPrivateKey(item)) { Instance.PrivateKeysList.Add(item); } } foreach (string enforcedPrivateKeys in Instance.EnforcedPrivateKeysList) { Instance.PrivateKeysList.Add(enforcedPrivateKeys); } try { ZRoutedRpc.instance.Register<string>("VV_SetPrivateKey", (Action<long, string>)Instance.RPC_SetPrivateKey); ZRoutedRpc.instance.Register<string>("VV_RemovePrivateKey", (Action<long, string>)Instance.RPC_RemovePrivateKey); ZRoutedRpc.instance.Register("VV_ResetPrivateKeys", (Action<long>)Instance.RPC_ResetPrivateKeys); } catch { ProgressionPlugin.VentureProgressionLogger.LogDebug((object)"Player RPCs have already been registered. Skipping."); } Instance.SendPrivateKeysToServer(Instance.PrivateKeysList); Instance.UpdateSkillConfigurations(); } } [HarmonyPatch(typeof(ZoneSystem), "Load")] public static class Patch_ZoneSystem_Load { private static void Postfix() { if (!ZNet.instance.IsServer()) { return; } ProgressionPlugin.VentureProgressionLogger.LogInfo((object)"Starting Server Key Management. Cleaning up public keys!"); Instance.ResetConfigurations(); Instance.ResetServer(); Instance.UpdateConfigurations(); List<string> list = ProgressionAPI.GetGlobalKeys().ToList(); bool blockAllGlobalKeys = ProgressionConfiguration.Instance.GetBlockAllGlobalKeys(); for (int i = 0; i < list.Count; i++) { if (Instance.BlockGlobalKey(blockAllGlobalKeys, list[i])) { ZoneSystem.instance.m_globalKeys.Remove(list[i]); } } foreach (string enforcedGlobalKeys in Instance.EnforcedGlobalKeysList) { ZoneSystem.instance.m_globalKeys.Add(enforcedGlobalKeys); } if (ProgressionConfiguration.Instance.GetUsePrivateKeys()) { ZoneSystem.instance.m_globalKeysEnums.Add((GlobalKeys)13); } try { ZRoutedRpc.instance.Register("VV_ServerListKeys", (Action<long>)Instance.RPC_ServerListKeys); ZRoutedRpc.instance.Register<string, long>("VV_ServerSetPrivateKeys", (Action<long, string, long>)Instance.RPC_ServerSetPrivateKeys); ZRoutedRpc.instance.Register<string, long>("VV_ServerSetPrivateKey", (Action<long, string, long>)Instance.RPC_ServerSetPrivateKey); ZRoutedRpc.instance.Register<string, long>("VV_ServerRemovePrivateKey", (Action<long, string, long>)Instance.RPC_ServerRemovePrivateKey); ZRoutedRpc.instance.Register<string>("VV_SetPrivateKey", (Action<long, string>)Instance.RPC_SetPrivateKey); ZRoutedRpc.instance.Register<string>("VV_RemovePrivateKey", (Action<long, string>)Instance.RPC_RemovePrivateKey); ZRoutedRpc.instance.Register("VV_ResetPrivateKeys", (Action<long>)Instance.RPC_ResetPrivateKeys); } catch { ProgressionPlugin.VentureProgressionLogger.LogDebug((object)"Server RPCs have already been registered. Skipping."); } } } [HarmonyPatch(typeof(Terminal), "InitTerminal")] private static class Patch_Terminal_InitTerminal { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static ConsoleEvent <>9__1_0; public static ConsoleEvent <>9__1_1; public static ConsoleEvent <>9__1_2; public static ConsoleEvent <>9__1_3; public static ConsoleEvent <>9__1_4; public static ConsoleEvent <>9__1_5; public static ConsoleEvent <>9__1_6; public static ConsoleEvent <>9__1_7; public static ConsoleEvent <>9__1_8; internal void <Postfix>b__1_0(ConsoleEventArgs args) { if (args.Length >= 2) { ProgressionAPI.AddGlobalKey(args[1]); args.Context.AddString("Setting global key " + args[1] + "."); } else { args.Context.AddString("Syntax: setglobalkey [key]"); } } internal void <Postfix>b__1_1(ConsoleEventArgs args) { if (args.Length >= 2) { ProgressionAPI.RemoveGlobalKey(args[1]); args.Context.AddString("Removing global key " + args[1] + "."); } else { args.Context.AddString("Syntax: removeglobalkey [key]"); } } internal void <Postfix>b__1_2(ConsoleEventArgs args) { HashSet<string> globalKeys = ProgressionAPI.GetGlobalKeys(); args.Context.AddString($"Total Keys {globalKeys.Count}"); foreach (string item in globalKeys) { args.Context.AddString(item); } } internal void <Postfix>b__1_3(ConsoleEventArgs args) { ZoneSystem.instance.ResetGlobalKeys(); } internal void <Postfix>b__1_4(ConsoleEventArgs args) { if (args.Length >= 3) { string text = args[2]; for (int i = 3; i < args.Length; i++) { text = text + " " + args[i]; } Instance.AddPrivateKey(args[1], text); args.Context.AddString("Setting private key " + args[1] + " for player " + text + "."); } else if (args.Length == 2) { Instance.AddPrivateKey(args[1]); args.Context.AddString("Setting private key " + args[1] + "."); } else { args.Context.AddString("Syntax: setprivatekey [key]"); } } internal void <Postfix>b__1_5(ConsoleEventArgs args) { if (args.Length >= 3) { string text = args[2]; for (int i = 3; i < args.Length; i++) { text = text + " " + args[i]; } Instance.RemovePrivateKey(args[1], text); args.Context.AddString("Removing private key " + args[1] + " for player " + text + "."); } else if (args.Length == 2) { Instance.RemovePrivateKey(args[1]); args.Context.AddString("Removing private key " + args[1] + "."); } else { args.Context.AddString("Syntax: removeprivatekey [key] [optional: player name]"); } } internal void <Postfix>b__1_6(ConsoleEventArgs args) { if (args.Length >= 2) { string text = args[1]; for (int i = 2; i < args.Length; i++) { text = text + " " + args[i]; } Instance.ResetPrivateKeys(args[1]); args.Context.AddString("Private keys cleared for player " + text + "."); } else if (args.Length == 1) { Instance.ResetPrivateKeys(); args.Context.AddString("Private keys cleared"); } else { args.Context.AddString("Syntax: resetprivatekeys [optional: player name]"); } } internal void <Postfix>b__1_7(ConsoleEventArgs args) { args.Context.AddString($"Total Keys {Instance.PrivateKeysList.Count}"); foreach (string privateKeys in Instance.PrivateKeysList) { args.Context.AddString(privateKeys); } } internal void <Postfix>b__1_8(ConsoleEventArgs args) { if (ZNet.instance.IsServer()) { args.Context.AddString($"Total Players Recorded This Session: {Instance.ServerPrivateKeysList.Count}"); { foreach (KeyValuePair<long, HashSet<string>> serverPrivateKeys in Instance.ServerPrivateKeysList) { int num = serverPrivateKeys.Value?.Count ?? 0; args.Context.AddString($"Player {serverPrivateKeys.Key} has {num} recorded keys:"); if (serverPrivateKeys.Value == null) { continue; } foreach (string item in serverPrivateKeys.Value) { args.Context.AddString(item); } } return; } } args.Context.AddString("You are not the server, no data available client side. Printing key information to server logoutput.log file."); Instance.SendServerListKeys(); } } [HarmonyPriority(800)] private static void Prefix(out bool __state) { __state = Terminal.m_terminalInitialized; } private static void Postfix(bool __state) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Expected O, but got Unknown //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Expected O, but got Unknown //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Expected O, but got Unknown //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Expected O, but got Unknown //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Expected O, but got Unknown //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Expected O, but got Unknown //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Expected O, but got Unknown if (__state) { return; } ProgressionPlugin.VentureProgressionLogger.LogInfo((object)"Adding Terminal Commands for key management."); object obj = <>c.<>9__1_0; if (obj == null) { ConsoleEvent val = delegate(ConsoleEventArgs args) { if (args.Length >= 2) { ProgressionAPI.AddGlobalKey(args[1]); args.Context.AddString("Setting global key " + args[1] + "."); } else { args.Context.AddString("Syntax: setglobalkey [key]"); } }; <>c.<>9__1_0 = val; obj = (object)val; } new ConsoleCommand("setglobalkey", "[name]", (ConsoleEvent)obj, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj2 = <>c.<>9__1_1; if (obj2 == null) { ConsoleEvent val2 = delegate(ConsoleEventArgs args) { if (args.Length >= 2) { ProgressionAPI.RemoveGlobalKey(args[1]); args.Context.AddString("Removing global key " + args[1] + "."); } else { args.Context.AddString("Syntax: removeglobalkey [key]"); } }; <>c.<>9__1_1 = val2; obj2 = (object)val2; } new ConsoleCommand("removeglobalkey", "[name]", (ConsoleEvent)obj2, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj3 = <>c.<>9__1_2; if (obj3 == null) { ConsoleEvent val3 = delegate(ConsoleEventArgs args) { HashSet<string> globalKeys = ProgressionAPI.GetGlobalKeys(); args.Context.AddString($"Total Keys {globalKeys.Count}"); foreach (string item in globalKeys) { args.Context.AddString(item); } }; <>c.<>9__1_2 = val3; obj3 = (object)val3; } new ConsoleCommand("listglobalkeys", "", (ConsoleEvent)obj3, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj4 = <>c.<>9__1_3; if (obj4 == null) { ConsoleEvent val4 = delegate { ZoneSystem.instance.ResetGlobalKeys(); }; <>c.<>9__1_3 = val4; obj4 = (object)val4; } new ConsoleCommand("resetglobalkeys", "", (ConsoleEvent)obj4, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj5 = <>c.<>9__1_4; if (obj5 == null) { ConsoleEvent val5 = delegate(ConsoleEventArgs args) { if (args.Length >= 3) { string text3 = args[2]; for (int k = 3; k < args.Length; k++) { text3 = text3 + " " + args[k]; } Instance.AddPrivateKey(args[1], text3); args.Context.AddString("Setting private key " + args[1] + " for player " + text3 + "."); } else if (args.Length == 2) { Instance.AddPrivateKey(args[1]); args.Context.AddString("Setting private key " + args[1] + "."); } else { args.Context.AddString("Syntax: setprivatekey [key]"); } }; <>c.<>9__1_4 = val5; obj5 = (object)val5; } new ConsoleCommand("setprivatekey", "[name] [optional: player name]", (ConsoleEvent)obj5, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj6 = <>c.<>9__1_5; if (obj6 == null) { ConsoleEvent val6 = delegate(ConsoleEventArgs args) { if (args.Length >= 3) { string text2 = args[2]; for (int j = 3; j < args.Length; j++) { text2 = text2 + " " + args[j]; } Instance.RemovePrivateKey(args[1], text2); args.Context.AddString("Removing private key " + args[1] + " for player " + text2 + "."); } else if (args.Length == 2) { Instance.RemovePrivateKey(args[1]); args.Context.AddString("Removing private key " + args[1] + "."); } else { args.Context.AddString("Syntax: removeprivatekey [key] [optional: player name]"); } }; <>c.<>9__1_5 = val6; obj6 = (object)val6; } new ConsoleCommand("removeprivatekey", "[name] [optional: player name]", (ConsoleEvent)obj6, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj7 = <>c.<>9__1_6; if (obj7 == null) { ConsoleEvent val7 = delegate(ConsoleEventArgs args) { if (args.Length >= 2) { string text = args[1]; for (int i = 2; i < args.Length; i++) { text = text + " " + args[i]; } Instance.ResetPrivateKeys(args[1]); args.Context.AddString("Private keys cleared for player " + text + "."); } else if (args.Length == 1) { Instance.ResetPrivateKeys(); args.Context.AddString("Private keys cleared"); } else { args.Context.AddString("Syntax: resetprivatekeys [optional: player name]"); } }; <>c.<>9__1_6 = val7; obj7 = (object)val7; } new ConsoleCommand("resetprivatekeys", "[optional: player name]", (ConsoleEvent)obj7, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj8 = <>c.<>9__1_7; if (obj8 == null) { ConsoleEvent val8 = delegate(ConsoleEventArgs args) { args.Context.AddString($"Total Keys {Instance.PrivateKeysList.Count}"); foreach (string privateKeys in Instance.PrivateKeysList) { args.Context.AddString(privateKeys); } }; <>c.<>9__1_7 = val8; obj8 = (object)val8; } new ConsoleCommand("listprivatekeys", "", (ConsoleEvent)obj8, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj9 = <>c.<>9__1_8; if (obj9 == null) { ConsoleEvent val9 = delegate(ConsoleEventArgs args) { if (ZNet.instance.IsServer()) { args.Context.AddString($"Total Players Recorded This Session: {Instance.ServerPrivateKeysList.Count}"); { foreach (KeyValuePair<long, HashSet<string>> serverPrivateKeys in Instance.ServerPrivateKeysList) { int num = serverPrivateKeys.Value?.Count ?? 0; args.Context.AddString($"Player {serverPrivateKeys.Key} has {num} recorded keys:"); if (serverPrivateKeys.Value != null) { foreach (string item2 in serverPrivateKeys.Value) { args.Context.AddString(item2); } } } return; } } args.Context.AddString("You are not the server, no data available client side. Printing key information to server logoutput.log file."); Instance.SendServerListKeys(); }; <>c.<>9__1_8 = val9; obj9 = (object)val9; } new ConsoleCommand("listserverkeys", "", (ConsoleEvent)obj9, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); } } [HarmonyPatch(typeof(RandEventSystem), "RefreshPlayerEventData")] public static class Patch_RandEventSystem_RefreshPlayerEventData { private static bool Prefix() { //IL_0048: 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 (!ProgressionConfiguration.Instance.GetUsePrivateRaids() || !ProgressionConfiguration.Instance.GetUsePrivateKeys()) { return true; } RandEventSystem.s_randomEventNeedsRefresh = false; RandEventSystem.s_playerEventDatas.Clear(); if (!ZNet.instance.IsDedicated() && (Object)(object)Player.m_localPlayer != (Object)null) { RandEventSystem.s_playerEventDatas.Add(GetHostPlayerEventData()); } foreach (ZNetPeer peer in ZNet.instance.GetPeers()) { if (peer.IsReady()) { RandEventSystem.s_playerEventDatas.Add(GetPlayerEventData(peer)); } } return false; } } [HarmonyPatch(typeof(RandEventSystem), "HaveGlobalKeys")] public static class Patch_RandEventSystem_HaveGlobalKeys { private static bool Prefix(ref bool __result) { if (!ProgressionConfiguration.Instance.GetUsePrivateRaids() || !ProgressionConfiguration.Instance.GetUsePrivateKeys()) { return true; } __result = true; return false; } } [HarmonyPatch(typeof(Trader), "GetAvailableItems")] public static class Patch_Trader_GetAvailableItems { private static bool Prefix(Trader __instance, ref List<TradeItem> __result) { string prefabName = Utils.GetPrefabName(((Component)__instance).gameObject); if ((prefabName.Equals("Haldor") && ProgressionConfiguration.Instance.GetUnlockAllHaldorItems()) || (prefabName.Equals("Hildir") && ProgressionConfiguration.Instance.GetUnlockAllHildirItems()) || (prefabName.Equals("BogWitch") && ProgressionConfiguration.Instance.GetUnlockAllBogWitchItems())) { __result = new List<TradeItem>(__instance.m_items); return false; } return true; } } [HarmonyPatch(typeof(StoreGui), "SelectItem")] public static class Patch_StoreGui_SelectItem { private static void Prefix(StoreGui __instance, ref int index) { if (__instance.m_itemList.Count == 0) { index = -1; } } } [HarmonyPatch(typeof(Trader), "Start")] public static class Patch_Trader_Start { [HarmonyPriority(800)] private static void Postfix(Trader __instance) { string prefabName = Utils.GetPrefabName(((Component)__instance).gameObject); Dictionary<string, string> dictionary = null; if (prefabName.Equals("Haldor")) { dictionary = Instance.GetTraderConfiguration(__instance.m_items); } else if (prefabName.Equals("Hildir")) { dictionary = Instance.GetHildirConfiguration(__instance.m_items); } else if (prefabName.Equals("BogWitch")) { dictionary = Instance.GetBogWitchConfiguration(__instance.m_items); } if (dictionary == null) { return; } foreach (TradeItem item in __instance.m_items) { if ((Object)(object)item.m_prefab != (Object)null) { string prefabName2 = Utils.GetPrefabName(((Component)item.m_prefab).gameObject); if (dictionary.ContainsKey(prefabName2)) { item.m_requiredGlobalKey = dictionary[prefabName2]; } } } } } public Dictionary<string, string> HaldorOriginalItemsList; public Dictionary<string, string> HildirOriginalItemsList; public Dictionary<string, string> BogWitchOriginalItemsList; public const string BOSS_KEY_MEADOW = "defeated_eikthyr"; public const string BOSS_KEY_BLACKFOREST = "defeated_gdking"; public const string BOSS_KEY_SWAMP = "defeated_bonemass"; public const string BOSS_KEY_MOUNTAIN = "defeated_dragon"; public const string BOSS_KEY_PLAIN = "defeated_goblinking"; public const string BOSS_KEY_MISTLAND = "defeated_queen"; public const string BOSS_KEY_ASHLAND = "defeated_fader"; public const string HILDIR_KEY_CRYPT = "hildir1"; public const string HILDIR_KEY_CAVE = "hildir2"; public const string HILDIR_KEY_TOWER = "hildir3"; public const int TOTAL_BOSSES = 7; public readonly Dictionary<string, int> BossKeyOrderList = new Dictionary<string, int> { { "", 0 }, { "defeated_eikthyr", 1 }, { "defeated_gdking", 2 }, { "defeated_bonemass", 3 }, { "defeated_dragon", 4 }, { "defeated_goblinking", 5 }, { "defeated_queen", 6 }, { "defeated_fader", 7 } }; public readonly Dictionary<string, string> GuardianKeysList = new Dictionary<string, string> { { "GP_Eikthyr", "defeated_eikthyr" }, { "GP_TheElder", "defeated_gdking" }, { "GP_Bonemass", "defeated_bonemass" }, { "GP_Moder", "defeated_dragon" }, { "GP_Yagluth", "defeated_goblinking" }, { "GP_Queen", "defeated_queen" }, { "GP_Fader", "defeated_fader" } }; public readonly Dictionary<string, string> BossItemKeysList = new Dictionary<string, string> { { "HardAntler", "defeated_eikthyr" }, { "CryptKey", "defeated_gdking" }, { "Wishbone", "defeated_bonemass" }, { "DragonTear", "defeated_dragon" }, { "YagluthDrop", "defeated_goblinking" }, { "DvergrKey", "defeated_goblinking" }, { "QueenDrop", "defeated_queen" }, { "FaderDrop", "defeated_fader" } }; public readonly Dictionary<string, string> MaterialKeysList = new Dictionary<string, string> { { "BjornHide", "defeated_eikthyr" }, { "BjornPaw", "defeated_eikthyr" }, { "Chitin", "defeated_eikthyr" }, { "Copper", "defeated_eikthyr" }, { "Bronze", "defeated_eikthyr" }, { "BronzeNails", "defeated_eikthyr" }, { "FineWood", "defeated_eikthyr" }, { "SerpentScale", "defeated_eikthyr" }, { "Tin", "defeated_eikthyr" }, { "TrollHide", "defeated_eikthyr" }, { "Chain", "defeated_gdking" }, { "ElderBark", "defeated_gdking" }, { "Iron", "defeated_gdking" }, { "IronNails", "defeated_gdking" }, { "Ooze", "defeated_gdking" }, { "Root", "defeated_gdking" }, { "SharpeningStone", "defeated_gdking" }, { "FreezeGland", "defeated_bonemass" }, { "JuteRed", "defeated_bonemass" }, { "Obsidian", "defeated_bonemass" }, { "Silver", "defeated_bonemass" }, { "WolfHairBundle", "defeated_bonemass" }, { "WolfPelt", "defeated_bonemass" }, { "WolfClaw", "defeated_bonemass" }, { "WolfFang", "defeated_bonemass" }, { "BlackMetal", "defeated_dragon" }, { "Tar", "defeated_dragon" }, { "Needle", "defeated_dragon" }, { "LinenThread", "defeated_dragon" }, { "LoxPelt", "defeated_dragon" }, { "TrophyBjornUndead", "defeated_dragon" }, { "UndeadBjornRibcage", "defeated_dragon" }, { "Bilebag", "defeated_goblinking" }, { "BlackMarble", "defeated_goblinking" }, { "BlackCore", "defeated_goblinking" }, { "Carapace", "defeated_goblinking" }, { "DvergrKeyFragment", "defeated_goblinking" }, { "Eitr", "defeated_goblinking" }, { "JuteBlue", "defeated_goblinking" }, { "Sap", "defeated_goblinking" }, { "ScaleHide", "defeated_goblinking" }, { "Wisp", "defeated_goblinking" }, { "YggdrasilWood", "defeated_goblinking" }, { "AskBladder", "defeated_queen" }, { "AskHide", "defeated_queen" }, { "BellFragment", "defeated_queen" }, { "Blackwood", "defeated_queen" }, { "BonemawSerpentTooth", "defeated_queen" }, { "CelestialFeather", "defeated_queen" }, { "CharcoalResin", "defeated_queen" }, { "CharredBone", "defeated_queen" }, { "CharredCogwheel", "defeated_queen" }, { "FlametalNew", "defeated_queen" }, { "GemstoneBlue", "defeated_queen" }, { "GemstoneGreen", "defeated_queen" }, { "GemstoneRed", "defeated_queen" }, { "Grausten", "defeated_queen" }, { "MoltenCore", "defeated_queen" }, { "MorgenSinew", "defeated_queen" }, { "MorgenHeart", "defeated_queen" }, { "ProustitePowder", "defeated_queen" }, { "SulfurStone", "defeated_queen" } }; public readonly Dictionary<string, string> FoodKeysList = new Dictionary<string, string> { { "BjornMeat", "defeated_eikthyr" }, { "CookedBjornMeat", "defeated_eikthyr" }, { "Blueberries", "defeated_eikthyr" }, { "Carrot", "defeated_eikthyr" }, { "Entrails", "defeated_eikthyr" }, { "FishCooked", "defeated_eikthyr" }, { "MushroomYellow", "defeated_eikthyr" }, { "Thistle", "defeated_eikthyr" }, { "Bloodbag", "defeated_gdking" }, { "Ooze", "defeated_gdking" }, { "SerpentMeat", "defeated_gdking" }, { "SerpentMeatCooked", "defeated_gdking" }, { "Turnip", "defeated_gdking" }, { "FreezeGland", "defeated_bonemass" }, { "Onion", "defeated_bonemass" }, { "WolfMeat", "defeated_bonemass" }, { "CookedWolfMeat", "defeated_bonemass" }, { "Barley", "defeated_dragon" }, { "BarleyFlour", "defeated_dragon" }, { "BreadDough", "defeated_dragon" }, { "Bread", "defeated_dragon" }, { "ChickenEgg", "defeated_dragon" }, { "CookedEgg", "defeated_dragon" }, { "ChickenMeat", "defeated_dragon" }, { "CookedChickenMeat", "defeated_dragon" }, { "Cloudberry", "defeated_dragon" }, { "FishAndBread", "defeated_dragon" }, { "LoxMeat", "defeated_dragon" }, { "LoxPie", "defeated_dragon" }, { "CookedLoxMeat", "defeated_dragon" }, { "MushroomBzerker", "defeated_dragon" }, { "FragrantBundle", "defeated_dragon" }, { "SpiceMountains", "defeated_dragon" }, { "BugMeat", "defeated_goblinking" }, { "CookedBugMeat", "defeated_goblinking" }, { "GiantBloodSack", "defeated_goblinking" }, { "HareMeat", "defeated_goblinking" }, { "CookedHareMeat", "defeated_goblinking" }, { "HoneyGlazedChicken", "defeated_goblinking" }, { "MagicallyStuffedShroom", "defeated_goblinking" }, { "MeatPlatter", "defeated_goblinking" }, { "MisthareSupreme", "defeated_goblinking" }, { "MushroomJotunPuffs", "defeated_goblinking" }, { "RoyalJelly", "defeated_goblinking" }, { "Sap", "defeated_goblinking" }, { "SpicePlains", "defeated_goblinking" }, { "AsksvinMeat", "defeated_queen" }, { "CookedAsksvinMeat", "defeated_queen" }, { "BoneMawSerpentMeat", "defeated_queen" }, { "CookedBoneMawSerpentMeat", "defeated_queen" }, { "Fiddleheadfern", "defeated_queen" }, { "MushroomSmokePuff", "defeated_queen" }, { "PiquantPie", "defeated_queen" }, { "RoastedCrustPie", "defeated_queen" }, { "Vineberry", "defeated_queen" }, { "VoltureEgg", "defeated_queen" }, { "VoltureMeat", "defeated_queen" }, { "CookedVoltureMeat", "defeated_queen" }, { "SpiceMistlands", "defeated_queen" }, { "SpiceAshlands", "defeated_fader" } }; private static int _cachedPublicBossKeys; private static int _cachedPrivateBossKeys; protected static readonly IKeyManager _instance; public const string RPCNAME_ServerListKeys = "VV_ServerListKeys"; public const string RPCNAME_ServerSetPrivateKeys = "VV_ServerSetPrivateKeys"; public const string RPCNAME_ServerSetPrivateKey = "VV_ServerSetPrivateKey"; public const string RPCNAME_ServerRemovePrivateKey = "VV_ServerRemovePrivateKey"; public const string RPCNAME_SetPrivateKey = "VV_SetPrivateKey"; public const string RPCNAME_RemovePrivateKey = "VV_RemovePrivateKey"; public const string RPCNAME_ResetPrivateKeys = "VV_ResetPrivateKeys"; public const string PLAYER_SAVE_KEY = "VV_PrivateKeys"; private HashSet<string> IgnoredModKeys = new HashSet<string> { "season_winter", "season_fall", "season_summer", "season_spring" }; private const string Haldor = "Haldor"; private const string Hildir = "Hildir"; private const string BogWitch = "BogWitch"; public string BlockedGlobalKeys { get; protected set; } public string AllowedGlobalKeys { get; protected set; } public string EnforcedGlobalKeys { get; protected set; } public string BlockedPrivateKeys { get; protected set; } public string AllowedPrivateKeys { get; protected set; } public string EnforcedPrivateKeys { get; protected set; } public string TamingKeys { get; protected set; } public string SummoningKeys { get; protected set; } public HashSet<string> BlockedGlobalKeysList { get; protected set; } public HashSet<string> AllowedGlobalKeysList { get; protected set; } public HashSet<string> EnforcedGlobalKeysList { get; protected set; } public HashSet<string> BlockedPrivateKeysList { get; protected set; } public HashSet<string> AllowedPrivateKeysList { get; protected set; } public HashSet<string> EnforcedPrivateKeysList { get; protected set; } public Dictionary<string, string> TamingKeysList { get; protected set; } public Dictionary<string, string> SummoningKeysList { get; protected set; } public static KeyManager Instance => _instance as KeyManager; public HashSet<string> PrivateKeysList { get; protected set; } public Dictionary<long, HashSet<string>> ServerPrivateKeysList { get; protected set; } public void UpdateAllConfigurations() { UpdateConfigurations(); UpdateSkillConfigurations(); } public void UpdateSkillConfigurations() { if (ProgressionConfiguration.Instance.GetEnableSkillManager()) { _cachedPublicBossKeys = CountPublicBossKeys(); _cachedPrivateBossKeys = CountPrivateBossKeys(); SkillsManager.Instance.UpdateCache(); } } protected void ResetConfigurations() { BlockedGlobalKeys = ""; AllowedGlobalKeys = ""; EnforcedGlobalKeys = ""; BlockedGlobalKeysList = new HashSet<string>(); AllowedGlobalKeysList = new HashSet<string>(); EnforcedGlobalKeysList = new HashSet<string>(); BlockedPrivateKeys = ""; AllowedPrivateKeys = ""; EnforcedPrivateKeys = ""; BlockedPrivateKeysList = new HashSet<string>(); AllowedPrivateKeysList = new HashSet<string>(); EnforcedPrivateKeysList = new HashSet<string>(); TamingKeys = null; SummoningKeys = null; } protected void ResetServer() { ServerPrivateKeysList = new Dictionary<long, HashSet<string>>(); } protected void ResetPlayer() { PrivateKeysList = new HashSet<string>(); _cachedPublicBossKeys = 0; _cachedPrivateBossKeys = 0; } protected int CountPrivateBossKeys() { int num = 0; foreach (string key in BossKeyOrderList.Keys) { if (!Utility.IsNullOrWhiteSpace(key) && PrivateKeysList.Contains(key)) { num++; } } return num; } private int CountPublicBossKeys() { int num = 0; foreach (string key in BossKeyOrderList.Keys) { if (!Utility.IsNullOrWhiteSpace(key) && HasGlobalKey(key)) { num++; } } return num; } private void UpdateConfigurations() { UpdateGlobalKeyConfiguration(ProgressionConfiguration.Instance.GetBlockedGlobalKeys(), ProgressionConfiguration.Instance.GetAllowedGlobalKeys()); UpdatePrivateKeyConfiguration(ProgressionConfiguration.Instance.GetBlockedPrivateKeys(), ProgressionConfiguration.Instance.GetAllowedPrivateKeys()); UpdateEnforcedKeyConfiguration(ProgressionConfiguration.Instance.GetEnforcedGlobalKeys(), ProgressionConfiguration.Instance.GetEnforcedPrivateKeys()); UpdateTamingConfiguration(ProgressionConfiguration.Instance.GetOverrideLockTamingDefaults()); UpdateSummoningConfiguration(ProgressionConfiguration.Instance.GetOverrideLockBossSummonsDefaults()); } protected void UpdateGlobalKeyConfiguration(string blockedGlobalKeys, string allowedGlobalKeys) { if (BlockedGlobalKeys == null || !BlockedGlobalKeys.Equals(blockedGlobalKeys)) { BlockedGlobalKeys = blockedGlobalKeys; BlockedGlobalKeysList = ProgressionAPI.StringToSet(blockedGlobalKeys); } if (AllowedGlobalKeys == null || !AllowedGlobalKeys.Equals(allowedGlobalKeys)) { AllowedGlobalKeys = allowedGlobalKeys; AllowedGlobalKeysList = ProgressionAPI.StringToSet(allowedGlobalKeys); } } protected void UpdatePrivateKeyConfiguration(string blockedPrivateKeys, string allowedPrivateKeys) { if (BlockedPrivateKeys == null || !BlockedPrivateKeys.Equals(blockedPrivateKeys)) { BlockedPrivateKeys = blockedPrivateKeys; BlockedPrivateKeysList = ProgressionAPI.StringToSet(blockedPrivateKeys); } if (AllowedPrivateKeys == null || !AllowedPrivateKeys.Equals(allowedPrivateKeys)) { AllowedPrivateKeys = allowedPrivateKeys; AllowedPrivateKeysList = ProgressionAPI.StringToSet(allowedPrivateKeys); } } protected void UpdateEnforcedKeyConfiguration(string enforcedGlobalKeys, string enforcedPrivateKeys) { if (EnforcedGlobalKeys == null || !EnforcedGlobalKeys.Equals(enforcedGlobalKeys)) { EnforcedGlobalKeys = enforcedGlobalKeys; EnforcedGlobalKeysList = ProgressionAPI.StringToSet(enforcedGlobalKeys); } if (EnforcedPrivateKeys == null || !EnforcedPrivateKeys.Equals(enforcedPrivateKeys)) { EnforcedPrivateKeys = enforcedPrivateKeys; EnforcedPrivateKeysList = ProgressionAPI.StringToSet(enforcedPrivateKeys); } } protected void UpdateTamingConfiguration(string tamingString) { if (TamingKeys == null || !TamingKeys.Equals(tamingString)) { TamingKeys = tamingString; if (Utility.IsNullOrWhiteSpace(TamingKeys)) { TamingKeysList = new Dictionary<string, string> { { "Wolf", "defeated_bonemass" }, { "Lox", "defeated_dragon" }, { "Asksvin", "defeated_queen" } }; } else { TamingKeysList = ProgressionAPI.StringToDictionary(tamingString); } } } protected void UpdateSummoningConfiguration(string summoningString) { if (SummoningKeys == null || !SummoningKeys.Equals(summoningString)) { SummoningKeys = summoningString; if (Utility.IsNullOrWhiteSpace(SummoningKeys)) { SummoningKeysList = new Dictionary<string, string> { { "Eikthyr", "" }, { "gd_king", "defeated_eikthyr" }, { "Bonemass", "defeated_gdking" }, { "Dragon", "defeated_bonemass" }, { "GoblinKing", "defeated_dragon" }, { "SeekerQueen", "defeated_goblinking" }, { "Fader", "defeated_queen" } }; } else { SummoningKeysList = ProgressionAPI.StringToDictionary(summoningString); } } } protected Dictionary<string, string> GetTraderConfiguration(List<TradeItem> items) { SetOriginalItemsList(ref HaldorOriginalItemsList, items); Dictionary<string, string> dictionary = new Dictionary<string, string>(); if (!Utility.IsNullOrWhiteSpace(ProgressionConfiguration.Instance.GetHelmetYuleKey())) { dictionary.Add("HelmetYule", ProgressionConfiguration.Instance.GetHelmetYuleKey()); } if (!Utility.IsNullOrWhiteSpace(ProgressionConfiguration.Instance.GetHelmetDvergerKey())) { dictionary.Add("HelmetDverger", ProgressionConfiguration.Instance.GetHelmetDvergerKey()); } if (!Utility.IsNullOrWhiteSpace(ProgressionConfiguration.Instance.GetBeltStrengthKey())) { dictionary.Add("BeltStrength", ProgressionConfiguration.Instance.GetBeltStrengthKey()); } if (!Utility.IsNullOrWhiteSpace(ProgressionConfiguration.Instance.GetYmirRemainsKey())) { dictionary.Add("YmirRemains", ProgressionConfiguration.Instance.GetYmirRemainsKey()); } if (!Utility.IsNullOrWhiteSpace(ProgressionConfiguration.Instance.GetFishingRodKey())) { dictionary.Add("FishingRod", ProgressionConfiguration.Instance.GetFishingRodKey()); } if (!Utility.IsNullOrWhiteSpace(ProgressionConfiguration.Instance.GetFishingBaitKey())) { dictionary.Add("FishingBait", ProgressionConfiguration.Instance.GetFishingBaitKey()); } if (!Utility.IsNullOrWhiteSpace(ProgressionConfiguration.Instance.GetThunderstoneKey())) { dictionary.Add("Thunderstone", ProgressionConfiguration.Instance.GetThunderstoneKey()); } if (!Utility.IsNullOrWhiteSpace(ProgressionConfiguration.Instance.GetChickenEggKey())) { dictionary.Add("ChickenEgg", ProgressionConfiguration.Instance.GetChickenEggKey()); } if (!Utility.IsNullOrWhiteSpace(ProgressionConfiguration.Instance.GetBarrelRingsKey())) { dictionary.Add("BarrelRings", ProgressionConfiguration.Instance.GetBarrelRingsKey()); } Dictionary<string, string> dictionary2 = new Dictionary<string, string>(); foreach (KeyValuePair<string, string> haldorOriginalItems in HaldorOriginalItemsList) { if (dictionary.ContainsKey(haldorOriginalItems.Key)) { dictionary2.Add(haldorOriginalItems.Key, dictionary[haldorOriginalItems.Key]); } else { dictionary2.Add(haldorOriginalItems.Key, haldorOriginalItems.Value); } } return dictionary2; } protected void SetOriginalItemsList(ref Dictionary<string, string> cache, List<TradeItem> items) { if (cache != null) { return; } cache = new Dictionary<string, string>(); foreach (TradeItem item in items) { if ((Object)(object)item.m_prefab != (Object)null) { string prefabName = Utils.GetPrefabName(((Component)item.m_prefab).gameObject); if (!cache.ContainsKey(prefabName)) { cache.Add(prefabName, item.m_requiredGlobalKey.ToLower()); } } } } protected Dictionary<string, string> GetHildirConfiguration(List<TradeItem> items) { SetOriginalItemsList(ref HildirOriginalItemsList, items); Dictionary<string, string> dictionary = new Dictionary<string, string>(); if (!Utility.IsNullOrWhiteSpace(ProgressionConfiguration.Instance.GetCryptItemsKey())) { dictionary.Add("hildir1", ProgressionConfiguration.Instance.GetCryptItemsKey()); } if (!Utility.IsNullOrWhiteSpace(ProgressionConfiguration.Instance.GetCaveItemsKey())) { dictionary.Add("hildir2", ProgressionConfiguration.Instance.GetCaveItemsKey()); } if (!Utility.IsNullOrWhiteSpace(ProgressionConfiguration.Instance.GetTowerItemsKey())) { dictionary.Add("hildir3", ProgressionConfiguration.Instance.GetTowerItemsKey()); } Dictionary<string, string> dictionary2 = new Dictionary<string, string>(); foreach (KeyValuePair<string, string> hildirOriginalItems in HildirOriginalItemsList) { if (dictionary.ContainsKey(hildirOriginalItems.Value)) { dictionary2.Add(hildirOriginalItems.Key, dictionary[hildirOriginalItems.Value]); } else { dictionary2.Add(hildirOriginalItems.Key, hildirOriginalItems.Value); } } return dictionary2; } protected Dictionary<string, string> GetBogWitchConfiguration(List<TradeItem> items) { SetOriginalItemsList(ref BogWitchOriginalItemsList, items); Dictionary<string, string> dictionary = new Dictionary<string, string>(); foreach (KeyValuePair<string, string> bogWitchOriginalItems in BogWitchOriginalItemsList) { if (bogWitchOriginalItems.Key.Equals("ScytheHandle") && !Utility.IsNullOrWhiteSpace(ProgressionConfiguration.Instance.GetScytheHandleKey())) { dictionary.Add(bogWitchOriginalItems.Key, ProgressionConfiguration.Instance.GetScytheHandleKey()); } else { dictionary.Add(bogWitchOriginalItems.Key, bogWitchOriginalItems.Value); } } return dictionary; } public int GetPublicBossKeysCount() { return _cachedPublicBossKeys; } public int GetPrivateBossKeysCount() { return _cachedPrivateBossKeys; } private bool HasTamingKey(string creature) { if (Utility.IsNullOrWhiteSpace(creature)) { return true; } if (TamingKeysList.ContainsKey(creature)) { return HasKey(TamingKeysList[creature]); } return true; } private bool HasSummoningKey(string creature) { if (Utility.IsNullOrWhiteSpace(creature)) { return true; } if (SummoningKeysList.ContainsKey(creature)) { if (HasKey(SummoningKeysList[creature])) { if (ProgressionConfiguration.Instance.GetUnlockBossSummonsOverTime()) { return SummoningTimeReached(SummoningKeysList[creature], ProgressionAPI.GetGameDay()); } return true; } return false; } return true; } protected bool SummoningTimeReached(string key, int gameDay) { if (BossKeyOrderList.ContainsKey(key)) { int num = BossKeyOrderList[key] * ProgressionConfiguration.Instance.GetUnlockBossSummonsTime(); return gameDay >= num; } return true; } protected bool HasGuardianKey(string guardianPower) { if (Utility.IsNullOrWhiteSpace(guardianPower)) { return true; } string[] array = guardianPower.Split(new char[1] { ',' }); foreach (string key in array) { if (GuardianKeysList.ContainsKey(key) && !HasKey(GuardianKeysList[key])) { return false; } } return true; } private bool HasItemKey(string item, bool checkBossItems, bool checkMaterials, bool checkFood) { if (Utility.IsNullOrWhiteSpace(item)) { return true; } if ((checkBossItems && BossItemKeysList.ContainsKey(item) && !HasKey(BossItemKeysList[item])) || (checkMaterials && MaterialKeysList.ContainsKey(item) && !HasKey(MaterialKeysList[item])) || (checkFood && FoodKeysList.ContainsKey(item) && !HasKey(FoodKeysList[item]))) { return false; } return true; } private bool IsActionBlocked(ItemData item, int quality, bool checkBossItems, bool checkMaterials, bool checkFood) { if (item == null || (Object)(object)item.m_dropPrefab == (Object)null) { return false; } if (!Instance.HasItemKey(Utils.GetPrefabName(item.m_dropPrefab), checkBossItems, checkMaterials, checkFood)) { return true; } Recipe recipe = ObjectDB.instance.GetRecipe(item); return IsActionBlocked(recipe, quality, checkBossItems, checkMaterials, checkFood); } private bool IsActionBlocked(Recipe recipe, int quality, bool checkBossItems, bool checkMaterials, bool checkFood) { if ((Object)(object)recipe == (Object)null) { return false; } if (recipe.m_requireOnlyOneIngredient) { for (int i = 1; i <= quality; i++) { bool flag = false; for (int j = 0; j < recipe.m_resources.Length; j++) { if (!((Object)(object)recipe.m_resources[j].m_resItem == (Object)null) && recipe.m_resources[j].GetAmount(i) > 0 && Instance.HasItemKey(Utils.GetPrefabName(((Component)recipe.m_resources[j].m_resItem).gameObject), checkBossItems, checkMaterials, checkFood)) { flag = true; break; } } if (!flag) { return true; } } } else { for (int k = 0; k < recipe.m_resources.Length; k++) { if ((Object)(object)recipe.m_resources[k].m_resItem == (Object)null) { continue; } for (int l = 1; l <= quality; l++) { if (recipe.m_resources[k].GetAmount(l) > 0) { if (Instance.HasItemKey(Utils.GetPrefabName(((Component)recipe.m_resources[k].m_resItem).gameObject), checkBossItems, checkMaterials, checkFood)) { break; } return true; } } } } return false; } private void ApplyBlockedActionEffects(Player player) { if (!((Object)(object)player != (Object)null) || !((Object)(object)((Character)player).GetSEMan()?.m_nview != (Object)null) || ((Character)player).GetSEMan().m_nview.m_zdo == null) { return; } if (ProgressionConfiguration.Instance.GetUseBlockedActionEffect()) { SEMan sEMan = ((Character)player).GetSEMan(); if (sEMan != null) { sEMan.AddStatusEffect(StringExtensionMethods.GetStableHashCode("Burning"), false, 0, 0f); } } if (ProgressionConfiguration.Instance.GetUseBlockedActionMessage()) { ((Character)player).Message((MessageType)2, ProgressionConfiguration.Instance.GetBlockedActionMessage(), 0, (Sprite)null); } } public bool IsTeleportable(string name, bool teleportable) { if (teleportable) { return true; } string text = null; switch (name) { case "TinOre": case "Bronze": case "Copper": case "CopperOre": case "CopperScrap": case "BronzeScrap": case "Tin": text = ProgressionConfiguration.Instance.GetUnlockPortalCopperTinKey(); break; case "IronScrap": case "IronOre": case "Ironpit": case "Iron": text = ProgressionConfiguration.Instance.GetUnlockPortalIronKey(); break; case "Silver": case "SilverOre": text = ProgressionConfiguration.Instance.GetUnlockPortalSilverKey(); break; case "BlackMetalScrap": case "BlackMetal": text = ProgressionConfiguration.Instance.GetUnlockPortalBlackMetalKey(); break; case "FlametalOre": case "FlametalNew": case "Flametal": case "FlametalOreNew": text = ProgressionConfiguration.Instance.GetUnlockPortalFlametalKey(); break; case "DragonEgg": text = ProgressionConfiguration.Instance.GetUnlockPortalDragonEggKey(); break; case "MechanicalSpring": case "DvergrNeedle": text = ProgressionConfiguration.Instance.GetUnlockPortalMistlandsKey(); break; case "chest_hildir1": case "chest_hildir2": case "chest_hildir3": text = ProgressionConfiguration.Instance.GetUnlockPortalHildirChestsKey(); break; case "CharredCogwheel": text = ProgressionConfiguration.Instance.GetUnlockPortalAshlandsKey(); break; } if (!Utility.IsNullOrWhiteSpace(text)) { return HasKey(text); } return teleportable; } static KeyManager() { _cachedPublicBossKeys = 0; _cachedPrivateBossKeys = 0; _instance = new KeyManager(); } protected KeyManager() { ResetServer(); ResetPlayer(); } private bool IsWorldModifier(string key) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Invalid comparison between Unknown and I4 string text = default(string); GlobalKeys val = default(GlobalKeys); ZoneSystem.GetKeyValue(key, ref text, ref val); if ((int)val < 32 || (int)val == 38) { return true; } return false; } public bool BlockGlobalKey(bool blockAll, string globalKey) { if (Utility.IsNullOrWhiteSpace(globalKey)) { return true; } if (IsWorldModifier(globalKey) || IgnoredModKeys.Contains(globalKey)) { ProgressionPlugin.VentureProgressionLogger.LogDebug((object)(globalKey + " is non-qualifying, can not block.")); return false; } if (blockAll) { if (AllowedGlobalKeysList.Count > 0) { return !AllowedGlobalKeysList.Contains(globalKey); } return true; } if (BlockedGlobalKeysList.Count > 0) { return BlockedGlobalKeysList.Contains(globalKey); } return false; } public bool BlockPrivateKey(string key) { if (ProgressionConfiguration.Instance.GetUsePrivateKeys() && !ZNet.instance.IsDedicated()) { return PrivateKeyIsBlocked(key); } return true; } protected bool PrivateKeyIsBlocked(string key) { if (Utility.IsNullOrWhiteSpace(key) || IsWorldModifier(key) || IgnoredModKeys.Contains(key)) { return true; } if (BlockedPrivateKeysList.Count > 0) { return BlockedPrivateKeysList.Contains(key); } if (AllowedPrivateKeysList.Count > 0) { return !AllowedPrivateKeysList.Contains(key); } return false; } public bool HasPrivateKey(string key) { if (Utility.IsNullOrWhiteSpace(key)) { return true; } return PrivateKeysList.Contains(key); } public bool HasKey(string key) { if (!ProgressionConfiguration.Instance.GetUsePrivateKeys() || !HasPrivateKey(key)) { return HasGlobalKey(key); } return true; } public bool HasGlobalKey(string key) { if (Utility.IsNullOrWhiteSpace(key)) { return true; } return ProgressionAPI.GetGlobalKey(key); } private void AddPrivateKey(string key) { if (!Utility.IsNullOrWhiteSpace(key)) { key = key.ToLower(); if (PrivateKeysList.Add(key)) { ProgressionPlugin.VentureProgressionLogger.LogDebug((object)("Adding Private Key " + key + ".")); SendPrivateKeyToServer(key); Instance.UpdateSkillConfigurations(); } } } private void AddPrivateKey(string key, string playerName) { if (Utility.IsNullOrWhiteSpace(playerName)) { AddPrivateKey(key); } else { SendPrivateKey(playerName, key); } } private void SendPrivateKey(string playerName, string key) { long playerZDOID = ProgressionAPI.GetPlayerZDOID(playerName); if (playerZDOID != 0L) { ZRoutedRpc.instance.InvokeRoutedRPC(playerZDOID, "VV_SetPrivateKey", new object[1] { key }); } } private void RPC_SetPrivateKey(long sender, string key) { ProgressionPlugin.VentureProgressionLogger.LogDebug((object)$"Got private key {key} from {sender}: adding to list."); AddPrivateKey(key); } private void RemovePrivateKey(string key) { key = key.ToLower(); if (PrivateKeysList.Remove(key)) { ProgressionPlugin.VentureProgressionLogger.LogDebug((object)("Removing Private Key " + key + ".")); SendRemovePrivateKeyFromServer(key); Instance.UpdateSkillConfigurations(); } } private void RemovePrivateKey(string key, string playerName) { if (Utility.IsNullOrWhiteSpace(playerName)) { RemovePrivateKey(key); } else { SendRemovePrivateKey(playerName, key); } } private void SendRemovePrivateKey(string playerName, string key) { long playerZDOID = ProgressionAPI.GetPlayerZDOID(playerName); if (playerZDOID != 0L) { ZRoutedRpc.instance.InvokeRoutedRPC(playerZDOID, "VV_RemovePrivateKey", new object[1] { key }); } } private void RPC_RemovePrivateKey(long sender, string key) { ProgressionPlugin.VentureProgressionLogger.LogDebug((object)$"Got private key {key} from {sender}: removing from list."); RemovePrivateKey(key); } private void ResetPrivateKeys() { ProgressionPlugin.VentureProgressionLogger.LogDebug((object)"Resetting Private Keys."); PrivateKeysList = new HashSet<string>(); SendPrivateKeysToServer(PrivateKeysList); Instance.UpdateSkillConfigurations(); } private void ResetPrivateKeys(string playerName) { if (Utility.IsNullOrWhiteSpace(playerName)) { ResetPrivateKeys(); } else { SendResetPrivateKeys(playerName); } } private void SendResetPrivateKeys(string playerName) { long playerZDOID = ProgressionAPI.GetPlayerZDOID(playerName); if (playerZDOID != 0L) { ZRoutedRpc.instance.InvokeRoutedRPC(playerZDOID, "VV_ResetPrivateKeys", Array.Empty<object>()); } } private void RPC_ResetPrivateKeys(long sender) { ProgressionPlugin.VentureProgressionLogger.LogDebug((object)$"Got reset keys command from {sender}."); ResetPrivateKeys(); } private void SendPrivateKeysToServer(HashSet<string> keys) { string text = string.Join<string>(",", (IEnumerable<string>)keys); ZRoutedRpc.instance.InvokeRoutedRPC("VV_ServerSetPrivateKeys", new object[2] { text, ProgressionAPI.GetLocalPlayerID() }); } private void RPC_ServerSetPrivateKeys(long sender, string keys, long playerID) { HashSet<string> hashSet = ProgressionAPI.StringToSet(keys); ProgressionPlugin.VentureProgressionLogger.LogDebug((object)("Updating Server Player: " + $"{hashSet.Count} keys found for player: \"{ProgressionAPI.GetPlayerName(playerID)}\".")); SetServerKeys(playerID, hashSet); } private void SendPrivateKeyToServer(string key) { ZRoutedRpc.instance.InvokeRoutedRPC("VV_ServerSetPrivateKey", new object[2] { key, ProgressionAPI.GetLocalPlayerID() }); } private void RPC_ServerSetPrivateKey(long sender, string key, long playerID) { ProgressionPlugin.VentureProgressionLogger.LogDebug((object)("Updating Server Player: Adding key " + key + " for player: \"" + ProgressionAPI.GetPlayerName(playerID) + "\".")); SetServerKey(playerID, key); } private void SendRemovePrivateKeyFromServer(string key) { ZRoutedRpc.instance.InvokeRoutedRPC("VV_ServerRemovePrivateKey", new object[2] { key, ProgressionAPI.GetLocalPlayerID() }); } private