Esempio n. 1
0
 public void EntityClicked(DCLBuilderInWorldEntity entityToSelect)
 {
     if (entityToSelect != null)
     {
         if (selectedEntities.Count <= 0)
         {
             ChangeEntitySelectStatus(entityToSelect);
         }
         else
         {
             if (!isMultiSelectionActive)
             {
                 DeselectEntities();
             }
             else
             {
                 ChangeEntitySelectStatus(entityToSelect);
             }
         }
     }
     else if (!isMultiSelectionActive)
     {
         DeselectEntities();
     }
 }
Esempio n. 2
0
    public void SetEntity(DCLBuilderInWorldEntity entity, ParcelScene currentScene)
    {
        EntityDeselected();
        entityInformationView.SetCurrentEntity(entity);

        if (entityInformationView.currentEntity != null)
        {
            entity.onStatusUpdate -= UpdateEntityName;
            entityInformationView.currentEntity.onStatusUpdate += UpdateEntityName;
        }

        parcelScene = currentScene;

        if (entity.HasSmartItemComponent())
        {
            if (entity.rootEntity.TryGetBaseComponent(CLASS_ID_COMPONENT.SMART_ITEM, out IEntityComponent baseComponent))
            {
                entityInformationView.smartItemList.SetSmartItemParameters(entity.GetSmartItemParameters(), ((SmartItemComponent)baseComponent).GetValues());
            }
        }
        else
        {
            entityInformationView.SetSmartItemListViewActive(false);
        }

        entityInformationView.SetEntityThumbnailEnable(false);
        CatalogItem entitySceneObject = entity.GetCatalogItemAssociated();

        GetThumbnail(entitySceneObject);
        UpdateLimitsInformation(entitySceneObject);
        UpdateEntityName(entityInformationView.currentEntity);
        UpdateInfo(entityInformationView.currentEntity);
    }
Esempio n. 3
0
    private void AddEntityNameComponent(CatalogItem catalogItem, DCLBuilderInWorldEntity entity)
    {
        DCLName name = (DCLName)sceneToEdit.SharedComponentCreate(Guid.NewGuid().ToString(), Convert.ToInt32(CLASS_ID.NAME));

        sceneToEdit.SharedComponentAttach(entity.rootEntity.entityId, name.id);
        builderInWorldEntityHandler.SetEntityName(entity, catalogItem.name);
    }
Esempio n. 4
0
        public void InvokeEntityActionCorrectly()
        {
            // Arrange
            DCLBuilderInWorldEntity testEntity = new GameObject("_DCLBuilderInWorldEntity").AddComponent <DCLBuilderInWorldEntity>();

            testEntity.entityUniqueId = "testId";
            EntityListAdapter testEntityListAdapter = new GameObject("_EntityListAdapter").AddComponent <EntityListAdapter>();

            testEntity.entityUniqueId = "testId";
            EntityAction            testEntityAction          = EntityAction.SHOW;
            DCLBuilderInWorldEntity returnedEntity            = null;
            EntityListAdapter       returnedEntityListAdapter = null;
            EntityAction            retournedEntityAction     = EntityAction.DELETE;

            inspectorView.OnEntityActionInvoked += (action, entityToApply, adapter) =>
            {
                retournedEntityAction     = action;
                returnedEntity            = entityToApply;
                returnedEntityListAdapter = adapter;
            };

            // Act
            inspectorView.EntityActionInvoked(testEntityAction, testEntity, testEntityListAdapter);

            // Assert
            Assert.AreEqual(testEntity.entityUniqueId, returnedEntity.entityUniqueId, "The entity does not match!!");
            Assert.AreEqual(testEntityListAdapter, returnedEntityListAdapter, "The entity list adapter does not match!!");
            Assert.AreEqual(testEntityAction, retournedEntityAction, "The entity action does not match!!");
        }
Esempio n. 5
0
    public void SetEntity(DCLBuilderInWorldEntity entity, ParcelScene currentScene)
    {
        if (currentEntity != null)
        {
            entity.onStatusUpdate -= UpdateEntityName;
        }

        currentEntity = entity;
        currentEntity.onStatusUpdate += UpdateEntityName;

        parcelScene = currentScene;

        if (entity.HasSmartItemComponent())
        {
            entity.rootEntity.TryGetBaseComponent(CLASS_ID_COMPONENT.SMART_ITEM, out BaseComponent baseComponent);
            smartItemListView.SetSmartItemParameters((SmartItemComponent)baseComponent);
        }
        else
        {
            smartItemListView.gameObject.SetActive(false);
        }

        entitytTumbailImg.enabled = false;

        SceneObject entitySceneObject = entity.GetSceneObjectAssociated();

        GetThumbnail(entitySceneObject);

        UpdateLimitsInformation(entitySceneObject);
        UpdateEntityName(currentEntity);
        UpdateInfo(currentEntity);
    }
