public override void Handle(LoginSession session, PacketReader packet) { LoginMode mode = (LoginMode)packet.ReadByte(); string username = packet.ReadUnicodeString(); string password = packet.ReadUnicodeString(); if (string.IsNullOrEmpty(username)) { session.Send(LoginResultPacket.SendLoginMode(Packets.LoginMode.IncorrectId)); return; } Account account; if (DatabaseManager.Accounts.AccountExists(username.ToLower())) { if (!DatabaseManager.Accounts.Authenticate(username, password, out account)) { session.Send(LoginResultPacket.SendLoginMode(Packets.LoginMode.IncorrectPassword)); return; } Session loggedInAccount = MapleServer.GetSessions(MapleServer.GetLoginServer(), MapleServer.GetGameServer()).FirstOrDefault(p => p switch { LoginSession s => s.AccountId == account.Id, GameSession s => s.Player?.AccountId == account.Id, _ => false });
private void ProcessLoginRequest(LoginRequestPacket obj) { var username = obj.Username; var password = obj.Password; if (AreCredentialsValid(username, password)) { var user = AddUser(obj, username); Logger.Instance.Log(Level.Info, user.Name + " has joined the lobby."); var packet = new LoginResultPacket(LoginResultPacket.LoginResult.Succesful); ClientNetworkManager.Instance.SendPacket(packet, obj.Sender); // Send the user a list of sessions going on //TODO: Send this when they register the intent - it's more generic var sessionService = (GameSessionService)ServiceContainer.GetService(typeof(GameSessionService)); sessionService.SendUserSessions(user); sessionService.SendToUsersOnlineList(); } else { // Reject the user if they aren't able to authenticate var packet = new LoginResultPacket(LoginResultPacket.LoginResult.Failed); ClientNetworkManager.Instance.SendPacket(packet, obj.Sender); } }
public void ReceiveLoginResult(byte[] data) { // receive packet serialize LoginResultPacket receivePacket = new LoginResultPacket(data); LoginResultData joinResultData = receivePacket.GetData(); Console.WriteLine(joinResultData.loginResult); Console.WriteLine(joinResultData.message); }
public override void Handle(LoginSession session, PacketReader packet) { byte mode = packet.ReadByte(); string username = packet.ReadUnicodeString(); string password = packet.ReadUnicodeString(); // Hash the password with BCrypt string passwordHash = BCrypt.Net.BCrypt.HashPassword(password); // TODO: Change authenticate to return bool and add packet for wrong password Account account = DatabaseManager.Authenticate(username, password); // Auto add new accounts if (account == default) { account = new Account(username, passwordHash); } Logger.Debug($"Logging in with account ID: {account.Id}"); session.AccountId = account.Id; switch (mode) { case 1: PacketWriter pWriter = PacketWriter.Of(SendOp.NPS_INFO); pWriter.WriteLong(); pWriter.WriteUnicodeString(account.Username); session.Send(pWriter); List <Banner> banners = DatabaseManager.GetBanners(); session.Send(BannerListPacket.SetBanner(banners)); session.Send(ServerListPacket.SetServers(ServerName, ServerIPs)); break; case 2: List <Player> characters = DatabaseManager.GetAccountCharacters(session.AccountId); Logger.Debug($"Initializing login with account id: {session.AccountId}"); session.Send(LoginResultPacket.InitLogin(session.AccountId)); session.Send(UgcPacket.SetEndpoint("http://127.0.0.1/ws.asmx?wsdl", "http://127.0.0.1")); session.Send(CharacterListPacket.SetMax(account.CharacterSlots)); session.Send(CharacterListPacket.StartList()); // Send each character data session.Send(CharacterListPacket.AddEntries(characters)); session.Send(CharacterListPacket.EndList()); break; } }
public override void Handle(LoginSession session, PacketReader packet) { byte mode = packet.ReadByte(); string user = packet.ReadUnicodeString(); string pass = packet.ReadUnicodeString(); logger.Debug($"Logging in with user:{user} pass:{pass}"); // TODO: From this user/pass lookup we should be able to find the accountId if (string.IsNullOrEmpty(user) && string.IsNullOrEmpty(pass)) { //session.AccountId = StaticAccountStorage.DEFAULT_ACCOUNT; logger.Info($"No user and password provide logging in with root account "); } else { logger.Info($"Success, with any string in user and pass"); //session.AccountId = StaticAccountStorage.SECONDARY_ACCOUNT; } switch (mode) { case 1: session.Send(PacketWriter.Of(SendOp.NPS_INFO).WriteLong().WriteUnicodeString("")); session.Send(BannerListPacket.SetBanner()); session.Send(ServerListPacket.SetServers(serverName, serverIps)); break; case 2: List <Player> characters = new List <Player>(); /* * foreach (long characterId in accountStorage.ListCharacters(session.AccountId)) { * characters.Add(accountStorage.GetCharacter(characterId)); * }*/ Console.WriteLine("Initializing login with " + session.AccountId); session.Send(LoginResultPacket.InitLogin(session.AccountId)); session.Send(UgcPacket.SetEndpoint("http://127.0.0.1/ws.asmx?wsdl", "http://127.0.0.1")); session.Send(CharacterListPacket.SetMax(4, 6)); session.Send(CharacterListPacket.StartList()); // Send each character data session.Send(CharacterListPacket.AddEntries(characters)); session.Send(CharacterListPacket.EndList()); break; } }
public override void Handle(LoginSession session, PacketReader packet) { byte mode = packet.ReadByte(); string username = packet.ReadUnicodeString(); string password = packet.ReadUnicodeString(); Account account = DatabaseManager.GetAccount(username, password); // Auto add new accounts if (account == default) { account = new Account(GuidGenerator.Long(), username, password); if (!DatabaseManager.Insert(account)) { throw new ArgumentException("Could not create account"); } } Logger.Debug($"Logging in with account ID: {account.Id}"); session.AccountId = account.Id; switch (mode) { case 1: PacketWriter pWriter = PacketWriter.Of(SendOp.NPS_INFO); pWriter.WriteLong(); pWriter.WriteUnicodeString(""); session.Send(pWriter); session.Send(BannerListPacket.SetBanner()); session.Send(ServerListPacket.SetServers(ServerName, ServerIPs)); break; case 2: List <Player> characters = DatabaseManager.GetAccountCharacters(session.AccountId); Logger.Debug($"Initializing login with account id: {session.AccountId}"); session.Send(LoginResultPacket.InitLogin(session.AccountId)); session.Send(UgcPacket.SetEndpoint("http://127.0.0.1/ws.asmx?wsdl", "http://127.0.0.1")); session.Send(CharacterListPacket.SetMax(4, 6)); session.Send(CharacterListPacket.StartList()); // Send each character data session.Send(CharacterListPacket.AddEntries(characters)); session.Send(CharacterListPacket.EndList()); break; } }
public override void Handle(LoginSession session, PacketReader packet) { byte mode = packet.ReadByte(); string username = packet.ReadUnicodeString(); string pass = packet.ReadUnicodeString(); Logger.Debug($"Logging in with username: '******' pass: '******'"); // TODO: From this user/pass lookup we should be able to find the accountId if (string.IsNullOrEmpty(username) && string.IsNullOrEmpty(pass)) { // send error / account credentials not found } session.AccountId = AccountStorage.DEFAULT_ACCOUNT_ID; switch (mode) { case 1: PacketWriter pWriter = PacketWriter.Of(SendOp.NPS_INFO); pWriter.WriteLong(); pWriter.WriteUnicodeString(""); session.Send(pWriter); session.Send(BannerListPacket.SetBanner()); session.Send(ServerListPacket.SetServers(ServerName, ServerIPs)); break; case 2: List <Player> characters = new List <Player>(); foreach (long characterId in AccountStorage.ListCharacters(session.AccountId)) { characters.Add(AccountStorage.GetCharacter(characterId)); } Logger.Debug($"Initializing login with account id: {session.AccountId}"); session.Send(LoginResultPacket.InitLogin(session.AccountId)); session.Send(UgcPacket.SetEndpoint("http://127.0.0.1/ws.asmx?wsdl", "http://127.0.0.1")); session.Send(CharacterListPacket.SetMax(4, 6)); session.Send(CharacterListPacket.StartList()); // Send each character data session.Send(CharacterListPacket.AddEntries(characters)); session.Send(CharacterListPacket.EndList()); break; } }
private void SendCharacters(LoginSession session, Account account) { string serverIp = Environment.GetEnvironmentVariable("IP"); string webServerPort = Environment.GetEnvironmentVariable("WEB_PORT"); string url = $"http://{serverIp}:{webServerPort}"; List <Player> characters = DatabaseManager.Characters.FindAllByAccountId(session.AccountId); Logger.Debug("Initializing login with account id: {session.AccountId}", session.AccountId); session.Send(LoginResultPacket.InitLogin(session.AccountId)); session.Send(UgcPacket.SetEndpoint($"{url}/ws.asmx?wsdl", url)); session.Send(CharacterListPacket.SetMax(account.CharacterSlots)); session.Send(CharacterListPacket.StartList()); // Send each character data session.Send(CharacterListPacket.AddEntries(characters)); session.Send(CharacterListPacket.EndList()); }
public void OnLogin(LoginPacket packet) { try { var request = new HttpRequestMessage() { RequestUri = new Uri("https://discordapp.com/api/users/@me"), Method = HttpMethod.Get, }; request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", packet.accessToken); HttpResponseMessage requestRespose = AsynchronousSocketListener.httpClient.SendAsync(request).Result;; requestRespose.EnsureSuccessStatusCode(); string result = requestRespose.Content.ReadAsStringAsync().Result; JObject parsedResult = JObject.Parse(result); if (parsedResult["id"] != null) { String id = parsedResult["id"].ToString(); String username = parsedResult["username"].ToString() + "#" + parsedResult["discriminator"].ToString(); Console.WriteLine("Successful login from {0} ({1})", id, username); loggedIn = true; loggedInUser = id; loggedInUsername = username; var response = new LoginResultPacket(1, id); SendPacket(response); } else { Console.WriteLine("Login Failed."); var response = new LoginResultPacket(0); SendPacket(response); } } catch (System.Net.Http.HttpRequestException) { Console.WriteLine("Login Errored."); var response = new LoginResultPacket(0); SendPacket(response); } }
public override void Handle(LoginSession session, PacketReader packet) { LoginMode mode = (LoginMode)packet.ReadByte(); string username = packet.ReadUnicodeString(); string password = packet.ReadUnicodeString(); Account account; if (DatabaseManager.Accounts.AccountExists(username.ToLower())) { if (!DatabaseManager.Accounts.Authenticate(username, password, out account)) { session.Send(LoginResultPacket.IncorrectPassword()); return; } } else { // Hash the password with BCrypt string passwordHash = BCrypt.Net.BCrypt.HashPassword(password); account = new Account(username, passwordHash); // Create a new account if username doesn't exist } Logger.Debug("Logging in with account ID: {account.Id}", account.Id); session.AccountId = account.Id; switch (mode) { case LoginMode.Banners: SendBanners(session, account); break; case LoginMode.SendCharacters: SendCharacters(session, account); break; } }
// login request public void ReceiveLoginRequest(Socket clientSocket, byte[] data) { // packet serialize LoginRequestPacket receivePacket = new LoginRequestPacket(data); LoginRequestData loginRequestData = receivePacket.GetData(); // process bool result; string resultString; result = dataProcessor.LoginPlayer(clientSocket, loginRequestData.id, loginRequestData.password, out resultString); // make result data LoginResultData sendData = new LoginResultData(); sendData.loginResult = result; sendData.message = resultString; //make result packet LoginResultPacket sendPacket = new LoginResultPacket(sendData); // send result packet networkProcessor.Send(clientSocket, sendPacket); }
public override void Handle(GameSession session, PacketReader packet) { long accountId = packet.ReadLong(); if (accountId is 0) { Logger.Error("Account ID was 0. Login has failed or connection was made directly to game server."); session.Send(LoginResultPacket.SendLoginMode(LoginMode.SessionVerificationFailed)); return; } AuthData authData = DatabaseManager.AuthData.GetByAccountId(accountId); if (authData is null) { Logger.Error("AuthData with account ID {accountId} was not found in database.", accountId); session.Send(LoginResultPacket.SendLoginMode(LoginMode.SystemErrorDB)); return; } Player dbPlayer = DatabaseManager.Characters.FindPlayerById(authData.OnlineCharacterId, session); // Backwards seeking because we read accountId here packet.Skip(-8); HandleCommon(session, packet); session.InitPlayer(dbPlayer); Player player = session.Player; player.BuddyList = GameServer.BuddyManager.GetBuddies(player.CharacterId); player.Mailbox = GameServer.MailManager.GetMails(player.CharacterId); GameServer.PlayerManager.AddPlayer(player); GameServer.BuddyManager.SetFriendSessions(player); // Only send buddy login notification if player is not changing channels if (!player.IsMigrating) { player.UpdateBuddies(); } if (player.GuildId != 0) { Guild guild = GameServer.GuildManager.GetGuildById(player.GuildId); player.Guild = guild; GuildMember guildMember = guild.Members.First(x => x.Id == player.CharacterId); guildMember.Player = player; player.GuildMember = guildMember; session.Send(GuildPacket.UpdateGuild(guild)); guild.BroadcastPacketGuild(GuildPacket.UpdatePlayer(player)); if (!player.IsMigrating) { guild.BroadcastPacketGuild(GuildPacket.MemberLoggedIn(player), session); } } // Get Clubs foreach (ClubMember member in player.ClubMembers) { Club club = GameServer.ClubManager.GetClubById(member.ClubId); club.Members.First(x => x.Player.CharacterId == player.CharacterId).Player = player; club.BroadcastPacketClub(ClubPacket.UpdateClub(club)); if (!player.IsMigrating) { club.BroadcastPacketClub(ClubPacket.LoginNotice(player, club), session); } player.Clubs.Add(club); member.Player = player; } // Get Group Chats player.GroupChats = GameServer.GroupChatManager.GetGroupChatsByMember(player.CharacterId); foreach (GroupChat groupChat in player.GroupChats) { session.Send(GroupChatPacket.Update(groupChat)); if (!player.IsMigrating) { groupChat.BroadcastPacketGroupChat(GroupChatPacket.LoginNotice(groupChat, player)); } } //session.Send(0x27, 0x01); // Meret market related...? session.Send(MushkingRoyaleSystemPacket.LoadStats(player.Account.MushkingRoyaleStats)); session.Send(MushkingRoyaleSystemPacket.LoadMedals(player.Account)); player.GetUnreadMailCount(); session.Send(BuddyPacket.Initialize()); session.Send(BuddyPacket.LoadList(player.BuddyList)); session.Send(BuddyPacket.EndList(player.BuddyList.Count)); // Meret market session.Player.GetMeretMarketPersonalListings(); session.Player.GetMeretMarketSales(); // UserConditionEvent //session.Send("BF 00 00 00 00 00 00".ToByteArray()); // PCBangBonus //session.Send("A7 00 03 00 00 00 00 00 00 00 00 00 00 00 00 00".ToByteArray()); session.Send(TimeSyncPacket.SetInitial1()); session.Send(TimeSyncPacket.SetInitial2()); session.Send(StatPacket.SetStats(session.Player.FieldPlayer)); // session.Send(StatPacket.SetStats(session.Player.FieldPlayer)); // Second packet is meant to send the stats initialized, for now we'll just send the first one session.Player.ClientTickSyncLoop(); session.Send(DynamicChannelPacket.DynamicChannel(short.Parse(ConstantsMetadataStorage.GetConstant("ChannelCount")))); session.Send(ServerEnterPacket.Enter(session)); session.Send(UGCPacket.Unknown22()); session.Send(CashPacket.Unknown09()); // SendContentShutdown f(0x01, 0x04) session.Send(PvpPacket.Mode0C()); session.Send(SyncNumberPacket.Send()); session.Send(SyncValuePacket.SetSyncValue(120000)); // unknown what this value means session.Send(PrestigePacket.SetLevels(player)); session.Send(PrestigePacket.WeeklyMissions(player.PrestigeMissions)); // Load inventory tabs foreach (InventoryTab tab in Enum.GetValues(typeof(InventoryTab))) { player.Inventory.LoadInventoryTab(session, tab); } if (player.Account.HomeId != 0) { Home home = GameServer.HomeManager.GetHomeById(player.Account.HomeId); player.Account.Home = home; session.Send(WarehouseInventoryPacket.StartList()); int counter = 0; foreach (KeyValuePair <long, Item> kvp in home.WarehouseInventory) { session.Send(WarehouseInventoryPacket.Load(kvp.Value, ++counter)); } session.Send(WarehouseInventoryPacket.EndList()); session.Send(FurnishingInventoryPacket.StartList()); foreach (Cube cube in home.FurnishingInventory.Values.Where(x => x.Item != null)) { session.Send(FurnishingInventoryPacket.Load(cube)); } session.Send(FurnishingInventoryPacket.EndList()); } session.Send(QuestPacket.StartList()); session.Send(QuestPacket.Packet1F()); session.Send(QuestPacket.Packet20()); IEnumerable <List <QuestStatus> > packetCount = player.QuestData.Values.ToList().SplitList(200); // Split the quest list in 200 quests per packet foreach (List <QuestStatus> item in packetCount) { session.Send(QuestPacket.SendQuests(item)); } session.Send(QuestPacket.EndList()); session.Send(TrophyPacket.WriteTableStart()); List <Trophy> trophyList = new(player.TrophyData.Values); IEnumerable <List <Trophy> > trophyListPackets = trophyList.SplitList(60); foreach (List <Trophy> trophy in trophyListPackets) { session.Send(TrophyPacket.WriteTableContent(trophy)); } // SendQuest, SendAchieve, SendManufacturer, SendUserMaid session.Send(UserEnvPacket.SetTitles(player)); session.Send(UserEnvPacket.Send04()); session.Send(UserEnvPacket.Send05()); session.Send(UserEnvPacket.UpdateLifeSkills(player.GatheringCount)); session.Send(UserEnvPacket.Send09()); session.Send(UserEnvPacket.Send10()); session.Send(UserEnvPacket.Send12()); session.Send(MeretMarketPacket.ModeC9()); session.Send(FishingPacket.LoadAlbum(player)); session.Send(PvpPacket.Mode16()); session.Send(PvpPacket.Mode17()); session.Send(ResponsePetPacket.LoadAlbum()); // LegionBattle (0xF6) // CharacterAbility // E1 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // If the character is not a new character, this is what we would send session.Send(KeyTablePacket.SendFullOptions(player.GameOptions)); if (player.MapId == (int)Map.UnknownLocation) // tutorial map { session.Send(KeyTablePacket.AskKeyboardOrMouse()); } GameEventHelper.LoadEvents(session.Player); List <GameEvent> gameEvents = DatabaseManager.Events.FindAll(); IEnumerable <List <GameEvent> > gameEventPackets = gameEvents.SplitList(5); foreach (List <GameEvent> gameEvent in gameEventPackets) { session.Send(GameEventPacket.Load(gameEvent)); } // SendKeyTable f(0x00), SendGuideRecord f(0x03), GameEvent f(0x00) // SendBannerList f(0x19), SendRoomDungeon f(0x05, 0x14, 0x17) session.Send(DungeonListPacket.DungeonList()); // 0xF0, ResponsePet P(0F 01) // RequestFieldEnter //session.Send("16 00 00 41 75 19 03 00 01 8A 42 0F 00 00 00 00 00 00 C0 28 C4 00 40 03 44 00 00 16 44 00 00 00 00 00 00 00 00 55 FF 33 42 E8 49 01 00".ToByteArray()); session.Send(RequestFieldEnterPacket.RequestEnter(player.FieldPlayer)); Party party = GameServer.PartyManager.GetPartyByMember(player.CharacterId); if (party != null) { player.Party = party; if (!player.IsMigrating) { party.BroadcastPacketParty(PartyPacket.LoginNotice(player), session); } session.Send(PartyPacket.Create(party, false)); party.BroadcastPacketParty(PartyPacket.UpdatePlayer(player)); party.BroadcastPacketParty(PartyPacket.UpdateDungeonInfo(player)); } player.IsMigrating = false; // SendUgc: 15 01 00 00 00 00 00 00 00 00 00 00 00 4B 00 00 00 session.Send(HomeCommandPacket.LoadHome(player)); player.TimeSyncLoop(); session.Send(TimeSyncPacket.SetSessionServerTick(0)); //session.Send("B9 00 00 E1 0F 26 89 7F 98 3C 26 00 00 00 00 00 00 00 00".ToByteArray()); session.Send(ServerEnterPacket.Confirm()); //session.Send(0xF0, 0x00, 0x1F, 0x78, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00); //session.Send(0x28, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00); }
public void getPackets() { //GD.Print("Get Packets"); //GD.Print(wrapped_client.GetAvailablePacketCount()); if (connected && client.GetAvailableBytes() > 0) { //byte[] packet_data = wrapped_client.GetPacket(); //UInt32 packetLength = BitConverter.ToUInt32(packet_data, 0); //short packetId = BitConverter.ToInt16(packet_data, 4); UInt32 packetLength = (UInt32)client.GetU32(); short packetId = (short)client.Get16(); var packetData = client.GetData((int)packetLength - 2); //var data = new List<byte>(packet_data).GetRange(6, packet_data.Length -6).ToArray(); //GD.Print(BitConverter.ToString( (byte[]) packetData[1])); var data = (byte[])packetData[1]; var packet = Packets.Packets.decode(packetId, data); if (GetParent().GetNodeOrNull("GUI") != null) { var gui = (Control)GetParent().GetNodeOrNull("GUI"); gui.Call("recordPacket", packetLength + 4); } GD.Print(String.Format("Received packet {0}, ID: {1} Length: {2}", packet.name, packetId, packetLength)); if (packet is ReadyPacket) { ReadyPacket parsed_packet = (ReadyPacket)packet; if (parsed_packet.code == 0) { string token = (string)GetParent().GetNode("Discord Integration").Call("getToken"); var loginPacket = new LoginPacket(token); GD.Print("Sending login"); sendPacket(loginPacket); } else if (parsed_packet.code == 1) { var requestWorldPacket = new RequestWorldPacket(); sendPacket(requestWorldPacket); if (!joined) { var loadingRes = GD.Load <PackedScene>("res://scenes/world.tscn"); var node = loadingRes.Instance(); node.SetName("WorldScene"); var loadingGuiRes = GD.Load <PackedScene>("res://scenes/gui.tscn"); var gui = (Control)loadingGuiRes.Instance(); gui.SetName("GUI"); GetParent().Call("setState", 2); GetParent().AddChild(node); //GetParent().AddChild(gui); GetParent().AddChild(gui); //node.AddChild(gui); GetParent().GetNode("GameLoader").Free(); //var playerSpriteScene = (PackedScene) node.Call("getSprite", "rowan"); //var playerSprite = (AnimatedSprite) playerSpriteScene.Instance(); //playerSprite.SetName("PlayerSprite"); //node.GetNode("World/Player").AddChild(playerSprite); //playerSprite.Position = ((KinematicBody2D) node.GetNode("Player")).Position; //playerSprite.Visible = true; //GD.Print(playerSprite); joined = true; } } } else if (packet is PongPacket) { PongPacket parsed_packet = (PongPacket)packet; GD.Print("Got pong of " + parsed_packet.message); } else if (packet is LoginResultPacket) { LoginResultPacket parsed_packet = (LoginResultPacket)packet; GD.Print("Login Result: " + parsed_packet.responseCode.ToString() + " Name: " + parsed_packet.userId); var joinGamePacket = new JoinGamePacket(); sendPacket(joinGamePacket); } else if (packet is WorldPacket) { WorldPacket parsed_packet = (WorldPacket)packet; //GD.Print(parsed_packet.debug); GetParent().GetNode("WorldScene").Call("loadWorld", new object[] { parsed_packet.worldData, parsed_packet.bumpData, parsed_packet.height, parsed_packet.width }); } else if (packet is PlayerPositionPacket) { PlayerPositionPacket parsed_packet = (PlayerPositionPacket)packet; GetParent().GetNode("WorldScene/World/Player").Call("move", new object[] { parsed_packet.x, parsed_packet.y }); } else if (packet is ChatPacket) { ChatPacket parsed_packet = (ChatPacket)packet; GetNode("../GUI/Chat").Call("AddMessage", parsed_packet.author + ": " + parsed_packet.msg); } else if (packet is EntityPacket) { EntityPacket parsed_packet = (EntityPacket)packet; GD.Print("Got entity '", parsed_packet.sprite, "' at ", parsed_packet.x, ",", parsed_packet.y, " ID: ", parsed_packet.uuid); GetNode("../WorldScene").Call("addEntity", parsed_packet.x, parsed_packet.y, parsed_packet.type, parsed_packet.facing, parsed_packet.interactable, parsed_packet.sprite, parsed_packet.uuid, parsed_packet.type != 2); } else if (packet is EntityMovePacket) { EntityMovePacket parsed_packet = (EntityMovePacket)packet; GD.Print("Got entity moving to ", parsed_packet.x, ",", parsed_packet.y, " ID: ", parsed_packet.uuid); GetNode("../WorldScene").Call("moveEntity", parsed_packet.uuid, parsed_packet.x, parsed_packet.y, parsed_packet.facing); } else if (packet is InvalidateCachePacket) { InvalidateCachePacket parsed_packet = (InvalidateCachePacket)packet; GD.Print(parsed_packet.uuid, " Invalidated."); GetNode("../WorldScene").Call("hideEntity", parsed_packet.uuid); } else if (packet is DialoguePacket) { DialoguePacket parsed_packet = (DialoguePacket)packet; GD.Print("Got dialogue \"", parsed_packet.text, "\""); Window window = (Window)GetNode("../GUI/Window"); window.OpenDialoguePanel(); DialoguePanel dialoguePanel = window.OpenDialoguePanel(); //(DialoguePanel) GetNode("../GUI/Window/DialoguePanel"); dialoguePanel.SetDialogue(parsed_packet.text, parsed_packet.author, parsed_packet.sprite, parsed_packet.substitutions, parsed_packet.optionViews); } else if (packet is CloseDialoguePacket) { CloseDialoguePacket parsed_packet = (CloseDialoguePacket)packet; DialoguePanel dialoguePanel = (DialoguePanel)GetNode("../GUI/Window/DialoguePanel"); dialoguePanel.CloseDialogue(parsed_packet.guid); //dialoguePanel.SetDialogue(parsed_packet.text, parsed_packet.author, parsed_packet.sprite, parsed_packet.substitutions, parsed_packet.optionViews); } else if (packet is PlayerDataPacket) { PlayerDataPacket parsed_packet = (PlayerDataPacket)packet; var player = (Player)GetNode("../WorldScene/World/Player"); player.SetUuid(parsed_packet.guid); if (player.GetNodeOrNull("PlayerSprite") != null) { player.GetNodeOrNull("PlayerSprite").Free(); } var playerSpriteScene = (PackedScene)GetNode("../WorldScene").Call("getSprite", parsed_packet.sprite); var playerSprite = (AnimatedSprite)playerSpriteScene.Instance(); playerSprite.SetName("PlayerSprite"); player.AddChild(playerSprite); } else if (packet is InventoryPacket) { InventoryPacket parsed_packet = (InventoryPacket)packet; var player = (Player)GetNode("../WorldScene/World/Player"); if (player.guid == parsed_packet.inventory.guid) { player.inventory = parsed_packet.inventory; foreach (Item item in player.inventory.items) { GD.Print("Item: ", item.GetName(), " \"", item.GetDescription(), "\""); } } } else if (packet is AddItemPacket) { AddItemPacket parsed_packet = (AddItemPacket)packet; var player = (Player)GetNode("../WorldScene/World/Player"); if (player.guid == parsed_packet.guid) { //TODO: Make use of indices. player.inventory.AddItem(parsed_packet.item, true); } } else if (packet is ModifyItemPacket) { ModifyItemPacket parsed_packet = (ModifyItemPacket)packet; var player = (Player)GetNode("../WorldScene/World/Player"); if (player.guid == parsed_packet.guid) { //TODO: Make use of indices. player.inventory.UpdateItem(parsed_packet.item, parsed_packet.index); } } } else { var testPacket = new Packets.PingPacket("Hello There!"); //sendPacket(testPacket); } }