示例#1
0
        protected override async ETTask Run(Session session, C2G_LoginGate request, G2C_LoginGate response, Action reply)
        {
            Scene  scene   = session.DomainScene();
            string account = scene.GetComponent <GateSessionKeyComponent>().Get(request.Key);

            if (account == null)
            {
                response.Error   = ErrorCore.ERR_ConnectGateKeyError;
                response.Message = "Gate key验证失败!";
                reply();
                return;
            }

            session.RemoveComponent <SessionAcceptTimeoutComponent>();

            PlayerComponent playerComponent = scene.GetComponent <PlayerComponent>();
            Player          player          = playerComponent.AddChild <Player, string>(account);

            playerComponent.Add(player);
            session.AddComponent <SessionPlayerComponent>().PlayerId = player.Id;
            session.AddComponent <MailBoxComponent, MailboxType>(MailboxType.GateSession);

            response.PlayerId = player.Id;
            reply();
            await ETTask.CompletedTask;
        }
示例#2
0
 public static void Add(this PlayerComponent self, Player player)
 {
     self.idPlayers.Add(player.Id, player);
 }
示例#3
0
 public static void Remove(this PlayerComponent self, long id)
 {
     self.idPlayers.Remove(id);
 }
示例#4
0
 public static Player[] GetAll(this PlayerComponent self)
 {
     return(self.idPlayers.Values.ToArray());
 }
示例#5
0
 public static Player Get(this PlayerComponent self, long id)
 {
     self.idPlayers.TryGetValue(id, out Player gamer);
     return(gamer);
 }