public void Go(bool isBusy) { GameObject[] logLocations = null; if (checkedForLogs == false) //Look for logs and chop wood only if none are found. { logLocations = GameObject.FindGameObjectsWithTag("Wood"); } if (logLocations.Length != 0) { Debug.Log("Found some"); } else { if (stats.jobInProgress != "Tree") { jobObject = findClosest.Go("Tree"); foreach (Transform child in jobObject.transform) { jobLocation = child.transform.position; } } stats.jobInProgress = "Tree"; if (transform.position != jobLocation) { moveTo.Go(jobLocation, jobObject.transform.position, stats.speed, stats.turnSpeed); stats.moving = true; } else { stats.moving = false; if (jobObject != null) { if (isBusy == false) { treeCon = jobObject.GetComponent <TreeController>(); StartCoroutine(Timber()); } } else { stats.jobInProgress = ""; } } } }
//May at some point split ManageStats out to its own class. private void ManageStats(string stat) { if (jobInProgress != stat) { jobObject = findClosest.Go(stat); jobLocation = jobObject.transform.position; Debug.Log("Citizen: Found Job(" + jobObject.name + ") at location " + jobLocation); jobInProgress = stat; } //PERFORMANCE - Must prevent list generation for same type of job while on that job. if (transform.position != jobLocation) { moveTo.Go(jobLocation, jobLocation, speed, turnSpeed); moving = true; } else { moving = false; restoreStats.Go(isBusy, stat); } }