コード例 #1
0
        private bool AcceptsMeeting(AgentNPC agentNPC)
        {
            if (agentNPC.GetComponent <MeetBehaviour>() || agentNPC.GetComponent <PatrolBehaviour>() == null)
            {
                return(false); // if it is already in meeting then return false
            }
            // check to prevent two agents meeting without having time to turn around and walk away
            if (LastMeetingTime != 0 && !(Time.time - LastMeetingTime > _npc.agentConfiguration.cooldownMeeting))
            {
                return(false);
            }

            var found = _ignoredAgents.Find(tuple => tuple.Item1 == agentNPC);

            // if we found an agent ignored and
            if (found != null)
            {
                // if the duration has passed seconds had not still passed, then we simply cancel the meeting
                var ignoreDuration    = found.Item2;
                var initialIgnoreTIme = found.Item3;
                if (Time.time - initialIgnoreTIme < ignoreDuration)
                {
                    Debug.Log($"Meeting Failed because {_npc.name} ignored {agentNPC.name}");
                    return(false);
                }

                // if the duration in seconds passed(e.g 10 seconds) than remove the bot because is no longer ignored
                _ignoredAgents.Remove(found);
            }

            if (AIUtils.CanSeeObject(_transform, agentNPC.transform,
                                     AgentManager.Instance.generalConfiguration.viewDistance,
                                     AgentManager.Instance.generalConfiguration.viewAngle))
            {
                return(true);
            }

            return(false);
        }