public static float GetViewDistance(Vector3 position, float viewDistance, bool isAlerted) { var count = Physics.OverlapSphereNonAlloc(position, 1, Colliders, Layers.Zones, QueryTriggerInteraction.Collide); _dark.Clear(); _light.Clear(); _grass.Clear(); for (int i = 0; i < count; i++) { { var zone = DarkZone.Get(Colliders[i].gameObject); if (zone != null) { _dark.Add(zone); } } { var zone = LightZone.Get(Colliders[i].gameObject); if (zone != null) { _light.Add(zone); } } { var zone = GrassZone.Get(Colliders[i].gameObject); if (zone != null) { _grass.Add(zone); } } } return(GetViewDistance(viewDistance, _dark, _light, _grass, isAlerted)); }
/// <summary> /// The actor leaves a lighted area. /// </summary> public void OnLeaveLight(LightZone zone) { if (_lightZones.Contains(zone)) { _lightZones.Remove(zone); } }
/// <summary> /// The actor enters a flashlight or any similar object. /// </summary> public void OnEnterLight(LightZone zone) { if (!_lightZones.Contains(zone)) { _lightZones.Add(zone); } }
public static void Register(LightZone zone) { if (!_list.Contains(zone)) { _list.Add(zone); } _map[zone.gameObject] = zone; }
public static void Unregister(LightZone zone) { if (_list.Contains(zone)) { _list.Remove(zone); } if (_map.ContainsKey(zone.gameObject)) { _map.Remove(zone.gameObject); } }