private static void GotoMinerals(List <Entity> builders) { HashSet <Point> positions = GetMiningPositions(); foreach (Entity builder in builders) { PointTarget target = Helper.GetNearest(builder.Position, positions); if (target == null) { continue; } Point targetPosition = target.Target; positions.Remove(targetPosition); MoveHelper.Move(builder, targetPosition); } }
/// <summary> /// Makes the target for current selected units from the point under the cursor. /// </summary> private void MakeTarget() { if (!selector.selectedControllableUnits.Any()) { return; } var cursor = selector.InputProvider.CursorPosition; var ray = selector.CameraMain.Camera.ScreenPointToRay(cursor); ITarget target; if (Physics.Raycast(ray, out RaycastHit hit)) { target = hit.collider.GetComponent <ITarget>(); } else { var point = selector.CameraMain.Camera.ScreenToWorldPoint(new Vector3(cursor.x, cursor.y, Camera.main.transform.position.y)); target = new PointTarget(point); selector.CreatePositionMarker(point); } selector.SetTargetForSelectedControllableUnits(target); }