Esempio n. 6
0
    public DCLBuilderInWorldEntity CreateCatalogItem(CatalogItem catalogItem, bool autoSelect = true, bool isFloor = false)
    {
        if (catalogItem.IsNFT() && BuilderInWorldNFTController.i.IsNFTInUse(catalogItem.id))
        {
            return(null);
        }

        IsInsideTheLimits(catalogItem);

        //Note (Adrian): This is a workaround until the mapping is handle by kernel
        AddSceneMappings(catalogItem);

        Vector3 startPosition   = biwModeController.GetModeCreationEntryPoint();
        Vector3 editionPosition = biwModeController.GetCurrentEditionPosition();

        DCLBuilderInWorldEntity entity = builderInWorldEntityHandler.CreateEmptyEntity(sceneToEdit, startPosition, editionPosition, false);

        entity.isFloor = isFloor;
        entity.SetRotation(Vector3.zero);

        if (!isFloor)
        {
            CreateLoadingObject(entity);
        }

        AddShape(catalogItem, entity);

        AddEntityNameComponent(catalogItem, entity);

        AddLockedComponent(entity);

        if (catalogItem.IsSmartItem())
        {
            AddSmartItemComponent(entity);
        }

        if (catalogItem.IsVoxel())
        {
            entity.isVoxel = true;
        }

        if (autoSelect)
        {
            builderInWorldEntityHandler.DeselectEntities();
            builderInWorldEntityHandler.Select(entity.rootEntity);
        }

        entity.gameObject.transform.eulerAngles = Vector3.zero;

        biwModeController.CreatedEntity(entity);

        lastCatalogItemCreated = catalogItem;

        entity.OnShapeFinishLoading += OnShapeLoadFinish;
        builderInWorldEntityHandler.EntityListChanged();
        builderInWorldEntityHandler.NotifyEntityIsCreated(entity.rootEntity);
        OnInputDone?.Invoke();
        OnSceneObjectPlaced?.Invoke();
        return(entity);
    }
        public void ChangeEntityNameCorrectly()
        {
            // Arrange
            string newEntityName = "Test name";
            DCLBuilderInWorldEntity testEntity = new GameObject("_DCLBuilderInWorldEntity").AddComponent <DCLBuilderInWorldEntity>();

            testEntity.entityUniqueId           = "testId";
            entityInformationView.currentEntity = testEntity;

            DCLBuilderInWorldEntity entity = null;
            string entityName = "";

            entityInformationView.OnNameChange += (changedEntity, name) =>
            {
                entity     = changedEntity;
                entityName = name;
            };

            // Act
            entityInformationView.ChangeEntityName(newEntityName);

            // Assert
            Assert.AreEqual(entityInformationView.currentEntity, entity, "The current entity does not mach!");
            Assert.AreEqual(newEntityName, entityName, "The entity name does not match!");
        }
    private void CheckOutline()
    {
        if (outlinerOptimizationCounter >= 10 && isOutlineCheckActive)
        {
            if (!BuilderInWorldUtils.IsPointerOverUIElement())
            {
                DCLBuilderInWorldEntity entity = GetEntityOnPointer();
                if (!isMultiSelectionActive)
                {
                    outlinerController.CancelAllOutlines();
                }
                else
                {
                    outlinerController.CancelUnselectedOutlines();
                }

                if (entity != null && !entity.IsSelected)
                {
                    outlinerController.OutlineEntity(entity);
                }
            }

            outlinerOptimizationCounter = 0;
        }
        else
        {
            outlinerOptimizationCounter++;
        }
    }
Esempio n. 9
0
    public void EntityDuplicate()
    {
        IDCLEntity duplicateEntity = entityHandler.DuplicateEntity(entity).rootEntity;
        DCLBuilderInWorldEntity convertedEntity = entityHandler.GetConvertedEntity(duplicateEntity);

        Assert.IsNotNull(convertedEntity);
    }
