Skip to content

Commit

Permalink
MoveNetworkObject Added
Browse files Browse the repository at this point in the history
  • Loading branch information
NotZer0Two committed Aug 11, 2024
1 parent 92af4ce commit 69da7a0
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions EXILED/Exiled.API/Extensions/MirrorExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,44 @@ 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>
/// 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>
/// Send fake values to client's <see cref="SyncVarAttribute"/>.
/// </summary>
Expand Down

0 comments on commit 69da7a0

Please sign in to comment.