public IUpdateStream <TDocument> Subscribe(UpdateStreamFilter updateStreamFilter,
                                                   CancellationToken cancellationToken = default)
        {
            var updateStream = new UpdateStream <TDocument>();

            PipelineDefinition <ChangeStreamDocument <TDocument>, ChangeStreamDocument <TDocument> > pipeline =
                new EmptyPipelineDefinition <ChangeStreamDocument <TDocument> >();


            pipeline = pipeline.Match(x =>
                                      x.OperationType == ChangeStreamOperationType.Update &&
                                      updateStreamFilter.UpdateTypes.HasFlag(UpdateTypes.Update) ||
                                      x.OperationType == ChangeStreamOperationType.Insert &&
                                      updateStreamFilter.UpdateTypes.HasFlag(UpdateTypes.Insert) ||
                                      x.OperationType == ChangeStreamOperationType.Delete &&
                                      updateStreamFilter.UpdateTypes.HasFlag(UpdateTypes.Delete) ||
                                      x.OperationType == ChangeStreamOperationType.Replace &&
                                      updateStreamFilter.UpdateTypes.HasFlag(UpdateTypes.Replace) ||
                                      updateStreamFilter.UpdateTypes == UpdateTypes.Undefined
                                      );


            if (updateStreamFilter.RtId.HasValue)
            {
                var filter = Builders <ChangeStreamDocument <TDocument> > .Filter.Eq("fullDocument." + Constants.IdField, updateStreamFilter.RtId.Value.ToObjectId());

                pipeline = pipeline.Match(filter);
            }

            updateStream.Watch(_documentCollection, pipeline, cancellationToken);
            return(updateStream);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Constructor for the TSUpdater class
        /// </summary>
        public TSUpdater()
        {
            state                    = UpdaterState.Waiting;
            timedCoroutines          = new List <TSTimedCoroutine>();
            previousTimeSinceStartup = DateTime.Now;

            LocalVersionJSON local;

            if (File.Exists(TSConstants.LocalJSONPath))
            {
                local = JsonUtility.FromJson <LocalVersionJSON>(File.ReadAllText(TSConstants.LocalJSONPath));
            }
            else
            {
                local           = new LocalVersionJSON();
                local.beta      = true;
                local.betaSha   = "";
                local.version   = "beta";
                local.lastCheck = DateTime.Now.ToString();
                File.WriteAllText(TSConstants.LocalJSONPath, JsonUtility.ToJson(local));
            }

            if (local.beta)
            {
                updateStream = UpdateStream.Beta;
            }
            else
            {
                updateStream = UpdateStream.Release;
            }
        }
Ejemplo n.º 3
0
    private void Start()
    {
        // 走行アニメーションを再生する
        BeginStream.Subscribe(_ => _animator.Play("Run"));

        // チュートリアルの文言を変更する
        BeginStream.Subscribe(_ => _tutorialText.text = "左クリックで待機ステートに遷移します");

        // 左クリックされたら待機ステートに遷移する
        UpdateStream.Where(_ => Input.GetMouseButtonDown(0))
        .Subscribe(_ => Transition <IdleState>());
    }
Ejemplo n.º 4
0
    private void Start()
    {
        // Play the running animation
        BeginStream.Subscribe(_ => _animator.Play("Run"));

        // Change the language of the tutorial
        BeginStream.Subscribe(_ => _tutorialText.text = "Transit to wait state with left click");

        // Transit to wait state when left clicked
        UpdateStream.Where(_ => Input.GetMouseButtonDown(0))
        .Subscribe(_ => Transition <IdleState>());
    }
Ejemplo n.º 5
0
    private void Start()
    {
        // アピールアニメーションを再生する
        BeginStream.Subscribe(_ => _animator.Play("Appeal"));

        // チュートリアルの文言を変更する
        BeginStream.Subscribe(_ => _tutorialText.text = (int)IdleState.TRANSITION_TO_APPEAL_DURATION + "秒経過したのでアピールステートに遷移しました");

        // アピールアニメーションの再生が完了したら待機ステートに遷移する
        UpdateStream.Where(_ => _animator.IsCompleted(Animator.StringToHash("Appeal")))
        .Subscribe(_ => Transition <IdleState>());

        // 右クリックされたら走行ステートに遷移する
        UpdateStream.Where(_ => Input.GetMouseButtonDown(0))
        .Subscribe(_ => Transition <RunState>());
    }
Ejemplo n.º 6
0
    private void Start()
    {
        // Play appeal animation
        BeginStream.Subscribe(_ => _animator.Play("Appeal"));

        // Change the language of the tutorial
        BeginStream.Subscribe(_ => _tutorialText.text =
                                  (int)IdleState.TRANSITION_TO_APPEAL_DURATION + "It has transitioned to the appeal state because seconds have passed");

        // Transition to the standby state when the play of the appeal animation is completed
        UpdateStream.Where(_ => _animator.IsCompleted(Animator.StringToHash("Appeal")))
        .Subscribe(_ => Transition <IdleState>());

        // Transit to driving state when left-clicked
        UpdateStream.Where(_ => Input.GetMouseButtonDown(0))
        .Subscribe(_ => Transition <RunState>());
    }
Ejemplo n.º 7
0
    private void Start()
    {
        // 待機アニメーションを再生する
        BeginStream.Subscribe(_ => _animator.Play("Idle"));

        // チュートリアルの文言を変更する
        BeginStream.Subscribe(_ => _tutorialText.text = "左クリックで走行ステートに遷移します");


        float counter = 0f;

        // n秒経過したらアピールステートに遷移する
        UpdateStream.Do(_ => counter += Time.deltaTime)
        .Where(count => counter > TRANSITION_TO_APPEAL_DURATION)
        .Subscribe(_ => Transition <AppealState>());

        // 左クリックされたら走行ステートに遷移する
        UpdateStream.Where(_ => Input.GetMouseButtonDown(0))
        .Subscribe(_ => Transition <RunState>());

        // ステート遷移を行うときカウンタをリセットする
        EndStream.Subscribe(_ => counter = 0f);
    }
Ejemplo n.º 8
0
    private void Start()
    {
        // Play idle animation
        BeginStream.Subscribe(_ => _animator.Play("Idle"));

        // Change the language of the tutorial
        BeginStream.Subscribe(_ => _tutorialText.text = "Transit to driving state with left click");


        float counter = 0f;

        // Transit to appeal state after n seconds
        UpdateStream.Do(_ => counter += Time.deltaTime)
        .Where(count => counter > TRANSITION_TO_APPEAL_DURATION)
        .Subscribe(_ => Transition <AppealState>());

        // Transit to driving state when left-clicked
        UpdateStream.Where(_ => Input.GetMouseButtonDown(0))
        .Subscribe(_ => Transition <RunState>());

        // Reset counter when performing state transition
        EndStream.Subscribe(_ => counter = 0f);
    }