Skip to content

Commit

Permalink
Merge pull request #42 from TORISOUP/add_speed_max
Browse files Browse the repository at this point in the history
SpeedMax!
  • Loading branch information
TORISOUP committed Feb 18, 2016
2 parents c648c2b + 8e84c31 commit 001a6e6
Show file tree
Hide file tree
Showing 7 changed files with 260 additions and 72 deletions.
1 change: 1 addition & 0 deletions Inferno/Inferno.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@
<Compile Include="InfernoScripts\World\ChaosHeli.cs" />
<Compile Include="InfernoScripts\World\Fulton.cs" />
<Compile Include="InfernoScripts\World\Meteo.cs" />
<Compile Include="InfernoScripts\World\SpeedMax.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UniRx\Asynchronous\WebRequestExtensions.cs" />
<Compile Include="UniRx\Disposables\BooleanDisposable.cs" />
Expand Down
12 changes: 12 additions & 0 deletions Inferno/InfernoScripts/InfernoCore/CoroutineSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Markup.Localizer;

namespace Inferno
{
Expand Down Expand Up @@ -57,6 +58,17 @@ public void RemoveCoroutine(uint id)
}
}

/// <summary>
/// 全てのコルーチンを停止する
/// </summary>
public void RemoveAllCoroutine()
{
lock (_lockObject)
{
_coroutines.Clear();
}
}

/// <summary>
/// コルーチンが存在するかどうかチェックする
/// </summary>
Expand Down
10 changes: 6 additions & 4 deletions Inferno/InfernoScripts/InfernoCore/InfernoScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,12 @@ protected uint StartCoroutine(IEnumerable<Object> coroutine)

protected void StopCoroutine(uint id)
{
if (coroutineSystem != null)
{
coroutineSystem.RemoveCoroutine(id);
}
coroutineSystem?.RemoveCoroutine(id);
}

protected void StopAllCoroutine()
{
coroutineSystem?.RemoveAllCoroutine();
}

protected bool IsCoroutineActive(uint id)
Expand Down
1 change: 1 addition & 0 deletions Inferno/InfernoScripts/Parupunte/Scripts/Isono.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace Inferno.InfernoScripts.Parupunte.Scripts
{

internal class Isono : ParupunteScript
{
public Isono(ParupunteCore core) : base(core)
Expand Down
40 changes: 16 additions & 24 deletions Inferno/InfernoScripts/Parupunte/Scripts/PerfectFreeze.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using GTA;
using UniRx;
Expand All @@ -15,11 +16,11 @@ public PerfectFreeze(ParupunteCore core) : base(core)

public override string Name { get; } = "パーフェクトフリーズ";
public override string EndMessage { get; } = "おわり";
private readonly float FreezeRange = 30;
private readonly float FreezeRange = 60;

public override void OnStart()
{
ReduceCounter = new ReduceCounter(20 * 1000);
ReduceCounter = new ReduceCounter(15 * 1000);
AddProgressBar(ReduceCounter);
ReduceCounter.OnFinishedAsync.Subscribe(_ =>
{
Expand All @@ -32,42 +33,33 @@ public override void OnStart()
var playerPos = core.PlayerPed.Position;
var playerVehicle = core.GetPlayerVehicle();

#region Vehicle
foreach (var v in core.CachedVehicles.Where(

#region Ped
foreach (var p in core.CachedPeds.Where(
x => x.IsSafeExist()
&& !freezedEntities.Contains(x)
&& x.IsInRangeOf(playerPos, FreezeRange)
&& x.IsAlive
&& x != playerVehicle))
{
v.FreezePosition = true;
freezedEntities.Add(v);
p.FreezePosition = true;
freezedEntities.Add(p);
}
#endregion

#region props
var props = GTA.World.GetAllProps();
foreach (var prop in props.Where(x =>
x.IsSafeExist()
#region Vehicle
foreach (var v in core.CachedVehicles.Where(
x => x.IsSafeExist()
&& !freezedEntities.Contains(x)
&& x.IsInRangeOf(playerPos, FreezeRange)
))
&& x.IsAlive
&& x != playerVehicle))
{
prop.FreezePosition = true;
freezedEntities.Add(prop);
v.FreezePosition = true;
freezedEntities.Add(v);
}
#endregion

//離れていたら解除
var deleteTargets = freezedEntities.FirstOrDefault(x =>
x.IsSafeExist() && !x.IsInRangeOf(playerPos, FreezeRange + 5));

if (deleteTargets != null)
{
deleteTargets.FreezePosition = false;
freezedEntities.Remove(deleteTargets);
}

});

//プレイヤ車両は除外
Expand Down
88 changes: 44 additions & 44 deletions Inferno/InfernoScripts/Player/ArmorAndHealthSupplier.cs
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
using GTA;
using UniRx;

namespace Inferno
{
internal class ArmorAndHealthSupplier : InfernoScript
using UniRx;

namespace Inferno
{
internal class ArmorAndHealthSupplier : InfernoScript
{
protected override void Setup()
protected override void Setup()
{
CreateInputKeywordAsObservable("armor")
.Subscribe(_ =>
{
IsActive = !IsActive;
DrawText("SupplyArmorAndHealth:" + IsActive, 3.0f);
});

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

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

//プレイヤが復活した時
OnTickAsObservable
.Where(_ => IsActive && PlayerPed.IsSafeExist())
.Select(_ => PlayerPed.IsAlive)
.DistinctUntilChanged()
.Skip(1) //ONにした直後の判定結果は無視
.Where(x => x)
.Subscribe(_ => SupplyArmorAndHealth());
CreateInputKeywordAsObservable("armor")
.Subscribe(_ =>
{
IsActive = !IsActive;
DrawText("SupplyArmorAndHealth:" + IsActive, 3.0f);
});

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

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

//プレイヤが復活した時
OnTickAsObservable
.Where(_ => IsActive && PlayerPed.IsSafeExist())
.Select(_ => PlayerPed.IsAlive)
.DistinctUntilChanged()
.Skip(1) //ONにした直後の判定結果は無視
.Where(x => x)
.Subscribe(_ => SupplyArmorAndHealth());
}

/// <summary>
/// 体力とアーマー回復
/// </summary>
private void SupplyArmorAndHealth()
{
var player = PlayerPed;
var maxHealth = player.MaxHealth;
var maxArmor = Game.Player.GetPlayerMaxArmor();
player.Health = maxHealth;
player.Armor = maxArmor;
}
}
}
/// <summary>
/// 体力とアーマー回復
/// </summary>
private void SupplyArmorAndHealth()
{
var player = PlayerPed;
var maxHealth = player.MaxHealth;
var maxArmor = Game.Player.GetPlayerMaxArmor();
player.Health = maxHealth;
player.Armor = maxArmor;
}
}
}
Loading

0 comments on commit 001a6e6

Please sign in to comment.