From 88935001da6aef4860a43a47fb9c89f3e2fada6d Mon Sep 17 00:00:00 2001 From: mfoltz Date: Sat, 31 Aug 2024 02:21:06 -0500 Subject: [PATCH] - changed click detection to work off the same blood object that shows blood information when hovered over (this should fix any issues with errant clicks as if the blood object is not present it cannot be interacted with) - quests should reliably be on the bottom right of the screen now --- CHANGELOG.md | 4 ++ Eclipse.csproj | 2 +- Patches/GamePlayInputSystemPatch.cs | 13 ++---- Services/CanvasService.cs | 70 ++++++++++++++++++++++------- Services/DataService.cs | 14 +++++- thunderstore.toml | 2 +- 6 files changed, 75 insertions(+), 30 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fb267b8..62dfeb5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +`0.1.3` +- changed click detection to work off the same blood object that shows blood information when hovered over (this should fix any issues with errant clicks as if the blood object is not present it cannot be interacted with) +- quests should reliably be on the bottom right of the screen now + `0.1.2` - clicking blood orb area if UI not active in-game will not do anything diff --git a/Eclipse.csproj b/Eclipse.csproj index a294997..308b794 100644 --- a/Eclipse.csproj +++ b/Eclipse.csproj @@ -4,7 +4,7 @@ net6.0 enable Eclipse - 0.1.2 + 0.1.3 True https://api.nuget.org/v3/index.json; diff --git a/Patches/GamePlayInputSystemPatch.cs b/Patches/GamePlayInputSystemPatch.cs index 0d5296c..a5888e2 100644 --- a/Patches/GamePlayInputSystemPatch.cs +++ b/Patches/GamePlayInputSystemPatch.cs @@ -5,6 +5,7 @@ namespace Eclipse.Patches; +/* [HarmonyPatch] internal static class GameplayInputSystemPatch { @@ -27,21 +28,15 @@ static void HandleInputPrefix(InputState inputState) if (IsMouseInside(Input.mousePosition)) { //Core.Log.LogInfo($"Mouse 0 Down Inside {worldMousePosition.x},{worldMousePosition.y},{worldMousePosition.z}"); - ToggleUIObjects(); + //ToggleUIObjects(); } } } - static void ToggleUIObjects() - { - CanvasService.UIActive = !CanvasService.UIActive; - foreach (GameObject gameObject in CanvasService.ActiveObjects) - { - gameObject.active = CanvasService.UIActive; - } - } + static bool IsMouseInside(Vector3 position) { return position.x >= bottomLeft.x && position.x <= topRight.x && position.y >= bottomLeft.y && position.y <= topRight.y; } } +*/ diff --git a/Services/CanvasService.cs b/Services/CanvasService.cs index 64aab57..88e30d8 100644 --- a/Services/CanvasService.cs +++ b/Services/CanvasService.cs @@ -43,6 +43,7 @@ internal class CanvasService static float ExperienceProgress = 0f; static int ExperienceLevel = 0; static int ExperiencePrestige = 0; + static int ExperienceMaxLevel = 90; static PlayerClass ClassType = PlayerClass.None; static GameObject LegacyBarGameObject; @@ -58,6 +59,7 @@ internal class CanvasService static float LegacyProgress = 0f; static int LegacyLevel = 0; static int LegacyPrestige = 0; + static int LegacyMaxLevel = 100; static List LegacyBonusStats = ["","",""]; static GameObject ExpertiseBarGameObject; @@ -73,6 +75,7 @@ internal class CanvasService static float ExpertiseProgress = 0f; static int ExpertiseLevel = 0; static int ExpertisePrestige = 0; + static int ExpertiseMaxLevel = 100; static List ExpertiseBonusStats = ["","",""]; static GameObject DailyQuestObject; @@ -146,6 +149,9 @@ public static void ParseConfigData(List configData) ConfigData parsedConfigData = new( configData[index++], // prestigeMultiplier configData[index++], // statSynergyMultiplier + configData[index++], // maxPlayerLevel + configData[index++], // maxLegacyLevel + configData[index++], // maxExpertiseLevel string.Join(",", configData.Skip(index).Take(12)), // Combine the next 11 elements for weaponStatValues string.Join(",", configData.Skip(index += 12).Take(12)), // Combine the following 11 elements for bloodStatValues string.Join(",", configData.Skip(index += 12)) // Combine all remaining elements for classStatSynergies @@ -154,6 +160,10 @@ public static void ParseConfigData(List configData) PrestigeStatMultiplier = parsedConfigData.PrestigeStatMultiplier; ClassStatMultiplier = parsedConfigData.ClassStatMultiplier; + ExperienceMaxLevel = parsedConfigData.MaxPlayerLevel; + LegacyMaxLevel = parsedConfigData.MaxLegacyLevel; + ExpertiseMaxLevel = parsedConfigData.MaxExpertiseLevel; + WeaponStatValues = parsedConfigData.WeaponStatValues; BloodStatValues = parsedConfigData.BloodStatValues; @@ -217,7 +227,7 @@ public static IEnumerator CanvasUpdateLoop() // need to find another component, { ExperienceFill.fillAmount = ExperienceProgress; - if (ExperienceLevel == 90) ExperienceFill.fillAmount = 1f; + if (ExperienceLevel == ExperienceMaxLevel) ExperienceFill.fillAmount = 1f; if (ExperienceText.GetText() != ExperienceLevel.ToString()) { @@ -245,7 +255,7 @@ public static IEnumerator CanvasUpdateLoop() // need to find another component, { LegacyFill.fillAmount = LegacyProgress; - if (LegacyLevel == 100) LegacyFill.fillAmount = 1f; + if (LegacyLevel == LegacyMaxLevel) LegacyFill.fillAmount = 1f; if (LegacyHeader.GetText() != LegacyType) { @@ -259,7 +269,14 @@ public static IEnumerator CanvasUpdateLoop() // need to find another component, if (LegacyText.GetText() != LegacyLevel.ToString()) { - LegacyText.ForceSet(LegacyLevel.ToString()); + if (LegacyType == "Frailed") + { + LegacyText.ForceSet("N/A"); + } + else + { + LegacyText.ForceSet(LegacyLevel.ToString()); + } } if (LegacyBonusStats[0] != "None" && FirstLegacyStat.GetText() != LegacyBonusStats[0]) @@ -303,7 +320,7 @@ public static IEnumerator CanvasUpdateLoop() // need to find another component, { ExpertiseFill.fillAmount = ExpertiseProgress; - if (ExpertiseLevel == 100) ExpertiseFill.fillAmount = 1f; + if (ExpertiseLevel == ExpertiseMaxLevel) ExpertiseFill.fillAmount = 1f; if (ExpertiseHeader.GetText() != ExpertiseType) { @@ -434,13 +451,24 @@ static void InitializeBars(UICanvasBase canvas) GameObject bloodOrbParent = FindTargetUIObject(canvas.transform.root, "BloodOrbParent"); if (bloodOrbParent != null) { - RectTransform bloodOrbParentRectTransform = bloodOrbParent.GetComponent(); - Il2CppStructArray worldCorners = new(4); - bloodOrbParentRectTransform.GetWorldCorners(worldCorners); - GameplayInputSystemPatch.bottomLeft = worldCorners[0]; - GameplayInputSystemPatch.topRight = worldCorners[2]; + //RectTransform bloodOrbParentRectTransform = bloodOrbParent.GetComponent(); + //Il2CppStructArray worldCorners = new(4); + //bloodOrbParentRectTransform.GetWorldCorners(worldCorners); + //GameplayInputSystemPatch.bottomLeft = worldCorners[0]; + //GameplayInputSystemPatch.topRight = worldCorners[2]; + + GameObject bloodObject = FindTargetUIObject(bloodOrbParent.transform, "Blood"); + if (bloodObject != null) + { + SimpleStunButton stunButton = bloodObject.AddComponent(); + stunButton.onClick.AddListener(new Action(ToggleUIObjects)); + } + else + { + Core.Log.LogError("Failed to find Blood object"); + } } - + // Get MiniMap south icon on the compass to set locations GameObject MiniMapSouthObject = FindTargetUIObject(canvas.transform.root, "S"); RectTransform MiniMapSouthRectTransform = MiniMapSouthObject.GetComponent(); @@ -646,17 +674,17 @@ static void InitializeBars(UICanvasBase canvas) WeeklyQuestTransform.gameObject.layer = CanvasObject.layer; // Reduce window widths - DailyQuestTransform.sizeDelta = new Vector2(DailyQuestTransform.sizeDelta.x * 0.7f, DailyQuestTransform.sizeDelta.y); - WeeklyQuestTransform.sizeDelta = new Vector2(WeeklyQuestTransform.sizeDelta.x * 0.7f, WeeklyQuestTransform.sizeDelta.y); + DailyQuestTransform.sizeDelta = new Vector2(DailyQuestTransform.sizeDelta.x * 0.6f, DailyQuestTransform.sizeDelta.y); + WeeklyQuestTransform.sizeDelta = new Vector2(WeeklyQuestTransform.sizeDelta.x * 0.6f, WeeklyQuestTransform.sizeDelta.y); //Core.Log.LogInfo($"DailyQuestTransform: {DailyQuestTransform.position.x},{DailyQuestTransform.position.y},{DailyQuestTransform.position.z}"); // Set positions for quest tooltips //int windowNumber = 1; //DailyQuestTransform.anchoredPosition = new(DailyQuestTransform.anchoredPosition.x, DailyQuestTransform.anchoredPosition.y * 2); - DailyQuestTransform.position = new Vector3(1600f, 275f, 0f); - WeeklyQuestTransform.position = new Vector3(1600f, 200f, 0f); - //Core.Log.LogInfo($"DailyQuestTransform: {DailyQuestTransform.position.x},{DailyQuestTransform.position.y},{DailyQuestTransform.position.z}"); + DailyQuestTransform.position = new Vector3(Screen.width, 75f, 0f); + WeeklyQuestTransform.position = new Vector3(Screen.width, 0f, 0f); // oops, resolution >_> + Core.Log.LogInfo($"DailyQuestTransform: {DailyQuestTransform.rect.height},{DailyQuestTransform.rect.top},{DailyQuestTransform.rect.y}"); // Add objects to list for toggling later ActiveObjects.Add(DailyQuestTooltipObject); ActiveObjects.Add(WeeklyQuestTooltipObject); @@ -668,7 +696,7 @@ static void ConfigureBar(RectTransform barRectTransform, GameObject referenceObj float rectWidth = barRectTransform.rect.width; float sizeOffsetX = ((rectWidth * sizeMultiplier) - rectWidth) * (1 - barRectTransform.pivot.x); barRectTransform.localScale *= 0.75f; - barRectTransform.position = new Vector3(referenceObject.transform.position.x - sizeOffsetX * 2, (referenceObject.transform.position.y * 0.9f) - (referenceRectTransform.rect.height * 2.25f * barNumber), referenceObject.transform.position.z); + barRectTransform.position = new Vector3(referenceObject.transform.position.x - sizeOffsetX * 2, (referenceObject.transform.position.y * 0.9f) - (referenceRectTransform.rect.height * 2.5f * barNumber), referenceObject.transform.position.z); barRectTransform.gameObject.layer = layer; fillImage.fillAmount = 0f; @@ -682,7 +710,15 @@ static void ConfigureBar(RectTransform barRectTransform, GameObject referenceObj FindTargetUIObject(barRectTransform.transform, "AbsorbFill").GetComponent().fillAmount = 0f; barNumber++; - } + } + static void ToggleUIObjects() + { + UIActive = !UIActive; + foreach (GameObject gameObject in ActiveObjects) + { + gameObject.active = UIActive; + } + } public static class UIObjectUtils { static readonly Dictionary BloodIcons = new() diff --git a/Services/DataService.cs b/Services/DataService.cs index c795364..b2e1508 100644 --- a/Services/DataService.cs +++ b/Services/DataService.cs @@ -10,7 +10,7 @@ public enum BloodType Rogue, Mutant, VBlood, - None, + Frailed, GateBoss, Draculin, Immortal, @@ -161,19 +161,29 @@ internal class ConfigData public float ClassStatMultiplier; + public int MaxPlayerLevel; + + public int MaxLegacyLevel; + + public int MaxExpertiseLevel; + public Dictionary WeaponStatValues; public Dictionary BloodStatValues; public Dictionary WeaponStats, List bloodStats)> ClassStatSynergies; - public ConfigData(string prestigeMultiplier, string statSynergyMultiplier, string weaponStatValues, string bloodStatValues, string classStatSynergies) + public ConfigData(string prestigeMultiplier, string statSynergyMultiplier, string maxPlayerLevel, string maxLegacyLevel, string maxExpertiseLevel, string weaponStatValues, string bloodStatValues, string classStatSynergies) { //Core.Log.LogInfo($"ConfigData: {prestigeMultiplier}, {statSynergyMultiplier}, {weaponStatValues}, {bloodStatValues}, {classStatSynergies}"); PrestigeStatMultiplier = float.Parse(prestigeMultiplier); ClassStatMultiplier = float.Parse(statSynergyMultiplier); + MaxPlayerLevel = int.Parse(maxPlayerLevel); + MaxLegacyLevel = int.Parse(maxLegacyLevel); + MaxExpertiseLevel = int.Parse(maxExpertiseLevel); + WeaponStatValues = weaponStatValues.Split(',') .Select((value, index) => new { Index = index + 1, Value = float.Parse(value) }) .ToDictionary(x => (WeaponStatType)x.Index, x => x.Value); diff --git a/thunderstore.toml b/thunderstore.toml index 9c95655..0009145 100644 --- a/thunderstore.toml +++ b/thunderstore.toml @@ -12,7 +12,7 @@ v-rising = ["1-0-update", "mods", "server"] [package] namespace = "zfolmt" name = "Eclipse" -versionNumber = "0.1.1" +versionNumber = "0.1.3" description = "Client companion mod for Bloodcraft!" websiteUrl = "https://github.com/mfoltz/Eclipse" containsNsfwContent = false