CMsgLoginEvent.cs 869 B

12345678910111213141516171819202122232425262728
  1. using Common.Network;
  2. using Model;
  3. namespace Controller
  4. {
  5. public class CMsgLogin
  6. {
  7. public byte[] Account { get; set; }
  8. public byte[] PassMd5 { get; set; }
  9. }
  10. [Message(Opcode.CMsgLogin, typeof(CMsgLogin), ServerType.Gate)]
  11. internal class CMsgLoginEvent: IEventSync
  12. {
  13. public void Run(Env env)
  14. {
  15. CMsgLogin cmsg = env.Get<CMsgLogin>(EnvKey.Message);
  16. Unit unit = World.Instance.GetComponent<FactoryComponent<Unit>>().Create(UnitType.GatePlayer, 1);
  17. AChannel channel = env.Get<AChannel>(EnvKey.Channel);
  18. ChannelUnitInfoComponent channelUnitInfoComponent =
  19. channel.AddComponent<ChannelUnitInfoComponent>();
  20. channelUnitInfoComponent.Account = cmsg.Account;
  21. channelUnitInfoComponent.UnitId = unit.Id;
  22. World.Instance.GetComponent<GateNetworkComponent>().AssociateUnitIdAndChannel(unit.Id, channel);
  23. }
  24. }
  25. }