public void DuplicateSelectedEntities() { BIWCompleteAction buildAction = new BIWCompleteAction(); buildAction.actionType = BIWCompleteAction.ActionType.CREATE; List <BIWEntityAction> entityActionList = new List <BIWEntityAction>(); List <BIWEntity> entitiesToDuplicate = new List <BIWEntity>(selectedEntities); DeselectEntities(); foreach (BIWEntity entityToDuplicate in entitiesToDuplicate) { if (entityToDuplicate.isNFT) { continue; } var entityDuplicated = DuplicateEntity(entityToDuplicate); BIWEntityAction biwEntityAction = new BIWEntityAction(entityDuplicated.rootEntity, entityDuplicated.rootEntity.entityId, BIWUtils.ConvertEntityToJSON(entityDuplicated.rootEntity)); entityActionList.Add(biwEntityAction); SelectEntity(entityDuplicated); } currentActiveMode?.SetDuplicationOffset(DUPLICATE_OFFSET); buildAction.CreateActionType(entityActionList, BIWCompleteAction.ActionType.CREATE); actionController.AddAction(buildAction); }
public void CreateActionEntityCreated(IDCLEntity entity) { BIWEntityAction biwEntityAction = new BIWEntityAction(entity, entity.entityId, BIWUtils.ConvertEntityToJSON(entity)); BIWCompleteAction buildAction = new BIWCompleteAction(); buildAction.CreateActionType(biwEntityAction, ActionType.CREATE); AddAction(buildAction); }
protected void ActionFinish(BIWCompleteAction.ActionType type) { if (actionList.Count > 0 && selectedEntities.Count > 0) { BIWCompleteAction buildModeAction = new BIWCompleteAction(); buildModeAction.actionType = type; buildModeAction.CreateActionType(actionList, type); OnActionGenerated?.Invoke(buildModeAction); actionList = new List <BIWEntityAction>(); } }
public void CreateActionEntityDeleted(List <BIWEntity> entityList) { BIWCompleteAction buildAction = new BIWCompleteAction(); List <BIWEntityAction> entityActionList = new List <BIWEntityAction>(); foreach (BIWEntity entity in entityList) { BIWEntityAction biwEntityAction = new BIWEntityAction(entity.rootEntity.entityId, BIWUtils.ConvertEntityToJSON(entity.rootEntity), entity.rootEntity.entityId); entityActionList.Add(biwEntityAction); } buildAction.CreateActionType(entityActionList, BIWCompleteAction.ActionType.DELETE); AddAction(buildAction); }
public void UndoRedoScaleAction() { BIWCompleteAction buildModeAction = new BIWCompleteAction(); Vector3 oldScale = scene.entities[ENTITY_ID].gameObject.transform.localScale; Vector3 newScale = new Vector3(5, 5, 5); BIWEntityAction entityAction = new BIWEntityAction(ENTITY_ID); entityAction.oldValue = oldScale; entityAction.newValue = newScale; buildModeAction.CreateActionType(entityAction, BIWCompleteAction.ActionType.SCALE); scene.entities[ENTITY_ID].gameObject.transform.localScale = newScale; biwActionController.AddAction(buildModeAction); biwActionController.TryToUndoAction(); Assert.IsTrue(scene.entities[ENTITY_ID].gameObject.transform.localScale == oldScale); biwActionController.TryToRedoAction(); Assert.IsTrue(scene.entities[ENTITY_ID].gameObject.transform.localScale == newScale); }
public void UndoRedoRotateAction() { BIWCompleteAction buildModeAction = new BIWCompleteAction(); Vector3 oldRotation = scene.entities[ENTITY_ID].gameObject.transform.rotation.eulerAngles; Vector3 newRotation = new Vector3(5, 5, 5); BIWEntityAction entityAction = new BIWEntityAction(ENTITY_ID); entityAction.oldValue = oldRotation; entityAction.newValue = newRotation; buildModeAction.CreateActionType(entityAction, BIWCompleteAction.ActionType.ROTATE); scene.entities[ENTITY_ID].gameObject.transform.rotation = Quaternion.Euler(newRotation); biwActionController.AddAction(buildModeAction); biwActionController.TryToUndoAction(); Assert.IsTrue(scene.entities[ENTITY_ID].gameObject.transform.rotation.eulerAngles == oldRotation); biwActionController.TryToRedoAction(); Assert.IsTrue(scene.entities[ENTITY_ID].gameObject.transform.rotation.eulerAngles == newRotation); }
public void UndoRedoMoveAction() { BIWCompleteAction buildModeAction = new BIWCompleteAction(); Vector3 oldPosition = scene.entities[ENTITY_ID].gameObject.transform.position; Vector3 newPosition = new Vector3(5, 5, 5); BIWEntityAction entityAction = new BIWEntityAction(ENTITY_ID); entityAction.oldValue = oldPosition; entityAction.newValue = newPosition; buildModeAction.CreateActionType(entityAction, BIWCompleteAction.ActionType.MOVE); scene.entities[ENTITY_ID].gameObject.transform.position = newPosition; biwActionController.AddAction(buildModeAction); biwActionController.TryToUndoAction(); Assert.IsTrue(scene.entities[ENTITY_ID].gameObject.transform.position == oldPosition); biwActionController.TryToRedoAction(); Assert.IsTrue(scene.entities[ENTITY_ID].gameObject.transform.position == newPosition); }
private void MouseUp(int buttonID, Vector3 position) { if (!mousePressed || buttonID != 0) { return; } if (isCreatingMultipleVoxels) { lastVoxelCreated.rootEntity.transform.SetParent(null); bool canVoxelsBeCreated = true; foreach (VoxelPrefab voxel in createdVoxels.Values) { if (!voxel.IsAvailable()) { canVoxelsBeCreated = false; break; } } BIWCompleteAction buildAction = new BIWCompleteAction(); buildAction.actionType = BIWCompleteAction.ActionType.CREATE; List <BIWEntityAction> entityActionList = new List <BIWEntityAction>(); foreach (Vector3Int voxelPosition in createdVoxels.Keys) { if (canVoxelsBeCreated) { IDCLEntity entity = biwEntityHandler.DuplicateEntity(lastVoxelCreated).rootEntity; entity.gameObject.tag = BIWSettings.VOXEL_TAG; entity.gameObject.transform.position = voxelPosition; BIWEntityAction biwEntityAction = new BIWEntityAction(entity, entity.entityId, BIWUtils.ConvertEntityToJSON(entity)); entityActionList.Add(biwEntityAction); } GameObject.Destroy(createdVoxels[voxelPosition].gameObject); } if (!canVoxelsBeCreated) { biwEntityHandler.DeleteEntity(lastVoxelCreated); } else { buildAction.CreateActionType(entityActionList, BIWCompleteAction.ActionType.CREATE); biwActionController.AddAction(buildAction); } createdVoxels.Clear(); biwEntityHandler.DeselectEntities(); lastVoxelCreated = null; isCreatingMultipleVoxels = false; mousePressed = false; freeCameraMovement.SetCameraCanMove(true); } }