using System; using System.Collections.Generic; using UnityEngine; namespace DDD { [Serializable] public class RestaurantPropLocation { public string Id; public Vector2 Position; public RestaurantPropLocation(string id, Vector2 position) { Id = id; Position = position; } } public class RestaurantEnvironmentState : ScriptableObject { public List Props = new List(); public List Objects = new List(); // 인터랙션 가능한 객체(IInteractable)를 관리하기 위한 리스트 (런타임 전용) private readonly List _registeredInteractables = new List(); /// /// 인터랙션 가능한 객체를 등록합니다 /// public void RegisterInteractable(IInteractable interactable) { if (interactable == null) return; if (_registeredInteractables.Contains(interactable)) return; _registeredInteractables.Add(interactable); } /// /// 인터랙션 가능한 객체를 해제합니다 /// public void UnregisterInteractable(IInteractable interactable) { if (interactable == null) return; _registeredInteractables.Remove(interactable); } /// /// 특정 InteractionType에 해당하는 인터랙션 객체들을 반환합니다 /// public List GetInteractablesByType(InteractionType interactionType) { var result = new List(); // null 또는 Destroyed 오브젝트 정리 _registeredInteractables.RemoveAll(item => item == null || (item as UnityEngine.Object) == null); foreach (var interactable in _registeredInteractables) { if (interactable.GetInteractionType() == interactionType) { result.Add(interactable); } } return result; } /// /// 모든 등록된 인터랙션 객체들을 반환합니다 /// public List GetAllInteractables() { _registeredInteractables.RemoveAll(item => item == null || (item as UnityEngine.Object) == null); return new List(_registeredInteractables); } } }