public static void ToggleTryCatchWork(bool onoff) { if (onoff) { WorkSchedulerBatch[,] array = WorkScheduler.Instance.schedulers; int length = array.GetLength(0); int length2 = array.GetLength(1); for (int i = 0; i < length; i++) { for (int j = 0; j < length2; j++) { WorkSchedulerBatch workSchedulerBatch = array[i, j]; workSchedulerBatch.DoWork = new WorkSchedulerBatch.DoWorkDelegate(workSchedulerBatch.DoWorkTryCatch); } } } else { WorkSchedulerBatch[,] array2 = WorkScheduler.Instance.schedulers; int length3 = array2.GetLength(0); int length4 = array2.GetLength(1); for (int k = 0; k < length3; k++) { for (int l = 0; l < length4; l++) { WorkSchedulerBatch workSchedulerBatch2 = array2[k, l]; workSchedulerBatch2.DoWork = new WorkSchedulerBatch.DoWorkDelegate(workSchedulerBatch2.DoWorkNoTry); } } } }
private void Awake() { this.xOffset = base.transform.position.x; this.yOffset = base.transform.position.z; if (WorkScheduler.Instance == null) { WorkScheduler.Instance = this; } else if (WorkScheduler.Instance != this) { UnityEngine.Object.DestroyImmediate(base.gameObject); } this.schedulers = new WorkSchedulerBatch[this.GridSize, this.GridSize]; for (int i = 0; i < this.GridSize; i++) { for (int j = 0; j < this.GridSize; j++) { this.schedulers[i, j] = new WorkSchedulerBatch(); } } this.globalScheduler = new WorkSchedulerBatch(); if (Application.isPlaying && !this.CaveScene && base.gameObject) { base.gameObject.SetActive(false); } }
private void ProcessArea(Vector3 position, long remainingTicks, bool swipe) { int frameCount = Time.frameCount; int num = 0; int num2 = 0; this.xPlayer = this.WorldToGridXRounded(position.x); this.yPlayer = this.WorldToGridYRounded(position.z); this.xMin = -2 - Mathf.Min(this.xPlayer - 3, 0); this.yMin = -2 - Mathf.Min(this.yPlayer - 3, 0); this.xMax = 1 - Mathf.Max(this.xPlayer + 2 - this.GridSize, 0); this.yMax = 1 - Mathf.Max(this.yPlayer + 2 - this.GridSize, 0); long maxTicks = remainingTicks * 3L / 4L / 5L; long maxTicks2 = remainingTicks * 1L / 4L / 12L; if (swipe) { this.xPlayer = 0; this.yPlayer = 0; this.xMin = 0; this.yMin = 0; this.xMax = this.GridSize - 1; this.yMax = this.GridSize - 1; WorkScheduler.FullCycle = true; } for (int i = this.xMin; i <= this.xMax; i++) { for (int j = this.yMin; j <= this.yMax; j++) { WorkSchedulerBatch workSchedulerBatch = this.schedulers[this.xPlayer + i, this.yPlayer + j]; if (i > -2 && i < 1 && j > -2 && j < 1) { if (workSchedulerBatch.LastNearRefreshFrame != frameCount) { workSchedulerBatch.LastNearRefreshFrame = frameCount; num += workSchedulerBatch.DoWork(maxTicks, false); } } else if (workSchedulerBatch.LastNearRefreshFrame != frameCount && workSchedulerBatch.LastFarRefreshFrame != frameCount) { workSchedulerBatch.LastFarRefreshFrame = frameCount; num2 += workSchedulerBatch.DoWork(maxTicks2, false); } } } }
private void ProcessArea(Vector3 position, long remainingTicks, bool swipe, bool threadSafeOnly = false) { if (!threadSafeOnly) { this.currentFrame = Time.frameCount; } int num = 0; int num2 = 0; this.xPlayer = this.WorldToGridXRounded(position.x); this.yPlayer = this.WorldToGridYRounded(position.z); this.xMin = -2 - Mathf.Min(this.xPlayer - 2, 0); this.yMin = -2 - Mathf.Min(this.yPlayer - 2, 0); this.xMax = 2 - Mathf.Max(this.xPlayer + 2 - (this.GridSize - 1), 0); this.yMax = 2 - Mathf.Max(this.yPlayer + 2 - (this.GridSize - 1), 0); long maxTicks = remainingTicks * 3L / 4L / 5L; long maxTicks2 = remainingTicks / 4L / 12L; if (swipe) { this.xPlayer = 0; this.yPlayer = 0; this.xMin = 0; this.yMin = 0; this.xMax = this.GridSize - 1; this.yMax = this.GridSize - 1; if (!threadSafeOnly) { WorkScheduler.FullCycle = true; } } if (!threadSafeOnly) { } for (int i = this.xMin; i <= this.xMax; i++) { for (int j = this.yMin; j <= this.yMax; j++) { WorkSchedulerBatch workSchedulerBatch = this.schedulers[this.xPlayer + i, this.yPlayer + j]; if (i > -2 && i < 1 && j > -2 && j < 1) { if (!threadSafeOnly) { if (workSchedulerBatch.LastNearRefreshFrame != this.currentFrame) { workSchedulerBatch.LastNearRefreshFrame = this.currentFrame; num += workSchedulerBatch.DoWork(maxTicks, false); } } else if (workSchedulerBatch.LastThreadRefreshFrame != this.currentThreadFrame) { workSchedulerBatch.LastThreadRefreshFrame = this.currentThreadFrame; workSchedulerBatch.DoThreadSafeWorkTryCatch(false); } } else if (!threadSafeOnly) { if (workSchedulerBatch.LastNearRefreshFrame != this.currentFrame && workSchedulerBatch.LastFarRefreshFrame != this.currentFrame) { workSchedulerBatch.LastFarRefreshFrame = this.currentFrame; num2 += workSchedulerBatch.DoWork(maxTicks2, false); } } else if (workSchedulerBatch.LastThreadRefreshFrame != this.currentThreadFrame) { workSchedulerBatch.LastThreadRefreshFrame = this.currentThreadFrame; workSchedulerBatch.DoThreadSafeWorkTryCatch(false); } } } if (!threadSafeOnly) { } }
private void Awake() { this.xOffset = base.transform.position.x; this.yOffset = base.transform.position.z; if (WorkScheduler.Instance == null) { WorkScheduler.Instance = this; } else if (WorkScheduler.Instance != this) { UnityEngine.Object.DestroyImmediate(base.gameObject); } this.schedulers = new WorkSchedulerBatch[this.GridSize, this.GridSize]; for (int i = 0; i < this.GridSize; i++) { for (int j = 0; j < this.GridSize; j++) { this.schedulers[i, j] = new WorkSchedulerBatch(); } } this.globalScheduler = new WorkSchedulerBatch(); if (Application.isPlaying && !this.CaveScene && base.gameObject) { base.gameObject.SetActive(false); } }