InteractionType 비트연산으로 프리팹에서 설정하기
This commit is contained in:
parent
a3e6818810
commit
eb9ac5a34f
@ -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();
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user