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;
            }
        }
    }
Example #2
0
    public void CreateItem()
    {
        //Arrange
        BIWCatalogManager.Init();
        BuilderInWorldTestHelper.CreateTestCatalogLocalSingleObject();
        CatalogItem item = DataStore.i.builderInWorld.catalogItemDict.GetValues()[0];

        //Act
        biwCreatorController.CreateCatalogItem(item);

        //Assert
        foreach (DCLBuilderInWorldEntity entity in entityHandler.GetAllEntitiesFromCurrentScene())
        {
            Assert.IsTrue(entity.GetCatalogItemAssociated().id == item.id);
        }
    }
Example #3
0
    public void CreateFloor()
    {
        //Arrange
        BIWCatalogManager.Init();
        BuilderInWorldTestHelper.CreateTestCatalogLocalMultipleFloorObjects();
        CatalogItem floorItem = DataStore.i.builderInWorld.catalogItemDict.GetValues()[0];

        controller.InitGameObjects();
        controller.FindSceneToEdit();
        controller.InitControllers();

        biwCreatorController.EnterEditMode(scene);
        biwFloorHandler.EnterEditMode(scene);

        //Act
        biwFloorHandler.CreateFloor(floorItem);

        //Assert
        foreach (DCLBuilderInWorldEntity entity in entityHandler.GetAllEntitiesFromCurrentScene())
        {
            if (entity.isFloor)
            {
                Assert.IsTrue(biwFloorHandler.ExistsFloorPlaceHolderForEntity(entity.rootEntity.entityId));
                Assert.AreEqual(entity.GetCatalogItemAssociated().id, floorItem.id);
                break;
            }
        }

        foreach (DCLBuilderInWorldEntity entity in entityHandler.GetAllEntitiesFromCurrentScene())
        {
            if (entity.isFloor)
            {
                if (!entity.rootEntity.TryGetSharedComponent(CLASS_ID.GLTF_SHAPE, out ISharedComponent component))
                {
                    Assert.Fail("Floor doesn't contains a GLTFShape!");
                }

                entity.rootEntity.OnShapeUpdated?.Invoke(entity.rootEntity);
                Assert.IsFalse(biwFloorHandler.ExistsFloorPlaceHolderForEntity(entity.rootEntity.entityId));
                break;
            }
        }
    }
Example #4
0
 public CatalogItem FindCurrentFloorCatalogItem()
 {
     foreach (DCLBuilderInWorldEntity entity in builderInWorldEntityHandler.GetAllEntitiesFromCurrentScene())
     {
         if (entity.isFloor)
         {
             return(entity.GetCatalogItemAssociated());
         }
     }
     return(null);
 }
Example #5
0
    protected override IEnumerator SetUp()
    {
        yield return(base.SetUp());

        BuilderInWorldController controller = Resources.FindObjectsOfTypeAll <BuilderInWorldController>()[0];

        entityHandler = controller.builderInWorldEntityHandler;
        entityHandler.Init();

        TestHelpers.CreateSceneEntity(scene, ENTITY_ID);
        entityHandler.EnterEditMode(scene);
        entity = entityHandler.GetAllEntitiesFromCurrentScene().FirstOrDefault();
    }
Example #6
0
    public void EntitySelectionOperations()
    {
        DCLBuilderInWorldEntity createdEntity = entityHandler.CreateEmptyEntity(scene, Vector3.zero, Vector3.zero);

        int entityAmount = entityHandler.GetAllEntitiesFromCurrentScene().Count;

        entityHandler.SelectEntity(createdEntity);
        entityHandler.DuplicateSelectedEntities();

        Assert.Greater(entityHandler.GetAllEntitiesFromCurrentScene().Count, entityAmount);


        entityAmount = entityHandler.GetAllEntitiesFromCurrentScene().Count;
        entityHandler.DeleteSelectedEntities();

        Assert.Less(entityHandler.GetAllEntitiesFromCurrentScene().Count, entityAmount);
    }
Example #7
0
    void FillVoxels(Vector3Int firstPosition, Vector3Int lastPosition)
    {
        int xDifference = Mathf.Abs(firstPosition.x - lastPosition.x);
        int yDifference = Mathf.Abs(firstPosition.y - lastPosition.y);
        int zDifference = Mathf.Abs(firstPosition.z - lastPosition.z);

        List <Vector3Int> mustContainVoxelList       = new List <Vector3Int>();
        List <DCLBuilderInWorldEntity> voxelEntities = builderInWorldEntityHandler.GetAllVoxelsEntities();
        List <DCLBuilderInWorldEntity> allEntities   = builderInWorldEntityHandler.GetAllEntitiesFromCurrentScene();

        for (int x = 0; x <= xDifference; x++)
        {
            int contX = x;
            if (firstPosition.x > lastPosition.x)
            {
                contX = -contX;
            }

            for (int y = 0; y <= yDifference; y++)
            {
                int contY = y;
                if (firstPosition.y > lastPosition.y)
                {
                    contY = -contY;
                }

                for (int z = 0; z <= zDifference; z++)
                {
                    int contZ = z;
                    if (firstPosition.z > lastPosition.z)
                    {
                        contZ = -contZ;
                    }

                    Vector3Int positionOfVoxel = new Vector3Int(firstPosition.x + contX, firstPosition.y + contY, firstPosition.z + contZ);
                    if (positionOfVoxel == firstPosition)
                    {
                        continue;
                    }
                    if (ExistVoxelAtPosition(positionOfVoxel, voxelEntities))
                    {
                        continue;
                    }
                    CreateVoxel(positionOfVoxel);
                    mustContainVoxelList.Add(positionOfVoxel);
                }
            }
        }


        List <Vector3Int> voxelToRemove = new List <Vector3Int>();

        foreach (Vector3Int position in createdVoxels.Keys)
        {
            if (!mustContainVoxelList.Contains(position))
            {
                voxelToRemove.Add(position);
            }
        }

        foreach (Vector3Int vector in voxelToRemove)
        {
            Destroy(createdVoxels[vector].gameObject);
            createdVoxels.Remove(vector);
        }
        foreach (VoxelPrefab keyValuePair in createdVoxels.Values)
        {
            if (IsVoxelAtValidPoint(keyValuePair, allEntities))
            {
                keyValuePair.SetAvailability(true);
            }
            else
            {
                keyValuePair.SetAvailability(false);
            }
        }
    }