Skip to content

Commit

Permalink
[EXILED::API] Adding SendFakeSceneLoading (#45)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
NotZer0Two and VALERA771 authored Aug 20, 2024
1 parent c819ba5 commit 0c9cfff
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 0 deletions.
47 changes: 47 additions & 0 deletions EXILED/Exiled.API/Enums/ScenesType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// -----------------------------------------------------------------------
// <copyright file="ScenesType.cs" company="Exiled Team">
// Copyright (c) Exiled Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------

namespace Exiled.API.Enums
{
/// <summary>
/// Unique identifier for the different types of Scenes the client and server can load.
/// </summary>
public enum ScenesType
{
/// <summary>
/// The facility itself.
/// </summary>
Facility,

/// <summary>
/// The current main menu.
/// ! Will cause crash when trying joining servers !
/// </summary>
NewMainMenu,

/// <summary>
/// The old main menu.
/// </summary>
MainMenuRemastered,

/// <summary>
/// The old server list.
/// </summary>
FastMenu,

/// <summary>
/// The loading Screen.
/// ! Will cause crash when trying joining servers !
/// </summary>
PreLoader,

/// <summary>
/// A black menu before loading the <see cref="NewMainMenu"/>.
/// </summary>
Loader,
}
}
30 changes: 30 additions & 0 deletions EXILED/Exiled.API/Extensions/MirrorExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace Exiled.API.Extensions
using System.Reflection.Emit;
using System.Text;

using Exiled.API.Enums;
using Features;
using Features.Pools;

Expand Down Expand Up @@ -355,6 +356,35 @@ public static void MessageTranslated(this Player player, string words, string tr
}
}

/// <summary>
/// Sends to the player a Fake Change Scene.
/// </summary>
/// <param name="player">The player to send the Scene.</param>
/// <param name="newSceneName">The new Scene the client will load.</param>
public static void SendFakeSceneLoading(this Player player, ScenesType newSceneName)
{
SceneMessage message = new()
{
sceneName = newSceneName.ToString(),
};

player.Connection.Send(message);
}

/// <summary>
/// Emulation of the method SCP:SL uses to change scene.
/// </summary>
/// <param name="scene">The new Scene the client will load.</param>
public static void ChangeSceneToAllClients(ScenesType scene)
{
SceneMessage message = new()
{
sceneName = scene.ToString(),
};

NetworkServer.SendToAll(message);
}

/// <summary>
/// Scales an object for the specified player.
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions EXILED/Exiled.API/Features/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ namespace Exiled.API.Features
using System.Collections.Generic;
using System.Reflection;

using Exiled.API.Enums;

using GameCore;

using Interfaces;
Expand Down

0 comments on commit 0c9cfff

Please sign in to comment.