From 0c9cfff3bb7fc9fa45d850f87403429e76b4a6b8 Mon Sep 17 00:00:00 2001 From: ZeroTwo <63092138+NotZer0Two@users.noreply.github.com> Date: Tue, 20 Aug 2024 21:02:26 +0200 Subject: [PATCH] `[EXILED::API]` Adding SendFakeSceneLoading (#45) * Added ScenesType and Corrisponding Methods for the Server and Player * Fixing Building Error * Applied the Change request * Changes requested by Yamato made * Fixed Building Errors * Fix build --------- Co-authored-by: VALERA771 <72030575+VALERA771@users.noreply.github.com> --- EXILED/Exiled.API/Enums/ScenesType.cs | 47 +++++++++++++++++++ .../Exiled.API/Extensions/MirrorExtensions.cs | 30 ++++++++++++ EXILED/Exiled.API/Features/Server.cs | 2 + 3 files changed, 79 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 000000000..2a7898ca6 --- /dev/null +++ b/EXILED/Exiled.API/Enums/ScenesType.cs @@ -0,0 +1,47 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +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/Extensions/MirrorExtensions.cs b/EXILED/Exiled.API/Extensions/MirrorExtensions.cs index 21f2d111e..8b4350b5b 100644 --- a/EXILED/Exiled.API/Extensions/MirrorExtensions.cs +++ b/EXILED/Exiled.API/Extensions/MirrorExtensions.cs @@ -15,6 +15,7 @@ namespace Exiled.API.Extensions using System.Reflection.Emit; using System.Text; + using Exiled.API.Enums; using Features; using Features.Pools; @@ -355,6 +356,35 @@ 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); + } + + /// + /// 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); + } + /// /// Scales an object for the specified player. /// diff --git a/EXILED/Exiled.API/Features/Server.cs b/EXILED/Exiled.API/Features/Server.cs index b1b05e8c1..5dea5ee84 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;