public async Task Execute(PlayerStatusModel model) { int playerId = model.PlayerId; var player = await _playerDomainService.Get(playerId); if (player == null) { return; } var online = await _mudOnlineProvider.GetPlayerOnline(playerId); if (online == null) { //玩家离线后,从队列删除,并且修改状态为空闲 await _recurringQueue.Remove <PlayerStatusModel>($"player_{playerId}"); if (player.Status != PlayerStatusEnum.空闲) { player.Status = PlayerStatusEnum.空闲; await _playerDomainService.Update(player); await _bus.RaiseEvent(new PlayerStatusChangedEvent(player)).ConfigureAwait(false); } return; } if (player.Status != model.Status) { await _recurringQueue.Remove <PlayerStatusModel>($"player_{playerId}"); return; } var remainingTime = await _recurringQueue.GetRemainingTime <PlayerStatusModel>($"player_{playerId}"); await _mudProvider.ShowRemainingTime(playerId, remainingTime); //TODO switch (model.Status) { case PlayerStatusEnum.伐木: case PlayerStatusEnum.挖矿: case PlayerStatusEnum.打猎: case PlayerStatusEnum.采药: case PlayerStatusEnum.钓鱼: case PlayerStatusEnum.打工: await DoWork(player); break; case PlayerStatusEnum.疗伤: await Heal(player); break; case PlayerStatusEnum.打坐: await Muse(player); break; case PlayerStatusEnum.切磋: await Fighting(player, model.TargetType, model.TargetId); break; case PlayerStatusEnum.战斗: await Killing(player, model.TargetId); break; } }