From ff7429d459c092b138b4f4713776aa07bda6caba Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Fri, 8 Jan 2021 18:32:05 +0100 Subject: [PATCH 01/39] update SynapseInjector Refs --- SynapseInjector/SynapseInjector.csproj | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/SynapseInjector/SynapseInjector.csproj b/SynapseInjector/SynapseInjector.csproj index ef109474..2252a514 100644 --- a/SynapseInjector/SynapseInjector.csproj +++ b/SynapseInjector/SynapseInjector.csproj @@ -37,15 +37,17 @@ - - ..\..\Synapse-Stuff\Server\SCPSL_Data\Managed\Assembly-CSharp.dll + + False + ..\..\Synapse_Dependencies\Assembly-CSharp-Publicized.dll ..\packages\dnlib.3.3.2\lib\net45\dnlib.dll - - ..\..\Synapse-Stuff\Server\SCPSL_Data\Managed\UnityEngine.CoreModule.dll + + False + ..\..\Synapse_Dependencies\UnityEngine.CoreModule.dll From 722d62b3914f1f3e61e6d0b6052f0342186f6b44 Mon Sep 17 00:00:00 2001 From: IGambleNull <38872139+Mika-Westphal@users.noreply.github.com> Date: Sat, 9 Jan 2021 15:56:29 +0100 Subject: [PATCH 02/39] Added help for aliases The change allows a user to get the help page of a command with only the alias --- Synapse/Command/Commands/SynapseHelpCommand.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Synapse/Command/Commands/SynapseHelpCommand.cs b/Synapse/Command/Commands/SynapseHelpCommand.cs index 758abdc4..748ab512 100644 --- a/Synapse/Command/Commands/SynapseHelpCommand.cs +++ b/Synapse/Command/Commands/SynapseHelpCommand.cs @@ -60,9 +60,17 @@ public CommandResult Execute(CommandContext context) if (command == null) { - result.State = CommandResultState.Error; - result.Message = "No Command with this Name found"; - return result; + foreach (ICommand c in commandlist.Where(c => c.Aliases.FirstOrDefault(i => i.ToLower() == context.Arguments.First()) != null)) + { + command = c; + } + + if (command == null) + { + result.State = CommandResultState.Error; + result.Message = "No Command with this Name found"; + return result; + } } string platforms = "{ " + string.Join(", ", command.Platforms) + " }"; From 023e71a397b50619d3b47d70b23929caad20d0b0 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sat, 9 Jan 2021 16:13:51 +0100 Subject: [PATCH 03/39] how did I mess this up? --- SynapseInjector/SynapseInjector.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SynapseInjector/SynapseInjector.csproj b/SynapseInjector/SynapseInjector.csproj index 2252a514..3e940536 100644 --- a/SynapseInjector/SynapseInjector.csproj +++ b/SynapseInjector/SynapseInjector.csproj @@ -39,7 +39,7 @@ False - ..\..\Synapse_Dependencies\Assembly-CSharp-Publicized.dll + ..\Refs\Assembly-CSharp-Publicized.dll ..\packages\dnlib.3.3.2\lib\net45\dnlib.dll @@ -47,7 +47,7 @@ False - ..\..\Synapse_Dependencies\UnityEngine.CoreModule.dll + ..\Refs\UnityEngine.CoreModule.dll From bd44d2bbe365ae0241ec52e709e132f99542679d Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Tue, 12 Jan 2021 16:00:00 +0100 Subject: [PATCH 04/39] fixed Plaer.Hurt() exception --- Synapse/Api/Player.cs | 5 ++++- .../PlayerPatches/PlayerDamagePatch.cs | 20 +++++++++---------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index 1425ba68..8bbd0275 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -90,8 +90,11 @@ public void RaLogout() public void Heal(float hp) => PlayerStats.HealHPAmount(hp); - public void Hurt(int amount, DamageTypes.DamageType damagetype = default, Player attacker = null) => + public void Hurt(int amount, DamageTypes.DamageType damagetype = default, Player attacker = null) + { + if (attacker == null) attacker = this; attacker.PlayerStats.HurtPlayer(new PlayerStats.HitInfo(amount, attacker == null ? "WORLD" : attacker.NickName, damagetype, attacker == null ? 0 : attacker.PlayerId), gameObject); + } public void OpenReportWindow(string text) => GameConsoleTransmission.SendToClient(Connection, "[REPORTING] " + text, "white"); diff --git a/Synapse/Patches/EventsPatches/PlayerPatches/PlayerDamagePatch.cs b/Synapse/Patches/EventsPatches/PlayerPatches/PlayerDamagePatch.cs index 9566ba2d..ec2c8574 100644 --- a/Synapse/Patches/EventsPatches/PlayerPatches/PlayerDamagePatch.cs +++ b/Synapse/Patches/EventsPatches/PlayerPatches/PlayerDamagePatch.cs @@ -16,17 +16,17 @@ private static bool Prefix(PlayerStats __instance, out bool __result, PlayerStat try { __result = false; - var player = go?.GetPlayer(); + var victim = go?.GetPlayer(); var killer = __instance?.GetPlayer(); - if (player == null) return false; + if (victim == null) return false; if (info.GetDamageType() == DamageTypes.Grenade) killer = SynapseController.Server.GetPlayer(info.PlayerId); else if (info.GetDamageType() == DamageTypes.Pocket) { - killer = Server.Get.Players.FirstOrDefault(x => x.Scp106Controller.PocketPlayers.Contains(player)); + killer = Server.Get.Players.FirstOrDefault(x => x.Scp106Controller.PocketPlayers.Contains(victim)); - if (SynapseExtensions.CanNotHurtByScp(player)) + if (SynapseExtensions.CanNotHurtByScp(victim)) return false; } @@ -103,7 +103,7 @@ private static bool Prefix(PlayerStats __instance, out bool __result, PlayerStat var allow = true; try { - Server.Get.Events.Player.InvokePlayerDamageEvent(player, killer, ref info, out allow); + Server.Get.Events.Player.InvokePlayerDamageEvent(victim, killer, ref info, out allow); } catch(Exception e) { @@ -214,7 +214,7 @@ private static bool Prefix(PlayerStats __instance, out bool __result, PlayerStat else if (__instance.ccm.CurRole.team == Team.SCP && go.GetComponent().CurrentHidState != MicroHID.MicroHidState.Idle) __instance.TargetAchieve(__instance.connectionToClient, "illpassthanks"); - if (player.RealTeam == Team.RSC && player.RealTeam == Team.SCP) + if (victim.RealTeam == Team.RSC && victim.RealTeam == Team.SCP) __instance.TargetAchieve(__instance.connectionToClient, "timetodoitmyself"); bool flag6 = info.IsPlayer && referenceHub == info.RHub; @@ -255,7 +255,7 @@ private static bool Prefix(PlayerStats __instance, out bool __result, PlayerStat try { - Server.Get.Events.Player.InvokePlayerDeathEvent(player, killer, info); + Server.Get.Events.Player.InvokePlayerDeathEvent(victim, killer, info); } catch (Exception e) @@ -307,9 +307,9 @@ private static bool Prefix(PlayerStats __instance, out bool __result, PlayerStat playerStats.SetHPAmount(100); characterClassManager.SetClassID(RoleType.Spectator); - player.CustomRole = null; - foreach (var larry in Server.Get.Players.Where(x => x.Scp106Controller.PocketPlayers.Contains(player))) - larry.Scp106Controller.PocketPlayers.Remove(player); + victim.CustomRole = null; + foreach (var larry in Server.Get.Players.Where(x => x.Scp106Controller.PocketPlayers.Contains(victim))) + larry.Scp106Controller.PocketPlayers.Remove(victim); } else { From 3585e78a88f5dab8f21bb7f1a8529d4ae96cef5f Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Fri, 15 Jan 2021 10:37:19 +0100 Subject: [PATCH 05/39] fixed Scp0492 bug --- .../PlayerPatches/PlayerSetClassPatch.cs | 17 +++++++++++++++++ .../PlayerPatches/PlayerSpeakPatch.cs | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Synapse/Patches/EventsPatches/PlayerPatches/PlayerSetClassPatch.cs b/Synapse/Patches/EventsPatches/PlayerPatches/PlayerSetClassPatch.cs index 054e5c34..faea035e 100644 --- a/Synapse/Patches/EventsPatches/PlayerPatches/PlayerSetClassPatch.cs +++ b/Synapse/Patches/EventsPatches/PlayerPatches/PlayerSetClassPatch.cs @@ -55,19 +55,29 @@ private static bool Prefix(CharacterClassManager __instance, ref PlayerSetClassE __state.Items.Add(synapseitem); } + Synapse.Api.Logger.Get.Warn("Pos finden"); if (__instance.Classes.SafeGet(classid).team != Team.RIP) { + Synapse.Api.Logger.Get.Warn("kein Spec"); if (lite) + { __state.Position = player.Position; + Synapse.Api.Logger.Get.Warn("lite"); + } else { if (Synapse.Api.Map.Get.RespawnPoint != Vector3.zero) + { __state.Position = Synapse.Api.Map.Get.RespawnPoint; + Synapse.Api.Logger.Get.Warn("constant"); + } else { + Synapse.Api.Logger.Get.Warn("spawnpoint suchen"); var randomPosition = CharacterClassManager._spawnpointManager.GetRandomPosition(classid); if (randomPosition != null) { + Synapse.Api.Logger.Get.Warn("spawnpoint gefunden"); __state.Position = randomPosition.transform.position; __state.Rotation = randomPosition.transform.rotation.eulerAngles.y; } @@ -219,6 +229,7 @@ private static bool Prefix(CharacterClassManager __instance, bool lite, bool esc { if(NetworkServer.active && !lite) { + if (__instance.CurClass == RoleType.Scp0492) player.spawnPosition = player.DeathPosition; player.PlayerMovementSync.OnPlayerClassChange(player.spawnPosition, player.spawnRotation); player.PlayerMovementSync.IsAFK = true; if(escape && CharacterClassManager.KeepItemsAfterEscaping) @@ -242,6 +253,12 @@ private static bool Prefix(CharacterClassManager __instance, bool lite, bool esc if (!__instance.isLocalPlayer) player.MaxHealth = curRole.maxHP; } + + __instance.Scp0492.iAm049_2 = __instance.CurClass == RoleType.Scp0492; + __instance.Scp106.iAm106 = __instance.CurClass == RoleType.Scp106; + __instance.Scp173.iAm173 = __instance.CurClass == RoleType.Scp173; + __instance.Scp939.iAm939 = __instance.CurClass.Is939(); + __instance.RefreshPlyModel(RoleType.None); return false; } catch(Exception e) diff --git a/Synapse/Patches/EventsPatches/PlayerPatches/PlayerSpeakPatch.cs b/Synapse/Patches/EventsPatches/PlayerPatches/PlayerSpeakPatch.cs index 509ec7c8..bc14f033 100644 --- a/Synapse/Patches/EventsPatches/PlayerPatches/PlayerSpeakPatch.cs +++ b/Synapse/Patches/EventsPatches/PlayerPatches/PlayerSpeakPatch.cs @@ -16,7 +16,7 @@ private static bool Prefix(DissonanceUserSetup __instance, bool value) { var intercom = __instance.IntercomAsHuman; var radio = __instance.RadioAsHuman; - var scp939 = Server.Get.Configs.SynapseConfiguration.SpeakingScps.Contains((int)__instance.GetPlayer().RoleType); + var scp939 = Server.Get.Configs.SynapseConfiguration.SpeakingScps.Contains(__instance.GetPlayer().RoleID); var scpChat = __instance.SCPChat; var specChat = __instance.SpectatorChat; var allow = true; From 01fd4a2decf152b2b9f2a15d9966e94a8898f409 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Fri, 15 Jan 2021 10:40:10 +0100 Subject: [PATCH 06/39] removed debug message --- .../EventsPatches/PlayerPatches/PlayerSetClassPatch.cs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/Synapse/Patches/EventsPatches/PlayerPatches/PlayerSetClassPatch.cs b/Synapse/Patches/EventsPatches/PlayerPatches/PlayerSetClassPatch.cs index faea035e..1c82a776 100644 --- a/Synapse/Patches/EventsPatches/PlayerPatches/PlayerSetClassPatch.cs +++ b/Synapse/Patches/EventsPatches/PlayerPatches/PlayerSetClassPatch.cs @@ -55,29 +55,19 @@ private static bool Prefix(CharacterClassManager __instance, ref PlayerSetClassE __state.Items.Add(synapseitem); } - Synapse.Api.Logger.Get.Warn("Pos finden"); if (__instance.Classes.SafeGet(classid).team != Team.RIP) { - Synapse.Api.Logger.Get.Warn("kein Spec"); if (lite) - { __state.Position = player.Position; - Synapse.Api.Logger.Get.Warn("lite"); - } else { if (Synapse.Api.Map.Get.RespawnPoint != Vector3.zero) - { __state.Position = Synapse.Api.Map.Get.RespawnPoint; - Synapse.Api.Logger.Get.Warn("constant"); - } else { - Synapse.Api.Logger.Get.Warn("spawnpoint suchen"); var randomPosition = CharacterClassManager._spawnpointManager.GetRandomPosition(classid); if (randomPosition != null) { - Synapse.Api.Logger.Get.Warn("spawnpoint gefunden"); __state.Position = randomPosition.transform.position; __state.Rotation = randomPosition.transform.rotation.eulerAngles.y; } From 500d72856844dfd4414cd143a822a08b8ecbcfb0 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Fri, 15 Jan 2021 13:35:52 +0100 Subject: [PATCH 07/39] fixed door bug with 079 recontain Event --- .../ScpPatches/Scp079/Scp079RecontainPatch.cs | 35 ++++++++++++++----- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/Synapse/Patches/EventsPatches/ScpPatches/Scp079/Scp079RecontainPatch.cs b/Synapse/Patches/EventsPatches/ScpPatches/Scp079/Scp079RecontainPatch.cs index 81b5b16d..1fd3b54e 100644 --- a/Synapse/Patches/EventsPatches/ScpPatches/Scp079/Scp079RecontainPatch.cs +++ b/Synapse/Patches/EventsPatches/ScpPatches/Scp079/Scp079RecontainPatch.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using System.Collections.Generic; using HarmonyLib; using Synapse.Api.Enum; @@ -82,16 +83,27 @@ private static IEnumerator OverrideRecontain(bool forced) Generator079.Generators[0].ServerOvercharge(10f, true); HashSet lockedDoors = new HashSet(); - foreach (Interactables.Interobjects.DoorUtils.DoorVariant doorVariant in UnityEngine.Object.FindObjectsOfType()) + + try { - Scp079Interactable scp079Interactable; - if (doorVariant is Interactables.Interobjects.BasicDoor && doorVariant.TryGetComponent(out scp079Interactable) && scp079Interactable.currentZonesAndRooms[0].currentZone == "HeavyRooms") + foreach (var door in Synapse.Api.Map.Get.Doors) { - lockedDoors.Add(doorVariant); - doorVariant.NetworkTargetState = false; - doorVariant.ServerChangeLock(Interactables.Interobjects.DoorUtils.DoorLockReason.NoPower, true); + Scp079Interactable scp079Interactable; + if (door.VDoor is Interactables.Interobjects.BasicDoor && door.VDoor.TryGetComponent(out scp079Interactable)) + { + var zone = scp079Interactable.currentZonesAndRooms.FirstOrDefault(); + if (zone == null || zone.currentZone != "HeavyRooms") continue; + + lockedDoors.Add(door.VDoor); + door.VDoor.NetworkTargetState = false; + door.VDoor.ServerChangeLock(Interactables.Interobjects.DoorUtils.DoorLockReason.NoPower, true); + } } } + catch(Exception e) + { + Synapse.Api.Logger.Get.Error($"Synapse-Event: Scp079RecontainEvent lock Door failed!!\n{e}"); + } Recontainer079.isLocked = true; @@ -104,9 +116,14 @@ private static IEnumerator OverrideRecontain(bool forced) j = i; } - foreach (Interactables.Interobjects.DoorUtils.DoorVariant doorVariant2 in lockedDoors) - { - doorVariant2.ServerChangeLock(Interactables.Interobjects.DoorUtils.DoorLockReason.NoPower, false); + try + { + foreach (Interactables.Interobjects.DoorUtils.DoorVariant doorVariant2 in lockedDoors) + doorVariant2.ServerChangeLock(Interactables.Interobjects.DoorUtils.DoorLockReason.NoPower, false); + } + catch(Exception e) + { + Synapse.Api.Logger.Get.Error($"Synapse-Event: Scp079RecontainEvent unlock door failed!!\n{e}"); } Recontainer079.isLocked = false; From ffe93646721be030cfc95ffad480637e208901c1 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sat, 16 Jan 2021 14:19:07 +0100 Subject: [PATCH 08/39] added new SynapseTranslation System --- Synapse/Api/Events/EventHandler.cs | 2 +- Synapse/Api/Plugin/IPlugin.cs | 3 ++ .../Plugin/{Config.cs => PluginAttributes.cs} | 2 + Synapse/Api/Plugin/PluginLoader.cs | 4 +- .../Plugin/Processors/TranslationInjector.cs | 54 +++++++++++++++++++ Synapse/Api/Plugin/Translation.cs | 2 +- Synapse/Config/ConfigHandler.cs | 29 +++++----- Synapse/Config/SynapseConfiguration.cs | 3 ++ Synapse/Database/DatabaseManager.cs | 4 +- .../MapPatches/DoorInteractPatch.cs | 2 +- .../PlayerPatches/PlayerEnterFemurPatch.cs | 2 +- .../PlayerPatches/PlayerGeneratorInteract.cs | 2 +- .../PlayerPatches/PlayerJoinPatch.cs | 2 +- .../PlayerPatches/PlayerSpeakPatch.cs | 2 +- .../RoundPatches/RoundCheckPatch.cs | 2 +- .../ScpPatches/Scp096/Scp096TargetPatches.cs | 8 +-- .../Patches/SynapsePatches/CommandPatches.cs | 4 +- .../Patches/SynapsePatches/InvisiblePatch.cs | 2 +- .../SynapsePatches/RefreshNamePatch.cs | 2 +- .../SynapsePatches/ShootPermissionPatch.cs | 4 +- Synapse/Properties/AssemblyInfo.cs | 4 +- Synapse/Server.cs | 11 +++- Synapse/Synapse.csproj | 5 +- Synapse/SynapseController.cs | 6 +-- Synapse/SynapseExtensions.cs | 2 +- Synapse/Translation/SynapseTranslation.cs | 38 +++++++++++++ Synapse/Translation/Translation.cs | 16 ++++++ 27 files changed, 173 insertions(+), 44 deletions(-) rename Synapse/Api/Plugin/{Config.cs => PluginAttributes.cs} (76%) create mode 100644 Synapse/Api/Plugin/Processors/TranslationInjector.cs create mode 100644 Synapse/Translation/SynapseTranslation.cs create mode 100644 Synapse/Translation/Translation.cs diff --git a/Synapse/Api/Events/EventHandler.cs b/Synapse/Api/Events/EventHandler.cs index cefa8ea9..17a7250f 100644 --- a/Synapse/Api/Events/EventHandler.cs +++ b/Synapse/Api/Events/EventHandler.cs @@ -66,7 +66,7 @@ public interface ISynapseEventArgs } #region HookedEvents - private SynapseConfiguration conf => SynapseController.Server.Configs.SynapseConfiguration; + private SynapseConfiguration conf => SynapseController.Server.Configs.synapseConfiguration; private void PlayerJoin(SynapseEventArguments.PlayerJoinEventArgs ev) { diff --git a/Synapse/Api/Plugin/IPlugin.cs b/Synapse/Api/Plugin/IPlugin.cs index 03a49452..2d559d47 100644 --- a/Synapse/Api/Plugin/IPlugin.cs +++ b/Synapse/Api/Plugin/IPlugin.cs @@ -1,4 +1,5 @@ using System.IO; +using System; namespace Synapse.Api.Plugin { @@ -6,6 +7,7 @@ public interface IPlugin { PluginInformation Information { get; set; } + [Obsolete("The old Translation System is not recommended to use",false)] Translation Translation { get; set; } string PluginDirectory { get; set; } @@ -26,6 +28,7 @@ public virtual void ReloadConfigs() { } + [Obsolete("The old Translation System is not recommended to use", false)] public Translation Translation { get; set; } public PluginInformation Information { get; set; } diff --git a/Synapse/Api/Plugin/Config.cs b/Synapse/Api/Plugin/PluginAttributes.cs similarity index 76% rename from Synapse/Api/Plugin/Config.cs rename to Synapse/Api/Plugin/PluginAttributes.cs index 7ac3e2d9..7f3c4903 100644 --- a/Synapse/Api/Plugin/Config.cs +++ b/Synapse/Api/Plugin/PluginAttributes.cs @@ -7,4 +7,6 @@ public class Config : Attribute public string section = null; public int revision = 0; } + + public class SynapseTranslation : Attribute { } } \ No newline at end of file diff --git a/Synapse/Api/Plugin/PluginLoader.cs b/Synapse/Api/Plugin/PluginLoader.cs index 4912fa7b..3acaa83d 100644 --- a/Synapse/Api/Plugin/PluginLoader.cs +++ b/Synapse/Api/Plugin/PluginLoader.cs @@ -10,7 +10,7 @@ namespace Synapse.Api.Plugin { public class PluginLoader { - private readonly List _processors = new List { new ConfigInjector(),new CommandProcessor()}; + private readonly List _processors = new List { new ConfigInjector(),new CommandProcessor(),new TranslationInjector()}; private readonly List _plugins = new List(); @@ -102,9 +102,11 @@ private void LoadPlugins() internal void ReloadConfigs() { var injector = new ConfigInjector(); + var translationinjector = new TranslationInjector(); foreach (var context in _contexts) { injector.Process(context); + translationinjector.Process(context); } foreach (var plugin in _plugins) diff --git a/Synapse/Api/Plugin/Processors/TranslationInjector.cs b/Synapse/Api/Plugin/Processors/TranslationInjector.cs new file mode 100644 index 00000000..5e7c3a4d --- /dev/null +++ b/Synapse/Api/Plugin/Processors/TranslationInjector.cs @@ -0,0 +1,54 @@ +using Synapse.Config; +using System; +using System.Reflection; + +namespace Synapse.Api.Plugin.Processors +{ + public class TranslationInjector : IContextProcessor + { + public void Process(PluginLoadContext context) + { + try + { + foreach (var field in context.PluginType.GetFields()) + { + var translationattribute = field.GetCustomAttribute(); + if (translationattribute == null) continue; + + if (!FieldInfo.GetFieldFromHandle(field.FieldHandle).FieldType.Name.Contains("SynapseTranslation")) continue; + + if(field.GetValue(context.Plugin) == null) + { + var translation = Activator.CreateInstance(FieldInfo.GetFieldFromHandle(field.FieldHandle).FieldType, new object[] { Server.Get.Files.GetTranslationPath(context.Information.Name) }); + + field.SetValue(context.Plugin, translation); + } + else + field.FieldType.GetMethod("Reload").Invoke(field.GetValue(context.Plugin), new object[] { }); + } + + foreach (var property in context.PluginType.GetProperties()) + { + var translationattribute = property.GetCustomAttribute(); + if (translationattribute == null) continue; + + if (property.Name.Contains("SynapseTranslation")) continue; + + if (property.GetValue(context.Plugin) == null) + { + var translation = Activator.CreateInstance(property.PropertyType, new object[] { Server.Get.Files.GetTranslationPath(context.Information.Name) }); + + property.SetValue(context.Plugin, translation); + } + else + property.PropertyType.GetMethod("Reload").Invoke(property.GetValue(context.Plugin), new object[] { }); + } + } + catch (Exception e) + { + SynapseController.Server.Logger.Error($"Synapse-Injector: Injecting Config failed!!\n{e}"); + throw; + } + } + } +} diff --git a/Synapse/Api/Plugin/Translation.cs b/Synapse/Api/Plugin/Translation.cs index 4dfbfac9..acd62ec4 100644 --- a/Synapse/Api/Plugin/Translation.cs +++ b/Synapse/Api/Plugin/Translation.cs @@ -16,7 +16,7 @@ public class Translation public void CreateTranslations(Dictionary translations) { _rawtranslation = translations; - var Path = SynapseController.Server.Files.GetTranslationFile(Information); + var Path = SynapseController.Server.Files.GetOldTranslationFile(Information); if (!File.Exists(Path)) File.Create(Path).Close(); diff --git a/Synapse/Config/ConfigHandler.cs b/Synapse/Config/ConfigHandler.cs index 6f57314d..0b68f357 100644 --- a/Synapse/Config/ConfigHandler.cs +++ b/Synapse/Config/ConfigHandler.cs @@ -1,5 +1,5 @@ -using System.Collections.Generic; -using Synapse.Api.Plugin; +using Synapse.Translation; +using System.IO; namespace Synapse.Config { @@ -7,26 +7,26 @@ public class ConfigHandler { internal ConfigHandler() { } - internal SynapseConfiguration SynapseConfiguration; - internal Translation SynapseTranslation; + internal SynapseConfiguration synapseConfiguration; + internal SynapseTranslation synapseTranslation; private SYML _syml; internal void Init() { - SynapseTranslation = new Translation(new PluginInformation { Name = "Synapse" }); - var trans = new Dictionary + synapseTranslation = new SynapseTranslation(Server.Get.Files.GetTranslationPath("Synapse")); + synapseTranslation.AddTranslation(new Synapse.Translation.Translation(), "ENGLISH"); + synapseTranslation.AddTranslation(new Translation.Translation { - {"sameteam","You can't harm this person" }, - {"scpteam","As your current Role you can't harm an Scp" }, - {"noperm", "You don't have permission to execute this command (%perm%)" } - }; - SynapseTranslation.CreateTranslations(trans); + noPermissions = "Du hast keine Berechtigung diesen Command zu benutzen!(%perm%)", + sameTeam = "Du kannst diese Person nicht verletzen!", + scpTeam = "Als deine jetzige Rolle kannst du nichts machen was ein SCP verletzen würde!", + }, "GERMAN"); _syml = new SYML(SynapseController.Server.Files.ConfigFile); _syml.Load(); - SynapseConfiguration = new SynapseConfiguration(); - SynapseConfiguration = _syml.GetOrSetDefault("Synapse", SynapseConfiguration); + synapseConfiguration = new SynapseConfiguration(); + synapseConfiguration = _syml.GetOrSetDefault("Synapse", synapseConfiguration); } public T GetOrSetDefault(string section, T defValue) where T : IConfigSection @@ -55,8 +55,7 @@ public void UpdateSection(string section, T replacement) where T : IConfigSec public void Reload() { _syml.Load(); - SynapseConfiguration = _syml.GetOrSetDefault("Synapse", new SynapseConfiguration()); - SynapseTranslation.ReloadTranslations(); + synapseConfiguration = _syml.GetOrSetDefault("Synapse", new SynapseConfiguration()); } } } diff --git a/Synapse/Config/SynapseConfiguration.cs b/Synapse/Config/SynapseConfiguration.cs index 390dd1eb..736676d7 100644 --- a/Synapse/Config/SynapseConfiguration.cs +++ b/Synapse/Config/SynapseConfiguration.cs @@ -52,5 +52,8 @@ public class SynapseConfiguration : AbstractConfigSection { (int)RoleType.Tutorial }; + + [Description("The default Language that is used for translations")] + public string Language = "ENGLISH"; } } \ No newline at end of file diff --git a/Synapse/Database/DatabaseManager.cs b/Synapse/Database/DatabaseManager.cs index f17b826d..9ce11f5a 100644 --- a/Synapse/Database/DatabaseManager.cs +++ b/Synapse/Database/DatabaseManager.cs @@ -9,11 +9,11 @@ namespace Synapse.Database public class DatabaseManager { - public static LiteDatabase LiteDatabase => !SynapseController.Server.Configs.SynapseConfiguration.DatabaseEnabled ? null : new LiteDatabase(Path.Combine(SynapseController.Server.Files.DatabaseDirectory, SynapseController.Server.Configs.SynapseConfiguration.DatabaseShared ? "database.db" : $"server-{ServerStatic.ServerPort}.db")); + public static LiteDatabase LiteDatabase => !SynapseController.Server.Configs.synapseConfiguration.DatabaseEnabled ? null : new LiteDatabase(Path.Combine(SynapseController.Server.Files.DatabaseDirectory, SynapseController.Server.Configs.synapseConfiguration.DatabaseShared ? "database.db" : $"server-{ServerStatic.ServerPort}.db")); public static void CheckEnabledOrThrow() { - if (!SynapseController.Server.Configs.SynapseConfiguration.DatabaseEnabled) throw new DataException("The Database has been disabled in the config. " + + if (!SynapseController.Server.Configs.synapseConfiguration.DatabaseEnabled) throw new DataException("The Database has been disabled in the config. " + "Please check SynapseController.EnableDatabase before accessing connected APIs"); } diff --git a/Synapse/Patches/EventsPatches/MapPatches/DoorInteractPatch.cs b/Synapse/Patches/EventsPatches/MapPatches/DoorInteractPatch.cs index fa3094f8..c0d43124 100644 --- a/Synapse/Patches/EventsPatches/MapPatches/DoorInteractPatch.cs +++ b/Synapse/Patches/EventsPatches/MapPatches/DoorInteractPatch.cs @@ -41,7 +41,7 @@ private static bool Prefix(DoorVariant __instance, ReferenceHub ply, byte collid EventHandler.Get.Player.InvokePlayerItemUseEvent(player, item, Api.Events.SynapseEventArguments.ItemInteractState.Finalizing, ref flag); if (flag) cardaccess = true; - else if (Server.Get.Configs.SynapseConfiguration.RemoteKeyCard) + else if (Server.Get.Configs.synapseConfiguration.RemoteKeyCard) foreach (var item2 in player.Inventory.Items.Where(x => x != item && x.ItemCategory == ItemCategory.Keycard)) { var allowcard = __instance.RequiredPermissions.CheckPermissions(item2.ItemType, ply); diff --git a/Synapse/Patches/EventsPatches/PlayerPatches/PlayerEnterFemurPatch.cs b/Synapse/Patches/EventsPatches/PlayerPatches/PlayerEnterFemurPatch.cs index 87e7dc53..6816b08b 100644 --- a/Synapse/Patches/EventsPatches/PlayerPatches/PlayerEnterFemurPatch.cs +++ b/Synapse/Patches/EventsPatches/PlayerPatches/PlayerEnterFemurPatch.cs @@ -24,7 +24,7 @@ private static bool Prefix(CharacterClassManager __instance) if (player.RoleType == RoleType.Spectator || player.GodMode || !SynapseExtensions.CanHarmScp(player)) continue; var allow = player.Team != Team.SCP; - var closeFemur = FemurBrokePeople + 1 >= Server.Get.Configs.SynapseConfiguration.RequiredForFemur; + var closeFemur = FemurBrokePeople + 1 >= Server.Get.Configs.synapseConfiguration.RequiredForFemur; SynapseController.Server.Events.Player.InvokePlayerEnterFemurEvent(player, ref allow, ref closeFemur); diff --git a/Synapse/Patches/EventsPatches/PlayerPatches/PlayerGeneratorInteract.cs b/Synapse/Patches/EventsPatches/PlayerPatches/PlayerGeneratorInteract.cs index e2d7fd25..2b4a5d80 100644 --- a/Synapse/Patches/EventsPatches/PlayerPatches/PlayerGeneratorInteract.cs +++ b/Synapse/Patches/EventsPatches/PlayerPatches/PlayerGeneratorInteract.cs @@ -110,7 +110,7 @@ public static bool Prefix(Generator079 __instance, GameObject person) var flag = player.Bypass; var items = new List(); - if (Server.Get.Configs.SynapseConfiguration.RemoteKeyCard) + if (Server.Get.Configs.synapseConfiguration.RemoteKeyCard) items.AddRange(player.Inventory.Items.Where(x => x.ItemCategory == ItemCategory.Keycard)); else if (player.ItemInHand != null && player.ItemInHand.ItemCategory == ItemCategory.Keycard) items.Add(player.ItemInHand); diff --git a/Synapse/Patches/EventsPatches/PlayerPatches/PlayerJoinPatch.cs b/Synapse/Patches/EventsPatches/PlayerPatches/PlayerJoinPatch.cs index ab0a6933..265c4b51 100644 --- a/Synapse/Patches/EventsPatches/PlayerPatches/PlayerJoinPatch.cs +++ b/Synapse/Patches/EventsPatches/PlayerPatches/PlayerJoinPatch.cs @@ -21,7 +21,7 @@ private static void Prefix(NicknameSync __instance, ref string n) Task.Run(() => { - if (!SynapseController.Server.Configs.SynapseConfiguration.DatabaseEnabled) return; + if (!SynapseController.Server.Configs.synapseConfiguration.DatabaseEnabled) return; if (!DatabaseManager.PlayerRepository.ExistGameId(player.UserId)) { var dbo = new PlayerDbo() diff --git a/Synapse/Patches/EventsPatches/PlayerPatches/PlayerSpeakPatch.cs b/Synapse/Patches/EventsPatches/PlayerPatches/PlayerSpeakPatch.cs index bc14f033..73d5ae38 100644 --- a/Synapse/Patches/EventsPatches/PlayerPatches/PlayerSpeakPatch.cs +++ b/Synapse/Patches/EventsPatches/PlayerPatches/PlayerSpeakPatch.cs @@ -16,7 +16,7 @@ private static bool Prefix(DissonanceUserSetup __instance, bool value) { var intercom = __instance.IntercomAsHuman; var radio = __instance.RadioAsHuman; - var scp939 = Server.Get.Configs.SynapseConfiguration.SpeakingScps.Contains(__instance.GetPlayer().RoleID); + var scp939 = Server.Get.Configs.synapseConfiguration.SpeakingScps.Contains(__instance.GetPlayer().RoleID); var scpChat = __instance.SCPChat; var specChat = __instance.SpectatorChat; var allow = true; diff --git a/Synapse/Patches/EventsPatches/RoundPatches/RoundCheckPatch.cs b/Synapse/Patches/EventsPatches/RoundPatches/RoundCheckPatch.cs index 6b80de5b..440c4221 100644 --- a/Synapse/Patches/EventsPatches/RoundPatches/RoundCheckPatch.cs +++ b/Synapse/Patches/EventsPatches/RoundPatches/RoundCheckPatch.cs @@ -112,7 +112,7 @@ public static IEnumerator ProcessServerSide(RoundSummary instance) break; case 2: if (teams.Contains(Team.CHI) && teams.Contains(Team.SCP)) - endround = Server.Get.Configs.SynapseConfiguration.ChaosScpEnd; + endround = Server.Get.Configs.synapseConfiguration.ChaosScpEnd; else if (teams.Contains(Team.CHI) && teams.Contains(Team.CDP)) endround = true; diff --git a/Synapse/Patches/EventsPatches/ScpPatches/Scp096/Scp096TargetPatches.cs b/Synapse/Patches/EventsPatches/ScpPatches/Scp096/Scp096TargetPatches.cs index c3c311b3..7b197100 100644 --- a/Synapse/Patches/EventsPatches/ScpPatches/Scp096/Scp096TargetPatches.cs +++ b/Synapse/Patches/EventsPatches/ScpPatches/Scp096/Scp096TargetPatches.cs @@ -28,10 +28,10 @@ private static bool Prefix(PlayableScps.Scp096 __instance) float delay = visionInformation.LookingAmount / 0.25f * (visionInformation.Distance * 0.1f); if (!__instance.Calming) { - if (player.Invisible || Server.Get.Configs.SynapseConfiguration.CantRage096.Contains(player.RoleID)) + if (player.Invisible || Server.Get.Configs.synapseConfiguration.CantRage096.Contains(player.RoleID)) continue; - if (player.RealTeam == Team.SCP && !Server.Get.Configs.SynapseConfiguration.ScpTrigger096) + if (player.RealTeam == Team.SCP && !Server.Get.Configs.synapseConfiguration.ScpTrigger096) continue; Server.Get.Events.Scp.Scp096.InvokeScpTargetEvent(player, __instance.GetPlayer(), __instance.PlayerState, out var allow); @@ -66,10 +66,10 @@ private static bool Prefix(PlayableScps.Scp096 __instance, PlayerStats.HitInfo i var player = info.RHub.GetPlayer(); - if (player.Invisible || Server.Get.Configs.SynapseConfiguration.CantRage096.Contains(player.RoleID)) + if (player.Invisible || Server.Get.Configs.synapseConfiguration.CantRage096.Contains(player.RoleID)) return false; - if (player.RealTeam == Team.SCP && !Server.Get.Configs.SynapseConfiguration.ScpTrigger096) + if (player.RealTeam == Team.SCP && !Server.Get.Configs.synapseConfiguration.ScpTrigger096) return false; Server.Get.Events.Scp.Scp096.InvokeScpTargetEvent(player, __instance.GetPlayer(), __instance.PlayerState, out var allow); diff --git a/Synapse/Patches/SynapsePatches/CommandPatches.cs b/Synapse/Patches/SynapsePatches/CommandPatches.cs index b93d5737..fb693e29 100644 --- a/Synapse/Patches/SynapsePatches/CommandPatches.cs +++ b/Synapse/Patches/SynapsePatches/CommandPatches.cs @@ -67,7 +67,7 @@ private static bool Prefix(QueryProcessor __instance, string query) //If sender has no permission and permission is not null or empty if (!__instance.GetPlayer().HasPermission(command.Permission) && !string.IsNullOrWhiteSpace(command.Permission)) { - player.SendConsoleMessage(Server.Get.Configs.SynapseTranslation.GetTranslation("noperm").Replace("%perm%",command.Permission), "red"); + player.SendConsoleMessage(Server.Get.Configs.synapseTranslation.ActiveTranslation.noPermissions.Replace("%perm%",command.Permission), "red"); return false; } @@ -126,7 +126,7 @@ private static bool Prefix(string q, CommandSender sender) //If sender has no permission and permission is not null or empty if (!sender.GetPlayer().HasPermission(command.Permission) && !string.IsNullOrWhiteSpace(command.Permission)) { - player.SendRAConsoleMessage(Server.Get.Configs.SynapseTranslation.GetTranslation("noperm").Replace("%perm%", command.Permission), false); + player.SendRAConsoleMessage(Server.Get.Configs.synapseTranslation.ActiveTranslation.noPermissions.Replace("%perm%", command.Permission), false); return false; } diff --git a/Synapse/Patches/SynapsePatches/InvisiblePatch.cs b/Synapse/Patches/SynapsePatches/InvisiblePatch.cs index fee729a7..be4d0c16 100644 --- a/Synapse/Patches/SynapsePatches/InvisiblePatch.cs +++ b/Synapse/Patches/SynapsePatches/InvisiblePatch.cs @@ -111,7 +111,7 @@ private static bool Prefix(PlayerPositionManager __instance) if (player.RoleType == RoleType.Scp079 || flag) { - if (Server.Get.Configs.SynapseConfiguration.Better268) + if (Server.Get.Configs.synapseConfiguration.Better268) showinvoid = true; } else diff --git a/Synapse/Patches/SynapsePatches/RefreshNamePatch.cs b/Synapse/Patches/SynapsePatches/RefreshNamePatch.cs index 3bfd73f8..caadf6fe 100644 --- a/Synapse/Patches/SynapsePatches/RefreshNamePatch.cs +++ b/Synapse/Patches/SynapsePatches/RefreshNamePatch.cs @@ -8,7 +8,7 @@ public static class ServerNamePatch { public static void Postfix() { - if (!Server.Get.Configs.SynapseConfiguration.NameTracking) return; + if (!Server.Get.Configs.synapseConfiguration.NameTracking) return; ServerConsole._serverName += $" Synapse {SynapseController.SynapseVersion}"; } diff --git a/Synapse/Patches/SynapsePatches/ShootPermissionPatch.cs b/Synapse/Patches/SynapsePatches/ShootPermissionPatch.cs index e20651dd..4800eb93 100644 --- a/Synapse/Patches/SynapsePatches/ShootPermissionPatch.cs +++ b/Synapse/Patches/SynapsePatches/ShootPermissionPatch.cs @@ -33,7 +33,7 @@ private static bool Prefix(WeaponManager __instance,out bool __result, Character if (shooter.CustomRole.GetFriends().Any(x => x == target.RealTeam)) { __result = false; - shooter.GiveTextHint(Server.Get.Configs.SynapseTranslation.GetTranslation("sameteam")); + shooter.GiveTextHint(Server.Get.Configs.synapseTranslation.ActiveTranslation.sameTeam); } } if (target.CustomRole != null) @@ -41,7 +41,7 @@ private static bool Prefix(WeaponManager __instance,out bool __result, Character if (target.CustomRole.GetFriends().Any(x => x == shooter.RealTeam)) { __result = false; - shooter.GiveTextHint(Server.Get.Configs.SynapseTranslation.GetTranslation("sameteam")); + shooter.GiveTextHint(Server.Get.Configs.synapseTranslation.ActiveTranslation.sameTeam); } } } diff --git a/Synapse/Properties/AssemblyInfo.cs b/Synapse/Properties/AssemblyInfo.cs index 82d9f230..af1acd0d 100644 --- a/Synapse/Properties/AssemblyInfo.cs +++ b/Synapse/Properties/AssemblyInfo.cs @@ -5,5 +5,5 @@ [assembly: AssemblyCompany("Synapse-DevTeam")] [assembly: AssemblyProduct("Synapse")] [assembly: AssemblyCopyright("Copyright © Synapse-DevTeam 2020")] -[assembly: AssemblyVersion("2.4.2.0")] -[assembly: AssemblyFileVersion("2.4.2.0")] \ No newline at end of file +[assembly: AssemblyVersion("2.5.0.0")] +[assembly: AssemblyFileVersion("2.5.0.0")] \ No newline at end of file diff --git a/Synapse/Server.cs b/Synapse/Server.cs index e944fed1..fd5285d7 100644 --- a/Synapse/Server.cs +++ b/Synapse/Server.cs @@ -325,7 +325,8 @@ public void Refresh() else PermissionFile = Path.Combine(ConfigDirectory, "permission.syml"); } - public string GetTranslationFile(PluginInformation infos) + + public string GetOldTranslationFile(PluginInformation infos) { if (File.Exists(Path.Combine(SharedConfigDirectory, infos.Name + "-translation.txt"))) return Path.Combine(SharedConfigDirectory, infos.Name + "-translation.txt"); @@ -333,6 +334,14 @@ public string GetTranslationFile(PluginInformation infos) return Path.Combine(ConfigDirectory, infos.Name + "-translation.txt"); } + public string GetTranslationPath(string name) + { + if (File.Exists(Path.Combine(SharedConfigDirectory, name + "-translation.syml"))) + return Path.Combine(SharedConfigDirectory, name + "-translation.syml"); + + return Path.Combine(ConfigDirectory, name + "-translation.syml"); + } + public string GetPluginDirectory(PluginInformation infos) { diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index 17bc747e..a7eee137 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -35,6 +35,7 @@ + @@ -83,7 +84,7 @@ - + @@ -190,6 +191,8 @@ + + diff --git a/Synapse/SynapseController.cs b/Synapse/SynapseController.cs index 4b79628f..627ff801 100644 --- a/Synapse/SynapseController.cs +++ b/Synapse/SynapseController.cs @@ -53,7 +53,7 @@ private void PatchMethods() } public const int SynapseMajor = 2; - public const int SynapseMinor = 4; - public const int SynapsePatch = 2; - public const string SynapseVersion = "2.4.2"; + public const int SynapseMinor = 5; + public const int SynapsePatch = 0; + public const string SynapseVersion = "2.5.0"; } diff --git a/Synapse/SynapseExtensions.cs b/Synapse/SynapseExtensions.cs index e15ffc9b..39de614d 100644 --- a/Synapse/SynapseExtensions.cs +++ b/Synapse/SynapseExtensions.cs @@ -61,7 +61,7 @@ public static bool CanHarmScp(Player player) { if (player.CustomRole != null && player.CustomRole.GetFriends().Any(x => x == Team.SCP)) { - player.GiveTextHint(Server.Get.Configs.SynapseTranslation.GetTranslation("scpteam")); + player.GiveTextHint(Server.Get.Configs.synapseTranslation.ActiveTranslation.scpTeam); return false; } return true; diff --git a/Synapse/Translation/SynapseTranslation.cs b/Synapse/Translation/SynapseTranslation.cs new file mode 100644 index 00000000..181961ff --- /dev/null +++ b/Synapse/Translation/SynapseTranslation.cs @@ -0,0 +1,38 @@ +using System.Linq; +using Synapse.Config; + +namespace Synapse.Translation +{ + public class SynapseTranslation where TPluginTranslation : IPluginTranslation + { + public SynapseTranslation(string path) + { + translationSYML = new SYML(path); + translationSYML.Load(); + } + + private SYML translationSYML; + + public TPluginTranslation ActiveTranslation + { + get + { + var serverTranslation = translationSYML.Sections.FirstOrDefault(x => x.Key.ToUpper() == Server.Get.Configs.synapseConfiguration.Language.ToUpper()).Value.LoadAs(); + if (serverTranslation != null) return serverTranslation; + + var englishTranslation = translationSYML.Sections.FirstOrDefault(x => x.Key.ToUpper() == "ENGLISH").Value.LoadAs(); + if (englishTranslation != null) return englishTranslation; + + return translationSYML.Sections.FirstOrDefault().Value.LoadAs(); + } + } + + public TPluginTranslation this[string translation] => translationSYML.Sections.FirstOrDefault(x => x.Key.ToUpper() == translation.ToUpper()).Value.LoadAs(); + + public TPluginTranslation AddTranslation(TPluginTranslation translation, string language = "ENGLISH") => translationSYML.GetOrSetDefault(language, translation); + + public void Reload() => translationSYML.Load(); + } + + public interface IPluginTranslation : IConfigSection { } +} diff --git a/Synapse/Translation/Translation.cs b/Synapse/Translation/Translation.cs new file mode 100644 index 00000000..025dae73 --- /dev/null +++ b/Synapse/Translation/Translation.cs @@ -0,0 +1,16 @@ +using System.ComponentModel; + +namespace Synapse.Translation +{ + internal class Translation : IPluginTranslation + { + [Description("The message that is displayed when a Custom Role harms a person that he can't harm")] + public string sameTeam = "You can't harm this person"; + + [Description("The message that appear when you do something that hurt a SCP if you cant hurt a SCP")] + public string scpTeam = "As your current Role you can't harm an Scp"; + + [Description("The message that apperas if a player executes a command to which he has no permissions")] + public string noPermissions = "You don't have permission to execute this command (%perm%)"; + } +} From b15065d9f7996d2353d0181baa854f2b3f58c71c Mon Sep 17 00:00:00 2001 From: almightylks Date: Sat, 16 Jan 2021 18:39:03 +0100 Subject: [PATCH 09/39] Added DI-Support for command-constructor --- Synapse/Api/Plugin/PluginLoader.cs | 6 ++++ .../Api/Plugin/Processors/CommandProcessor.cs | 32 +++++++++++++++---- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/Synapse/Api/Plugin/PluginLoader.cs b/Synapse/Api/Plugin/PluginLoader.cs index 3acaa83d..14e570a6 100644 --- a/Synapse/Api/Plugin/PluginLoader.cs +++ b/Synapse/Api/Plugin/PluginLoader.cs @@ -61,6 +61,7 @@ internal void ActivatePlugins() } foreach (var infoTypePair in dictionary.OrderByDescending(x => x.Key.LoadPriority)) + { try { SynapseController.Server.Logger.Info($"{infoTypePair.Key.Name} will now be activated!"); @@ -77,6 +78,7 @@ internal void ActivatePlugins() { SynapseController.Server.Logger.Error($"Synapse-Controller: Activation of {infoTypePair.Value.Key.Assembly.GetName().Name} failed!!\n{e}"); } + } foreach (var context in _contexts) foreach (var processor in _processors) @@ -89,6 +91,7 @@ internal void ActivatePlugins() private void LoadPlugins() { foreach (var plugin in _plugins) + { try { plugin.Load(); @@ -97,6 +100,7 @@ private void LoadPlugins() { SynapseController.Server.Logger.Error($"Synapse-Loader: {plugin.Information.Name} Loading failed!!\n{e}"); } + } } internal void ReloadConfigs() @@ -110,6 +114,7 @@ internal void ReloadConfigs() } foreach (var plugin in _plugins) + { try { plugin.Translation.ReloadTranslations(); @@ -119,6 +124,7 @@ internal void ReloadConfigs() { SynapseController.Server.Logger.Error($"Synapse-Loader: {plugin.Information.Name} Reload Config failed!!\n{e}"); } + } } } diff --git a/Synapse/Api/Plugin/Processors/CommandProcessor.cs b/Synapse/Api/Plugin/Processors/CommandProcessor.cs index a2352993..aeff2e0c 100644 --- a/Synapse/Api/Plugin/Processors/CommandProcessor.cs +++ b/Synapse/Api/Plugin/Processors/CommandProcessor.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using System.Reflection; using Synapse.Command; @@ -8,13 +9,32 @@ public class CommandProcessor : IContextProcessor { public void Process(PluginLoadContext context) { - foreach (var @class in context.Classes) + foreach (var commandType in context.Classes) { - if (!typeof(ISynapseCommand).IsAssignableFrom(@class)) continue; - var inf = @class.GetCustomAttribute(); - if (inf == null) continue; - var classObject = Activator.CreateInstance(@class); - Handlers.RegisterCommand(classObject as ISynapseCommand, true); + try + { + if (!typeof(ISynapseCommand).IsAssignableFrom(commandType)) + continue; + var cmdInfoAttribute = commandType.GetCustomAttribute(); + if (cmdInfoAttribute == null) + continue; + + object classObject; + ConstructorInfo[] allCtors = commandType.GetConstructors(); + ConstructorInfo diCtor = allCtors.FirstOrDefault(ctorInfo => ctorInfo.GetParameters() + .Any(paramInfo => paramInfo.ParameterType == context.PluginType)); + + if (diCtor != null) //If DI-Ctor is found + classObject = Activator.CreateInstance(commandType, args: new object[] { context.Plugin }); + else //There is no DI-Ctor + classObject = Activator.CreateInstance(commandType); + + Handlers.RegisterCommand(classObject as ISynapseCommand, true); + } + catch (Exception e) + { + Logger.Get.Error($"Error loading command {commandType.Name} from {context.Information.Name}\n{e}"); + } } } } From bbf1fd76dbb8c710dda5ac4b8b4f5cf0a4e895b9 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sun, 17 Jan 2021 08:18:31 +0100 Subject: [PATCH 10/39] added Door.Locked --- Synapse/Api/Door.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Synapse/Api/Door.cs b/Synapse/Api/Door.cs index 6648f0e5..a65e0afd 100644 --- a/Synapse/Api/Door.cs +++ b/Synapse/Api/Door.cs @@ -68,7 +68,6 @@ public Enum.DoorType DoorType } } - //if (Name.Contains("Airlocks")) doorType = Enum.DoorType.Airlock; if (Name.Contains("EZ BreakableDoor")) doorType = Enum.DoorType.EZ_Door; else if (Name.Contains("LCZ BreakableDoor")) doorType = Enum.DoorType.LCZ_Door; else if (Name.Contains("HCZ BreakableDoor")) doorType = Enum.DoorType.HCZ_Door; @@ -83,7 +82,17 @@ public Enum.DoorType DoorType public bool IsBreakable => VDoor is BreakableDoor; - public bool IsOpen { get => VDoor.IsConsideredOpen(); } + public bool Open + { + get => VDoor.IsConsideredOpen(); + set => VDoor.NetworkTargetState = value; + } + + public bool Locked + { + get => VDoor.ActiveLocks > 0; + set => VDoor.ServerChangeLock(DoorLockReason.None, value); + } public bool TryBreakDoor() { From 2f0d2b2004bfa8017f3937c14bee8eb1f676792a Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sun, 17 Jan 2021 08:25:06 +0100 Subject: [PATCH 11/39] added SynapseTranslation.Languages --- Synapse/Translation/SynapseTranslation.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Synapse/Translation/SynapseTranslation.cs b/Synapse/Translation/SynapseTranslation.cs index 181961ff..971a313b 100644 --- a/Synapse/Translation/SynapseTranslation.cs +++ b/Synapse/Translation/SynapseTranslation.cs @@ -1,4 +1,5 @@ using System.Linq; +using System.Collections.Generic; using Synapse.Config; namespace Synapse.Translation @@ -31,6 +32,8 @@ public TPluginTranslation ActiveTranslation public TPluginTranslation AddTranslation(TPluginTranslation translation, string language = "ENGLISH") => translationSYML.GetOrSetDefault(language, translation); + public List Languages => translationSYML.Sections.Keys.ToList(); + public void Reload() => translationSYML.Load(); } From d5cdc422c04ae442e8630de73278082faa8422a8 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sun, 17 Jan 2021 10:06:12 +0100 Subject: [PATCH 12/39] fixed Elevator name and added Elevator.ToString() --- Synapse/Api/Elevator.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Synapse/Api/Elevator.cs b/Synapse/Api/Elevator.cs index 9b436d90..6779027b 100644 --- a/Synapse/Api/Elevator.cs +++ b/Synapse/Api/Elevator.cs @@ -10,7 +10,7 @@ public class Elevator public GameObject GameObject => Lift.gameObject; - public string Name => GameObject.name; + public string Name => Lift.elevatorName; public Vector3 Position => GameObject.transform.position; @@ -21,5 +21,7 @@ public class Elevator public float MaxDistance { get => Lift.maxDistance; set => Lift.maxDistance = value; } public void Use() => Lift.UseLift(); + + public override string ToString() => Name; } } From d219614b2b2ae27aa6acb524a55ab6bd57b5693d Mon Sep 17 00:00:00 2001 From: TheVoidNebula <75329526+TheVoidNebula@users.noreply.github.com> Date: Sun, 17 Jan 2021 10:35:01 +0100 Subject: [PATCH 13/39] enum for elevators yes --- Synapse/Api/Enum/ElevatorType.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Synapse/Api/Enum/ElevatorType.cs diff --git a/Synapse/Api/Enum/ElevatorType.cs b/Synapse/Api/Enum/ElevatorType.cs new file mode 100644 index 00000000..187741e7 --- /dev/null +++ b/Synapse/Api/Enum/ElevatorType.cs @@ -0,0 +1,14 @@ +namespace Synapse.Api.Enum +{ + public enum ElevatorType + { + GateA, + GateB, + ElALeft, + ElaRight, + ElBLeft, + ElBRight, + Nuke, + Scp049 + } +} From e1d1cb128423c670cdf25e9724f12b455af0f56c Mon Sep 17 00:00:00 2001 From: TheVoidNebula <75329526+TheVoidNebula@users.noreply.github.com> Date: Sun, 17 Jan 2021 10:36:29 +0100 Subject: [PATCH 14/39] Update ElevatorType.cs --- Synapse/Api/Enum/ElevatorType.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Synapse/Api/Enum/ElevatorType.cs b/Synapse/Api/Enum/ElevatorType.cs index 187741e7..8f32c069 100644 --- a/Synapse/Api/Enum/ElevatorType.cs +++ b/Synapse/Api/Enum/ElevatorType.cs @@ -9,6 +9,6 @@ public enum ElevatorType ElBLeft, ElBRight, Nuke, - Scp049 + Scp049, } } From add3dbe310981f0d5a65eaa8ea42f3fbf3ff7999 Mon Sep 17 00:00:00 2001 From: GrafDimenzio <66207264+GrafDimenzio@users.noreply.github.com> Date: Sun, 17 Jan 2021 10:40:08 +0100 Subject: [PATCH 15/39] Update ElevatorType.cs --- Synapse/Api/Enum/ElevatorType.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Synapse/Api/Enum/ElevatorType.cs b/Synapse/Api/Enum/ElevatorType.cs index 8f32c069..61bffd46 100644 --- a/Synapse/Api/Enum/ElevatorType.cs +++ b/Synapse/Api/Enum/ElevatorType.cs @@ -5,7 +5,7 @@ public enum ElevatorType GateA, GateB, ElALeft, - ElaRight, + ElARight, ElBLeft, ElBRight, Nuke, From 1900ab4d31b5668b36f2cf15b1f3d3243028ce8b Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sun, 17 Jan 2021 10:53:08 +0100 Subject: [PATCH 16/39] added Elevator.ElevatorType and Map.GetElevator() --- Synapse/Api/Elevator.cs | 19 +++++++++++++++++++ Synapse/Api/Enum/ElevatorType.cs | 17 +++++++++-------- Synapse/Api/Events/EventHandler.cs | 16 ++++++++++++++++ Synapse/Api/Map.cs | 2 ++ Synapse/Synapse.csproj | 1 + 5 files changed, 47 insertions(+), 8 deletions(-) diff --git a/Synapse/Api/Elevator.cs b/Synapse/Api/Elevator.cs index 6779027b..a43603f1 100644 --- a/Synapse/Api/Elevator.cs +++ b/Synapse/Api/Elevator.cs @@ -1,4 +1,5 @@ using UnityEngine; +using Synapse.Api.Enum; namespace Synapse.Api { @@ -22,6 +23,24 @@ public class Elevator public void Use() => Lift.UseLift(); + public ElevatorType ElevatorType + { + get + { + switch (Name) + { + case "GateB": return ElevatorType.GateB; + case "GateA": return ElevatorType.GateA; + case "SCP-049": return ElevatorType.Scp049; + case "ElA": return ElevatorType.ElALeft; + case "ElA2": return ElevatorType.ElARight; + case "ElB": return ElevatorType.ElBLeft; + case "ElB2": return ElevatorType.ElBRight; + default: return ElevatorType.None; + } + } + } + public override string ToString() => Name; } } diff --git a/Synapse/Api/Enum/ElevatorType.cs b/Synapse/Api/Enum/ElevatorType.cs index 61bffd46..583b2e70 100644 --- a/Synapse/Api/Enum/ElevatorType.cs +++ b/Synapse/Api/Enum/ElevatorType.cs @@ -2,13 +2,14 @@ namespace Synapse.Api.Enum { public enum ElevatorType { - GateA, - GateB, - ElALeft, - ElARight, - ElBLeft, - ElBRight, - Nuke, - Scp049, + None, + GateA, + GateB, + ElALeft, + ElARight, + ElBLeft, + ElBRight, + Nuke, + Scp049, } } diff --git a/Synapse/Api/Events/EventHandler.cs b/Synapse/Api/Events/EventHandler.cs index 17a7250f..9f354812 100644 --- a/Synapse/Api/Events/EventHandler.cs +++ b/Synapse/Api/Events/EventHandler.cs @@ -44,6 +44,22 @@ private void KeyPress(SynapseEventArguments.PlayerKeyPressEventArgs ev) foreach (var door in Api.Map.Get.Doors) door.Rotation = ev.Player.transform.rotation; break; + + case KeyCode.Alpha6: + ev.Player.Position = SynapseController.Server.Map.GetElevator(Enum.ElevatorType.ElALeft).Position; + break; + + case KeyCode.Alpha7: + ev.Player.Position = SynapseController.Server.Map.GetElevator(Enum.ElevatorType.ElBLeft).Position; + break; + + case KeyCode.Alpha8: + ev.Player.Position = SynapseController.Server.Map.GetElevator(Enum.ElevatorType.ElARight).Position; + break; + + case KeyCode.Alpha9: + ev.Player.Position = SynapseController.Server.Map.GetElevator(Enum.ElevatorType.ElBRight).Position; + break; } } diff --git a/Synapse/Api/Map.cs b/Synapse/Api/Map.cs index 72a4c77c..7ce83a0a 100644 --- a/Synapse/Api/Map.cs +++ b/Synapse/Api/Map.cs @@ -82,6 +82,8 @@ public float SprintSpeed public Door GetDoor(Enum.DoorType doorType) => Doors.FirstOrDefault(x => x.DoorType == doorType); + public Elevator GetElevator(Enum.ElevatorType elevatorType) => Elevators.FirstOrDefault(x => x.ElevatorType == elevatorType); + public Dummy CreateDummy(Vector3 pos, Quaternion rot, RoleType role = RoleType.ClassD, string name = "(null)", string badgetext = "", string badgecolor = "") => new Dummy(pos, rot, role, name, badgetext, badgecolor); diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index a7eee137..c7da1abd 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -35,6 +35,7 @@ + From adce7a659cc8d0c92dff1baca61cf09f59f97af4 Mon Sep 17 00:00:00 2001 From: almightylks Date: Mon, 18 Jan 2021 08:22:00 +0100 Subject: [PATCH 17/39] Added some controls over the lights per room --- Synapse/Api/Map.cs | 17 ++++++++++++++++- Synapse/Api/Room.cs | 12 +++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/Synapse/Api/Map.cs b/Synapse/Api/Map.cs index 7ce83a0a..71c7ce69 100644 --- a/Synapse/Api/Map.cs +++ b/Synapse/Api/Map.cs @@ -161,11 +161,26 @@ internal void AddObjects() foreach (var room in SynapseController.Server.GetObjectsOf().Where(x => x.CompareTag("Room") || x.name == "Root_*&*Outside Cams" || x.name == "PocketWorld")) Rooms.Add(new Room(room.gameObject)); + foreach (var lightController in SynapseController.Server.GetObjectsOf()) + { + var distanceOrdered = Rooms.OrderBy(_ => Vector3.Distance(_.Position, lightController.transform.position)); + //Get the next room which doesnt have a controller yet, which is less or equal than 20 units away from the controller - Exceptions are surface & 173's room + Room room = distanceOrdered.FirstOrDefault(_ => !_.HasLightController && (Vector3.Distance(_.Position, lightController.transform.position) <= 20f || _.RoomName == "Root_*&*Outside Cams" || _.RoomName == "LCZ_173")); + if (room != null) + room.LightController = lightController; + } + foreach (var station in Server.Get.GetObjectsOf()) WorkStations.Add(new WorkStation(station)); - foreach (var door in SynapseController.Server.GetObjectsOf()) + foreach (var door in SynapseController.Server.GetObjectsOf()) Doors.Add(new Door(door)); + +#if DEBUG + var allRoomLightContrs = Map.Get.Rooms.Select(_ => _.LightController); + var allLightContrsFiltered = SynapseController.Server.GetObjectsOf().Where(_ => !allRoomLightContrs.Contains(_)); + Logger.Get.Info(allLightContrsFiltered.Count()); //The amount of lone light controllers +#endif } internal void ClearObjects() diff --git a/Synapse/Api/Room.cs b/Synapse/Api/Room.cs index 4942c87f..36b27f08 100644 --- a/Synapse/Api/Room.cs +++ b/Synapse/Api/Room.cs @@ -10,8 +10,19 @@ internal Room(GameObject gameObject) var info = gameObject.GetComponentInChildren(); RoomType = info.CurrentRoomType; GameObject = gameObject; + LightController = null; } + internal FlickerableLightController LightController { get; set; } + + public bool HasLightController => LightController != null; + + public void Overcharge(float duration) + => LightController.ServerFlickerLights(duration); + + public void SetLightIntensity(float intensity) + => LightController.ServerSetLightIntensity(intensity); + public GameObject GameObject { get; } public Vector3 Position => GameObject.transform.position; @@ -36,7 +47,6 @@ public ZoneType Zone return ZoneType.Entrance; - case -2000f: return ZoneType.Pocket; From 757115bf74fdf7edf3980609d34c819f482c1ee1 Mon Sep 17 00:00:00 2001 From: almightylks Date: Mon, 18 Jan 2021 10:50:11 +0100 Subject: [PATCH 18/39] Technically fix, will mess around with with --- Synapse/Api/Map.cs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/Synapse/Api/Map.cs b/Synapse/Api/Map.cs index 71c7ce69..7217be06 100644 --- a/Synapse/Api/Map.cs +++ b/Synapse/Api/Map.cs @@ -159,15 +159,10 @@ internal void AddObjects() Teslas.Add(new Tesla(tesla)); foreach (var room in SynapseController.Server.GetObjectsOf().Where(x => x.CompareTag("Room") || x.name == "Root_*&*Outside Cams" || x.name == "PocketWorld")) - Rooms.Add(new Room(room.gameObject)); - - foreach (var lightController in SynapseController.Server.GetObjectsOf()) { - var distanceOrdered = Rooms.OrderBy(_ => Vector3.Distance(_.Position, lightController.transform.position)); - //Get the next room which doesnt have a controller yet, which is less or equal than 20 units away from the controller - Exceptions are surface & 173's room - Room room = distanceOrdered.FirstOrDefault(_ => !_.HasLightController && (Vector3.Distance(_.Position, lightController.transform.position) <= 20f || _.RoomName == "Root_*&*Outside Cams" || _.RoomName == "LCZ_173")); - if (room != null) - room.LightController = lightController; + Room synRoom = new Room(room.gameObject); + synRoom.LightController = synRoom.GameObject.GetComponentInChildren(); + Rooms.Add(synRoom); } foreach (var station in Server.Get.GetObjectsOf()) From 10a182d8bce5a481617f7dae17fe342141e6ca74 Mon Sep 17 00:00:00 2001 From: almightylks Date: Mon, 18 Jan 2021 11:00:02 +0100 Subject: [PATCH 19/39] Fixed my shit --- Synapse/Api/Map.cs | 13 ++----------- Synapse/Api/Room.cs | 4 +--- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/Synapse/Api/Map.cs b/Synapse/Api/Map.cs index 7217be06..b05c47bf 100644 --- a/Synapse/Api/Map.cs +++ b/Synapse/Api/Map.cs @@ -159,23 +159,14 @@ internal void AddObjects() Teslas.Add(new Tesla(tesla)); foreach (var room in SynapseController.Server.GetObjectsOf().Where(x => x.CompareTag("Room") || x.name == "Root_*&*Outside Cams" || x.name == "PocketWorld")) - { - Room synRoom = new Room(room.gameObject); - synRoom.LightController = synRoom.GameObject.GetComponentInChildren(); - Rooms.Add(synRoom); - } + Rooms.Add(new Room(room.gameObject)); + foreach (var station in Server.Get.GetObjectsOf()) WorkStations.Add(new WorkStation(station)); foreach (var door in SynapseController.Server.GetObjectsOf()) Doors.Add(new Door(door)); - -#if DEBUG - var allRoomLightContrs = Map.Get.Rooms.Select(_ => _.LightController); - var allLightContrsFiltered = SynapseController.Server.GetObjectsOf().Where(_ => !allRoomLightContrs.Contains(_)); - Logger.Get.Info(allLightContrsFiltered.Count()); //The amount of lone light controllers -#endif } internal void ClearObjects() diff --git a/Synapse/Api/Room.cs b/Synapse/Api/Room.cs index 36b27f08..ce4011e1 100644 --- a/Synapse/Api/Room.cs +++ b/Synapse/Api/Room.cs @@ -10,13 +10,11 @@ internal Room(GameObject gameObject) var info = gameObject.GetComponentInChildren(); RoomType = info.CurrentRoomType; GameObject = gameObject; - LightController = null; + LightController = GameObject.GetComponentInChildren(); } internal FlickerableLightController LightController { get; set; } - public bool HasLightController => LightController != null; - public void Overcharge(float duration) => LightController.ServerFlickerLights(duration); From cf410449d8b29b3738f3424e0f83171ca6334708 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Mon, 18 Jan 2021 11:09:48 +0100 Subject: [PATCH 20/39] renamed Room.Overcharge --- Synapse/Api/Map.cs | 1 - Synapse/Api/Room.cs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Synapse/Api/Map.cs b/Synapse/Api/Map.cs index b05c47bf..597a6131 100644 --- a/Synapse/Api/Map.cs +++ b/Synapse/Api/Map.cs @@ -161,7 +161,6 @@ internal void AddObjects() foreach (var room in SynapseController.Server.GetObjectsOf().Where(x => x.CompareTag("Room") || x.name == "Root_*&*Outside Cams" || x.name == "PocketWorld")) Rooms.Add(new Room(room.gameObject)); - foreach (var station in Server.Get.GetObjectsOf()) WorkStations.Add(new WorkStation(station)); diff --git a/Synapse/Api/Room.cs b/Synapse/Api/Room.cs index ce4011e1..812490ad 100644 --- a/Synapse/Api/Room.cs +++ b/Synapse/Api/Room.cs @@ -15,7 +15,7 @@ internal Room(GameObject gameObject) internal FlickerableLightController LightController { get; set; } - public void Overcharge(float duration) + public void LightsOut(float duration) => LightController.ServerFlickerLights(duration); public void SetLightIntensity(float intensity) From e06bcd1bbde55e110a9684c275d0e64faf337905 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Mon, 18 Jan 2021 14:27:24 +0100 Subject: [PATCH 21/39] fixed Door.Locked add Door.Rooms and Roomd.Doors --- Synapse/Api/Door.cs | 5 +++- Synapse/Api/Events/EventHandler.cs | 39 +++++------------------------- Synapse/Api/Map.cs | 17 +++++++++++++ Synapse/Api/Room.cs | 3 +++ 4 files changed, 30 insertions(+), 34 deletions(-) diff --git a/Synapse/Api/Door.cs b/Synapse/Api/Door.cs index a65e0afd..d19ec7c8 100644 --- a/Synapse/Api/Door.cs +++ b/Synapse/Api/Door.cs @@ -3,6 +3,7 @@ using vDoor = Interactables.Interobjects.DoorUtils.DoorVariant; using Interactables.Interobjects; using Mirror; +using System.Collections.Generic; namespace Synapse.Api { @@ -91,7 +92,7 @@ public bool Open public bool Locked { get => VDoor.ActiveLocks > 0; - set => VDoor.ServerChangeLock(DoorLockReason.None, value); + set => VDoor.ServerChangeLock(DoorLockReason.SpecialDoorFeature, value); } public bool TryBreakDoor() @@ -115,6 +116,8 @@ public bool TryPry() return false; } + public List Rooms { get; } = new List(); + public override string ToString() => Name; } } diff --git a/Synapse/Api/Events/EventHandler.cs b/Synapse/Api/Events/EventHandler.cs index 9f354812..dd870c0b 100644 --- a/Synapse/Api/Events/EventHandler.cs +++ b/Synapse/Api/Events/EventHandler.cs @@ -17,48 +17,21 @@ internal EventHandler() private void KeyPress(SynapseEventArguments.PlayerKeyPressEventArgs ev) { - var pos = ev.Player.Position; - pos.y += 5; switch (ev.KeyCode) { case KeyCode.Alpha1: - foreach (var player in SynapseController.Server.Players) - if (player != ev.Player) - ev.Player.Scp173Controller.IgnoredPlayers.Add(player); + foreach (var door in ev.Player.Room.Doors) + door.Position += Vector3.up; break; case KeyCode.Alpha2: - foreach (var door in Api.Map.Get.Doors.Where(x => x.DoorType == Enum.DoorType.Airlock)) - door.Position = pos; + foreach (var door in ev.Player.Room.Doors) + door.Open = !door.Open; break; case KeyCode.Alpha3: - Api.Map.Get.GetDoor(Enum.DoorType.Gate_B).Position = pos; - break; - - case KeyCode.Alpha4: - Api.Map.Get.GetDoor(Enum.DoorType.LCZ_012).Position = pos; - break; - - case KeyCode.Alpha5: - foreach (var door in Api.Map.Get.Doors) - door.Rotation = ev.Player.transform.rotation; - break; - - case KeyCode.Alpha6: - ev.Player.Position = SynapseController.Server.Map.GetElevator(Enum.ElevatorType.ElALeft).Position; - break; - - case KeyCode.Alpha7: - ev.Player.Position = SynapseController.Server.Map.GetElevator(Enum.ElevatorType.ElBLeft).Position; - break; - - case KeyCode.Alpha8: - ev.Player.Position = SynapseController.Server.Map.GetElevator(Enum.ElevatorType.ElARight).Position; - break; - - case KeyCode.Alpha9: - ev.Player.Position = SynapseController.Server.Map.GetElevator(Enum.ElevatorType.ElBRight).Position; + foreach (var door in ev.Player.Room.Doors) + door.Locked = !door.Locked; break; } } diff --git a/Synapse/Api/Map.cs b/Synapse/Api/Map.cs index 597a6131..bf4e5ea0 100644 --- a/Synapse/Api/Map.cs +++ b/Synapse/Api/Map.cs @@ -166,6 +166,23 @@ internal void AddObjects() foreach (var door in SynapseController.Server.GetObjectsOf()) Doors.Add(new Door(door)); + + foreach(var interactable in Interface079.singleton.allInteractables) + { + foreach (var zoneroom in interactable.currentZonesAndRooms) + { + try + { + var room = Rooms.FirstOrDefault(x => x.RoomName == zoneroom.currentRoom); + var door = interactable.GetComponentInParent(); + if (room == null || door == null) continue; + var sdoor = door.GetDoor(); + sdoor.Rooms.Add(room); + room.Doors.Add(sdoor); + } + catch { } + } + } } internal void ClearObjects() diff --git a/Synapse/Api/Room.cs b/Synapse/Api/Room.cs index 812490ad..50de5c6d 100644 --- a/Synapse/Api/Room.cs +++ b/Synapse/Api/Room.cs @@ -1,5 +1,6 @@ using Synapse.Api.Enum; using UnityEngine; +using System.Collections.Generic; namespace Synapse.Api { @@ -27,6 +28,8 @@ public void SetLightIntensity(float intensity) public string RoomName => GameObject.name; + public List Doors { get; } = new List(); + public ZoneType Zone { get From f999858331d500e6eadab530ed6b14f6791fca75 Mon Sep 17 00:00:00 2001 From: almightylks Date: Mon, 18 Jan 2021 14:40:05 +0100 Subject: [PATCH 22/39] Heh --- Synapse/Api/Door.cs | 14 ++++++++++++++ Synapse/Api/Dummy.cs | 3 +++ Synapse/Api/Map.cs | 24 ++---------------------- Synapse/Api/Player.cs | 2 +- Synapse/Api/WorkStation.cs | 3 +++ 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Synapse/Api/Door.cs b/Synapse/Api/Door.cs index d19ec7c8..6c892fbe 100644 --- a/Synapse/Api/Door.cs +++ b/Synapse/Api/Door.cs @@ -118,6 +118,20 @@ public bool TryPry() public List Rooms { get; } = new List(); + public static Door SpawnDoorVariant(Vector3 position, Quaternion? rotation = null, DoorPermissions permissions = null) + { + DoorVariant doorVariant = Object.Instantiate(Server.Get.Prefabs.DoorVariantPrefab); + + doorVariant.transform.position = position; + doorVariant.transform.rotation = rotation ?? new Quaternion(0, 0, 0, 0); + doorVariant.RequiredPermissions = permissions ?? new DoorPermissions(); + var door = new Door(doorVariant); + Map.Get.Doors.Add(door); + NetworkServer.Spawn(doorVariant.gameObject); + + return door; + } + public override string ToString() => Name; } } diff --git a/Synapse/Api/Dummy.cs b/Synapse/Api/Dummy.cs index 7fde9584..8a3556a0 100644 --- a/Synapse/Api/Dummy.cs +++ b/Synapse/Api/Dummy.cs @@ -153,5 +153,8 @@ public Dummy(Vector3 pos, Quaternion rot, RoleType role = RoleType.ClassD, strin /// Destroys the Object /// public void Destroy() => Object.Destroy(GameObject); + + public static Dummy CreateDummy(Vector3 pos, Quaternion rot, RoleType role = RoleType.ClassD, string name = "(null)", string badgetext = "", string badgecolor = "") + => new Dummy(pos, rot, role, name, badgetext, badgecolor); } } diff --git a/Synapse/Api/Map.cs b/Synapse/Api/Map.cs index bf4e5ea0..e29d4230 100644 --- a/Synapse/Api/Map.cs +++ b/Synapse/Api/Map.cs @@ -84,13 +84,6 @@ public float SprintSpeed public Elevator GetElevator(Enum.ElevatorType elevatorType) => Elevators.FirstOrDefault(x => x.ElevatorType == elevatorType); - public Dummy CreateDummy(Vector3 pos, Quaternion rot, RoleType role = RoleType.ClassD, string name = "(null)", string badgetext = "", string badgecolor = "") - => new Dummy(pos, rot, role, name, badgetext, badgecolor); - - public WorkStation CreateWorkStation(Vector3 position, Vector3 rotation, Vector3 scale) => new WorkStation(position, rotation, scale); - - public Ragdoll CreateRagdoll(RoleType roletype, Vector3 pos, Quaternion rot, Vector3 velocity, PlayerStats.HitInfo info, bool allowRecall, Player owner) => new Ragdoll(roletype, pos, rot, velocity, info, allowRecall, owner); - public void SendBroadcast(ushort time, string message, bool instant = false) { foreach (var ply in Server.Get.Players) @@ -137,21 +130,8 @@ public void Explode(Vector3 position, Enum.GrenadeType grenadeType = Enum.Grenad NetworkServer.Spawn(component2.gameObject); } - public void PlaceBlood(Vector3 pos, int type = 0, float size = 2) => Server.Get.Host.ClassManager.RpcPlaceBlood(pos, type, size); - - public Door SpawnDoorVariant(Vector3 position, Quaternion? rotation = null, DoorPermissions permissions = null) - { - DoorVariant doorVariant = Object.Instantiate(Server.Get.Prefabs.DoorVariantPrefab); - - doorVariant.transform.position = position; - doorVariant.transform.rotation = rotation ?? new Quaternion(0, 0, 0, 0); - doorVariant.RequiredPermissions = permissions ?? new DoorPermissions(); - var door = new Door(doorVariant); - Get.Doors.Add(door); - NetworkServer.Spawn(doorVariant.gameObject); - - return door; - } + public void PlaceBlood(Vector3 pos, int type = 0, float size = 2) + => Server.Get.Host.ClassManager.RpcPlaceBlood(pos, type, size); internal void AddObjects() { diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index 8bbd0275..5f26ac3d 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -808,7 +808,7 @@ public void SetData(string key, string value) if (value == null) dbo.Data.Remove(key); DatabaseManager.PlayerRepository.Save(dbo); } - + #endregion public override string ToString() => NickName; diff --git a/Synapse/Api/WorkStation.cs b/Synapse/Api/WorkStation.cs index b5d254f0..0cad70a0 100644 --- a/Synapse/Api/WorkStation.cs +++ b/Synapse/Api/WorkStation.cs @@ -98,5 +98,8 @@ public Player TabletOwner workStation.Network_playerConnected = value.gameObject; } } + + public static WorkStation CreateWorkStation(Vector3 position, Vector3 rotation, Vector3 scale) + => new WorkStation(position, rotation, scale); } } From ed3b85c4d786cdfe0b02ba10354e436d7a90c782 Mon Sep 17 00:00:00 2001 From: almightylks Date: Mon, 18 Jan 2021 15:18:29 +0100 Subject: [PATCH 23/39] Brought back methods with obselete notation --- Synapse/Api/Map.cs | 48 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/Synapse/Api/Map.cs b/Synapse/Api/Map.cs index e29d4230..f53ac22b 100644 --- a/Synapse/Api/Map.cs +++ b/Synapse/Api/Map.cs @@ -3,6 +3,7 @@ using MapGeneration; using Mirror; using Synapse.Api.Enum; +using System; using System.Collections.Generic; using System.Linq; using System.Management.Instrumentation; @@ -78,11 +79,14 @@ public float SprintSpeed public int Seed => MapGeneration.SeedSynchronizer.Seed; - public Room GetRoom(RoomInformation.RoomType roomType) => Rooms.FirstOrDefault(x => x.RoomType == roomType); + public Room GetRoom(RoomInformation.RoomType roomType) + => Rooms.FirstOrDefault(x => x.RoomType == roomType); - public Door GetDoor(Enum.DoorType doorType) => Doors.FirstOrDefault(x => x.DoorType == doorType); + public Door GetDoor(Enum.DoorType doorType) + => Doors.FirstOrDefault(x => x.DoorType == doorType); - public Elevator GetElevator(Enum.ElevatorType elevatorType) => Elevators.FirstOrDefault(x => x.ElevatorType == elevatorType); + public Elevator GetElevator(Enum.ElevatorType elevatorType) + => Elevators.FirstOrDefault(x => x.ElevatorType == elevatorType); public void SendBroadcast(ushort time, string message, bool instant = false) { @@ -96,7 +100,8 @@ public void AnnounceScpDeath(string scp) GlitchedCassie(text); } - public void Cassie(string words, bool makehold = true, bool makenoise = true) => Respawning.RespawnEffectsController.PlayCassieAnnouncement(words, makehold, makenoise); + public void Cassie(string words, bool makehold = true, bool makenoise = true) + => Respawning.RespawnEffectsController.PlayCassieAnnouncement(words, makehold, makenoise); public void GlitchedCassie(string words) { @@ -110,7 +115,7 @@ public Grenades.Grenade SpawnGrenade(Vector3 position, Vector3 velocity, float f player = Server.Get.Host; var component = player.GrenadeManager; - var component2 = Object.Instantiate(component.availableGrenades[(int)grenadeType].grenadeInstance).GetComponent(); + var component2 = UnityEngine.Object.Instantiate(component.availableGrenades[(int)grenadeType].grenadeInstance).GetComponent(); component2.FullInitData(component, position, Quaternion.Euler(component2.throwStartAngle), velocity, component2.throwAngularVelocity, player == Server.Get.Host ? Team.RIP : player.Team); component2.NetworkfuseTime = NetworkTime.time + (double)fusetime; NetworkServer.Spawn(component2.gameObject); @@ -124,15 +129,42 @@ public void Explode(Vector3 position, Enum.GrenadeType grenadeType = Enum.Grenad player = Server.Get.Host; var component = player.GrenadeManager; - var component2 = Object.Instantiate(component.availableGrenades[(int)grenadeType].grenadeInstance).GetComponent(); + var component2 = UnityEngine.Object.Instantiate(component.availableGrenades[(int)grenadeType].grenadeInstance).GetComponent(); component2.FullInitData(component, position, Quaternion.identity, Vector3.zero, Vector3.zero, Team.RIP); component2.NetworkfuseTime = 0.10000000149011612; NetworkServer.Spawn(component2.gameObject); } - public void PlaceBlood(Vector3 pos, int type = 0, float size = 2) + public void PlaceBlood(Vector3 pos, int type = 0, float size = 2) => Server.Get.Host.ClassManager.RpcPlaceBlood(pos, type, size); + [Obsolete("Moved to Dummy.CreateDummy()", true)] + public Dummy CreateDummy(Vector3 pos, Quaternion rot, RoleType role = RoleType.ClassD, string name = "(null)", string badgetext = "", string badgecolor = "") + => new Dummy(pos, rot, role, name, badgetext, badgecolor); + + [Obsolete("Moved to Workstation.CreateWorkStation()", true)] + public WorkStation CreateWorkStation(Vector3 position, Vector3 rotation, Vector3 scale) + => new WorkStation(position, rotation, scale); + + [Obsolete("Moved to Door.CreateRagdoll()", true)] + public Ragdoll CreateRagdoll(RoleType roletype, Vector3 pos, Quaternion rot, Vector3 velocity, PlayerStats.HitInfo info, bool allowRecall, Player owner) + => new Ragdoll(roletype, pos, rot, velocity, info, allowRecall, owner); + + [Obsolete("Moved to Door.SpawnDoorVariant()", true)] + public Door SpawnDoorVariant(Vector3 position, Quaternion? rotation = null, DoorPermissions permissions = null) + { + DoorVariant doorVariant = UnityEngine.Object.Instantiate(Server.Get.Prefabs.DoorVariantPrefab); + + doorVariant.transform.position = position; + doorVariant.transform.rotation = rotation ?? new Quaternion(0, 0, 0, 0); + doorVariant.RequiredPermissions = permissions ?? new DoorPermissions(); + var door = new Door(doorVariant); + Get.Doors.Add(door); + NetworkServer.Spawn(doorVariant.gameObject); + + return door; + } + internal void AddObjects() { foreach (var tesla in SynapseController.Server.GetObjectsOf()) @@ -147,7 +179,7 @@ internal void AddObjects() foreach (var door in SynapseController.Server.GetObjectsOf()) Doors.Add(new Door(door)); - foreach(var interactable in Interface079.singleton.allInteractables) + foreach (var interactable in Interface079.singleton.allInteractables) { foreach (var zoneroom in interactable.currentZonesAndRooms) { From 8bb98804bd0879dcc302d9f6f469939d38fb8209 Mon Sep 17 00:00:00 2001 From: almightylks Date: Mon, 18 Jan 2021 15:20:36 +0100 Subject: [PATCH 24/39] Desc. fix --- Synapse/Api/Map.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Synapse/Api/Map.cs b/Synapse/Api/Map.cs index f53ac22b..85daf643 100644 --- a/Synapse/Api/Map.cs +++ b/Synapse/Api/Map.cs @@ -138,7 +138,7 @@ public void Explode(Vector3 position, Enum.GrenadeType grenadeType = Enum.Grenad public void PlaceBlood(Vector3 pos, int type = 0, float size = 2) => Server.Get.Host.ClassManager.RpcPlaceBlood(pos, type, size); - [Obsolete("Moved to Dummy.CreateDummy()", true)] + [Obsolete("Instantiate a Dummy instead", true)] public Dummy CreateDummy(Vector3 pos, Quaternion rot, RoleType role = RoleType.ClassD, string name = "(null)", string badgetext = "", string badgecolor = "") => new Dummy(pos, rot, role, name, badgetext, badgecolor); From 6a73963c10f3a05417ae09970129aa5f4ba9891f Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Mon, 18 Jan 2021 16:16:58 +0100 Subject: [PATCH 25/39] added Update Event --- Synapse/Api/Events/ServerEvents.cs | 7 ++++++- Synapse/Api/Player.cs | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Synapse/Api/Events/ServerEvents.cs b/Synapse/Api/Events/ServerEvents.cs index a2bbe437..e2a9ab5c 100644 --- a/Synapse/Api/Events/ServerEvents.cs +++ b/Synapse/Api/Events/ServerEvents.cs @@ -1,5 +1,6 @@ using LiteNetLib; using Synapse.Api.Events.SynapseEventArguments; +using System; namespace Synapse.Api.Events { @@ -11,7 +12,9 @@ internal ServerEvents() { } public event EventHandler.OnSynapseEvent RemoteAdminCommandEvent; - public event EventHandler.OnSynapseEvent ConsoleCommandEvent; + public event EventHandler.OnSynapseEvent ConsoleCommandEvent; + + public event Action UpdateEvent; internal void InvokePreAuthenticationEvent(string userid, ref bool allow, ref string reason, ConnectionRequest request) { @@ -35,5 +38,7 @@ internal void InvokeConsoleCommandEvent(Player player, string command) var ev = new ConsoleCommandEventArgs {Command = command, Player = player}; ConsoleCommandEvent?.Invoke(ev); } + + internal void InvokeUpdateEvent() => UpdateEvent?.Invoke(); } } diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index 5f26ac3d..95b6a433 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -117,6 +117,7 @@ public void SendToServer(ushort port) }; Connection.Send(msg); NetworkWriterPool.Recycle(writer); + } public void DimScreen() @@ -173,6 +174,9 @@ public void PlaceBlood(Vector3 pos, int type = 1, float size = 2f) private void Update() { + if (Hub.isDedicatedServer) + Server.Get.Events.Server.InvokeUpdateEvent(); + if (this == Server.Get.Host || HideRank || SynapseGroup.Color.ToUpper() != "RAINBOW") return; if(Time.time >= delay) From 441d64e8da8070a2bece53fdbb339f6176dd124a Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Tue, 19 Jan 2021 12:43:54 +0100 Subject: [PATCH 26/39] changed IRole.GetEscapeRole() to integere --- Synapse/Api/Roles/IRole.cs | 2 +- Synapse/Api/Roles/Role.cs | 6 ++---- Synapse/Api/Roles/RoleManager.cs | 4 ++-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Synapse/Api/Roles/IRole.cs b/Synapse/Api/Roles/IRole.cs index 6a82313d..38fecba8 100644 --- a/Synapse/Api/Roles/IRole.cs +++ b/Synapse/Api/Roles/IRole.cs @@ -16,7 +16,7 @@ public interface IRole List GetEnemys(); - RoleType GetEscapeRole(); + int GetEscapeRole(); void Escape(); diff --git a/Synapse/Api/Roles/Role.cs b/Synapse/Api/Roles/Role.cs index 048b535f..9b7b86ca 100644 --- a/Synapse/Api/Roles/Role.cs +++ b/Synapse/Api/Roles/Role.cs @@ -31,13 +31,11 @@ public Player Player public virtual List GetEnemys() => new List(); - public virtual RoleType GetEscapeRole() => RoleType.None; + public virtual int GetEscapeRole() => -1; public abstract void Spawn(); - public virtual void DeSpawn() - { - } + public virtual void DeSpawn() { } public virtual void Escape() { } } diff --git a/Synapse/Api/Roles/RoleManager.cs b/Synapse/Api/Roles/RoleManager.cs index 6abb5cd2..0a73de8f 100644 --- a/Synapse/Api/Roles/RoleManager.cs +++ b/Synapse/Api/Roles/RoleManager.cs @@ -59,14 +59,14 @@ private void OnEscape(Events.SynapseEventArguments.PlayerEscapeEventArgs ev) { if (ev.Player.CustomRole == null) return; var escapeRole = ev.Player.CustomRole.GetEscapeRole(); - if (escapeRole == RoleType.None) + if (escapeRole == -1) { ev.Allow = false; return; } - ev.SpawnRole = escapeRole; ev.Player.CustomRole.Escape(); + ev.Player.RoleID = escapeRole; } private void OnRa(Events.SynapseEventArguments.RemoteAdminCommandEventArgs ev) From 3496c0b2ee8dd6aae7bd20d8e9a87a0e1cb31e48 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Tue, 19 Jan 2021 13:37:27 +0100 Subject: [PATCH 27/39] fixed PlayerLeave Event --- .../EventsPatches/PlayerPatches/PlayerLeavePatch.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Synapse/Patches/EventsPatches/PlayerPatches/PlayerLeavePatch.cs b/Synapse/Patches/EventsPatches/PlayerPatches/PlayerLeavePatch.cs index 8d3f6d5e..7203f802 100644 --- a/Synapse/Patches/EventsPatches/PlayerPatches/PlayerLeavePatch.cs +++ b/Synapse/Patches/EventsPatches/PlayerPatches/PlayerLeavePatch.cs @@ -1,17 +1,18 @@ using System; using HarmonyLib; +using Mirror; // ReSharper disable All namespace Synapse.Patches.EventsPatches.PlayerPatches { - [HarmonyPatch(typeof(ReferenceHub), nameof(ReferenceHub.OnDestroy))] + [HarmonyPatch(typeof(CustomNetworkManager), nameof(CustomNetworkManager.OnServerDisconnect))] internal static class PlayerLeavePatch { - private static void Prefix(ReferenceHub __instance) + private static void Prefix(NetworkConnection conn) { try { - var player = __instance.GetPlayer(); + var player = conn.identity.GetPlayer(); if (player.CustomRole != null) player.CustomRole = null; SynapseController.Server.Events.Player.InvokePlayerLeaveEvent(player); From 96c4f2ab7903f787f114881a781f2c5491406357 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Tue, 26 Jan 2021 20:41:50 +0100 Subject: [PATCH 28/39] Fixed Scp096 ScpAttack Event --- .../ScpPatches/Scp096/Scp096AttackPatch.cs | 112 ++++++++++++++++++ 1 file changed, 112 insertions(+) diff --git a/Synapse/Patches/EventsPatches/ScpPatches/Scp096/Scp096AttackPatch.cs b/Synapse/Patches/EventsPatches/ScpPatches/Scp096/Scp096AttackPatch.cs index a273ce56..d8c66ee3 100644 --- a/Synapse/Patches/EventsPatches/ScpPatches/Scp096/Scp096AttackPatch.cs +++ b/Synapse/Patches/EventsPatches/ScpPatches/Scp096/Scp096AttackPatch.cs @@ -92,4 +92,116 @@ private static IEnumerator NewAttackTriggerPhysics(PlayableScps.Scp096 __ yield break; } } + + [HarmonyPatch(typeof(PlayableScps.Scp096),nameof(PlayableScps.Scp096.ChargePlayer))] + internal static class Scp096AttackPatch2 + { + private static bool Prefix(PlayableScps.Scp096 __instance, ReferenceHub player) + { + try + { + if (!NetworkServer.active) return false; + + var scp = __instance.GetPlayer(); + var target = player.GetPlayer(); + if (!scp.WeaponManager.GetShootPermission(player.characterClassManager)) return false; + try + { + ev.Get.Scp.InvokeScpAttack(scp, target, Api.Enum.ScpAttackType.Scp096_Tear, out var allow); + if (!allow) return false; + } + catch (Exception e) + { + Synapse.Api.Logger.Get.Error($"Synapse-Event: ScpAttackEvent(Scp096-Charge) failed!!\n{e}\nStackTrace:\n{e.StackTrace}"); + } + + if (Physics.Linecast(scp.transform.position, player.transform.position, LayerMask.GetMask(new string[] + { + "Default", + "Door", + "Glass" + }))) + return false; + var flag = __instance._targets.Contains(player); + + if(scp.PlayerStats.HurtPlayer(new PlayerStats.HitInfo(flag ? 9696f : 35f,player.LoggedNameFromRefHub(),DamageTypes.Scp096, + scp.PlayerId), player.gameObject, false, true)) + { + __instance._targets.Remove(player); + NetworkServer.SendToClientOfPlayer(scp.NetworkIdentity, new PlayableScps.Messages.Scp096HitmarkerMessage(1.35f)); + NetworkServer.SendToAll(default(PlayableScps.Messages.Scp096OnKillMessage), 0); + } + if (flag) + __instance.EndChargeNextFrame(); + + return false; + } + catch(Exception e) + { + Synapse.Api.Logger.Get.Error($"Synapse-Event: Scp096AttackEvent(Charge) failed!!\n{e}\nStackTrace:\n{e.StackTrace}"); + return true; + } + } + } + + [HarmonyPatch(typeof(PlayableScps.Scp096), nameof(PlayableScps.Scp096.UpdatePry))] + internal static class Scp096AttackPatch3 + { + private static bool Prefix(PlayableScps.Scp096 __instance) + { + try + { + if (!__instance.PryingGate) + { + return false; + } + Collider[] array = Physics.OverlapSphere(__instance.Hub.playerMovementSync.RealModelPosition, 0.5f, LayerMask.GetMask(new string[] + { + "Hitbox" + })); + if (array.Length == 0) + { + return false; + } + Collider[] array2 = array; + for (int i = 0; i < array2.Length; i++) + { + ReferenceHub componentInParent = array2[i].gameObject.GetComponentInParent(); + + var scp = __instance.GetPlayer(); + var target = componentInParent.GetPlayer(); + if (!scp.WeaponManager.GetShootPermission(target.ClassManager)) continue; + try + { + ev.Get.Scp.InvokeScpAttack(scp, target, Api.Enum.ScpAttackType.Scp096_Tear, out var allow); + if (!allow) continue; + } + catch (Exception e) + { + Synapse.Api.Logger.Get.Error($"Synapse-Event: ScpAttackEvent(Scp096-Charge) failed!!\n{e}\nStackTrace:\n{e.StackTrace}"); + } + + if (!(componentInParent == null) && !(componentInParent == __instance.Hub) && !componentInParent.characterClassManager.IsAnyScp() && __instance.Hub.playerStats.HurtPlayer(new PlayerStats.HitInfo(9696f, __instance.Hub.LoggedNameFromRefHub(), DamageTypes.Scp096, __instance.Hub.queryProcessor.PlayerId), componentInParent.gameObject, false, true)) + { + if (__instance._targets.Contains(componentInParent)) + __instance._targets.Remove(componentInParent); + + NetworkServer.SendToAll(default(PlayableScps.Messages.Scp096OnKillMessage), 0); + } + } + if (Physics.Raycast(__instance.Hub.PlayerCameraReference.position, __instance.Hub.PlayerCameraReference.forward, 2f, LayerMask.GetMask(new string[] + { + "Default" + }))) + __instance.EndChargeNextFrame(); + + return false; + } + catch (Exception e) + { + Synapse.Api.Logger.Get.Error($"Synapse-Event: Scp096AttackEvent(Pry) failed!!\n{e}\nStackTrace:\n{e.StackTrace}"); + return true; + } + } + } } From e9e3c208c404c47fcaf8ef2f2007db10a9fccf11 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Wed, 27 Jan 2021 08:46:49 +0100 Subject: [PATCH 29/39] fixed that Custom scps can stop SCP173 --- .../Patches/SynapsePatches/InvisiblePatch.cs | 19 +++++++++++++++---- Synapse/SynapseExtensions.cs | 5 +++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Synapse/Patches/SynapsePatches/InvisiblePatch.cs b/Synapse/Patches/SynapsePatches/InvisiblePatch.cs index be4d0c16..73c611d0 100644 --- a/Synapse/Patches/SynapsePatches/InvisiblePatch.cs +++ b/Synapse/Patches/SynapsePatches/InvisiblePatch.cs @@ -57,10 +57,19 @@ private static bool Prefix(PlayerPositionManager __instance) var newplayer = players[k]; var vector = __instance._transmitBuffer[k].position - player.Position; - if (player.RoleType == RoleType.Scp173 && player.Scp173Controller.IgnoredPlayers.Contains(newplayer)) + if (player.RoleType == RoleType.Scp173) { - showinvoid = true; - goto AA_001; + if (player.Scp173Controller.IgnoredPlayers.Contains(newplayer)) + { + showinvoid = true; + goto AA_001; + } + else if (!SynapseExtensions.CanHarmScp(newplayer, false)) + { + var posinfo = __instance._transmitBuffer[k]; + var rot = Quaternion.LookRotation(newplayer.Position - player.Position).eulerAngles.y; + __instance._transmitBuffer[k] = new PlayerPositionData(posinfo.position, rot, posinfo.playerID); + } } if (newplayer.Invisible && !player.HasPermission("synapse.see.invisible")) @@ -164,8 +173,10 @@ private static void Postfix(ref bool __result, Scp173PlayerScript __instance, Ga { var player = __instance.GetPlayer(); var peanut = scp.GetPlayer(); + if (!__result) return; - __result = player?.Invisible != true && __result; + if (player.Invisible || !SynapseExtensions.CanHarmScp(player, false)) + __result = false; if (peanut.RoleType == RoleType.Scp173 && peanut.Scp173Controller.IgnoredPlayers.Contains(player)) __result = false; diff --git a/Synapse/SynapseExtensions.cs b/Synapse/SynapseExtensions.cs index 39de614d..80e7d268 100644 --- a/Synapse/SynapseExtensions.cs +++ b/Synapse/SynapseExtensions.cs @@ -57,11 +57,12 @@ public static void RaMessage(this CommandSender sender, string message, bool suc public static Synapse.Api.Items.SynapseItem GetSynapseItem(this Inventory.SyncItemInfo info) => Map.Get.Items.FirstOrDefault(x => x.itemInfo == info); public static Synapse.Api.Items.SynapseItem GetSynapseItem(this Pickup pickup) => Map.Get.Items.FirstOrDefault(x => x.pickup == pickup); - public static bool CanHarmScp(Player player) + public static bool CanHarmScp(Player player,bool message = true) { if (player.CustomRole != null && player.CustomRole.GetFriends().Any(x => x == Team.SCP)) { - player.GiveTextHint(Server.Get.Configs.synapseTranslation.ActiveTranslation.scpTeam); + if (message) + player.GiveTextHint(Server.Get.Configs.synapseTranslation.ActiveTranslation.scpTeam); return false; } return true; From 8e7e7ceebea2700df718bdf321c38a8c0f97975a Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Wed, 27 Jan 2021 08:58:57 +0100 Subject: [PATCH 30/39] added ScpTrigger173 config --- Synapse/Config/SynapseConfiguration.cs | 5 ++++- .../EventsPatches/ScpPatches/Scp096/Scp096TargetPatches.cs | 2 +- Synapse/Patches/SynapsePatches/InvisiblePatch.cs | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Synapse/Config/SynapseConfiguration.cs b/Synapse/Config/SynapseConfiguration.cs index 736676d7..68cd7302 100644 --- a/Synapse/Config/SynapseConfiguration.cs +++ b/Synapse/Config/SynapseConfiguration.cs @@ -41,7 +41,10 @@ public class SynapseConfiguration : AbstractConfigSection [Description("If disabled Chaos must kill all Scps to end the round")] public bool ChaosScpEnd = true; - [Description("If enabled custom Scps such as 035 can trigger Scp096's rage")] + [Description("If enabled custom Scps such as 035 can stop SCP-173 by looking at him")] + public bool ScpTrigger173 = false; + + [Description("If enabled custom Scps such as 035 can trigger SCP-096's rage")] public bool ScpTrigger096 = false; [Description("If Enabled Scp-079 and Scp-096 can't see the Player who is wearing Scp-268")] diff --git a/Synapse/Patches/EventsPatches/ScpPatches/Scp096/Scp096TargetPatches.cs b/Synapse/Patches/EventsPatches/ScpPatches/Scp096/Scp096TargetPatches.cs index 7b197100..9e56b1e8 100644 --- a/Synapse/Patches/EventsPatches/ScpPatches/Scp096/Scp096TargetPatches.cs +++ b/Synapse/Patches/EventsPatches/ScpPatches/Scp096/Scp096TargetPatches.cs @@ -69,7 +69,7 @@ private static bool Prefix(PlayableScps.Scp096 __instance, PlayerStats.HitInfo i if (player.Invisible || Server.Get.Configs.synapseConfiguration.CantRage096.Contains(player.RoleID)) return false; - if (player.RealTeam == Team.SCP && !Server.Get.Configs.synapseConfiguration.ScpTrigger096) + if (!SynapseExtensions.CanHarmScp(player, false) && !Server.Get.Configs.synapseConfiguration.ScpTrigger096) return false; Server.Get.Events.Scp.Scp096.InvokeScpTargetEvent(player, __instance.GetPlayer(), __instance.PlayerState, out var allow); diff --git a/Synapse/Patches/SynapsePatches/InvisiblePatch.cs b/Synapse/Patches/SynapsePatches/InvisiblePatch.cs index 73c611d0..01cd1879 100644 --- a/Synapse/Patches/SynapsePatches/InvisiblePatch.cs +++ b/Synapse/Patches/SynapsePatches/InvisiblePatch.cs @@ -64,7 +64,7 @@ private static bool Prefix(PlayerPositionManager __instance) showinvoid = true; goto AA_001; } - else if (!SynapseExtensions.CanHarmScp(newplayer, false)) + else if (!SynapseExtensions.CanHarmScp(newplayer, false) && !Server.Get.Configs.synapseConfiguration.ScpTrigger173) { var posinfo = __instance._transmitBuffer[k]; var rot = Quaternion.LookRotation(newplayer.Position - player.Position).eulerAngles.y; @@ -175,7 +175,7 @@ private static void Postfix(ref bool __result, Scp173PlayerScript __instance, Ga var peanut = scp.GetPlayer(); if (!__result) return; - if (player.Invisible || !SynapseExtensions.CanHarmScp(player, false)) + if (player.Invisible || (!SynapseExtensions.CanHarmScp(player, false) && !Server.Get.Configs.synapseConfiguration.ScpTrigger173)) __result = false; if (peanut.RoleType == RoleType.Scp173 && peanut.Scp173Controller.IgnoredPlayers.Contains(player)) From b5337c9ffdd55c07d4fdac1eb6ac02bd043b8308 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Thu, 28 Jan 2021 18:00:50 +0100 Subject: [PATCH 31/39] added Player.ExecuteCommand() --- Synapse/Api/Player.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index 95b6a433..5292b5f7 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -102,6 +102,8 @@ public void Hurt(int amount, DamageTypes.DamageType damagetype = default, Player public void AddDisplayInfo(PlayerInfoArea playerInfo) => NicknameSync.Network_playerInfoToShow |= playerInfo; + public void ExecuteCommand(string command, bool RA = true) => GameCore.Console.singleton.TypeCommand(RA ? "/" : "" + command, CommandSender); + public void SendToServer(ushort port) { var component = SynapseController.Server.Host.PlayerStats; From fbbaaa0cddce05c6bc6ba017d1a3ba4224726808 Mon Sep 17 00:00:00 2001 From: IGambleNull <38872139+Mika-Westphal@users.noreply.github.com> Date: Tue, 2 Feb 2021 20:09:08 +0100 Subject: [PATCH 32/39] Added offline bans --- Synapse/Server.cs | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/Synapse/Server.cs b/Synapse/Server.cs index fd5285d7..df16437c 100644 --- a/Synapse/Server.cs +++ b/Synapse/Server.cs @@ -113,6 +113,46 @@ public void Reload() PermissionHandler.Reload(); SynapseController.PluginLoader.ReloadConfigs(); } + + /// + /// Bans a player that is not on the server + /// + /// The reason for the ban + /// The person/SCP that banned the player + /// The person account id (e.g. xxxxxxxxxxx@steam) to ban + /// The duration for the ban in seconds + public void OfflineBanID(string reason, string issuer, string id, int duration) + { + BanHandler.IssueBan(new BanDetails() + { + Reason = reason, + Issuer = issuer, + Id = id, + OriginalName = "Unknown - offline ban", + IssuanceTime = DateTime.UtcNow.Ticks, + Expires = DateTime.UtcNow.AddSeconds(duration).Ticks + }, BanHandler.BanType.UserId); + } + + /// + /// Bans a IP + /// + /// The reason for the ban + /// The person/SCP that banned the player + /// The IPv4 or IPv6 to ban + /// The duration for the ban in seconds + public void OfflineBanIP(string reason, string issuer, string ip, int duration) + { + BanHandler.IssueBan(new BanDetails() + { + Reason = reason, + Issuer = issuer, + Id = ip, + OriginalName = "Unknown - offline ban", + IssuanceTime = DateTime.UtcNow.Ticks, + Expires = DateTime.UtcNow.AddSeconds(duration).Ticks + }, BanHandler.BanType.IP); + } public List GetObjectsOf() where TObject : UnityEngine.Object => UnityEngine.Object.FindObjectsOfType().ToList(); From bfc739de781320c9f88534c0b4b076db44432068 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Thu, 4 Feb 2021 19:56:11 +0100 Subject: [PATCH 33/39] fixed Map.TeslaTrigger Event --- Synapse/Api/Events/MapEvents.cs | 3 +-- .../SynapseEventArguments/MapEventArgs.cs | 2 -- .../MapPatches/TriggerTeslaPatch.cs | 26 ++++++------------- 3 files changed, 9 insertions(+), 22 deletions(-) diff --git a/Synapse/Api/Events/MapEvents.cs b/Synapse/Api/Events/MapEvents.cs index ef6dfc41..7b261d95 100644 --- a/Synapse/Api/Events/MapEvents.cs +++ b/Synapse/Api/Events/MapEvents.cs @@ -19,14 +19,13 @@ internal MapEvents() { } public event EventHandler.OnSynapseEvent Scp914ActivateEvent; #region Invoke - internal void InvokeTriggerTeslaEv(Player player,Tesla tesla,bool hurtrange,out bool trigger) + internal void InvokeTriggerTeslaEv(Player player, Tesla tesla, ref bool trigger) { trigger = true; var ev = new TriggerTeslaEventArgs { Player = player, Tesla = tesla, - HurtRange = hurtrange, Trigger = trigger }; diff --git a/Synapse/Api/Events/SynapseEventArguments/MapEventArgs.cs b/Synapse/Api/Events/SynapseEventArguments/MapEventArgs.cs index 25957e3f..9530001e 100644 --- a/Synapse/Api/Events/SynapseEventArguments/MapEventArgs.cs +++ b/Synapse/Api/Events/SynapseEventArguments/MapEventArgs.cs @@ -8,8 +8,6 @@ public class TriggerTeslaEventArgs : EventHandler.ISynapseEventArgs public Player Player { get; internal set; } - public bool HurtRange { get; internal set; } - public bool Trigger { get; set; } } diff --git a/Synapse/Patches/EventsPatches/MapPatches/TriggerTeslaPatch.cs b/Synapse/Patches/EventsPatches/MapPatches/TriggerTeslaPatch.cs index 594ee05d..77b0a7fd 100644 --- a/Synapse/Patches/EventsPatches/MapPatches/TriggerTeslaPatch.cs +++ b/Synapse/Patches/EventsPatches/MapPatches/TriggerTeslaPatch.cs @@ -1,39 +1,29 @@ using System; using HarmonyLib; -using System.Collections.Generic; -using Synapse.Api; -using System.Linq; using UnityEngine; using Logger = Synapse.Api.Logger; namespace Synapse.Patches.EventsPatches.MapPatches { - [HarmonyPatch(typeof(TeslaGate), nameof(TeslaGate.PlayersInRange))] + [HarmonyPatch(typeof(TeslaGate), nameof(TeslaGate.PlayerInRange))] internal static class TriggerTeslaPatch { - private static void Postfix(TeslaGate __instance, bool hurtRange, ref List __result) + private static bool Prefix(TeslaGate __instance, out bool __result, ReferenceHub player) { + __result = false; try { - __result = new List(); - var Tesla = Map.Get.Teslas.FirstOrDefault(x => x.GameObject == __instance.gameObject); + __result = Vector3.Distance(__instance.transform.position, player.playerMovementSync.RealModelPosition) < __instance.sizeOfTrigger; - foreach(var player in SynapseController.Server.Players) - { - if (Vector3.Distance(Tesla.Position, player.Position) > Tesla.SizeOfTrigger || player.IsDead) - continue; + if (__result) + Server.Get.Events.Map.InvokeTriggerTeslaEv(player.GetPlayer(), __instance.GetTesla(), ref __result); - if (player.Invisible) - continue; - - SynapseController.Server.Events.Map.InvokeTriggerTeslaEv(player, Tesla, hurtRange, out var trigger); - - if (trigger) __result.Add(player.PlayerStats); - } + return false; } catch (Exception e) { Logger.Get.Error($"Synapse-Event: TriggerTesla failed!!\n{e}\nStackTrace:\n{e.StackTrace}"); + return true; } } } From be5a88dcf8cc1a14ca37d9c555a1e750b9ba218b Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Fri, 5 Feb 2021 16:10:33 +0100 Subject: [PATCH 34/39] added SynapseTeam API --- Synapse/Api/Player.cs | 4 +- Synapse/Api/Roles/IRole.cs | 6 +-- Synapse/Api/Roles/Role.cs | 17 ++++++-- Synapse/Api/Roles/RoleManager.cs | 1 + Synapse/Api/Teams/ISynapseTeam.cs | 11 ++++++ Synapse/Api/Teams/SynapseTeam.cs | 11 ++++++ Synapse/Api/Teams/SynapseTeamInformation.cs | 11 ++++++ Synapse/Api/Teams/TeamManager.cs | 39 +++++++++++++++++++ .../RoundPatches/RoundCheckPatch.cs | 5 ++- .../Scp106/PocketDimensionPatches.cs | 2 +- .../SynapsePatches/ShootPermissionPatch.cs | 4 +- Synapse/Server.cs | 3 ++ Synapse/Synapse.csproj | 4 ++ Synapse/SynapseExtensions.cs | 4 +- 14 files changed, 109 insertions(+), 13 deletions(-) create mode 100644 Synapse/Api/Teams/ISynapseTeam.cs create mode 100644 Synapse/Api/Teams/SynapseTeam.cs create mode 100644 Synapse/Api/Teams/SynapseTeamInformation.cs create mode 100644 Synapse/Api/Teams/TeamManager.cs diff --git a/Synapse/Api/Player.cs b/Synapse/Api/Player.cs index 5292b5f7..174419aa 100644 --- a/Synapse/Api/Player.cs +++ b/Synapse/Api/Player.cs @@ -732,7 +732,9 @@ public CommandSender CommandSender public Team Team => ClassManager.CurRole.team; - public Team RealTeam => (CustomRole == null) ? Team : CustomRole.GetTeam(); + public int TeamID => CustomRole == null ? (int)Team : CustomRole.GetTeamID(); + + public Team RealTeam => Server.Get.TeamManager.IsDefaultID(TeamID) ? (Team)TeamID : Team.RIP; public Fraction Fraction => ClassManager.Fraction; diff --git a/Synapse/Api/Roles/IRole.cs b/Synapse/Api/Roles/IRole.cs index 38fecba8..29e0a72d 100644 --- a/Synapse/Api/Roles/IRole.cs +++ b/Synapse/Api/Roles/IRole.cs @@ -10,11 +10,11 @@ public interface IRole int GetRoleID(); - Team GetTeam(); + int GetTeamID(); - List GetFriends(); + List GetFriendsID(); - List GetEnemys(); + List GetEnemiesID(); int GetEscapeRole(); diff --git a/Synapse/Api/Roles/Role.cs b/Synapse/Api/Roles/Role.cs index 9b7b86ca..f484350f 100644 --- a/Synapse/Api/Roles/Role.cs +++ b/Synapse/Api/Roles/Role.cs @@ -1,4 +1,6 @@ using System.Collections.Generic; +using System.Linq; +using System; namespace Synapse.Api.Roles { @@ -25,11 +27,11 @@ public Player Player public abstract int GetRoleID(); - public abstract Team GetTeam(); + public virtual int GetTeamID() => (int)GetTeam(); - public virtual List GetFriends() => new List(); + public virtual List GetFriendsID() => GetFriends().Select(x => (int)x).ToList(); - public virtual List GetEnemys() => new List(); + public virtual List GetEnemiesID() => GetEnemys().Select(x => (int)x).ToList(); public virtual int GetEscapeRole() => -1; @@ -38,5 +40,14 @@ public Player Player public virtual void DeSpawn() { } public virtual void Escape() { } + + #region Obsolete + [Obsolete("Use GetTeamID()",false)] + public virtual Team GetTeam() => Team.RIP; + [Obsolete("Use GetFriendsID()", false)] + public virtual List GetFriends() => new List(); + [Obsolete("Use GetEnemiesID()", false)] + public virtual List GetEnemys() => new List(); + #endregion } } diff --git a/Synapse/Api/Roles/RoleManager.cs b/Synapse/Api/Roles/RoleManager.cs index 0a73de8f..9a2e7510 100644 --- a/Synapse/Api/Roles/RoleManager.cs +++ b/Synapse/Api/Roles/RoleManager.cs @@ -39,6 +39,7 @@ public void RegisterCustomRole() where TRole : IRole var role = (IRole)Activator.CreateInstance(typeof(TRole)); if (role.GetRoleID() >= 0 && role.GetRoleID() <= HighestRole) throw new Exception("A Plugin tried to register a CustomRole with an Id of a vanilla RoleType"); + if (!Server.Get.TeamManager.IsIDRegistered(role.GetTeamID())) Logger.Get.Warn($"The role {role.GetRoleName()} is using a not registered Team"); var pair = new KeyValuePair(role.GetRoleName(), role.GetRoleID()); diff --git a/Synapse/Api/Teams/ISynapseTeam.cs b/Synapse/Api/Teams/ISynapseTeam.cs new file mode 100644 index 00000000..11ed3dce --- /dev/null +++ b/Synapse/Api/Teams/ISynapseTeam.cs @@ -0,0 +1,11 @@ +namespace Synapse.Api.Teams +{ + public interface ISynapseTeam + { + SynapseTeamInformation Info { get; set; } + + void Spawn(); + + void Initialise(); + } +} diff --git a/Synapse/Api/Teams/SynapseTeam.cs b/Synapse/Api/Teams/SynapseTeam.cs new file mode 100644 index 00000000..848fd29a --- /dev/null +++ b/Synapse/Api/Teams/SynapseTeam.cs @@ -0,0 +1,11 @@ +namespace Synapse.Api.Teams +{ + public abstract class SynapseTeam : ISynapseTeam + { + public SynapseTeamInformation Info { get; set; } + + public abstract void Spawn(); + + public virtual void Initialise() { } + } +} diff --git a/Synapse/Api/Teams/SynapseTeamInformation.cs b/Synapse/Api/Teams/SynapseTeamInformation.cs new file mode 100644 index 00000000..9c2223d2 --- /dev/null +++ b/Synapse/Api/Teams/SynapseTeamInformation.cs @@ -0,0 +1,11 @@ +using System; + +namespace Synapse.Api.Teams +{ + public class SynapseTeamInformation : Attribute + { + public int ID { get; set; } + + public string Name { get; set; } + } +} diff --git a/Synapse/Api/Teams/TeamManager.cs b/Synapse/Api/Teams/TeamManager.cs new file mode 100644 index 00000000..b82c8b69 --- /dev/null +++ b/Synapse/Api/Teams/TeamManager.cs @@ -0,0 +1,39 @@ +using System; +using System.Linq; +using System.Collections.Generic; +using System.Reflection; + +namespace Synapse.Api.Teams +{ + public class TeamManager + { + internal TeamManager() { } + + private readonly List teams = new List(); + + public void RegisterTeam() where TTeam : ISynapseTeam + { + var team = Activator.CreateInstance(typeof(TTeam)) as ISynapseTeam; + if (team.Info == null) + team.Info = typeof(TTeam).GetCustomAttribute(); + + if (IsIDRegistered(team.Info.ID)) throw new Exception("A Plugin tried to register a CustomTeam with an already used Id"); + + teams.Add(team); + team.Initialise(); + } + + public bool IsIDRegistered(int id) => (id >= (int)Team.SCP && id <= (int)Team.TUT) || teams.Any(x => x.Info.ID == id); + + public bool IsDefaultID(int id) => id >= (int)Team.SCP && id <= (int)Team.TUT; + + public void SpawnTeam(int id) + { + var team = teams.FirstOrDefault(x => x.Info.ID == id); + if (team == null) return; + team.Spawn(); + } + + public ISynapseTeam GetTeam(int id) => teams.FirstOrDefault(x => x.Info.ID == id); + } +} diff --git a/Synapse/Patches/EventsPatches/RoundPatches/RoundCheckPatch.cs b/Synapse/Patches/EventsPatches/RoundPatches/RoundCheckPatch.cs index 440c4221..2868f908 100644 --- a/Synapse/Patches/EventsPatches/RoundPatches/RoundCheckPatch.cs +++ b/Synapse/Patches/EventsPatches/RoundPatches/RoundCheckPatch.cs @@ -43,6 +43,8 @@ public static IEnumerator ProcessServerSide(RoundSummary instance) yield return Timing.WaitForOneFrame; var teams = new List(); + //I know it's a lazy solution but it should work + var teamids = new List(); var customroles = new List(); @@ -59,6 +61,7 @@ public static IEnumerator ProcessServerSide(RoundSummary instance) if (player.CustomRole != null) customroles.Add(player.CustomRole); + teamids.Add(player.TeamID); teams.Add(player.RealTeam); switch (player.RealTeam) @@ -128,7 +131,7 @@ public static IEnumerator ProcessServerSide(RoundSummary instance) } foreach (var role in customroles) - if (role.GetEnemys().Any(x => teams.Contains(x))) + if (role.GetEnemiesID().Any(x => teamids.Contains(x))) endround = false; if (RoundSummary.escaped_ds + teams.Count(x => x == Team.CDP) > 0) diff --git a/Synapse/Patches/EventsPatches/ScpPatches/Scp106/PocketDimensionPatches.cs b/Synapse/Patches/EventsPatches/ScpPatches/Scp106/PocketDimensionPatches.cs index 4789e2d1..b7cc44d3 100644 --- a/Synapse/Patches/EventsPatches/ScpPatches/Scp106/PocketDimensionPatches.cs +++ b/Synapse/Patches/EventsPatches/ScpPatches/Scp106/PocketDimensionPatches.cs @@ -113,7 +113,7 @@ private static bool Prefix(PocketDimensionTeleport __instance, Collider other) var pos = __instance.tpPositions[UnityEngine.Random.Range(0, __instance.tpPositions.Count)]; pos.y += 2f; - if ((player.CustomRole != null && player.CustomRole.GetFriends().Any(x => x == Team.SCP)) || player.Team == Team.SCP) + if (SynapseExtensions.CanNotHurtByScp(player) || player.Team == Team.SCP) type = PocketDimensionTeleport.PDTeleportType.Exit; EventHandler.Get.Scp.Scp106.InvokePocketDimensionLeaveEvent(player, ref pos, ref type, out var allow); diff --git a/Synapse/Patches/SynapsePatches/ShootPermissionPatch.cs b/Synapse/Patches/SynapsePatches/ShootPermissionPatch.cs index 4800eb93..08a44218 100644 --- a/Synapse/Patches/SynapsePatches/ShootPermissionPatch.cs +++ b/Synapse/Patches/SynapsePatches/ShootPermissionPatch.cs @@ -30,7 +30,7 @@ private static bool Prefix(WeaponManager __instance,out bool __result, Character { if (shooter.CustomRole != null) { - if (shooter.CustomRole.GetFriends().Any(x => x == target.RealTeam)) + if (shooter.CustomRole.GetFriendsID().Any(x => x == target.TeamID)) { __result = false; shooter.GiveTextHint(Server.Get.Configs.synapseTranslation.ActiveTranslation.sameTeam); @@ -38,7 +38,7 @@ private static bool Prefix(WeaponManager __instance,out bool __result, Character } if (target.CustomRole != null) { - if (target.CustomRole.GetFriends().Any(x => x == shooter.RealTeam)) + if (target.CustomRole.GetFriendsID().Any(x => x == shooter.TeamID)) { __result = false; shooter.GiveTextHint(Server.Get.Configs.synapseTranslation.ActiveTranslation.sameTeam); diff --git a/Synapse/Server.cs b/Synapse/Server.cs index df16437c..e2b403b5 100644 --- a/Synapse/Server.cs +++ b/Synapse/Server.cs @@ -10,6 +10,7 @@ using Synapse.Api.Plugin; using Synapse.Api.Roles; using Synapse.Api.Items; +using Synapse.Api.Teams; namespace Synapse { @@ -32,6 +33,8 @@ internal Server() { } public RoleManager RoleManager { get; } = new RoleManager(); + public TeamManager TeamManager { get; } = new TeamManager(); + public ItemManager ItemManager { get; } = new ItemManager(); public ConfigHandler Configs { get; } = new ConfigHandler(); diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index c7da1abd..1c5817e1 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -49,6 +49,10 @@ + + + + diff --git a/Synapse/SynapseExtensions.cs b/Synapse/SynapseExtensions.cs index 80e7d268..ebb58c5b 100644 --- a/Synapse/SynapseExtensions.cs +++ b/Synapse/SynapseExtensions.cs @@ -59,7 +59,7 @@ public static void RaMessage(this CommandSender sender, string message, bool suc public static bool CanHarmScp(Player player,bool message = true) { - if (player.CustomRole != null && player.CustomRole.GetFriends().Any(x => x == Team.SCP)) + if (player.Team == Team.SCP || player.CustomRole != null && player.CustomRole.GetFriendsID().Any(x => x == (int)Team.SCP)) { if (message) player.GiveTextHint(Server.Get.Configs.synapseTranslation.ActiveTranslation.scpTeam); @@ -68,5 +68,5 @@ public static bool CanHarmScp(Player player,bool message = true) return true; } - public static bool CanNotHurtByScp(Player player) => player.Team == Team.SCP || player.CustomRole == null ? false : player.CustomRole.GetFriends().Any(x => x == Team.SCP); + public static bool CanNotHurtByScp(Player player) => player.Team == Team.SCP || player.CustomRole == null ? false : player.CustomRole.GetFriendsID().Any(x => x == (int)Team.SCP); } \ No newline at end of file From acd33b91e01c968a439d37e6f2348504d2d41d2c Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Fri, 5 Feb 2021 18:46:30 +0100 Subject: [PATCH 35/39] added TeamRespawnEventArgs.TeamID --- Synapse/Api/Events/EventHandler.cs | 11 ++----- Synapse/Api/Events/RoundEvents.cs | 3 +- .../SynapseEventArguments/RoundEventArgs.cs | 32 ++++++++++++++++++- Synapse/Api/Round.cs | 7 ++++ .../RoundPatches/TeamRespawnPatch.cs | 8 ++++- .../Patches/SynapsePatches/InvisiblePatch.cs | 2 +- 6 files changed, 50 insertions(+), 13 deletions(-) diff --git a/Synapse/Api/Events/EventHandler.cs b/Synapse/Api/Events/EventHandler.cs index dd870c0b..788bc747 100644 --- a/Synapse/Api/Events/EventHandler.cs +++ b/Synapse/Api/Events/EventHandler.cs @@ -20,18 +20,11 @@ private void KeyPress(SynapseEventArguments.PlayerKeyPressEventArgs ev) switch (ev.KeyCode) { case KeyCode.Alpha1: - foreach (var door in ev.Player.Room.Doors) - door.Position += Vector3.up; + ev.Player.GiveTextHint("Next spawn in : " + SynapseController.Server.Map.Round.NextRespawn.ToString()); break; case KeyCode.Alpha2: - foreach (var door in ev.Player.Room.Doors) - door.Open = !door.Open; - break; - - case KeyCode.Alpha3: - foreach (var door in ev.Player.Room.Doors) - door.Locked = !door.Locked; + SynapseController.Server.Map.Round.NextRespawn = 20; break; } } diff --git a/Synapse/Api/Events/RoundEvents.cs b/Synapse/Api/Events/RoundEvents.cs index 85d0e891..77151d4d 100644 --- a/Synapse/Api/Events/RoundEvents.cs +++ b/Synapse/Api/Events/RoundEvents.cs @@ -56,7 +56,7 @@ internal void InvokeSpawnPlayersEvent(ref Dictionary spawnplayers, allow = ev.Allow; } - internal void InvokeTeamRespawn(ref List players,ref Respawning.SpawnableTeamType teamType, out bool allow) + internal void InvokeTeamRespawn(ref List players,ref Respawning.SpawnableTeamType teamType, out bool allow,out int teamid) { var ev = new TeamRespawnEventArgs { @@ -69,6 +69,7 @@ internal void InvokeTeamRespawn(ref List players,ref Respawning.Spawnabl players = ev.Players; teamType = ev.Team; allow = ev.Allow; + teamid = ev.TeamID; } #endregion } diff --git a/Synapse/Api/Events/SynapseEventArguments/RoundEventArgs.cs b/Synapse/Api/Events/SynapseEventArguments/RoundEventArgs.cs index 1fd80785..aa8ce81f 100644 --- a/Synapse/Api/Events/SynapseEventArguments/RoundEventArgs.cs +++ b/Synapse/Api/Events/SynapseEventArguments/RoundEventArgs.cs @@ -21,7 +21,37 @@ public class SpawnPlayersEventArgs: EventHandler.ISynapseEventArgs public class TeamRespawnEventArgs : EventHandler.ISynapseEventArgs { - public Respawning.SpawnableTeamType Team { get; set; } + private int team; + + public Respawning.SpawnableTeamType Team + { + get + { + switch (team) + { + case 1: return Respawning.SpawnableTeamType.NineTailedFox; + case 2: return Respawning.SpawnableTeamType.ChaosInsurgency; + default: return Respawning.SpawnableTeamType.None; + } + } + set + { + switch (value) + { + case Respawning.SpawnableTeamType.NineTailedFox: + team = 1; + break; + case Respawning.SpawnableTeamType.ChaosInsurgency: + team = 2; + break; + default: + team = -1; + break; + } + } + } + + public int TeamID { get => team; set => team = value; } public List Players { get; set; } diff --git a/Synapse/Api/Round.cs b/Synapse/Api/Round.cs index fab67558..8ac690b7 100644 --- a/Synapse/Api/Round.cs +++ b/Synapse/Api/Round.cs @@ -10,9 +10,16 @@ public class Round internal Round() { } private RoundSummary rs => RoundSummary.singleton; + private RespawnManager rm => RespawnManager.Singleton; public int CurrentRound { get; internal set; } = 0; + public float NextRespawn + { + get => rm._timeForNextSequence - rm._stopwatch.Elapsed.Seconds; + set => rm._timeForNextSequence = value + rm._stopwatch.Elapsed.Seconds; + } + public bool LobbyLock { get => RoundStart.LobbyLock; diff --git a/Synapse/Patches/EventsPatches/RoundPatches/TeamRespawnPatch.cs b/Synapse/Patches/EventsPatches/RoundPatches/TeamRespawnPatch.cs index b007f415..b6a8c788 100644 --- a/Synapse/Patches/EventsPatches/RoundPatches/TeamRespawnPatch.cs +++ b/Synapse/Patches/EventsPatches/RoundPatches/TeamRespawnPatch.cs @@ -52,10 +52,16 @@ orderby item.characterClassManager.DeathTime var players = list.Select(x => x.GetPlayer()).ToList(); var team = __instance.NextKnownTeam; - SynapseController.Server.Events.Round.InvokeTeamRespawn(ref players, ref team, out var allow); + SynapseController.Server.Events.Round.InvokeTeamRespawn(ref players, ref team, out var allow, out var id); if (!allow) return false; + if(team == SpawnableTeamType.None) + { + Server.Get.TeamManager.SpawnTeam(id); + return false; + } + list = players.Select(x => x.Hub).ToList(); __instance.NextKnownTeam = team; diff --git a/Synapse/Patches/SynapsePatches/InvisiblePatch.cs b/Synapse/Patches/SynapsePatches/InvisiblePatch.cs index 01cd1879..7a70f4dd 100644 --- a/Synapse/Patches/SynapsePatches/InvisiblePatch.cs +++ b/Synapse/Patches/SynapsePatches/InvisiblePatch.cs @@ -160,7 +160,7 @@ private static bool Prefix(PlayerPositionManager __instance) } catch (Exception e) { - Api.Logger.Get.Error($"Synapse-InvisibleMode: TransmitData failed failed!!\n{e}\nStackTrace:\n{e.StackTrace}"); + Api.Logger.Get.Error($"Synapse-InvisibleMode: TransmitData failed!!\n{e}\nStackTrace:\n{e.StackTrace}"); return true; } } From e82729a8e088bd6239109714a55fb0c2cfd969e1 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Fri, 5 Feb 2021 18:56:51 +0100 Subject: [PATCH 36/39] added player list to ISynapseTeam.Spawn() --- Synapse/Api/Teams/ISynapseTeam.cs | 6 ++++-- Synapse/Api/Teams/SynapseTeam.cs | 6 ++++-- Synapse/Api/Teams/TeamManager.cs | 4 ++-- .../Patches/EventsPatches/RoundPatches/TeamRespawnPatch.cs | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Synapse/Api/Teams/ISynapseTeam.cs b/Synapse/Api/Teams/ISynapseTeam.cs index 11ed3dce..5d92c4c8 100644 --- a/Synapse/Api/Teams/ISynapseTeam.cs +++ b/Synapse/Api/Teams/ISynapseTeam.cs @@ -1,10 +1,12 @@ -namespace Synapse.Api.Teams +using System.Collections.Generic; + +namespace Synapse.Api.Teams { public interface ISynapseTeam { SynapseTeamInformation Info { get; set; } - void Spawn(); + void Spawn(List players); void Initialise(); } diff --git a/Synapse/Api/Teams/SynapseTeam.cs b/Synapse/Api/Teams/SynapseTeam.cs index 848fd29a..b71fdf2e 100644 --- a/Synapse/Api/Teams/SynapseTeam.cs +++ b/Synapse/Api/Teams/SynapseTeam.cs @@ -1,10 +1,12 @@ -namespace Synapse.Api.Teams +using System.Collections.Generic; + +namespace Synapse.Api.Teams { public abstract class SynapseTeam : ISynapseTeam { public SynapseTeamInformation Info { get; set; } - public abstract void Spawn(); + public abstract void Spawn(List players); public virtual void Initialise() { } } diff --git a/Synapse/Api/Teams/TeamManager.cs b/Synapse/Api/Teams/TeamManager.cs index b82c8b69..ca9c7321 100644 --- a/Synapse/Api/Teams/TeamManager.cs +++ b/Synapse/Api/Teams/TeamManager.cs @@ -27,11 +27,11 @@ public void RegisterTeam() where TTeam : ISynapseTeam public bool IsDefaultID(int id) => id >= (int)Team.SCP && id <= (int)Team.TUT; - public void SpawnTeam(int id) + public void SpawnTeam(int id,List players) { var team = teams.FirstOrDefault(x => x.Info.ID == id); if (team == null) return; - team.Spawn(); + team.Spawn(players); } public ISynapseTeam GetTeam(int id) => teams.FirstOrDefault(x => x.Info.ID == id); diff --git a/Synapse/Patches/EventsPatches/RoundPatches/TeamRespawnPatch.cs b/Synapse/Patches/EventsPatches/RoundPatches/TeamRespawnPatch.cs index b6a8c788..ce2e03c5 100644 --- a/Synapse/Patches/EventsPatches/RoundPatches/TeamRespawnPatch.cs +++ b/Synapse/Patches/EventsPatches/RoundPatches/TeamRespawnPatch.cs @@ -58,7 +58,7 @@ orderby item.characterClassManager.DeathTime if(team == SpawnableTeamType.None) { - Server.Get.TeamManager.SpawnTeam(id); + Server.Get.TeamManager.SpawnTeam(id,players); return false; } From 8fa12da7cbadaeeab5d1582aa776f3b20661da87 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Fri, 5 Feb 2021 19:31:08 +0100 Subject: [PATCH 37/39] added SynapseRespawnCommand --- .../Commands/SynapseGiveCustomItemCommand.cs | 7 --- .../Command/Commands/SynapseHelpCommand.cs | 8 --- .../Commands/SynapseMapPointCommand.cs | 6 --- .../Command/Commands/SynapsePluginCommand.cs | 7 --- .../Command/Commands/SynapseReloadCommand.cs | 7 --- .../Command/Commands/SynapseRespawnCommand.cs | 50 +++++++++++++++++++ .../Commands/SynapseSetClassCommand.cs | 7 --- Synapse/Command/Handlers.cs | 1 + Synapse/Synapse.csproj | 1 + 9 files changed, 52 insertions(+), 42 deletions(-) create mode 100644 Synapse/Command/Commands/SynapseRespawnCommand.cs diff --git a/Synapse/Command/Commands/SynapseGiveCustomItemCommand.cs b/Synapse/Command/Commands/SynapseGiveCustomItemCommand.cs index 806823c9..017c26e5 100644 --- a/Synapse/Command/Commands/SynapseGiveCustomItemCommand.cs +++ b/Synapse/Command/Commands/SynapseGiveCustomItemCommand.cs @@ -16,13 +16,6 @@ public CommandResult Execute(CommandContext context) { var result = new CommandResult(); - if (!context.Player.HasPermission("synapse.command.give")) - { - result.Message = "You don't have permission to use this command"; - result.State = CommandResultState.NoPermission; - return result; - } - if(context.Arguments.Count < 2) { result.Message = "Missing parameter! Command Usage: give player itemid"; diff --git a/Synapse/Command/Commands/SynapseHelpCommand.cs b/Synapse/Command/Commands/SynapseHelpCommand.cs index 748ab512..2180ad8b 100644 --- a/Synapse/Command/Commands/SynapseHelpCommand.cs +++ b/Synapse/Command/Commands/SynapseHelpCommand.cs @@ -18,14 +18,6 @@ public CommandResult Execute(CommandContext context) { var result = new CommandResult(); - if (!context.Player.HasPermission("synapse.command.help")) - { - result.State = CommandResultState.NoPermission; - result.Message = "You don't have permission to use this command"; - return result; - } - - List commandlist; diff --git a/Synapse/Command/Commands/SynapseMapPointCommand.cs b/Synapse/Command/Commands/SynapseMapPointCommand.cs index 74901d5f..43798cc8 100644 --- a/Synapse/Command/Commands/SynapseMapPointCommand.cs +++ b/Synapse/Command/Commands/SynapseMapPointCommand.cs @@ -16,12 +16,6 @@ public class SynapseMapPointCommand : ISynapseCommand public CommandResult Execute(CommandContext context) { var result = new CommandResult(); - if (!context.Player.HasPermission("synapse.command.mappoint")) - { - result.Message = "You don't have permission to use this command"; - result.State = CommandResultState.NoPermission; - return result; - } Physics.Raycast(context.Player.CameraReference.transform.position, context.Player.CameraReference.transform.forward, out RaycastHit raycastthit, 100f); diff --git a/Synapse/Command/Commands/SynapsePluginCommand.cs b/Synapse/Command/Commands/SynapsePluginCommand.cs index e5d0d7a1..f872bc87 100644 --- a/Synapse/Command/Commands/SynapsePluginCommand.cs +++ b/Synapse/Command/Commands/SynapsePluginCommand.cs @@ -16,13 +16,6 @@ public CommandResult Execute(CommandContext context) { var result = new CommandResult(); - if (!context.Player.HasPermission("synapse.command.plugins")) - { - result.Message = "You don't have permission to use this command"; - result.State = CommandResultState.NoPermission; - return result; - } - if(context.Arguments.Count > 0) { var pl = SynapseController.PluginLoader.Plugins.FirstOrDefault(x => x.Name.ToUpper() == context.Arguments.First().ToUpper()); diff --git a/Synapse/Command/Commands/SynapseReloadCommand.cs b/Synapse/Command/Commands/SynapseReloadCommand.cs index 735c15f6..294d644a 100644 --- a/Synapse/Command/Commands/SynapseReloadCommand.cs +++ b/Synapse/Command/Commands/SynapseReloadCommand.cs @@ -15,13 +15,6 @@ public CommandResult Execute(CommandContext context) { var result = new CommandResult(); - if (!context.Player.HasPermission("synapse.command.reload")) - { - result.State = CommandResultState.NoPermission; - result.Message = "You don't have permission to use this command"; - return result; - } - try { Server.Get.Reload(); diff --git a/Synapse/Command/Commands/SynapseRespawnCommand.cs b/Synapse/Command/Commands/SynapseRespawnCommand.cs new file mode 100644 index 00000000..2ee59822 --- /dev/null +++ b/Synapse/Command/Commands/SynapseRespawnCommand.cs @@ -0,0 +1,50 @@ +using System.Linq; + +namespace Synapse.Command.Commands +{ + [CommandInformation( + Name = "respawn", + Aliases = new string[] { "spawn" }, + Description = "spawns a specific tea,", + Usage = "respawn teamid size", + Permission = "synapse.command.respawn", + Platforms = new[] { Platform.ClientConsole, Platform.RemoteAdmin, Platform.ServerConsole } + )] + public class SynapseRespawnCommand : ISynapseCommand + { + public CommandResult Execute(CommandContext context) + { + if (context.Arguments.Count < 1) return new CommandResult + { + Message = "Missing parameter! Usage: spawn teamid", + State = CommandResultState.Error + }; + + if (!int.TryParse(context.Arguments.At(0), out var id)) return new CommandResult + { + Message = "Invalid Team ID", + State = CommandResultState.Error + }; + var players = RoleType.Spectator.GetPlayers().Where(x => !x.OverWatch).ToList(); + + if (context.Arguments.Count > 1 && int.TryParse(context.Arguments.At(1), out var size)) + { + if (players.Count > size) + players = players.GetRange(0, size); + } + + if (players.Count < 1) return new CommandResult + { + Message = "Not enough players to respawn", + State = CommandResultState.Error + }; + + Server.Get.TeamManager.SpawnTeam(id,players); + return new CommandResult + { + Message = "Team was spawned", + State = CommandResultState.Ok + }; + } + } +} diff --git a/Synapse/Command/Commands/SynapseSetClassCommand.cs b/Synapse/Command/Commands/SynapseSetClassCommand.cs index 377ed998..8b3d929f 100644 --- a/Synapse/Command/Commands/SynapseSetClassCommand.cs +++ b/Synapse/Command/Commands/SynapseSetClassCommand.cs @@ -16,13 +16,6 @@ public CommandResult Execute(CommandContext context) { var result = new CommandResult(); - if (!context.Player.HasPermission("synapse.command.setclass")) - { - result.Message = "You don't have permission to use this command"; - result.State = CommandResultState.NoPermission; - return result; - } - if(context.Arguments.Count < 2) { result.Message = "Missing Parameters! Command Usage: setclass player RoleID"; diff --git a/Synapse/Command/Handlers.cs b/Synapse/Command/Handlers.cs index 97f0c682..8c872901 100644 --- a/Synapse/Command/Handlers.cs +++ b/Synapse/Command/Handlers.cs @@ -26,6 +26,7 @@ internal void RegisterSynapseCommands() RegisterCommand(new SynapseGiveCustomItemCommand(), false); RegisterCommand(new SynapseSetClassCommand(), false); RegisterCommand(new SynapseMapPointCommand(), false); + RegisterCommand(new SynapseRespawnCommand(), false); } internal static void RegisterCommand(ISynapseCommand iSynapseCommand, bool awaitPluginInitialisation) diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index 1c5817e1..d97deb89 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -102,6 +102,7 @@ + From 7f990711e46dd247b87cd303d80e942a87e15cd2 Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Fri, 5 Feb 2021 20:56:07 +0100 Subject: [PATCH 38/39] fixed Invisible Tesla bug --- .../Patches/EventsPatches/MapPatches/TriggerTeslaPatch.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Synapse/Patches/EventsPatches/MapPatches/TriggerTeslaPatch.cs b/Synapse/Patches/EventsPatches/MapPatches/TriggerTeslaPatch.cs index 77b0a7fd..cdd1c908 100644 --- a/Synapse/Patches/EventsPatches/MapPatches/TriggerTeslaPatch.cs +++ b/Synapse/Patches/EventsPatches/MapPatches/TriggerTeslaPatch.cs @@ -13,10 +13,13 @@ private static bool Prefix(TeslaGate __instance, out bool __result, ReferenceHub __result = false; try { + var synapseplayer = player.GetPlayer(); + if (synapseplayer.Invisible) return false; + __result = Vector3.Distance(__instance.transform.position, player.playerMovementSync.RealModelPosition) < __instance.sizeOfTrigger; if (__result) - Server.Get.Events.Map.InvokeTriggerTeslaEv(player.GetPlayer(), __instance.GetTesla(), ref __result); + Server.Get.Events.Map.InvokeTriggerTeslaEv(synapseplayer, __instance.GetTesla(), ref __result); return false; } From 2a8fda3306c153655ffa36741e96aa7ce0e219bc Mon Sep 17 00:00:00 2001 From: GrafDimenzio Date: Sat, 6 Feb 2021 11:32:47 +0100 Subject: [PATCH 39/39] fixed Tesla event null exception --- Synapse/Api/Events/MapEvents.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Synapse/Api/Events/MapEvents.cs b/Synapse/Api/Events/MapEvents.cs index 7b261d95..fb9ddd01 100644 --- a/Synapse/Api/Events/MapEvents.cs +++ b/Synapse/Api/Events/MapEvents.cs @@ -29,7 +29,7 @@ internal void InvokeTriggerTeslaEv(Player player, Tesla tesla, ref bool trigger) Trigger = trigger }; - TriggerTeslaEvent.Invoke(ev); + TriggerTeslaEvent?.Invoke(ev); trigger = ev.Trigger; }