Esempio n. 10
0
    public void NftComponent()
    {
        CatalogItem catalogItem = DataStore.i.builderInWorld.catalogItemDict.GetValues()[0];



        DCLBuilderInWorldEntity biwEntity = Utils.GetOrCreateComponent <DCLBuilderInWorldEntity>(scene.entities[ENTITY_ID].gameObject);

        biwEntity.Init(scene.entities[ENTITY_ID], null);

        NFTShape nftShape = (NFTShape)scene.SharedComponentCreate(catalogItem.id, Convert.ToInt32(CLASS_ID.NFT_SHAPE));

        nftShape.model         = new NFTShape.Model();
        nftShape.model.color   = new Color(0.6404918f, 0.611472f, 0.8584906f);
        nftShape.model.src     = catalogItem.model;
        nftShape.model.assetId = catalogItem.id;

        scene.SharedComponentAttach(biwEntity.rootEntity.entityId, nftShape.id);

        Assert.IsTrue(biwEntity.IsEntityNFT());

        CatalogItem associatedCatalogItem = biwEntity.GetCatalogItemAssociated();

        Assert.IsTrue(associatedCatalogItem.IsNFT());
        Assert.AreEqual(associatedCatalogItem, catalogItem);
    }
Esempio n. 11
0
    public void DeleteEntity(DCLBuilderInWorldEntity entityToDelete, bool checkSelection = true)
    {
        if (entityToDelete.IsSelected && checkSelection)
        {
            DeselectEntity(entityToDelete);
        }

        if (selectedEntities.Contains(entityToDelete))
        {
            selectedEntities.Remove(entityToDelete);
        }

        string entityName = entityToDelete.GetDescriptiveName();

        if (entityNameList.Contains(entityName))
        {
            entityNameList.Remove(entityName);
        }

        RemoveConvertedEntity(entityToDelete.rootEntity);
        entityToDelete.rootEntity.OnRemoved -= RemoveConvertedEntity;
        entityToDelete.Delete();
        string idToRemove = entityToDelete.rootEntity.entityId;

        Destroy(entityToDelete);
        if (sceneToEdit.entities.ContainsKey(idToRemove))
        {
            sceneToEdit.RemoveEntity(idToRemove, true);
        }
        hudController?.RefreshCatalogAssetPack();
        EntityListChanged();
        builderInWorldBridge?.RemoveEntityOnKernel(idToRemove, sceneToEdit);
    }
        public void InvokeEntityActionCorrectly(EntityAction actionToInvoke)
        {
            // Arrange
            EntityAction            testAction     = actionToInvoke;
            DCLBuilderInWorldEntity testEntity     = new GameObject("_DCLBuilderInWorldEntity").AddComponent <DCLBuilderInWorldEntity>();
            DCLBuilderInWorldEntity returnedEntity = null;

            switch (actionToInvoke)
            {
            case EntityAction.SELECT:

                inspectorController.OnEntityClick += (entity) => { returnedEntity = entity; };
                break;

            case EntityAction.LOCK:

                inspectorController.OnEntityLock += (entity) => { returnedEntity = entity; };
                break;

            case EntityAction.DELETE:

                inspectorController.OnEntityDelete += (entity) => { returnedEntity = entity; };
                break;

            case EntityAction.SHOW:
                inspectorController.OnEntityChangeVisibility += (entity) => { returnedEntity = entity; };
                break;
            }

            // Act
            inspectorController.EntityActionInvoked(testAction, testEntity, null);

            // Assert
            Assert.AreEqual(testEntity, returnedEntity, "The entity does not match!");
        }
Esempio n. 13
0
    DCLBuilderInWorldEntity SetupEntityToEdit(IDCLEntity entity, bool hasBeenCreated = false)
    {
        if (!convertedEntities.ContainsKey(GetConvertedUniqueKeyForEntity(entity)))
        {
            DCLBuilderInWorldEntity entityToEdit = Utils.GetOrCreateComponent <DCLBuilderInWorldEntity>(entity.gameObject);
            entityToEdit.Init(entity, editMaterial);
            convertedEntities.Add(entityToEdit.entityUniqueId, entityToEdit);
            entity.OnRemoved  += RemoveConvertedEntity;
            entityToEdit.IsNew = hasBeenCreated;

            string entityName  = entityToEdit.GetDescriptiveName();
            var    catalogItem = entityToEdit.GetCatalogItemAssociated();

            if ((string.IsNullOrEmpty(entityName) || entityNameList.Contains(entityName)) && catalogItem != null)
            {
                entityName = GetNewNameForEntity(catalogItem);
                SetEntityName(entityToEdit, entityName);
            }
            else if (!string.IsNullOrEmpty(entityName) && !entityNameList.Contains(entityName))
            {
                entityNameList.Add(entityName);
            }

            return(entityToEdit);
        }
        else
        {
            return(convertedEntities[GetConvertedUniqueKeyForEntity(entity)]);
        }
    }
