Skip to content

Commit

Permalink
[EXILED::API] Adding ScaleNetworkIdentityObject (#2768)
Browse files Browse the repository at this point in the history
* Scale Objects

* Fixed the names

* Update Exiled.API/Features/Server.cs

Co-authored-by: Nao <60253860+NaoUnderscore@users.noreply.github.com>

* Update Exiled.API/Features/Player.cs

Co-authored-by: Nao <60253860+NaoUnderscore@users.noreply.github.com>

* Update Exiled.API/Features/Player.cs

Co-authored-by: Nao <60253860+NaoUnderscore@users.noreply.github.com>

* Update Exiled.API/Features/Server.cs

Co-authored-by: Nao <60253860+NaoUnderscore@users.noreply.github.com>

---------

Co-authored-by: Nao <60253860+NaoUnderscore@users.noreply.github.com>
  • Loading branch information
NotZer0Two and NaoUnderscore authored Aug 14, 2024
1 parent 5e85cda commit dd7673b
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
17 changes: 17 additions & 0 deletions Exiled.API/Features/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4107,6 +4107,23 @@ public void SendFakeSceneLoading(string newSceneName)
/// <param name="newSceneName">The new Scene the client will load.</param>
public void SendFakeSceneLoading(ScenesType newSceneName) => SendFakeSceneLoading(newSceneName.ToString());

/// <summary>
/// Scales an object for the specified player.
/// </summary>
/// <param name="identity">The <see cref="Mirror.NetworkIdentity"/> to scale.</param>
/// <param name="scale">The scale the object needs to be set to.</param>
public void ScaleNetworkIdentityObject(NetworkIdentity identity, Vector3 scale)
{
identity.gameObject.transform.localScale = scale;
ObjectDestroyMessage objectDestroyMessage = new()
{
netId = identity.netId,
};

Connection.Send(objectDestroyMessage, 0);
MirrorExtensions.SendSpawnMessageMethodInfo?.Invoke(null, new object[] { identity, Connection });
}

/// <summary>
/// Converts the player in a human-readable format.
/// </summary>
Expand Down
22 changes: 21 additions & 1 deletion Exiled.API/Features/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Exiled.API.Features
using System.Reflection;

using Exiled.API.Enums;

using Exiled.API.Extensions;
using GameCore;

using Interfaces;
Expand Down Expand Up @@ -356,5 +356,25 @@ public static void ChangeSceneToAllClients(string newSceneName)
/// </summary>
/// <param name="scene">The new Scene the client will load.</param>
public static void ChangeSceneToAllClients(ScenesType scene) => ChangeSceneToAllClients(scene.ToString());

/// <summary>
/// Scales an object for all players.
/// </summary>
/// <param name="identity">The <see cref="Mirror.NetworkIdentity"/> to scale.</param>
/// <param name="scale">The scale the object needs to be set to.</param>
public static void ScaleNetworkIdentityObject(NetworkIdentity identity, Vector3 scale)
{
identity.gameObject.transform.localScale = scale;
ObjectDestroyMessage objectDestroyMessage = new()
{
netId = identity.netId,
};

foreach (Player ply in Player.List)
{
ply.Connection.Send(objectDestroyMessage, 0);
MirrorExtensions.SendSpawnMessageMethodInfo?.Invoke(null, new object[] { identity, ply.Connection });
}
}
}
}

0 comments on commit dd7673b

Please sign in to comment.