Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EXILED::API] Adding ScaleNetworkIdentityObject #2768

Merged
merged 6 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
NotZer0Two marked this conversation as resolved.
Show resolved Hide resolved
/// </summary>
/// <param name="identity">The <see cref="Mirror.NetworkIdentity"/> to scale.</param>
/// <param name="scale">The scale the object needs to be.</param>
NotZer0Two marked this conversation as resolved.
Show resolved Hide resolved
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.
NotZer0Two marked this conversation as resolved.
Show resolved Hide resolved
/// </summary>
/// <param name="identity">The <see cref="Mirror.NetworkIdentity"/> to scale.</param>
/// <param name="scale">The scale the object needs to be.</param>
NotZer0Two marked this conversation as resolved.
Show resolved Hide resolved
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 });
}
}
}
}
Loading