Esempio n. 14
0
    public DCLBuilderInWorldEntity CreateEmptyEntity(ParcelScene parcelScene, Vector3 entryPoint, Vector3 editionGOPosition, bool notifyEntityList = true)
    {
        IDCLEntity newEntity = parcelScene.CreateEntity(Guid.NewGuid().ToString());

        DCLTransform.model.position = WorldStateUtils.ConvertUnityToScenePosition(entryPoint, parcelScene);

        Vector3 pointToLookAt = Camera.main.transform.position;

        pointToLookAt.y = editionGOPosition.y;
        Quaternion lookOnLook = Quaternion.LookRotation(editionGOPosition - pointToLookAt);

        DCLTransform.model.rotation = lookOnLook;
        DCLTransform.model.scale    = newEntity.gameObject.transform.lossyScale;

        parcelScene.EntityComponentCreateOrUpdateWithModel(newEntity.entityId, CLASS_ID_COMPONENT.TRANSFORM, DCLTransform.model);

        DCLBuilderInWorldEntity convertedEntity = SetupEntityToEdit(newEntity, true);

        hudController?.UpdateSceneLimitInfo();

        if (notifyEntityList)
        {
            EntityListChanged();
        }
        return(convertedEntity);
    }
Esempio n. 15
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);
        }
    }
Esempio n. 16
0
    public void SetEntityName(DCLBuilderInWorldEntity entityToApply, string newName, bool sendUpdateToKernel = true)
    {
        string currentName = entityToApply.GetDescriptiveName();

        if (currentName == newName)
        {
            return;
        }

        if (entityNameList.Contains(newName))
        {
            newName = GetNewNameForEntity(newName);
        }

        if (entityNameList.Contains(currentName))
        {
            entityNameList.Remove(currentName);
        }

        entityToApply.SetDescriptiveName(newName);
        entityNameList.Add(newName);

        if (sendUpdateToKernel)
        {
            builderInWorldBridge?.ChangedEntityName(entityToApply, sceneToEdit);
        }
    }
Esempio n. 17
0
    public override void SelectedEntity(DCLBuilderInWorldEntity selectedEntity)
    {
        base.SelectedEntity(selectedEntity);

        List <EditableEntity> editableEntities = new List <EditableEntity>();

        foreach (DCLBuilderInWorldEntity entity in selectedEntities)
        {
            editableEntities.Add(entity);
        }

        gizmoManager.SetSelectedEntities(editionGO.transform, editableEntities);

        if (!isMultiSelectionActive && !selectedEntity.IsNew)
        {
            LookAtEntity(selectedEntity.rootEntity);
        }

        snapGO.transform.SetParent(null);
        if (selectedEntity.isVoxel && selectedEntities.Count == 0)
        {
            editionGO.transform.position = voxelController.ConverPositionToVoxelPosition(editionGO.transform.position);
        }
        UpdateActionsInteractable();
    }
Esempio n. 18
0
    public void DeselectEntity(DCLBuilderInWorldEntity entity)
    {
        if (!selectedEntities.Contains(entity))
        {
            return;
        }

        if (!DCL.Environment.i.world.sceneBoundsChecker.IsEntityInsideSceneBoundaries(entity.rootEntity))
        {
            DestroyLastCreatedEntities();
        }

        DCL.Environment.i.world.sceneBoundsChecker.EvaluateEntityPosition(entity.rootEntity);
        DCL.Environment.i.world.sceneBoundsChecker.RemoveEntityToBeChecked(entity.rootEntity);

        entity.Deselect();

        outlinerController.CancelEntityOutline(entity);
        selectedEntities.Remove(entity);
        currentActiveMode?.EntityDeselected(entity);
        if (selectedEntities.Count <= 0 &&
            hudController != null)
        {
            hudController.HideEntityInformation();
        }
    }
Esempio n. 19
0
    public void EntityDuplicate()
    {
        DecentralandEntity      duplicateEntity = entityHandler.DuplicateEntity(entity);
        DCLBuilderInWorldEntity convertedEntity = entityHandler.GetConvertedEntity(duplicateEntity);

        Assert.IsNotNull(convertedEntity);
    }
