From 40c7b0a35dee1182581b3ed1d318b46f10e161e6 Mon Sep 17 00:00:00 2001 From: NotZer0Two Date: Sat, 10 Aug 2024 18:11:00 +0200 Subject: [PATCH 1/6] Added ScenesType and Corrisponding Methods for the Server and Player --- EXILED/Exiled.API/Enums/ScenesType.cs | 40 +++++++++++++++++++++++++++ EXILED/Exiled.API/Features/Player.cs | 20 ++++++++++++++ EXILED/Exiled.API/Features/Server.cs | 22 +++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 EXILED/Exiled.API/Enums/ScenesType.cs diff --git a/EXILED/Exiled.API/Enums/ScenesType.cs b/EXILED/Exiled.API/Enums/ScenesType.cs new file mode 100644 index 0000000000..f75fa0bf50 --- /dev/null +++ b/EXILED/Exiled.API/Enums/ScenesType.cs @@ -0,0 +1,40 @@ +namespace Exiled.API.Enums +{ + /// + /// Unique identifier for the different types of Scenes the client and server can load. + /// + public enum ScenesType + { + /// + /// The facility itself. + /// + Facility, + + /// + /// The current main menu. + /// ! Will cause crash when trying joining servers ! + /// + NewMainMenu, + + /// + /// The old main menu. + /// + MainMenuRemastered, + + /// + /// The old server list. + /// + FastMenu, + + /// + /// The loading Screen. + /// ! Will cause crash when trying joining servers ! + /// + PreLoader, + + /// + /// A black menu before loading the . + /// + Loader, + } +} diff --git a/EXILED/Exiled.API/Features/Player.cs b/EXILED/Exiled.API/Features/Player.cs index 4991e13d4c..ac7bd2c507 100644 --- a/EXILED/Exiled.API/Features/Player.cs +++ b/EXILED/Exiled.API/Features/Player.cs @@ -3516,6 +3516,26 @@ public void SetCooldownItem(float time, ItemType itemType) /// The projectile that will create the effect. public void ExplodeEffect(ProjectileType projectileType) => Map.ExplodeEffect(Position, projectileType); + /// + /// Sends to the player a Fake Change Scene. + /// + /// The new Scene the client will load. + public void SendFakeSceneLoading(string newSceneName) + { + SceneMessage message = new() + { + sceneName = newSceneName, + }; + + Connection.Send(message); + } + + /// + /// Sends to the player a Fake Change Scene. + /// + /// The new Scene the client will load. + public void SendFakeSceneLoading(ScenesType newSceneName) => SendFakeSceneLoading(newSceneName.ToString()); + /// /// Converts the player in a human-readable format. /// diff --git a/EXILED/Exiled.API/Features/Server.cs b/EXILED/Exiled.API/Features/Server.cs index 26cf64c98f..237f370153 100644 --- a/EXILED/Exiled.API/Features/Server.cs +++ b/EXILED/Exiled.API/Features/Server.cs @@ -11,6 +11,8 @@ namespace Exiled.API.Features using System.Collections.Generic; using System.Reflection; + using Exiled.API.Enums; + using GameCore; using Interfaces; @@ -267,6 +269,26 @@ public static bool ShutdownRedirect(ushort redirectPort) /// Command response, if there is one; otherwise, . public static string ExecuteCommand(string command, CommandSender sender = null) => GameCore.Console.singleton.TypeCommand(command, sender); + /// + /// Emulation of the method SCP:SL uses to change scene. + /// + /// The new Scene the client will load. + public static void ChangeSceneToAllClients(string newSceneName) + { + SceneMessage message = new() + { + sceneName = newSceneName, + }; + + NetworkServer.SendToAll(message); + } + + /// + /// Emulation of the method SCP:SL uses to change scene. + /// + /// The new Scene the client will load. + public static void ChangeSceneToAllClients(ScenesType scene) => ChangeSceneToAllClients(scene.ToString()); + /// /// Safely gets an from , then casts it to . /// From a6eb93838d8743dbe69536656c6ab8a4cba0bda4 Mon Sep 17 00:00:00 2001 From: NotZer0Two Date: Sat, 10 Aug 2024 18:24:02 +0200 Subject: [PATCH 2/6] Fixing Building Error --- EXILED/Exiled.API/Enums/ScenesType.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/EXILED/Exiled.API/Enums/ScenesType.cs b/EXILED/Exiled.API/Enums/ScenesType.cs index f75fa0bf50..2a7898ca6e 100644 --- a/EXILED/Exiled.API/Enums/ScenesType.cs +++ b/EXILED/Exiled.API/Enums/ScenesType.cs @@ -1,3 +1,10 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + namespace Exiled.API.Enums { /// From 2b39320aa61f8632200de6d01b71f060bfc15167 Mon Sep 17 00:00:00 2001 From: NotZer0Two Date: Sun, 11 Aug 2024 09:14:45 +0200 Subject: [PATCH 3/6] Applied the Change request --- .../Exiled.API/Extensions/MirrorExtensions.cs | 17 +++++++++++++++- EXILED/Exiled.API/Features/Player.cs | 20 ------------------- EXILED/Exiled.API/Features/Server.cs | 12 +++-------- 3 files changed, 19 insertions(+), 30 deletions(-) diff --git a/EXILED/Exiled.API/Extensions/MirrorExtensions.cs b/EXILED/Exiled.API/Extensions/MirrorExtensions.cs index 8b30327d4e..5a31e0f8ef 100644 --- a/EXILED/Exiled.API/Extensions/MirrorExtensions.cs +++ b/EXILED/Exiled.API/Extensions/MirrorExtensions.cs @@ -14,7 +14,7 @@ namespace Exiled.API.Extensions using System.Reflection; using System.Reflection.Emit; using System.Text; - + using Exiled.API.Enums; using Features; using Features.Pools; @@ -342,6 +342,21 @@ public static void MessageTranslated(this Player player, string words, string tr } } + /// + /// Sends to the player a Fake Change Scene. + /// + /// The player to send the Scene + /// The new Scene the client will load. + public static void SendFakeSceneLoading(this Player player, ScenesType newSceneName) + { + SceneMessage message = new() + { + sceneName = newSceneName.ToString(), + }; + + player.Connection.Send(message); + } + /// /// Send fake values to client's . /// diff --git a/EXILED/Exiled.API/Features/Player.cs b/EXILED/Exiled.API/Features/Player.cs index ac7bd2c507..4991e13d4c 100644 --- a/EXILED/Exiled.API/Features/Player.cs +++ b/EXILED/Exiled.API/Features/Player.cs @@ -3516,26 +3516,6 @@ public void SetCooldownItem(float time, ItemType itemType) /// The projectile that will create the effect. public void ExplodeEffect(ProjectileType projectileType) => Map.ExplodeEffect(Position, projectileType); - /// - /// Sends to the player a Fake Change Scene. - /// - /// The new Scene the client will load. - public void SendFakeSceneLoading(string newSceneName) - { - SceneMessage message = new() - { - sceneName = newSceneName, - }; - - Connection.Send(message); - } - - /// - /// Sends to the player a Fake Change Scene. - /// - /// The new Scene the client will load. - public void SendFakeSceneLoading(ScenesType newSceneName) => SendFakeSceneLoading(newSceneName.ToString()); - /// /// Converts the player in a human-readable format. /// diff --git a/EXILED/Exiled.API/Features/Server.cs b/EXILED/Exiled.API/Features/Server.cs index 237f370153..13d4e3edfe 100644 --- a/EXILED/Exiled.API/Features/Server.cs +++ b/EXILED/Exiled.API/Features/Server.cs @@ -272,23 +272,17 @@ public static bool ShutdownRedirect(ushort redirectPort) /// /// Emulation of the method SCP:SL uses to change scene. /// - /// The new Scene the client will load. - public static void ChangeSceneToAllClients(string newSceneName) + /// The new Scene the client will load. + public static void ChangeSceneToAllClients(ScenesType scene) { SceneMessage message = new() { - sceneName = newSceneName, + sceneName = scene.ToString(), }; NetworkServer.SendToAll(message); } - /// - /// Emulation of the method SCP:SL uses to change scene. - /// - /// The new Scene the client will load. - public static void ChangeSceneToAllClients(ScenesType scene) => ChangeSceneToAllClients(scene.ToString()); - /// /// Safely gets an from , then casts it to . /// From 7390d421ede3db7eb07bc89b5462f039835ffb5a Mon Sep 17 00:00:00 2001 From: NotZer0Two Date: Sun, 11 Aug 2024 11:00:59 +0200 Subject: [PATCH 4/6] Changes requested by Yamato made --- EXILED/Exiled.API/Extensions/MirrorExtensions.cs | 14 ++++++++++++++ EXILED/Exiled.API/Features/Server.cs | 14 -------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/EXILED/Exiled.API/Extensions/MirrorExtensions.cs b/EXILED/Exiled.API/Extensions/MirrorExtensions.cs index 5a31e0f8ef..bd908e507f 100644 --- a/EXILED/Exiled.API/Extensions/MirrorExtensions.cs +++ b/EXILED/Exiled.API/Extensions/MirrorExtensions.cs @@ -357,6 +357,20 @@ public static void SendFakeSceneLoading(this Player player, ScenesType newSceneN player.Connection.Send(message); } + /// + /// Emulation of the method SCP:SL uses to change scene. + /// + /// The new Scene the client will load. + public static void ChangeSceneToAllClients(ScenesType scene) + { + SceneMessage message = new() + { + sceneName = scene.ToString(), + }; + + NetworkServer.SendToAll(message); + } + /// /// Send fake values to client's . /// diff --git a/EXILED/Exiled.API/Features/Server.cs b/EXILED/Exiled.API/Features/Server.cs index 13d4e3edfe..7248fdb709 100644 --- a/EXILED/Exiled.API/Features/Server.cs +++ b/EXILED/Exiled.API/Features/Server.cs @@ -269,20 +269,6 @@ public static bool ShutdownRedirect(ushort redirectPort) /// Command response, if there is one; otherwise, . public static string ExecuteCommand(string command, CommandSender sender = null) => GameCore.Console.singleton.TypeCommand(command, sender); - /// - /// Emulation of the method SCP:SL uses to change scene. - /// - /// The new Scene the client will load. - public static void ChangeSceneToAllClients(ScenesType scene) - { - SceneMessage message = new() - { - sceneName = scene.ToString(), - }; - - NetworkServer.SendToAll(message); - } - /// /// Safely gets an from , then casts it to . /// From a686c6fb9b83376eb8d0590fef142a734b06718a Mon Sep 17 00:00:00 2001 From: NotZer0Two Date: Sun, 11 Aug 2024 11:14:56 +0200 Subject: [PATCH 5/6] Fixed Building Errors --- EXILED/Exiled.API/Extensions/MirrorExtensions.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/EXILED/Exiled.API/Extensions/MirrorExtensions.cs b/EXILED/Exiled.API/Extensions/MirrorExtensions.cs index bd908e507f..b403eb9af7 100644 --- a/EXILED/Exiled.API/Extensions/MirrorExtensions.cs +++ b/EXILED/Exiled.API/Extensions/MirrorExtensions.cs @@ -14,6 +14,7 @@ namespace Exiled.API.Extensions using System.Reflection; using System.Reflection.Emit; using System.Text; + using Exiled.API.Enums; using Features; using Features.Pools; @@ -345,7 +346,7 @@ public static void MessageTranslated(this Player player, string words, string tr /// /// Sends to the player a Fake Change Scene. /// - /// The player to send the Scene + /// The player to send the Scene. /// The new Scene the client will load. public static void SendFakeSceneLoading(this Player player, ScenesType newSceneName) { From 3e747a0a485fdbbdaec9b8a5e619a3c5d4e92345 Mon Sep 17 00:00:00 2001 From: NotZer0Two Date: Fri, 16 Aug 2024 09:27:19 +0200 Subject: [PATCH 6/6] Fix build --- EXILED/Exiled.API/Extensions/MirrorExtensions.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/EXILED/Exiled.API/Extensions/MirrorExtensions.cs b/EXILED/Exiled.API/Extensions/MirrorExtensions.cs index c7a37911e1..8b4350b5b0 100644 --- a/EXILED/Exiled.API/Extensions/MirrorExtensions.cs +++ b/EXILED/Exiled.API/Extensions/MirrorExtensions.cs @@ -385,6 +385,7 @@ public static void ChangeSceneToAllClients(ScenesType scene) NetworkServer.SendToAll(message); } + /// /// Scales an object for the specified player. /// /// Target to send.