Exemple #1
0
    public void NftComponent()
    {
        CatalogItem catalogItem = DataStore.i.dataStoreBuilderInWorld.catalogItemDict.GetValues()[0];


        BIWEntity biwEntity = new BIWEntity();

        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);
    }
    BIWEntity SetupEntityToEdit(IDCLEntity entity, bool hasBeenCreated = false)
    {
        if (!convertedEntities.ContainsKey(GetConvertedUniqueKeyForEntity(entity)))
        {
            BIWEntity entityToEdit = new BIWEntity();
            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)]);
        }
    }
Exemple #3
0
        public void UpdateInfoCorrectly()
        {
            // Arrange
            BIWEntity testEntity = new BIWEntity();

            var entity = TestHelpers.CreateSceneEntity(scene, "entityId");

            testEntity.Init(entity, null);

            // Act
            entityInformationController.UpdateInfo(testEntity);

            // Assert
            entityInformationController.entityInformationView.Received(1).SetPositionAttribute(Arg.Any <Vector3>());
            entityInformationController.entityInformationView.Received(1).SetRotationAttribute(Arg.Any <Vector3>());
            entityInformationController.entityInformationView.Received(1).SetScaleAttribute(Arg.Any <Vector3>());
        }
Exemple #4
0
    public void BuilderInWorldEntityComponents()
    {
        string entityId = "1";

        TestHelpers.CreateSceneEntity(scene, entityId);

        BIWEntity biwEntity = new BIWEntity();

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

        Assert.IsTrue(biwEntity.entityUniqueId == scene.sceneData.id + scene.entities[entityId].entityId, "Entity id is not created correctly, this can lead to weird behaviour");

        SmartItemComponent.Model model = new SmartItemComponent.Model();

        scene.EntityComponentCreateOrUpdateWithModel(entityId, CLASS_ID_COMPONENT.SMART_ITEM, model);

        Assert.IsTrue(biwEntity.HasSmartItemComponent());

        DCLName name = (DCLName)scene.SharedComponentCreate(Guid.NewGuid().ToString(), Convert.ToInt32(CLASS_ID.NAME));

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

        DCLName dclName = biwEntity.rootEntity.TryGetComponent <DCLName>();

        Assert.IsNotNull(dclName);

        string newName = "TestingName";

        dclName.SetNewName(newName);
        Assert.AreEqual(newName, biwEntity.GetDescriptiveName());


        DCLLockedOnEdit entityLocked = (DCLLockedOnEdit)scene.SharedComponentCreate(Guid.NewGuid().ToString(), Convert.ToInt32(CLASS_ID.LOCKED_ON_EDIT));

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

        DCLLockedOnEdit dclLockedOnEdit = biwEntity.rootEntity.TryGetComponent <DCLLockedOnEdit>();

        Assert.IsNotNull(dclLockedOnEdit);

        bool isLocked = true;

        dclLockedOnEdit.SetIsLocked(isLocked);
        Assert.AreEqual(biwEntity.IsLocked, isLocked);
    }
    public void UndoRedoCreateDeleteActions()
    {
        biwActionController.CreateActionEntityCreated(scene.entities[ENTITY_ID]);
        biwActionController.TryToUndoAction();
        Assert.IsFalse(scene.entities.ContainsKey(ENTITY_ID));

        biwActionController.TryToRedoAction();
        Assert.IsTrue(scene.entities.ContainsKey(ENTITY_ID));

        BIWEntity biwEntity = new BIWEntity();

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

        biwActionController.CreateActionEntityDeleted(biwEntity);
        biwActionController.TryToUndoAction();
        Assert.IsTrue(scene.entities.ContainsKey(ENTITY_ID));

        biwActionController.TryToRedoAction();
        Assert.IsFalse(scene.entities.ContainsKey(ENTITY_ID));
    }