Ejemplo n.º 1
0
        private void SendResidenceDecor(Player player)
        {
            var residenceDecor = new ServerHousingResidenceDecor();

            Decor[] decors = residence.GetDecor().ToArray();
            for (uint i = 0u; i < decors.Length; i++)
            {
                // client freaks out if too much decor is sent in a single message, limit to 100
                if (i != 0u && i % 100u == 0u)
                {
                    player.Session.EnqueueMessageEncrypted(residenceDecor);
                    residenceDecor = new ServerHousingResidenceDecor();
                }

                Decor decor = decors[i];
                residenceDecor.DecorData.Add(new ServerHousingResidenceDecor.Decor
                {
                    RealmId     = WorldServer.RealmId,
                    DecorId     = decor.DecorId,
                    ResidenceId = residence.Id,
                    DecorType   = decor.Type,
                    Scale       = decor.Scale,
                    Position    = decor.Position,
                    Rotation    = decor.Rotation,
                    DecorInfoId = decor.Entry.Id,
                    ColourShift = decor.ColourShiftId
                });

                if (i == decors.Length - 1)
                {
                    player.Session.EnqueueMessageEncrypted(residenceDecor);
                }
            }
        }
Ejemplo n.º 2
0
        public static void HandleHousingCommunityDonate(WorldSession session, ClientHousingCommunityDonate housingCommunityDonate)
        {
            // can only donate to a community from a residence map
            if (session.Player.Map is not ResidenceMapInstance)
            {
                throw new InvalidPacketValueException();
            }

            Residence residence = session.Player.ResidenceManager.Residence;

            if (residence == null)
            {
                throw new InvalidPacketValueException();
            }

            Community community = session.Player.GuildManager.GetGuild <Community>(GuildType.Community);

            if (community?.Residence == null)
            {
                throw new InvalidPacketValueException();
            }

            foreach (DecorInfo decorInfo in housingCommunityDonate.Decor)
            {
                Decor decor = residence.GetDecor(decorInfo.DecorId);
                if (decor == null)
                {
                    throw new InvalidPacketValueException();
                }

                if (decor.Type != DecorType.Crate)
                {
                    throw new InvalidPacketValueException();
                }

                // copy decor to recipient residence
                if (community.Residence.Map != null)
                {
                    community.Residence.Map.DecorCopy(community.Residence, decor);
                }
                else
                {
                    community.Residence.DecorCopy(decor);
                }

                // remove decor from donor residence
                if (residence.Map != null)
                {
                    residence.Map.DecorDelete(residence, decor);
                }
                else
                {
                    if (decor.PendingCreate)
                    {
                        residence.DecorRemove(decor);
                    }
                    else
                    {
                        decor.EnqueueDelete();
                    }
                }
            }
        }