protected override void Setup()
        {
            //0.3秒間押しっぱなしなら発動
            OnThinnedTickAsObservable
            .Select(_ => !this.GetPlayerVehicle().IsSafeExist() &&
                    !_isGriped &&
                    this.IsGamePadPressed(GameKey.Reload)
                    ).Buffer(3, 1)
            .Where(x => x.All(v => v))
            .Subscribe(_ => GripAction());

            OnThinnedTickAsObservable
            .Where(_ => _isGriped)
            .Subscribe(_ =>
            {
                Grip(PlayerPed, _vehicle, _ofsetPosition);
            });

            OnThinnedTickAsObservable
            .Where(_ => _isGriped && (!this.IsGamePadPressed(GameKey.Reload) || PlayerPed.IsDead))
            .Subscribe(_ => GripRemove());

            this.OnAbortAsync.Subscribe(_ =>
            {
                SetPlayerProof(false);
            });
        }
示例#2
0
        protected override void Setup()
        {
            pPed.Add(PlayerPed);

            //キーワードが入力されたらON/OFFを切り替える
            CreateInputKeywordAsObservable(Keyword)
            .Subscribe(_ =>
            {
                IsActive = !IsActive;
                DrawText("BombBat:" + IsActive, 3.0f);
            });

            OnAllOnCommandObservable.Subscribe(_ => IsActive = true);

            //interval間隔で実行
            OnThinnedTickAsObservable
            .Where(_ => IsActive)
            .Subscribe(p =>
            {
                foreach (var ped in CachedPeds)
                {
                    if (!ped.IsSafeExist())
                    {
                        continue;
                    }
                    BomBatAction(ped);
                }

                BomBatAction(PlayerPed);
            });
        }
示例#3
0
        protected override void Setup()
        {
            CreateInputKeywordAsObservable("fulton")
            .Subscribe(_ =>
            {
                IsActive = !IsActive;
                DrawText("Fulton:" + IsActive, 3.0f);
            });

            OnAllOnCommandObservable.Subscribe(_ => IsActive = true);

            OnKeyDownAsObservable
            .Where(x => IsActive && x.KeyCode == Keys.F9 && motherbaseVeh.Count > 0)
            .Subscribe(_ => SpawnVehicle());

            OnKeyDownAsObservable
            .Where(x => IsActive && x.KeyCode == Keys.F10 && motherBasePeds.Count > 0)
            .Subscribe(_ => SpawnCitizen());

            CreateTickAsObservable(TimeSpan.FromSeconds(0.5))
            .Where(_ => IsActive && !Function.Call <bool>(Hash.IS_CUTSCENE_ACTIVE))
            .Subscribe(_ => FulutonUpdate());

            //プレイヤが死んだらリストクリア
            OnThinnedTickAsObservable
            .Select(_ => PlayerPed.IsDead)
            .DistinctUntilChanged()
            .Where(x => x)
            .Subscribe(_ => fulutonedEntityList.Clear());
            SetUpSound();
        }
        protected override void Setup()
        {
            CreateInputKeywordAsObservable("armor")
            .Subscribe(_ =>
            {
                IsActive = !IsActive;
                DrawText("SupplyArmorAndHealth:" + IsActive, 3.0f);
            });

            OnAllOnCommandObservable.Subscribe(_ => IsActive = true);

            //ミッションが始まった時
            OnThinnedTickAsObservable
            .Where(_ => IsActive)
            .Select(_ => Game.MissionFlag)
            .DistinctUntilChanged()
            .Where(x => x)
            .Subscribe(_ => SupplyArmorAndHealth());

            //プレイヤが復活した時
            OnThinnedTickAsObservable
            .Where(_ => IsActive && PlayerPed.IsSafeExist())
            .Select(_ => PlayerPed.IsAlive)
            .DistinctUntilChanged()
            .Skip(1)     //ONにした直後の判定結果は無視
            .Where(x => x)
            .Subscribe(_ => SupplyArmorAndHealth());
        }
示例#5
0
        protected override void Setup()
        {
            conf = LoadConfig <EmergencyEscapeConf>();

            OnThinnedTickAsObservable
            .Where(_ => this.IsGamePadPressed(GameKey.VehicleHorn) && this.IsGamePadPressed(GameKey.VehicleExit))
            .Subscribe(_ => EscapeVehicle());
        }
