diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs
index f4d7794..f0f3833 100644
--- a/Synapse/Api/Player.cs
+++ b/Synapse/Api/Player.cs
@@ -239,7 +239,7 @@ public Team Side
}
}
}
-
+
///
/// The Room where the player currently is
///
diff --git a/Synapse/Events/Classes/PlayerThrowGrenadeEvent.cs b/Synapse/Events/Classes/PlayerThrowGrenadeEvent.cs
new file mode 100644
index 0000000..a81189d
--- /dev/null
+++ b/Synapse/Events/Classes/PlayerThrowGrenadeEvent.cs
@@ -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; }
+
+ ///
+ /// The time before the grenade gets launched. This value can not be higher than the throwingAnimationTime;
+ ///
+ public double FuseTime { get; set; }
+
+ public bool Allow { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/Synapse/Events/Patches/EventPatches/MapPatches/DoorInteractPatch.cs b/Synapse/Events/Patches/EventPatches/MapPatches/DoorInteractPatch.cs
index 647ec22..d59cad1 100644
--- a/Synapse/Events/Patches/EventPatches/MapPatches/DoorInteractPatch.cs
+++ b/Synapse/Events/Patches/EventPatches/MapPatches/DoorInteractPatch.cs
@@ -11,23 +11,41 @@ public class DoorInteractPatch
{
public static bool Prefix(PlayerInteract __instance, GameObject doorId)
{
- var allowTheAccess = true;
- Door door = null;
try
{
- if (!__instance._playerInteractRateLimit.CanExecute() ||
- (__instance._hc.CufferId > 0 && !PlayerInteract.CanDisarmedInteract) || doorId == null ||
- __instance._ccm.CurClass == RoleType.None || __instance._ccm.CurClass == RoleType.Spectator ||
- !doorId.TryGetComponent(out door) || !((door.Buttons.Count == 0)
- ? __instance.ChckDis(doorId.transform.position)
- : door.Buttons.Any(item => __instance.ChckDis(item.button.transform.position)))) return false;
+ var allowTheAccess = true;
+ Door door = null;
+
+ if (!__instance._playerInteractRateLimit.CanExecute() || (__instance._hc.CufferId > 0 && !PlayerInteract.CanDisarmedInteract))
+ {
+ return false;
+ }
+
+ if (doorId == null)
+ {
+ return false;
+ }
+
+ if (__instance._ccm.CurClass == RoleType.None || __instance._ccm.CurClass == RoleType.Spectator)
+ {
+ return false;
+ }
+
+ if (!doorId.TryGetComponent(out door))
+ {
+ return false;
+ }
+
+ if ((door.Buttons.Count == 0) ? (!__instance.ChckDis(doorId.transform.position)) : Enumerable.All(door.Buttons, item => !__instance.ChckDis(item.button.transform.position)))
+ {
+ return false;
+ }
+
__instance.OnInteract();
- if (__instance._sr.BypassMode) {}
- else if (door.PermissionLevels.HasPermission(Door.AccessRequirements.Checkpoints) &&
- __instance._ccm.CurRole.team == Team.SCP) {}
- else
+ if (!__instance._sr.BypassMode && !(door.PermissionLevels.HasPermission(Door.AccessRequirements.Checkpoints) &&
+ __instance._ccm.CurRole.team == Team.SCP))
{
try
{
@@ -51,8 +69,8 @@ public static bool Prefix(PlayerInteract __instance, GameObject doorId)
}
Events.InvokeDoorInteraction(__instance.gameObject.GetPlayer(), door, ref allowTheAccess);
-
- if(allowTheAccess) door.ChangeState(__instance._sr.BypassMode);
+
+ if (allowTheAccess) door.ChangeState(__instance._sr.BypassMode);
else __instance.RpcDenied(doorId);
return false;
@@ -60,11 +78,8 @@ public static bool Prefix(PlayerInteract __instance, GameObject doorId)
catch (Exception e)
{
Log.Error($"DoorInteraction Error: {e}");
-
- if(allowTheAccess && door != null)
- door.ChangeState(__instance._sr.BypassMode);
- else __instance.RpcDenied(doorId);
- return false;
+
+ return true;
}
}
}
diff --git a/Synapse/Events/Patches/EventPatches/PlayerPatches/PlayerThrowGrenadePatch.cs b/Synapse/Events/Patches/EventPatches/PlayerPatches/PlayerThrowGrenadePatch.cs
new file mode 100644
index 0000000..cb07345
--- /dev/null
+++ b/Synapse/Events/Patches/EventPatches/PlayerPatches/PlayerThrowGrenadePatch.cs
@@ -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;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Synapse/Events/PlayerEvents.cs b/Synapse/Events/PlayerEvents.cs
index ebb8ad6..e697ed2 100644
--- a/Synapse/Events/PlayerEvents.cs
+++ b/Synapse/Events/PlayerEvents.cs
@@ -466,5 +466,31 @@ internal static void InvokePlayerHealEvent(Player player, ref float amount, out
amount = ev.Amount;
}
+
+ public delegate void OnPlayerThrowGrenade(PlayerThrowGrenadeEvent ev);
+
+ public static event OnPlayerThrowGrenade PlayerThrowGrenadeEvent;
+ internal static void InvokePlayerThrowGrenadeEvent(Player player, ItemType type, ref bool slow, ref double time, out bool allow)
+ {
+ allow = true;
+
+ if (PlayerThrowGrenadeEvent == null) return;
+
+ var ev = new PlayerThrowGrenadeEvent
+ {
+ Player = player,
+ Grenade = type,
+ Slow = slow,
+ FuseTime = time,
+ Allow = allow
+ };
+
+ PlayerThrowGrenadeEvent.Invoke(ev);
+
+ allow = ev.Allow;
+ slow = ev.Slow;
+ time = ev.FuseTime;
+
+ }
}
}
\ No newline at end of file
diff --git a/Synapse/Properties/AssemblyInfo.cs b/Synapse/Properties/AssemblyInfo.cs
index 2528c0b..0736dca 100644
--- a/Synapse/Properties/AssemblyInfo.cs
+++ b/Synapse/Properties/AssemblyInfo.cs
@@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.2.0")]
-[assembly: AssemblyFileVersion("1.2.0")]
\ No newline at end of file
+[assembly: AssemblyVersion("1.2.1")]
+[assembly: AssemblyFileVersion("1.2.1")]
\ No newline at end of file
diff --git a/Synapse/Synapse.cs b/Synapse/Synapse.cs
index 004e70e..83f012b 100644
--- a/Synapse/Synapse.cs
+++ b/Synapse/Synapse.cs
@@ -17,11 +17,11 @@ public static class Synapse
{
#region Version
private const int MajorVersion = 1;
- private const int MinorVerion = 2;
- private const int Patch = 0;
+ private const int MinorVersion = 2;
+ private const int Patch = 1;
- public static int VersionNumber => MajorVersion * 100 + MinorVerion * 10 + Patch;
- public static string Version => $"{MajorVersion}.{MinorVerion}.{Patch}";
+ public static int VersionNumber => MajorVersion * 100 + MinorVersion * 10 + Patch;
+ public static string Version => $"{MajorVersion}.{MinorVersion}.{Patch}";
#endregion
private static bool _isLoaded;
@@ -124,16 +124,16 @@ private static void LoadPlugin(string pluginPath)
Name = assembly.GetName().Name,
Version = assembly.ImageRuntimeVersion,
SynapseMajor = MajorVersion,
- SynapseMinor = MinorVerion,
+ SynapseMinor = MinorVersion,
SynapsePatch = Patch
};
p.Assembly = assembly;
plugins.Add(p);
- if (p.Details.SynapseMajor * 10 + p.Details.SynapseMinor == MajorVersion * 10 + MinorVerion) Log.Info($"Successfully loaded {p.Details.Name}");
+ if (p.Details.SynapseMajor * 10 + p.Details.SynapseMinor == MajorVersion * 10 + MinorVersion) Log.Info($"Successfully loaded {p.Details.Name}");
- else if (p.Details.SynapseMajor * 10 + p.Details.SynapseMinor > MajorVersion * 10 + MinorVerion) Log.Warn($"The Plugin {p.Details.Name} is for the newer Synapse version {p.Details.GetVersionString()} but was succesfully loaded(bugs can occure)");
+ else if (p.Details.SynapseMajor * 10 + p.Details.SynapseMinor > MajorVersion * 10 + MinorVersion) Log.Warn($"The Plugin {p.Details.Name} is for the newer Synapse version {p.Details.GetVersionString()} but was succesfully loaded(bugs can occure)");
else Log.Warn($"The Plugin {p.Details.Name} is for the older Synapse version {p.Details.GetVersionString()} but was succesfully loaded(bugs can occure)");
}
diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj
index acd17e1..3e5c4da 100644
--- a/Synapse/Synapse.csproj
+++ b/Synapse/Synapse.csproj
@@ -90,8 +90,10 @@
+
+