public void DuplicateSelectedEntities() { BuildInWorldCompleteAction buildAction = new BuildInWorldCompleteAction(); buildAction.actionType = BuildInWorldCompleteAction.ActionType.CREATE; List <BuilderInWorldEntityAction> entityActionList = new List <BuilderInWorldEntityAction>(); List <DCLBuilderInWorldEntity> entitiesToDuplicate = new List <DCLBuilderInWorldEntity>(selectedEntities); DeselectEntities(); foreach (DCLBuilderInWorldEntity entityToDuplicate in entitiesToDuplicate) { if (entityToDuplicate.isNFT) { continue; } var entityDuplicated = DuplicateEntity(entityToDuplicate); BuilderInWorldEntityAction builderInWorldEntityAction = new BuilderInWorldEntityAction(entityDuplicated.rootEntity, entityDuplicated.rootEntity.entityId, BuilderInWorldUtils.ConvertEntityToJSON(entityDuplicated.rootEntity)); entityActionList.Add(builderInWorldEntityAction); SelectEntity(entityDuplicated); } currentActiveMode?.SetDuplicationOffset(duplicateOffset); buildAction.CreateActionType(entityActionList, BuildInWorldCompleteAction.ActionType.CREATE); actionController.AddAction(buildAction); }
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); } }
public void DuplicateSelectedEntities() { BuildInWorldCompleteAction buildAction = new BuildInWorldCompleteAction(); buildAction.actionType = BuildInWorldCompleteAction.ActionType.CREATE; List <BuilderInWorldEntityAction> entityActionList = new List <BuilderInWorldEntityAction>(); int amount = selectedEntities.Count; for (int i = 0; i < amount; i++) { if (selectedEntities[i].isNFT) { continue; } DecentralandEntity entityDuplicated = DuplicateEntity(selectedEntities[i]); BuilderInWorldEntityAction builderInWorldEntityAction = new BuilderInWorldEntityAction(entityDuplicated, entityDuplicated.entityId, BuilderInWorldUtils.ConvertEntityToJSON(entityDuplicated)); entityActionList.Add(builderInWorldEntityAction); } currentActiveMode?.SetDuplicationOffset(duplicateOffset); Cursor.SetCursor(duplicateCursorTexture, Vector2.zero, CursorMode.Auto); buildAction.CreateActionType(entityActionList, BuildInWorldCompleteAction.ActionType.CREATE); actionController.AddAction(buildAction); }
public void GoToAction(BuildInWorldCompleteAction action) { int index = actionsMade.IndexOf(action); int stepsAmount = currentUndoStepIndex - index; for (int i = 0; i <= Mathf.Abs(stepsAmount); i++) { if (stepsAmount > 0) { UndoCurrentAction(); if (currentUndoStepIndex > 0) { currentUndoStepIndex--; } } else { RedoCurrentAction(); if (currentUndoStepIndex + 1 < actionsMade.Count) { currentUndoStepIndex++; } } } }
public void SetContent(BuildInWorldCompleteAction action) { this.action = action; switch (this.action.actionType) { case BuildInWorldCompleteAction.ActionType.MOVE: actionImg.sprite = moveSprite; break; case BuildInWorldCompleteAction.ActionType.ROTATE: actionImg.sprite = rotateSprite; break; case BuildInWorldCompleteAction.ActionType.SCALE: actionImg.sprite = scaleSprite; break; case BuildInWorldCompleteAction.ActionType.CREATE: actionImg.sprite = createdSprite; break; default: actionImg.enabled = false; break; } actionTitle.text = this.action.actionType.ToString().Replace("_", " "); RefreshIsDone(); }
public void CreateActionEntityCreated(DecentralandEntity entity) { BuilderInWorldEntityAction builderInWorldEntityAction = new BuilderInWorldEntityAction(entity, entity.entityId, BuilderInWorldUtils.ConvertEntityToJSON(entity)); BuildInWorldCompleteAction buildAction = new BuildInWorldCompleteAction(); buildAction.CreateActionType(builderInWorldEntityAction, ActionType.CREATE); AddAction(buildAction); }
public void UndoRedoChangeFloorAction() { BIWCatalogManager.Init(); BuilderInWorldTestHelper.CreateTestCatalogLocalMultipleFloorObjects(); CatalogItem oldFloor = DataStore.i.builderInWorld.catalogItemDict.GetValues()[0]; CatalogItem newFloor = DataStore.i.builderInWorld.catalogItemDict.GetValues()[1]; BuildInWorldCompleteAction buildModeAction = new BuildInWorldCompleteAction(); controller.InitGameObjects(); controller.FindSceneToEdit(); controller.InitControllers(); biwCreatorController.EnterEditMode(scene); biwFloorHandler.EnterEditMode(scene); biwFloorHandler.CreateFloor(oldFloor); biwFloorHandler.ChangeFloor(newFloor); buildModeAction.CreateChangeFloorAction(oldFloor, newFloor); actionController.AddAction(buildModeAction); foreach (DCLBuilderInWorldEntity entity in entityHandler.GetAllEntitiesFromCurrentScene()) { if (entity.isFloor) { Assert.AreEqual(entity.GetCatalogItemAssociated().id, newFloor.id); break; } } actionController.TryToUndoAction(); foreach (DCLBuilderInWorldEntity entity in entityHandler.GetAllEntitiesFromCurrentScene()) { if (entity.isFloor) { Assert.AreEqual(entity.GetCatalogItemAssociated().id, oldFloor.id); break; } } actionController.TryToRedoAction(); foreach (DCLBuilderInWorldEntity entity in entityHandler.GetAllEntitiesFromCurrentScene()) { if (entity.isFloor) { Assert.AreEqual(entity.GetCatalogItemAssociated().id, newFloor.id); break; } } }
protected void ActionFinish(BuildInWorldCompleteAction.ActionType type) { if (actionList.Count > 0 && selectedEntities.Count > 0) { BuildInWorldCompleteAction buildModeAction = new BuildInWorldCompleteAction(); buildModeAction.actionType = type; buildModeAction.CreateActionType(actionList, type); OnActionGenerated?.Invoke(buildModeAction); actionList = new List <BuilderInWorldEntityAction>(); } }
public void CreateActionEntityDeleted(List <DCLBuilderInWorldEntity> entityList) { BuildInWorldCompleteAction buildAction = new BuildInWorldCompleteAction(); List <BuilderInWorldEntityAction> entityActionList = new List <BuilderInWorldEntityAction>(); foreach (DCLBuilderInWorldEntity entity in entityList) { BuilderInWorldEntityAction builderInWorldEntityAction = new BuilderInWorldEntityAction(entity.rootEntity.entityId, BuilderInWorldUtils.ConvertEntityToJSON(entity.rootEntity), entity.rootEntity.entityId); entityActionList.Add(builderInWorldEntityAction); } buildAction.CreateActionType(entityActionList, BuildInWorldCompleteAction.ActionType.DELETE); AddAction(buildAction); }
public void ChangeFloor(CatalogItem newFloorObject) { CatalogItem lastFloor = lastFloorCalalogItemUsed; if (lastFloor == null) { lastFloor = FindCurrentFloorCatalogItem(); } builderInWorldEntityHandler.DeleteFloorEntities(); CreateFloor(newFloorObject); BuildInWorldCompleteAction buildAction = new BuildInWorldCompleteAction(); buildAction.CreateChangeFloorAction(lastFloor, newFloorObject); actionController.AddAction(buildAction); }
void OnSceneObjectSelected(SceneObject sceneObject) { if (IsSceneObjectFloor(sceneObject)) { builderInWorldEntityHandler.DeleteFloorEntities(); SceneObject lastFloor = lastFloorSceneObjectUsed; CreateFloor(sceneObject); BuildInWorldCompleteAction buildAction = new BuildInWorldCompleteAction(); buildAction.CreateChangeFloorAction(lastFloor, sceneObject); actionController.AddAction(buildAction); } else { CreateSceneObject(sceneObject); } }
public void AddAction(BuildInWorldCompleteAction action) { if (currentRedoStepIndex < actionsMade.Count - 1) { actionsMade.RemoveRange(currentRedoStepIndex, actionsMade.Count - currentRedoStepIndex); } else if (actionsMade.Count > 0 && !actionsMade[currentRedoStepIndex].isDone) { actionsMade.RemoveAt(actionsMade.Count - 1); } actionsMade.Add(action); currentUndoStepIndex = actionsMade.Count - 1; currentRedoStepIndex = actionsMade.Count - 1; if (VERBOSE) { Debug.Log("Redo: Current actions " + actionsMade.Count + " Current undo index " + currentUndoStepIndex + " Current redo index " + currentRedoStepIndex); } action.OnApplyValue += ApplyAction; }
public void UndoRedoScaleAction() { BuildInWorldCompleteAction buildModeAction = new BuildInWorldCompleteAction(); Vector3 oldScale = scene.entities[ENTITY_ID].gameObject.transform.localScale; Vector3 newScale = new Vector3(5, 5, 5); BuilderInWorldEntityAction entityAction = new BuilderInWorldEntityAction(ENTITY_ID); entityAction.oldValue = oldScale; entityAction.newValue = newScale; buildModeAction.CreateActionType(entityAction, BuildInWorldCompleteAction.ActionType.SCALE); scene.entities[ENTITY_ID].gameObject.transform.localScale = newScale; actionController.AddAction(buildModeAction); actionController.TryToUndoAction(); Assert.IsTrue(scene.entities[ENTITY_ID].gameObject.transform.localScale == oldScale); actionController.TryToRedoAction(); Assert.IsTrue(scene.entities[ENTITY_ID].gameObject.transform.localScale == newScale); }
public void UndoRedoRotateAction() { BuildInWorldCompleteAction buildModeAction = new BuildInWorldCompleteAction(); Vector3 oldRotation = scene.entities[ENTITY_ID].gameObject.transform.rotation.eulerAngles; Vector3 newRotation = new Vector3(5, 5, 5); BuilderInWorldEntityAction entityAction = new BuilderInWorldEntityAction(ENTITY_ID); entityAction.oldValue = oldRotation; entityAction.newValue = newRotation; buildModeAction.CreateActionType(entityAction, BuildInWorldCompleteAction.ActionType.ROTATE); scene.entities[ENTITY_ID].gameObject.transform.rotation = Quaternion.Euler(newRotation); actionController.AddAction(buildModeAction); actionController.TryToUndoAction(); Assert.IsTrue(scene.entities[ENTITY_ID].gameObject.transform.rotation.eulerAngles == oldRotation); actionController.TryToRedoAction(); Assert.IsTrue(scene.entities[ENTITY_ID].gameObject.transform.rotation.eulerAngles == newRotation); }
public void DuplicateSelectedEntities() { foreach (DCLBuilderInWorldEntity entity in selectedEntities) { if (!DCL.Environment.i.world.sceneBoundsChecker.IsEntityInsideSceneBoundaries(entity.rootEntity)) { return; } } BuildInWorldCompleteAction buildAction = new BuildInWorldCompleteAction(); buildAction.actionType = BuildInWorldCompleteAction.ActionType.CREATE; List <BuilderInWorldEntityAction> entityActionList = new List <BuilderInWorldEntityAction>(); int amount = selectedEntities.Count; for (int i = 0; i < amount; i++) { if (selectedEntities[i].isNFT) { continue; } DecentralandEntity entityDuplicated = DuplicateEntity(selectedEntities[i]); BuilderInWorldEntityAction builderInWorldEntityAction = new BuilderInWorldEntityAction(entityDuplicated, entityDuplicated.entityId, BuilderInWorldUtils.ConvertEntityToJSON(entityDuplicated)); entityActionList.Add(builderInWorldEntityAction); } currentActiveMode.SetDuplicationOffset(duplicateOffset); Cursor.SetCursor(duplicateCursorTexture, Vector2.zero, CursorMode.Auto); buildAction.CreateActionType(entityActionList, BuildInWorldCompleteAction.ActionType.CREATE); actionController.AddAction(buildAction); }