From c648c2bbc7c6720342df150da624b482dbc9867a Mon Sep 17 00:00:00 2001 From: TORISOUP Date: Sat, 6 Feb 2016 18:24:34 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=91=E3=83=AB=E3=83=97=E3=83=B3=E3=83=86?= =?UTF-8?q?=E5=8A=B9=E6=9E=9C=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Inferno/Inferno.csproj | 2 + .../InfernoScripts/InfernoCore/InfernoCore.cs | 6 ++ .../InfernoCore/InfernoScript.cs | 2 + .../Parupunte/Scripts/PerfectFreeze.cs | 88 +++++++++++++++++++ .../Parupunte/Scripts/VehicleSpeedUp.cs | 32 +++++++ 5 files changed, 130 insertions(+) create mode 100644 Inferno/InfernoScripts/Parupunte/Scripts/PerfectFreeze.cs create mode 100644 Inferno/InfernoScripts/Parupunte/Scripts/VehicleSpeedUp.cs diff --git a/Inferno/Inferno.csproj b/Inferno/Inferno.csproj index 67875065..6ab14839 100644 --- a/Inferno/Inferno.csproj +++ b/Inferno/Inferno.csproj @@ -110,6 +110,8 @@ + + diff --git a/Inferno/InfernoScripts/InfernoCore/InfernoCore.cs b/Inferno/InfernoScripts/InfernoCore/InfernoCore.cs index f56010c3..affb2a77 100644 --- a/Inferno/InfernoScripts/InfernoCore/InfernoCore.cs +++ b/Inferno/InfernoScripts/InfernoCore/InfernoCore.cs @@ -32,6 +32,11 @@ public sealed class InfernoCore : Script /// public ReactiveProperty PlayerPed = new ReactiveProperty(); + /// + /// プレイヤの乗ってる車両 + /// + public ReactiveProperty PlayerVehicle = new ReactiveProperty(); + /// /// 25ms周期のTick /// @@ -80,6 +85,7 @@ private void UpdatePedsAndVehiclesList() PlayerPed.Value = ped; PedsNearPlayer.Value = World.GetNearbyPeds(ped, 500); VehicleNearPlayer.Value = World.GetNearbyVehicles(ped, 500); + PlayerVehicle.Value = ped?.CurrentVehicle; } catch (Exception e) { diff --git a/Inferno/InfernoScripts/InfernoCore/InfernoScript.cs b/Inferno/InfernoScripts/InfernoCore/InfernoScript.cs index abe3d0bf..95cdf7cd 100644 --- a/Inferno/InfernoScripts/InfernoCore/InfernoScript.cs +++ b/Inferno/InfernoScripts/InfernoCore/InfernoScript.cs @@ -48,6 +48,7 @@ protected bool IsActive public Ped PlayerPed => cahcedPlayerPed ?? Game.Player.Character; private Ped cahcedPlayerPed; + public ReactiveProperty PlayerVehicle = new ReactiveProperty(); private Ped[] _cachedPeds = new Ped[0]; @@ -259,6 +260,7 @@ protected InfernoScript() 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); }); //TickイベントをObservable化しておく diff --git a/Inferno/InfernoScripts/Parupunte/Scripts/PerfectFreeze.cs b/Inferno/InfernoScripts/Parupunte/Scripts/PerfectFreeze.cs new file mode 100644 index 00000000..5b45ea2e --- /dev/null +++ b/Inferno/InfernoScripts/Parupunte/Scripts/PerfectFreeze.cs @@ -0,0 +1,88 @@ +using System.Collections.Generic; +using System.Linq; +using GTA; +using UniRx; + +namespace Inferno.InfernoScripts.Parupunte.Scripts +{ + class PerfectFreeze : ParupunteScript + { + public PerfectFreeze(ParupunteCore core) : base(core) + { + } + + private HashSet freezedEntities = new HashSet(); + + public override string Name { get; } = "パーフェクトフリーズ"; + public override string EndMessage { get; } = "おわり"; + private readonly float FreezeRange = 30; + + public override void OnStart() + { + ReduceCounter = new ReduceCounter(20 * 1000); + AddProgressBar(ReduceCounter); + ReduceCounter.OnFinishedAsync.Subscribe(_ => + { + ParupunteEnd(); + }); + + this.OnUpdateAsObservable + .Subscribe(_ => + { + var playerPos = core.PlayerPed.Position; + var playerVehicle = core.GetPlayerVehicle(); + + #region Vehicle + foreach (var v in core.CachedVehicles.Where( + x => x.IsSafeExist() + && !freezedEntities.Contains(x) + && x.IsInRangeOf(playerPos, FreezeRange) + && x.IsAlive + && x != playerVehicle)) + { + v.FreezePosition = true; + freezedEntities.Add(v); + } + #endregion + + #region props + var props = GTA.World.GetAllProps(); + foreach (var prop in props.Where(x => + x.IsSafeExist() + && !freezedEntities.Contains(x) + && x.IsInRangeOf(playerPos, FreezeRange) + )) + { + prop.FreezePosition = true; + freezedEntities.Add(prop); + } + #endregion + + //離れていたら解除 + var deleteTargets = freezedEntities.FirstOrDefault(x => + x.IsSafeExist() && !x.IsInRangeOf(playerPos, FreezeRange + 5)); + + if (deleteTargets != null) + { + deleteTargets.FreezePosition = false; + freezedEntities.Remove(deleteTargets); + } + + }); + + //プレイヤ車両は除外 + core.PlayerVehicle.Where(x => x.IsSafeExist()) + .Subscribe(x => x.FreezePosition = false); + + //終了時に全て解除 + this.OnFinishedAsObservable + .Subscribe(_ => + { + foreach (var x in freezedEntities.Where(x => x.IsSafeExist())) + { + x.FreezePosition = false; + } + }); + } + } +} diff --git a/Inferno/InfernoScripts/Parupunte/Scripts/VehicleSpeedUp.cs b/Inferno/InfernoScripts/Parupunte/Scripts/VehicleSpeedUp.cs new file mode 100644 index 00000000..bcf76cd2 --- /dev/null +++ b/Inferno/InfernoScripts/Parupunte/Scripts/VehicleSpeedUp.cs @@ -0,0 +1,32 @@ +using GTA.Math; +using GTA.Native; +using System.Linq; +using UniRx; + +namespace Inferno.InfernoScripts.Parupunte.Scripts +{ + internal class VehicleSpeedUp : ParupunteScript + { + public VehicleSpeedUp(ParupunteCore core) : base(core) + { + } + + public override string Name { get; } = "エンジンパワーアップ"; + + public override void OnSetUp() + { + } + + public override void OnStart() + { + foreach (var v in core.CachedVehicles.Where( + x => x.IsSafeExist() && x.IsAlive)) + { + v.EnginePowerMultiplier = 200.0f; + v.EngineTorqueMultiplier = 200.0f; + } + + ParupunteEnd(); + } + } +}