add quick change skill for dev only

This commit is contained in:
Chomper9981
2026-03-13 10:35:13 +07:00
parent ee9855ccb3
commit febcaa74b2
3 changed files with 334 additions and 421 deletions
+31 -78
View File
@@ -1819,9 +1819,9 @@ namespace BrewMonster
#if UNITY_EDITOR
/// <summary>
/// Cycles through learned skills by removing all shortcuts and adding 2 new skills to slots 0 and 1.
/// If m_startingSkillID is set (>0), uses that specific skill ID and the next one (ID+1).
/// Otherwise, cycles through all learned skills in pairs.
/// Cycles through learned skills by removing all shortcuts and adding 8 new skills to slots 0-7.
/// If m_startingSkillID is set (>0), uses that specific skill ID and the next 7 (ID+1 through ID+7).
/// Otherwise, cycles through all learned skills in groups of 8.
/// </summary>
public void CycleSkillShortcuts()
{
@@ -1843,71 +1843,31 @@ namespace BrewMonster
// First press: startingID + 0, startingID + 1 (e.g., 5, 6)
// Second press: startingID + 2, startingID + 3 (e.g., 7, 8)
// Third press: startingID + 4, startingID + 5 (e.g., 9, 10)
int currentSkillID1 = m_startingSkillID + (m_currentSkillCycleIndex * 2);
int currentSkillID2 = currentSkillID1 + 1;
BMLogger.LogError($"CycleSkillShortcuts: Trying to add skills {currentSkillID1} and {currentSkillID2}");
// Find and add first skill
CECSkill pSkill1 = GetPositiveSkillByID(currentSkillID1);
if (pSkill1 != null)
int firstIndex = m_startingSkillID + (m_currentSkillCycleIndex * 8);
List<int> skillIDs = new List<int>();
for (int i = 0; i < 8; i++)
{
pSCS.CreateSkillShortcut(0, pSkill1);
Debug.LogError($"CycleSkillShortcuts: Added skill ID {currentSkillID1} to slot 0");
skillIDs.Add(firstIndex + i);
}
else
string skillIDsString = string.Join(", ", skillIDs);
BMLogger.LogError($"CycleSkillShortcuts: Trying to add skills {skillIDsString}");
for (int i = 0; i < skillIDs.Count; i++)
{
Debug.LogError($"CycleSkillShortcuts: Skill with ID {currentSkillID1} not found in learned skills");
int find = 1;
while (pSkill1 == null && find < 100)
int skillID = skillIDs[i];
CECSkill pSkill = GetPositiveSkillByID(skillID);
if (pSkill != null)
{
m_startingSkillID++;
Debug.LogError($"CycleSkillShortcuts: m_startingSkillID {m_startingSkillID} ");
currentSkillID1 = m_startingSkillID + (m_currentSkillCycleIndex * 2);
pSkill1 = GetPositiveSkillByID(currentSkillID1);
find++;
}
if (pSkill1 != null)
{
pSCS.CreateSkillShortcut(0, pSkill1);
pSCS.CreateSkillShortcut(i, pSkill);
}
else
{
Debug.LogError($"CycleSkillShortcuts: Failed to find skill after {find} attempts");
}
}
// Find and add second skill
CECSkill pSkill2 = GetPositiveSkillByID(currentSkillID2);
if (pSkill2 != null)
{
pSCS.CreateSkillShortcut(1, pSkill2);
Debug.LogError($"CycleSkillShortcuts: Added skill ID {currentSkillID2} to slot 1");
}
else
{
Debug.LogError($"CycleSkillShortcuts: Skill with ID {currentSkillID2} not found in learned skills");
int find = 1;
while (pSkill2 == null && find < 100)
{
m_startingSkillID++;
Debug.LogError($"CycleSkillShortcuts: m_startingSkillID {m_startingSkillID} ");
currentSkillID2 = m_startingSkillID + (m_currentSkillCycleIndex * 2) + 1;
pSkill2 = GetPositiveSkillByID(currentSkillID2);
find++;
}
if (pSkill2 != null)
{
pSCS.CreateSkillShortcut(1, pSkill2);
}
else
{
Debug.LogError($"CycleSkillShortcuts: Failed to find skill after {find} attempts");
Debug.LogError($"CycleSkillShortcuts: Skill with ID {skillID} not found in learned skills");
break;
}
}
// Increment cycle index for next press
m_currentSkillCycleIndex++;
++m_currentSkillCycleIndex;
// Update UI
CDlgQuickBar cDlgQuickBar2 = CECUIManager.Instance?.GetCDlgQuickBar();
@@ -1928,36 +1888,29 @@ namespace BrewMonster
return;
}
// Calculate how many pairs we can make
int maxPairs = (skillCount + 1) / 2; // Round up division
// Calculate how many groups of 8 we can make
int maxGroups = (skillCount + 7) / 8; // Round up division
// Wrap around if we've reached the end
if (m_currentSkillCycleIndex >= maxPairs)
if (m_currentSkillCycleIndex >= maxGroups)
{
m_currentSkillCycleIndex = 0;
}
// Calculate skill indices for this cycle
int skillIndex1 = m_currentSkillCycleIndex * 2;
int skillIndex2 = skillIndex1 + 1;
// Calculate starting skill index for this cycle
int startSkillIndex = m_currentSkillCycleIndex * 8;
// Add first skill to slot 0
if (skillIndex1 < skillCount)
// Fill all 8 shortcut slots
for (int slotIndex = 0; slotIndex < 8; slotIndex++)
{
CECSkill pSkill1 = GetPositiveSkillByIndex(skillIndex1);
if (pSkill1 != null)
int skillIndex = startSkillIndex + slotIndex;
if (skillIndex < skillCount)
{
pSCS.CreateSkillShortcut(0, pSkill1);
}
}
// Add second skill to slot 1 (if available)
if (skillIndex2 < skillCount)
{
CECSkill pSkill2 = GetPositiveSkillByIndex(skillIndex2);
if (pSkill2 != null)
{
pSCS.CreateSkillShortcut(1, pSkill2);
CECSkill pSkill = GetPositiveSkillByIndex(skillIndex);
if (pSkill != null)
{
pSCS.CreateSkillShortcut(slotIndex, pSkill);
}
}
}
+6
View File
@@ -31,6 +31,7 @@ public class CECUIManager : MonoSingleton<CECUIManager>
[SerializeField] private UnityEngine.UI.Button btnSecondClick;
[SerializeField] CDlgQuickBar m_pDlgQuickBar1;
[SerializeField] GameObject ChangeSkillShortcutButton;
public CDlgSkillSubOther m_pDlgSkillSubOther;
CDlgMessageBox m_pDlgMessageBox;
public CDlgSkillAction m_pDlgSkillAction;
@@ -61,6 +62,11 @@ public class CECUIManager : MonoSingleton<CECUIManager>
}
ShowUI("Win_Hpmpxp");
#if UNITY_EDITOR
ChangeSkillShortcutButton.SetActive(true);
#else
ChangeSkillShortcutButton.SetActive(false);
#endif
}
private void Update()