public static void OnAddPartyMember(WorldClient client, INetPacketStream packet) { var addPartyMemberPacket = new PartyAddMemberPacket(packet); var addPartyMemberEventArgs = new PartyAddMemberEventArgs(addPartyMemberPacket); client.Player.NotifySystem <PartySystem>(addPartyMemberEventArgs); }
private void OnAddPartyMember(IPlayerEntity player, PartyAddMemberEventArgs e) { var partyManager = DependencyContainer.Instance.Resolve <PartyManager>(); var worldServer = DependencyContainer.Instance.Resolve <IWorldServer>(); var leader = worldServer.GetPlayerEntityByCharacterId(e.LeaderId); var member = worldServer.GetPlayerEntityByCharacterId(e.MemberId); if (leader == null || member == null) { return; } if (member.Party.IsInParty) { Logger.LogWarning($"Player {member.Object.Name} is already in a party."); return; } if (leader.Party.IsInParty) { // Add member to leaders party if (leader.Party.Party.IsFull) { // Send SNAPSHOTTYPE_ERRORPARTY with ERROR_FULLPARTY (201) return; } leader.Party.Party.AddMember(member); foreach (var partyMember in leader.Party.Party.Members) { WorldPacketFactory.SendAddPartyMember(partyMember, leader.Party.Party, member.PlayerData.Id, leader.Object.Name, member.Object.Name); } } else { // Create Party with leader and member var party = partyManager.CreateParty(); party.AddMember(leader, true); party.AddMember(member); foreach (var partyMember in party.Members) { WorldPacketFactory.SendAddPartyMember(partyMember, party, member.PlayerData.Id, leader.Object.Name, member.Object.Name); } } }