private IEnumerator BroadcastTransformPosition() { while (true) { if (Vector3.Magnitude(lastPosition - transform.position) > Vector3.kEpsilon) { lastPosition = transform.position; isFinishedMoving = false; SendService.SendMessage(new Sub60MovingFastPositionSetCommand(Identity.EntityId, UnitScaler.UnScaleYtoZ(transform.position)).ToPayload()); } else if (!isFinishedMoving) { lastPosition = transform.position; isFinishedMoving = true; //TODO: Handle rotation //Send a stop if we stopped moving SendService.SendMessage(new Sub60FinishedMovingCommand(Identity.EntityId, UnitScaler.ScaleYRotation(transform.rotation.eulerAngles.y), UnitScaler.UnScale(transform.position).ToNetworkVector3(), RoomQueryService.RoomIdForPlayerById(Identity.EntityId), ZoneData.ZoneId).ToPayload()); } yield return(new WaitForSeconds(1.0f / BroadcastsPerSecond)); } }
private void InitializeAckDataToEntityMappables(Sub60FinishedWarpAckCommand command, int entityGuid) { //We have to do basically what the 3 packet process does for newly joining clients //We need to create the world transform so that it will be known where to spawn. float rotation = UnitScaler.ScaleYRotation(command.YAxisRotation); Vector3 position = UnitScaler.Scale(command.Position); WorldTransformMappable[entityGuid] = new WorldTransform(position, Quaternion.Euler(0.0f, rotation, 0.0f)); //Then we have to actually create/set the zone data so that //it's known which zone the player is in ZoneDataMappable[entityGuid] = new PlayerZoneData(command.ZoneId); }
/// <inheritdoc /> public Task StopMovementAsync(Vector3 position, Quaternion rotation) { return(SendService.SendMessage(new Sub60FinishedMovingCommand(PlayerSlotModel.SlotSelected, UnitScaler.ScaleYRotation(rotation.eulerAngles.y), UnitScaler.UnScale(position).ToNetworkVector3(), RoomQueryService.RoomIdForPlayerById(PlayerSlotModel.SlotSelected), ZoneData.ZoneId).ToPayload())); }