Пример #1
0
        public static void TransferData(StaticHouse sh)
        {
            // now transfer over the data from the original blueprint house
            try
            {
                Misc.Diagnostics.Assert(sh != null, "sh == null");
                if (!IsBlueprintLoaded(sh.HouseBlueprintID))
                {
                    if (!LoadBlueprint(sh.HouseBlueprintID))
                    {
                        try { throw new ApplicationException(); }
                        catch (Exception ex) { LogHelper.LogException(ex, "Can't find/load blueprint from hashtable/xml."); }
                        return;
                    }
                }

                Misc.Diagnostics.Assert(m_BlueprintList[sh.HouseBlueprintID] is HouseBlueprint, "m_BlueprintList[sh.HouseBlueprintID] is HouseBlueprint == false");
                HouseBlueprint house = m_BlueprintList[sh.HouseBlueprintID] as HouseBlueprint;
                if (house == null)
                {
                    try { throw new ApplicationException(); }
                    catch (Exception ex) { LogHelper.LogException(ex, "Can't find/load blueprint from hashtable."); }
                    return;
                }

                // copy the data
                sh.DefaultPrice         = house.Price;
                sh.BlueprintVersion     = house.Version;
                sh.Description          = house.Description;
                sh.OriginalOwnerName    = house.OriginalOwnerName;
                sh.OriginalOwnerAccount = house.OriginalOwnerAccount;
                sh.OriginalOwnerSerial  = house.OriginalOwnerSerial;
                sh.SignHanger.ItemID    = house.SignHangerGraphic;
                sh.Signpost.ItemID      = house.SignpostGraphic;
                sh.SignpostGraphic      = house.SignpostGraphic;
                sh.RevisionDate         = house.Capture;

                Misc.Diagnostics.Assert(house.Region != null, "house.Region == null");
                if (house.Region != null && house.Region.Count > 0)
                {
                    Misc.Diagnostics.Assert(sh.Components != null, "sh.Components == null");
                    foreach (Rectangle2D rect in house.Region)
                    {                           // fixup offsets
                        MultiComponentList mcl = sh.Components;
                        int x = rect.X + sh.X + mcl.Min.X;
                        int y = rect.Y + sh.Y + mcl.Min.Y;
                        sh.AreaList.Add(new Rectangle2D(x, y, rect.Width, rect.Height));
                    }
                    sh.UpdateRegionArea();
                }
            }
            catch (Exception e)
            {
                Server.Commands.LogHelper.LogException(e, "Botched Static Housing xml.");
            }
        }
Пример #2
0
        private static void OnDumpRegions(CommandEventArgs e)
        {
            BaseHouse bh = BaseHouse.FindHouseAt(e.Mobile);

            if (bh == null)
            {
                e.Mobile.SendMessage("You must be standing in the house you wish to dump regions for.");
                return;
            }
            if (bh is StaticHouse == false)
            {
                e.Mobile.SendMessage("You may only dump regions for static houses.");
                return;
            }

            StaticHouse sh = bh as StaticHouse;

            if (sh.AreaList.Count == 0)
            {
                e.Mobile.SendMessage("There are no regions for this house.");
            }
            else
            {
                e.Mobile.SendMessage("--- Area ---");

                foreach (Rectangle2D rx in sh.AreaList)
                {
                    e.Mobile.SendMessage(rx.ToString());
                }

                e.Mobile.SendMessage("--- Regions ---");

                Region r = sh.Region;
                if (r == null || r.Coords == null || r.Coords.Count == 0)
                {
                    return;
                }

                ArrayList c = r.Coords;

                for (int i = 0; i < c.Count; i++)
                {
                    if (c[i] is Rectangle2D)
                    {
                        e.Mobile.SendMessage(((Rectangle2D)c[i]).ToString());
                    }
                }
            }
        }
