/// <summary> /// This Validcheck will only return true if all its checks are true /// </summary> public override bool ValidCheck(Vector3 startPos, float radius, ref Vector3 pos, ref Quaternion rot) { bool allValid = true; //For each check we have in our checkList, run a validCheck for (int i = 0; i < checks.Count; i++) { if (checks[i] == null) { continue; } SpawnCheck check = checks[i]; if (!check.ValidCheck(startPos, radius, ref pos, ref rot))// Will break out of this try early if any of the checks return false { allValid = false; break; } } return(allValid); }
/// <summary> /// Checks to see if this spotFinder allows spawning in the input direction, based on the directions of the checks /// </summary> public virtual bool CanSpawnDirection(Vector3 rootDirection) { //if we have a raycast check, this spotfinder requires a nearby place for (int i = 0; i < checks.Count; i++) { SpawnCheck check = checks[i]; System.Type checkType = check.GetType(); if (checkType == typeof(RaycastCheck)) { if (rootDirection == Vector3.zero) { return(false); } RaycastCheck dr = check as RaycastCheck; float rootDot = Vector3.Dot(dr.castDirection, rootDirection); //Debug.Log("Checking root " + rootDirection + " and " + dr.castDirection + " / " + rootDot); if (rootDot < 0.1f) { return(false); } } } return(true); }