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 MoveNetworkIdentityObject #48

Merged
merged 7 commits into from
Aug 27, 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 @@ -356,6 +356,24 @@ public static void MessageTranslated(this Player player, string words, string tr
}
}

/// <summary>
/// Moves object for the player.
/// </summary>
/// <param name="player">Target to send.</param>
/// <param name="identity">The <see cref="Mirror.NetworkIdentity"/> to move.</param>
/// <param name="pos">The position to change.</param>
public static void MoveNetworkIdentityObject(this Player player, NetworkIdentity identity, Vector3 pos)
{
identity.gameObject.transform.position = pos;
ObjectDestroyMessage objectDestroyMessage = new()
{
netId = identity.netId,
};

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

/// <summary>
/// Sends to the player a Fake Change Scene.
/// </summary>
Expand Down Expand Up @@ -403,6 +421,26 @@ public static void ScaleNetworkIdentityObject(this Player player, NetworkIdentit
SendSpawnMessageMethodInfo?.Invoke(null, new object[] { identity, player.Connection });
}

/// <summary>
/// Moves object for all the players.
/// </summary>
/// <param name="identity">The <see cref="NetworkIdentity"/> to move.</param>
/// <param name="pos">The position to change.</param>
public static void MoveNetworkIdentityObject(this NetworkIdentity identity, Vector3 pos)
{
identity.gameObject.transform.position = pos;
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>
/// Scales an object for all players.
/// </summary>
Expand Down
Loading