/// <summary> /// Updates cover search. /// </summary> public void Update(CoverState current, Vector3 position, Vector3 head, float takeRadius, float crouchRadius, float climbRadius, float capsuleRadius, CoverSettings settings) { _current = current; _position = position; _head = head; _capsuleRadius = capsuleRadius; _settings = settings; _takeRadius = takeRadius; _crouchRadius = crouchRadius; _climbRadius = climbRadius; var searchRadius = takeRadius > crouchRadius ? takeRadius : crouchRadius; searchRadius = searchRadius > climbRadius ? searchRadius : climbRadius; var colliderCount = Physics.OverlapSphereNonAlloc(position, searchRadius, Util.Colliders, Layers.Cover); _coverCount = 0; for (int i = 0; i < colliderCount; i++) { var cover = GetCover(Util.Colliders[i].gameObject); if (cover != null) { _covers[_coverCount++] = cover; if (_coverCount == _covers.Length) { break; } } } }
/// <summary> /// Updates cover search. /// </summary> public void Update(CoverState current, Vector3 position, Vector3 head, float searchRadius, float capsuleRadius, CoverSettings settings) { _current = current; _colliderCount = Physics.OverlapSphereNonAlloc(position, searchRadius, _colliders); _position = position; _head = head; _radius = capsuleRadius; _settings = settings; for (int i = 0; i < _colliderCount; i++) { _covers[i] = GetCover(_colliders[i].gameObject); } }