protected override void OnActivateTool()
    {
        lastDragCell = -1;
        if ((Object)visualizer != (Object)null)
        {
            ClearTilePreview();
            Object.Destroy(visualizer);
        }
        active = true;
        base.OnActivateTool();
        buildingOrientation = Orientation.Neutral;
        placementPivot      = def.placementPivot;
        Vector3    cursorPos       = PlayerController.GetCursorPos(KInputManager.GetMousePos());
        GameObject buildingPreview = def.BuildingPreview;
        Vector3    position        = cursorPos;

        Grid.SceneLayer sceneLayer = Grid.SceneLayer.Ore;
        int             gameLayer  = LayerMask.NameToLayer("Place");

        visualizer = GameUtil.KInstantiate(buildingPreview, position, sceneLayer, null, gameLayer);
        KBatchedAnimController component = visualizer.GetComponent <KBatchedAnimController>();

        if ((Object)component != (Object)null)
        {
            component.visibilityType = KAnimControllerBase.VisibilityType.Always;
            component.isMovable      = true;
            component.Offset         = def.GetVisualizerOffset();
            component.Offset        += def.placementPivot;
            component.name           = component.GetComponent <KPrefabID>().GetDebugName() + "_visualizer";
        }
        visualizer.SetActive(true);
        UpdateVis(cursorPos);
        BuildToolHoverTextCard component2 = GetComponent <BuildToolHoverTextCard>();

        component2.currentDef = def;
        ResourceRemainingDisplayScreen.instance.ActivateDisplay(visualizer);
        if ((Object)component == (Object)null)
        {
            visualizer.SetLayerRecursively(LayerMask.NameToLayer("Place"));
        }
        else
        {
            component.SetLayer(LayerMask.NameToLayer("Place"));
        }
        GridCompositor.Instance.ToggleMajor(true);
    }