From eb9ac5a34f1f95ab95e8192225a8fb07ac4f4e1a Mon Sep 17 00:00:00 2001 From: NTG_Lenovo Date: Fri, 8 Aug 2025 15:44:11 +0900 Subject: [PATCH] =?UTF-8?q?InteractionType=20=EB=B9=84=ED=8A=B8=EC=97=B0?= =?UTF-8?q?=EC=82=B0=EC=9C=BC=EB=A1=9C=20=ED=94=84=EB=A6=AC=ED=8C=B9?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EC=84=A4=EC=A0=95=ED=95=98=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/_DDD/_Scripts/GameEvent/IInteractable.cs | 13 ++++++++----- .../RestaurantCharacter/RestaurantCharacter.cs | 17 +++++++++++------ 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Assets/_DDD/_Scripts/GameEvent/IInteractable.cs b/Assets/_DDD/_Scripts/GameEvent/IInteractable.cs index dbb465fa8..556fae820 100644 --- a/Assets/_DDD/_Scripts/GameEvent/IInteractable.cs +++ b/Assets/_DDD/_Scripts/GameEvent/IInteractable.cs @@ -1,14 +1,17 @@ +using System; using UnityEngine; namespace DDD { - public enum InteractionType + [Flags] + public enum InteractionType : uint { - None = 0, - RestaurantManagementUi, - OpenRestaurant, - Count + None = 0u, + RestaurantManagementUi = 1u << 0, + OpenRestaurant = 1u << 1, + All = 0xFFFFFFFFu } + public interface IInteractable { bool CanInteract(); diff --git a/Assets/_DDD/_Scripts/RestaurantCharacter/RestaurantCharacter.cs b/Assets/_DDD/_Scripts/RestaurantCharacter/RestaurantCharacter.cs index 33aae44a9..eacd99880 100644 --- a/Assets/_DDD/_Scripts/RestaurantCharacter/RestaurantCharacter.cs +++ b/Assets/_DDD/_Scripts/RestaurantCharacter/RestaurantCharacter.cs @@ -1,19 +1,24 @@ +using Sirenix.OdinInspector; using UnityEngine; namespace DDD { public class RestaurantCharacter : MonoBehaviour, IGameCharacter, IInteractor { + [EnumToggleButtons, SerializeField] protected InteractionType _interactionType; + private void Start() { - // TODO : Add event solvers dynamically - for (int i = 0; i < (int)InteractionType.Count; i++) + foreach (var typeToSolver in RestaurantInteractionEventSolvers.TypeToSolver) { - InteractionType interactionType = (InteractionType)i; - // TODO : if this character should handle the interaction? - if (RestaurantInteractionEventSolvers.TypeToSolver.TryGetValue(interactionType, out var solverType)) + var flag = typeToSolver.Key; + if (flag == InteractionType.None) continue; + + if ((_interactionType & flag) == 0) continue; + + if (!TryGetComponent(typeToSolver.Value, out _)) { - gameObject.AddComponent(solverType); + gameObject.AddComponent(typeToSolver.Value); } } }