using UnityEngine; namespace DDD { public class RestaurantCharacterMovement : MonoBehaviour { private RestaurantCharacterMovementConstraint _constraint; private void Awake() { _constraint = gameObject.AddComponent(); } public virtual bool CanMove() { // Get all components implements IRestaurantMovementConstraint var constraints = GetComponents(); // TODO : Maybe need optimize GetComponents? foreach (var movementConstraint in constraints) { if (movementConstraint.IsBlockingMovement()) { return false; } } return true; } } }