diff --git a/.gitignore b/.gitignore index 019b9b03..cb4a536e 100644 --- a/.gitignore +++ b/.gitignore @@ -76,3 +76,14 @@ crashlytics-build.properties /valheim_Data/BepInEx-out/plugins/EpicLoot/enchantcosts.json /valheim_Data/BepInEx-out/plugins/EpicLoot/adventuredata.json /valheim_Data/BepInEx-out/plugins/EpicLoot/abilities.json +ValheimUnity/Assets/ExternalLibraries/EpicLoot-UnityLib.dll + +# Unity +ValheimUnity/AssetBundles +ValheimUnity/Assets/ExternalLibraries/*.dll +ValheimUnity/Assets/ExternalLibraries/valheim/*.dll +ValheimUnity/UserSettings + +# Manual adds +Common +ValheimMods.sln \ No newline at end of file diff --git a/AdvancedPortals/AdvancedPortals-1.0.1.zip b/AdvancedPortals/AdvancedPortals-1.0.1.zip deleted file mode 100644 index 06cf6936..00000000 Binary files a/AdvancedPortals/AdvancedPortals-1.0.1.zip and /dev/null differ diff --git a/AdvancedPortals/AdvancedPortals-1.0.2.zip b/AdvancedPortals/AdvancedPortals-1.0.2.zip deleted file mode 100644 index 427099ec..00000000 Binary files a/AdvancedPortals/AdvancedPortals-1.0.2.zip and /dev/null differ diff --git a/AdvancedPortals/AdvancedPortals-1.0.3.zip b/AdvancedPortals/AdvancedPortals-1.0.3.zip deleted file mode 100644 index 52449c4a..00000000 Binary files a/AdvancedPortals/AdvancedPortals-1.0.3.zip and /dev/null differ diff --git a/AdvancedPortals/AdvancedPortals-1.0.zip b/AdvancedPortals/AdvancedPortals-1.0.zip deleted file mode 100644 index affb23ae..00000000 Binary files a/AdvancedPortals/AdvancedPortals-1.0.zip and /dev/null differ diff --git a/AdvancedPortals/AdvancedPortals.cs b/AdvancedPortals/AdvancedPortals.cs index dfd82c29..de093283 100644 --- a/AdvancedPortals/AdvancedPortals.cs +++ b/AdvancedPortals/AdvancedPortals.cs @@ -29,7 +29,7 @@ public class AdvancedPortals : BaseUnityPlugin { public const string PluginId = "randyknapp.mods.advancedportals"; public const string DisplayName = "Advanced Portals"; - public const string Version = "1.0.8"; + public const string Version = "1.0.11"; public static readonly string[] _portalPrefabs = { "portal_ancient", "portal_obsidian", "portal_blackmarble" }; public static readonly List RegisteredPrefabs = new List(); @@ -250,7 +250,6 @@ private static List MakeRecipeFromConfig(string portalN private void OnDestroy() { _instance = null; - _harmony?.UnpatchSelf(); } private ConfigEntry SyncedConfig(string group, string configName, T value, string description, bool synchronizedSetting = true) => SyncedConfig(group, configName, value, new ConfigDescription(description), synchronizedSetting); @@ -389,7 +388,7 @@ public static void TryRegisterObjects() return; } - ObjectDB.instance.UpdateItemHashes(); + ObjectDB.instance.UpdateRegisters(); var pieceTables = new List(); foreach (var itemPrefab in ObjectDB.instance.m_items) diff --git a/AdvancedPortals/AdvancedPortals.csproj b/AdvancedPortals/AdvancedPortals.csproj index f85d1274..666ded5b 100644 --- a/AdvancedPortals/AdvancedPortals.csproj +++ b/AdvancedPortals/AdvancedPortals.csproj @@ -1,6 +1,7 @@  + Debug AnyCPU @@ -9,7 +10,8 @@ Properties AdvancedPortals AdvancedPortals - v4.6.2 + v4.7.2 + 10.0 512 true @@ -33,60 +35,9 @@ true - - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\BepInEx\core\0Harmony.dll - - - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\valheim_Data\Managed\publicized_assemblies\assembly_utils_publicized.dll - - - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\valheim_Data\Managed\publicized_assemblies\assembly_valheim_publicized.dll - - - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\BepInEx\core\BepInEx.dll - - - ..\Libs\ServerSync.dll - - - - - - - - - - - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\unstripped_corlib\UnityEngine.dll - - - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\unstripped_corlib\UnityEngine.AssetBundleModule.dll - - - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\unstripped_corlib\UnityEngine.AudioModule.dll - - - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\unstripped_corlib\UnityEngine.CoreModule.dll - - - False - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\unstripped_corlib\UnityEngine.ImageConversionModule.dll - - - False - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\unstripped_corlib\UnityEngine.PhysicsModule.dll - - - False - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\unstripped_corlib\UnityEngine.TextRenderingModule.dll - - - - - + - @@ -102,15 +53,11 @@ - + - - - - diff --git a/AdvancedPortals/CHANGELOG.md b/AdvancedPortals/CHANGELOG.md new file mode 100644 index 00000000..345d4cbd --- /dev/null +++ b/AdvancedPortals/CHANGELOG.md @@ -0,0 +1,39 @@ +## 1.0.11 +* Update for Valheim version 0.219.13 Bog Witch. + +## 1.0.10 +* ServerSync Update fixing a multiplayer issue + +## 1.0.9 +* Update for 0.217.24 - Hildr's Request + +## 1.0.8 +* Fixing the Portal Saving issue with the changes that were presented in a recent update. +* This now adds the Custom Portal Prefabs to the PortalPrefab list during Game.Awake reducing the need to patch any ZDOMan stuff. + +## 1.0.7 +* Hildir's Request Update 0.217.14 + +## 1.0.6 +* Restored Portal Connections on Dedicated Servers. + +## 1.0.5 +* Updated Portal Connection logic which was preventing Advanced Portals from connecting + +## 1.0.4 +* Updates for 0.216.9 Valheim + +## 1.0.3 +* Vapok fixed a bug that makes Adventure Backpacks work with Advanced Portals + +## 1.0.2 +* Added bronze to Ancient portal transport list (how could I forget?) +* Updated to support other mods that extend the inventory (Thanks Vapok) + +## 1.0.1 +* Added compatibility with AnyPortal and TargetPortal +* Fixed a bug with Obsidian and Black Marble portal recipes +* Added 5 BlackMetal to the default recipe for Black Marble portals (delete your config to automatically use the new recipe) + +## 1.0.0 +* Initial Release \ No newline at end of file diff --git a/AdvancedPortals/Properties/AssemblyInfo.cs b/AdvancedPortals/Properties/AssemblyInfo.cs index c62fdc1a..135ff500 100644 --- a/AdvancedPortals/Properties/AssemblyInfo.cs +++ b/AdvancedPortals/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.8")] -[assembly: AssemblyFileVersion("1.0.8")] +[assembly: AssemblyVersion("1.0.11")] +[assembly: AssemblyFileVersion("1.0.11")] diff --git a/AdvancedPortals/README.md b/AdvancedPortals/README.md index c7ad672e..a2e8984c 100644 --- a/AdvancedPortals/README.md +++ b/AdvancedPortals/README.md @@ -1,8 +1,9 @@ -# AdvancedPortals -Author: RandyKnapp -Source: [Github](https://github.com/RandyKnapp/ValheimMods/tree/main/AdvancedPortals) -Discord: [RandyKnapp's Mod Community](https://discord.gg/randyknappmods) -Patreon: [Randy's Patreon](https://www.patreon.com/randyknapp) +# Advanced Portals + +Author: [RandyKnapp](https://discord.gg/ZNhYeavv3C) +Source: [Github](https://github.com/RandyKnapp/ValheimMods/tree/main/AdvancedPortals/) +Patreon: [patreon.com/randyknapp](https://www.patreon.com/randyknapp) +Discord: [RandyKnapp's Mod Community](https://discord.gg/ZNhYeavv3C) Adds three new portals to provide a lore-friendly and balanced way to reduce the item-transport slog! @@ -42,24 +43,4 @@ Includes ServerSync. ## Installation: * Nexus: Drop the AdvancedPortals.dll right into your BepInEx/plugins folder - * ThunderStore: Use r2modman to install, or manually drop the dll into your BepInEx/plugins folder - -### Changelist: - -#### 1.0.6 -* Restored Portal Connections on Dedicated Servers. -#### 1.0.5 - * Updated Portal Connection logic which was preventing Advanced Portals from connecting -#### 1.0.4 - * Updates for Valheim 0.217.5 -#### 1.0.3 - * Vapok fixed a bug that makes Adventure Backpacks work with Advanced Portals -#### 1.0.2 - * Added bronze to Ancient portal transport list (how could I forget?) - * Updated to support other mods that extend the inventory (Thanks Vapok) -#### 1.0.1 - * Added compatibility with AnyPortal and TargetPortal - * Fixed a bug with Obsidian and Black Marble portal recipes - * Added 5 BlackMetal to the default recipe for Black Marble portals (delete your config to automatically use the new recipe) -#### 1.0.0 - * Initial Release \ No newline at end of file + * ThunderStore: Use r2modman to install, or manually drop the dll into your BepInEx/plugins folder \ No newline at end of file diff --git a/AdvancedPortals/AdvancedPortals-Header.png b/AdvancedPortals/image/AdvancedPortals-Header.png similarity index 100% rename from AdvancedPortals/AdvancedPortals-Header.png rename to AdvancedPortals/image/AdvancedPortals-Header.png diff --git a/AdvancedPortals/AdvancedPortals-Tile.png b/AdvancedPortals/image/AdvancedPortals-Tile.png similarity index 100% rename from AdvancedPortals/AdvancedPortals-Tile.png rename to AdvancedPortals/image/AdvancedPortals-Tile.png diff --git a/AdvancedPortals/Screenshots/Screenshot 2023-01-11 145724.png b/AdvancedPortals/image/Screenshot 2023-01-11 145724.png similarity index 100% rename from AdvancedPortals/Screenshots/Screenshot 2023-01-11 145724.png rename to AdvancedPortals/image/Screenshot 2023-01-11 145724.png diff --git a/AdvancedPortals/Screenshots/Screenshot 2023-01-11 15.02.48.png b/AdvancedPortals/image/Screenshot 2023-01-11 15.02.48.png similarity index 100% rename from AdvancedPortals/Screenshots/Screenshot 2023-01-11 15.02.48.png rename to AdvancedPortals/image/Screenshot 2023-01-11 15.02.48.png diff --git a/AdvancedPortals/Screenshots/Screenshot 2023-01-11 150221.png b/AdvancedPortals/image/Screenshot 2023-01-11 150221.png similarity index 100% rename from AdvancedPortals/Screenshots/Screenshot 2023-01-11 150221.png rename to AdvancedPortals/image/Screenshot 2023-01-11 150221.png diff --git a/AdvancedPortals/manifest.json b/AdvancedPortals/manifest.json deleted file mode 100644 index ef4320dc..00000000 --- a/AdvancedPortals/manifest.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "AdvancedPortals", - "version_number": "1.0.8", - "website_url": "https://github.com/RandyKnapp/ValheimMods/tree/main/AdvancedPortals", - "description": "Add new, lore-friendly and balanced portals to allow some items to be teleported.", - "dependencies": [] -} \ No newline at end of file diff --git a/AdvancedPortals/AddPortals.cs b/AdvancedPortals/src/AddPortals.cs similarity index 100% rename from AdvancedPortals/AddPortals.cs rename to AdvancedPortals/src/AddPortals.cs diff --git a/AdvancedPortals/AdvancedPortal.cs b/AdvancedPortals/src/AdvancedPortal.cs similarity index 92% rename from AdvancedPortals/AdvancedPortal.cs rename to AdvancedPortals/src/AdvancedPortal.cs index 519ad892..fededd98 100644 --- a/AdvancedPortals/AdvancedPortal.cs +++ b/AdvancedPortals/src/AdvancedPortal.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using UnityEngine; namespace AdvancedPortals diff --git a/AdvancedPortals/Teleport_Patch.cs b/AdvancedPortals/src/Teleport_Patch.cs similarity index 100% rename from AdvancedPortals/Teleport_Patch.cs rename to AdvancedPortals/src/Teleport_Patch.cs diff --git a/AdvancedPortals/icon.png b/AdvancedPortals/thunderstore/icon.png similarity index 100% rename from AdvancedPortals/icon.png rename to AdvancedPortals/thunderstore/icon.png diff --git a/AdvancedPortals/thunderstore/manifest.json b/AdvancedPortals/thunderstore/manifest.json new file mode 100644 index 00000000..461bc4be --- /dev/null +++ b/AdvancedPortals/thunderstore/manifest.json @@ -0,0 +1,9 @@ +{ + "name": "AdvancedPortals", + "version_number": "1.0.10", + "website_url": "https://github.com/RandyKnapp/ValheimMods/tree/main/AdvancedPortals", + "description": "Add new, lore-friendly and balanced portals to allow some items to be teleported.", + "dependencies": [ + "denikson-BepInExPack_Valheim-5.4.2200" + ] +} \ No newline at end of file diff --git a/Common/Common.projitems b/Common/Common.projitems index bd2b60c1..c0d416dd 100644 --- a/Common/Common.projitems +++ b/Common/Common.projitems @@ -9,15 +9,6 @@ Common - - - - - - - - - - + \ No newline at end of file diff --git a/Common/ConfigPositionedElement.cs b/Common/src/ConfigPositionedElement.cs similarity index 100% rename from Common/ConfigPositionedElement.cs rename to Common/src/ConfigPositionedElement.cs diff --git a/Common/Consumables.cs b/Common/src/Consumables.cs similarity index 100% rename from Common/Consumables.cs rename to Common/src/Consumables.cs diff --git a/Common/GameObjectExtensions.cs b/Common/src/GameObjectExtensions.cs similarity index 100% rename from Common/GameObjectExtensions.cs rename to Common/src/GameObjectExtensions.cs diff --git a/Common/GotDestroyed.cs b/Common/src/GotDestroyed.cs similarity index 100% rename from Common/GotDestroyed.cs rename to Common/src/GotDestroyed.cs diff --git a/Common/MultiValueDictionary.cs b/Common/src/MultiValueDictionary.cs similarity index 100% rename from Common/MultiValueDictionary.cs rename to Common/src/MultiValueDictionary.cs diff --git a/Common/PlayerExtensions.cs b/Common/src/PlayerExtensions.cs similarity index 100% rename from Common/PlayerExtensions.cs rename to Common/src/PlayerExtensions.cs diff --git a/Common/PrefabCreator.cs b/Common/src/PrefabCreator.cs similarity index 100% rename from Common/PrefabCreator.cs rename to Common/src/PrefabCreator.cs diff --git a/Common/SerializableVector3.cs b/Common/src/SerializableVector3.cs similarity index 100% rename from Common/SerializableVector3.cs rename to Common/src/SerializableVector3.cs diff --git a/Common/Utils.cs b/Common/src/Utils.cs similarity index 100% rename from Common/Utils.cs rename to Common/src/Utils.cs diff --git a/Common/WeightedRandomCollection.cs b/Common/src/WeightedRandomCollection.cs similarity index 100% rename from Common/WeightedRandomCollection.cs rename to Common/src/WeightedRandomCollection.cs diff --git a/ConsoleHelper/ConsoleHelper.csproj b/ConsoleHelper/ConsoleHelper.csproj index e1f2160a..759c0dd0 100644 --- a/ConsoleHelper/ConsoleHelper.csproj +++ b/ConsoleHelper/ConsoleHelper.csproj @@ -1,6 +1,7 @@  + Debug AnyCPU @@ -9,7 +10,8 @@ Properties ConsoleHelper ConsoleHelper - v4.6.1 + v4.7.2 + 10.0 512 true @@ -31,31 +33,9 @@ prompt 4 - - - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\BepInEx\core\0Harmony.dll - - - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\valheim_Data\Managed\publicized_assemblies\assembly_valheim_publicized.dll - - - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\BepInEx\core\BepInEx.dll - - - - - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\unstripped_corlib\UnityEngine.dll - - - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\unstripped_corlib\UnityEngine.CoreModule.dll - - - - xcopy "$(TargetDir)$(TargetFileName)" "C:\Program Files (x86)\Steam\steamapps\common\Valheim\BepInEx\plugins\" /q /y /i - \ No newline at end of file diff --git a/CreatureLevelAndLootControl/API.cs b/CreatureLevelAndLootControl/API.cs index bc4fe7b8..15583204 100644 --- a/CreatureLevelAndLootControl/API.cs +++ b/CreatureLevelAndLootControl/API.cs @@ -1,55 +1,42 @@ using HarmonyLib; using System.Reflection; using System.Reflection.Emit; +using JetBrains.Annotations; #nullable enable namespace CreatureLevelControl { + [PublicAPI] public static class API { - private static readonly Assembly? targetAssembly; - static API() + public static bool IsLoaded() { - if (!((API.targetAssembly = API.LoadAssembly()) != (Assembly) null)) - return; - Harmony harmony = new Harmony("org.bepinex.plugins.creaturelevelcontrol.API"); - foreach (MethodInfo original in ((IEnumerable) typeof (API).GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Static | BindingFlags.Public)).Where((Func) (m => m.Name != "IsLoaded" && m.Name != "LoadAssembly"))) - harmony.Patch((MethodBase) original, transpiler: new HarmonyMethod(AccessTools.DeclaredMethod(typeof (API), "transpiler"))); + return false; } - private static IEnumerable transpiler( - IEnumerable _, - MethodBase original) + public static bool IsEnabled() { - System.Type[] parameters = ((IEnumerable) original.GetParameters()).Select((Func) (p => - { - System.Type type = p.ParameterType; - if (type.Assembly == Assembly.GetExecutingAssembly()) - type = API.targetAssembly.GetType(type.FullName); - return type; - })).ToArray(); - MethodBase originalMethod = (MethodBase) API.targetAssembly.GetType("CreatureLevelControl.API").GetMethod(original.Name, parameters); - for (int i = 0; i < parameters.Length; ++i) - yield return new CodeInstruction(OpCodes.Ldarg, (object) i); - yield return new CodeInstruction(OpCodes.Call, (object) originalMethod); - yield return new CodeInstruction(OpCodes.Ret); + return false; } - public static Assembly? LoadAssembly() => ((IEnumerable) AppDomain.CurrentDomain.GetAssemblies()).SingleOrDefault((Func) (a => a.GetName().Name == "CreatureLevelControl")); - - public static bool IsLoaded() => API.LoadAssembly() != (Assembly) null; - - public static bool IsEnabled() => false; - - public static bool IsInfusionEnabled() => false; - - public static bool IsExtraEffectEnabled() => false; - - public static bool IsAffixEnabled() => false; - - public static int GetWorldLevel() => 0; + public static bool IsInfusionEnabled() + { + return false; + } + public static bool IsExtraEffectEnabled() + { + return false; + } + public static bool IsAffixEnabled() + { + return false; + } + public static int GetWorldLevel() + { + return 0; + } public static float[] LevelProbabilities( Character? character, @@ -66,16 +53,20 @@ public static int LevelRand(Character character) return UnityEngine.Random.Range(0, 10) != 0 ? 2 : 3; } - public static bool HasAffixBoss(Character character) => false; - + public static bool HasAffixBoss(Character character) + { + return false; + } public static BossAffix GetAffixBoss(Character character) => BossAffix.None; public static void SetAffixBoss(Character character, BossAffix affix) { } - public static bool HasExtraEffectCreature(Character character) => false; - + public static bool HasExtraEffectCreature(Character character) + { + return false; + } public static CreatureExtraEffect GetExtraEffectCreature(Character character) => CreatureExtraEffect.None; public static void SetExtraEffectCreature(Character character) @@ -86,8 +77,10 @@ public static void SetExtraEffectCreature(Character character, CreatureExtraEffe { } - public static bool HasInfusionCreature(Character character) => false; - + public static bool HasInfusionCreature(Character character) + { + return false; + } public static CreatureInfusion GetInfusionCreature(Character character) => CreatureInfusion.None; public static void SetInfusionCreature(Character character) @@ -98,7 +91,7 @@ public static void SetInfusionCreature(Character character, CreatureInfusion inf { } - public static Character? GetTwinBoss(Character boss) => (Character) null; + public static Character? GetTwinBoss(Character boss) => null; public static bool DropItemOnDeath(ItemDrop.ItemData item) => !item.m_shared.m_questItem && !item.m_equipped; } diff --git a/CreatureLevelAndLootControl/CreatureLevelAndLootControl.csproj b/CreatureLevelAndLootControl/CreatureLevelAndLootControl.csproj index 43fdb804..a60952ca 100644 --- a/CreatureLevelAndLootControl/CreatureLevelAndLootControl.csproj +++ b/CreatureLevelAndLootControl/CreatureLevelAndLootControl.csproj @@ -1,36 +1,11 @@ - enable disable CreatureLevelControlAPI CreatureLevelControl latestmajor - net461;net462 + net472 - - - M:\Code\VapokModBase\References\BepInEx\5.4.2101\BepInEx\core\0Harmony.dll - - - M:\Code\VapokModBase\References\Valheim\0.216.8\assembly_guiutils_publicized.dll - - - M:\Code\VapokModBase\References\Valheim\0.216.8\assembly_utils_publicized.dll - - - M:\Code\VapokModBase\References\Valheim\0.216.8\assembly_valheim_publicized.dll - - - ..\..\VapokModBase\References\CLLC\CreatureLevelControl.dll - - - - - M:\Code\VapokModBase\References\BepInEx\5.4.2101\unstripped_corlib\UnityEngine.dll - - - M:\Code\VapokModBase\References\BepInEx\5.4.2101\unstripped_corlib\UnityEngine.CoreModule.dll - - + diff --git a/DvergerColor/DvergerColor.cs b/DvergerColor/DvergerColor.cs index b8e03ee0..295327c3 100644 --- a/DvergerColor/DvergerColor.cs +++ b/DvergerColor/DvergerColor.cs @@ -6,7 +6,7 @@ namespace DvergerColor { - [BepInPlugin(PluginId, "Dverger Color", "1.0.3")] + [BepInPlugin(PluginId, "Dverger Color", "1.0.6")] [BepInProcess("valheim.exe")] public class DvergerColor : BaseUnityPlugin { @@ -51,10 +51,5 @@ private void Awake() _harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), PluginId); } - - private void OnDestroy() - { - _harmony.UnpatchSelf(); - } } } diff --git a/DvergerColor/ImprovedDvergerCirclet-1.0.2.zip b/DvergerColor/ImprovedDvergerCirclet-1.0.2.zip deleted file mode 100644 index 3d80f9bf..00000000 Binary files a/DvergerColor/ImprovedDvergerCirclet-1.0.2.zip and /dev/null differ diff --git a/DvergerColor/ImprovedDvergerCirclet.csproj b/DvergerColor/ImprovedDvergerCirclet.csproj index 9a778cfb..55b29ef9 100644 --- a/DvergerColor/ImprovedDvergerCirclet.csproj +++ b/DvergerColor/ImprovedDvergerCirclet.csproj @@ -1,6 +1,7 @@  + Debug AnyCPU @@ -9,7 +10,8 @@ Properties DvergerColor ImprovedDvergerCirclet - v4.6.1 + v4.7.2 + 10.0 512 true @@ -34,54 +36,13 @@ - + - + - - - False - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\BepInEx\core\0Harmony.dll - - - False - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\valheim_Data\Managed\publicized_assemblies\assembly_utils_publicized.dll - - - False - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\valheim_Data\Managed\publicized_assemblies\assembly_valheim_publicized.dll - - - False - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\BepInEx\core\BepInEx.dll - - - False - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\unstripped_corlib\UnityEngine.dll - - - False - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\unstripped_corlib\UnityEngine.CoreModule.dll - - - False - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\unstripped_corlib\UnityEngine.ImageConversionModule.dll - - - False - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\unstripped_corlib\UnityEngine.InputLegacyModule.dll - - - False - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\unstripped_corlib\UnityEngine.TextRenderingModule.dll - - - - xcopy "$(TargetDir)\$(TargetFileName)" "C:\Program Files (x86)\Steam\steamapps\common\Valheim\BepInEx\plugins\" /q /y /i - \ No newline at end of file diff --git a/DvergerColor/ImprovedDvergerCirclet.zip b/DvergerColor/ImprovedDvergerCirclet.zip deleted file mode 100644 index f839a13a..00000000 Binary files a/DvergerColor/ImprovedDvergerCirclet.zip and /dev/null differ diff --git a/DvergerColor/Properties/AssemblyInfo.cs b/DvergerColor/Properties/AssemblyInfo.cs index c24de2c7..d4d57241 100644 --- a/DvergerColor/Properties/AssemblyInfo.cs +++ b/DvergerColor/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("1.0.7.0")] +[assembly: AssemblyFileVersion("1.0.7.0")] diff --git a/DvergerColor/ImprovedDvergerCirclet-Header.png b/DvergerColor/image/ImprovedDvergerCirclet-Header.png similarity index 100% rename from DvergerColor/ImprovedDvergerCirclet-Header.png rename to DvergerColor/image/ImprovedDvergerCirclet-Header.png diff --git a/DvergerColor/ImprovedDvergerCirclet-Tile.png b/DvergerColor/image/ImprovedDvergerCirclet-Tile.png similarity index 100% rename from DvergerColor/ImprovedDvergerCirclet-Tile.png rename to DvergerColor/image/ImprovedDvergerCirclet-Tile.png diff --git a/DvergerColor/Screenshot 2021-02-21 21.51.25.png b/DvergerColor/image/Screenshot 2021-02-21 21.51.25.png similarity index 100% rename from DvergerColor/Screenshot 2021-02-21 21.51.25.png rename to DvergerColor/image/Screenshot 2021-02-21 21.51.25.png diff --git a/DvergerColor/Screenshot 2021-02-21 21.51.33.png b/DvergerColor/image/Screenshot 2021-02-21 21.51.33.png similarity index 100% rename from DvergerColor/Screenshot 2021-02-21 21.51.33.png rename to DvergerColor/image/Screenshot 2021-02-21 21.51.33.png diff --git a/DvergerColor/Screenshot 2021-02-21 21.51.37.png b/DvergerColor/image/Screenshot 2021-02-21 21.51.37.png similarity index 100% rename from DvergerColor/Screenshot 2021-02-21 21.51.37.png rename to DvergerColor/image/Screenshot 2021-02-21 21.51.37.png diff --git a/DvergerColor/Screenshot 2021-02-21 21.51.41.png b/DvergerColor/image/Screenshot 2021-02-21 21.51.41.png similarity index 100% rename from DvergerColor/Screenshot 2021-02-21 21.51.41.png rename to DvergerColor/image/Screenshot 2021-02-21 21.51.41.png diff --git a/DvergerColor/manifest.json b/DvergerColor/manifest.json deleted file mode 100644 index 0b027ee8..00000000 --- a/DvergerColor/manifest.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "ImprovedDvergerCirclet", - "version_number": "1.0.4", - "website_url": "https://github.com/RandyKnapp/ValheimMods/tree/main/DvergerColor", - "description": "Changes the color of the light emitted by the Dverger circlet to white. Adds several beam width options, and a pool of radiance (point light) option.", - "dependencies": [] -} diff --git a/DvergerColor/VisEquipment_Patch.cs b/DvergerColor/src/VisEquipment_Patch.cs similarity index 100% rename from DvergerColor/VisEquipment_Patch.cs rename to DvergerColor/src/VisEquipment_Patch.cs diff --git a/DvergerColor/icon.png b/DvergerColor/thunderstore/icon.png similarity index 100% rename from DvergerColor/icon.png rename to DvergerColor/thunderstore/icon.png diff --git a/DvergerColor/thunderstore/manifest.json b/DvergerColor/thunderstore/manifest.json new file mode 100644 index 00000000..86d18132 --- /dev/null +++ b/DvergerColor/thunderstore/manifest.json @@ -0,0 +1,9 @@ +{ + "name": "ImprovedDvergerCirclet", + "version_number": "1.0.7", + "website_url": "https://github.com/RandyKnapp/ValheimMods/tree/main/DvergerColor", + "description": "Changes the color of the light emitted by the Dverger circlet to white. Adds several beam width options, and a pool of radiance (point light) option.", + "dependencies": [ + "denikson-BepInExPack_Valheim-5.4.2200" + ] +} diff --git a/EpicLoot-Addon-Helheim/Console_Patch.cs b/EpicLoot-Addon-Helheim/Console_Patch.cs deleted file mode 100644 index 8d775353..00000000 --- a/EpicLoot-Addon-Helheim/Console_Patch.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Linq; -using HarmonyLib; - -namespace EpicLoot_Addon_Helheim -{ - [HarmonyPatch(typeof(Console), "InputText")] - public static class Console_Patch - { - public static bool Prefix(Console __instance) - { - var input = __instance.m_input.text; - var args = input.Split(' '); - if (args.Length == 0) - { - return true; - } - - var player = Player.m_localPlayer; - - if (Command("helheim", args)) - { - var level = args.Length >= 2 ? int.Parse(args[1]) : 0; - Helheim.SetLevel(level); - } - - return true; - } - - private static bool Command(string command, params string[] args) - { - return args.Contains(command); - } - } -} diff --git a/EpicLoot-Addon-Helheim/EnvMan_Patch.cs b/EpicLoot-Addon-Helheim/EnvMan_Patch.cs deleted file mode 100644 index dea9ee27..00000000 --- a/EpicLoot-Addon-Helheim/EnvMan_Patch.cs +++ /dev/null @@ -1,159 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using HarmonyLib; -using Random = UnityEngine.Random; - -namespace EpicLoot_Addon_Helheim -{ - [HarmonyPatch] - public static class EnvMan_Patch - { - public static int PreviousHelheimLevel; - public static Heightmap.Biome PreviousBiome; - public static string PreviousEnvName; - - //Awake - [HarmonyPatch(typeof(EnvMan), nameof(EnvMan.Awake))] - public static class EnvMan_Awake_Patch - { - public static void Prefix(EnvMan __instance) - { - var eikthyr = __instance.m_environments.Find(x => x.m_name == "Eikthyr"); - AddHelheimEnvironments(__instance, eikthyr, 1); - - var ashrain = __instance.m_environments.Find(x => x.m_name == "Ashrain"); - AddHelheimEnvironments(__instance, ashrain, 2); - - var moder = __instance.m_environments.Find(x => x.m_name == "Moder"); - AddHelheimEnvironments(__instance, moder, 3); - } - } - - [HarmonyPatch(typeof(EnvMan), nameof(EnvMan.UpdateEnvironment))] - public static class EnvMan_UpdateEnvironment_Patch - { - public static bool Prefix(EnvMan __instance, long sec, Heightmap.Biome biome) - { - if (HasEnvChanged(Helheim.HelheimLevel, biome, __instance.GetCurrentEnvironment().m_name)) - { - Helheim.Log($"Helheim: {Helheim.HelheimLevel}, Biome: {biome}, Current: {__instance.GetCurrentEnvironment().m_name}, Wet: {__instance.IsWet()}, Freezing: {__instance.IsFreezing()}"); - } - - var allowBaseMethod = true; - var forceSwitch = Helheim.HelheimLevel != PreviousHelheimLevel; - __instance.m_firstEnv = forceSwitch; - - if (Helheim.HelheimLevel > 0) - { - var num = sec / __instance.m_environmentDuration; - if (!forceSwitch && __instance.m_currentEnv.m_name.StartsWith("Helheim") && __instance.m_environmentPeriod == num && __instance.m_currentBiome == biome) - { - return false; - } - - __instance.m_environmentPeriod = num; - __instance.m_currentBiome = biome; - var state = Random.state; - Random.InitState((int)num); - var availableEnvironments = __instance.GetAvailableEnvironments(biome); - if (availableEnvironments != null && availableEnvironments.Count > 0) - { - var biomeEnv = __instance.SelectWeightedEnvironment(availableEnvironments); - var helheimEnv = GetHelheimEnvironment(__instance, biomeEnv, Helheim.HelheimLevel); - __instance.QueueEnvironment(helheimEnv); - Helheim.LogWarning($"Changing Environment: {helheimEnv.m_name}"); - } - Random.state = state; - allowBaseMethod = false; - } - else - { - if (forceSwitch) - { - __instance.m_currentBiome = Heightmap.Biome.None; - } - } - - PreviousHelheimLevel = Helheim.HelheimLevel; - PreviousBiome = biome; - PreviousEnvName = __instance.GetCurrentEnvironment().m_name; - return allowBaseMethod; - } - } - - public static bool HasEnvChanged(int helheimLevel, Heightmap.Biome biome, string envName) - { - return PreviousHelheimLevel != helheimLevel || - PreviousBiome != biome || - PreviousEnvName != envName; - } - - public static EnvSetup GetHelheimEnvironment(EnvMan envMan, EnvSetup biomeEnv, int level) - { - var name = GetHelheimEnvName(level, biomeEnv.m_isWet, biomeEnv.m_isFreezing); - return envMan.GetEnv(name); - } - - public static void AddHelheimEnvironments(EnvMan envMan, EnvSetup baseEnv, int level) - { - var helheimEnvBase = baseEnv.Clone(); - helheimEnvBase.m_name = GetHelheimEnvName(level, false, false); - //FindAndCopyEnvObjectByName(envMan, "Thunder", helheimEnvBase); - envMan.m_environments.Add(helheimEnvBase); - - var helheimEnvWet = helheimEnvBase.Clone(); - helheimEnvWet.m_name = GetHelheimEnvName(level, true, false); - helheimEnvWet.m_isWet = true; - FindAndCopyPsystemByName(envMan, level == 1 ? "LightRain" : "Rain", helheimEnvWet); - envMan.m_environments.Add(helheimEnvWet); - - var helheimEnvFreezing = helheimEnvBase.Clone(); - helheimEnvFreezing.m_name = GetHelheimEnvName(level, false, true); - helheimEnvFreezing.m_isFreezing = true; - FindAndCopyPsystemByName(envMan, level == 1 ? "Snow" : "SnowStorm", helheimEnvFreezing); - envMan.m_environments.Add(helheimEnvFreezing); - } - - public static void FindAndCopyEnvObjectByName(EnvMan envMan, string name, EnvSetup targetEnv) - { - if (targetEnv.m_envObject.name == name) - { - return; - } - - foreach (var env in envMan.m_environments) - { - if (env.m_envObject.name.Equals(name)) - { - targetEnv.m_envObject = env.m_envObject; - return; - } - } - } - - public static void FindAndCopyPsystemByName(EnvMan envMan, string name, EnvSetup targetEnv) - { - if (targetEnv.m_psystems.ToList().Exists(x => x.name == name)) - { - return; - } - - foreach (var env in envMan.m_environments) - { - foreach (var psystem in env.m_psystems) - { - if (psystem.name.Equals(name)) - { - targetEnv.m_psystems = targetEnv.m_psystems.AddToArray(psystem); - return; - } - } - } - } - - public static string GetHelheimEnvName(int level, bool wet, bool freezing) - { - return $"Helheim{level}{(wet ? "_Wet" : (freezing ? "_Freezing" : ""))}"; - } - } -} diff --git a/EpicLoot-Addon-Helheim/EpicLoot-Addon-Helheim.csproj b/EpicLoot-Addon-Helheim/EpicLoot-Addon-Helheim.csproj deleted file mode 100644 index b78b7b44..00000000 --- a/EpicLoot-Addon-Helheim/EpicLoot-Addon-Helheim.csproj +++ /dev/null @@ -1,95 +0,0 @@ - - - - - Debug - AnyCPU - {FB508E8D-0C64-4EC6-B746-F668F510295F} - Library - Properties - EpicLoot_Addon_Helheim - EpicLoot-Addon-Helheim - v4.6.2 - 512 - true - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - true - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\BepInEx\core\0Harmony.dll - - - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\valheim_Data\Managed\publicized_assemblies\assembly_valheim_publicized.dll - - - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\BepInEx\core\BepInEx.dll - - - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\BepInEx\plugins\CreatureLevelControl.dll - - - ..\Libs\fastJSON.dll - - - - - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\unstripped_corlib\UnityEngine.dll - - - False - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\unstripped_corlib\UnityEngine.AssetBundleModule.dll - - - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\unstripped_corlib\UnityEngine.CoreModule.dll - - - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\unstripped_corlib\UnityEngine.UI.dll - - - - - - - - - - - - - helheim - - - - - fastJSON.dll - - - - - - - - - xcopy "$(TargetDir)$(TargetFileName)" "C:\Program Files (x86)\Steam\steamapps\common\Valheim\BepInEx\plugins\$(ProjectName)\" /q /y /i - -xcopy "$(ProjectDir)helheim.json" "C:\Program Files (x86)\Steam\steamapps\common\Valheim\BepInEx\plugins\$(ProjectName)\" /q /y /i - - \ No newline at end of file diff --git a/EpicLoot-Addon-Helheim/Helheim.cs b/EpicLoot-Addon-Helheim/Helheim.cs deleted file mode 100644 index 3a6a6671..00000000 --- a/EpicLoot-Addon-Helheim/Helheim.cs +++ /dev/null @@ -1,165 +0,0 @@ -using System; -using System.IO; -using System.Linq; -using System.Reflection; -using BepInEx; -using BepInEx.Configuration; -using fastJSON; -using HarmonyLib; -using UnityEngine; - -namespace EpicLoot_Addon_Helheim -{ - public class Assets - { - public GameObject HelheimTextPrefab; - } - - [BepInPlugin(PluginId, "Epic Loot Addon - Helheim", Version)] - [BepInDependency("randyknapp.mods.epicloot")] - [BepInDependency("org.bepinex.plugins.creaturelevelcontrol")] - public class Helheim : BaseUnityPlugin - { - private const string PluginId = "randyknapp.mods.epicloot.addon.helheim"; - private const string Version = "1.0.0"; - - private static ConfigEntry _loggingEnabled; - - private static Helheim _instance; - - public const int HelheimLevelCount = 5; - public static int HelheimLevel { get; private set; } - public static readonly Assets Assets = new Assets(); - - public static event Action HelheimLevelChanged; - - public HelheimConfig HelheimConfig; - - public Helheim() - { - LoadEmbeddedAssembly("fastJSON.dll"); - } - - public void Awake() - { - _instance = this; - _loggingEnabled = Config.Bind("Logging", "Logging Enabled", false, "Enable logging"); - - var assetBundle = LoadAssetBundle("helheim"); - Assets.HelheimTextPrefab = assetBundle.LoadAsset("HelheimText"); - - HelheimConfig = LoadJsonFile("helheim.json"); - - Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), PluginId); - - CreatureLevelControl.CreatureLevelControl.difficulty.Value = CreatureLevelControl.CreatureLevelControl.Difficulty.Custom; - } - - private static void LoadEmbeddedAssembly(string assemblyName) - { - var stream = GetManifestResourceStream(assemblyName); - if (stream == null) - { - LogError($"Could not load embedded assembly ({assemblyName})!"); - return; - } - - using (stream) - { - var data = new byte[stream.Length]; - stream.Read(data, 0, data.Length); - Assembly.Load(data); - } - } - - public static AssetBundle LoadAssetBundle(string filename) - { - using (var stream = GetManifestResourceStream(filename)) - { - return AssetBundle.LoadFromStream(stream); - } - } - - public static Stream GetManifestResourceStream(string filename) - { - var assembly = Assembly.GetCallingAssembly(); - var fullname = assembly.GetManifestResourceNames().SingleOrDefault(x => x.EndsWith(filename)); - if (!string.IsNullOrEmpty(fullname)) - { - return assembly.GetManifestResourceStream(fullname); - } - - return null; - } - - public static T LoadJsonFile(string filename) where T : class - { - var jsonFile = LoadJsonText(filename); - T result; - try - { - result = string.IsNullOrEmpty(jsonFile) ? null : JSON.ToObject(jsonFile); - } - catch (Exception) - { - LogError($"Could not parse file '{filename}'! Errors in JSON!"); - throw; - } - - return result; - } - - public static string LoadJsonText(string filename) - { - var jsonFileName = GetAssetPath(filename); - return !string.IsNullOrEmpty(jsonFileName) ? File.ReadAllText(jsonFileName) : null; - } - - public static string GetAssetPath(string assetName) - { - var assembly = typeof(Helheim).Assembly; - var assetFileName = Path.Combine(Path.GetDirectoryName(assembly.Location) ?? string.Empty, assetName); - if (!File.Exists(assetFileName)) - { - LogError($"Could not find asset ({assetName})"); - return null; - } - - return assetFileName; - } - - public static void SetLevel(int level) - { - if (HelheimLevel != level) - { - HelheimLevel = Mathf.Clamp(level, 0, HelheimLevelCount); - HelheimLevelChanged?.Invoke(HelheimLevel); - LogWarning($"Helheim level: {HelheimLevel}"); - } - } - - public static void Log(string message) - { - if (_loggingEnabled.Value) - { - _instance.Logger.LogInfo(message); - } - } - - public static void LogWarning(string message) - { - if (_loggingEnabled.Value) - { - _instance.Logger.LogWarning(message); - } - } - - public static void LogError(string message) - { - if (_loggingEnabled.Value) - { - _instance.Logger.LogError(message); - } - } - } -} diff --git a/EpicLoot-Addon-Helheim/HelheimConfig.cs b/EpicLoot-Addon-Helheim/HelheimConfig.cs deleted file mode 100644 index c23b8322..00000000 --- a/EpicLoot-Addon-Helheim/HelheimConfig.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace EpicLoot_Addon_Helheim -{ - [Serializable] - public class HelheimLevelConfig - { - public int Level; - } - - [Serializable] - public class HelheimConfig - { - public List HelheimLevels = new List(); - } -} diff --git a/EpicLoot-Addon-Helheim/HelheimText.cs b/EpicLoot-Addon-Helheim/HelheimText.cs deleted file mode 100644 index 19ef51f3..00000000 --- a/EpicLoot-Addon-Helheim/HelheimText.cs +++ /dev/null @@ -1,49 +0,0 @@ -using HarmonyLib; -using UnityEngine; -using UnityEngine.UI; - -namespace EpicLoot_Addon_Helheim -{ - [HarmonyPatch(typeof(Hud), nameof(Hud.Awake))] - public static class Hud_Awake_Patch - { - public static void Postfix(Hud __instance) - { - var helheimTextObject = Object.Instantiate(Helheim.Assets.HelheimTextPrefab, __instance.m_rootObject.transform, false); - helheimTextObject.AddComponent(); - } - } - - public class HelheimText : MonoBehaviour - { - public Text Label; - - public void Awake() - { - Label = GetComponentInChildren(); - } - - public void Update() - { - Label.text = Helheim.HelheimLevel == 0 ? "Valheim" : $"Helheim: Level {Helheim.HelheimLevel} - {GetHelheimName()}"; - } - - // Niflhel - the edge of Helheim - // Baldyrborg - the funeral pyre of Baldyr - // Myrkstaðr - the place of darkness - // Frostsalr - the house of frost - // Skaðihaugar - the mounds of death - private static string GetHelheimName() - { - switch (Helheim.HelheimLevel) - { - case 1: return "Niflhel"; - case 2: return "Baldyrborg"; - case 3: return "Myrkstaðr"; - case 4: return "Frostsalr"; - case 5: return "Skaðihaugar"; - default: return ""; - } - } - } -} diff --git a/EpicLoot-Addon-Helheim/Notes.md b/EpicLoot-Addon-Helheim/Notes.md deleted file mode 100644 index 126d7d27..00000000 --- a/EpicLoot-Addon-Helheim/Notes.md +++ /dev/null @@ -1,6 +0,0 @@ -## Helheim Notes - -- Create world at Helheim level, can't change existing world -- Store "Helheim" and "HelheimLevel{X}" in the GlobalKeys of the world -- If you go to a Valheim world with a character that's been in Helheim, you get Helheim Sickness for 30 minutes (?) that doesn't go away automatically, even if you come back to Helheim -- Helheim sickness gives you -80% health regen and stamina regen, and -100 carry weight \ No newline at end of file diff --git a/EpicLoot-Addon-Helheim/Properties/AssemblyInfo.cs b/EpicLoot-Addon-Helheim/Properties/AssemblyInfo.cs deleted file mode 100644 index c659a303..00000000 --- a/EpicLoot-Addon-Helheim/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("EpicLoot-Addon-Helheim")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("EpicLoot-Addon-Helheim")] -[assembly: AssemblyCopyright("Copyright © 2021")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("fb508e8d-0c64-4ec6-b746-f668f510295f")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0")] -[assembly: AssemblyFileVersion("1.0.0")] diff --git a/EpicLoot-Addon-Helheim/helheim.json b/EpicLoot-Addon-Helheim/helheim.json deleted file mode 100644 index 704fbe49..00000000 --- a/EpicLoot-Addon-Helheim/helheim.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "HelheimLevels" : [ - { - "Level" : 1 - }, - { - "Level" : 2 - } - ] -} diff --git a/EpicLoot-Addon-MCE/EpicLoot-Addon-MCE.csproj b/EpicLoot-Addon-MCE/EpicLoot-Addon-MCE.csproj deleted file mode 100644 index c690a24e..00000000 --- a/EpicLoot-Addon-MCE/EpicLoot-Addon-MCE.csproj +++ /dev/null @@ -1,77 +0,0 @@ - - - - - Debug - AnyCPU - {8B9A7665-F688-4E13-B62A-F62DB7E065C4} - Library - Properties - EpicLoot_Addon_MCE - EpicLoot-Addon-MCE - v4.6.1 - 512 - true - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - true - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\BepInEx\core\0Harmony.dll - - - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\valheim_Data\Managed\publicized_assemblies\assembly_utils_publicized.dll - - - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\valheim_Data\Managed\publicized_assemblies\assembly_valheim_publicized.dll - - - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\BepInEx\core\BepInEx.dll - - - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\BepInEx\plugins\ModConfigEnforcer.dll - - - - - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\unstripped_corlib\UnityEngine.dll - - - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\unstripped_corlib\UnityEngine.CoreModule.dll - - - - - - - - - - {963cf4f8-ba02-49fc-8884-97e781e6bc18} - EpicLoot - - - - - - - - xcopy "$(TargetDir)$(TargetFileName)" "C:\Program Files (x86)\Steam\steamapps\common\Valheim\BepInEx\plugins\$(ProjectName)\" /q /y /i - - \ No newline at end of file diff --git a/EpicLoot-Addon-MCE/EpicLoot-Addon-MCE.zip b/EpicLoot-Addon-MCE/EpicLoot-Addon-MCE.zip deleted file mode 100644 index 4c7a19a7..00000000 Binary files a/EpicLoot-Addon-MCE/EpicLoot-Addon-MCE.zip and /dev/null differ diff --git a/EpicLoot-Addon-MCE/EpicLoot-Header.png b/EpicLoot-Addon-MCE/EpicLoot-Header.png deleted file mode 100644 index 2308f932..00000000 Binary files a/EpicLoot-Addon-MCE/EpicLoot-Header.png and /dev/null differ diff --git a/EpicLoot-Addon-MCE/EpicLoot-Tile.png b/EpicLoot-Addon-MCE/EpicLoot-Tile.png deleted file mode 100644 index d9955804..00000000 Binary files a/EpicLoot-Addon-MCE/EpicLoot-Tile.png and /dev/null differ diff --git a/EpicLoot-Addon-MCE/EpicLoot_Addon_MCE.cs b/EpicLoot-Addon-MCE/EpicLoot_Addon_MCE.cs deleted file mode 100644 index b1ae9517..00000000 --- a/EpicLoot-Addon-MCE/EpicLoot_Addon_MCE.cs +++ /dev/null @@ -1,138 +0,0 @@ -using System.Reflection; -using BepInEx; -using BepInEx.Configuration; -using Common; -using EpicLoot; -using EpicLoot.Adventure; -using EpicLoot.Crafting; -using EpicLoot.GatedItemType; -using HarmonyLib; -using ModConfigEnforcer; - -namespace EpicLoot_Addon_MCE -{ - [BepInPlugin(PluginId, "Epic Loot Addon - MCE", Version)] - [BepInDependency("randyknapp.mods.epicloot")] - [BepInDependency("pfhoenix.modconfigenforcer")] - public class EpicLoot_Addon_MCE : BaseUnityPlugin - { - private const string PluginId = "randyknapp.mods.epicloot.addon.mce"; - private const string Version = "1.0.4"; - - private static ConfigVariable _gatedItemTypeModeConfig; - private static ConfigVariable _bossTrophyDropMode; - private static ConfigVariable _bossTrophyDropPlayerRange; - private static ConfigVariable _adventureModeEnabled; - - private static readonly JsonFileConfigVariable _lootConfigFile = new JsonFileConfigVariable("loottables.json"); - private static readonly JsonFileConfigVariable _magicEffectsConfigFile = new JsonFileConfigVariable("magiceffects.json"); - private static readonly JsonFileConfigVariable _itemInfoConfigFile = new JsonFileConfigVariable("iteminfo.json"); - private static readonly JsonFileConfigVariable _recipesConfigFile = new JsonFileConfigVariable("recipes.json"); - private static readonly JsonFileConfigVariable _enchantCostsConfigFile = new JsonFileConfigVariable("enchantcosts.json"); - private static readonly JsonFileConfigVariable _itemNamesConfigFile = new JsonFileConfigVariable("itemnames.json"); - private static readonly JsonFileConfigVariable _adventureDataConfigFile = new JsonFileConfigVariable("adventuredata.json"); - - public void Awake() - { - var epicLootConfig = EpicLoot.EpicLoot.GetConfigObject(); - ConfigManager.RegisterMod(EpicLoot.EpicLoot.PluginId, epicLootConfig); - - ConfigManager.ServerConfigReceived += InitializeConfig; - - _gatedItemTypeModeConfig = ReplaceConfigVar(epicLootConfig, "Balance", "Item Drop Limits"); - _bossTrophyDropMode = ReplaceConfigVar(epicLootConfig, "Balance", "Boss Trophy Drop Mode"); - _bossTrophyDropPlayerRange = ReplaceConfigVar(epicLootConfig, "Balance", "Boss Trophy Drop Player Range"); - _adventureModeEnabled = ReplaceConfigVar(epicLootConfig, "Balance", "Adventure Mode Enabled"); - - ConfigManager.RegisterModConfigVariable(EpicLoot.EpicLoot.PluginId, _lootConfigFile); - ConfigManager.RegisterModConfigVariable(EpicLoot.EpicLoot.PluginId, _magicEffectsConfigFile); - ConfigManager.RegisterModConfigVariable(EpicLoot.EpicLoot.PluginId, _itemInfoConfigFile); - ConfigManager.RegisterModConfigVariable(EpicLoot.EpicLoot.PluginId, _recipesConfigFile); - ConfigManager.RegisterModConfigVariable(EpicLoot.EpicLoot.PluginId, _enchantCostsConfigFile); - ConfigManager.RegisterModConfigVariable(EpicLoot.EpicLoot.PluginId, _itemNamesConfigFile); - ConfigManager.RegisterModConfigVariable(EpicLoot.EpicLoot.PluginId, _adventureDataConfigFile); - - Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), PluginId); - } - - public static ConfigVariable ReplaceConfigVar(ConfigFile epicLootConfig, string section, string key) - { - if (epicLootConfig.TryGetEntry(section, key, out var gatedItemTypeConfigEntry)) - { - return ConfigManager.RegisterModConfigVariable( - EpicLoot.EpicLoot.PluginId, - gatedItemTypeConfigEntry.Definition.Key, - (T)gatedItemTypeConfigEntry.DefaultValue, - gatedItemTypeConfigEntry.Definition.Section, - gatedItemTypeConfigEntry.Description.Description, - false); - } - - return null; - } - - public static void InitializeConfig() - { - LootRoller.Initialize(_lootConfigFile.Value, _itemInfoConfigFile.Value); - MagicItemEffectDefinitions.Initialize(_magicEffectsConfigFile.Value); - GatedItemTypeHelper.Initialize(_itemInfoConfigFile.Value); - RecipesHelper.Initialize(_recipesConfigFile.Value); - EnchantCostsHelper.Initialize(_enchantCostsConfigFile.Value); - MagicItemNames.Initialize(_itemNamesConfigFile.Value); - AdventureDataManager.Initialize(_adventureDataConfigFile.Value); - } - - [HarmonyPatch(typeof(EpicLoot.EpicLoot), "GetGatedItemTypeMode")] - public static class EpicLoot_GetGatedItemTypeMode_Patch - { - public static bool Prefix(ref GatedItemTypeMode __result) - { - __result = _gatedItemTypeModeConfig.Value; - return false; - } - } - - [HarmonyPatch(typeof(EpicLoot.EpicLoot), nameof(EpicLoot.EpicLoot.GetBossTrophyDropMode))] - public static class EpicLoot_GetBossTrophyDropMode_Patch - { - public static bool Prefix(ref BossDropMode __result) - { - __result = _bossTrophyDropMode.Value; - return false; - } - } - - [HarmonyPatch(typeof(EpicLoot.EpicLoot), nameof(EpicLoot.EpicLoot.GetBossTrophyDropPlayerRange))] - public static class EpicLoot_GetBossTrophyDropPlayerRange_Patch - { - public static bool Prefix(ref float __result) - { - __result = _bossTrophyDropPlayerRange.Value; - return false; - } - } - - [HarmonyPatch(typeof(EpicLoot.EpicLoot), nameof(EpicLoot.EpicLoot.IsAdventureModeEnabled))] - public static class EpicLoot_IsAdventureModeEnabled_Patch - { - public static bool Prefix(ref bool __result) - { - __result = _adventureModeEnabled.Value; - return false; - } - } - - [HarmonyPatch(typeof(ZNet), "Start")] - public static class ZNet_Start_Patch - { - public static void Postfix() - { - // This resets EpicLoot to using its local config when starting a local game - if (ConfigManager.ShouldUseLocalConfig) - { - EpicLoot.EpicLoot.InitializeConfig(); - } - } - } - } -} diff --git a/EpicLoot-Addon-MCE/JsonFileConfigVariable.cs b/EpicLoot-Addon-MCE/JsonFileConfigVariable.cs deleted file mode 100644 index 3cf7d5c8..00000000 --- a/EpicLoot-Addon-MCE/JsonFileConfigVariable.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using ModConfigEnforcer; -using UnityEngine; - -namespace EpicLoot_Addon_MCE -{ - public class JsonFileConfigVariable : IConfigVariable where T : class - { - private readonly string _sourceFile; - private T _config; - - public JsonFileConfigVariable(string sourceFile) - { - _sourceFile = sourceFile; - } - - public string GetName() => _sourceFile; - public bool LocalOnly() => false; - public Type GetValueType() => typeof(T); - public T Value => (T)GetValue(); - - public object GetValue() - { - return ConfigManager.ShouldUseLocalConfig ? EpicLoot.EpicLoot.LoadJsonFile(_sourceFile) : _config; - } - - public void SetValue(object o) - { - // Will never be called - } - - public void Serialize(ZPackage zpg) - { - Debug.LogWarning($"Serialized config ({_sourceFile})"); - var configJson = EpicLoot.EpicLoot.LoadJsonText(_sourceFile); - zpg.Write(configJson); - } - - public bool Deserialize(ZPackage zpg) - { - Debug.LogWarning($"Deserialized config ({_sourceFile})"); - var configJson = zpg.ReadString(); - _config = EpicLoot.EpicLoot.JsonToObject(configJson); - return _config != null; - } - } -} diff --git a/EpicLoot-Addon-MCE/Properties/AssemblyInfo.cs b/EpicLoot-Addon-MCE/Properties/AssemblyInfo.cs deleted file mode 100644 index 593536c9..00000000 --- a/EpicLoot-Addon-MCE/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("EpicLoot-Addon-MCE")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("EpicLoot-Addon-MCE")] -[assembly: AssemblyCopyright("Copyright © 2021")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("8b9a7665-f688-4e13-b62a-f62db7e065c4")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.3")] -[assembly: AssemblyFileVersion("1.0.3")] diff --git a/EpicLoot-Addon-MCE/README.md b/EpicLoot-Addon-MCE/README.md deleted file mode 100644 index 5027bc4b..00000000 --- a/EpicLoot-Addon-MCE/README.md +++ /dev/null @@ -1,36 +0,0 @@ -# Epic Loot Addon - MCE v1.0.3 -Author: RandyKnapp -Source: [Github](https://github.com/RandyKnapp/ValheimMods/tree/main/EpicLoot-Addon-MCE/) - -## What does it do? - -This mod addon allows EpicLoot config files to be enforced by the server using ModConfigEnforcer. All loot tables, recipes, even item names will be controlled by the server for all connected clients. Both clients and server are required to have this addon installed to get server enforced configs. - -#### Currently Enforced by MCE: - - * Config Value: Balance / Item Drop Limits - * Config File: enchantcosts.json - * Config File: iteminfo.json - * Config File: itemnames.json - * Config File: loottables.json - * Config File: magiceffects.json - * Config File: recipes.json - -## How to Install - -For both the server and the client: - -1. Install [EpicLoot](https://www.nexusmods.com/valheim/mods/387) (requires version 0.6.4 or later) -2. Install [ModConfigEnforcer](https://www.nexusmods.com/valheim/mods/460) (requires version 1.4.1 or later) -3. Copy EpicLoot-Addon-MCE.dll to your BepInEx plugins folder - -## Patch Notes -#### Version 1.0.0 - * Initial release, allows MCE to control config values -#### Version 1.0.1 - * Added config for adventure stuff update -#### Version 1.0.2 - * Added config for boss trophy drops -#### Version 1.0.3 - * Added additional config for boss trophy drops - * Added adventure mode toggle diff --git a/EpicLoot-UnityLib/EnchantingTableUIPanelBase.cs b/EpicLoot-UnityLib/EnchantingTableUIPanelBase.cs deleted file mode 100644 index daef1705..00000000 --- a/EpicLoot-UnityLib/EnchantingTableUIPanelBase.cs +++ /dev/null @@ -1,211 +0,0 @@ -using System.Collections.Generic; -using UnityEngine; -using UnityEngine.UI; - -namespace EpicLoot_UnityLib -{ - public abstract class EnchantingTableUIPanelBase : MonoBehaviour - { - public const float CountdownTime = 0.8f; - - public MultiSelectItemList AvailableItems; - public Button MainButton; - public GameObject LevelDisplay; - public GuiBar ProgressBar; - public AudioSource Audio; - public AudioClip ProgressLoopSFX; - public AudioClip CompleteSFX; - - protected bool _inProgress; - protected float _countdown; - protected Text _buttonLabel; - protected string _defaultButtonLabelText; - protected bool _locked; - - protected abstract void DoMainAction(); - protected abstract void OnSelectedItemsChanged(); - - public virtual void Awake() - { - if (AvailableItems != null) - { - AvailableItems.OnSelectedItemsChanged += OnSelectedItemsChanged; - AvailableItems.GiveFocus(true, 0); - } - - if (MainButton != null) - { - MainButton.onClick.AddListener(OnMainButtonClicked); - _buttonLabel = MainButton.GetComponentInChildren(); - _defaultButtonLabelText = _buttonLabel.text; - } - - var uiSFX = GameObject.Find("sfx_gui_button"); - if (uiSFX && Audio != null) - Audio.outputAudioMixerGroup = uiSFX.GetComponent().outputAudioMixerGroup; - } - - protected virtual void OnMainButtonClicked() - { - if (_inProgress) - Cancel(); - else - StartProgress(); - } - - public virtual void DeselectAll() - { - } - - public virtual void Update() - { - if (ProgressBar != null) - ProgressBar.gameObject.SetActive(_inProgress); - if (LevelDisplay != null) - LevelDisplay.gameObject.SetActive(!_inProgress); - - if (_inProgress) - { - if (ProgressBar != null) - ProgressBar.SetValue(CountdownTime - _countdown); - - _countdown -= Time.deltaTime; - if (_countdown < 0) - { - _inProgress = false; - _countdown = 0; - - if (Audio != null) - { - Audio.loop = false; - Audio.Stop(); - } - - DoMainAction(); - PlayCompleteSFX(); - } - } - } - - private void PlayCompleteSFX() - { - var clip = GetCompleteAudioClip(); - if (Audio != null && clip != null) - Audio.PlayOneShot(clip); - } - - protected virtual AudioClip GetCompleteAudioClip() - { - return CompleteSFX; - } - - public virtual void StartProgress() - { - _buttonLabel.text = Localization.instance.Localize("$menu_cancel"); - _inProgress = true; - _countdown = CountdownTime; - - if (ProgressBar != null) - ProgressBar.SetMaxValue(CountdownTime); - - if (Audio != null) - { - Audio.loop = true; - Audio.clip = ProgressLoopSFX; - Audio.Play(); - } - - Lock(); - } - - public virtual bool CanCancel() - { - return _inProgress; - } - - public virtual void Cancel() - { - _buttonLabel.text = Localization.instance.Localize(_defaultButtonLabelText); - _inProgress = false; - _countdown = 0; - - if (Audio != null) - { - Audio.loop = false; - Audio.Stop(); - } - - Unlock(); - } - - public virtual void Lock() - { - _locked = true; - var lists = GetComponentsInChildren(); - foreach (var list in lists) - { - list.Lock(); - } - - EnchantingTableUI.instance.LockTabs(); - } - - public virtual void Unlock() - { - _locked = false; - var lists = GetComponentsInChildren(); - foreach (var list in lists) - { - list.Unlock(); - } - - EnchantingTableUI.instance.UnlockTabs(); - } - - protected static bool LocalPlayerCanAffordCost(List cost) - { - var player = Player.m_localPlayer; - if (player.NoCostCheat()) - return true; - - var inventory = player.GetInventory(); - foreach (var element in cost) - { - var item = element.GetItem(); - if (inventory.CountItems(item.m_shared.m_name) < item.m_stack) - return false; - } - - return true; - } - - protected static void GiveItemsToPlayer(List sacrificeProducts) - { - var player = Player.m_localPlayer; - var inventory = player.GetInventory(); - - foreach (var sacrificeProduct in sacrificeProducts) - { - var item = sacrificeProduct.GetItem(); - do - { - var itemToAdd = item.Clone(); - itemToAdd.m_stack = Mathf.Min(item.m_stack, item.m_shared.m_maxStackSize); - item.m_stack -= itemToAdd.m_stack; - //Debug.LogWarning($"Adding item: {itemToAdd.m_shared.m_name} x{itemToAdd.m_stack} (remaining:{item.m_stack})"); - if (inventory.CanAddItem(itemToAdd)) - { - inventory.AddItem(itemToAdd); - player.Message(MessageHud.MessageType.TopLeft, $"$msg_added {itemToAdd.m_shared.m_name}", itemToAdd.m_stack, itemToAdd.GetIcon()); - } - else - { - var itemDrop = ItemDrop.DropItem(itemToAdd, itemToAdd.m_stack, player.transform.position + player.transform.forward + player.transform.up, player.transform.rotation); - itemDrop.GetComponent().velocity = Vector3.up * 5f; - player.Message(MessageHud.MessageType.TopLeft, $"$msg_dropped {itemDrop.m_itemData.m_shared.m_name} $mod_epicloot_sacrifice_inventoryfullexplanation", itemDrop.m_itemData.m_stack, itemDrop.m_itemData.GetIcon()); - } - } while (item.m_stack > 0); - } - } - } -} diff --git a/EpicLoot-UnityLib/EpicLoot-UnityLib.csproj b/EpicLoot-UnityLib/EpicLoot-UnityLib.csproj index 578ac689..0f3e9379 100644 --- a/EpicLoot-UnityLib/EpicLoot-UnityLib.csproj +++ b/EpicLoot-UnityLib/EpicLoot-UnityLib.csproj @@ -2,6 +2,7 @@ + Debug AnyCPU @@ -10,7 +11,8 @@ Properties EpicLoot_UnityLib EpicLoot-UnityLib - v4.6.1 + v4.7.2 + 10.0 512 true @@ -38,104 +40,20 @@ latest - - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\BepInEx\core\0Harmony.dll - - - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\valheim_Data\Managed\publicized_assemblies\assembly_guiutils_publicized.dll - - - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\valheim_Data\Managed\publicized_assemblies\assembly_utils_publicized.dll - - - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\valheim_Data\Managed\publicized_assemblies\assembly_valheim_publicized.dll - - - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\BepInEx\core\BepInEx.dll - - - False - ..\Libs\Newtonsoft.Json.dll - - - False - ..\Libs\Newtonsoft.Json.dll - - - - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\unstripped_corlib\UnityEngine.dll - - - False - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\unstripped_corlib\UnityEngine.AssetBundleModule.dll - - - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\unstripped_corlib\UnityEngine.AudioModule.dll - - - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\unstripped_corlib\UnityEngine.CoreModule.dll - - - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\unstripped_corlib\UnityEngine.ImageConversionModule.dll - - - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\unstripped_corlib\UnityEngine.InputLegacyModule.dll - - - False - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\unstripped_corlib\UnityEngine.ParticleSystemModule.dll - - - False - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\unstripped_corlib\UnityEngine.PhysicsModule.dll - - - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\unstripped_corlib\UnityEngine.TextCoreModule.dll - - - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\unstripped_corlib\UnityEngine.TextRenderingModule.dll - - - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\unstripped_corlib\UnityEngine.UI.dll - - - ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Valheim\unstripped_corlib\UnityEngine.UIModule.dll - - - - - - - - - - - - - - - - - + - - - - - - - - xcopy "$(TargetDir)$(TargetFileName)" "$(SolutionDir)ValheimUnity\Assets\ExternalLibraries\" /q /y /i - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + \ No newline at end of file diff --git a/EpicLoot-UnityLib/SelectableTextColor.cs b/EpicLoot-UnityLib/SelectableTextColor.cs deleted file mode 100644 index 2db83e32..00000000 --- a/EpicLoot-UnityLib/SelectableTextColor.cs +++ /dev/null @@ -1,28 +0,0 @@ -using UnityEngine; -using UnityEngine.UI; - -namespace EpicLoot_UnityLib -{ - public class SelectableTextColor : MonoBehaviour - { - private Color _defaultColor = Color.white; - public Color DisabledColor = Color.grey; - private Selectable _selectable; - private Text _text; - - public void Awake() - { - _selectable = GetComponent(); - _text = GetComponentInChildren(); - _defaultColor = _text.color; - } - - public void Update() - { - if (_selectable.IsInteractable()) - _text.color = _defaultColor; - else - _text.color = DisabledColor; - } - } -} diff --git a/EpicLoot-UnityLib/packages.config b/EpicLoot-UnityLib/packages.config index ded7cfb3..1063f24d 100644 --- a/EpicLoot-UnityLib/packages.config +++ b/EpicLoot-UnityLib/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/EpicLoot-UnityLib/AugmentUI.cs b/EpicLoot-UnityLib/src/AugmentUI.cs similarity index 94% rename from EpicLoot-UnityLib/AugmentUI.cs rename to EpicLoot-UnityLib/src/AugmentUI.cs index 32429294..1f8e2289 100644 --- a/EpicLoot-UnityLib/AugmentUI.cs +++ b/EpicLoot-UnityLib/src/AugmentUI.cs @@ -59,7 +59,9 @@ public void OnEnable() var augmentChoices = 2; var featureValues = EnchantingTableUI.instance.SourceTable.GetFeatureCurrentValue(EnchantingFeature.Augment); if (!float.IsNaN(featureValues.Item1)) + { augmentChoices = (int)featureValues.Item1; + } var colorPre = augmentChoices > 2 ? "" : ""; var colorPost = augmentChoices > 2 ? "" : ""; @@ -91,7 +93,9 @@ public override void Update() { var rightStickAxis = ZInput.GetJoyRightStickY(); if (Mathf.Abs(rightStickAxis) > 0.5f) + { AvailableEffectsScrollbar.value = Mathf.Clamp01(AvailableEffectsScrollbar.value + rightStickAxis * -0.1f); + } } } @@ -105,7 +109,9 @@ public override void Update() AvailableItems.ForeachElement((i, e) => { if (!e.IsSelected()) + { return; + } e.SetItem(e.GetListElement()); e.Refresh(); }); @@ -131,7 +137,9 @@ public void OnAugmentSelectorToggled(bool isOn) else { if (!AugmentSelectors.Any(x => x.isOn)) + { SelectAugmentIndex(-1); + } } } @@ -183,9 +191,14 @@ public void OnAugmentIndexChanged() var featureValues = EnchantingTableUI.instance.SourceTable.GetFeatureCurrentValue(EnchantingFeature.Augment); var reenchantCostReduction = float.IsNaN(featureValues.Item2) ? 0 : featureValues.Item2; if (reenchantCostReduction > 0) - CostLabel.text = Localization.instance.Localize($"$mod_epicloot_augmentcost (-{reenchantCostReduction}% $item_coins!)"); + { + CostLabel.text = Localization.instance.Localize($"$mod_epicloot_augmentcost " + + $"(-{reenchantCostReduction}% $item_coins!)"); + } else + { CostLabel.text = Localization.instance.Localize("$mod_epicloot_augmentcost"); + } var canAfford = LocalPlayerCanAffordCost(cost); var featureUnlocked = EnchantingTableUI.instance.SourceTable.IsFeatureUnlocked(EnchantingFeature.Augment); @@ -219,16 +232,16 @@ protected override void DoMainAction() return; } - var inventory = player.GetInventory(); foreach (var costElement in cost) { - var costItem = costElement.GetItem(); - inventory.RemoveItem(costItem.m_shared.m_name, costItem.m_stack); + InventoryManagement.Instance.RemoveItem(costElement.GetItem()); } } if (_choiceDialog != null) + { Destroy(_choiceDialog); + } _choiceDialog = AugmentItem(item, _augmentIndex); @@ -250,12 +263,16 @@ protected override void OnSelectedItemsChanged() { var selector = AugmentSelectors[index]; if (selector == null) + { continue; + } selector.SetIsOnWithoutNotify(index == 0); selector.gameObject.SetActive(item != null && index < augmentableEffects.Count); if (!selector.gameObject.activeSelf) + { continue; + } var selectorText = selector.GetComponentInChildren(); if (selectorText != null) @@ -266,7 +283,9 @@ protected override void OnSelectedItemsChanged() } if (item == null) + { AvailableEffectsText.text = string.Empty; + } _augmentIndex = 0; OnAugmentIndexChanged(); @@ -282,12 +301,16 @@ private void RefreshAugmentSelectors() { var selector = AugmentSelectors[index]; if (selector == null) + { continue; + } selector.SetIsOnWithoutNotify(index == _augmentIndex); selector.gameObject.SetActive(item != null && index < augmentableEffects.Count); if (!selector.gameObject.activeSelf) + { continue; + } var selectorText = selector.GetComponentInChildren(); if (selectorText != null) diff --git a/EpicLoot-UnityLib/ConvertUI.cs b/EpicLoot-UnityLib/src/ConvertUI.cs similarity index 84% rename from EpicLoot-UnityLib/ConvertUI.cs rename to EpicLoot-UnityLib/src/ConvertUI.cs index 29e7e149..b5dd53cb 100644 --- a/EpicLoot-UnityLib/ConvertUI.cs +++ b/EpicLoot-UnityLib/src/ConvertUI.cs @@ -31,16 +31,11 @@ public class ConversionRecipeUnity : IListElement public int GetMax() { - var player = Player.m_localPlayer; - if (player == null) - return 0; - - var inventory = player.GetInventory(); - var min = int.MaxValue; + int min = int.MaxValue; foreach (var cost in Cost) { - var count = inventory.CountItems(cost.Item.m_shared.m_name); - var canMake = Mathf.FloorToInt(count / (float)cost.Amount); + int count = InventoryManagement.Instance.CountItem(cost.Item); + int canMake = Mathf.FloorToInt(count / (float)cost.Amount); min = Mathf.Min(min, canMake); } @@ -138,19 +133,28 @@ public void OnModeChanged() case MaterialConversionMode.Upgrade: CostLabel.text = Localization.instance.Localize("$mod_epicloot_upgradecost"); _progressLabel.text = Localization.instance.Localize("$mod_epicloot_upgradeprogress"); - _buttonLabel.text = Localization.instance.Localize("$mod_epicloot_upgrade"); + if (_useTMP) + _tmpButtonLabel.text = Localization.instance.Localize("$mod_epicloot_upgrade"); + else + _buttonLabel.text = Localization.instance.Localize("$mod_epicloot_upgrade"); break; case MaterialConversionMode.Convert: CostLabel.text = Localization.instance.Localize("$mod_epicloot_convertcost"); _progressLabel.text = Localization.instance.Localize("$mod_epicloot_convertprogress"); - _buttonLabel.text = Localization.instance.Localize("$mod_epicloot_convert"); + if (_useTMP) + _tmpButtonLabel.text = Localization.instance.Localize("$mod_epicloot_convert"); + else + _buttonLabel.text = Localization.instance.Localize("$mod_epicloot_convert"); break; case MaterialConversionMode.Junk: CostLabel.text = Localization.instance.Localize("$mod_epicloot_junkcost"); _progressLabel.text = Localization.instance.Localize("$mod_epicloot_junkprogress"); - _buttonLabel.text = Localization.instance.Localize("$mod_epicloot_junk"); + if (_useTMP) + _tmpButtonLabel.text = Localization.instance.Localize("$mod_epicloot_junk"); + else + _buttonLabel.text = Localization.instance.Localize("$mod_epicloot_junk"); break; default: @@ -166,28 +170,14 @@ protected override void DoMainAction() Cancel(); - var player = Player.m_localPlayer; - var inventory = player.GetInventory(); foreach (var costElement in cost) { - var costItem = costElement.GetItem(); - inventory.RemoveItem(costItem.m_shared.m_name, costItem.m_stack); + InventoryManagement.Instance.RemoveItem(costElement.GetItem()); } foreach (var productElement in allProducts) { - var product = productElement.GetItem(); - if (inventory.CanAddItem(product)) - { - inventory.AddItem(product); - player.Message(MessageHud.MessageType.TopLeft, $"$msg_added {product.m_shared.m_name}", product.m_stack, product.GetIcon()); - } - else - { - var itemDrop = ItemDrop.DropItem(product, product.m_stack, player.transform.position + player.transform.forward + player.transform.up, player.transform.rotation); - itemDrop.GetComponent().velocity = Vector3.up * 5f; - player.Message(MessageHud.MessageType.TopLeft, $"$msg_dropped {itemDrop.m_itemData.m_shared.m_name} $mod_epicloot_sacrifice_inventoryfullexplanation", itemDrop.m_itemData.m_stack, itemDrop.m_itemData.GetIcon()); - } + InventoryManagement.Instance.GiveItem(productElement.GetItem()); } DeselectAll(); diff --git a/EpicLoot-UnityLib/DisenchantUI.cs b/EpicLoot-UnityLib/src/DisenchantUI.cs similarity index 94% rename from EpicLoot-UnityLib/DisenchantUI.cs rename to EpicLoot-UnityLib/src/DisenchantUI.cs index 1e6ab9a9..d7679847 100644 --- a/EpicLoot-UnityLib/DisenchantUI.cs +++ b/EpicLoot-UnityLib/src/DisenchantUI.cs @@ -40,12 +40,9 @@ protected override void DoMainAction() if (!LocalPlayerCanAffordCost(cost)) return; - var player = Player.m_localPlayer; - var inventory = player.GetInventory(); foreach (var costElement in cost) { - var costItem = costElement.GetItem(); - inventory.RemoveItem(costItem.m_shared.m_name, costItem.m_stack); + InventoryManagement.Instance.RemoveItem(costElement.GetItem()); } var bonusItems = DisenchantItem(item); diff --git a/EpicLoot-UnityLib/EnchantBonus.cs b/EpicLoot-UnityLib/src/EnchantBonus.cs similarity index 100% rename from EpicLoot-UnityLib/EnchantBonus.cs rename to EpicLoot-UnityLib/src/EnchantBonus.cs diff --git a/EpicLoot-UnityLib/EnchantUI.cs b/EpicLoot-UnityLib/src/EnchantUI.cs similarity index 97% rename from EpicLoot-UnityLib/EnchantUI.cs rename to EpicLoot-UnityLib/src/EnchantUI.cs index 962d6c65..5cb5fd63 100644 --- a/EpicLoot-UnityLib/EnchantUI.cs +++ b/EpicLoot-UnityLib/src/EnchantUI.cs @@ -147,7 +147,9 @@ protected override void DoMainAction() Cancel(); if (selectedItem?.Item1.GetItem() == null) + { return; + } var item = selectedItem.Item1.GetItem(); var cost = GetEnchantCost(item, _rarity); @@ -161,16 +163,16 @@ protected override void DoMainAction() return; } - var inventory = player.GetInventory(); foreach (var costElement in cost) { - var costItem = costElement.GetItem(); - inventory.RemoveItem(costItem.m_shared.m_name, costItem.m_stack); + InventoryManagement.Instance.RemoveItem(costElement.GetItem()); } } if (_successDialog != null) + { Destroy(_successDialog); + } DeselectAll(); Lock(); diff --git a/EpicLoot-UnityLib/EnchantingTable.cs b/EpicLoot-UnityLib/src/EnchantingTable.cs similarity index 87% rename from EpicLoot-UnityLib/EnchantingTable.cs rename to EpicLoot-UnityLib/src/EnchantingTable.cs index 76cb773c..febf77bf 100644 --- a/EpicLoot-UnityLib/EnchantingTable.cs +++ b/EpicLoot-UnityLib/src/EnchantingTable.cs @@ -74,7 +74,6 @@ public void RequestTableUpgrade(EnchantingFeature feature, int toLevel, Action$piece_toofar") + ? Localization.instance.Localize("$piece_toofar") : Localization.instance.Localize($"${DisplayNameLocID}\n[$KEY_Use] $piece_use"); } @@ -187,12 +195,17 @@ private void InitFeatureLevels() private static int GetDefaultFeatureLevel(EnchantingFeature feature) { if (!UpgradesActive(feature, out var featureActive)) + { return FeatureLevelOne; + } if (!featureActive) + { return FeatureUnavailableSentinel; + } - return EnchantingTableUpgrades.Config.DefaultFeatureLevels.TryGetValue(feature, out var level) ? level : FeatureUnavailableSentinel; + return EnchantingTableUpgrades.Config.DefaultFeatureLevels.TryGetValue(feature, out var level) ? + level : FeatureUnavailableSentinel; } public void Reset() @@ -206,22 +219,25 @@ public void Reset() public int GetFeatureLevel(EnchantingFeature feature) { if (_nview == null || _nview.GetZDO() == null) + { return FeatureUnavailableSentinel; + } - if (!UpgradesActive(feature, out var featureActive)) { return FeatureLevelOne; } if (!featureActive) + { return FeatureUnavailableSentinel; + } var featureName = feature.ToString(); var level = _nview.GetZDO().GetInt(FormatFeatureName(featureName), FeatureUnavailableSentinel); //For those that travel here from afar, you might be asking yourself why I'm adding and subtracting 1 to the level. //It's because Iron Gate decided that 0 value ZDO's should be removed when world save occurs........ - var returncode = level == FeatureUnavailableSentinel ? FeatureUnavailableSentinel : level - 1; + //var returncode = level == FeatureUnavailableSentinel ? FeatureUnavailableSentinel : level - 1; return level == FeatureUnavailableSentinel ? FeatureUnavailableSentinel : level - 1; } @@ -236,11 +252,13 @@ public void SetFeatureLevel(EnchantingFeature feature, int level) } else { - if (level > (EnchantingTableUpgrades.Config.MaximumFeatureLevels.TryGetValue(feature, out var maxLevel) ? maxLevel : 1)) + if (level > (EnchantingTableUpgrades.Config.MaximumFeatureLevels.TryGetValue( + feature, out var maxLevel) ? maxLevel : 1)) { return; } } + var featureName = feature.ToString(); _nview.GetZDO().Set(FormatFeatureName(featureName), level+1); OnFeatureLevelChanged?.Invoke(feature, level); @@ -270,7 +288,10 @@ public bool IsFeatureMaxLevel(EnchantingFeature feature) public List GetFeatureUnlockCost(EnchantingFeature feature) { if (IsFeatureUnlocked(feature)) - Debug.LogWarning($"[EpicLoot] Warning: tried to get unlock cost for a feature that is already unlocked! ({feature})"); + { + Debug.LogWarning($"[EpicLoot] Warning: " + + $"tried to get unlock cost for a feature that is already unlocked! ({feature})"); + } return EnchantingTableUpgrades.GetUpgradeCost(feature, 0); } @@ -278,7 +299,10 @@ public List GetFeatureUnlockCost(EnchantingFeature fea public List GetFeatureUpgradeCost(EnchantingFeature feature) { if (IsFeatureLocked(feature) || !IsFeatureAvailable(feature)) - Debug.LogWarning($"[EpicLoot] Warning: tried to get enchanting feature unlock cost for a feature that is locked or unavailable! ({feature})"); + { + Debug.LogWarning($"[EpicLoot] Warning: " + + $"tried to get enchanting feature unlock cost for a feature that is locked or unavailable! ({feature})"); + } var currentLevel = GetFeatureLevel(feature); return EnchantingTableUpgrades.GetUpgradeCost(feature, currentLevel + 1); @@ -287,10 +311,14 @@ public List GetFeatureUpgradeCost(EnchantingFeature fe public Tuple GetFeatureValue(EnchantingFeature feature, int level) { if (!IsFeatureAvailable(feature)) + { return new Tuple(float.NaN, float.NaN); + } if (level < 0 || level > EnchantingTableUpgrades.GetFeatureMaxLevel(feature)) + { return new Tuple(float.NaN, float.NaN); + } var values = feature switch { @@ -304,13 +332,21 @@ public Tuple GetFeatureValue(EnchantingFeature feature, int level) }; if (level >= values.Count) + { return new Tuple(float.NaN, float.NaN); + } var levelValues = values[level]; if (levelValues.Length == 1) + { return new Tuple(levelValues[0], float.NaN); + } + if (levelValues.Length >= 2) + { return new Tuple(levelValues[0], levelValues[1]); + } + return new Tuple(float.NaN, float.NaN); } diff --git a/EpicLoot-UnityLib/EnchantingTableUI.cs b/EpicLoot-UnityLib/src/EnchantingTableUI.cs similarity index 76% rename from EpicLoot-UnityLib/EnchantingTableUI.cs rename to EpicLoot-UnityLib/src/EnchantingTableUI.cs index 3d714c2b..e520d1b8 100644 --- a/EpicLoot-UnityLib/EnchantingTableUI.cs +++ b/EpicLoot-UnityLib/src/EnchantingTableUI.cs @@ -36,52 +36,68 @@ public void Awake() var uiSFX = GameObject.Find("sfx_gui_button"); if (uiSFX) - Audio.outputAudioMixerGroup = uiSFX.GetComponent().outputAudioMixerGroup; + { + Audio.outputAudioMixerGroup = + uiSFX.GetComponent().outputAudioMixerGroup; + } + + AugaFixup(this); + } + private void SetupTabs() + { for (var index = 0; index < TabHandler.m_tabs.Count; index++) { var tabData = TabHandler.m_tabs[index]; tabData.m_onClick.AddListener(PlayTabSelectSFX); var featureStatus = tabData.m_button.gameObject.GetComponent(); if (featureStatus != null) - featureStatus.SetFeature((EnchantingFeature)index); + { + featureStatus.Refresh(); + } } - - AugaFixup(this); TabActivation(this); } public static void Show(GameObject enchantingUiPrefab, EnchantingTable source) { - if (instance == null) + bool firstSetup = false; + if (instance == null && StoreGui.instance != null) { - if (StoreGui.instance != null) - { - var inGameGui = StoreGui.instance.transform.parent; - var siblingIndex = StoreGui.instance.transform.GetSiblingIndex() + 1; - var enchantingUI = Instantiate(enchantingUiPrefab, inGameGui); - enchantingUI.transform.SetSiblingIndex(siblingIndex); - } + var inGameGui = StoreGui.instance.transform.parent; + var siblingIndex = StoreGui.instance.transform.GetSiblingIndex() + 1; + var enchantingUI = Instantiate(enchantingUiPrefab, inGameGui); + enchantingUI.transform.SetSiblingIndex(siblingIndex); + firstSetup = true; } if (instance == null) + { return; + } instance.SourceTable = source; instance.Root.SetActive(true); instance.Scrim.SetActive(true); instance.SourceTable.Refresh(); - + foreach (var panel in instance.Panels) { panel.DeselectAll(); } + + if (firstSetup) + { + instance.SetupTabs(); + } } public static void Hide() { if (instance == null) + { return; + } instance.Root.SetActive(false); instance.Scrim.SetActive(false); @@ -90,19 +106,24 @@ public static void Hide() public static bool IsVisible() { - return instance != null && ((instance._hiddenFrames <= 2) || (instance.Root != null && instance.Root.activeSelf)); + return instance != null && ((instance._hiddenFrames <= 2) || + (instance.Root != null && instance.Root.activeSelf)); } public static bool IsInTextInput() { if (!IsVisible()) + { return false; + } var textFields = instance.Root.GetComponentsInChildren(false); foreach (var inputField in textFields) { if (inputField.isFocused) + { return true; + } } return false; @@ -111,7 +132,9 @@ public static bool IsInTextInput() public void Update() { if (Root == null) + { return; + } if (!Root.activeSelf) { @@ -121,11 +144,18 @@ public void Update() _hiddenFrames = 0; - var disallowClose = (Chat.instance != null && Chat.instance.HasFocus()) || Console.IsVisible() || Menu.IsVisible() || (TextViewer.instance != null && TextViewer.instance.IsVisible()) || Player.m_localPlayer.InCutscene(); + var disallowClose = (Chat.instance != null && Chat.instance.HasFocus()) || + Console.IsVisible() || Menu.IsVisible() || (TextViewer.instance != null && + TextViewer.instance.IsVisible()) || Player.m_localPlayer.InCutscene(); + if (disallowClose) + { return; + } + + var gotCloseInput = ZInput.GetButtonDown("JoyButtonB") || + ZInput.GetKeyDown(KeyCode.Escape) || ZInput.GetKeyDown(KeyCode.Tab); - var gotCloseInput = ZInput.GetButtonDown("JoyButtonB") || Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.Tab); if (gotCloseInput) { ZInput.ResetButtonStatus("JoyButtonB"); @@ -143,7 +173,9 @@ public void Update() } if (!panelCapturedInput) + { Hide(); + } } } diff --git a/EpicLoot-UnityLib/src/EnchantingTableUIPanelBase.cs b/EpicLoot-UnityLib/src/EnchantingTableUIPanelBase.cs new file mode 100644 index 00000000..10caf06b --- /dev/null +++ b/EpicLoot-UnityLib/src/EnchantingTableUIPanelBase.cs @@ -0,0 +1,210 @@ +using System.Collections.Generic; +using TMPro; +using UnityEngine; +using UnityEngine.UI; + +namespace EpicLoot_UnityLib +{ + public abstract class EnchantingTableUIPanelBase : MonoBehaviour + { + public const float CountdownTime = 0.8f; + + public MultiSelectItemList AvailableItems; + public Button MainButton; + public GameObject LevelDisplay; + public GuiBar ProgressBar; + public AudioSource Audio; + public AudioClip ProgressLoopSFX; + public AudioClip CompleteSFX; + + protected bool _inProgress; + protected float _countdown; + protected Text _buttonLabel; + protected TMP_Text _tmpButtonLabel; + protected bool _useTMP = false; + protected string _defaultButtonLabelText; + protected bool _locked; + + protected abstract void DoMainAction(); + protected abstract void OnSelectedItemsChanged(); + + public virtual void Awake() + { + if (AvailableItems != null) + { + AvailableItems.OnSelectedItemsChanged += OnSelectedItemsChanged; + AvailableItems.GiveFocus(true, 0); + } + + if (MainButton != null) + { + MainButton.onClick.AddListener(OnMainButtonClicked); + _buttonLabel = MainButton.GetComponentInChildren(); + if (_buttonLabel == null) + { + _tmpButtonLabel = MainButton.GetComponentInChildren(); + _useTMP = true; + } + + _defaultButtonLabelText = _useTMP ? _tmpButtonLabel.text : _buttonLabel.text; + } + + var uiSFX = GameObject.Find("sfx_gui_button"); + if (uiSFX && Audio != null) + Audio.outputAudioMixerGroup = uiSFX.GetComponent().outputAudioMixerGroup; + } + + protected virtual void OnMainButtonClicked() + { + if (_inProgress) + Cancel(); + else + StartProgress(); + } + + public virtual void DeselectAll() + { + } + + public virtual void Update() + { + if (ProgressBar != null) + ProgressBar.gameObject.SetActive(_inProgress); + if (LevelDisplay != null) + LevelDisplay.gameObject.SetActive(!_inProgress); + + if (_inProgress) + { + if (ProgressBar != null) + ProgressBar.SetValue(CountdownTime - _countdown); + + _countdown -= Time.deltaTime; + if (_countdown < 0) + { + _inProgress = false; + _countdown = 0; + + if (Audio != null) + { + Audio.loop = false; + Audio.Stop(); + } + + DoMainAction(); + PlayCompleteSFX(); + } + } + } + + private void PlayCompleteSFX() + { + var clip = GetCompleteAudioClip(); + if (Audio != null && clip != null) + Audio.PlayOneShot(clip); + } + + protected virtual AudioClip GetCompleteAudioClip() + { + return CompleteSFX; + } + + public virtual void StartProgress() + { + if (_useTMP) + _tmpButtonLabel.text = Localization.instance.Localize("$menu_cancel"); + else + _buttonLabel.text = Localization.instance.Localize("$menu_cancel"); + _inProgress = true; + _countdown = CountdownTime; + + if (ProgressBar != null) + ProgressBar.SetMaxValue(CountdownTime); + + if (Audio != null) + { + Audio.loop = true; + Audio.clip = ProgressLoopSFX; + Audio.Play(); + } + + Lock(); + } + + public virtual bool CanCancel() + { + return _inProgress; + } + + public virtual void Cancel() + { + if (_useTMP) + _tmpButtonLabel.text = Localization.instance.Localize(_defaultButtonLabelText); + else + _buttonLabel.text = Localization.instance.Localize(_defaultButtonLabelText); + + _inProgress = false; + _countdown = 0; + + if (Audio != null) + { + Audio.loop = false; + Audio.Stop(); + } + + Unlock(); + } + + public virtual void Lock() + { + _locked = true; + var lists = GetComponentsInChildren(); + foreach (var list in lists) + { + list.Lock(); + } + + EnchantingTableUI.instance.LockTabs(); + } + + public virtual void Unlock() + { + _locked = false; + var lists = GetComponentsInChildren(); + foreach (var list in lists) + { + list.Unlock(); + } + + EnchantingTableUI.instance.UnlockTabs(); + } + + protected static bool LocalPlayerCanAffordCost(List cost) + { + if (Player.m_localPlayer.NoCostCheat()) + { + return true; + } + + foreach (var element in cost) + { + var item = element.GetItem(); + + if (!InventoryManagement.Instance.HasItem(item)) + { + return false; + } + } + + return true; + } + + protected static void GiveItemsToPlayer(List sacrificeProducts) + { + foreach (var sacrificeProduct in sacrificeProducts) + { + var item = sacrificeProduct.GetItem(); + InventoryManagement.Instance.GiveItem(item); + } + } + } +} diff --git a/EpicLoot-UnityLib/EnchantingTableUpgrades.cs b/EpicLoot-UnityLib/src/EnchantingTableUpgrades.cs similarity index 99% rename from EpicLoot-UnityLib/EnchantingTableUpgrades.cs rename to EpicLoot-UnityLib/src/EnchantingTableUpgrades.cs index 2e08ca9f..68bcb759 100644 --- a/EpicLoot-UnityLib/EnchantingTableUpgrades.cs +++ b/EpicLoot-UnityLib/src/EnchantingTableUpgrades.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Runtime.CompilerServices; using UnityEngine; namespace EpicLoot_UnityLib diff --git a/EpicLoot-UnityLib/FeatureStatus.cs b/EpicLoot-UnityLib/src/FeatureStatus.cs similarity index 91% rename from EpicLoot-UnityLib/FeatureStatus.cs rename to EpicLoot-UnityLib/src/FeatureStatus.cs index 14e30af3..5c95e732 100644 --- a/EpicLoot-UnityLib/FeatureStatus.cs +++ b/EpicLoot-UnityLib/src/FeatureStatus.cs @@ -20,7 +20,6 @@ public class FeatureStatus : MonoBehaviour public delegate bool UpgradesActiveDelegate(EnchantingFeature feature, out bool featureActive); public static UpgradesActiveDelegate UpgradesActive; - public void Awake() { if (Tooltip != null) @@ -29,13 +28,15 @@ public void Awake() public void OnEnable() { - EnchantingTableUI.instance.SourceTable.OnFeatureLevelChanged += OnFeatureLevelChanged; + if (EnchantingTableUI.instance != null && EnchantingTableUI.instance.SourceTable != null) + EnchantingTableUI.instance.SourceTable.OnFeatureLevelChanged += OnFeatureLevelChanged; Refresh(); } public void OnDisable() { - EnchantingTableUI.instance.SourceTable.OnFeatureLevelChanged -= OnFeatureLevelChanged; + if (EnchantingTableUI.instance != null && EnchantingTableUI.instance.SourceTable != null) + EnchantingTableUI.instance.SourceTable.OnFeatureLevelChanged -= OnFeatureLevelChanged; } public void SetFeature(EnchantingFeature feature) @@ -106,7 +107,7 @@ public void Refresh() UnlockedLabel.SetActive(level == 0); } - if (Tooltip != null && UpgradesActive(Feature,out _)) + if (Tooltip != null && UpgradesActive(Feature, out _)) { Tooltip.m_topic = Localization.instance.Localize(EnchantingTableUpgrades.GetFeatureName(Feature)); diff --git a/EpicLoot-UnityLib/FeatureStatus3D.cs b/EpicLoot-UnityLib/src/FeatureStatus3D.cs similarity index 100% rename from EpicLoot-UnityLib/FeatureStatus3D.cs rename to EpicLoot-UnityLib/src/FeatureStatus3D.cs diff --git a/EpicLoot-UnityLib/src/InventoryManagement.cs b/EpicLoot-UnityLib/src/InventoryManagement.cs new file mode 100644 index 00000000..52f0156d --- /dev/null +++ b/EpicLoot-UnityLib/src/InventoryManagement.cs @@ -0,0 +1,187 @@ +using System.Collections.Generic; +using UnityEngine; + +namespace EpicLoot_UnityLib; + +public class InventoryManagement +{ + static InventoryManagement() { } + private InventoryManagement() { } + private static readonly InventoryManagement _instance = new InventoryManagement(); + + public static InventoryManagement Instance + { + get => _instance; + } + + private void SendMessage(string message, int amount, Sprite icon) + { + Player.m_localPlayer.Message(MessageHud.MessageType.TopLeft, + message, amount, icon); + } + + private Inventory GetInventory() + { + Player player = Player.m_localPlayer; + + if (player != null) + { + return player.GetInventory(); + } + + return null; + } + + public List GetAllItems() + { + Inventory inventory = GetInventory(); + if (inventory != null) + { + return inventory.GetAllItems(); + } + + return null; + } + + public bool HasItem(ItemDrop.ItemData item) + { + Inventory inventory = GetInventory(); + + if (inventory == null || inventory.CountItems(item.m_shared.m_name) < item.m_stack) + { + return false; + } + + return true; + } + + public int CountItem(ItemDrop.ItemData item) + { + return CountItem(item.m_shared.m_name); + } + + public int CountItem(string item) + { + Inventory inventory = GetInventory(); + + if (inventory == null) + { + return 0; + } + + return inventory.CountItems(item); + } + + public void GiveItem(string item, int amount) + { + Debug.Log($"Attempting to give item {item} with amount {amount}"); + Inventory inventory = GetInventory(); + if (inventory != null) + { + AddItem(ref inventory, item, amount); + } + else + { + DropItem(item, amount); + } + } + + public bool GiveItem(ItemDrop.ItemData item) + { + Debug.Log($"Attempting to give itemdata {item.m_shared.m_name} with amount {item.m_stack}"); + Inventory inventory = GetInventory(); + + do + { + var itemToAdd = item.Clone(); + itemToAdd.m_stack = Mathf.Min(item.m_stack, item.m_shared.m_maxStackSize); + item.m_stack -= itemToAdd.m_stack; + + if (inventory != null) + { + AddItem(ref inventory, itemToAdd); + } + else + { + DropItem(itemToAdd); + } + } while (item.m_stack > 0); + + return true; + } + + private void AddItem(ref Inventory inventory, string item, int amount) + { + var result = inventory.AddItem(item, amount, 1, 0, 0, string.Empty); + + if (result == null) + { + DropItem(item, amount); + } + } + + private void AddItem(ref Inventory inventory, ItemDrop.ItemData item) + { + if (inventory.AddItem(item)) + { + SendMessage($"$msg_added {item.m_shared.m_name}", item.m_stack, item.GetIcon()); + } + else + { + DropItem(item); + } + } + + private void DropItem(string item, int amount) + { + Debug.Log($"Attempting to drop item {item} with amount {amount}"); + Player player = Player.m_localPlayer; + var prefab = ObjectDB.instance.GetItemPrefab(item); + + if (prefab != null) + { + var go = GameObject.Instantiate(prefab, + player.transform.position + player.transform.forward + player.transform.up, + player.transform.rotation); + + var itemdrop = go.GetComponent(); + itemdrop.SetStack(amount); + itemdrop.GetComponent().velocity = Vector3.up * 5f; + + SendMessage($"$msg_dropped {itemdrop.m_itemData.m_shared.m_name}", + itemdrop.m_itemData.m_stack, itemdrop.m_itemData.GetIcon()); + } + } + + private void DropItem(ItemDrop.ItemData item) + { + Debug.Log($"Attempting to drop itemdata {item.m_shared.m_name} with amount {item.m_stack}"); + Player player = Player.m_localPlayer; + var itemDrop = ItemDrop.DropItem(item, item.m_stack, + player.transform.position + player.transform.forward + player.transform.up, + player.transform.rotation); + itemDrop.GetComponent().velocity = Vector3.up * 5f; + + SendMessage($"$msg_dropped {itemDrop.m_itemData.m_shared.m_name}", + itemDrop.m_itemData.m_stack, itemDrop.m_itemData.GetIcon()); + } + + public void RemoveExactItem(ItemDrop.ItemData item, int amount) + { + Inventory inventory = GetInventory(); + + inventory.RemoveItem(item, amount); + } + + public void RemoveItem(ItemDrop.ItemData item) + { + RemoveItem(item.m_shared.m_name, item.m_stack); + } + + public void RemoveItem(string item, int amount) + { + Inventory inventory = GetInventory(); + + inventory.RemoveItem(item, amount); + } +} diff --git a/EpicLoot-UnityLib/MultiSelectItemList.cs b/EpicLoot-UnityLib/src/MultiSelectItemList.cs similarity index 100% rename from EpicLoot-UnityLib/MultiSelectItemList.cs rename to EpicLoot-UnityLib/src/MultiSelectItemList.cs diff --git a/EpicLoot-UnityLib/MultiSelectItemListElement.cs b/EpicLoot-UnityLib/src/MultiSelectItemListElement.cs similarity index 98% rename from EpicLoot-UnityLib/MultiSelectItemListElement.cs rename to EpicLoot-UnityLib/src/MultiSelectItemListElement.cs index 59f6b113..53028193 100644 --- a/EpicLoot-UnityLib/MultiSelectItemListElement.cs +++ b/EpicLoot-UnityLib/src/MultiSelectItemListElement.cs @@ -281,10 +281,10 @@ public void Refresh() var quantityText = string.Format(ReadOnly ? ReadOnlyQuantityFormat : TotalQuantityFormat, _item.GetMax()); if (CheckPlayerInventory) { - var inventory = Player.m_localPlayer.GetInventory(); - var hasEnough = inventory.CountItems(_item.GetItem().m_shared.m_name) >= _item.GetItem().m_stack; - if (!hasEnough) + if (!InventoryManagement.Instance.HasItem(_item.GetItem())) + { quantityText = $"{quantityText}"; + } } ItemTotalQuantity.text = quantityText; } diff --git a/EpicLoot-UnityLib/MultiSelectListFocusController.cs b/EpicLoot-UnityLib/src/MultiSelectListFocusController.cs similarity index 100% rename from EpicLoot-UnityLib/MultiSelectListFocusController.cs rename to EpicLoot-UnityLib/src/MultiSelectListFocusController.cs diff --git a/EpicLoot-UnityLib/PlaySoundOnChecked.cs b/EpicLoot-UnityLib/src/PlaySoundOnChecked.cs similarity index 100% rename from EpicLoot-UnityLib/PlaySoundOnChecked.cs rename to EpicLoot-UnityLib/src/PlaySoundOnChecked.cs diff --git a/EpicLoot-UnityLib/SacrificeUI.cs b/EpicLoot-UnityLib/src/SacrificeUI.cs similarity index 84% rename from EpicLoot-UnityLib/SacrificeUI.cs rename to EpicLoot-UnityLib/src/SacrificeUI.cs index b419f85b..bd518da2 100644 --- a/EpicLoot-UnityLib/SacrificeUI.cs +++ b/EpicLoot-UnityLib/src/SacrificeUI.cs @@ -48,11 +48,9 @@ protected override void DoMainAction() } } - var player = Player.m_localPlayer; - var inventory = player.GetInventory(); foreach (var selectedItem in selectedItems) { - inventory.RemoveItem(selectedItem.Item1.GetItem(), selectedItem.Item2); + InventoryManagement.Instance.RemoveExactItem(selectedItem.Item1.GetItem(), selectedItem.Item2); } GiveItemsToPlayer(sacrificeProducts); @@ -74,13 +72,17 @@ protected override void OnSelectedItemsChanged() var selectedItems = AvailableItems.GetSelectedItems(); var sacrificeProducts = GetSacrificeProducts(selectedItems.Select(x => new Tuple(x.Item1.GetItem(), x.Item2)).ToList()); SacrificeProducts.SetItems(sacrificeProducts.Cast().ToList()); - var featureUnlocked = EnchantingTableUI.instance.SourceTable.IsFeatureUnlocked(EnchantingFeature.Sacrifice); + var featureUnlocked = EnchantingTableUI.instance != null && EnchantingTableUI.instance.SourceTable != null && EnchantingTableUI.instance.SourceTable.IsFeatureUnlocked(EnchantingFeature.Sacrifice); MainButton.interactable = featureUnlocked && selectedItems.Count > 0; } public override void Cancel() { - _buttonLabel.text = Localization.instance.Localize("$mod_epicloot_sacrifice"); + if (_useTMP) + _tmpButtonLabel.text = Localization.instance.Localize("$mod_epicloot_sacrifice"); + else + _buttonLabel.text = Localization.instance.Localize("$mod_epicloot_sacrifice"); + base.Cancel(); } diff --git a/EpicLoot-UnityLib/src/SelectableTextColor.cs b/EpicLoot-UnityLib/src/SelectableTextColor.cs new file mode 100644 index 00000000..1ce2da5d --- /dev/null +++ b/EpicLoot-UnityLib/src/SelectableTextColor.cs @@ -0,0 +1,48 @@ +using TMPro; +using UnityEngine; +using UnityEngine.UI; + +namespace EpicLoot_UnityLib +{ + public class SelectableTextColor : MonoBehaviour + { + private Color _defaultColor = Color.white; + public Color DisabledColor = Color.grey; + private Selectable _selectable; + private Text _text; + private TMP_Text _tmpText; + private bool useTMP = false; + + public void Awake() + { + _selectable = GetComponent(); + _text = GetComponentInChildren(); + if (_text != null) + { + _defaultColor = _text.color; + return; + } + _tmpText = GetComponentInChildren(); + _defaultColor = _tmpText.color; + useTMP = true; + } + + public void Update() + { + if (_selectable.IsInteractable()) + { + if (!useTMP) + _text.color = _defaultColor; + else + _tmpText.color = _defaultColor; + } + else + { + if (!useTMP) + _text.color = DisabledColor; + else + _tmpText.color = DisabledColor; + } + } + } +} diff --git a/EpicLoot-UnityLib/SetRarityColor.cs b/EpicLoot-UnityLib/src/SetRarityColor.cs similarity index 100% rename from EpicLoot-UnityLib/SetRarityColor.cs rename to EpicLoot-UnityLib/src/SetRarityColor.cs diff --git a/EpicLoot-UnityLib/TableUpgradeDecorations.cs b/EpicLoot-UnityLib/src/TableUpgradeDecorations.cs similarity index 100% rename from EpicLoot-UnityLib/TableUpgradeDecorations.cs rename to EpicLoot-UnityLib/src/TableUpgradeDecorations.cs diff --git a/EpicLoot-UnityLib/UpgradeTableUI.cs b/EpicLoot-UnityLib/src/UpgradeTableUI.cs similarity index 81% rename from EpicLoot-UnityLib/UpgradeTableUI.cs rename to EpicLoot-UnityLib/src/UpgradeTableUI.cs index 9e04b7e4..479bd7b1 100644 --- a/EpicLoot-UnityLib/UpgradeTableUI.cs +++ b/EpicLoot-UnityLib/src/UpgradeTableUI.cs @@ -26,6 +26,7 @@ public override void Awake() { base.Awake(); _featureButtons.Clear(); + for (var i = 0; i < ListContainer.childCount; ++ i) { var child = ListContainer.GetChild(i); @@ -38,8 +39,16 @@ public override void Awake() button.SelectMaxQuantity(true); } } + } + + public void OnEnable() + { + if (EnchantingTableUI.instance.SourceTable != null) + { + EnchantingTableUI.instance.SourceTable.OnAnyFeatureLevelChanged -= Refresh; + EnchantingTableUI.instance.SourceTable.OnAnyFeatureLevelChanged += Refresh; + } - EnchantingTableUI.instance.SourceTable.OnAnyFeatureLevelChanged += Refresh; Refresh(); } @@ -49,25 +58,24 @@ private void OnButtonSelected(MultiSelectItemListElement selectedButton, bool se return; var noneSelected = !_featureButtons.Any(x => x.IsSelected()); - if (noneSelected) - { - _selectedFeature = -1; - Refresh(); - return; - } _selectedFeature = -1; - for (var index = 0; index < _featureButtons.Count; index++) + + if (!noneSelected) { - var button = _featureButtons[index]; - if (button == selectedButton) + for (var index = 0; index < _featureButtons.Count; index++) { - _selectedFeature = index; - } - else - { button.SuppressEvents = true; - button.Deselect(true); - button.SuppressEvents = false; + var button = _featureButtons[index]; + if (button == selectedButton) + { + _selectedFeature = index; + } + else + { + button.SuppressEvents = true; + button.Deselect(true); + button.SuppressEvents = false; + } } } @@ -76,6 +84,11 @@ private void OnButtonSelected(MultiSelectItemListElement selectedButton, bool se public void Refresh() { + if (EnchantingTableUI.instance.SourceTable == null) + { + return; + } + for (var index = 0; index < _featureButtons.Count; index++) { var button = _featureButtons[index]; @@ -130,7 +143,11 @@ public void Refresh() CostLabel.text = Localization.instance.Localize("$mod_epicloot_unlockcost"); CostList.SetItems(cost.Cast().ToList()); canAfford = LocalPlayerCanAffordCost(cost); - _buttonLabel.text = Localization.instance.Localize("$mod_epicloot_featureunlock"); + var buttonText = Localization.instance.Localize("$mod_epicloot_featureunlock"); + if (_useTMP) + _tmpButtonLabel.text = buttonText; + else + _buttonLabel.text = buttonText; } else { @@ -138,7 +155,11 @@ public void Refresh() CostLabel.text = Localization.instance.Localize("$mod_epicloot_upgradecost"); CostList.SetItems(cost.Cast().ToList()); canAfford = LocalPlayerCanAffordCost(cost); - _buttonLabel.text = Localization.instance.Localize("$mod_epicloot_upgrade"); + var buttonText = Localization.instance.Localize("$mod_epicloot_upgrade"); + if (_useTMP) + _tmpButtonLabel.text = buttonText; + else + _buttonLabel.text = buttonText; } } @@ -174,7 +195,7 @@ private string GenerateFeatureInfoText() for (var i = 1; i <= maxLevel; ++i) { var text = EnchantingTableUpgrades.GetFeatureUpgradeLevelDescription(EnchantingTableUI.instance.SourceTable, feature, i); - sb.AppendLine($"{i}: " + (i == currentLevel ? $"{text}" : text)); + sb.AppendLine($"{i}: " + (i == currentLevel ? $"{text}" : text)); } return sb.ToString(); @@ -191,8 +212,8 @@ protected override void DoMainAction() if (maxLevel) return; - var cost = EnchantingTableUI.instance.SourceTable.IsFeatureLocked(feature) - ? EnchantingTableUI.instance.SourceTable.GetFeatureUnlockCost(feature) + var cost = EnchantingTableUI.instance.SourceTable.IsFeatureLocked(feature) + ? EnchantingTableUI.instance.SourceTable.GetFeatureUnlockCost(feature) : EnchantingTableUI.instance.SourceTable.GetFeatureUpgradeCost(feature); var canAfford = LocalPlayerCanAffordCost(cost); @@ -203,7 +224,8 @@ protected override void DoMainAction() { if (!success) { - Debug.LogError($"[Enchanting Upgrade] ERROR: Tried to upgrade ({feature}) to level ({currentLevel + 1}) but it failed!"); + Debug.LogError($"[Enchanting Upgrade] ERROR: " + + $"Tried to upgrade ({feature}) to level ({currentLevel + 1}) but it failed!"); return; } @@ -212,15 +234,14 @@ protected override void DoMainAction() { if (!LocalPlayerCanAffordCost(cost)) { - Debug.LogError("[Augment Item] ERROR: Tried to augment item but could not afford the cost. This should not happen!"); + Debug.LogError("[Augment Item] ERROR: Tried to augment item but could not afford the cost. " + + "This should not happen!"); return; } - var inventory = player.GetInventory(); foreach (var costElement in cost) { - var costItem = costElement.GetItem(); - inventory.RemoveItem(costItem.m_shared.m_name, costItem.m_stack); + InventoryManagement.Instance.RemoveItem(costElement.GetItem()); } } diff --git a/EpicLoot/Abilities/AbilityDefinitions.cs b/EpicLoot/Abilities/AbilityDefinitions.cs deleted file mode 100644 index 7cc977d8..00000000 --- a/EpicLoot/Abilities/AbilityDefinitions.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Collections.Generic; - -namespace EpicLoot.Abilities -{ - public static class AbilityDefinitions - { - public static AbilityConfig Config; - public static readonly Dictionary Abilities = new Dictionary(); - - public static void Initialize(AbilityConfig config) - { - Config = config; - - Abilities.Clear(); - foreach (var def in Config.Abilities) - { - Abilities.Add(def.ID, def); - } - } - - public static bool TryGetAbilityDef(string abilityID, out AbilityDefinition abilityDef) - { - return Abilities.TryGetValue(abilityID, out abilityDef); - } - } -} diff --git a/EpicLoot/Abilities/AbilityFactory.cs b/EpicLoot/Abilities/AbilityFactory.cs deleted file mode 100644 index dde78b0e..00000000 --- a/EpicLoot/Abilities/AbilityFactory.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace EpicLoot.Abilities -{ - public static class AbilityFactory - { - public static readonly Dictionary AbilityClassTypes = new Dictionary(); - - public static void Register(string abilityID, Type abilityClassType) - { - AbilityClassTypes.Add(abilityID, abilityClassType); - } - - public static Ability Create(string abilityID) - { - if (AbilityClassTypes.TryGetValue(abilityID, out var abilityClassType)) - { - return (Ability)Activator.CreateInstance(abilityClassType); - } - - return new Ability(); - } - } -} diff --git a/EpicLoot/Adventure/BountyManagmentSystem.cs b/EpicLoot/Adventure/BountyManagmentSystem.cs deleted file mode 100644 index af40f1c7..00000000 --- a/EpicLoot/Adventure/BountyManagmentSystem.cs +++ /dev/null @@ -1,127 +0,0 @@ -using System; -using System.IO; -using System.Linq; -using System.Runtime.Serialization.Formatters.Binary; -using BepInEx; -using EpicLoot.Adventure.Feature; -using Newtonsoft.Json; -using UnityEngine; - -namespace EpicLoot.Adventure; - -public class BountyManagmentSystem : MonoBehaviour -{ - public static BountyManagmentSystem Instance => _instance; - - public BountyLedger BountyLedger => _bountyLedger; - - private BountyLedger _bountyLedger; - private BountyLedger _tempBountyLedger; - private static BountyManagmentSystem _instance; - private const string LedgerIdentifier = "randyknapp.mods.epicloot.BountyLedger"; - private static string _ledgerSaveDirectory = Path.Combine(Paths.ConfigPath, "EpicLoot","BountySaves"); - private static string _ledgerSaveFile = Path.Combine(_ledgerSaveDirectory, $"{LedgerIdentifier}.{ZNet.m_world.m_uid}.dat"); - - private void Awake() - { - Directory.CreateDirectory(_ledgerSaveDirectory); - _instance = this; - } - - private void Start() - { - LoadBounties(); - InvokeRepeating(nameof(SaveBounties), 0f, 60f); - } - - private void SaveBounties() - { - if (!Common.Utils.IsServer() || ZoneSystem.instance == null || _bountyLedger == null) - { - return; - } - - SaveTempLedger(); - - var bf = new BinaryFormatter(); - var fs = File.Create(_ledgerSaveFile); - - bf.Serialize(fs,_tempBountyLedger); - fs.Close(); - } - - private void LoadBounties() - { - if (!Common.Utils.IsServer() || ZoneSystem.instance == null) - { - return; - } - - var globalKeys = ZoneSystem.instance.GetGlobalKeys(); - - if (File.Exists(_ledgerSaveFile)) - { - var bf = new BinaryFormatter(); - var fs = File.Open(_ledgerSaveFile, FileMode.Open); - var ledgerDataFile = bf.Deserialize(fs) as BountyLedger; - fs.Close(); - - if (ledgerDataFile != null) - { - _bountyLedger = ledgerDataFile; - } - } - else - { - var ledgerGlobalKey = globalKeys.Find(x => x.StartsWith(LedgerIdentifier,StringComparison.OrdinalIgnoreCase)); - var ledgerData = ledgerGlobalKey?.Substring(LedgerIdentifier.Length); - - if (string.IsNullOrEmpty(ledgerData)) - { - _bountyLedger = new BountyLedger { WorldID = ZNet.m_world.m_uid }; - } - else - { - try - { - _bountyLedger = JsonConvert.DeserializeObject(ledgerData); - } - catch (Exception) - { - Debug.LogWarning("[EpicLoot] WARNING! Could not load bounty kill ledger, kills made by other players may not have counted towards your bounties."); - _bountyLedger = new BountyLedger { WorldID = ZNet.m_world.m_uid }; - } - } - } - - foreach (var globalKey in globalKeys.Where(globalKey => globalKey.StartsWith(LedgerIdentifier,StringComparison.OrdinalIgnoreCase))) - { - ZoneSystem.instance.m_globalKeys.Remove(globalKey); - } - - } - - public void Shutdown(bool save = true) - { - if (!Common.Utils.IsServer() || ZoneSystem.instance == null || BountyLedger == null) - { - return; - } - - if (!save) - return; - - SaveTempLedger(); - - ZoneSystem.instance.m_globalKeys.RemoveWhere(x => x.StartsWith(LedgerIdentifier,StringComparison.OrdinalIgnoreCase)); - - var ledgerData = JsonConvert.SerializeObject(_tempBountyLedger, Formatting.None); - ledgerData = LedgerIdentifier + ledgerData; - ZoneSystem.instance.SetGlobalKey(ledgerData); - } - - private void SaveTempLedger() - { - _tempBountyLedger = _bountyLedger; - } -} \ No newline at end of file diff --git a/EpicLoot/Adventure/BountyTarget.cs b/EpicLoot/Adventure/BountyTarget.cs deleted file mode 100644 index d399dbcf..00000000 --- a/EpicLoot/Adventure/BountyTarget.cs +++ /dev/null @@ -1,186 +0,0 @@ -using System; -using HarmonyLib; -using JetBrains.Annotations; -using UnityEngine; - -namespace EpicLoot.Adventure -{ - [RequireComponent(typeof(Character))] - public class BountyTarget : MonoBehaviour - { - public const string BountyIDKey = "BountyID"; - public const string BountyDataKey = "BountyData"; - public const string MonsterIDKey = "MonsterID"; - public const string IsAddKey = "IsAdd"; - public const string BountyTargetNameKey = "BountyTargetName"; - - private BountyInfo _bountyInfo; - private string _monsterID; - private bool _isAdd; - - private Character _character; - private ZDO _zdo; - - [UsedImplicitly] - public void Awake() - { - _character = GetComponent(); - _character.m_onDeath += OnDeath; - _zdo = _character.m_nview.GetZDO(); - - if (HasBeenSetup()) - { - Reinitialize(); - } - } - - [UsedImplicitly] - public void OnDestroy() - { - if (_character != null) - { - _character.m_onDeath -= OnDeath; - } - } - - private bool HasBeenSetup() - { - var bountyID = _zdo.GetString(BountyIDKey); - return !string.IsNullOrEmpty(bountyID); - } - - private void OnDeath() - { - if (ZNet.instance.IsServer() || !ZNet.instance.IsServer() && !ZNet.instance.IsDedicated()) - { - var pkg = new ZPackage(); - _bountyInfo.ToPackage(pkg); - - EpicLoot.LogWarning($"SENDING -> RPC_SlayBountyTarget: {_monsterID} ({(_isAdd ? "minion" : "target")})"); - ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "SlayBountyTarget", pkg, _monsterID, _isAdd); - } - else - { - var bountyID = _zdo.GetString(BountyIDKey); - EpicLoot.LogWarning($"SENDING -> RPC_SlayBountyTargetFromBountyId: (bountyID={bountyID}) {_monsterID} ({(_isAdd ? "minion" : "target")})"); - ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "SlayBountyIDTarget", _monsterID, _isAdd, bountyID); - } - } - - public void Initialize(BountyInfo bounty, string monsterID, bool isAdd) - { - _zdo.Set(BountyIDKey, bounty.ID); - if (ZNet.instance.IsServer() || !ZNet.instance.IsServer() && !ZNet.instance.IsDedicated()) - { - var pkg = new ZPackage(); - bounty.ToPackage(pkg); - pkg.SetPos(0); - _zdo.Set(BountyDataKey, pkg.GetBase64()); - } - _zdo.Set(MonsterIDKey, monsterID); - _zdo.Set(IsAddKey, isAdd); - _zdo.Set(BountyTargetNameKey, GetTargetName(_character.m_name, isAdd, bounty.TargetName)); - - _character.SetLevel(GetTargetLevel(bounty, monsterID, isAdd)); - _character.SetMaxHealth(GetModifiedMaxHealth(_character, bounty, isAdd)); - _character.m_baseAI.SetPatrolPoint(); - - Reinitialize(); - } - - public void Reinitialize() - { - if (ZNet.instance.IsServer() || !ZNet.instance.IsServer() && !ZNet.instance.IsDedicated()) - { - var pkgString = _zdo.GetString(BountyDataKey); - var pkg = new ZPackage(pkgString); - try - { - _bountyInfo = BountyInfo.FromPackage(pkg); - } - catch (Exception) - { - Debug.LogError($"[EpicLoot] Error loading bounty info on creature ({name})! Possibly old or outdated bounty target, destroying creature.\nBountyData:\n{pkgString}"); - _zdo.Set("BountyTarget", ""); - _zdo.Set(BountyDataKey, ""); - _character.m_nview.Destroy(); - return; - } - } - _monsterID = _zdo.GetString(MonsterIDKey); - _isAdd = _zdo.GetBool(IsAddKey); - - _character.m_name = _zdo.GetString(BountyTargetNameKey); - _character.m_boss = !_zdo.GetBool(IsAddKey); - } - - private static float GetModifiedMaxHealth(Character character, BountyInfo bounty, bool isAdd) - { - if (isAdd) - { - return character.GetMaxHealth() * AdventureDataManager.Config.Bounties.AddsHealthMultiplier; - } - - if (bounty.RewardGold > 0) - { - return character.GetMaxHealth() * AdventureDataManager.Config.Bounties.GoldHealthMultiplier; - } - - return character.GetMaxHealth() * AdventureDataManager.Config.Bounties.IronHealthMultiplier; - } - - private static string GetTargetName(string originalName, bool isAdd, string targetName) - { - return isAdd ? - Localization.instance.Localize("$mod_epicloot_bounties_minionname", originalName) - : (string.IsNullOrEmpty(targetName) ? originalName : targetName); - } - - private static int GetTargetLevel(BountyInfo bounty, string monsterID, bool isAdd) - { - if (isAdd) - { - foreach (var targetInfo in bounty.Adds) - { - if (targetInfo.MonsterID == monsterID) - { - return targetInfo.Level; - } - } - - return 1; - } - - return bounty.Target.Level; - } - } - - [HarmonyPatch(typeof(Humanoid), nameof(Humanoid.Start))] - [HarmonyPatch(typeof(Character), nameof(Character.Start))] - public static class Character_Start_Patch - { - public static void Postfix(Character __instance) - { - var zdo = __instance.m_nview != null ? __instance.m_nview.GetZDO() : null; - - if (zdo != null && zdo.IsValid()) - { - var old = !string.IsNullOrEmpty(zdo.GetString("BountyTarget")); - - if (old) - { - EpicLoot.LogWarning($"Destroying old bounty target: {__instance.name}"); - zdo.Set("BountyTarget", ""); - __instance.m_nview.Destroy(); - return; - } - - if (!string.IsNullOrEmpty(zdo.GetString(BountyTarget.BountyIDKey))) - { - var bountyTarget = __instance.gameObject.AddComponent(); - bountyTarget.Reinitialize(); - } - } - } - } -} diff --git a/EpicLoot/Adventure/Feature/Bounties.cs b/EpicLoot/Adventure/Feature/Bounties.cs deleted file mode 100644 index 69c37ab6..00000000 --- a/EpicLoot/Adventure/Feature/Bounties.cs +++ /dev/null @@ -1,526 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Common; -using HarmonyLib; -using Newtonsoft.Json; -using UnityEngine; -using Object = UnityEngine.Object; -using Random = System.Random; - -namespace EpicLoot.Adventure.Feature -{ - public class BountiesAdventureFeature : AdventureFeature - { - public BountyLedger BountyLedger => BountyManagmentSystem.Instance.BountyLedger; - - private const string LedgerIdentifier = "randyknapp.mods.epicloot.BountyLedger"; - - public override AdventureFeatureType Type => AdventureFeatureType.Bounties; - public override int RefreshInterval => AdventureDataManager.Config.Bounties.RefreshInterval; - - public List GetAvailableBounties() - { - return GetAvailableBounties(GetCurrentInterval()); - } - - public bool BossBountiesGated() - { - switch (EpicLoot.BossBountyMode.Value) - { - case GatedBountyMode.BossKillUnlocksCurrentBiomeBounties: - case GatedBountyMode.BossKillUnlocksNextBiomeBounties: - return true; - default: - return false; - } - } - - public List GetAvailableBounties(int interval, bool removeAcceptedBounties = true) - { - var player = Player.m_localPlayer; - var random = GetRandomForInterval(interval, RefreshInterval); - - var bountiesPerBiome = new MultiValueDictionary(); - - var defeatedBossBiomes = new List(); - var previousBossKilled = false; - var previousBoss = ""; - - if (BossBountiesGated()) - { - foreach (var bossConfig in AdventureDataManager.Config.Bounties.Bosses) - { - if (previousBoss == "" && EpicLoot.BossBountyMode.Value == GatedBountyMode.BossKillUnlocksNextBiomeBounties) - { - defeatedBossBiomes.Add(bossConfig.Biome); - previousBoss = bossConfig.BossDefeatedKey; - } - - if (ZoneSystem.instance.GetGlobalKey(bossConfig.BossDefeatedKey)) - { - defeatedBossBiomes.Add(bossConfig.Biome); - previousBossKilled = true; - previousBoss = bossConfig.BossDefeatedKey; - } - else if ((previousBossKilled || previousBoss.Equals(bossConfig.BossDefeatedKey)) && EpicLoot.BossBountyMode.Value == GatedBountyMode.BossKillUnlocksNextBiomeBounties) - { - defeatedBossBiomes.Add(bossConfig.Biome); - previousBoss = bossConfig.BossDefeatedKey; - previousBossKilled = false; - } - } - } - - foreach (var targetConfig in AdventureDataManager.Config.Bounties.Targets) - { - bountiesPerBiome.Add(targetConfig.Biome, targetConfig); - } - - var selectedTargets = new List(); - foreach (var entry in bountiesPerBiome) - { - var targets = entry.Value; - RollOnListNTimes(random, targets, 1, selectedTargets); - } - // Remove the results that the player doesn't know about yet - selectedTargets.RemoveAll(result => !player.m_knownBiome.Contains(result.Biome)); - - if (BossBountiesGated()) - { - //Remove the results of undefeated biome bosses - selectedTargets.RemoveAll(result => !defeatedBossBiomes.Contains(result.Biome)); - } - - var saveData = player.GetAdventureSaveData(); - - var results = selectedTargets.Select(targetConfig => new BountyInfo() - { - Biome = targetConfig.Biome, - Interval = interval, - PlayerID = player.GetPlayerID(), - Target = new BountyTargetInfo() { MonsterID = targetConfig.TargetID, Level = GetTargetLevel(random, targetConfig.RewardGold > 0, false), Count = 1 }, - TargetName = GenerateTargetName(random), - RewardIron = targetConfig.RewardIron, - RewardGold = targetConfig.RewardGold, - RewardCoins = targetConfig.RewardCoins, - Adds = targetConfig.Adds.Select(x => new BountyTargetInfo() { MonsterID = x.ID, Count = x.Count, Level = GetTargetLevel(random, false, true) }).ToList() - }) - .ToList(); - - if (removeAcceptedBounties) - { - results.RemoveAll(x => saveData.HasAcceptedBounty(x.Interval, x.ID)); - } - - return results; - } - - public static string PrintBounties(string label, List results) - { - var sb = new StringBuilder(); - sb.AppendLine(label); - for (var index = 0; index < results.Count; index++) - { - var bountyInfo = results[index]; - sb.AppendLine($"{index} - {bountyInfo.Interval}, {bountyInfo.Biome}, {bountyInfo.TargetName}, ID={bountyInfo.ID}, state={bountyInfo.State}"); - } - - EpicLoot.Log(sb.ToString()); - return sb.ToString(); - } - - public static string GenerateTargetName(Random random) - { - var specialNames = AdventureDataManager.Config.Bounties.Names.SpecialNames; - var prefixes = AdventureDataManager.Config.Bounties.Names.Prefixes; - var suffixes = AdventureDataManager.Config.Bounties.Names.Suffixes; - if (specialNames.Count == 0 && (prefixes.Count == 0 || suffixes.Count == 0)) - { - return string.Empty; - } - - var useSpecialName = random.NextDouble() <= AdventureDataManager.Config.Bounties.Names.ChanceForSpecialName; - if (useSpecialName) - { - return RollOnList(random, specialNames); - } - - var prefix = Localization.instance.Localize(RollOnList(random, prefixes)); - var suffix = Localization.instance.Localize(RollOnList(random, suffixes)); - var format = suffix.StartsWith(" ") || suffix.StartsWith(",") ? "$mod_epicloot_bounties_targetnameformat_nospace" : "$mod_epicloot_bounties_targetnameformat"; - return Localization.instance.Localize(format, prefix, suffix); - } - - private static int GetTargetLevel(Random random, bool isGold, bool isAdd) - { - var config = AdventureDataManager.Config.Bounties; - - var min = isAdd ? config.AddsMinLevel : (isGold ? config.GoldMinLevel : config.IronMinLevel); - var max = isAdd ? config.AddsMaxLevel : (isGold ? config.GoldMaxLevel : config.IronMaxLevel); - - return random.Next(min, max + 1); - } - - public List GetClaimableBounties() - { - var results = new List(); - - var saveData = Player.m_localPlayer?.GetAdventureSaveData(); - if (saveData == null) - { - return results; - } - - return saveData.GetClaimableBounties().Concat(saveData.GetInProgressBounties()).ToList(); - } - - public IEnumerator AcceptBounty(Player player, BountyInfo bounty, Action callback) - { - player.Message(MessageHud.MessageType.Center, "$mod_epicloot_bounties_locatingmsg"); - var saveData = player.GetAdventureSaveData(); - yield return GetRandomPointInBiome(bounty.Biome, saveData, (success, spawnPoint, _) => - { - if (success) - { - var offset2 = UnityEngine.Random.insideUnitCircle * AdventureDataManager.Config.TreasureMap.MinimapAreaRadius; - var offset = new Vector3(offset2.x, 0, offset2.y); - saveData.AcceptedBounty(bounty, spawnPoint, offset); - saveData.NumberOfTreasureMapsOrBountiesStarted++; - player.SaveAdventureSaveData(); - - // Spawn Monster - SpawnBountyTargets(bounty, spawnPoint, offset); - } - else - { - callback?.Invoke(false, Vector3.zero); - } - }); - } - - private static void SpawnBountyTargets(BountyInfo bounty, Vector3 spawnPoint, Vector3 offset) - { - var mainPrefab = ZNetScene.instance.GetPrefab(bounty.Target.MonsterID); - if (mainPrefab == null) - { - EpicLoot.LogError($"Could not find prefab for bounty target! BountyID: {bounty.ID}, MonsterID: {bounty.Target.MonsterID}"); - return; - } - - var prefabs = new List() { mainPrefab }; - foreach (var addConfig in bounty.Adds) - { - for (var i = 0; i < addConfig.Count; i++) - { - var prefab = ZNetScene.instance.GetPrefab(addConfig.MonsterID); - if (prefab == null) - { - EpicLoot.LogError($"Could not find prefab for bounty add! BountyID: {bounty.ID}, MonsterID: {addConfig.MonsterID}"); - return; - } - prefabs.Add(prefab); - } - } - for (var index = 0; index < prefabs.Count; index++) - { - var prefab = prefabs[index]; - var isAdd = index > 0; - - var creature = Object.Instantiate(prefab, spawnPoint, Quaternion.identity); - var bountyTarget = creature.AddComponent(); - bountyTarget.Initialize(bounty, prefab.name, isAdd); - - var randomSpacing = UnityEngine.Random.insideUnitSphere * 4; - spawnPoint += randomSpacing; - ZoneSystem.instance.FindFloor(spawnPoint, out var floorHeight); - spawnPoint.y = floorHeight; - } - - Minimap.instance.ShowPointOnMap(spawnPoint + offset); - - var pkg = new ZPackage(); - bounty.ToPackage(pkg); - ZRoutedRpc.instance.InvokeRoutedRPC("SpawnBounties", pkg); - } - - private static void OnBountyTargetSlain(string bountyID, string monsterID, bool isAdd) - { - var player = Player.m_localPlayer; - if (player == null) - { - return; - } - - var saveData = player.GetAdventureSaveData(); - var bountyInfo = saveData.GetBountyInfoByID(bountyID); - - if (bountyInfo == null || bountyInfo.PlayerID != player.GetPlayerID()) - { - // Someone else's bounty - return; - } - - if (!saveData.HasAcceptedBounty(bountyInfo.Interval, bountyInfo.ID) || bountyInfo.State != BountyState.InProgress) - { - return; - } - - EpicLoot.Log($"Bounty Target Slain: bounty={bountyInfo.ID} monsterId={monsterID} ({(isAdd ? "add" : "main target")})"); - - if (!isAdd && bountyInfo.Target.MonsterID == monsterID) - { - bountyInfo.Slain = true; - player.SaveAdventureSaveData(); - } - - if (isAdd) - { - foreach (var addConfig in bountyInfo.Adds) - { - if (addConfig.MonsterID == monsterID && addConfig.Count > 0) - { - addConfig.Count--; - player.SaveAdventureSaveData(); - break; - } - } - } - - var isComplete = bountyInfo.Slain && bountyInfo.Adds.Sum(x => x.Count) == 0; - if (isComplete) - { - MessageHud.instance.ShowBiomeFoundMsg("$mod_epicloot_bounties_completemsg", true); - bountyInfo.State = BountyState.Complete; - - if (!MinimapController.BountyPins.ContainsKey(bountyInfo.ID)) return; - - var pinJob = new PinJob - { - Task = MinimapPinQueueTask.RemoveBountyPin, - DebugMode = MinimapController.DebugMode, - BountyPin = new KeyValuePair(bountyInfo.ID, MinimapController.BountyPins[bountyInfo.ID]) - }; - - MinimapController.AddPinJobToQueue(pinJob); - - player.SaveAdventureSaveData(); - } - } - - public void ClaimBountyReward(BountyInfo bountyInfo) - { - var player = Player.m_localPlayer; - if (player == null) - { - return; - } - - var saveData = player.GetAdventureSaveData(); - if (!saveData.HasAcceptedBounty(bountyInfo.Interval, bountyInfo.ID) || bountyInfo.State != BountyState.Complete) - { - return; - } - - bountyInfo.State = BountyState.Claimed; - player.SaveAdventureSaveData(); - - MessageHud.instance.ShowBiomeFoundMsg("$mod_epicloot_bounties_claimedmsg", true); - - var inventory = player.GetInventory(); - if (bountyInfo.RewardIron > 0) - { - inventory.AddItem("IronBountyToken", bountyInfo.RewardIron, 1, 0, 0, string.Empty); - } - if (bountyInfo.RewardGold > 0) - { - inventory.AddItem("GoldBountyToken", bountyInfo.RewardGold, 1, 0, 0, string.Empty); - } - if (bountyInfo.RewardCoins > 0) - { - inventory.AddItem("Coins", bountyInfo.RewardCoins, 1, 0, 0, string.Empty); - } - } - - public void AbandonBounty(BountyInfo bountyInfo) - { - var saveData = Player.m_localPlayer?.GetAdventureSaveData(); - if (saveData != null && bountyInfo != null && saveData.BountyIsInProgress(bountyInfo.Interval, bountyInfo.ID)) - { - saveData.AbandonedBounty(bountyInfo.ID); - Player.m_localPlayer.SaveAdventureSaveData(); - } - } - - public void RegisterRPC(ZRoutedRpc routedRpc) - { - routedRpc.Register("SendKillLogs", RPC_Client_ReceiveKillLogs); - - if (Common.Utils.IsServer()) - { - routedRpc.Register("SlayBountyTarget", RPC_SlayBountyTarget); - routedRpc.Register("SlayBountyIDTarget", RPC_SlayBountyTargetFromBountyId); - routedRpc.Register("RequestKillLogs", RPC_Server_RequestKillLogs); - routedRpc.Register("ClearKillLogs", RPC_Server_ClearKillLogs); - } - else - { - routedRpc.Register("SlayBountyTargetFromServer", RPC_Client_SlayBountyTargetFromServer); - } - } - - private void RPC_Client_SlayBountyTargetFromServer(long sender, ZPackage pkg, string monsterID, bool isAdd) - { - if (Common.Utils.IsServer()) - { - return; - } - - RPC_SlayBountyTarget(sender, pkg, monsterID, isAdd); - } - - public void RPC_SlayBountyTarget(long sender, ZPackage pkg, string monsterID, bool isAdd) - { - var isServer = Common.Utils.IsServer(); - if (isServer) - { - ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "SlayBountyTargetFromServer", pkg, monsterID, isAdd); - } - - var bounty = BountyInfo.FromPackage(pkg); - - if (isServer) - { - AddSlainBountyTargetToLedger(bounty, monsterID, isAdd); - } - - if (Player.m_localPlayer == null || bounty.PlayerID != Player.m_localPlayer.GetPlayerID()) - { - // Not my bounty - return; - } - - OnBountyTargetSlain(bounty.ID, monsterID, isAdd); - } - - public void RPC_SlayBountyTargetFromBountyId(long sender, string monsterID, bool isAdd, string bountyID) - { - EpicLoot.LogWarning($"CLIENT: RPC_SlayBountyTargetFromBountyId: {monsterID} ({(isAdd ? "minion" : "target")})"); - - var bounty = BountyInfo.FromBountyID(bountyID); - - if (Player.m_localPlayer == null || bounty.PlayerID != Player.m_localPlayer.GetPlayerID()) - { - // Not my bounty - return; - } - - OnBountyTargetSlain(bounty.ID, monsterID, isAdd); - } - - private void AddSlainBountyTargetToLedger(BountyInfo bounty, string monsterID, bool isAdd) - { - if (!Common.Utils.IsServer()) - { - return; - } - - if (BountyLedger == null) - { - EpicLoot.LogError("[BountyLedger] Server tried to add kill log to bounty ledger but BountyLedger was null"); - return; - } - - if (Player.m_localPlayer != null && Player.m_localPlayer.GetPlayerID() == bounty.PlayerID) - { - EpicLoot.Log($"[BountyLedger] This player ({bounty.PlayerID}) is the local player"); - return; - } - - var characterZdos = ZNet.instance.GetAllCharacterZDOS(); - var playerIsOnline = characterZdos.Select(zdo => zdo.GetLong("playerID")).Any(playerID => playerID == bounty.PlayerID); - if (playerIsOnline) - { - EpicLoot.Log($"[BountyLedger] This player ({bounty.PlayerID}) is connected to server, don't log the kill, they'll get the RPC"); - return; - } - - BountyLedger.AddKillLog(bounty.PlayerID, bounty.ID, monsterID, isAdd); - } - - public override void OnZNetStart() - { - } - - public override void OnZNetDestroyed() - { - } - - public override void OnWorldSave() - { - } - - private void RPC_Server_RequestKillLogs(long sender, long playerID) - { - if (!Common.Utils.IsServer()) - { - return; - } - - var results = ""; - if (BountyLedger != null) - { - var logs = BountyLedger.GetAllKillLogs(playerID); - results = JsonConvert.SerializeObject(logs, Formatting.Indented); - } - - ZRoutedRpc.instance.InvokeRoutedRPC(sender, "SendKillLogs", results); - } - - private void RPC_Client_ReceiveKillLogs(long sender, string logData) - { - var logs = JsonConvert.DeserializeObject(logData); - if (logs == null) - return; - - foreach (var killLog in logs) - { - OnBountyTargetSlain(killLog.BountyID, killLog.MonsterID, killLog.IsAdd); - } - - var playerID = Player.m_localPlayer.GetPlayerID(); - ZRoutedRpc.instance.InvokeRoutedRPC("ClearKillLogs", playerID); - } - - private void RPC_Server_ClearKillLogs(long sender, long playerID) - { - if (!Common.Utils.IsServer()) - { - return; - } - - BountyLedger?.RemoveKillLogsForPlayer(playerID); - } - } - - [HarmonyPatch(typeof(Game), nameof(Game.SpawnPlayer))] - public static class Game_SpawnPlayer_Patch - { - public static void Postfix() - { - if (ZRoutedRpc.instance != null && Player.m_localPlayer != null) - { - Player.m_localPlayer.StartCoroutine(WaitThenRequestKillLogs(Player.m_localPlayer)); - } - } - - public static IEnumerator WaitThenRequestKillLogs(Player player) - { - yield return new WaitForSeconds(5); - var playerID = player.GetPlayerID(); - ZRoutedRpc.instance.InvokeRoutedRPC("RequestKillLogs", playerID); - } - } -} diff --git a/EpicLoot/Adventure/Feature/BountyLedger.cs b/EpicLoot/Adventure/Feature/BountyLedger.cs deleted file mode 100644 index 2597826e..00000000 --- a/EpicLoot/Adventure/Feature/BountyLedger.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -namespace EpicLoot.Adventure.Feature -{ - [Serializable] - public class BountyKillLog - { - public string BountyID = ""; - public string MonsterID = ""; - public bool IsAdd = false; - } - - [Serializable] - public class BountyLedger - { - public long WorldID; - public bool ConvertedGlobalKeys; - public Dictionary> KillLogsPerPlayer = new Dictionary>(); - - public List GetAllKillLogs(long playerID) - { - if (!KillLogsPerPlayer.TryGetValue(playerID, out var logs)) - { - logs = new List(); - KillLogsPerPlayer.Add(playerID, logs); - } - - return logs; - } - - public List GetKillLogForBounty(long playerID, string bountyID) - { - KillLogsPerPlayer.TryGetValue(playerID, out var killLog); - return killLog?.Where(x => x.BountyID == bountyID).ToList() ?? new List(); - } - - public void RemoveKillLogForBounty(long playerID, string bountyID) - { - KillLogsPerPlayer.TryGetValue(playerID, out var killLog); - killLog?.RemoveAll(x => x.BountyID == bountyID); - } - - public void RemoveKillLogsForPlayer(long playerID) - { - KillLogsPerPlayer.Remove(playerID); - } - - public void AddKillLog(long playerID, string bountyID, string monsterID, bool isAdd) - { - if (!KillLogsPerPlayer.TryGetValue(playerID, out var list)) - { - list = new List(); - KillLogsPerPlayer.Add(playerID, list); - } - list.Add(new BountyKillLog { BountyID = bountyID, MonsterID = monsterID, IsAdd = isAdd }); - } - } -} diff --git a/EpicLoot/Adventure/Feature/TreasureMapListPanel.cs b/EpicLoot/Adventure/Feature/TreasureMapListPanel.cs deleted file mode 100644 index 9858fcfa..00000000 --- a/EpicLoot/Adventure/Feature/TreasureMapListPanel.cs +++ /dev/null @@ -1,95 +0,0 @@ -using UnityEngine; -using UnityEngine.UI; -using Object = UnityEngine.Object; - -namespace EpicLoot.Adventure.Feature -{ - class TreasureMapListPanel : MerchantListPanel - { - private readonly MerchantPanel _merchantPanel; - - public TreasureMapListPanel(MerchantPanel merchantPanel, TreasureMapListElement elementPrefab) - : base( - merchantPanel.transform.Find("TreasureMap/Panel/ItemList") as RectTransform, - elementPrefab, - merchantPanel.transform.Find("TreasureMap/TreasureMapBuyButton").GetComponent