private void Update() { if (!freezer.IsInteractionFreeze && Input.GetMouseButtonDown((int)MouseButton.RightMouse)) { DeactivateBuilder(); } if (!isActive) { return; } if (!freezer.IsInteractionFreeze && Utils.IntersectionMouseRayWithXOZPlane(mainCamera, out Vector3 enter)) { if (!currentBuilding) { UpdateCurrentBuilding(); } if (currentBuilding) { Vector3 hexCenter = worldMap.GetHexCenterPosition(enter); bool isHexContainsResource = worldMap.IsHexContainsResource(enter); bool isValidPlace = worldMap.IsHexAvailableForBuilding(enter); isValidPlace &= isCurrentBuildResourceExtractor == isHexContainsResource; isValidPlace &= worldMap.Distance(worldMap.GetPositoinByColonyMainBase(worldMap.colonyMainBaseArray[0]), hexCenter) <= colonyRaduis; currentBuilding.transform.position = hexCenter + Vector3.up * preViewOffset; currentBuildHelper.SetMaterialColor(isValidPlace ? validPositionColor : invalidPositionColor); if (isValidPlace && Input.GetMouseButtonDown((int)MouseButton.LeftMouse)) { AddCurrentBuildingToMap(); } } } else { Destroy(currentBuilding); } }