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 #49

Merged
merged 8 commits into from
Aug 15, 2024
Merged
Changes from all 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
38 changes: 38 additions & 0 deletions EXILED/Exiled.API/Extensions/MirrorExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,44 @@ public static void MessageTranslated(this Player player, string words, string tr
}
}

/// <summary>
/// Scales an object for the specified player.
/// </summary>
/// <param name="player">Target to send.</param>
/// <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(this Player player, NetworkIdentity identity, Vector3 scale)
{
identity.gameObject.transform.localScale = scale;
ObjectDestroyMessage objectDestroyMessage = new()
{
netId = identity.netId,
};

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

/// <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(this 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);
SendSpawnMessageMethodInfo?.Invoke(null, new object[] { identity, ply.Connection });
}
}

/// <summary>
/// Send fake values to client's <see cref="SyncVarAttribute"/>.
/// </summary>
Expand Down
Loading