public void InvokeEntityActionCorrectly() { // Arrange BIWEntity testEntity = new BIWEntity(); testEntity.entityUniqueId = "testId"; EntityListAdapter testEntityListAdapter = new GameObject("_EntityListAdapter").AddComponent <EntityListAdapter>(); testEntity.entityUniqueId = "testId"; EntityAction testEntityAction = EntityAction.SHOW; BIWEntity 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!!"); }
protected override IEnumerator SetUp() { yield return(base.SetUp()); TestHelpers.CreateSceneEntity(scene, ENTITY_ID); TestHelpers.CreateAndSetShape(scene, ENTITY_ID, DCL.Models.CLASS_ID.GLTF_SHAPE, JsonConvert.SerializeObject( new { src = TestAssetsUtils.GetPath() + "/GLB/Trunk/Trunk.glb" })); LoadWrapper gltfShape = GLTFShape.GetLoaderForEntity(scene.entities[ENTITY_ID]); yield return(new DCL.WaitUntil(() => gltfShape.alreadyLoaded)); outlinerController = new BIWOutlinerController(); entityHandler = new BIWEntityHandler(); var referencesController = BIWTestHelper.CreateReferencesControllerWithGenericMocks( outlinerController, entityHandler ); outlinerController.Init(referencesController); entityHandler.Init(referencesController); entityHandler.EnterEditMode(scene); outlinerController.EnterEditMode(scene); entity = entityHandler.GetConvertedEntity(scene.entities[ENTITY_ID]); }
public void OutlineEntity(BIWEntity entity) { if (entity.rootEntity.meshRootGameObject == null) { return; } if (!entity.rootEntity.meshRootGameObject && entity.rootEntity.renderers.Length <= 0) { return; } if (entitiesOutlined.Contains(entity)) { return; } if (entity.IsLocked) { return; } entitiesOutlined.Add(entity); for (int i = 0; i < entity.rootEntity.meshesInfo.renderers.Length; i++) { if (entity.rootEntity.meshesInfo.renderers[i] == null) { continue; } entity.rootEntity.meshesInfo.renderers[i].gameObject.layer = BIWSettings.SELECTION_LAYER_INDEX; } }
public void CheckOutline() { if (outlinerOptimizationCounter >= 10 && isOutlineCheckActive) { if (!BIWUtils.IsPointerOverUIElement() && !BIWUtils.IsPointerOverMaskElement(BIWSettings.GIZMOS_LAYER)) { BIWEntity entity = raycastController.GetEntityOnPointer(); RemoveEntitiesOutlineOutsidePointerOrUnselected(); if (entity != null && !entity.IsSelected) { OutlineEntity(entity); } } else { CancelUnselectedOutlines(); } outlinerOptimizationCounter = 0; } else { outlinerOptimizationCounter++; } }
private void OnFloorEntityDeleted(BIWEntity entity) { if (entity.isFloor) { RemovePlaceHolder(entity); } }
public void ChangeEntityNameCorrectly() { // Arrange string newEntityName = "Test name"; BIWEntity testEntity = new BIWEntity(); testEntity.entityUniqueId = "testId"; entityInformationView.currentEntity = testEntity; BIWEntity 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!"); }
public void SetEntityName(BIWEntity 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) { bridge?.ChangedEntityName(entityToApply, sceneToEdit); } }
public void CreateFloor(CatalogItem floorSceneObject) { Vector3 initialPosition = new Vector3(ParcelSettings.PARCEL_SIZE / 2, 0, ParcelSettings.PARCEL_SIZE / 2); Vector2Int[] parcelsPoints = sceneToEdit.sceneData.parcels; numberOfParcelsLoaded = 0; loadedFloorEntities.Clear(); foreach (Vector2Int parcel in parcelsPoints) { BIWEntity decentralandEntity = creatorController.CreateCatalogItem( floorSceneObject, WorldStateUtils.ConvertPointInSceneToUnityPosition(initialPosition, parcel), false, true, OnFloorLoaded); // It may happen that when you get here, the floor entity is already loaded and it wouldn't be necessary to show its loading indicator. if (!loadedFloorEntities.Contains(decentralandEntity.rootEntity.entityId)) { GameObject floorPlaceHolder = GameObject.Instantiate(floorPrefab, decentralandEntity.rootEntity.gameObject.transform.position, Quaternion.identity); floorPlaceHolder.GetComponentInChildren <BIWFloorLoading>().Initialize(mainCamera); floorPlaceHolderDict.Add(decentralandEntity.rootEntity.entityId, floorPlaceHolder); decentralandEntity.OnShapeFinishLoading += RemovePlaceHolder; } } entityHandler.DeselectEntities(); lastFloorCalalogItemUsed = floorSceneObject; }
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)]); } }
public BIWEntity 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); BIWEntity convertedEntity = SetupEntityToEdit(newEntity, true); hudController?.UpdateSceneLimitInfo(); if (notifyEntityList) { EntityListChanged(); } return(convertedEntity); }
public bool SelectEntity(BIWEntity entityEditable, bool selectedFromCatalog = false) { 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(selectedFromCatalog); hudController.EntityInformationSetEntity(entityEditable, sceneToEdit); } outlinerController.CancelAllOutlines(); OnEntitySelected?.Invoke(); return(true); }
public void SetEntity(BIWEntity entity, ParcelScene currentScene) { currentEntity = entity; EntityDeselected(); entityInformationView.SetCurrentEntity(entity); if (entityInformationView.currentEntity != null) { entity.OnStatusUpdate -= UpdateEntityName; entityInformationView.currentEntity.OnStatusUpdate += UpdateEntityName; } parcelScene = currentScene; if (entity.HasSmartItemComponent()) { entityInformationView.SetSmartItemListViewActive(false); //TODO: Remove this comment when we implement smart items in builder in world //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); }
void DeleteAdapter(BIWEntity entityToEdit) { if (this != null && entityToEdit.entityUniqueId == currentEntity.entityUniqueId) { Destroy(gameObject); } }
public void SetEntitiesListCorrectly() { // Arrange List <BIWEntity> testList = new List <BIWEntity>(); BIWEntity testEntity1 = new BIWEntity(); testEntity1.entityUniqueId = "testId1"; BIWEntity testEntity2 = new BIWEntity(); testEntity1.entityUniqueId = "testId2"; BIWEntity testEntity3 = new BIWEntity(); testEntity1.entityUniqueId = "testId3"; testList.Add(testEntity1); testList.Add(testEntity2); testList.Add(testEntity3); inspectorView.entitiesList = new List <BIWEntity>(); // Act inspectorView.SetEntitiesList(testList); // Assert Assert.AreEqual(3, inspectorView.entitiesList.Count, "The number of set entities does not match!"); for (int i = 0; i < 3; i++) { Assert.AreEqual(testList[i].entityUniqueId, inspectorView.entitiesList[i].entityUniqueId, "The added entity id does not match!"); } }
public void EntityDuplicate() { IDCLEntity duplicateEntity = entityHandler.DuplicateEntity(entity).rootEntity; BIWEntity convertedEntity = entityHandler.GetConvertedEntity(duplicateEntity); Assert.IsNotNull(convertedEntity); }
private void AddEntityNameComponent(CatalogItem catalogItem, BIWEntity entity) { DCLName name = (DCLName)sceneToEdit.SharedComponentCreate(Guid.NewGuid().ToString(), Convert.ToInt32(CLASS_ID.NAME)); sceneToEdit.SharedComponentAttach(entity.rootEntity.entityId, name.id); entityHandler.SetEntityName(entity, catalogItem.name, false); }
public void InvokeEntityActionCorrectly(EntityAction actionToInvoke) { // Arrange EntityAction testAction = actionToInvoke; BIWEntity testEntity = new BIWEntity(); BIWEntity 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!"); }
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); }
public void EntityClicked(BIWEntity entityToSelect) { if (entityToSelect != null) { if (!isMultiSelectionActive) { DeselectEntities(); } if (!entityToSelect.IsLocked) { ChangeEntitySelectStatus(entityToSelect); } if (entityToSelect == lastClickedEntity && (lastTimeEntityClicked + BIWSettings.MOUSE_MS_DOUBLE_CLICK_THRESHOLD / 1000f) >= Time.realtimeSinceStartup) { modeController.EntityDoubleClick(entityToSelect); } lastClickedEntity = entityToSelect; lastTimeEntityClicked = Time.realtimeSinceStartup; } else if (!isMultiSelectionActive) { DeselectEntities(); } }
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); }
public override void EntityDoubleClick(BIWEntity entity) { base.EntityDoubleClick(entity); if (!entity.IsLocked) { LookAtEntity(entity.rootEntity); } }
private void ChangeEntityVisibilityStatus(BIWEntity entityToApply) { entityToApply.ToggleShowStatus(); if (!entityToApply.IsVisible && selectedEntities.Contains(entityToApply)) { DeselectEntity(entityToApply); } }
private void SetEntityError(BIWEntity entity) { if (entity != currentEntity) { return; } CheckEntityNameColor(entity); }
public override void OnDeleteEntity(BIWEntity entity) { base.OnDeleteEntity(entity); saveController.TryToSave(); if (selectedEntities.Count == 0) { gizmoManager.HideGizmo(); } }
public void EntityCreationDelete() { BIWEntity 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); }
private void ChangeEntityLockStatus(BIWEntity entityToApply) { entityToApply.ToggleLockStatus(); if (entityToApply.IsLocked && selectedEntities.Contains(entityToApply)) { DeselectEntity(entityToApply); } bridge.ChangeEntityLockStatus(entityToApply, sceneToEdit); }
public virtual void EntityDeselected(BIWEntity entityDeselected) { CenterGameObjectToEdit(); if (isNewObjectPlaced) { actionController.CreateActionEntityCreated(entityDeselected.rootEntity); } isNewObjectPlaced = false; }
public void TestTransformKernelUpdate() { //Arrange BIWEntity entity = entityHandler.CreateEmptyEntity(scene, Vector3.zero, Vector3.zero); //Act biwBridge.EntityTransformReport(entity.rootEntity, scene); //Assert CheckMessageReceived(); }
public void TestSmartItemComponentKernelUpdate() { //Arrange BIWEntity entity = BIWTestHelper.CreateSmartItemEntity(entityHandler, scene, null); //Act biwBridge.UpdateSmartItemComponent(entity, scene); //Assert CheckMessageReceived(); }
public void TestRemoveEntityKernelUpdate() { //Arrange BIWEntity entity = entityHandler.CreateEmptyEntity(scene, Vector3.zero, Vector3.zero); //Act biwBridge.RemoveEntityOnKernel(entity.rootEntity.entityId, scene); //Assert CheckMessageReceived(); }