Example #1
0
        public static float GetViewDistance(Vector3 position, float viewDistance, bool isAlerted)
        {
            var count = Physics.OverlapSphereNonAlloc(position, 1, _colliders, 0x1 << 8, QueryTriggerInteraction.Collide);

            _dark.Clear();
            _light.Clear();
            _grass.Clear();

            for (int i = 0; i < count; i++)
            {
                {
                    var zone = DarkZones.Get(_colliders[i].gameObject);
                    if (zone != null)
                    {
                        _dark.Add(zone);
                    }
                }
                {
                    var zone = LightZones.Get(_colliders[i].gameObject);
                    if (zone != null)
                    {
                        _light.Add(zone);
                    }
                }
                {
                    var zone = GrassZones.Get(_colliders[i].gameObject);
                    if (zone != null)
                    {
                        _grass.Add(zone);
                    }
                }
            }

            return(GetViewDistance(viewDistance, _dark, _light, _grass, isAlerted));
        }
Example #2
0
 private void OnDestroy()
 {
     GrassZones.Unregister(this);
 }
Example #3
0
 private void OnDisable()
 {
     GrassZones.Unregister(this);
 }
Example #4
0
 private void OnEnable()
 {
     GrassZones.Register(this);
 }