update feature useitem

This commit is contained in:
VuNgocHaiC7
2026-01-29 17:08:58 +07:00
parent d69fed7aea
commit ccbe1b4a0c
13 changed files with 37 additions and 52 deletions
@@ -663,7 +663,7 @@ namespace BrewMonster.Common
{
int piMax = -1;
CECHostPlayer pHost = EC_Game.GetGameRun().GetHostPlayer();
if (pHost.GetCoolTime((int)CSNetwork.GPDataType.CoolTimeIndex.GP_CT_QUERY_MAFIA_PVP_INFO, ref piMax) == 0)
if (pHost.GetCoolTime((int)CSNetwork.GPDataType.CoolTimeIndex.GP_CT_QUERY_MAFIA_PVP_INFO, out piMax) == 0)
{
UnityGameSession.Instance.GameSession.c2s_SendCmdQueryFactionPVPInfo(idFaction);
}
@@ -147,10 +147,6 @@ namespace BrewMonster.Scripts.Managers
// Update inventory pack cooldowns
// 更新背包冷却
UpdatePackageCooldowns(inventoryPackButtons, PKG_INVENTORY);
// Equipment pack doesn't typically have cooldowns but update anyway
// 装备栏通常没有冷却但也更新
UpdatePackageCooldowns(equipmentPackButtons, PKG_EQUIPMENT);
}
/// <summary>
@@ -187,16 +183,15 @@ namespace BrewMonster.Scripts.Managers
if (hasItem)
{
Debug.Log($"[UpdatePackageCooldowns] Package {package}, Slot {slot}: Found item {itemData.m_tid}");
// Use InventoryView's method to update cooldown
// 使用 InventoryView 的方法更新冷却
view.UpdateCooldownOverlay(button, itemData);
}
else
{
// Hide overlay for empty slots
// 空槽位隐藏遮罩
view.HideCooldownOverlay(button);
//// Hide overlay for empty slots
//// 空槽位隐藏遮罩
//view.HideCooldownOverlay(button);
}
}
}
@@ -807,8 +802,6 @@ namespace BrewMonster.Scripts.Managers
return;
}
Debug.Log($"[UpdateCooldownOverlay] Checking item {itemData.m_tid} in button {button.name}");
// Find or cache overlay image
// 查找或缓存遮罩图片
Image overlay = null;
@@ -833,7 +826,6 @@ namespace BrewMonster.Scripts.Managers
overlay = overlayTransform.GetComponent<Image>();
if (overlay != null)
{
Debug.Log($"[UpdateCooldownOverlay] Found image_overlay for button {button.name}");
_overlayImages[button] = overlay;
}
else
@@ -849,18 +841,15 @@ namespace BrewMonster.Scripts.Managers
if (overlay == null)
{
Debug.LogWarning($"[UpdateCooldownOverlay] Overlay is null after search for button {button.name}");
return;
}
// Get cooldown info from item
// 从物品获取冷却信息
int? maxCooldown = null;
int maxCooldown = -1;
int currentCooldown = itemData.GetCoolTime(out maxCooldown);
Debug.Log($"[UpdateCooldownOverlay] Item {itemData.m_tid}: currentCooldown={currentCooldown}, maxCooldown={maxCooldown}");
if (currentCooldown > 0 && maxCooldown > 0)
if (currentCooldown > 0)
{
// Show overlay and set fill amount
// 显示遮罩并设置填充量
@@ -868,21 +857,18 @@ namespace BrewMonster.Scripts.Managers
// Calculate fill amount (1 = full cooldown, 0 = ready)
// 计算填充量(1=完全冷却,0=就绪)
float fillAmount = (float)currentCooldown / maxCooldown.Value;
overlay.fillAmount = fillAmount;
if (maxCooldown > 0)
{
float fillAmount = (float)currentCooldown / maxCooldown;
overlay.fillAmount = fillAmount;
}
// Set semi-transparent black color like original code
// 设置半透明黑色,与原始代码相同
overlay.color = new Color(0, 0, 0, 0.5f); // A3DCOLORRGBA(0, 0, 0, 128)
Debug.Log($"[UpdateCooldownOverlay] Showing overlay for item {itemData.m_tid} with fillAmount={fillAmount}, overlay active={overlay.gameObject.activeSelf}");
}
else
{
// Hide overlay when not in cooldown
// 不在冷却时隐藏遮罩
overlay.gameObject.SetActive(false);
Debug.Log($"[UpdateCooldownOverlay] Hiding overlay for item {itemData.m_tid} (no cooldown)");
}
}
@@ -165,10 +165,11 @@ namespace PerfectWorld.Scripts.Managers
}
// Get item cool time
public int GetCoolTime(ref int piMax)
public override int GetCoolTime(out int piMax)
{
piMax = 0;
CECHostPlayer pHost = EC_Game.GetGameRun().GetHostPlayer();
return pHost != null ? pHost.GetCoolTime((int)CoolTimeIndex.GP_CT_AUTOHP, ref piMax) : 0;
return pHost != null ? pHost.GetCoolTime((int)CoolTimeIndex.GP_CT_AUTOHP, out piMax) : 0;
}
}
}
@@ -168,7 +168,7 @@ namespace PerfectWorld.Scripts.Managers
public int GetCoolTime(ref int piMax)
{
CECHostPlayer pHost = EC_Game.GetGameRun().GetHostPlayer();
return pHost != null ? pHost.GetCoolTime((int)CoolTimeIndex.GP_CT_AUTOMP, ref piMax) : 0;
return pHost != null ? pHost.GetCoolTime((int)CoolTimeIndex.GP_CT_AUTOMP, out piMax) : 0;
}
}
}
@@ -1138,9 +1138,9 @@ namespace BrewMonster.Scripts.Managers
}
/// <summary>Get item cool time in milliseconds (0 by default).</summary>
public virtual int GetCoolTime(out int? piMax)
public virtual int GetCoolTime(out int piMax)
{
piMax = null;
piMax = -1;
return 0;
}
@@ -65,8 +65,9 @@ namespace PerfectWorld.Scripts.Managers
{
return m_pDBEssence.Name;
}
public int GetCoolTime(ref int piMax/* NULL */)
public override int GetCoolTime(out int piMax/* NULL */)
{
piMax = 1;
CECHostPlayer pHost = CECGameRun.Instance.GetHostPlayer();
if (!pHost)
return 0;
@@ -75,11 +76,11 @@ namespace PerfectWorld.Scripts.Managers
switch (m_pDBMajorType.id)
{
case 1810: iTime = pHost.GetCoolTime((int)CoolTimeIndex.GP_CT_REJUVENATION_POTION, ref piMax); break;
case 1794: iTime = pHost.GetCoolTime((int)CoolTimeIndex.GP_CT_HP_POTION, ref piMax); break;
case 1802: iTime = pHost.GetCoolTime((int)CoolTimeIndex.GP_CT_MP_POTION, ref piMax); break;
case 1810: iTime = pHost.GetCoolTime((int)CoolTimeIndex.GP_CT_REJUVENATION_POTION, out piMax); break;
case 1794: iTime = pHost.GetCoolTime((int)CoolTimeIndex.GP_CT_HP_POTION, out piMax); break;
case 1802: iTime = pHost.GetCoolTime((int)CoolTimeIndex.GP_CT_MP_POTION, out piMax); break;
case 1815:
case 2038: iTime = pHost.GetCoolTime((int)CoolTimeIndex.GP_CT_ANTIDOTE_POTION, ref piMax); break;
case 2038: iTime = pHost.GetCoolTime((int)CoolTimeIndex.GP_CT_ANTIDOTE_POTION, out piMax); break;
}
return iTime;
@@ -80,7 +80,7 @@ namespace PerfectWorld.Scripts.Managers
if (!pHost)
return 0;
int iTime = pHost.GetCoolTime((int)CoolTimeIndex.GP_CT_FEED_PET, ref piMax);
int iTime = pHost.GetCoolTime((int)CoolTimeIndex.GP_CT_FEED_PET, out piMax);
return iTime;
}
@@ -55,7 +55,7 @@ namespace PerfectWorld.Scripts.Managers
public int GetCoolTime(ref int piMax)
{
CECHostPlayer pHost = EC_Game.GetGameRun().GetHostPlayer();
return pHost ? pHost.GetCoolTime((int)CoolTimeIndex.GP_CT_TOWNSCROLL, ref piMax) : 0;
return pHost ? pHost.GetCoolTime((int)CoolTimeIndex.GP_CT_TOWNSCROLL, out piMax) : 0;
}
protected override string GetNormalDesc(bool bRepair)
@@ -56,7 +56,7 @@ namespace PerfectWorld.Scripts.Managers
CECHostPlayer pHost = EC_Game.GetGameRun().GetHostPlayer();
if (!pHost)
return 0;
int iTime = pHost.GetCoolTime((int)CoolTimeIndex.GP_CT_TOWNSCROLL, ref piMax);
int iTime = pHost.GetCoolTime((int)CoolTimeIndex.GP_CT_TOWNSCROLL, out piMax);
return iTime;
}
@@ -244,8 +244,6 @@ public class CECNPCServer : CECNPC
if (idTask <= 0)
continue;
BMLogger.Log($"[UpdateCurTaskIcon] Check OUT task {idTask}, CanShow={pTask.CanShowTask(idTask)}, CanDeliver={pTask.CanDeliverTask(idTask)}");
if (!pTask.CanShowTask(idTask))
continue;
@@ -258,7 +256,6 @@ public class CECNPCServer : CECNPC
if (pTaskTemp.IsKeyTask())
{
m_TaskIcon = IconTaskType.QI_OUT_K;
BMLogger.Log($"[UpdateCurTaskIcon] Set icon QI_OUT_K for task {idTask}");
UpdateTaskIconUI();
return;
}
@@ -209,9 +209,9 @@ namespace BrewMonster
if (pItem != null)
{
int? maxNullable = null;
int maxNullable = -1;
int coolTime = pItem.GetCoolTime(out maxNullable);
nMax = maxNullable ?? 0;
nMax = maxNullable > 0 ? maxNullable: 0;
if (coolTime > 0)
{
@@ -270,8 +270,7 @@ namespace BrewMonster
{
iIconFile = (int)EC_GAMEUI_ICONS.ICONS_SUITE;
int fashionCoolTimeMax = 0;
int fashionCoolTime = pHost.GetCoolTime((int)CoolTimeIndex.GP_CT_EQUIP_FASHION_ITEM, ref fashionCoolTimeMax);
int fashionCoolTime = pHost.GetCoolTime((int)CoolTimeIndex.GP_CT_EQUIP_FASHION_ITEM, out int fashionCoolTimeMax);
pCell.SetColor(new Color(1f, 1f, 1f));
if (fashionCoolTimeMax > 0)
@@ -117,9 +117,9 @@ namespace BrewMonster
EC_IvtrItem pItem = GetItem();
if (pItem != null)
{
int? maxNullable = null;
int maxNullable = -1;
int result = pItem.GetCoolTime(out maxNullable);
piMax = maxNullable ?? 0;
piMax = maxNullable >0 ? maxNullable: 0;
return result;
}
+6 -5
View File
@@ -678,8 +678,9 @@ namespace BrewMonster
COOLTIME ct = m_aCoolTimes[pCmd.cooldown_index];
ct.iCurTime = pCmd.cooldown_time;
ct.iMaxTime = pCmd.cooldown_time;
Debug.Log("New Max cool time forIvtrMedicine: it be: " + pCmd.cooldown_time);
Math.Min(ct.iCurTime, ct.iMaxTime);
m_aCoolTimes[pCmd.cooldown_index] = ct;
if (pCmd.cooldown_index == (int)CoolTimeIndex.GP_CT_CAST_ELF_SKILL)
{
int i;
@@ -707,7 +708,7 @@ namespace BrewMonster
CECSkill pSkill = GetPositiveSkillByIndex(i);
int fakeRef = 0;
if (pSkill != null && (pSkill.GetCommonCoolDown() & mask) != 0)
pSkill.StartCooling(GetCoolTime(pCmd.cooldown_index, ref fakeRef), GetCoolTime(pCmd.cooldown_index, ref fakeRef));
pSkill.StartCooling(GetCoolTime(pCmd.cooldown_index, out fakeRef), GetCoolTime(pCmd.cooldown_index, out fakeRef));
}
/*const std::map<unsigned int, CECSkill*>&inherentSkillMap = CECComboSkillState::Instance().GetInherentSkillMap();
std::map < unsigned int, CECSkill*>::const_iterator it;
@@ -6098,13 +6099,13 @@ namespace BrewMonster
}
// Get cool time
public int GetCoolTime(int iIndex, ref int piMax /* NULL */)
public virtual int GetCoolTime(int iIndex, out int piMax /* NULL */)
{
piMax = 1;
if (iIndex >= 0 && iIndex < (int)CoolTimeIndex.GP_CT_MAX)
{
if (piMax > 0)
piMax = m_aCoolTimes[iIndex].iMaxTime;
return m_aCoolTimes[iIndex].iCurTime;
}
@@ -7376,7 +7377,7 @@ namespace BrewMonster
return false;
}
int? piMax = null;
int piMax = -1;
if (pItem.GetCoolTime(out piMax) > 0)
{
if (showMsg)