protected void AddOrReplaceMetrics(DecentralandEntity entity) { if (entitiesMetrics.ContainsKey(entity)) { SubstractMetrics(entity); } AddMetrics(entity); }
protected virtual void OnEntityRemoved(DecentralandEntity e) { SubstractMetrics(e); e.OnMeshesInfoUpdated -= OnEntityMeshInfoUpdated; e.OnMeshesInfoCleaned -= OnEntityMeshInfoCleaned; model.entities--; isDirty = true; }
private void ProcessEntityShape(DecentralandEntity entity) { if (entity.meshRootGameObject && entity.meshesInfo.renderers.Length > 0) { CreateColliders(entity.meshesInfo); SetCollidersActive(true); } }
public static void SharedComponentAttach(BaseDisposable component, DecentralandEntity entity) { entity.scene.SharedComponentAttach( entity.entityId, component.id, component.componentName ); }
public Dictionary <Renderer, Material> GetOriginalMaterials(DecentralandEntity entity) { if (invalidMeshesInfo.ContainsKey(entity.gameObject)) { return(invalidMeshesInfo[entity.gameObject].originalMaterials); } return(null); }
void EvaluateMeshBounds(DecentralandEntity entity) { bool isInsideBoundaries = IsEntityInsideSceneBoundaries(entity); UpdateEntityMeshesValidState(entity.meshesInfo, isInsideBoundaries); UpdateEntityCollidersValidState(entity.meshesInfo, isInsideBoundaries); UpdateComponents(entity, isInsideBoundaries); }
public static GLTFShape CreateEntityWithGLTFShape(ParcelScene scene, Vector3 position, string url, out DecentralandEntity entity) { return(CreateEntityWithGLTFShape(scene, position, new GLTFShape.Model() { src = url }, out entity)); }
private void OnEntityRemoved(DecentralandEntity entity) { rootEntity.OnRemoved -= OnEntityRemoved; rootEntity.OnShapeUpdated -= OnShapeUpdated; rootEntity.OnTransformChange -= OnTransformUpdated; DCLBuilderBridge.OnPreviewModeChanged -= OnPreviewModeChanged; DestroyColliders(); }
public static GLTFShape CreateEntityWithGLTFShape(ParcelScene scene, Vector3 position, GLTFShape.Model model, out DecentralandEntity entity) { entity = CreateSceneEntity(scene); GLTFShape gltfShape = AttachGLTFShape(entity, scene, position, model); return(gltfShape); }
void ApplyAction(string entityIdToApply, object value, ActionType actionType, bool isUndo) { switch (actionType) { case ActionType.MOVE: Vector3 convertedPosition = (Vector3)value; builderInWorldEntityHandler.GetEntity(entityIdToApply).rootEntity.gameObject.transform.position = convertedPosition; break; case ActionType.ROTATE: Vector3 convertedAngles = (Vector3)value; builderInWorldEntityHandler.GetEntity(entityIdToApply).rootEntity.gameObject.transform.eulerAngles = convertedAngles; break; case ActionType.SCALE: Vector3 convertedScale = (Vector3)value; DecentralandEntity entityToApply = builderInWorldEntityHandler.GetEntity(entityIdToApply).rootEntity; Transform parent = entityToApply.gameObject.transform.parent; entityToApply.gameObject.transform.localScale = new Vector3(convertedScale.x / parent.localScale.x, convertedScale.y / parent.localScale.y, convertedScale.z / parent.localScale.z); break; case ActionType.CREATE: string entityString = (string)value; if (isUndo) { builderInWorldEntityHandler.DeleteEntity(entityString); } else { builderInWorldEntityHandler.CreateEntityFromJSON(entityString); } break; case ActionType.DELETE: string deletedEntityString = (string)value; if (isUndo) { builderInWorldEntityHandler.CreateEntityFromJSON(deletedEntityString); } else { builderInWorldEntityHandler.DeleteEntity(deletedEntityString); } break; case ActionType.CHANGE_FLOOR: string sceneObjectToApply = (string)value; SceneObject floorObject = JsonConvert.DeserializeObject <SceneObject>(sceneObjectToApply); builderInWorldEntityHandler.DeleteFloorEntities(); builderInWorldController.CreateFloor(floorObject); break; } }
public static string ConvertEntityToJSON(DecentralandEntity entity) { EntityData builderInWorldEntityData = new EntityData(); builderInWorldEntityData.entityId = entity.entityId; foreach (KeyValuePair <CLASS_ID_COMPONENT, BaseComponent> keyValuePair in entity.components) { if (keyValuePair.Key == CLASS_ID_COMPONENT.TRANSFORM) { EntityData.TransformComponent entityComponentModel = new EntityData.TransformComponent(); entityComponentModel.position = WorldStateUtils.ConvertUnityToScenePosition(entity.gameObject.transform.position, entity.scene); entityComponentModel.rotation = entity.gameObject.transform.localRotation.eulerAngles; entityComponentModel.scale = entity.gameObject.transform.localScale; builderInWorldEntityData.transformComponent = entityComponentModel; } else { ProtocolV2.GenericComponent entityComponentModel = new ProtocolV2.GenericComponent(); entityComponentModel.componentId = (int)keyValuePair.Key; entityComponentModel.data = keyValuePair.Value.GetModel(); builderInWorldEntityData.components.Add(entityComponentModel); } } foreach (KeyValuePair <Type, BaseDisposable> keyValuePair in entity.GetSharedComponents()) { if (keyValuePair.Value.GetClassId() == (int)CLASS_ID.NFT_SHAPE) { EntityData.NFTComponent nFTComponent = new EntityData.NFTComponent(); NFTShape.Model model = (NFTShape.Model)keyValuePair.Value.GetModel(); nFTComponent.id = keyValuePair.Value.id; nFTComponent.color = new ColorRepresentation(model.color); nFTComponent.assetId = model.assetId; nFTComponent.src = model.src; nFTComponent.style = model.style; builderInWorldEntityData.nftComponent = nFTComponent; } else { ProtocolV2.GenericComponent entityComponentModel = new ProtocolV2.GenericComponent(); entityComponentModel.componentId = keyValuePair.Value.GetClassId(); entityComponentModel.data = keyValuePair.Value.GetModel(); entityComponentModel.classId = keyValuePair.Value.id; builderInWorldEntityData.sharedComponents.Add(entityComponentModel); } } return(JsonConvert.SerializeObject(builderInWorldEntityData)); }
protected void UpdateComponents(DecentralandEntity entity, bool isInsideBoundaries) { IOutOfSceneBoundariesHandler[] components = entity.gameObject.GetComponentsInChildren <IOutOfSceneBoundariesHandler>(); for (int i = 0; i < components.Length; i++) { components[i].UpdateOutOfBoundariesState(isInsideBoundaries); } }
void OnShapeUpdate(DecentralandEntity decentralandEntity) { if (IsSelected) { SaveOriginalMaterialAndSetEditMaterials(); } ShapeInit(); }
public static void SharedComponentAttach(BaseDisposable component, DecentralandEntity entity) { ParcelScene scene = entity.scene as ParcelScene; scene.SharedComponentAttach( entity.entityId, component.id ); }
public override void AttachTo(DecentralandEntity entity, System.Type overridenAttachedType = null) { if (attachedEntities.Contains(entity)) { return; } base.AttachTo(entity); }
private void OnEntityDetachedMaterial(DecentralandEntity entity) { if (texturePlayer != null) { texturePlayer.Pause(); } entity.OnShapeUpdated -= OnEntityShapeUpdated; }
public IEnumerator MaterialTransitionWithParametrizableMeshes() { DCL.Configuration.EnvironmentSettings.DEBUG = true; var entity1 = TestHelpers.CreateSceneEntity(scene); ParcelSettings.VISUAL_LOADING_ENABLED = true; DecentralandEntity entity = null; ConeShape shape = TestHelpers.InstantiateEntityWithShape <ConeShape, ConeShape.Model> ( scene, DCL.Models.CLASS_ID.CONE_SHAPE, new Vector3(2, 1, 3), out entity, new ConeShape.Model()); yield return(null); float timeout = 0f; float maxTime = 20f; while (timeout < maxTime) { timeout += Time.deltaTime; if (timeout > maxTime) { timeout = maxTime; } if (entity.meshRootGameObject != null) { var c = entity.meshRootGameObject.GetComponentInChildren <MaterialTransitionController>(); if (c != null) // NOTE(Brian): Wait for it { Assert.IsTrue(!c.useHologram, "useHologram must be false"); Assert.IsTrue(entity.meshRootGameObject != null, "meshGameObject is null"); Assert.IsTrue(c.placeholder == null, "placeholder must be null because we're not using holograms with parametric shapes."); yield return(new WaitForSeconds(2f)); Assert.IsTrue(c == null, "MaterialTransitionController should be destroyed by now!"); break; } } yield return(null); } Assert.Less(timeout, maxTime + 0.1f, "Timeout! MaterialTransitionController never appeared?"); yield return(null); }
public void AddEntityToBeChecked(DecentralandEntity entity) { if (!SceneController.i.useBoundariesChecker) { return; } OnAddEntity(entity); }
public void RemoveEntityToBeChecked(DecentralandEntity entity) { if (!SceneController.i.useBoundariesChecker) { return; } entitiesToCheck.Remove(entity); }
void OnShapeUpdate(DecentralandEntity decentralandEntity) { ShapeInit(); if (IsSelected) { SetEditMaterial(); } }
private void OnEntityIsRemoved(DecentralandEntity entity) { var builderEntity = entity.gameObject.GetComponent <DCLBuilderEntity>(); if (builderEntity != null) { OnEntityRemoved?.Invoke(builderEntity); } }
public void Setup(string button, string feedbackText, DecentralandEntity entity) { text.text = feedbackText; this.entity = entity; ConfigureIcon(button); canvas.enabled = enabled && isHovered; }
private void OnAvatarShapeUpdated(DecentralandEntity entity, AvatarShape avatarShape) { if (rootEntity != entity) { return; } OnShapeUpdated(rootEntity); }
protected override void OnRemoveEntity(DecentralandEntity entity) { base.OnRemoveEntity(entity); if (entity.gameObject != null) { RemoveInvalidMeshEffect(entity); } }
public static GLTFShape AttachGLTFShape(DecentralandEntity entity, ParcelScene scene, Vector3 position, GLTFShape.Model model) { string componentId = GetComponentUniqueId(scene, "gltfShape", (int)CLASS_ID.GLTF_SHAPE, entity.entityId); GLTFShape gltfShape = SharedComponentCreate <GLTFShape, GLTFShape.Model>(scene, CLASS_ID.GLTF_SHAPE, model); SetEntityTransform(scene, entity, position, Quaternion.identity, Vector3.one); SharedComponentAttach(gltfShape, entity); return(gltfShape); }
public void RemoveEntityToBeChecked(DecentralandEntity entity) { if (!enabled) { return; } OnRemoveEntity(entity); }
public static AvatarShape CreateAvatarShape(ParcelScene scene, AvatarModel model) { GLTFSceneImporter.budgetPerFrameInMilliseconds = float.MaxValue; DecentralandEntity entity = TestHelpers.CreateSceneEntity(scene); AvatarShape shape = TestHelpers.EntityComponentCreate <AvatarShape, AvatarModel>(scene, entity, model, CLASS_ID_COMPONENT.AVATAR_SHAPE); TestHelpers.SetEntityTransform(scene, entity, new Vector3(0, 0, 0), Quaternion.identity, Vector3.one); return(shape); }
public void SetEntityParent(string entityId, string parentId) { SceneController.i.OnMessageDecodeStart?.Invoke("SetEntityParent"); SceneController.i.OnMessageDecodeEnds?.Invoke("SetEntityParent"); if (entityId == parentId) { return; } DecentralandEntity me = GetEntityForUpdate(entityId); if (me != null) { if (parentId == "FirstPersonCameraEntityReference" || parentId == "PlayerEntityReference") // PlayerEntityReference is for compatibility purposes { // In this case, the entity will attached to the first person camera // On first person mode, the entity will rotate with the camera. On third person mode, the entity will rotate with the avatar me.SetParent(DCLCharacterController.i.firstPersonCameraReference); SceneController.i.boundariesChecker.AddPersistent(me); SceneController.i.physicsSyncController.MarkDirty(); } else if (parentId == "AvatarEntityReference" || parentId == "AvatarPositionEntityReference") // AvatarPositionEntityReference is for compatibility purposes { // In this case, the entity will be attached to the avatar // It will simply rotate with the avatar, regardless of where the camera is pointing me.SetParent(DCLCharacterController.i.avatarReference); SceneController.i.boundariesChecker.AddPersistent(me); SceneController.i.physicsSyncController.MarkDirty(); } else { if (me.parent == DCLCharacterController.i.firstPersonCameraReference || me.parent == DCLCharacterController.i.avatarReference) { SceneController.i.boundariesChecker.RemoveEntityToBeChecked(me); } if (parentId == "0") { // The entity will be child of the scene directly me.SetParent(null); me.gameObject.transform.SetParent(gameObject.transform, false); SceneController.i.physicsSyncController.MarkDirty(); } else { DecentralandEntity myParent = GetEntityForUpdate(parentId); if (myParent != null) { me.SetParent(myParent); SceneController.i.physicsSyncController.MarkDirty(); } } } } }
public void AddEntityOnKernel(DecentralandEntity entity, ParcelScene scene) { List <ComponentPayload> list = new List <ComponentPayload>(); foreach (KeyValuePair <CLASS_ID_COMPONENT, BaseComponent> keyValuePair in entity.components) { ComponentPayload componentPayLoad = new ComponentPayload(); componentPayLoad.componentId = Convert.ToInt32(keyValuePair.Key); if (keyValuePair.Key == CLASS_ID_COMPONENT.TRANSFORM) { TransformComponent entityComponentModel = new TransformComponent(); entityComponentModel.position = WorldStateUtils.ConvertUnityToScenePosition(entity.gameObject.transform.position, scene); entityComponentModel.rotation = new QuaternionRepresentation(entity.gameObject.transform.rotation); entityComponentModel.scale = entity.gameObject.transform.localScale; componentPayLoad.data = entityComponentModel; } else { componentPayLoad.data = keyValuePair.Value.GetModel(); } list.Add(componentPayLoad); } foreach (KeyValuePair <Type, BaseDisposable> keyValuePairBaseDisposable in entity.GetSharedComponents()) { ComponentPayload componentPayLoad = new ComponentPayload(); componentPayLoad.componentId = keyValuePairBaseDisposable.Value.GetClassId(); if (keyValuePairBaseDisposable.Value.GetClassId() == (int)CLASS_ID.NFT_SHAPE) { NFTComponent nftComponent = new NFTComponent(); NFTShape.Model model = (NFTShape.Model)keyValuePairBaseDisposable.Value.GetModel(); nftComponent.color = new ColorRepresentation(model.color); nftComponent.assetId = model.assetId; nftComponent.src = model.src; nftComponent.style = model.style; componentPayLoad.data = nftComponent; } else { componentPayLoad.data = keyValuePairBaseDisposable.Value.GetModel(); } list.Add(componentPayLoad); } SendNewEntityToKernel(scene.sceneData.id, entity.entityId, list.ToArray()); }
public override void AttachTo(DecentralandEntity entity, System.Type overridenAttachedType = null) { if (attachedEntities.Contains(entity)) { return; } entity.RemoveSharedComponent(typeof(PBRMaterial)); base.AttachTo(entity); }