public override Collider[] detect(int pMaxRequired, LayerMask pLayerMask, detectorFilterFunc pNeedDetectedFunc) { if (!collisionLayer.isAliveFullCheck(_lockedTarget)) searchFireTargetInList(); if (_lockedTarget) { return new Collider[] { _lockedTarget .collider}; } return new Collider[0]; }
public override Collider[] detect(int pMaxRequired, LayerMask pLayerMask, detectorFilterFunc pNeedDetectedFunc) { //Collider[] lOut = new Collider[0]; List<Collider> lOut = new List<Collider>(); foreach (zzDetectorBase subDetector in subDetectorList) { Collider[] lSubResult = subDetector.detect(pMaxRequired, pLayerMask,pNeedDetectedFunc); pMaxRequired -= lSubResult.Length; //lOut += lSubResult; lOut.AddRange(lSubResult); if (pMaxRequired <= 0) break; } return lOut.ToArray(); }
public virtual Collider[] detect(int pMaxRequired, LayerMask pLayerMask, detectorFilterFunc pNeedDetectedFunc) { RaycastHit[] lHits; //lHits = Physics.SphereCastAll(getOrigin(), radius, getDirection(), Mathf.Infinity, pLayerMask); lHits = _impDetect(pLayerMask); int lOutNum; lOutNum = Mathf.Min(pMaxRequired, lHits.Length); Collider[] lOut; //执行探测过滤,未测试 if (pNeedDetectedFunc != null) { int lHitsIndex = 0; int lOutIndex = 0; var lColliderList = new List<Collider>(lOutNum); while ( lOutIndex < lOutNum && lHitsIndex < lHits.Length ) { if (pNeedDetectedFunc(lHits[lOutIndex].collider)) { //lOut[lOutIndex] = lHits[lOutIndex].collider; lColliderList.Add(lHits[lOutIndex].collider); ++lOutIndex; } ++lHitsIndex; } lOut = lColliderList.ToArray(); } else { lOut = new Collider[lOutNum]; for (int lOutIndex = 0; lOutIndex < lOutNum; ++lOutIndex) { lOut[lOutIndex] = lHits[lOutIndex].collider; } } return lOut; }
public override Collider[] detect(int pMaxRequired, LayerMask pLayerMask, detectorFilterFunc pNeedDetectedFunc) { if(detectedList.Count==0) return nullReturn; List<Collider> lOut = new List<Collider>(detectedList.Count); List<Collider> lRemoved = new List<Collider>(); foreach (var lCollider in detectedList) { if (lCollider && ((1 << lCollider.gameObject.layer) & _layerMask.value)!=0 ) lOut.Add(lCollider); else lRemoved.Add(lCollider); } foreach (var lCollider in lRemoved) { removeDetectedObject(lCollider); } return lOut.ToArray(); }
public override Collider[] detect(int pMaxRequired, LayerMask pLayerMask, detectorFilterFunc pNeedDetectedFunc) { return Physics.OverlapSphere(transform.position, radius, pLayerMask); }