This repository has been archived by the owner on Sep 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from SynapseSL/development
v1.2.1 - Gamepatch
- Loading branch information
Showing
8 changed files
with
149 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -239,7 +239,7 @@ public Team Side | |
} | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// The Room where the player currently is | ||
/// </summary> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
using Synapse.Api; | ||
|
||
namespace Synapse.Events.Classes | ||
{ | ||
[SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Global")] | ||
public class PlayerThrowGrenadeEvent | ||
{ | ||
public Player Player { get; internal set; } | ||
|
||
public ItemType Grenade { get; internal set; } | ||
|
||
public bool Slow { get; set; } | ||
|
||
/// <summary> | ||
/// The time before the grenade gets launched. This value can not be higher than the throwingAnimationTime; | ||
/// </summary> | ||
public double FuseTime { get; set; } | ||
|
||
public bool Allow { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
Synapse/Events/Patches/EventPatches/PlayerPatches/PlayerThrowGrenadePatch.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using System; | ||
using Grenades; | ||
using Harmony; | ||
using Mirror; | ||
using Synapse.Api; | ||
|
||
namespace Synapse.Events.Patches | ||
{ | ||
[HarmonyPatch(typeof(GrenadeManager), nameof(GrenadeManager.CallCmdThrowGrenade))] | ||
public class PlayerThrowGrenadePatch | ||
{ | ||
public static bool Prefix(ref GrenadeManager __instance, ref int id, ref bool slowThrow, ref double time) | ||
{ | ||
try | ||
{ | ||
var player = __instance.GetPlayer(); | ||
if (player == null) return true; | ||
ItemType item; | ||
switch (id) | ||
{ | ||
case 0: | ||
item = ItemType.GrenadeFlash; | ||
break; | ||
case 1: | ||
item = ItemType.GrenadeFrag; | ||
break; | ||
case 2: | ||
item = ItemType.SCP018; | ||
break; | ||
default: | ||
Log.Error($"Invalid Grenade ID: {id}"); | ||
return true; | ||
} | ||
|
||
time -= NetworkTime.time; | ||
|
||
Events.InvokeUseItemEvent(player, item, out var useAllow); | ||
|
||
if (!useAllow) return false; | ||
|
||
Events.InvokePlayerThrowGrenadeEvent(player, item, ref slowThrow, ref time, out var allow); | ||
|
||
time += NetworkTime.time; | ||
|
||
return allow; | ||
|
||
} | ||
catch (Exception e) | ||
{ | ||
Log.Error($"Player Throw Grenade Error: {e}"); | ||
return true; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters