Beispiel #1
0
        private void DecorCreate(Player player, ClientHousingDecorUpdate.DecorUpdate update)
        {
            HousingDecorInfoEntry entry = GameTableManager.HousingDecorInfo.GetEntry(update.DecorInfoId);

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

            if (entry.CostCurrencyTypeId != 0u && entry.Cost != 0u)
            {
                /*if (!player.CurrencyManager.CanAfford((byte)entry.CostCurrencyTypeId, entry.Cost))
                 * {
                 *  // TODO: show error
                 *  return;
                 * }
                 *
                 * player.CurrencyManager.CurrencySubtractAmount((byte)entry.CostCurrencyTypeId, entry.Cost);*/
            }

            Decor decor = residence.DecorCreate(entry);

            decor.Type = update.DecorType;

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

            if (update.DecorType != DecorType.Crate)
            {
                if (update.Scale < 0f)
                {
                    throw new InvalidPacketValueException();
                }

                // new decor is being placed directly in the world
                decor.Position = update.Position;
                decor.Rotation = update.Rotation;
                decor.Scale    = 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,
                        ColourShift = decor.ColourShiftId
                    }
                }
            });
        }
Beispiel #2
0
        private void DecorMove(ClientHousingDecorUpdate.DecorUpdate update)
        {
            Decor decor = residence.GetDecor(update.DecorId);

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

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

            // 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,
                        ColourShift = decor.ColourShiftId
                    }
                }
            });
        }
Beispiel #3
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
                    }
                }
            });
        }