protected override void Dispose(bool disposing) { //Does nothing base.Dispose(disposing); //If disposing if (disposing) { IsDisposed = true; //Calls Close virtual (Calls Dispose(true) and GC.SuppressFinalize(this)) //base.Dispose(); //Clear memory Clear(); m_Position = m_Cursor = -1; //Handled with free... if (false.Equals(IDisposedExtensions.IsNullOrDisposed(WorkingSegment))) { BaseDisposable.SetShouldDispose(WorkingSegment, true, true); WorkingSegment = null; } } }
public static void SharedComponentAttach(BaseDisposable component, DecentralandEntity entity) { entity.scene.SharedComponentAttach( entity.entityId, component.id, component.componentName ); }
public static void SharedComponentAttach(BaseDisposable component, DecentralandEntity entity) { ParcelScene scene = entity.scene as ParcelScene; scene.SharedComponentAttach( entity.entityId, component.id ); }
public void AddSharedComponent(System.Type componentType, BaseDisposable component) { if (component == null) { return; } RemoveSharedComponent(componentType); sharedComponents.Add(componentType, component); }
public bool TryGetSharedComponent(CLASS_ID componentId, out BaseDisposable component) { foreach (KeyValuePair <Type, BaseDisposable> keyValuePairBaseDisposable in GetSharedComponents()) { if (keyValuePairBaseDisposable.Value.GetClassId() == (int)componentId) { component = keyValuePairBaseDisposable.Value; return(true); } } component = null; return(false); }
public DecentralandEntity DuplicateEntity(DecentralandEntity entity) { if (!entities.ContainsKey(entity.entityId)) { return(null); } DecentralandEntity newEntity = CreateEntity(System.Guid.NewGuid().ToString()); if (entity.children.Count > 0) { using (var iterator = entity.children.GetEnumerator()) { while (iterator.MoveNext()) { DecentralandEntity childDuplicate = DuplicateEntity(iterator.Current.Value); childDuplicate.SetParent(newEntity); } } } if (entity.parent != null) { SetEntityParent(newEntity.entityId, entity.parent.entityId); } DCLTransform.model.position = WorldStateUtils.ConvertUnityToScenePosition(entity.gameObject.transform.position); DCLTransform.model.rotation = entity.gameObject.transform.rotation; DCLTransform.model.scale = entity.gameObject.transform.lossyScale; foreach (KeyValuePair <CLASS_ID_COMPONENT, BaseComponent> component in entity.components) { EntityComponentCreateOrUpdateFromUnity(newEntity.entityId, component.Key, DCLTransform.model); } foreach (KeyValuePair <System.Type, BaseDisposable> component in entity.GetSharedComponents()) { BaseDisposable baseDisposable = SharedComponentCreate(System.Guid.NewGuid().ToString(), component.Value.GetClassId()); string jsonModel = Newtonsoft.Json.JsonConvert.SerializeObject(component.Value.GetModel()); baseDisposable.UpdateFromJSON(jsonModel); SharedComponentAttach(newEntity.entityId, baseDisposable.id); } //NOTE: (Adrian) Evaluate if all created components should be handle as equals instead of different foreach (KeyValuePair <string, UUIDComponent> component in entity.uuidComponents) { EntityComponentCreateOrUpdateFromUnity(newEntity.entityId, CLASS_ID_COMPONENT.UUID_CALLBACK, component.Value.model); } return(newEntity); }
public void SharedComponentUpdate(string id, string json, out CleanableYieldInstruction yieldInstruction) { ProfilingEvents.OnMessageDecodeStart?.Invoke("ComponentUpdated"); BaseDisposable newComponent = SharedComponentUpdate(id, json); ProfilingEvents.OnMessageDecodeEnds?.Invoke("ComponentUpdated"); yieldInstruction = null; if (newComponent != null && newComponent.isRoutineRunning) { yieldInstruction = newComponent.yieldInstruction; } }
public BaseDisposable SharedComponentUpdate(string id, string json, out CleanableYieldInstruction yieldInstruction) { SceneController.i.OnMessageDecodeStart?.Invoke("ComponentUpdated"); BaseDisposable newComponent = SharedComponentUpdate(id, json); SceneController.i.OnMessageDecodeEnds?.Invoke("ComponentUpdated"); yieldInstruction = null; if (newComponent != null && newComponent.isRoutineRunning) { yieldInstruction = newComponent.yieldInstruction; } return(newComponent); }
public static void TestCompletedByDisposable() { var disposable = new BaseDisposable(); var obs = Observable .Interval(TimeSpan.FromSeconds(1)) .CompletedBy(disposable) .Timestamp(); obs.Subscribe(i => Console.WriteLine("ob 1 Next " + i), () => Console.WriteLine("ob 1 Completed")); Task.Delay(2200).Wait(); obs.Subscribe(i => Console.WriteLine("ob 2 Next " + i), () => Console.WriteLine("ob 2 Completed")); Task.Delay(2200).Wait(); var sub = obs.Subscribe(i => Console.WriteLine("ob 3 Next " + i), () => Console.WriteLine("ob 3 Completed")); Task.Delay(2200).Wait(); sub.Dispose(); Task.Delay(2200).Wait(); disposable.Dispose(); }
private void OnDisposableReady(BaseDisposable disposable) { if (isReleased) { return; } disposableNotReady.Remove(disposable.id); if (VERBOSE) { Debug.Log($"{sceneData.basePosition} Disposable objects left... {disposableNotReady.Count}"); } if (disposableNotReady.Count == 0) { SetSceneReady(); } RefreshName(); }
public static void TestDisposableAsObservable() { Console.WriteLine(DateTime.Now); var disposable = new BaseDisposable(); var observable = disposable.AsObservable <int>(() => 42).Timestamp(); observable.Subscribe(i => Console.WriteLine("ob 1 Next " + i), () => Console.WriteLine("ob 1 Completed")); var sub = observable.Subscribe(i => Console.WriteLine("ob 2 Next " + i), () => Console.WriteLine("ob 2 Completed")); Task.Delay(1000).Wait(); sub.Dispose(); Task.Delay(1000).Wait(); disposable.Dispose(); Task.Delay(1000).Wait(); observable.Subscribe(i => Console.WriteLine("ob 3 Next " + i), () => Console.WriteLine("ob 3 Completed")); }
//Remove with timestamp start and end /// <summary> /// Clears all contained frames and optionally disposes all contained frames when removed. /// </summary> /// <param name="disposeFrames"></param> public void Clear(bool disposeFrames = true) { int[] keys = System.Linq.Enumerable.ToArray(Frames.Keys); int Key; //Store the frames at the key System.Collections.Generic.IEnumerable <RtpFrame> frames; //Could perform in parallel, would need frames local. //System.Linq.ParallelEnumerable.ForAll(keys, () => { }); //Enumerate an array of contained keys for (int i = 0, e = keys.Length; i < e; ++i) { //Get the key Key = keys[i]; //if removed from the ConcurrentThesaurus if (Frames.Remove(ref Key, out frames)) { //if we need to dispose the frames then Loop the frames contined at the key if (disposeFrames) { foreach (RtpFrame frame in frames) { //Set ShouldDispose through the base class. BaseDisposable.SetShouldDispose(frame, true, true); //Dispose the frame (already done with above call) frame.Dispose(); } } } } }
public static void SharedComponentDispose(BaseDisposable component) { component.scene.SharedComponentDispose(component.id); }
public static void SharedComponentDispose(BaseDisposable component) { ParcelScene scene = component.scene as ParcelScene; scene.SharedComponentDispose(component.id); }
public BaseDisposable SharedComponentCreate(string id, string name, int classId) { SceneController.i.OnMessageDecodeStart?.Invoke("ComponentCreated"); sharedComponentCreatedMessage.id = id; sharedComponentCreatedMessage.name = name; sharedComponentCreatedMessage.classId = classId; SceneController.i.OnMessageDecodeEnds?.Invoke("ComponentCreated"); BaseDisposable disposableComponent; if (disposableComponents.TryGetValue(sharedComponentCreatedMessage.id, out disposableComponent)) { return(disposableComponent); } BaseDisposable newComponent = null; switch ((CLASS_ID)sharedComponentCreatedMessage.classId) { case CLASS_ID.BOX_SHAPE: { newComponent = new BoxShape(this); break; } case CLASS_ID.SPHERE_SHAPE: { newComponent = new SphereShape(this); break; } case CLASS_ID.CONE_SHAPE: { newComponent = new ConeShape(this); break; } case CLASS_ID.CYLINDER_SHAPE: { newComponent = new CylinderShape(this); break; } case CLASS_ID.PLANE_SHAPE: { newComponent = new PlaneShape(this); break; } case CLASS_ID.GLTF_SHAPE: { newComponent = new GLTFShape(this); break; } case CLASS_ID.NFT_SHAPE: { newComponent = new NFTShape(this); break; } case CLASS_ID.OBJ_SHAPE: { newComponent = new OBJShape(this); break; } case CLASS_ID.BASIC_MATERIAL: { newComponent = new BasicMaterial(this); break; } case CLASS_ID.PBR_MATERIAL: { newComponent = new PBRMaterial(this); break; } case CLASS_ID.AUDIO_CLIP: { newComponent = new DCLAudioClip(this); break; } case CLASS_ID.TEXTURE: { newComponent = new DCLTexture(this); break; } case CLASS_ID.UI_INPUT_TEXT_SHAPE: { newComponent = new UIInputText(this); break; } case CLASS_ID.UI_FULLSCREEN_SHAPE: case CLASS_ID.UI_SCREEN_SPACE_SHAPE: { if (uiScreenSpace == null) { newComponent = new UIScreenSpace(this); } break; } case CLASS_ID.UI_CONTAINER_RECT: { newComponent = new UIContainerRect(this); break; } case CLASS_ID.UI_SLIDER_SHAPE: { newComponent = new UIScrollRect(this); break; } case CLASS_ID.UI_CONTAINER_STACK: { newComponent = new UIContainerStack(this); break; } case CLASS_ID.UI_IMAGE_SHAPE: { newComponent = new UIImage(this); break; } case CLASS_ID.UI_TEXT_SHAPE: { newComponent = new UIText(this); break; } case CLASS_ID.VIDEO_CLIP: { newComponent = new DCLVideoClip(this); break; } case CLASS_ID.VIDEO_TEXTURE: { newComponent = new DCLVideoTexture(this); break; } case CLASS_ID.FONT: { newComponent = new DCLFont(this); break; } default: Debug.LogError($"Unknown classId"); break; } if (newComponent != null) { newComponent.id = sharedComponentCreatedMessage.id; disposableComponents.Add(sharedComponentCreatedMessage.id, newComponent); if (state != State.READY) { disposableNotReady.Add(id); } } return(newComponent); }
public BaseDisposable SharedComponentCreate(string id, int classId) { BaseDisposable disposableComponent; if (disposableComponents.TryGetValue(id, out disposableComponent)) { return(disposableComponent); } BaseDisposable newComponent = null; switch ((CLASS_ID)classId) { case CLASS_ID.BOX_SHAPE: { newComponent = new BoxShape(this); break; } case CLASS_ID.SPHERE_SHAPE: { newComponent = new SphereShape(this); break; } case CLASS_ID.CONE_SHAPE: { newComponent = new ConeShape(this); break; } case CLASS_ID.CYLINDER_SHAPE: { newComponent = new CylinderShape(this); break; } case CLASS_ID.PLANE_SHAPE: { newComponent = new PlaneShape(this); break; } case CLASS_ID.GLTF_SHAPE: { newComponent = new GLTFShape(this); break; } case CLASS_ID.NFT_SHAPE: { newComponent = new NFTShape(this); break; } case CLASS_ID.OBJ_SHAPE: { newComponent = new OBJShape(this); break; } case CLASS_ID.BASIC_MATERIAL: { newComponent = new BasicMaterial(this); break; } case CLASS_ID.PBR_MATERIAL: { newComponent = new PBRMaterial(this); break; } case CLASS_ID.AUDIO_CLIP: { newComponent = new DCLAudioClip(this); break; } case CLASS_ID.TEXTURE: { newComponent = new DCLTexture(this); break; } case CLASS_ID.UI_INPUT_TEXT_SHAPE: { newComponent = new UIInputText(this); break; } case CLASS_ID.UI_FULLSCREEN_SHAPE: case CLASS_ID.UI_SCREEN_SPACE_SHAPE: { if (GetSharedComponent <UIScreenSpace>() == null) { newComponent = new UIScreenSpace(this); } break; } case CLASS_ID.UI_CONTAINER_RECT: { newComponent = new UIContainerRect(this); break; } case CLASS_ID.UI_SLIDER_SHAPE: { newComponent = new UIScrollRect(this); break; } case CLASS_ID.UI_CONTAINER_STACK: { newComponent = new UIContainerStack(this); break; } case CLASS_ID.UI_IMAGE_SHAPE: { newComponent = new UIImage(this); break; } case CLASS_ID.UI_TEXT_SHAPE: { newComponent = new UIText(this); break; } case CLASS_ID.VIDEO_CLIP: { newComponent = new DCLVideoClip(this); break; } case CLASS_ID.VIDEO_TEXTURE: { newComponent = new DCLVideoTexture(this); break; } case CLASS_ID.FONT: { newComponent = new DCLFont(this); break; } case CLASS_ID.NAME: { newComponent = new DCLName(this); break; } case CLASS_ID.LOCKED_ON_EDIT: { newComponent = new DCLLockedOnEdit(this); break; } case CLASS_ID.VISIBLE_ON_EDIT: { newComponent = new DCLVisibleOnEdit(this); break; } default: Debug.LogError($"Unknown classId"); break; } if (newComponent != null) { newComponent.id = id; disposableComponents.Add(id, newComponent); OnAddSharedComponent?.Invoke(id, newComponent); } return(newComponent); }