示例#1
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);
    }
示例#2
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);
    }
示例#3
0
    public void SetContent(CatalogItem catalogItem)
    {
        this.catalogItem = catalogItem;

        if (favImg != null)
        {
            if (catalogItem.IsFavorite())
            {
                favImg.color = onFavoriteColor;
            }
            else
            {
                favImg.color = offFavoriteColor;
            }
        }

        smartItemGO.SetActive(catalogItem.IsSmartItem());

        GetThumbnail();

        lockedGO.gameObject.SetActive(false);

        if (catalogItem.IsNFT() && BuilderInWorldNFTController.i.IsNFTInUse(catalogItem.id))
        {
            lockedGO.gameObject.SetActive(true);
        }
    }
示例#4
0
    public BIWEntity CreateCatalogItem(CatalogItem catalogItem, Vector3 startPosition, bool autoSelect = true, bool isFloor = false, Action <IDCLEntity> onFloorLoadedAction = null)
    {
        if (catalogItem.IsNFT() && BIWNFTController.i.IsNFTInUse(catalogItem.id))
        {
            return(null);
        }

        IsInsideTheLimits(catalogItem);

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

        Vector3 editionPosition = modeController.GetCurrentEditionPosition();

        BIWEntity entity = entityHandler.CreateEmptyEntity(sceneToEdit, startPosition, editionPosition, false);

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

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

        entity.rootEntity.OnShapeUpdated += (entity) => onFloorLoadedAction?.Invoke(entity);
        AddShape(catalogItem, entity);

        AddEntityNameComponent(catalogItem, entity);

        AddLockedComponent(entity);

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

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

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

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

        modeController.CreatedEntity(entity);

        lastCatalogItemCreated = catalogItem;

        entityHandler.EntityListChanged();
        entityHandler.NotifyEntityIsCreated(entity.rootEntity);
        OnInputDone?.Invoke();
        OnCatalogItemPlaced?.Invoke();
        return(entity);
    }
    private void AddShape(CatalogItem catalogItem, DCLBuilderInWorldEntity entity)
    {
        if (catalogItem.IsNFT())
        {
            NFTShape nftShape = (NFTShape)sceneToEdit.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;

            sceneToEdit.SharedComponentAttach(entity.rootEntity.entityId, nftShape.id);
        }
        else
        {
            GLTFShape mesh = (GLTFShape)sceneToEdit.SharedComponentCreate(catalogItem.id, Convert.ToInt32(CLASS_ID.GLTF_SHAPE));
            mesh.model         = new LoadableShape.Model();
            mesh.model.src     = catalogItem.model;
            mesh.model.assetId = catalogItem.id;
            sceneToEdit.SharedComponentAttach(entity.rootEntity.entityId, mesh.id);
        }
    }
示例#6
0
    private void AddShape(CatalogItem catalogItem, BIWEntity entity)
    {
        if (catalogItem.IsNFT())
        {
            NFTShape nftShape = (NFTShape)sceneToEdit.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;
            sceneToEdit.SharedComponentAttach(entity.rootEntity.entityId, nftShape.id);

            nftShape.CallWhenReady(entity.ShapeLoadFinish);
        }
        else
        {
            GLTFShape gltfComponent = (GLTFShape)sceneToEdit.SharedComponentCreate(catalogItem.id, Convert.ToInt32(CLASS_ID.GLTF_SHAPE));
            gltfComponent.model         = new LoadableShape.Model();
            gltfComponent.model.src     = catalogItem.model;
            gltfComponent.model.assetId = catalogItem.id;
            sceneToEdit.SharedComponentAttach(entity.rootEntity.entityId, gltfComponent.id);

            gltfComponent.CallWhenReady(entity.ShapeLoadFinish);
        }
    }
    public void SetContent(CatalogItem catalogItem)
    {
        this.catalogItem = catalogItem;

        if (favImg != null)
        {
            favImg.color = catalogItem.IsFavorite() ? onFavoriteColor : offFavoriteColor;
        }

        if (backgroundImg != null)
        {
            backgroundImg.color = catalogItem.IsSmartItem() ? smartItemColor : normalColor;
        }
        smartItemGO.SetActive(catalogItem.IsSmartItem());

        GetThumbnail();

        lockedGO.gameObject.SetActive(false);

        if (catalogItem.IsNFT() && BIWNFTController.i.IsNFTInUse(catalogItem.id))
        {
            lockedGO.gameObject.SetActive(true);
        }
    }