public void CheckCombine(Mobile m, RefinementComponent component)
        {
            if (ToUpgrade == null)
            {
                if (component.ModType != ModType.Invulnerability)
                {
                    ToCombine = new List <RefinementComponent>();
                    ToUpgrade = component;

                    m.SendLocalizedMessage(1154351); // Target the refinement you wish to combine.
                    m.Target = new InternalTarget(m, this);
                }
                else
                {
                    m.SendLocalizedMessage(1154353); // You can't upgrade this refinement.
                }
            }
            else
            {
                if (ToUpgrade == component) // Can't target the same one twice.
                {
                    return;
                }

                if (ToUpgrade.RefinementType != component.RefinementType || ToUpgrade.CraftType != component.CraftType || ToUpgrade.SubCraftType != component.SubCraftType || ToUpgrade.ModType != component.ModType)
                {
                    m.SendLocalizedMessage(1154354); // This refinement does not match the type currently being combined.
                }
                else
                {
                    ToCombine.Add(component);
                    ValidateList(m);

                    if (ToCombine.Count >= GetCombineTotal(component.ModType) - 1) // -1 because we're counting ToUpgrade
                    {
                        for (var index = 0; index < ToCombine.Count; index++)
                        {
                            RefinementComponent comp = ToCombine[index];

                            comp.Delete();
                        }

                        ToUpgrade.ModType++;

                        m.SendLocalizedMessage(1154352); // You've completed the amalgamation and received an upgraded version of your refinement.
                    }
                    else
                    {
                        m.SendLocalizedMessage(1154360); // You place the refinement into the amalgamator.

                        m.SendLocalizedMessage(1154351); // Target the refinement you wish to combine.
                        m.Target = new InternalTarget(m, this);
                    }
                }
            }
        }
Example #2
0
        private void ValidateList(Mobile m)
        {
            if (ToCombine == null)
            {
                return;
            }

            var copy = new List <RefinementComponent>(ToCombine);

            foreach (var comp in copy)
            {
                if (comp == null || comp.Deleted || !comp.IsChildOf(m.Backpack))
                {
                    ToCombine.Remove(comp);
                }
            }

            ColUtility.Free(copy);
        }
        private void ValidateList(Mobile m)
        {
            if (ToCombine == null)
            {
                return;
            }

            List <RefinementComponent> copy = new List <RefinementComponent>(ToCombine);

            for (var index = 0; index < copy.Count; index++)
            {
                RefinementComponent comp = copy[index];

                if (comp == null || comp.Deleted || !comp.IsChildOf(m.Backpack))
                {
                    ToCombine.Remove(comp);
                }
            }

            ColUtility.Free(copy);
        }