Skip to content

Commit

Permalink
- changed click detection to work off the same blood object that show…
Browse files Browse the repository at this point in the history
…s 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
  • Loading branch information
mfoltz committed Aug 31, 2024
1 parent c80ac3e commit 8893500
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 30 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion Eclipse.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<AssemblyName>Eclipse</AssemblyName>
<Version>0.1.2</Version>
<Version>0.1.3</Version>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<RestoreSources>
https://api.nuget.org/v3/index.json;
Expand Down
13 changes: 4 additions & 9 deletions Patches/GamePlayInputSystemPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

namespace Eclipse.Patches;

/*
[HarmonyPatch]
internal static class GameplayInputSystemPatch
{
Expand All @@ -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;
}
}
*/
70 changes: 53 additions & 17 deletions Services/CanvasService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<string> LegacyBonusStats = ["","",""];

static GameObject ExpertiseBarGameObject;
Expand All @@ -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<string> ExpertiseBonusStats = ["","",""];

static GameObject DailyQuestObject;
Expand Down Expand Up @@ -146,6 +149,9 @@ public static void ParseConfigData(List<string> 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
Expand All @@ -154,6 +160,10 @@ public static void ParseConfigData(List<string> configData)
PrestigeStatMultiplier = parsedConfigData.PrestigeStatMultiplier;
ClassStatMultiplier = parsedConfigData.ClassStatMultiplier;

ExperienceMaxLevel = parsedConfigData.MaxPlayerLevel;
LegacyMaxLevel = parsedConfigData.MaxLegacyLevel;
ExpertiseMaxLevel = parsedConfigData.MaxExpertiseLevel;

WeaponStatValues = parsedConfigData.WeaponStatValues;

BloodStatValues = parsedConfigData.BloodStatValues;
Expand Down Expand Up @@ -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())
{
Expand Down Expand Up @@ -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)
{
Expand All @@ -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])
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -434,13 +451,24 @@ static void InitializeBars(UICanvasBase canvas)
GameObject bloodOrbParent = FindTargetUIObject(canvas.transform.root, "BloodOrbParent");
if (bloodOrbParent != null)
{
RectTransform bloodOrbParentRectTransform = bloodOrbParent.GetComponent<RectTransform>();
Il2CppStructArray<Vector3> worldCorners = new(4);
bloodOrbParentRectTransform.GetWorldCorners(worldCorners);
GameplayInputSystemPatch.bottomLeft = worldCorners[0];
GameplayInputSystemPatch.topRight = worldCorners[2];
//RectTransform bloodOrbParentRectTransform = bloodOrbParent.GetComponent<RectTransform>();
//Il2CppStructArray<Vector3> 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<SimpleStunButton>();
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<RectTransform>();
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -682,7 +710,15 @@ static void ConfigureBar(RectTransform barRectTransform, GameObject referenceObj
FindTargetUIObject(barRectTransform.transform, "AbsorbFill").GetComponent<Image>().fillAmount = 0f;

barNumber++;
}
}
static void ToggleUIObjects()
{
UIActive = !UIActive;
foreach (GameObject gameObject in ActiveObjects)
{
gameObject.active = UIActive;
}
}
public static class UIObjectUtils
{
static readonly Dictionary<BloodType, string> BloodIcons = new()
Expand Down
14 changes: 12 additions & 2 deletions Services/DataService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public enum BloodType
Rogue,
Mutant,
VBlood,
None,
Frailed,
GateBoss,
Draculin,
Immortal,
Expand Down Expand Up @@ -161,19 +161,29 @@ internal class ConfigData

public float ClassStatMultiplier;

public int MaxPlayerLevel;

public int MaxLegacyLevel;

public int MaxExpertiseLevel;

public Dictionary<WeaponStatType, float> WeaponStatValues;

public Dictionary<BloodStatType, float> BloodStatValues;

public Dictionary<PlayerClass, (List<WeaponStatType> WeaponStats, List<BloodStatType> 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);
Expand Down
2 changes: 1 addition & 1 deletion thunderstore.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 8893500

Please sign in to comment.