-namespace Impostor.Api.Net.Inner.Objects.Components
+using System.Numerics;
+using System.Threading.Tasks;
+
+namespace Impostor.Api.Net.Inner.Objects.Components
{
public interface IInnerCustomNetworkTransform : IInnerNetObject
{
+ /// <summary>
+ /// Snaps the current to the given position <see cref="IInnerPlayerControl"/>.
+ /// </summary>
+ /// <param name="position">The target position.</param>
+ /// <returns>Task that must be awaited.</returns>
+ ValueTask SnapTo(Vector2 position);
}
}
-using Impostor.Api.Net.Inner.Objects.Components;
+using System.Numerics;
+using System.Threading.Tasks;
+using Impostor.Api.Net.Inner.Objects.Components;
namespace Impostor.Server.Net.Inner.Objects.Components
{
internal partial class InnerCustomNetworkTransform : IInnerCustomNetworkTransform
{
+ public async ValueTask SnapTo(Vector2 position)
+ {
+ var writer = _game.StartRpc(NetId, RpcCalls.SnapTo);
+ WriteVector2(writer, position);
+ writer.Write(_lastSequenceId + 5U);
+ await _game.FinishRpcAsync(writer);
+ }
}
}