Beispiel #1
0
        private void DecorMove(ClientHousingDecorUpdate.DecorUpdate update)
        {
            Decor decor = residence.GetDecor(update.DecorId);

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

            // TODO: research 0.835f
            if (decor.Type == DecorType.Crate)
            {
                if (decor.Entry.Creature2IdActiveProp != 0u)
                {
                    // TODO: used for decor that have an associated entity
                }

                // crate->world
                var position = new Vector3(update.Position.X, update.Position.Y + 0.835f, update.Position.Z);
                decor.Move(update.DecorType, position, update.Rotation, update.Scale);
            }
            else
            {
                if (update.DecorType == DecorType.Crate)
                {
                    decor.Crate();
                }
                else
                {
                    // world->world
                    var position = new Vector3(update.Position.X, update.Position.Y + 0.835f, update.Position.Z);
                    decor.Move(update.DecorType, position, update.Rotation, update.Scale);
                }
            }

            EnqueueToAll(new ServerHousingResidenceDecor
            {
                Operation = 0,
                DecorData = new List <ServerHousingResidenceDecor.Decor>
                {
                    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
                    }
                }
            });
        }
Beispiel #2
0
        private void DecorMove(Player player, ClientHousingDecorUpdate.DecorUpdate update)
        {
            Decor decor = residence.GetDecor(update.DecorId);

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

            HousingResult GetResult()
            {
                if (!IsValidPlotForPosition(update))
                {
                    return(HousingResult.Decor_InvalidPosition);
                }

                return(HousingResult.Success);
            }

            HousingResult result = GetResult();

            if (result == HousingResult.Success)
            {
                if (update.PlotIndex != decor.PlotIndex)
                {
                    decor.PlotIndex = update.PlotIndex;
                }

                if (update.ColourShiftId != decor.ColourShiftId)
                {
                    if (update.ColourShiftId != 0u)
                    {
                        ColorShiftEntry colourEntry = GameTableManager.Instance.ColorShift.GetEntry(update.ColourShiftId);
                        if (colourEntry == null)
                        {
                            throw new InvalidPacketValueException();
                        }
                    }

                    decor.ColourShiftId = update.ColourShiftId;
                }

                if (decor.Type == DecorType.Crate)
                {
                    if (decor.Entry.Creature2IdActiveProp != 0u)
                    {
                        // TODO: used for decor that have an associated entity
                    }

                    // crate->world
                    decor.Move(update.DecorType, update.Position, update.Rotation, update.Scale);
                }
                else
                {
                    if (update.DecorType == DecorType.Crate)
                    {
                        decor.Crate();
                    }
                    else
                    {
                        // world->world
                        decor.Move(update.DecorType, update.Position, update.Rotation, update.Scale);
                        decor.DecorParentId = update.ParentDecorId;
                    }
                }
            }
            else
            {
                player.Session.EnqueueMessageEncrypted(new ServerHousingResult
                {
                    RealmId     = WorldServer.RealmId,
                    ResidenceId = residence.Id,
                    PlayerName  = player.Name,
                    Result      = result
                });
            }

            EnqueueToAll(new ServerHousingResidenceDecor
            {
                Operation = 0,
                DecorData = new List <ServerHousingResidenceDecor.Decor>
                {
                    new ServerHousingResidenceDecor.Decor
                    {
                        RealmId       = WorldServer.RealmId,
                        DecorId       = decor.DecorId,
                        ResidenceId   = residence.Id,
                        DecorType     = decor.Type,
                        PlotIndex     = decor.PlotIndex,
                        Scale         = decor.Scale,
                        Position      = decor.Position,
                        Rotation      = decor.Rotation,
                        DecorInfoId   = decor.Entry.Id,
                        ParentDecorId = decor.DecorParentId,
                        ColourShift   = decor.ColourShiftId
                    }
                }
            });
        }