public override void ReplaceWith(Item newItem) { if (Parent is Container) { var cont = (Container)Parent; if (newItem is BaseFireworkStar) { BaseFireworkStar star = (BaseFireworkStar)newItem; Type starType = star.GetType(); BaseFireworkStar stackWith = cont.FindItemsByType <BaseFireworkStar>() .FirstOrDefault( s => s.Stackable && s.Resource == star.Resource && s.Amount + star.Amount <= 60000 && s.GetType().IsEqual(starType)); if (stackWith != null) { stackWith.Amount += newItem.Amount; newItem.Delete(); } else { cont.AddItem(newItem); newItem.Location = Location; } } else { cont.AddItem(newItem); newItem.Location = Location; } } else { newItem.MoveToWorld(GetWorldLocation(), Map); } Delete(); }
public override int OnCraft( int quality, bool makersMark, Mobile m, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue) { if (craftSystem is Pyrotechnics && craftItem != null) { var stars = new CraftRes[craftItem.Resources.Count]; stars.SetAll(i => craftItem.Resources.GetAt(i)); stars = stars.Where(res => res.ItemType.IsEqualOrChildOf <BaseFireworkStar>()).ToArray(); if (stars.Length > 0) { StarsRangeMin = 1 + stars.Sum(s => s.Amount); StarsRangeMax = StarsRangeMin * 2; LaunchHeightMin = Math.Max(50, Math.Min(100, StarsRangeMin * 5)); LaunchHeightMax = Math.Max(50, Math.Min(100, StarsRangeMax * 5)); StarHues.AddRange(BaseFireworkStar.GetEffectHues(typeRes ?? stars[0].ItemType)); if (stars.Length > 1) { StarHues.AddRange(stars.Skip(1).SelectMany(s => BaseFireworkStar.GetEffectHues(s.ItemType))); } } } return(base.OnCraft(quality, makersMark, m, craftSystem, typeRes, tool, craftItem, resHue)); }