Skip to content

Commit

Permalink
パルプンテ効果追加
Browse files Browse the repository at this point in the history
  • Loading branch information
TORISOUP committed Feb 6, 2016
1 parent a903734 commit c648c2b
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Inferno/Inferno.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@
<Compile Include="InfernoScripts\Parupunte\Scripts\ExplodeDeadBodies.cs" />
<Compile Include="InfernoScripts\Parupunte\Scripts\FishHeaven.cs" />
<Compile Include="InfernoScripts\Parupunte\Scripts\FixPedsAndVehicles.cs" />
<Compile Include="InfernoScripts\Parupunte\Scripts\PerfectFreeze.cs" />
<Compile Include="InfernoScripts\Parupunte\Scripts\VehicleSpeedUp.cs" />
<Compile Include="InfernoScripts\Parupunte\Scripts\Gochiusa.cs" />
<Compile Include="InfernoScripts\Parupunte\Scripts\InvisiblePeds.cs" />
<Compile Include="InfernoScripts\Parupunte\Scripts\KillCitizens.cs" />
Expand Down
6 changes: 6 additions & 0 deletions Inferno/InfernoScripts/InfernoCore/InfernoCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ public sealed class InfernoCore : Script
/// </summary>
public ReactiveProperty<Ped> PlayerPed = new ReactiveProperty<Ped>();

/// <summary>
/// プレイヤの乗ってる車両
/// </summary>
public ReactiveProperty<Vehicle> PlayerVehicle = new ReactiveProperty<Vehicle>();

/// <summary>
/// 25ms周期のTick
/// </summary>
Expand Down Expand Up @@ -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)
{
Expand Down
2 changes: 2 additions & 0 deletions Inferno/InfernoScripts/InfernoCore/InfernoScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ protected bool IsActive
public Ped PlayerPed => cahcedPlayerPed ?? Game.Player.Character;

private Ped cahcedPlayerPed;
public ReactiveProperty<Vehicle> PlayerVehicle = new ReactiveProperty<Vehicle>();

private Ped[] _cachedPeds = new Ped[0];

Expand Down Expand Up @@ -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化しておく
Expand Down
88 changes: 88 additions & 0 deletions Inferno/InfernoScripts/Parupunte/Scripts/PerfectFreeze.cs
Original file line number Diff line number Diff line change
@@ -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<Entity> freezedEntities = new HashSet<Entity>();

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;
}
});
}
}
}
32 changes: 32 additions & 0 deletions Inferno/InfernoScripts/Parupunte/Scripts/VehicleSpeedUp.cs
Original file line number Diff line number Diff line change
@@ -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();
}
}
}

0 comments on commit c648c2b

Please sign in to comment.