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); sceneToEdit.RemoveEntity(idToRemove, true); HUDController.i.builderInWorldMainHud.RefreshCatalogAssetPack(); EntityListChanged(); builderInWorldBridge.RemoveEntityOnKernel(idToRemove, sceneToEdit); }
public void ForceCleanup() { ParcelScene scene = null; // If we have root entities queued for removal, we call Parcel Scene's RemoveEntity() // so that the child entities end up recursively in the entitiesMarkedForCleanup queue while (rootEntitiesMarkedForCleanup.Count > 0) { // If the next scene is different to the last one // we removed all the entities from the parcel scene if (scene != null && rootEntitiesMarkedForCleanup.Peek().scene != scene) { break; } ParcelEntity parcelEntity = rootEntitiesMarkedForCleanup.Dequeue(); scene = parcelEntity.scene; scene.RemoveEntity(parcelEntity.entity.entityId, false); } while (entitiesMarkedForCleanup.Count > 0) { DecentralandEntity entity = entitiesMarkedForCleanup.Dequeue(); entity.SetParent(null); entity.Cleanup(); } if (scene != null) { GameObject.Destroy(scene.gameObject); } }
/// <summary> ///Removes an instantiated bot. Every bot has its ID as its avatar name. /// </summary> /// <param name="targetEntityId">The target bot ID. Every bot has its ID as its avatar name.</param> public void RemoveBot(string targetEntityId) { if (!instantiatedBots.Contains(targetEntityId)) { return; } globalScene.RemoveEntity(targetEntityId); instantiatedBots.Remove(targetEntityId); }
IEnumerator CleanupEntitiesCoroutine() { while (true) { float lastTime = Time.unscaledTime; ParcelScene scene = null; // If we have root entities queued for removal, we call Parcel Scene's RemoveEntity() // so that the child entities end up recursively in the entitiesMarkedForCleanup queue while (rootEntitiesMarkedForCleanup.Count > 0) { // If the next scene is different to the last one // we removed all the entities from the parcel scene if (scene != null && rootEntitiesMarkedForCleanup.Peek().scene != scene) { break; } ParcelEntity parcelEntity = rootEntitiesMarkedForCleanup.Dequeue(); scene = parcelEntity.scene; scene.RemoveEntity(parcelEntity.entity.entityId, false); if (DCLTime.realtimeSinceStartup - lastTime >= MAX_TIME_BUDGET) { yield return(null); lastTime = Time.unscaledTime; } } while (entitiesMarkedForCleanup.Count > 0) { DecentralandEntity entity = entitiesMarkedForCleanup.Dequeue(); entity.SetParent(null); entity.Cleanup(); if (DCLTime.realtimeSinceStartup - lastTime >= MAX_TIME_BUDGET) { yield return(null); lastTime = Time.unscaledTime; } } if (scene != null) { GameObject.Destroy(scene.gameObject); } yield return(null); } }
public static void RemoveSceneEntity(ParcelScene scene, DecentralandEntity entity) { scene.RemoveEntity(entity.entityId); }
public static void RemoveSceneEntity(ParcelScene scene, string id) { scene.RemoveEntity(id); }
private void ProcessMessage(ParcelScene scene, string method, object msgPayload, out CustomYieldInstruction yieldInstruction) { yieldInstruction = null; IDelayedComponent delayedComponent = null; try { switch (method) { case MessagingTypes.ENTITY_CREATE: { if (msgPayload is Protocol.CreateEntity payload) { scene.CreateEntity(payload.entityId); } break; } case MessagingTypes.ENTITY_REPARENT: { if (msgPayload is Protocol.SetEntityParent payload) { scene.SetEntityParent(payload.entityId, payload.parentId); } break; } case MessagingTypes.ENTITY_COMPONENT_CREATE_OR_UPDATE: { if (msgPayload is Protocol.EntityComponentCreateOrUpdate payload) { delayedComponent = scene.EntityComponentCreateOrUpdate(payload.entityId, (CLASS_ID_COMPONENT)payload.classId, payload.json) as IDelayedComponent; } break; } case MessagingTypes.ENTITY_COMPONENT_DESTROY: { if (msgPayload is Protocol.EntityComponentDestroy payload) { scene.EntityComponentRemove(payload.entityId, payload.name); } break; } case MessagingTypes.SHARED_COMPONENT_ATTACH: { if (msgPayload is Protocol.SharedComponentAttach payload) { scene.SharedComponentAttach(payload.entityId, payload.id); } break; } case MessagingTypes.SHARED_COMPONENT_CREATE: { if (msgPayload is Protocol.SharedComponentCreate payload) { scene.SharedComponentCreate(payload.id, payload.classId); } break; } case MessagingTypes.SHARED_COMPONENT_DISPOSE: { if (msgPayload is Protocol.SharedComponentDispose payload) { scene.SharedComponentDispose(payload.id); } break; } case MessagingTypes.SHARED_COMPONENT_UPDATE: { if (msgPayload is Protocol.SharedComponentUpdate payload) { delayedComponent = scene.SharedComponentUpdate(payload.componentId, payload.json) as IDelayedComponent; } break; } case MessagingTypes.ENTITY_DESTROY: { if (msgPayload is Protocol.RemoveEntity payload) { scene.RemoveEntity(payload.entityId); } break; } case MessagingTypes.INIT_DONE: { scene.sceneLifecycleHandler.SetInitMessagesDone(); break; } case MessagingTypes.QUERY: { if (msgPayload is QueryMessage queryMessage) { ParseQuery(queryMessage.payload, scene.sceneData.id); } break; } case MessagingTypes.OPEN_EXTERNAL_URL: { if (msgPayload is Protocol.OpenExternalUrl payload) { OnOpenExternalUrlRequest?.Invoke(scene, payload.url); } break; } case MessagingTypes.OPEN_NFT_DIALOG: { if (msgPayload is Protocol.OpenNftDialog payload) { DataStore.i.onOpenNFTPrompt.Set(new NFTPromptModel(payload.contactAddress, payload.tokenId, payload.comment), true); } break; } default: Debug.LogError($"Unknown method {method}"); break; } } catch (Exception e) { throw new Exception( $"Scene message error. scene: {scene.sceneData.id} method: {method} payload: {JsonUtility.ToJson(msgPayload)} {e}"); } if (delayedComponent != null) { if (delayedComponent.isRoutineRunning) { yieldInstruction = delayedComponent.yieldInstruction; } } }