remove old skill cycle logic

This commit is contained in:
Chomper9981
2026-03-12 17:08:54 +07:00
parent 7319df6660
commit b5f89bb703
9 changed files with 1061 additions and 119 deletions
File diff suppressed because it is too large Load Diff
@@ -1611,19 +1611,5 @@ public static class generate_item_temp
}
#endregion
private static void PrintData(byte[] buf, int offset, int size)
{
for(int i = offset; i < offset + size; i++)
{
BMLogger.Log("[thn]PrintData: buf[" + i + "]: " + buf[i]);
}
}
private static void PrintPreData(byte[] buf, int offset, int size)
{
for(int i = offset-1; i >= offset - size; i--)
{
BMLogger.Log("[thn]PrintPreData: buf[" + i + "]: " + buf[i]);
}
}
}
@@ -505,7 +505,6 @@ namespace BrewMonster
ret = -1;
break;
}
//Debug.Log("[THN]return_item_for_sell: ret:" + ret + " size:" + size + " datatype:" + datatype + " id:" + id);
if (ret == 0 && size != 0)
{
sale_item_ptr_array.Add(item);
@@ -1312,14 +1312,14 @@ namespace BrewMonster.Scripts
{
if (CECUIManager.Instance != null)
{
string message = $"Please deactive the fly mode to start the path finding.";
// string message = $"Please deactive the fly mode to start the path finding.";
CECUIManager.Instance.ShowMessageBox(
"Fly Mode", // 飞行模式
message, // 消息
BrewMonster.MessageBoxType.YesButton
);
Finish();
// CECUIManager.Instance.ShowMessageBox(
// "Fly Mode", // 飞行模式
// message, // 消息
// BrewMonster.MessageBoxType.YesButton
// );
// Finish();
//return;
}
break;
@@ -274,7 +274,6 @@ namespace BrewMonster.Scripts.Task.UI
A3DVECTOR3 vPos = instCoord[0].vPos;
strName = FormatFromTable(9393, ((int)vPos.x+4000)/10, ((int)vPos.z+5500)/10);
Debug.Log($"[DlgTaskTrace] AppendCommand: strName {strName}");
strName = string.Format("<link=\"coord\">{0}</link>", strName);
//FormatFromTable(9393, ((int)vPos.x+4000)/10, ((int)vPos.z+5500)/10);
@@ -174,7 +174,6 @@ namespace BrewMonster.Scripts.UI
string strDesc = pItem.GetDesc();
pImage.SetHint(strDesc); // TODO
pImage.SetOnClick(OnAwardItemClicked);
//Debug.Log("[THN]CDlgAward: pItem.GetDesc():" + pItem.GetDesc());
// af_GetFileTitle(pItem.GetIconFile(), strFile); // TODO
strFile.ToLower();
// TODO: Set the image cover here
@@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.UI;
@@ -44,6 +45,7 @@ namespace BrewMonster.Assets.PerfectWorld.Scripts.UI.GamePlay
public void SetDataPtr(CECShortcut pvData, string strName = null)
{
pSC = pvData;
}
public void SetInteract(bool isInteract)
{
@@ -141,6 +143,15 @@ namespace BrewMonster.Assets.PerfectWorld.Scripts.UI.GamePlay
{
return m_hintText;
}
public void Clear()
{
// BMLogger.Log("Clear AUIImagePicture with name: " + name) ;
pSC = null;
this.SetDataPtr(null);
borderImage.SetActive(false);
m_ClockCounter.SetProgressRange(0, 1);
m_ClockCounter.SetProgressPos(1);
}
}
public struct OpenSkillUIEvent
{
@@ -23,7 +23,7 @@ namespace BrewMonster
public int m_nCurPanel1 = 1;
public int m_nCurPanel2 = 1;
int m_CurrentShortcutOffset = 0;
int currentListIndex = 0;
/// <summary>
/// Apply for a license remove later
/// </summary>
@@ -40,7 +40,7 @@ namespace BrewMonster
[ContextMenu("SwitchShowSkillShortcut")]
public void SwitchShowSkillShortcut()
{
m_CurrentShortcutOffset += AUIImagePictureList.Count;
currentListIndex += 1;
UpdateShortcuts();
}
public bool UpdateShortcuts()
@@ -54,7 +54,6 @@ namespace BrewMonster
int nCurPanel9 = GetCurPanel1();
int nCurPanel8 = GetCurPanel2();
int countOffset = 0;
CECHostPlayer pHost = EC_Game.GetGameRun().GetHostPlayer();
if (pHost == null) return false;
var a_pSCS = new List<CECShortcutSet>();
@@ -62,43 +61,17 @@ namespace BrewMonster
GetQuickBarNameAndSC(pHost, a_pszPanel, a_pSCS, nCurPanel9, nCurPanel8);
if (a_pSCS == null || a_pSCS.Count < 2)
return false;
#if LICENSE_VERSION
int slotIndex = 0;
#endif
if(m_CurrentShortcutOffset >( a_pSCS.Count * 9)){
m_CurrentShortcutOffset = 0;
}
for (int i = 0; i < a_pSCS.Count; i++)
if(currentListIndex >= a_pSCS.Count )
{
if (a_pSCS[i] == null)
continue;
//*//*CDlgQuickBar* pQuickBar = dynamic_cast<CDlgQuickBar*>(GetGameUIMan()->GetDialog(a_pszPanel[i]));
//if (!pQuickBar || !pQuickBar->IsShow()) continue;*//*
#if LICENSE_VERSION
for (int j = 0; j < AUIImagePictureList.Count /*a_pSCS.Count*/; j++)
{
#else
int nSlots = Mathf.Min(a_pSCS[i].GetShortcutNum(), AUIImagePictureList.Count);
currentListIndex = 0;
}
int nSlots = Mathf.Min(a_pSCS[currentListIndex].GetShortcutNum(), AUIImagePictureList.Count);
for (int j = 0; j < nSlots; j++)
{
#endif
#if LICENSE_VERSION
if (slotIndex >= AUIImagePictureList.Count) break;
pCell = AUIImagePictureList[slotIndex];
#else
pCell = AUIImagePictureList[j];
#endif
if (pCell == null || !pCell.gameObject.activeInHierarchy) continue;
if(m_CurrentShortcutOffset > countOffset)
{
countOffset++;
continue;
}
pSC = a_pSCS[i].GetShortcut(j);
pSC = a_pSCS[currentListIndex].GetShortcut(j);
pClock = pCell.GetClockIcon();
pClock.SetProgressRange(0, 1);
pClock.SetProgressPos(1);
@@ -361,9 +334,6 @@ namespace BrewMonster
if (pSC != null)
{
#if LICENSE_VERSION
slotIndex++;
#endif
if (pCell.GetDataPtr() == pSC)
{
continue;
@@ -400,9 +370,10 @@ namespace BrewMonster
pCell->SetText(_AL(""));
pCell->SetDataPtr(NULL);
pCell->SetColor(A3DCOLORRGB(255, 255, 255)); */
pCell.Clear();
}
}
}
return true;
}
private void GetQuickBarNameAndSC(CECHostPlayer pHost, List<string> pszPanel, List<CECShortcutSet> pSCS, int panel9, int panel8)
+84 -51
View File
@@ -72,6 +72,7 @@ namespace BrewMonster
int offset = sizeof(uint);
int skillSize = Marshal.SizeOf<cmd_skill_data.SKILL>();
pCmd.skill_list = new cmd_skill_data.SKILL[pCmd.skill_count];
BMLogger.LogError("OnMsgHstSkillData: skill_count= " + pCmd.skill_count);
for (int i = 0; i < pCmd.skill_count; i++)
{
pCmd.skill_list[i] = GPDataTypeHelper.FromBytes<cmd_skill_data.SKILL>((byte[])Msg.dwParam1, offset);
@@ -1816,10 +1817,11 @@ namespace BrewMonster
}
}
#if UNITY_EDITOR
/// <summary>
/// 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 to ID+7).
/// Otherwise, cycles through all learned skills in groups of 8.
/// 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.
/// </summary>
public void CycleSkillShortcuts()
{
@@ -1833,51 +1835,74 @@ namespace BrewMonster
// Remove all shortcuts
pSCS.RemoveAllShortcuts();
const int skillsPerCycle = 8;
// If starting skill ID is configured, cycle through groups of 8 starting from that ID
// If starting skill ID is configured, cycle through pairs starting from that ID
if (m_startingSkillID > 0)
{
// Calculate the current skill IDs based on cycle index
// First press: startingID + 0 to startingID + 7 (e.g., 5-12)
// Second press: startingID + 8 to startingID + 15 (e.g., 13-20)
// Third press: startingID + 16 to startingID + 23 (e.g., 21-28)
int baseSkillID = m_startingSkillID + (m_currentSkillCycleIndex * skillsPerCycle);
BMLogger.LogError($"CycleSkillShortcuts: Trying to add skills {baseSkillID} to {baseSkillID + skillsPerCycle - 1}");
// Add 8 skills to slots 0-7
for (int slot = 0; slot < skillsPerCycle; slot++)
// 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 currentSkillID = baseSkillID + slot;
CECSkill pSkill = GetPositiveSkillByID(currentSkillID);
if (pSkill != null)
pSCS.CreateSkillShortcut(0, pSkill1);
Debug.LogError($"CycleSkillShortcuts: Added skill ID {currentSkillID1} to slot 0");
}
else
{
Debug.LogError($"CycleSkillShortcuts: Skill with ID {currentSkillID1} not found in learned skills");
int find = 1;
while (pSkill1 == null && find < 100)
{
pSCS.CreateSkillShortcut(slot, pSkill);
Debug.LogError($"CycleSkillShortcuts: Added skill ID {currentSkillID} to slot {slot}");
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);
}
else
{
Debug.LogError($"CycleSkillShortcuts: Skill with ID {currentSkillID} not found in learned skills");
// Try to find a valid skill by incrementing starting ID
int find = 1;
while (pSkill == null && find < 100)
{
m_startingSkillID++;
Debug.LogError($"CycleSkillShortcuts: m_startingSkillID {m_startingSkillID}");
currentSkillID = m_startingSkillID + (m_currentSkillCycleIndex * skillsPerCycle) + slot;
pSkill = GetPositiveSkillByID(currentSkillID);
find++;
}
Debug.LogError($"CycleSkillShortcuts: Failed to find skill after {find} attempts");
}
}
if (pSkill != null)
{
pSCS.CreateSkillShortcut(slot, pSkill);
}
else
{
Debug.LogError($"CycleSkillShortcuts: Failed to find skill for slot {slot} 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");
}
}
@@ -1903,29 +1928,36 @@ namespace BrewMonster
return;
}
// Calculate how many groups of 8 we can make
int maxGroups = (skillCount + skillsPerCycle - 1) / skillsPerCycle; // Round up division
// Calculate how many pairs we can make
int maxPairs = (skillCount + 1) / 2; // Round up division
// Wrap around if we've reached the end
if (m_currentSkillCycleIndex >= maxGroups)
if (m_currentSkillCycleIndex >= maxPairs)
{
m_currentSkillCycleIndex = 0;
}
// Calculate skill indices for this cycle
int baseSkillIndex = m_currentSkillCycleIndex * skillsPerCycle;
int skillIndex1 = m_currentSkillCycleIndex * 2;
int skillIndex2 = skillIndex1 + 1;
// Add up to 8 skills to slots 0-7
for (int slot = 0; slot < skillsPerCycle; slot++)
// Add first skill to slot 0
if (skillIndex1 < skillCount)
{
int skillIndex = baseSkillIndex + slot;
if (skillIndex < skillCount)
CECSkill pSkill1 = GetPositiveSkillByIndex(skillIndex1);
if (pSkill1 != null)
{
CECSkill pSkill = GetPositiveSkillByIndex(skillIndex);
if (pSkill != null)
{
pSCS.CreateSkillShortcut(slot, pSkill);
}
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);
}
}
@@ -1936,5 +1968,6 @@ namespace BrewMonster
CDlgQuickBar cDlgQuickBar = CECUIManager.Instance?.GetCDlgQuickBar();
cDlgQuickBar?.UpdateShortcuts();
}
#endif
}
}