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 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);
        }
    }