//InteractorKey targetActor = null;

    void scanforactor()
    {
        //print ("scan");

        foreach (Collider checker in Physics.OverlapSphere(transform.position + offset, radius))
        {
            if (logDebugInfo)
            {
                print(checker);
            }
            //if (checker.gameObject.tag == "Player") {
            if (checker.GetComponent <InteractorKey> ())
            {
                if (!playerOnly || (playerOnly && checker.tag == "Player"))
                {
                    if (actorTarget == null)
                    {
                        actorTarget = checker.GetComponent <InteractorKey> ();

                        if (actorTarget.eventTarget != null && actorTarget.eventTarget.priority > priority)
                        {
                            actorTarget = null;
                            return;
                        }

                        if (!noAction)
                        {
                            actorTarget.eventTarget = this;
                        }
                        m_enterEvent.Invoke(actorTarget);
                    }

                    m_stayEvent.Invoke(actorTarget);
                    if (logDebugInfo)
                    {
                        print("Stay Event");
                    }

                    return;
                }
            }
        }

        if (actorTarget != null)
        {
            m_exitEvent.Invoke(actorTarget);

            actorTarget.eventTarget = null;

            actorTarget = null;
        }
    }
Exemple #2
0
 public IInteractor this[InteractorKey key] => _interactors[key];