using System.Collections.Generic; // 리스트 기능을 사용할거에요 -> System.Collections.Generic을 using UnityEngine; // 유니티 엔진의 기본 기능을 불러올거에요 -> UnityEngine을 public class MobUpdateManager : MonoBehaviour // 클래스를 선언할거에요 -> MonoBehaviour를 상속받는 MobUpdateManager를 { public static MobUpdateManager Instance; // 변수를 선언할거에요 -> 어디서든 접근 가능한 싱글톤 인스턴스 Instance를 // ⭐ Monster -> MonsterClass로 수정하여 에러 해결 private List _activeMobs = new List(); // 리스트를 초기화할거에요 -> 활성화된 몬스터들을 담을 _activeMobs를 private void Awake() => Instance = this; // 함수를 실행할거에요 -> 스크립트 시작 시 내 자신(this)을 Instance에 넣기를 // ⭐ 매개변수 타입도 MonsterClass로 변경 public void RegisterMob(MonsterClass mob) => _activeMobs.Add(mob); // 함수를 선언할거에요 -> 몬스터를 리스트에 추가하는 RegisterMob을 public void UnregisterMob(MonsterClass mob) => _activeMobs.Remove(mob); // 함수를 선언할거에요 -> 몬스터를 리스트에서 제거하는 UnregisterMob을 private void Update() // 함수를 실행할거에요 -> 매 프레임마다 호출되는 Update를 { for (int i = 0; i < _activeMobs.Count; i++) // 반복할거에요 -> 리스트에 있는 모든 몬스터 개수만큼 { // 리스트를 돌며 카메라 최적화 로직이 담긴 OnManagedUpdate 호출 if (_activeMobs[i] != null) _activeMobs[i].OnManagedUpdate(); // 조건이 맞으면 실행할거에요 -> 몬스터가 존재한다면 관리 업데이트 함수(OnManagedUpdate)를 } } }