private void RightMouse() { Ray r = _camera.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(r, out var hit)) { if (hit.collider.CompareTag("Ground")) { foreach (var selectable in selectables.Where(selectable => selectable.IsSelected)) { selectable.SendMessage(nameof(IMovable.SetDestination), hit.point, SendMessageOptions.DontRequireReceiver); } } foreach (var selectable in selectables.Where(selectable => selectable.IsSelected)) { var workerManager = selectable.GetComponent <WorkerUnitManager>(); if (workerManager) { workerManager.ClearTasks(); var rightClickedSelectable = hit.collider.GetComponentInParent <Selectable>(); if (rightClickedSelectable) { var buildingInfo = rightClickedSelectable.GetComponentInParent <BuildingInfo>(); if (buildingInfo) { workerManager.ReplaceQueueWithTask(WorkerUnitTask.Create(buildingInfo)); } } } } } }
private void PlaceBuilding() { if (!_ghostBuildingManager.canBePlaced) { return; } workerUnitManager.AddTask(WorkerUnitTask.Create(_buildingInfo)); StopPlacing(false); }