From fc38b2199d5930e148262ce19aff2e7792b40420 Mon Sep 17 00:00:00 2001 From: HungDK <> Date: Thu, 9 Apr 2026 10:53:36 +0700 Subject: [PATCH] Update select target to nearest everytimes --- Assets/Scripts/CECHostPlayer.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Assets/Scripts/CECHostPlayer.cs b/Assets/Scripts/CECHostPlayer.cs index 90efd3e2bf..5a63a0e17b 100644 --- a/Assets/Scripts/CECHostPlayer.cs +++ b/Assets/Scripts/CECHostPlayer.cs @@ -63,6 +63,7 @@ namespace BrewMonster private CECPetCorral m_pPetCorral; private List m_aTabSels = new List(); + private int m_lastAutoSelectNearestId = 0; private List m_aPtSkills = new List(); private List m_aPsSkills = new List(); private List m_aEquipSkills = new List(); @@ -2812,10 +2813,22 @@ namespace BrewMonster int idNewSel = 0; if (sorted.Count == 0) { + m_lastAutoSelectNearestId = 0; idNewSel = idCurSel; } else { + int nearestId = sorted[0].id; + if (nearestId != 0 && nearestId != m_lastAutoSelectNearestId) + { + // If the nearest target changed (movement/spawn/despawn), reset cycle back to nearest + m_lastAutoSelectNearestId = nearestId; + idNewSel = nearestId; + } + else + { + m_lastAutoSelectNearestId = nearestId; + int idx = -1; for (int i = 0; i < sorted.Count; i++) { @@ -2827,6 +2840,7 @@ namespace BrewMonster } int nextIdx = idx < 0 ? 0 : (idx + 1) % sorted.Count; idNewSel = sorted[nextIdx].id; + } } // Select the target if found / 如果找到目标则选择它