Beispiel #1
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
        }
Beispiel #2
0
        protected override void Setup()
        {
            //敵対関係のグループを作成
            chaosRelationShipId = World.AddRelationshipGroup("Inferno:ChaosPeds");

            var chaosSettingLoader = new ChaosModeSettingLoader();

            chaosModeSetting = chaosSettingLoader.LoadSettingFile(@"ChaosMode_Default.conf");

            chaosChecker = new CharacterChaosChecker(chaosModeSetting.DefaultMissionCharacterTreatment,
                                                     chaosModeSetting.IsChangeMissionCharacterWeapon);

            defaultWeaponProvider = new CustomWeaponProvider(chaosModeSetting.WeaponList, chaosModeSetting.WeaponListForDriveBy);

            //キーワードが入力されたらON/OFFを切り替える
            CreateInputKeywordAsObservable(Keyword)
            .Subscribe(_ =>
            {
                IsActive = !IsActive;
                chaosedPedList.Clear();
                StopAllChaosCoroutine();
                if (IsActive)
                {
                    DrawText("ChaosMode:On/" + currentTreatType.ToString(), 3.0f);
                    World.SetRelationshipBetweenGroups(Relationship.Hate, chaosRelationShipId, PlayerPed.RelationshipGroup);
                }
                else
                {
                    DrawText("ChaosMode:Off", 3.0f);
                    World.SetRelationshipBetweenGroups(Relationship.Neutral, chaosRelationShipId, PlayerPed.RelationshipGroup);
                }
            });

            nextTreatType = currentTreatType;

            //F7でキャラカオスの切り替え(暫定
            OnKeyDownAsObservable
            .Where(x => IsActive && x.KeyCode == Keys.F7)
            .Do(_ =>
            {
                nextTreatType = (MissionCharacterTreatmentType)(((int)nextTreatType + 1) % 3);
                DrawText("CharacterChaos:" + nextTreatType.ToString(), 1.1f);
            })
            .Throttle(TimeSpan.FromSeconds(1))
            .Subscribe(_ =>
            {
                currentTreatType = nextTreatType;
                chaosChecker.MissionCharacterTreatment = nextTreatType;
                DrawText("CharacterChaos:" + currentTreatType.ToString() + "[OK]", 3.0f);
                chaosedPedList.Clear();
                StopAllChaosCoroutine();
            });

            //interval設定
            Interval = chaosModeSetting.Interval;

            var oneSecondTich = CreateTickAsObservable(TimeSpan.FromSeconds(1));

            //市民をカオス化する
            oneSecondTich
            .Where(_ => IsActive && PlayerPed.IsSafeExist() && PlayerPed.IsAlive)
            .Subscribe(_ => CitizenChaos());

            //プレイヤが死んだらリセット
            oneSecondTich
            .Where(_ => PlayerPed.IsSafeExist())
            .Select(_ => PlayerPed.IsDead)
            .DistinctUntilChanged()
            .Where(x => x)
            .Subscribe(_ =>
            {
                chaosedPedList.Clear();
                StopAllChaosCoroutine();
            });

            oneSecondTich
            .Where(_ => IsActive)
            .Subscribe(_ => NativeFunctions.SetAllRandomPedsFlee(Game.Player, false));

            //イベントが来たら武器を変更する
            OnRecievedInfernoEvent
            .OfType <IEventMessage, ChasoModeEvent>()
            .Subscribe(e =>
            {
                if (e is ChangeToDefaultEvent)
                {
                    singleWeaponProvider = null;
                }
                else if (e is ChangeWeaponEvent)
                {
                    var s = (ChangeWeaponEvent)e;
                    singleWeaponProvider = new SingleWeaponProvider(s.Weapon);
                }
            });
        }