Пример #3
0
        private static void AddRegionCallback(Mobile from, Map map, Point3D start, Point3D end, object state)
        {
            if (state is StaticHouse == false)
            {
                return;
            }

            StaticHouse sh = state as StaticHouse;

            // normalize bounding rect
            if (start.X > end.X)
            {
                int ix = start.X;
                start.X = end.X;
                end.X   = ix;
            }
            if (start.Y > end.Y)
            {
                int iy = start.Y;
                start.Y = end.Y;
                end.Y   = iy;
            }

            int x = 0;
            int y = 0;

            /*MultiComponentList mcl = sh.Components;
             * int x = sh.X + mcl.Min.X;
             * int y = sh.Y + mcl.Min.Y;*/

            x = start.X - sh.X;
            y = start.Y - sh.Y;

            Rectangle2D temp      = new Rectangle2D(start, end);
            Rectangle2D rectangle = new Rectangle2D(x, y, temp.Width, temp.Height);

            sh.AreaList.Add(rectangle);
            sh.UpdateRegionArea();
        }
Пример #4
0
            protected override void OnTarget(Mobile from, object target)
            {
                if (target is HouseSign && (target as HouseSign).Structure != null)
                {
                    HouseSign sign = target as HouseSign;

                    if (sign.Structure is StaticHouse == false)
                    {
                        from.SendMessage("You may only wipe regions on a StaticHouse.");
                        return;
                    }

                    StaticHouse sh = sign.Structure as StaticHouse;
                    sh.AreaList.Clear();
                    sh.UpdateRegionArea();

                    from.SendMessage("All regions for thie StaticHouse have been wiped.");
                }
                else
                {
                    from.SendMessage("That is not a house sign.");
                }
            }
Пример #5
0
		public static void TransferData(StaticHouse sh)
		{
			// now transfer over the data from the original blueprint house
			try
			{
				Misc.Diagnostics.Assert(sh != null, "sh == null");
				if (!IsBlueprintLoaded(sh.HouseBlueprintID))
					if (!LoadBlueprint(sh.HouseBlueprintID))
					{
						try { throw new ApplicationException(); }
						catch (Exception ex) { LogHelper.LogException(ex, "Can't find/load blueprint from hashtable/xml."); }
						return;
					}

				Misc.Diagnostics.Assert(m_BlueprintList[sh.HouseBlueprintID] is HouseBlueprint, "m_BlueprintList[sh.HouseBlueprintID] is HouseBlueprint == false");
				HouseBlueprint house = m_BlueprintList[sh.HouseBlueprintID] as HouseBlueprint;
				if (house == null)
				{
					try { throw new ApplicationException(); }
					catch (Exception ex) { LogHelper.LogException(ex, "Can't find/load blueprint from hashtable."); }
					return;
				}
				
				// copy the data
				sh.DefaultPrice = house.Price;
				sh.BlueprintVersion = house.Version;
				sh.Description = house.Description;
				sh.OriginalOwnerName = house.OriginalOwnerName;
				sh.OriginalOwnerAccount = house.OriginalOwnerAccount;
				sh.OriginalOwnerSerial = house.OriginalOwnerSerial;
				sh.SignHanger.ItemID = house.SignHangerGraphic;
				sh.Signpost.ItemID = house.SignpostGraphic;
				sh.SignpostGraphic = house.SignpostGraphic;
				sh.RevisionDate = house.Capture;

				Misc.Diagnostics.Assert(house.Region != null, "house.Region == null");
				if (house.Region != null && house.Region.Count > 0)
				{
					Misc.Diagnostics.Assert(sh.Components != null, "sh.Components == null");
					foreach (Rectangle2D rect in house.Region)
					{	// fixup offsets
						MultiComponentList mcl = sh.Components;
						int x = rect.X + sh.X + mcl.Min.X;
						int y = rect.Y + sh.Y + mcl.Min.Y;
						sh.AreaList.Add(new Rectangle2D (x, y, rect.Width, rect.Height));
					}
					sh.UpdateRegionArea();
				}
			}
			catch (Exception e)
			{
				Scripts.Commands.LogHelper.LogException(e, "Botched Static Housing xml.");
			}

		}