ProjectDDD/Assets/_DDD/_Scripts/RestaurantState/FlowStates/RestaurantEnvironmentState.cs
Jeonghyeon Ha 4ef63ec9a9 AI 비헤이비어 트리 액션 및 컨디셔널 구현
RestaurantOrderAvailable, StartRestaurantOrder, MoveToInteractionTarget
2025-08-21 19:12:06 +09:00

74 lines
2.6 KiB
C#

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<RestaurantPropLocation> Props = new List<RestaurantPropLocation>();
public List<RestaurantPropLocation> Objects = new List<RestaurantPropLocation>();
// 인터랙션 가능한 객체(IInteractable)를 관리하기 위한 리스트 (런타임 전용)
private readonly List<IInteractable> _registeredInteractables = new List<IInteractable>();
/// <summary>
/// 인터랙션 가능한 객체를 등록합니다
/// </summary>
public void RegisterInteractable(IInteractable interactable)
{
if (interactable == null) return;
if (_registeredInteractables.Contains(interactable)) return;
_registeredInteractables.Add(interactable);
}
/// <summary>
/// 인터랙션 가능한 객체를 해제합니다
/// </summary>
public void UnregisterInteractable(IInteractable interactable)
{
if (interactable == null) return;
_registeredInteractables.Remove(interactable);
}
/// <summary>
/// 특정 InteractionType에 해당하는 인터랙션 객체들을 반환합니다
/// </summary>
public List<IInteractable> GetInteractablesByType(InteractionType interactionType)
{
var result = new List<IInteractable>();
// 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;
}
/// <summary>
/// 모든 등록된 인터랙션 객체들을 반환합니다
/// </summary>
public List<IInteractable> GetAllInteractables()
{
_registeredInteractables.RemoveAll(item => item == null || (item as UnityEngine.Object) == null);
return new List<IInteractable>(_registeredInteractables);
}
}
}