Esempio n. 1
0
        public virtual void OnCraftComponentUsed(Mobile from, AddonToolComponent tool)
        {
            if (!tool.TurnedOn)
            {
                return;
            }

            if (from.InRange(tool.Location, 2))
            {
                BaseHouse house = BaseHouse.FindHouseAt(from);

                if (house != null && house.HasSecureAccess(from, Level))
                {
                    from.SendGump(new CraftGump(from, CraftSystem, tool, null));
                }
                else
                {
                    tool.PublicOverheadMessage(MessageType.Regular, 0x3E9, 1061637); // You are not allowed to access this.
                }
            }
            else
            {
                from.SendLocalizedMessage(500325); // I am too far away to do that.
            }
        }
Esempio n. 2
0
        public void AddCraftComponent(AddonToolComponent tool, int x, int y, int z)
        {
            if (Deleted)
            {
                return;
            }

            Tools.Add(tool);
            Level = SecureLevel.CoOwners;

            tool.Addon  = this;
            tool.Offset = new Point3D(x, y, z);
            tool.MoveToWorld(new Point3D(X + x, Y + y, Z + z), Map);
        }
Esempio n. 3
0
            public override bool OnDragDrop(Mobile from, Item dropped)
            {
                BaseHouse  house = BaseHouse.FindHouseAt(this);
                CraftAddon addon = Addon as CraftAddon;

                if (house != null && addon != null && house.HasSecureAccess(from, addon.Level) && dropped is ITool && !(dropped is BaseRunicTool))
                {
                    var tool = dropped as ITool;

                    if (addon != null && tool.CraftSystem == addon.CraftSystem)
                    {
                        AddonToolComponent comp = addon.Tools.FirstOrDefault(t => t != null);

                        if (comp == null)
                        {
                            return(false);
                        }

                        if (comp.UsesRemaining >= comp.MaxUses)
                        {
                            from.SendMessage("That is already at its maximum charges.");
                            return(false);
                        }
                        else
                        {
                            int toadd = Math.Min(tool.UsesRemaining, comp.MaxUses - comp.UsesRemaining);

                            comp.UsesRemaining += toadd;
                            tool.UsesRemaining -= toadd;

                            if (tool.UsesRemaining <= 0 && !tool.Deleted)
                            {
                                tool.Delete();
                            }

                            Effects.PlaySound(this.Location, this.Map, 0x42);

                            return(false);
                        }
                    }
                }

                return(false);
            }
Esempio n. 4
0
        public virtual void OnCraftComponentUsed(Mobile from, AddonToolComponent tool)
        {
            if (!tool.TurnedOn)
            {
                return;
            }

            if (from.InRange(tool.Location, 2))
            {
                BaseHouse house = BaseHouse.FindHouseAt(from);

                if (house != null && house.HasSecureAccess(from, Level))
                {
                    from.SendGump(new CraftGump(from, CraftSystem, tool, null));
                }
            }
            else
            {
                from.SendLocalizedMessage(1076766); // That is too far away.
            }
        }
Esempio n. 5
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();

            Level = (SecureLevel)reader.ReadInt();

            Tools = new List <AddonToolComponent>();

            int count = reader.ReadInt();

            for (int i = 0; i < count; i++)
            {
                AddonToolComponent tool = reader.ReadItem() as AddonToolComponent;

                if (tool != null)
                {
                    tool.SetCraftSystem(CraftSystem);
                    Tools.Add(tool);
                }
            }
        }
Esempio n. 6
0
 public virtual void OnCraftComponentLoaded(AddonToolComponent tool)
 {
 }
Esempio n. 7
0
            public override bool OnDragDrop(Mobile from, Item dropped)
            {
                BaseHouse  house = BaseHouse.FindHouseAt(this);
                CraftAddon addon = Addon as CraftAddon;

                if (house != null && addon != null && house.HasSecureAccess(from, addon.Level))
                {
                    if (dropped is ITool && !(dropped is BaseRunicTool))
                    {
                        ITool tool = dropped as ITool;

                        if (tool.CraftSystem == addon.CraftSystem)
                        {
                            AddonToolComponent comp = addon.Tools.FirstOrDefault(t => t != null);

                            if (comp == null)
                            {
                                return(false);
                            }

                            if (comp.UsesRemaining >= comp.MaxUses)
                            {
                                from.SendLocalizedMessage(1155740); // Adding this to the power tool would put it over the max number of charges the tool can hold.
                                return(false);
                            }
                            else
                            {
                                int toadd = Math.Min(tool.UsesRemaining, comp.MaxUses - comp.UsesRemaining);

                                comp.UsesRemaining += toadd;
                                tool.UsesRemaining -= toadd;

                                if (tool.UsesRemaining <= 0 && !tool.Deleted)
                                {
                                    tool.Delete();
                                }

                                from.SendLocalizedMessage(1155741); // Charges have been added to the power tool.

                                Effects.PlaySound(Location, Map, 0x42);

                                return(false);
                            }
                        }
                        else
                        {
                            from.SendLocalizedMessage(1074836); // The container cannot hold that type of object.
                            return(false);
                        }
                    }
                    else
                    {
                        from.SendLocalizedMessage(1074836); // The container cannot hold that type of object.
                        return(false);
                    }
                }
                else
                {
                    SendLocalizedMessageTo(from, 1061637); // You are not allowed to access this.
                    return(false);
                }
            }