示例#6
0
        protected override void Setup()
        {
            filePaths = LoadWavFilePaths(@"scripts/SpecialAbilityBgm");

            if (filePaths.Length <= 0)
            {
                return;
            }

            soundPlayer = new SoundPlayer {
                SoundLocation = filePaths[Random.Next(filePaths.Length)]
            };

            CreateInputKeywordAsObservable("sbmg")
            .Subscribe(_ =>
            {
                IsActive = !IsActive;
                DrawText("SpecialAbilityBGM:" + IsActive, 3.0f);
            });

            OnAllOnCommandObservable.Subscribe(_ => IsActive = true);

            OnThinnedTickAsObservable
            .Where(_ => IsActive && (uint)PlayerPed.Model.Hash == (uint)PedHash.Trevor)
            .Select(_ => Game.Player.IsSpecialAbilityActive() && PlayerPed.IsAlive)
            .DistinctUntilChanged()
            .Subscribe(x =>
            {
                if (x)
                {
                    soundPlayer.Play();
                }
                else
                {
                    soundPlayer.Stop();
                    //次の音をセット
                    soundPlayer.SoundLocation = filePaths[Random.Next(filePaths.Length)];
                    soundPlayer.LoadAsync();
                }
            });
        }
示例#7
0
        protected override void Setup()
        {
            config = LoadConfig <BondCarConfig>();

            OnThinnedTickAsObservable
            .Where(_ =>
                   PlayerVehicle.Value.IsSafeExist() &&
                   this.IsGamePadPressed(GameKey.VehicleAim) &&
                   this.IsGamePadPressed(GameKey.VehicleAttack) &&
                   PlayerPed.Weapons.Current.Hash == WeaponHash.Unarmed
                   )
            .ThrottleFirst(TimeSpan.FromMilliseconds(CoolDownMillSeconds), InfernoScriptScheduler)
            .Subscribe(_ =>
            {
                var v = PlayerVehicle.Value;
                //そこら辺の市民のせいにする
                var ped = CachedPeds.Where(x => x.IsSafeExist()).DefaultIfEmpty(PlayerPed).FirstOrDefault();
                StartCoroutine(InvincibleVehicle(v, 2));
                CreateRpgBullet(v, ped, 1.5f);
                CreateRpgBullet(v, ped, -1.5f);
                v.EngineHealth *= 0.9f;
            });
        }
