/// <summary> /// Create and add <see cref="Decor"/> from supplied <see cref="HousingDecorInfoEntry"/> to your crate. /// </summary> public void DecorCreate(HousingDecorInfoEntry entry, uint quantity) { var residenceDecor = new ServerHousingResidenceDecor(); for (uint i = 0u; i < quantity; i++) { Decor decor = residence.DecorCreate(entry); decor.Type = DecorType.Crate; residenceDecor.DecorData.Add(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 }); } EnqueueToAll(residenceDecor); }
public Task DecorAddSubCommandHandler(CommandContext context, string command, string[] parameters) { if (parameters.Length < 1 && parameters.Length > 2) { return(Task.CompletedTask); } if (!(context.Session.Player.Map is ResidenceMap residenceMap)) { context.SendMessageAsync("You need to be on a housing map to use this command!"); return(Task.CompletedTask); } uint decorInfoId = uint.Parse(parameters[0]); uint quantity = parameters.Length == 2 ? uint.Parse(parameters[1]) : 1u; HousingDecorInfoEntry entry = GameTableManager.HousingDecorInfo.GetEntry(decorInfoId); if (entry == null) { context.SendMessageAsync($"Invalid decor info id {decorInfoId}!"); return(Task.CompletedTask); } residenceMap.DecorCreate(entry, quantity); return(Task.CompletedTask); }
public static void HandleItemUseDecor(WorldSession session, ClientItemUseDecor itemUseDecor) { Item item = session.Player.Inventory.GetItem(itemUseDecor.ItemGuid); if (item == null) { throw new InvalidPacketValueException(); } HousingDecorInfoEntry entry = GameTableManager.HousingDecorInfo.GetEntry(item.Entry.HousingDecorInfoId); if (entry == null) { throw new InvalidPacketValueException(); } Task <Residence> task = ResidenceManager.GetResidence(session.Player.Name); session.EnqueueEvent(new TaskGenericEvent <Residence>(task, residence => { if (residence == null) { residence = ResidenceManager.CreateResidence(session.Player); } if (session.Player.Inventory.ItemUse(item)) { residence.DecorCreate(entry); } })); }
/// <summary> /// Create new <see cref="Decor"/> from supplied <see cref="HousingDecorInfoEntry"/> to residence your crate. /// </summary> /// <remarks> /// Decor will be created for your residence regardless of the current residence you are on. /// </remarks> public void DecorCreate(HousingDecorInfoEntry entry, uint quantity = 1u) { Residence ??= GlobalResidenceManager.Instance.CreateResidence(owner); if (Residence.Map != null) { Residence.Map.DecorCreate(Residence, entry, quantity); } else { for (uint i = 0u; i < quantity; i++) { Residence.DecorCreate(entry); } } }
public void HandleHouseDecorAdd(ICommandContext context, [Parameter("Decor info id entry to add to the crate.")] uint decorInfoId, [Parameter("Quantity of decor to add to the crate.")] uint?quantity) { quantity ??= 1u; HousingDecorInfoEntry entry = GameTableManager.Instance.HousingDecorInfo.GetEntry(decorInfoId); if (entry == null) { context.SendMessage($"Invalid decor info id {decorInfoId}!"); return; } context.GetTargetOrInvoker <Player>().ResidenceManager.DecorCreate(entry, quantity.Value); }
public static void HandleItemUseDecor(WorldSession session, ClientItemUseDecor itemUseDecor) { Item item = session.Player.Inventory.GetItem(itemUseDecor.ItemGuid); if (item == null) { throw new InvalidPacketValueException(); } HousingDecorInfoEntry entry = GameTableManager.Instance.HousingDecorInfo.GetEntry(item.Info.Entry.HousingDecorInfoId); if (entry == null) { throw new InvalidPacketValueException(); } if (session.Player.Inventory.ItemUse(item)) { session.Player.ResidenceManager.DecorCreate(entry); } }
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 } } }); }