예제 #1
0
        public void Place(IPoint3D p, Map map, Mobile from)
        {
            if (p == null || map == null || this.Deleted)
            {
                return;
            }

            if (IsChildOf(from.Backpack))
            {
                BaseAddon addon = Addon;                 // this creates an instance, don't use Addon (capital A) more than once!

                Server.Spells.SpellHelper.GetSurfaceTop(ref p);

                ArrayList houses = null;

                AddonFitResult res = addon.CouldFit(addon.BlocksDoors, p, map, from, ref houses);

                if (res == AddonFitResult.Valid)
                {
                    addon.MoveToWorld(new Point3D(p), map);
                }
                else if (res == AddonFitResult.Blocked)
                {
                    from.SendLocalizedMessage(500269);                     // You cannot build that there.
                }
                else if (res == AddonFitResult.NotInHouse)
                {
                    from.SendLocalizedMessage(500274);                     // You can only place this in a house that you own!
                }
                else if (res == AddonFitResult.DoorsNotClosed)
                {
                    from.SendMessage("You must close all house doors before placing this.");
                }
                else if (res == AddonFitResult.DoorTooClose)
                {
                    from.SendLocalizedMessage(500271);                     // You cannot build near the door.
                }
                if (res == AddonFitResult.Valid)
                {
                    Delete();

                    if (houses != null)
                    {
                        foreach (Server.Multis.BaseHouse h in houses)
                        {
                            h.Addons.Add(addon);
                            addon.OnPlaced(from, h);
                        }

                        from.SendGump(new ConfirmAddonPlacementGump(from, addon));
                    }
                }
                else
                {
                    addon.Delete();
                }
            }
            else
            {
                from.SendLocalizedMessage(1042001);                 // That must be in your pack for you to use it.
            }
        }