示例#8
0
        protected override void Setup()
        {
            filePath = LoadWavFiles(@"scripts/Pichun");

            soundPlayer = new SoundPlayer();
            //音声ファイルロード完了時に再生する
            soundPlayer.LoadCompleted += (sender, args) =>
            {
                soundPlayer.Play();
            };

            //ファイルが存在した時のみ
            if (filePath.Length > 0)
            {
                //プレイヤが死亡したら再生
                OnThinnedTickAsObservable
                .Select(_ => PlayerPed)
                .Where(p => p.IsSafeExist())
                .Select(p => p.IsAlive)
                .DistinctUntilChanged()
                .Where(isAlive => !isAlive)
                .Subscribe(_ => PlayAction());
            }
        }
        protected override void Setup()
        {
            CreateInputKeywordAsObservable("snax")
            .Subscribe(_ => IsActive = !IsActive);

            IsActiveAsObservable
            .Where(x => x)
            .Subscribe(x =>
            {
                DrawText($"SpeedMax:{IsActive}[Type:{(currentSpeedType)}][Exclude:{excludeMissionVehicle}]");
                vehicleHashSet.Clear();
            });

            IsActiveAsObservable
            .Skip(1)
            .Where(x => !x)
            .Subscribe(x =>
            {
                DrawText($"SpeedMax:{IsActive}");
                vehicleHashSet.Clear();
            });

            //ミッション開始直後に一瞬動作を止めるフラグ
            var suspednFlag = false;

            OnThinnedTickAsObservable
            .Where(_ => IsActive && !suspednFlag)
            .Subscribe(_ =>
            {
                foreach (var v in CachedVehicles
                         .Where(x =>
                                x.IsSafeExist() &&
                                x.IsInRangeOf(PlayerPed.Position, 100.0f) &&
                                !vehicleHashSet.Contains(x.Handle) &&
                                !(excludeMissionVehicle && x.IsPersistent)
                                ))
                {
                    vehicleHashSet.Add(v.Handle);
                    if (currentSpeedType == SpeedType.Original)
                    {
                        StartCoroutine(OriginalSpeedMaxCoroutine(v));
                    }
                    else
                    {
                        StartCoroutine(VehicleSpeedMaxCorutine(v));
                    }
                }
            });
            var nextType = currentSpeedType;

            OnKeyDownAsObservable
            .Where(x => IsActive && x.KeyCode == Keys.F6)
            .Do(_ =>
            {
                nextType = GetNextSpeedType(nextType);
                DrawText($"SpeedMax:[Type:{nextType}]", 1.0f);
            })
            .Throttle(TimeSpan.FromSeconds(1))
            .Subscribe(_ =>
            {
                currentSpeedType = nextType;
                DrawText($"SpeedMax:[Type:{(currentSpeedType)}][OK]", 2.0f);
                StopAllCoroutine();
                vehicleHashSet.Clear();
            });

            OnKeyDownAsObservable
            .Where(x => IsActive && x.KeyCode == Keys.F5)
            .Subscribe(_ =>
            {
                excludeMissionVehicle = !excludeMissionVehicle;
                vehicleHashSet.Clear();
                StopAllCoroutine();
                DrawText($"SpeedMax:ExcludeMissionVehicles[{excludeMissionVehicle}]");
            });

            OnThinnedTickAsObservable
            .Where(_ => IsActive)
            .Select(_ => PlayerPed.IsAlive)
            .DistinctUntilChanged()
            .Where(x => x)
            .Subscribe(_ => vehicleHashSet.Clear());

            //ミッションが始まった時にしばらく動作を止める
            OnThinnedTickAsObservable
            .Where(_ => IsActive)
            .Select(_ => Game.MissionFlag)
            .DistinctUntilChanged()
            .Where(x => x)
            .Do(_ => suspednFlag = true)
            .Delay(TimeSpan.FromSeconds(3))
            .Subscribe(_ => suspednFlag = false);
        }
示例#10
0
        protected override void Setup()
        {
            IsActive  = false;
            timerText = new TimerUiTextManager(this);

            #region ParunteScripts

            //RefrectionでParupunteScriptを継承しているクラスをすべて取得する
            _parupunteScritpts =
                Assembly.GetExecutingAssembly()
                .GetTypes()
                .Where(type => type.BaseType != null && type.BaseType == typeof(ParupunteScript))
                .Where(x =>
            {
                var attribute = x.GetCustomAttribute <ParupunteDebug>();
                return(attribute == null || !attribute.IsIgnore);
            })
                .ToArray();

            _debugParuputeScripts = _parupunteScritpts.Where(x =>
            {
                var attribute = x.GetCustomAttribute <ParupunteDebug>();
                return(attribute != null && attribute.IsDebug);
            }).ToArray();


            #endregion ParunteScripts

            #region Config

            SetConfigData(_parupunteScritpts);

            #endregion

            #region EventHook

            CreateInputKeywordAsObservable("rnt")
            .Where(_ => !IsActive)
            .Subscribe(_ => ParupunteStart(ChooseParupounteScript()));

            CreateInputKeywordAsObservable("snt")
            .Where(_ => IsActive)
            .Subscribe(_ => ParupunteStop());

            OnKeyDownAsObservable.Where(x => x.KeyCode == Keys.NumPad0)
            .ThrottleFirst(TimeSpan.FromSeconds(2f), InfernoScriptScheduler)
            .Subscribe(_ =>
            {
                if (IsActive)
                {
                    ParupunteStop();
                }
                else
                {
                    ParupunteStart(ChooseParupounteScript());
                }
            });

            //パルプンテが停止したタイミングで開放
            IsActiveAsObservable
            .Where(x => !x)
            .Subscribe(_ =>
            {
                foreach (var entity in _autoReleaseEntitiesList.Where(entity => entity.IsSafeExist()))
                {
                    entity.MarkAsNoLongerNeeded();
                }
                _autoReleaseEntitiesList.Clear();
            });

            var nextIsonoTime = Time;

            OnRecievedInfernoEvent
            .OfType <IEventMessage, IsonoMessage>()
            .Where(_ => (nextIsonoTime - Time).Ticks <= 0)
            .Retry()
            .Subscribe(c =>
            {
                var r = IsonoMethod(c.Command);
                if (r)
                {
                    nextIsonoTime = Time.Add(TimeSpan.FromSeconds(4));
                }
            });

            #endregion EventHook

            #region Drawer

            var screenResolution = NativeFunctions.GetScreenResolution();
            _screenHeight        = (int)screenResolution.Y;
            _screenWidth         = (int)screenResolution.X;
            _mainTextUiContainer = new UIContainer(
                new Point(0, 0), new Size(_screenWidth, _screenHeight));
            _subTextUiContainer = new UIContainer(
                new Point(0, 0), new Size(_screenWidth, _screenHeight));

            //テキストが更新されたら詰め直す
            timerText.OnSetTextAsObservable.Subscribe(_ =>
            {
                _mainTextUiContainer.Items.Clear();
                _mainTextUiContainer.Items.Add(timerText.Text);
            });
            //テキストが時間切れしたら消す
            OnThinnedTickAsObservable.Select(_ => timerText.IsEnabled)
            .DistinctUntilChanged()
            .Where(x => !x)
            .Subscribe(_ => _mainTextUiContainer.Items.Clear());

            this.OnDrawingTickAsObservable
            .Where(_ => _mainTextUiContainer.Items.Any() || _subTextUiContainer.Items.Any())
            .Subscribe(_ =>
            {
                _mainTextUiContainer.Draw();
                _subTextUiContainer.Draw();
            });

            #endregion Drawer
        }
