public static void OnGameMatchmakingResultMessageReceived(GameMatchmakingResultMessage message) { if (GameMatchmakingManager.m_queue.TryGetValue(message.SessionId, out MatchmakingEntry entry)) { GameSession session = entry.Session; if (message.EnemyId != null) { GameAvatar enemy = GameAvatarManager.Get(message.EnemyId); GameMatchmakingManager.Dequeue(session); entry.Session.GameAvatar.AddRecentlyMatchedEnemy(message.EnemyId); session.LoadGameState(new GameMatchedAttackState { Home = enemy.LogicClientHome, HomeOwnerAvatar = enemy.LogicClientAvatar, PlayerAvatar = session.GameAvatar.LogicClientAvatar, MaintenanceTime = enemy.MaintenanceTime, SaveTime = enemy.SaveTime, LiveReplayId = LiveReplayManager.Create(session, null, null) }); } else { AttackHomeFailedMessage attackHomeFailedMessage = new AttackHomeFailedMessage(); switch (ServerStatus.Status) { case ServerStatusType.SHUTDOWN_STARTED: case ServerStatusType.MAINTENANCE: attackHomeFailedMessage.SetReason(AttackHomeFailedMessage.Reason.SHUTDOWN_ATTACK_DISABLED); break; case ServerStatusType.COOLDOWN_AFTER_MAINTENANCE: attackHomeFailedMessage.SetReason(AttackHomeFailedMessage.Reason.COOLDOWN_AFTER_MAINTENANCE); break; default: entry.MatchConfirmation = false; return; } session.SendPiranhaMessage(attackHomeFailedMessage, 1); GameMatchmakingManager.Dequeue(session); } } }
private static void OnGameStartFakeAttackMessageReceived(GameStartFakeAttackMessage message) { if (GameSessionManager.TryGet(message.SessionId, out GameSession session)) { if (message.AccountId != null) { ServerRequestManager.Create(new GameAvatarRequestMessage { AccountId = message.AccountId }, ServerManager.GetDocumentSocket(9, message.AccountId)).OnComplete = args => { if (session.IsDestructed()) { return; } if (args.ErrorCode == ServerRequestError.Success && args.ResponseMessage.Success) { GameState currentGameState = session.GameState; if (currentGameState != null && currentGameState.GetGameStateType() == GameStateType.HOME) { GameAvatarResponseMessage gameAvatarResponseMessage = (GameAvatarResponseMessage)args.ResponseMessage; GameDocument document = gameAvatarResponseMessage.Document; AvailableServerCommandMessage availableServerCommandMessage = new AvailableServerCommandMessage(); availableServerCommandMessage.SetServerCommand(new LogicMatchmakingCommand()); session.SendPiranhaMessage(availableServerCommandMessage, 1); session.FakeAttackState = new GameFakeAttackState { Home = document.LogicClientHome, HomeOwnerAvatar = document.LogicClientAvatar, PlayerAvatar = session.GameAvatar.LogicClientAvatar, SaveTime = document.SaveTime, MaintenanceTime = document.MaintenanceTime }; } } else { AttackHomeFailedMessage attackHomeFailedMessage = new AttackHomeFailedMessage(); attackHomeFailedMessage.SetReason(AttackHomeFailedMessage.Reason.GENERIC); session.SendPiranhaMessage(attackHomeFailedMessage, 1); } }; } else { GameState currentGameState = session.GameState; if (currentGameState != null && currentGameState.GetGameStateType() == GameStateType.HOME) { AvailableServerCommandMessage availableServerCommandMessage = new AvailableServerCommandMessage(); availableServerCommandMessage.SetServerCommand(new LogicMatchmakingCommand()); session.SendPiranhaMessage(availableServerCommandMessage, 1); session.FakeAttackState = new GameFakeAttackState { Home = GameBaseGenerator.GenerateBase((LogicGameObjectData)message.ArgData), HomeOwnerAvatar = GameBaseGenerator.HomeOwnerAvatar, PlayerAvatar = session.GameAvatar.LogicClientAvatar, SaveTime = TimeUtil.GetTimestamp(), MaintenanceTime = -1 }; } } } }