public override void Tick(IChalkboard chalkboard)
        {
            base.Tick(chalkboard);

            List <Interactable> detectedInteractables = new List <Interactable>();

            Collider[] colliders = Physics.OverlapSphere(transform.position, radius, layerMask);
            for (int i = 0; i < colliders.Length; i++)
            {
                if (colliders[i].gameObject != transform.gameObject)
                {
                    Interactable interactable = colliders[i].GetComponentInParent <Interactable>();
                    if (interactable)
                    {
                        detectedInteractables.Add(interactable);
                    }
                }
            }
            chalkboard.AddOrUpdate(interactablesListName, detectedInteractables);

            if (detectedInteractables.Count == 0)
            {
                if (noInteractablesBehaviour)
                {
                    noInteractablesBehaviour.Tick(chalkboard);
                }
            }
            else
            {
                Vector3 pos = detectedInteractables[0].GetInteractionPosition();
                chalkboard.AddOrUpdate(chosenInteractablePositionName, pos);

                if (interactablesBehaviour)
                {
                    interactablesBehaviour.Tick(chalkboard);
                }
                Debug.Log(transform.name + " detected " + chalkboard.GetSystem <List <Interactable> >(interactablesListName).Count + " Colliders");
            }
        }
Exemplo n.º 2
0
 protected override void OnUpdate()
 {
     aiBehaviour.Tick(chalkboard);
 }