protected void StartCreateUnitJob() { UnitQueueEntry dequeuedEntry = unitQueue.Dequeue(); currentUnitJob = new CreateUnitJob(this, dequeuedEntry.UnitToConvert, dequeuedEntry.DestinationUnit, Owner, true); if(dequeuedEntry.UnitToConvert != null) { currentUnitJob.AssignNextJob(dequeuedEntry.UnitToConvert, false); } }
// Complete a unit, instantiating it at a proper location, and giving it a rally point if necessary protected void CompleteUnitCreation() { GameObject newUnit; float distance = collider.bounds.size.magnitude + currentUnitJob.DestinationUnit.collider.bounds.size.magnitude; if(currentUnitJob.IsConversion) { newUnit = GameUtil.InstantiateConvertedControllable(currentUnitJob.Assignee, currentUnitJob.DestinationUnit.GetComponent<Controllable>(), Owner, transform.position + (transform.right * distance)); } else { newUnit = GameUtil.InstantiateControllable(currentUnitJob.DestinationUnit.GetComponent<Controllable>(), Owner, transform.position + (transform.right * distance)); } if(rallyPoint != null) { newUnit.GetComponent<Controllable>().AddTask(new MoveTask(newUnit.GetComponent<MoveTaskScript>(), rallyPoint), false); } currentUnitJob.RemoveAssignee(currentUnitJob.Assignee); currentUnitJob = null; }