Skip to content

Commit

Permalink
[EXILED::API] Adding SendFakeSceneLoading (#2756)
Browse files Browse the repository at this point in the history
* Added UsersWhitelisted in Server.cs

* MirrorExtensions Rework

* Removed wrong import

* Rework

* Fixed issue and renamed the functions

* Fixed Stylecop and issue with building

* Fixed Name

* Changed Name from UsersWhitelisted to WhitelistedPlayers

* Scenes Loader Added

* Simplification

* Is this ok?

* Fix Stylecop here

* Update Player.cs

* Update Server.cs

* Update ScenesType.cs

---------

Co-authored-by: xNexusACS <83370388+xNexusACS@users.noreply.github.com>
  • Loading branch information
NotZer0Two and xNexusACS authored Aug 9, 2024
1 parent c6ec7f3 commit 4efc121
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 1 deletion.
47 changes: 47 additions & 0 deletions 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,
}
}
20 changes: 20 additions & 0 deletions Exiled.API/Features/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4087,6 +4087,26 @@ public void SendCassieAnnouncement(string words, string translation, bool makeHo
}
}

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

Connection.Send(message);
}

/// <summary>
/// Sends to the player a Fake Change Scene.
/// </summary>
/// <param name="newSceneName">The new Scene the client will load.</param>
public void SendFakeSceneLoading(ScenesType newSceneName) => SendFakeSceneLoading(newSceneName.ToString());

/// <summary>
/// Converts the player in a human-readable format.
/// </summary>
Expand Down
24 changes: 23 additions & 1 deletion 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 Expand Up @@ -334,5 +336,25 @@ public static bool TryGetSessionVariable<T>(string key, out T result)
result = default;
return false;
}

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

NetworkServer.SendToAll(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) => ChangeSceneToAllClients(scene.ToString());
}
}
}

0 comments on commit 4efc121

Please sign in to comment.