public static IUniTaskSource <T> Create(ReadOnlyAsyncReactiveProperty <T> parent, CancellationToken cancellationToken, out short token)
            {
                if (cancellationToken.IsCancellationRequested)
                {
                    return(AutoResetUniTaskCompletionSource <T> .CreateFromCanceled(cancellationToken, out token));
                }

                if (!pool.TryPop(out var result))
                {
                    result = new WaitAsyncSource();
                }

                result.parent            = parent;
                result.cancellationToken = cancellationToken;

                if (cancellationToken.CanBeCanceled)
                {
                    result.cancellationTokenRegistration = cancellationToken.RegisterWithoutCaptureExecutionContext(cancellationCallback, result);
                }

                result.parent.triggerEvent.Add(result);

                TaskTracker.TrackActiveTask(result, 3);

                token = result.core.Version;
                return(result);
            }
Ejemplo n.º 2
0
 private void BindControllableHealth(ReadOnlyAsyncReactiveProperty <float> healthStream)
 {
     controllableHealthBarCg.alpha = 1;
     controllableHealthStreamToken?.Cancel();
     controllableHealthStreamToken =
         CancellationTokenSource.CreateLinkedTokenSource(this.GetCancellationTokenOnDestroy());
     healthStream.Subscribe(UpdateControllableHealth, controllableHealthStreamToken.Token);
 }
Ejemplo n.º 3
0
 public PlayerStreams(PlayerState playerState)
 {
     this.playerState = playerState;
     countStream      = UniTaskAsyncEnumerable
                        .EveryValueChanged(playerState, s => s.players.Count)
                        .Select(_ => playerState.players.Select(x => x.id))
                        .ToReadOnlyAsyncReactiveProperty(cts.Token);
 }
 bool TryReturn()
 {
     TaskTracker.RemoveTracking(this);
     core.Reset();
     cancellationTokenRegistration.Dispose();
     cancellationTokenRegistration = default;
     parent.triggerEvent.Remove(this);
     parent            = null;
     cancellationToken = default;
     return(pool.TryPush(this));
 }
            public Enumerator(ReadOnlyAsyncReactiveProperty <T> parent, CancellationToken cancellationToken, bool publishCurrentValue)
            {
                this.parent            = parent;
                this.cancellationToken = cancellationToken;
                this.firstCall         = publishCurrentValue;

                parent.triggerEvent.Add(this);
                TaskTracker.TrackActiveTask(this, 3);

                if (cancellationToken.CanBeCanceled)
                {
                    cancellationTokenRegistration = cancellationToken.RegisterWithoutCaptureExecutionContext(cancellationCallback, this);
                }
            }
 public PantiePatchEditorConvertWindow()
 {
     CanStartConvert = UniTaskAsyncEnumerable.CombineLatest(ConvertTexture, SelectedAvatarIndex, ConvertRunning,
                                                            (convertTexture, selectedAvatarIndex, convertRunning) =>
                                                            convertTexture != null && selectedAvatarIndex != -1 && !convertRunning)
                       .ToReadOnlyAsyncReactiveProperty(default);
 public WithoutCurrentEnumerable(ReadOnlyAsyncReactiveProperty <T> parent)
 {
     this.parent = parent;
 }
 public PantiePatchEditorDLWindow()
 {
     GUIDisable = UniTaskAsyncEnumerable.CombineLatest(DownloadingDreams, UpdatingAvatars, (a, b) => a | b).ToReadOnlyAsyncReactiveProperty(default);