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

Merged
merged 6 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
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
17 changes: 17 additions & 0 deletions Exiled.API/Features/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4113,6 +4113,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>
/// Moves an object for the player.
/// </summary>
/// <param name="identity">The <see cref="Mirror.NetworkIdentity"/> to move.</param>
/// <param name="pos">The position to change.</param>
public void MoveNetworkIdentityObject(NetworkIdentity identity, Vector3 pos)
{
identity.gameObject.transform.position = pos;
ObjectDestroyMessage objectDestroyMessage = new()
{
netId = identity.netId,
};

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

/// <summary>
/// Scales an object for the specified player.
/// </summary>
Expand Down
20 changes: 20 additions & 0 deletions Exiled.API/Features/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,26 @@ public static void ChangeSceneToAllClients(string newSceneName)
/// <param name="scene">The new Scene the client will load.</param>
public static void ChangeSceneToAllClients(ScenesType scene) => ChangeSceneToAllClients(scene.ToString());

/// <summary>
/// Moves an object for all players.
/// </summary>
/// <param name="identity">The <see cref="NetworkIdentity"/> to move.</param>
/// <param name="pos">The position to change.</param>
public static void MoveNetworkIdentityObject(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);
MirrorExtensions.SendSpawnMessageMethodInfo?.Invoke(null, new object[] { identity, ply.Connection });
}
}

/// <summary>
/// Scales an object for all players.
/// </summary>
Expand Down
Loading