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); } } }