Esempio n. 20
0
    public bool SelectEntity(DCLBuilderInWorldEntity entityEditable)
    {
        if (entityEditable.IsLocked)
        {
            return(false);
        }

        if (entityEditable.IsSelected)
        {
            return(false);
        }

        entityEditable.Select();

        selectedEntities.Add(entityEditable);

        currentActiveMode?.SelectedEntity(entityEditable);

        if (HUDController.i.builderInWorldMainHud != null)
        {
            hudController.UpdateEntitiesSelection(selectedEntities.Count);
            hudController.ShowEntityInformation();
            hudController.EntityInformationSetEntity(entityEditable, sceneToEdit);
        }

        outlinerController.CancelAllOutlines();

        OnEntitySelected?.Invoke();

        return(true);
    }
Esempio n. 21
0
    private void CreateLoadingObject(DCLBuilderInWorldEntity entity)
    {
        entity.rootEntity.OnShapeUpdated += OnRealShapeLoaded;
        GameObject loadingPlaceHolder = GameObject.Instantiate(loadingObjectPrefab, entity.gameObject.transform);

        loadingGameObjects.Add(entity.rootEntity.entityId, loadingPlaceHolder);
        CoroutineStarter.Start(LoadingObjectTimeout(entity.rootEntity.entityId));
    }
Esempio n. 22
0
 public override void OnDeleteEntity(DCLBuilderInWorldEntity entity)
 {
     base.OnDeleteEntity(entity);
     if (selectedEntities.Count == 0)
     {
         gizmoManager.HideGizmo();
     }
 }
Esempio n. 23
0
 private void ChangeEntityVisibilityStatus(DCLBuilderInWorldEntity entityToApply)
 {
     entityToApply.ToggleShowStatus();
     if (!entityToApply.IsVisible && selectedEntities.Contains(entityToApply))
     {
         DeselectEntity(entityToApply);
     }
 }
Esempio n. 24
0
    public void EntityCreationDelete()
    {
        DCLBuilderInWorldEntity createdEntity = entityHandler.CreateEmptyEntity(scene, Vector3.zero, Vector3.zero);

        Assert.IsNotNull(createdEntity);
        Assert.AreEqual(entityHandler.GetAllEntitiesFromCurrentScene().Count, 2);

        entityHandler.DeleteEntity(createdEntity.rootEntity.entityId);
        Assert.AreEqual(entityHandler.GetAllEntitiesFromCurrentScene().Count, 1);
    }
Esempio n. 25
0
 void DeleteAdapter(DCLBuilderInWorldEntity entityToEdit)
 {
     if (this != null)
     {
         if (entityToEdit.entityUniqueId == currentEntity.entityUniqueId)
         {
             Destroy(gameObject);
         }
     }
 }
Esempio n. 26
0
    private void ChangeEntityLockStatus(DCLBuilderInWorldEntity entityToApply)
    {
        entityToApply.ToggleLockStatus();
        if (entityToApply.IsLocked && selectedEntities.Contains(entityToApply))
        {
            DeselectEntity(entityToApply);
        }

        builderInWorldBridge.ChangeEntityLockStatus(entityToApply, sceneToEdit);
    }
Esempio n. 27
0
 private void ChangeEntitySelectionFromList(DCLBuilderInWorldEntity entityToEdit)
 {
     if (!selectedEntities.Contains(entityToEdit))
     {
         SelectFromList(entityToEdit);
     }
     else
     {
         DeselectEntity(entityToEdit);
     }
 }
Esempio n. 28
0
 void ChangeEntitySelectStatus(DCLBuilderInWorldEntity entityCliked)
 {
     if (entityCliked.IsSelected)
     {
         DeselectEntity(entityCliked);
     }
     else
     {
         SelectEntity(entityCliked);
     }
 }
Esempio n. 29
0
    public void Select(IDCLEntity entity)
    {
        DCLBuilderInWorldEntity entityEditable = GetConvertedEntity(entity);

        if (entityEditable == null)
        {
            return;
        }

        SelectEntity(entityEditable);
    }
Esempio n. 30
0
    public DCLBuilderInWorldEntity DuplicateEntity(DCLBuilderInWorldEntity entityToDuplicate)
    {
        IDCLEntity entity = SceneUtils.DuplicateEntity(sceneToEdit, entityToDuplicate.rootEntity);

        BuilderInWorldUtils.CopyGameObjectStatus(entityToDuplicate.gameObject, entity.gameObject, false, false);
        DCLBuilderInWorldEntity convertedEntity = SetupEntityToEdit(entity);

        NotifyEntityIsCreated(entity);
        EntityListChanged();
        return(convertedEntity);
    }