Skip to content
This repository has been archived by the owner on Jan 19, 2025. It is now read-only.

Commit

Permalink
Scale Objects
Browse files Browse the repository at this point in the history
  • Loading branch information
NotZer0Two committed Aug 11, 2024
1 parent 5e85cda commit a857984
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>
/// Scale object for the player.
/// </summary>
/// <param name="identity">The <see cref="Mirror.NetworkIdentity"/> to move.</param>
/// <param name="scale">The scale to change.</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 object for all the players.
/// </summary>
/// <param name="identity">The <see cref="NetworkIdentity"/> to move.</param>
/// <param name="scale">The scale to change.</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 a857984

Please sign in to comment.