/// <inheritdoc /> protected override async Task HandleSubMessage(IPeerMessageContext <PSOBBGamePacketPayloadClient> context, Sub60GameBurstingCompleteEventCommand command) { //It's possible we get this on OUR join. We may not be spawned yet. if (!PlayerData.isWorldObjectSpawned) { return; } //This could be for a couple of reasons. Bursting wasn't set, and it's a BIG failure //or this is our JOIN bursting finish and we don't do anything here really. if (!BurstingService.isBurstingInProgress) { return; } //TODO: At some point, this may not run on the main thread so this won't be safe. GameObject playerWorldObject = PlayerData.WorldObject; Vector3 <float> scaledPosition = ScalerService.UnScale(playerWorldObject.transform.position).ToNetworkVector3(); float scaledRotation = ScalerService.UnScaleYRotation(playerWorldObject.transform.rotation.y); //If have to send this message otherwise other client's won't know we're also in the same zone //It's odd, but it's something we have to do. await context.PayloadSendService.SendMessage(new Sub60FinishedWarpAckCommand(SlotModel.SlotSelected, ZoneSettings.ZoneId, scaledPosition, scaledRotation).ToPayload()); int entityGuid = BurstingService.BurstingEntityGuid.Value; //Successful burst, let everyone know. OnClientBurstingFinished?.Invoke(this, new ClientBurstingEndingEventArgs(entityGuid, true)); //Bursting is done, we should release bursting state //Then we should broadcast to everyone that bursting is done. BurstingService.ClearBursting(); }
/// <inheritdoc /> protected override Task HandleSubMessage(IPeerMessageContext <PSOBBGamePacketPayloadClient> context, Sub60TeleportToPositionCommand command) { //TODO: Don't do anything with this if (Logger.IsInfoEnabled) { Logger.Info($"Recieved {nameof(Sub60TeleportToPositionCommand)} ClientId: {command.Identifier} X: {command.Position.X} Y: {command.Position.Y} Z: {command.Position.Z}"); } int entityGuid = EntityGuid.ComputeEntityGuid(EntityType.Player, command.Identifier); //For this packet, we just directly set the world transform //Clients seem to set this when they're loading into a new area //or maybe to teleport too from teleports //TODO: Is this good enough, what about teleporters?? EntityLocationMappable[entityGuid] = new WorldTransform(ScalerService.Scale(command.Position), Quaternion.identity); return(Task.CompletedTask); }
/// <inheritdoc /> protected override async void OnEventFired(object source, LocalPlayerWorldObjectSpawnedEventArgs args) { //TODO: We should extract this into a warping service. //TODO: Send rotation //TODO: What should the W coord be? How sould we handle this poition? //We can't do anything with the data right now await SendService.SendMessage(new Sub60TeleportToPositionCommand((byte)EntityGuid.GetEntityId(args.EntityGuid), ScalerService.UnScale(args.WorldObject.transform.position).ToNetworkVector3()).ToPayload()); //Now we have to send a 1F to start the warp //Tell the server we're warping now await SendService.SendMessage(new Sub60WarpToNewAreaCommand((byte)EntityGuid.GetEntityId(args.EntityGuid), ZoneSettings.ZoneId).ToPayload()); //TODO: is it save to send this in the lobby?? await SendService.SendMessage(new Sub60FinishedMapLoadCommand(EntityGuid.GetEntityId(args.EntityGuid)).ToPayload()); //TODO: Should we send ClientId with this one too? //We can just send a finished right away, we have nothing to load really await SendService.SendMessage(new Sub60FinishedWarpingBurstingCommand((byte)EntityGuid.GetEntityId(args.EntityGuid)).ToPayload()); }