示例#11
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        protected InfernoScript()
        {
            Interval = 16;

            //初期化をちょっと遅延させる
            Observable.Interval(TimeSpan.FromMilliseconds(10))
            .Where(_ => InfernoCore.Instance != null)
            .First()
            .Subscribe(_ =>
            {
                InfernoCore.Instance.PedsNearPlayer.Subscribe(x => _cachedPeds        = x);
                InfernoCore.Instance.VehicleNearPlayer.Subscribe(x => _cachedVehicles = x);
                InfernoCore.Instance.PlayerPed.Subscribe(x => cahcedPlayerPed         = x);
                InfernoCore.Instance.PlayerVehicle.Subscribe(x => PlayerVehicle.Value = x);
            });

            OnTickAsObservable =
                Observable.FromEventPattern <EventHandler, EventArgs>(h => h.Invoke, h => Tick += h, h => Tick -= h)
                .Select(_ => Unit.Default).Share();     //Subscribeされたらイベントハンドラを登録する

            OnThinnedTickAsObservable =
                OnTickAsObservable.ThrottleFirst(TimeSpan.FromMilliseconds(100), InfernoScriptScheduler)
                .Share();

            OnDrawingTickAsObservable = DrawingCore.OnDrawingTickAsObservable;

            OnAllOnCommandObservable = CreateInputKeywordAsObservable("allon");

            //スケジューラ実行
            OnTickAsObservable.Subscribe(_ => infernoScheduler?.Run());

            // SynchronizationContextの実行
            OnTickAsObservable
            .Subscribe(_ =>
            {
                if (SynchronizationContext.Current == null)
                {
                    SynchronizationContext.SetSynchronizationContext(InfernoSynchronizationContext);
                }
                InfernoSynchronizationContext.Update();
            });

            //タイマのカウント
            OnThinnedTickAsObservable
            .Where(_ => _counterList.Any())
            .Subscribe(_ =>
            {
                foreach (var c in _counterList)
                {
                    c.Update(100);
                }
                //完了状態にあるタイマを全て削除
                _counterList.RemoveAll(x => x.IsCompleted);
            });

            _coroutinePool = new CoroutinePool(5);

            //コルーチンを実行する
            CreateTickAsObservable(TimeSpan.FromMilliseconds(_coroutinePool.ExpectExecutionInterbalMillSeconds))
            .Subscribe(_ => _coroutinePool.Run());


            OnAbortAsync.Subscribe(_ =>
            {
                IsActive = false;
                foreach (var e in _autoReleaseEntities.Where(x => x.IsSafeExist()))
                {
                    e.MarkAsNoLongerNeeded();
                }
                _autoReleaseEntities.Clear();
            });

            try
            {
                Setup();
            }
            catch (Exception e)
            {
                LogWrite(e.ToString());
            }
        }