From b3a9823f493bfc3f72f57f152f3dc1a8f03671e0 Mon Sep 17 00:00:00 2001 From: dal4segno Date: Wed, 25 Feb 2026 22:14:33 +0900 Subject: [PATCH] =?UTF-8?q?=EC=96=B4=EA=B7=B8=EB=A1=9C=20=EC=8B=9C?= =?UTF-8?q?=EC=8A=A4=ED=85=9C=20=EA=B4=80=EB=A0=A8=20=EC=98=A4=EB=A5=98=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 순회 중 순회 대상을 수정해서 발생한 문제 순회와 수정을 분리함 --- Assets/Scripts/EnemyAIController.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Assets/Scripts/EnemyAIController.cs b/Assets/Scripts/EnemyAIController.cs index 6cb5853..e16b811 100644 --- a/Assets/Scripts/EnemyAIController.cs +++ b/Assets/Scripts/EnemyAIController.cs @@ -671,6 +671,7 @@ namespace Northbound private void DecayAggro() { List keysToRemove = new List(); + List> updates = new List>(); foreach (var kvp in _aggroTable) { @@ -681,10 +682,16 @@ namespace Northbound } else { - _aggroTable[kvp.Key] = newAggro; + updates.Add(new KeyValuePair(kvp.Key, newAggro)); } } + // 순회 후 수정 적용 + foreach (var update in updates) + { + _aggroTable[update.Key] = update.Value; + } + // 어그로가 0 이하인 항목 제거 foreach (var key in keysToRemove) {