コード例 #1
0
ファイル: HouseCraftables.cs プロジェクト: tflynt91/TrueUO
        public void Replace()
        {
            BaseDoor door;

            if (Type < DoorType.LeftMetalDoor_S_In)
            {
                door = new CraftableStoneHouseDoor(Type, CraftableMetalHouseDoor.GetDoorFacing(Type));
            }
            else
            {
                door = new CraftableMetalHouseDoor(Type, CraftableMetalHouseDoor.GetDoorFacing(Type));
            }

            if (door is IResource)
            {
                ((IResource)door).Resource = _Resource;
            }

            if (Parent is Container)
            {
                ((Container)Parent).DropItem(door);
            }
            else
            {
                BaseHouse house = BaseHouse.FindHouseAt(this);

                door.MoveToWorld(Location, Map);

                door.IsLockedDown = IsLockedDown;
                door.IsSecure     = IsSecure;
                door.Movable      = Movable;

                if (house != null && house.LockDowns.ContainsKey(this))
                {
                    house.LockDowns.Remove(this);
                    house.LockDowns.Add(door, house.Owner);
                }
                else if (house != null && house.IsSecure(this))
                {
                    house.ReleaseSecure(house.Owner, this);
                    house.AddSecure(house.Owner, door);
                }
            }

            Delete();
        }
コード例 #2
0
        public override void OnDoubleClick(Mobile from)
        {
            if (IsChildOf(from.Backpack))
            {
                from.BeginTarget(10, true, Server.Targeting.TargetFlags.None, (m, targeted) =>
                {
                    if (IsChildOf(from.Backpack))
                    {
                        IPoint3D p = targeted as IPoint3D;
                        Map map    = from.Map;

                        if (p == null || map == null || Deleted)
                        {
                            return;
                        }

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

                        BaseHouse house = null;
                        Item door;

                        if (this.Type < DoorType.LeftMetalDoor_S_In)
                        {
                            door = new CraftableStoneHouseDoor(this.Type, GetDoorFacing(this.Type));
                        }
                        else
                        {
                            door = new CraftableMetalHouseDoor(this.Type, GetDoorFacing(this.Type));
                        }

                        if (door is CraftableMetalHouseDoor)
                        {
                            ((CraftableMetalHouseDoor)door).Resource = _Resource;
                        }
                        else if (door is CraftableStoneHouseDoor)
                        {
                            ((CraftableStoneHouseDoor)door).Resource = _Resource;
                        }

                        AddonFitResult res = CouldFit(door, p, map, from, ref house);

                        switch (res)
                        {
                        case AddonFitResult.Valid:
                            PlaceDoor(door, p, map, house);
                            return;

                        case AddonFitResult.Blocked:
                            from.SendLocalizedMessage(500269);     // You cannot build that there.
                            break;

                        case AddonFitResult.NotInHouse:
                            from.SendLocalizedMessage(500274);     // You can only place this in a house that you own!
                            break;

                        case AddonFitResult.DoorsNotClosed:
                            from.SendMessage("You must close all house doors before placing this.");
                            break;

                        case AddonFitResult.DoorTooClose:
                            from.SendLocalizedMessage(500271);     // You cannot build near the door.
                            break;

                        case AddonFitResult.BadHouse:
                            from.SendLocalizedMessage(500269);     // You cannot build that there.
                            break;
                        }

                        door.Delete();
                    }
                    else
                    {
                        from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
                    }
                });
            }
            else
            {
                from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
            }
        }