IEnumerator SecondView() { while (MopOcclusionCoreSettings.IsModActive) { ticks += 1; if (ticks > 1000) { ticks = 0; } int step = Math.Max(Screen.width, Screen.height) / MopOcclusionCoreSettings.OcclusionSamples; int x, y; for (x = step / 2; x <= Screen.width; x += step * 2) { for (y = step / 2; y <= Screen.height; y += step * 2) { try { Ray sampleRay = Camera.main.ScreenPointToRay(new Vector3(x, y, 0)); RaycastHit hit; if (Physics.Raycast(sampleRay, out hit, MopOcclusionCoreSettings.ViewDistance)) { GameObject target = hit.transform.gameObject; OcclusionBase thisTargetScript = target.GetComponent <OcclusionBase>(); while (thisTargetScript == null && target.transform.parent != null) { if (target.transform.parent != null) { target = target.transform.parent.gameObject; thisTargetScript = target.GetComponent <OcclusionBase>(); } ; if (thisTargetScript != null) { thisTargetScript.LastSeen = DateTime.Now; thisTargetScript.IsVisible = true; } } } } catch { } } yield return(null); } } }
IEnumerator FirstView() { while (MopOcclusionCoreSettings.IsModActive) { Stopwatch stopwatch = new Stopwatch(); if (!isOcclusionHideDelayCalculated) { calculationDelayStep += 1; if (calculationDelayStep > DelayEnd) { stopwatch = Stopwatch.StartNew(); } } ticks += 1; if (ticks > 1000) { ticks = 0; } int step = Math.Max(Screen.width, Screen.height) / MopOcclusionCoreSettings.OcclusionSamples; int x, y; for (x = 0; x <= Screen.width; x += step * 2) { for (y = 0; y <= Screen.height; y += step * 2) { try { Ray sampleRay = Camera.main.ScreenPointToRay(new Vector3(x, y, 0)); RaycastHit hit; if (Physics.Raycast(sampleRay, out hit, MopOcclusionCoreSettings.ViewDistance)) { GameObject target = hit.transform.gameObject; OcclusionBase thisTargetScript = target.GetComponent <OcclusionBase>(); while (thisTargetScript == null && target.transform.parent != null) { if (target.transform.parent != null) { target = target.transform.parent.gameObject; thisTargetScript = target.GetComponent <OcclusionBase>(); } ; if (thisTargetScript != null) { thisTargetScript.LastSeen = DateTime.Now; thisTargetScript.IsVisible = true; } } } } catch { } } yield return(null); } yield return(null); if (!isOcclusionHideDelayCalculated && calculationDelayStep > DelayEnd) { stopwatch.Stop(); isOcclusionHideDelayCalculated = true; long time = stopwatch.ElapsedMilliseconds * 2; SetOcclusionHideDelayTime(time); } } }