Example #1
0
    private void MouseUp(int buttonID, Vector3 position)
    {
        if (!mousePressed || buttonID != 0)
        {
            return;
        }

        if (isCreatingMultipleVoxels)
        {
            lastVoxelCreated.transform.SetParent(null);
            bool canVoxelsBeCreated = true;

            foreach (VoxelPrefab voxel in createdVoxels.Values)
            {
                if (!voxel.IsAvailable())
                {
                    canVoxelsBeCreated = false;
                    break;
                }
            }

            BuildInWorldCompleteAction buildAction = new BuildInWorldCompleteAction();
            buildAction.actionType = BuildInWorldCompleteAction.ActionType.CREATE;

            List <BuilderInWorldEntityAction> entityActionList = new List <BuilderInWorldEntityAction>();

            foreach (Vector3Int voxelPosition in createdVoxels.Keys)
            {
                if (canVoxelsBeCreated)
                {
                    DecentralandEntity entity = builderInWorldEntityHandler.DuplicateEntity(lastVoxelCreated);
                    entity.gameObject.tag = BuilderInWorldSettings.VOXEL_TAG;
                    entity.gameObject.transform.position = voxelPosition;

                    BuilderInWorldEntityAction builderInWorldEntityAction = new BuilderInWorldEntityAction(entity, entity.entityId, BuilderInWorldUtils.ConvertEntityToJSON(entity));
                    entityActionList.Add(builderInWorldEntityAction);
                }
                Destroy(createdVoxels[voxelPosition].gameObject);
            }

            if (!canVoxelsBeCreated)
            {
                builderInWorldEntityHandler.DeleteEntity(lastVoxelCreated);
            }
            else
            {
                buildAction.CreateActionType(entityActionList, BuildInWorldCompleteAction.ActionType.CREATE);
                actionController.AddAction(buildAction);
            }

            createdVoxels.Clear();
            builderInWorldEntityHandler.DeselectEntities();

            lastVoxelCreated         = null;
            isCreatingMultipleVoxels = false;

            mousePressed = false;
            freeCameraMovement.SetCameraCanMove(true);
        }
    }
    void OnInputMouseDown(int buttonID, Vector3 position)
    {
        lastMousePosition = position;

        if (buttonID == 1)
        {
            mouseSecondaryBtnPressed = true;
            freeCameraController.StartDectectingMovement();
        }

        if (buttonID != 0)
        {
            return;
        }

        dragStartedPoint = raycastController.GetFloorPointAtMouse(position);

        if (isSnapActive)
        {
            dragStartedPoint.x = Mathf.Round(dragStartedPoint.x);
            dragStartedPoint.z = Mathf.Round(dragStartedPoint.z);
        }

        if (isPlacingNewObject)
        {
            return;
        }

        var entity = raycastController.GetEntityOnPointer();

        if ((entity == null ||
             (entity != null && !entity.IsSelected)) &&
            !BIWUtils.IsPointerOverMaskElement(BIWSettings.GIZMOS_LAYER))
        {
            isSquareMultiSelectionInputActive = true;
            outlinerController.SetOutlineCheckActive(false);
        }

        mouseMainBtnPressed = true;
        freeCameraController.SetCameraCanMove(false);
    }
Example #3
0
    void OnMouseDown(int buttonID, Vector3 position)
    {
        if (buttonID != 0)
        {
            return;
        }

        dragStartedPoint = GetFloorPointAtMouse(position);

        if (!squareMultiSelectionButtonPressed || isPlacingNewObject)
        {
            return;
        }

        isDoingSquareMultiSelection    = true;
        isTypeOfBoundSelectionSelected = false;
        isVoxelBoundMultiSelection     = false;
        lastMousePosition = position;
        mousePressed      = true;
        freeCameraController.SetCameraCanMove(false);
        outlinerController.SetOutlineCheckActive(false);
    }
Example #4
0
    void OnInputMouseDown(int buttonID, Vector3 position)
    {
        lastMousePosition = position;

        if (buttonID == 1)
        {
            mouseSecondaryBtnPressed = true;
            freeCameraController.StartDectectingMovement();
        }

        if (buttonID != 0)
        {
            return;
        }

        dragStartedPoint = GetFloorPointAtMouse(position);

        if (isPlacingNewObject)
        {
            return;
        }

        var entity = builderInWorldEntityHandler.GetEntityOnPointer();

        if ((entity == null ||
             (entity != null && !entity.IsSelected)) &&
            !BuilderInWorldUtils.IsPointerOverMaskElement(layerToStopClick))
        {
            isSquareMultiSelectionInputActive = true;
            isTypeOfBoundSelectionSelected    = false;
            isVoxelBoundMultiSelection        = false;
            outlinerController.SetOutlineCheckActive(false);
        }
        mouseMainBtnPressed = true;
        freeCameraController.SetCameraCanMove(false);
    }