示例#1
0
        public PreviewHouse(int multiID)
            : base(multiID)
        {
            this.m_Components = new List <Item>();

            MultiComponentList mcl = this.Components;

            for (int i = 1; i < mcl.List.Length; ++i)
            {
                MultiTileEntry entry = mcl.List[i];

                if (entry.m_Flags == 0)
                {
                    Item item = new Static((int)entry.m_ItemID);

                    item.MoveToWorld(new Point3D(this.X + entry.m_OffsetX, this.Y + entry.m_OffsetY, this.Z + entry.m_OffsetZ), this.Map);

                    this.m_Components.Add(item);
                }
            }

            this.m_Timer = new DecayTimer(this);
            this.m_Timer.Start();
        }
示例#2
0
        public PreviewHouse(int multiID)
            : base(multiID)
        {
            m_Components = new ArrayList();

            MultiComponentList mcl = this.Components;

            for (int i = 1; i < mcl.List.Length; ++i)
            {
                MultiTileEntry entry = mcl.List[i];

                if (entry.m_Flags == 0)
                {
                    Item item = new Static(entry.m_ItemID & TileData.MaxItemValue);

                    item.MoveToWorld(new Point3D(X + entry.m_OffsetX, Y + entry.m_OffsetY, Z + entry.m_OffsetZ), Map);

                    m_Components.Add(item);
                }
            }

            m_Timer = new DecayTimer(this);
            m_Timer.Start();
        }
示例#3
0
        public virtual void AssignItemEffect(Item targetitem, int effectid, int hue, int fraction)
        {
            if (targetitem == null || targetitem.Deleted)
            {
                return;
            }

            // deal with addons
            if (targetitem is BaseAddon)
            {
                BaseAddon addon = (BaseAddon)targetitem;
                if (addon.Components != null)
                {
                    int count = 0;
                    // change the ids of all of the components if they dont already have xmlsiege attachments
                    foreach (AddonComponent i in addon.Components)
                    {
                        if (XmlAttach.FindAttachment(i, typeof(XmlSiege)) == null)
                        {
                            // put the effect on a fraction of the components, but make sure you have at least one
                            if (Utility.Random(100) < fraction || count == 0)
                            {
                                Effects.SendLocationEffect(i.Location, i.Map, effectid, DamagedItemEffectDuration, hue, 0);
                                //Effects.SendTargetEffect(i, DamagedItemEffectID, DamagedItemEffectDuration, hue, 0);
                                count++;
                            }
                        }
                    }
                }
            }
            else
            if (targetitem is BaseMulti)
            {
                // place an effect at the location of the target item
                Effects.SendLocationEffect(targetitem.Location, targetitem.Map, effectid, DamagedItemEffectDuration, hue, 0);

                ArrayList tilelist = new ArrayList();
                // go through all of the multi components
                MultiComponentList mcl = ((BaseMulti)targetitem).Components;
                int count = 0;
                if (mcl != null && mcl.List != null)
                {
                    for (int i = 0; i < mcl.List.Length; i++)
                    {
                        MultiTileEntry t = mcl.List[i];

                        int x = t.m_OffsetX + targetitem.X;
                        int y = t.m_OffsetY + targetitem.Y;
                        int z = t.m_OffsetZ + targetitem.Z;
                        if (Utility.Random(100) < fraction || count == 0)
                        {
                            tilelist.Add(new TileEntry(t.m_ItemID, x, y, z));
                            count++;
                        }
                    }

                    foreach (TileEntry s in tilelist)
                    {
                        Effects.SendLocationEffect(new Point3D(s.X, s.Y, s.Z), targetitem.Map, effectid, DamagedItemEffectDuration, hue, 0);
                    }
                }
            }
            else
            {
                // place an effect at the location of the target item
                Effects.SendLocationEffect(targetitem.Location, targetitem.Map, effectid, DamagedItemEffectDuration, hue, 0);
                //Effects.SendTargetEffect(targetitem, DamagedItemEffectID, DamagedItemEffectDuration, hue, 0);
            }
        }
示例#4
0
文件: Multis.cs 项目: credzba/Razor
        public MultiComponentList(StreamReader stream, int count)
        {
            string line;
            int    itemcount = 0;

            m_Min         = m_Max = Point.Empty;
            m_SortedTiles = new MultiTileEntry[count];
            m_Min.X       = 10000;
            m_Min.Y       = 10000;

            while ((line = stream.ReadLine()) != null)
            {
                string[] split = Regex.Split(line, @"\s+");
                m_SortedTiles[itemcount].m_ItemID  = Convert.ToUInt16(split[0]);
                m_SortedTiles[itemcount].m_Flags   = Convert.ToInt32(split[1]);
                m_SortedTiles[itemcount].m_OffsetX = Convert.ToInt16(split[2]);
                m_SortedTiles[itemcount].m_OffsetY = Convert.ToInt16(split[3]);
                m_SortedTiles[itemcount].m_OffsetZ = Convert.ToInt16(split[4]);
                m_SortedTiles[itemcount].m_Unk1    = 0;

                MultiTileEntry e = m_SortedTiles[itemcount];

                if (e.m_OffsetX < m_Min.X)
                {
                    m_Min.X = e.m_OffsetX;
                }
                if (e.m_OffsetY < m_Min.Y)
                {
                    m_Min.Y = e.m_OffsetY;
                }
                if (e.m_OffsetX > m_Max.X)
                {
                    m_Max.X = e.m_OffsetX;
                }
                if (e.m_OffsetY > m_Max.Y)
                {
                    m_Max.Y = e.m_OffsetY;
                }
                if (e.m_OffsetZ > m_maxHeight)
                {
                    m_maxHeight = e.m_OffsetZ;
                }

                ++itemcount;
                if (itemcount == count)
                {
                    break;
                }
            }

            int centerx = m_Max.X - (int)(Math.Round((m_Max.X - m_Min.X) / 2.0));
            int centery = m_Max.Y - (int)(Math.Round((m_Max.Y - m_Min.Y) / 2.0));

            m_Min = m_Max = Point.Empty;
            int i = 0;

            for (; i < m_SortedTiles.Length; i++)
            {
                m_SortedTiles[i].m_OffsetX -= (short)centerx;
                m_SortedTiles[i].m_OffsetY -= (short)centery;
                if (m_SortedTiles[i].m_OffsetX < m_Min.X)
                {
                    m_Min.X = m_SortedTiles[i].m_OffsetX;
                }
                if (m_SortedTiles[i].m_OffsetX > m_Max.X)
                {
                    m_Max.X = m_SortedTiles[i].m_OffsetX;
                }

                if (m_SortedTiles[i].m_OffsetY < m_Min.Y)
                {
                    m_Min.Y = m_SortedTiles[i].m_OffsetY;
                }
                if (m_SortedTiles[i].m_OffsetY > m_Max.Y)
                {
                    m_Max.Y = m_SortedTiles[i].m_OffsetY;
                }
            }

            ConvertList();
        }
示例#5
0
		public void AddFixture( Item item, MultiTileEntry mte )
		{
			m_Fixtures.Add( item );
			item.MoveToWorld( new Point3D( X + mte.m_OffsetX, Y + mte.m_OffsetY, Z + mte.m_OffsetZ ), Map );
		}
示例#6
0
		public void AddFixtures( Mobile from, MultiTileEntry[] list )
		{
			if( m_Fixtures == null )
				m_Fixtures = new List<Item>();

			uint keyValue = 0;

			for( int i = 0; i < list.Length; ++i )
			{
				MultiTileEntry mte = list[i];
				int itemID = mte.m_ItemID;

				if( itemID >= 0x181D && itemID < 0x1829 )
				{
					HouseTeleporter tp = new HouseTeleporter( itemID );

					AddFixture( tp, mte );
				}
				else
				{
					BaseDoor door = null;

					if( itemID >= 0x675 && itemID < 0x6F5 )
					{
						int type = (itemID - 0x675) / 16;
						DoorFacing facing = (DoorFacing)(((itemID - 0x675) / 2) % 8);

						switch( type )
						{
							case 0: door = new GenericHouseDoor( facing, 0x675, 0xEC, 0xF3 ); break;
							case 1: door = new GenericHouseDoor( facing, 0x685, 0xEC, 0xF3 ); break;
							case 2: door = new GenericHouseDoor( facing, 0x695, 0xEB, 0xF2 ); break;
							case 3: door = new GenericHouseDoor( facing, 0x6A5, 0xEA, 0xF1 ); break;
							case 4: door = new GenericHouseDoor( facing, 0x6B5, 0xEA, 0xF1 ); break;
							case 5: door = new GenericHouseDoor( facing, 0x6C5, 0xEC, 0xF3 ); break;
							case 6: door = new GenericHouseDoor( facing, 0x6D5, 0xEA, 0xF1 ); break;
							case 7: door = new GenericHouseDoor( facing, 0x6E5, 0xEA, 0xF1 ); break;
						}
					}
					else if( itemID >= 0x314 && itemID < 0x364 )
					{
						int type = (itemID - 0x314) / 16;
						DoorFacing facing = (DoorFacing)(((itemID - 0x314) / 2) % 8);
						door = new GenericHouseDoor( facing, 0x314 + ( type * 16 ), 0xED, 0xF4 );
					}
					else if( itemID >= 0x824 && itemID < 0x834 )
					{
						DoorFacing facing = (DoorFacing)(((itemID - 0x824) / 2) % 8);
						door = new GenericHouseDoor( facing, 0x824, 0xEC, 0xF3 );
					}
					else if( itemID >= 0x839 && itemID < 0x849 )
					{
						DoorFacing facing = (DoorFacing)(((itemID - 0x839) / 2) % 8);
						door = new GenericHouseDoor( facing, 0x839, 0xEB, 0xF2 );
					}
					else if( itemID >= 0x84C && itemID < 0x85C )
					{
						DoorFacing facing = (DoorFacing)(((itemID - 0x84C) / 2) % 8);
						door = new GenericHouseDoor( facing, 0x84C, 0xEC, 0xF3 );
					}
					else if( itemID >= 0x866 && itemID < 0x876 )
					{
						DoorFacing facing = (DoorFacing)(((itemID - 0x866) / 2) % 8);
						door = new GenericHouseDoor( facing, 0x866, 0xEB, 0xF2 );
					}
					else if( itemID >= 0xE8 && itemID < 0xF8 )
					{
						DoorFacing facing = (DoorFacing)(((itemID - 0xE8) / 2) % 8);
						door = new GenericHouseDoor( facing, 0xE8, 0xED, 0xF4 );
					}
					else if( itemID >= 0x1FED && itemID < 0x1FFD )
					{
						DoorFacing facing = (DoorFacing)(((itemID - 0x1FED) / 2) % 8);
						door = new GenericHouseDoor( facing, 0x1FED, 0xEC, 0xF3 );
					}
					else if( itemID >= 0x241F && itemID < 0x2421 )
					{
						//DoorFacing facing = (DoorFacing)(((itemID - 0x241F) / 2) % 8);
						door = new GenericHouseDoor( DoorFacing.NorthCCW, 0x2415, -1, -1 );
					}
					else if( itemID >= 0x2423 && itemID < 0x2425 )
					{
						//DoorFacing facing = (DoorFacing)(((itemID - 0x241F) / 2) % 8);
						//This one and the above one are 'special' cases, ie: OSI had the ItemID pattern discombobulated for these
						door = new GenericHouseDoor( DoorFacing.WestCW, 0x2423, -1, -1 );
					}
					else if( itemID >= 0x2A05 && itemID < 0x2A1D )
					{
						DoorFacing facing = (DoorFacing)((((itemID - 0x2A05) / 2) % 4) + 8);

						int sound = (itemID >= 0x2A0D && itemID < 0x2a15) ? 0x539 : -1;

						door = new GenericHouseDoor( facing, 0x29F5 + (8 * ((itemID - 0x2A05) / 8)), sound, sound );
					}
					else if( itemID == 0x2D46 )
					{
						door = new GenericHouseDoor( DoorFacing.NorthCW, 0x2D46, 0xEA, 0xF1, false );
					}
					else if( itemID == 0x2D48 || itemID == 0x2FE2 )
					{
						door = new GenericHouseDoor( DoorFacing.SouthCCW, itemID, 0xEA, 0xF1, false );
					}
					else if( itemID >= 0x2D63 && itemID < 0x2D70 )
					{
						int mod = (itemID - 0x2D63)/2%2;
						DoorFacing facing = ( ( mod == 0 ) ? DoorFacing.SouthCCW : DoorFacing.WestCCW );

						int type = (itemID - 0x2D63) / 4;

						door = new GenericHouseDoor( facing, 0x2D63 + 4*type + mod*2, 0xEA, 0xF1, false );
					}
					else if( itemID == 0x2FE4 || itemID == 0x31AE )
					{
						door = new GenericHouseDoor( DoorFacing.WestCCW, itemID, 0xEA, 0xF1, false );
					}
					else if( itemID >= 0x319C && itemID < 0x31AE )
					{
						//special case for 0x31aa <-> 0x31a8 (a9)

						int mod = (itemID - 0x319C) / 2 % 2;

						bool specialCase = (itemID == 0x31AA || itemID == 0x31A8);

						DoorFacing facing;

						if ( itemID == 0x31AA || itemID == 0x31A8 )
							facing = ((mod == 0) ? DoorFacing.NorthCW : DoorFacing.EastCW);
						else
							facing = ((mod == 0) ? DoorFacing.EastCW : DoorFacing.NorthCW);

						int type = (itemID - 0x319C) / 4;

						door = new GenericHouseDoor( facing, 0x319C + 4 * type + mod * 2, 0xEA, 0xF1, false );
					}
					else if( itemID >= 0x367B && itemID < 0x369B )
					{
						int type = (itemID - 0x367B) / 16;
						DoorFacing facing = (DoorFacing)(((itemID - 0x367B) / 2) % 8);

						switch( type )
						{
							case 0: door = new GenericHouseDoor( facing, 0x367B, 0xED, 0xF4 ); break;	//crystal
							case 1: door = new GenericHouseDoor( facing, 0x368B, 0xEC, 0x3E7 ); break;	//shadow
						}
					}
					else if( itemID >= 0x409B && itemID < 0x40A3 )
					{
						door = new GenericHouseDoor( GetSADoorFacing( itemID - 0x409B ), itemID, 0xEA, 0xF1, false );
					}
					else if( itemID >= 0x410C && itemID < 0x4114 )
					{
						door = new GenericHouseDoor( GetSADoorFacing( itemID - 0x410C ), itemID, 0xEA, 0xF1, false );
					}
					else if( itemID >= 0x41C2 && itemID < 0x41CA )
					{
						door = new GenericHouseDoor( GetSADoorFacing( itemID - 0x41C2 ), itemID, 0xEA, 0xF1, false );
					}
					else if( itemID >= 0x41CF && itemID < 0x41D7 )
					{
						door = new GenericHouseDoor( GetSADoorFacing( itemID - 0x41CF ), itemID, 0xEA, 0xF1, false );
					}
					else if( itemID >= 0x436E && itemID < 0x437E )
					{
						/* These ones had to be different...
						 * Offset		0	2	4	6	8	10	12	14
						 * DoorFacing	2	3	2	3	6	7	6	7
						 */
						int offset = itemID - 0x436E;
						DoorFacing facing = (DoorFacing)( ( offset / 2 + 2 * ( ( 1 + offset / 4 ) % 2 ) ) % 8 );
						door = new GenericHouseDoor( facing, itemID, 0xEA, 0xF1, false );
					}
					else if( itemID >= 0x46DD && itemID < 0x46E5 )
					{
						door = new GenericHouseDoor( GetSADoorFacing( itemID - 0x46DD ), itemID, 0xEB, 0xF2, false );
					}
					else if( itemID >= 0x4D22 && itemID < 0x4D2A )
					{
						door = new GenericHouseDoor( GetSADoorFacing( itemID - 0x4D22 ), itemID, 0xEA, 0xF1, false );
					}
					else if( itemID >= 0x50C8 && itemID < 0x50D0 )
					{
						door = new GenericHouseDoor( GetSADoorFacing( itemID - 0x50C8 ), itemID, 0xEA, 0xF1, false );
					}
					else if( itemID >= 0x50D0 && itemID < 0x50D8 )
					{
						door = new GenericHouseDoor( GetSADoorFacing( itemID - 0x50D0 ), itemID, 0xEA, 0xF1, false );
					}
					else if( itemID >= 0x5142 && itemID < 0x514A )
					{
						door = new GenericHouseDoor( GetSADoorFacing( itemID - 0x5142 ), itemID, 0xF0, 0xEF, false );
					}

					if( door != null )
					{
						if( keyValue == 0 )
							keyValue = CreateKeys( from );

						door.Locked = true;
						door.KeyValue = keyValue;

						AddDoor( door, mte.m_OffsetX, mte.m_OffsetY, mte.m_OffsetZ );
						m_Fixtures.Add( door );
					}
				}
			}

			for( int i = 0; i < m_Fixtures.Count; ++i )
			{
				Item fixture = m_Fixtures[i];

				if( fixture is HouseTeleporter )
				{
					HouseTeleporter tp = (HouseTeleporter)fixture;

					for( int j = 1; j <= m_Fixtures.Count; ++j )
					{
						HouseTeleporter check = m_Fixtures[(i + j) % m_Fixtures.Count] as HouseTeleporter;

						if( check != null && check.ItemID == tp.ItemID )
						{
							tp.Target = check;
							break;
						}
					}
				}
				else if( fixture is BaseHouseDoor )
				{
					BaseHouseDoor door = (BaseHouseDoor)fixture;

					if( door.Link != null )
						continue;

					DoorFacing linkFacing;
					int xOffset, yOffset;

					switch( door.Facing )
					{
						default:
						case DoorFacing.WestCW: linkFacing = DoorFacing.EastCCW; xOffset = 1; yOffset = 0; break;
						case DoorFacing.EastCCW: linkFacing = DoorFacing.WestCW; xOffset = -1; yOffset = 0; break;
						case DoorFacing.WestCCW: linkFacing = DoorFacing.EastCW; xOffset = 1; yOffset = 0; break;
						case DoorFacing.EastCW: linkFacing = DoorFacing.WestCCW; xOffset = -1; yOffset = 0; break;
						case DoorFacing.SouthCW: linkFacing = DoorFacing.NorthCCW; xOffset = 0; yOffset = -1; break;
						case DoorFacing.NorthCCW: linkFacing = DoorFacing.SouthCW; xOffset = 0; yOffset = 1; break;
						case DoorFacing.SouthCCW: linkFacing = DoorFacing.NorthCW; xOffset = 0; yOffset = -1; break;
						case DoorFacing.NorthCW: linkFacing = DoorFacing.SouthCCW; xOffset = 0; yOffset = 1; break;
						case DoorFacing.SouthSW: linkFacing = DoorFacing.SouthSE; xOffset = 1; yOffset = 0; break;
						case DoorFacing.SouthSE: linkFacing = DoorFacing.SouthSW; xOffset = -1; yOffset = 0; break;
						case DoorFacing.WestSN: linkFacing = DoorFacing.WestSS; xOffset = 0; yOffset = 1; break;
						case DoorFacing.WestSS: linkFacing = DoorFacing.WestSN; xOffset = 0; yOffset = -1; break;
					}

					for( int j = i + 1; j < m_Fixtures.Count; ++j )
					{
						BaseHouseDoor check = m_Fixtures[j] as BaseHouseDoor;

						if( check != null && check.Link == null && check.Facing == linkFacing && (check.X - door.X) == xOffset && (check.Y - door.Y) == yOffset && (check.Z == door.Z) )
						{
							check.Link = door;
							door.Link = check;
							break;
						}
					}
				}
			}
		}
示例#7
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (from == null || m_weapon == null || from.Map == null || m_attachment == null)
                {
                    return;
                }

                if (targeted is StaticTarget)
                {
                    int staticid = ((StaticTarget)targeted).ItemID;
                    int staticx  = ((StaticTarget)targeted).Location.X;
                    int staticy  = ((StaticTarget)targeted).Location.Y;

                    Item    multiitem = null;
                    Point3D tileloc   = Point3D.Zero;

                    // find the possible multi owner of the static tile
                    foreach (Item item in from.Map.GetItemsInRange(((StaticTarget)targeted).Location, 50))
                    {
                        if (item is BaseMulti)
                        {
                            // search the component list for a match
                            MultiComponentList mcl = ((BaseMulti)item).Components;
                            bool found             = false;
                            if (mcl != null && mcl.List != null)
                            {
                                for (int i = 0; i < mcl.List.Length; i++)
                                {
                                    MultiTileEntry t = mcl.List[i];

                                    int x      = t.m_OffsetX + item.X;
                                    int y      = t.m_OffsetY + item.Y;
                                    int z      = t.m_OffsetZ + item.Z;
                                    int itemID = t.m_ItemID & 0x3FFF;

                                    if (itemID == staticid && x == staticx && y == staticy)
                                    {
                                        found   = true;
                                        tileloc = new Point3D(x, y, z);
                                        break;
                                    }
                                }
                            }

                            if (found)
                            {
                                multiitem = item;
                                break;
                            }
                        }
                    }
                    if (multiitem != null)
                    {
                        //Console.WriteLine("attacking {0} at {1}:{2}", multiitem, tileloc, ((StaticTarget)targeted).Location);
                        // may have to reconsider the use tileloc vs target loc
                        //m_cannon.AttackTarget(from, multiitem, ((StaticTarget)targeted).Location);

                        //m_weapon.AttackTarget(from, multiitem, multiitem.Map.GetPoint(targeted, true), m_checklos);


                        m_attachment.BeginAttackTarget(from, multiitem, multiitem.Map.GetPoint(targeted, true));
                    }
                }
                else
                if (targeted is AddonComponent)
                {
                    // if the addon doesnt have an xmlsiege attachment, then attack the addon
                    XmlSiege a = (XmlSiege)XmlAttach.FindAttachment(targeted, typeof(XmlSiege));
                    if (a == null || a.Deleted)
                    {
                        m_attachment.BeginAttackTarget(from, ((AddonComponent)targeted).Addon, ((Item)targeted).Location);
                    }
                    else
                    {
                        m_attachment.BeginAttackTarget(from, (Item)targeted, ((Item)targeted).Location);
                    }
                }
                else
                if (targeted is Item)
                {
                    m_attachment.BeginAttackTarget(from, (Item)targeted, ((Item)targeted).Location);
                }
            }
        public bool OnPlacement(Mobile from, Point3D p)
        {
            if (!from.CheckAlive())
            {
                return(false);
            }

            ArrayList            toMove;
            Point3D              center = new Point3D(p.X - m_Offset.X, p.Y - m_Offset.Y, p.Z - m_Offset.Z);
            HousePlacementResult res    = HousePlacement.Check(from, m_MultiID, center, out toMove);

            switch (res)
            {
            case HousePlacementResult.Valid:
            {
                if (from.AccessLevel < AccessLevel.GameMaster && BaseHouse.HasAccountHouse(from))
                {
                    from.SendLocalizedMessage(501271);                               // You already own a house, you may not place another!
                }
                else
                {
                    from.SendLocalizedMessage(1011576);                               // This is a valid location.

                    PreviewHouse prev = new PreviewHouse(m_MultiID);

                    MultiComponentList mcl = prev.Components;

                    Point3D banLoc = new Point3D(center.X + mcl.Min.X, center.Y + mcl.Max.Y + 1, center.Z);

                    for (int i = 0; i < mcl.List.Length; ++i)
                    {
                        MultiTileEntry entry = mcl.List[i];

                        int itemID = entry.m_ItemID & 0x3FFF;

                        if (itemID >= 0xBA3 && itemID <= 0xC0E)
                        {
                            banLoc = new Point3D(center.X + entry.m_OffsetX, center.Y + entry.m_OffsetY, center.Z);
                            break;
                        }
                    }

                    for (int i = 0; i < toMove.Count; ++i)
                    {
                        object o = toMove[i];

                        if (o is Mobile)
                        {
                            ((Mobile)o).Location = banLoc;
                        }
                        else if (o is Item)
                        {
                            ((Item)o).Location = banLoc;
                        }
                    }

                    prev.MoveToWorld(center, from.Map);

                    /* You are about to place a new house.
                     * Placing this house will condemn any and all of your other houses that you may have.
                     * All of your houses on all shards will be affected.
                     *
                     * In addition, you will not be able to place another house or have one transferred to you for one (1) real-life week.
                     *
                     * Once you accept these terms, these effects cannot be reversed.
                     * Re-deeding or transferring your new house will not uncondemn your other house(s) nor will the one week timer be removed.
                     *
                     * If you are absolutely certain you wish to proceed, click the button next to OKAY below.
                     * If you do not wish to trade for this house, click CANCEL.
                     */
                    from.SendGump(new WarningGump(1060635, 30720, 1049583, 32512, 420, 280, new WarningGumpCallback(PlacementWarning_Callback), prev));

                    return(true);
                }

                break;
            }

            case HousePlacementResult.BadItem:
            case HousePlacementResult.BadLand:
            case HousePlacementResult.BadStatic:
            case HousePlacementResult.BadRegionHidden:
            case HousePlacementResult.NoSurface:
            {
                from.SendLocalizedMessage(1043287);                           // The house could not be created here.  Either something is blocking the house, or the house would not be on valid terrain.
                break;
            }

            case HousePlacementResult.BadRegion:
            {
                from.SendLocalizedMessage(501265);                           // Housing cannot be created in this area.
                break;
            }
            }

            return(false);
        }
示例#9
0
 public void AddFixture(Item item, MultiTileEntry mte)
 {
     this.m_Fixtures.Add(item);
     item.MoveToWorld(new Point3D(this.X + mte.m_OffsetX, this.Y + mte.m_OffsetY, this.Z + mte.m_OffsetZ), this.Map);
 }
示例#10
0
文件: Multis.cs 项目: Crwth/UltimaXNA
        public MultiComponentList(BinaryReader reader, int count)
        {
            int streamStart = (int)reader.BaseStream.Position;

            m_Min = m_Max = Point.Empty;

            MultiTileEntry[] allTiles = new MultiTileEntry[count];

            for (int i = 0; i < count; ++i)
            {
                allTiles[i].m_ItemID = reader.ReadInt16();
                allTiles[i].m_OffsetX = reader.ReadInt16();
                allTiles[i].m_OffsetY = reader.ReadInt16();
                allTiles[i].m_OffsetZ = reader.ReadInt16();
                allTiles[i].m_Flags = reader.ReadInt32();

                MultiTileEntry e = allTiles[i];

                if (e.m_OffsetX < m_Min.X)
                    m_Min.X = e.m_OffsetX;

                if (e.m_OffsetY < m_Min.Y)
                    m_Min.Y = e.m_OffsetY;

                if (e.m_OffsetX > m_Max.X)
                    m_Max.X = e.m_OffsetX;

                if (e.m_OffsetY > m_Max.Y)
                    m_Max.Y = e.m_OffsetY;
            }

            m_Center = new Point(-m_Min.X, -m_Min.Y);
            m_Width = (m_Max.X - m_Min.X) + 1;
            m_Height = (m_Max.Y - m_Min.Y) + 1;

            StaticTileList[][] tiles = new StaticTileList[m_Width][];
            m_Tiles = new StaticTile[m_Width][][];

            for (int x = 0; x < m_Width; ++x)
            {
                tiles[x] = new StaticTileList[m_Height];
                m_Tiles[x] = new StaticTile[m_Height][];

                for (int y = 0; y < m_Height; ++y)
                    tiles[x][y] = new StaticTileList();
            }

            for (int i = 0; i < allTiles.Length; ++i)
            {
                int xOffset = allTiles[i].m_OffsetX + m_Center.X;
                int yOffset = allTiles[i].m_OffsetY + m_Center.Y;

                tiles[xOffset][yOffset].Add((short)((allTiles[i].m_ItemID & 0x3FFF) + 0x4000), (sbyte)allTiles[i].m_OffsetZ);
            }

            for (int x = 0; x < m_Width; ++x)
            {
                for (int y = 0; y < m_Height; ++y)
                {
                    m_Tiles[x][y] = tiles[x][y].ToArray();
                    //
                    // This is unnecessary, since TileEngine has to sort/resort anyways.
                    //
                    // if (m_Tiles[x][y].Length > 1)
                    // {
                    //     Array.Sort(m_Tiles[x][y]);
                    // }
                }
            }

            ClientVars.Metrics.ReportDataRead((int)reader.BaseStream.Position - streamStart);
        }
        public static void CreateBuilding(Mobile from, Map map, Point3D start, Point3D end, object state)
        {
            DateTime started = DateTime.Now;
            from.SendMessage("Building Creation Started:");

            object[] objarr = (object[])state;
            string name = (string)objarr[0];
            bool scriptbased = (bool)objarr[1];
            bool staticsonly = (bool)objarr[2];
            end = new Point3D(end.X + 1, end.Y + 1, end.Z);
            List<Item> staticlist = new List<Item>();
            IPooledEnumerable itemlist = map.GetItemsInBounds(new Rectangle2D(start, end));

            int lowx = end.X;
            int lowy = end.Y;
            int highx = start.X;
            int highy = start.Y;
            int lowz = 150;

            foreach (Item item in itemlist)
            {
                if (!staticsonly || item is Static)
                {
                    staticlist.Add(item);
                    lowx = Math.Min(lowx, item.Location.X);
                    lowy = Math.Min(lowy, item.Location.Y);
                    lowz = Math.Min(lowz, item.Location.Z);
                    highx = Math.Max(highx, item.Location.X);
                    highy = Math.Max(highy, item.Location.Y);
                }
            }

            int totparts = 0;

            if (staticlist.Count != 0)
            {
                lowz -= 51;// was 9
                int totwidth = Math.Max(highx - lowx, 1);
                int totheight = Math.Max(highy - lowy, 1);
                int tothorparts = (int)Math.Ceiling((double)(totwidth / 18.0));
                int totvertparts = (int)Math.Ceiling((double)(totheight / 19.0));
                totparts = tothorparts * totvertparts;

                MultiTileEntry[][][] dataarray = new MultiTileEntry[tothorparts][][];
                bool[][] issmallarray = new bool[tothorparts][];

                for (int i = 0; i < tothorparts; i++)
                {
                    dataarray[i] = new MultiTileEntry[totvertparts][];
                    issmallarray[i] = new bool[totvertparts];
                }

                for (int i = 0; i < tothorparts; i++)
                {
                    for (int j = 0; j < totvertparts; j++)
                    {
                        List<MultiTileEntry> partlist = new List<MultiTileEntry>();
                        int lowpartx = 100;
                        int lowparty = 100;
                        int highpartx = -100;
                        int highparty = -100;

                        int minx = lowx + (i * 18);
                        int miny = lowy + (j * 19);
                        int maxx = minx + 18;
                        int maxy = miny + 19;
                        int centerx = minx + 8;
                        int centery = miny + 8;

                        if (totwidth < 18 && totheight < 19)
                        {
                            centerx = minx + (totwidth / 2);
                            centery = miny + (totheight / 2);
                        }

                        foreach (Item stat in staticlist)
                        {
                            Point3D loc = stat.Location;

                            if (loc.X >= minx && loc.X < maxx && loc.Y >= miny && loc.Y < maxy)
                            {
                                short x = (short)(stat.X - centerx);
                                short y = (short)(stat.Y - centery);
                                short z = (short)(stat.Z - lowz);
                                partlist.Add(new MultiTileEntry((short)stat.ItemID, x, y, z, 1));

                                lowpartx = Math.Min(lowpartx, x);
                                lowparty = Math.Min(lowparty, y);
                                highpartx = Math.Max(highpartx, x);
                                highparty = Math.Max(highparty, y);
                            }
                        }

                        dataarray[i][j] = partlist.ToArray();
                        issmallarray[i][j] = ((highpartx - lowpartx) < 16) && ((highparty - lowparty) < 16);
                    }
                }
                itemlist.Free();

                Point2D min = new Point2D(-8, -8);
                Point2D max = new Point2D(9, 10);
                Point2D center = new Point2D(8, 8);
                string classname = "Server.Multis." + name;

                if (dataarray.Length == 1 && dataarray[0].Length == 1)
                {
                    if (scriptbased)
                    {
                        string output = Templates.SBBTemplate.Replace("{name}", name);
                        output = output.Replace("{namen}", String.Format("\"{0}\"", name));
                        output = output.Replace("{addtiles}", GetTileString(dataarray[0][0]));
                        output = output.Replace("{updaterange}", issmallarray[0][0]? "18" : "22");
                        WriteScript(name, output);
                    }
                    else
                        FileBasedBuilding.BuildingTable[name] = new BuildingEntry(0, GetComponentList(dataarray[0][0]), issmallarray[0][0]);
                }

                else
                {
                    if (!scriptbased)
                        for (int i = 1; i < totparts; i++)
                        {
                            string countedname = name +"_"+ i;

                            if (FileBasedBuilding.BuildingTable.ContainsKey(name))
                            {
                                from.SendMessage("One of the names would conflict with an existing building, please choose a different name or remove the existing type.");
                                return;
                            }
                        }

                    int number = 1;
                    List<string> stringlist = new List<string>();
                    System.Text.StringBuilder components = new System.Text.StringBuilder();

                    for (int x = 0; x < dataarray.Length; x++)
                    {
                        for (int y = 0; y < dataarray[x].Length; y++)
                        {
                            if (x == 0 && y == 0)
                                continue;

                            else
                            {
                                string countedname = name + "_" + number;

                                if (scriptbased)
                                {
                                    components.AppendFormat("\n			AddComponent( new {0}(), {1}, {2});", countedname, x * 18, y * 19);

                                    string output = Templates.SBBATemplate.Replace("{name}", countedname);
                                    output = output.Replace("{namen}", String.Format("\"{0}\"", countedname));
                                    output = output.Replace("{addtiles}", GetTileString(dataarray[x][y]));
                                    output = output.Replace("{updaterange}", issmallarray[x][y] ? "18" : "22");

                                    WriteScript(countedname, output);
                                }

                                else
                                {
                                    stringlist.Add(countedname);
                                    FileBasedBuilding.BuildingTable[countedname] = new ComponentEntry(GetComponentList(dataarray[x][y]), issmallarray[x][y], x * 18, y * 19);
                                }

                                number++;
                            }
                        }
                    }

                    if (scriptbased)
                    {
                        string output = Templates.SBABTemplate.Replace("{name}", name);
                        output = output.Replace("{namen}", String.Format("\"{0}\"", name));
                        output = output.Replace("{addcomponents}", components.ToString());
                        output = output.Replace("{addtiles}", GetTileString(dataarray[0][0]));
                        output = output.Replace("{updaterange}", issmallarray[0][0] ? "18" : "22");

                        WriteScript(name, output);
                    }

                    else
                        FileBasedBuilding.BuildingTable[name] = new AddonEntry(GetComponentList(dataarray[0][0]), stringlist,issmallarray[0][0]);
                }
                if (!scriptbased)
                    FileBasedBuilding.SeperateData.Save();
            }

            TimeSpan duration = DateTime.Now - started;
            from.SendMessage("A total of {0} buildings have been created", totparts);
            from.SendMessage("The proces took {0} seconds", duration.TotalSeconds);
            from.SendMessage("Building Creation Ended");
        }
        private static string GetTileString(MultiTileEntry[] array)
        {
            System.Text.StringBuilder tiles = new System.Text.StringBuilder();
            foreach (MultiTileEntry entry in array)
                tiles.AppendFormat("\n			m_Components.Add({0}, {1}, {2}, {3});", entry.m_ItemID, entry.m_OffsetX, entry.m_OffsetY, entry.m_OffsetZ);

            return tiles.ToString();
        }
        private static MultiComponentList GetComponentList(MultiTileEntry[] array)
        {
            MultiComponentList mcl = new MultiComponentList(BaseBuilding.EmptyList);
            foreach (MultiTileEntry entry in array)
                mcl.Add(entry.m_ItemID, entry.m_OffsetX, entry.m_OffsetY, entry.m_OffsetZ);

            return mcl;
        }
示例#14
0
        public bool OnPlacement(Mobile from, Point3D p)
        {
            if (!from.CheckAlive() || from.Backpack == null || from.Backpack.FindItemByType(typeof(HousePlacementTool)) == null)
            {
                return(false);
            }

            ArrayList            toMove;
            Point3D              center = new Point3D(p.X - m_Offset.X, p.Y - m_Offset.Y, p.Z - m_Offset.Z);
            HousePlacementResult res    = HousePlacement.Check(from, m_MultiID, center, out toMove);

            switch (res)
            {
            case HousePlacementResult.Valid:
            {
                from.SendLocalizedMessage(1011576);         // This is a valid location.

                PreviewHouse prev = new PreviewHouse(m_MultiID);

                MultiComponentList mcl = prev.Components;

                Point3D banLoc = new Point3D(center.X + mcl.Min.X, center.Y + mcl.Max.Y + 1, center.Z);

                for (int i = 0; i < mcl.List.Length; ++i)
                {
                    MultiTileEntry entry = mcl.List[i];

                    int itemID = entry.m_ItemID;

                    if (itemID >= 0xBA3 && itemID <= 0xC0E)
                    {
                        banLoc = new Point3D(center.X + entry.m_OffsetX, center.Y + entry.m_OffsetY, center.Z);
                        break;
                    }
                }

                for (int i = 0; i < toMove.Count; ++i)
                {
                    object o = toMove[i];

                    if (o is Mobile)
                    {
                        ((Mobile)o).Location = banLoc;
                    }
                    else if (o is Item)
                    {
                        ((Item)o).Location = banLoc;
                    }
                }

                prev.MoveToWorld(center, from.Map);

                /* You are about to place a new house.
                 * Placing this house will condemn any and all of your other houses that you may have.
                 * All of your houses on all shards will be affected.
                 *
                 * In addition, you will not be able to place another house or have one transferred to you for one (1) real-life week.
                 *
                 * Once you accept these terms, these effects cannot be reversed.
                 * Re-deeding or transferring your new house will not uncondemn your other house(s) nor will the one week timer be removed.
                 *
                 * If you are absolutely certain you wish to proceed, click the button next to OKAY below.
                 * If you do not wish to trade for this house, click CANCEL.
                 */
                from.SendGump(new WarningGump(1060635, 30720, 1049583, 32512, 420, 280, new WarningGumpCallback(PlacementWarning_Callback), prev));

                return(true);
            }

            case HousePlacementResult.BadItem:
            case HousePlacementResult.BadLand:
            case HousePlacementResult.BadStatic:
            case HousePlacementResult.BadRegionHidden:
            case HousePlacementResult.NoSurface:
            {
                from.SendLocalizedMessage(1043287);         // The house could not be created here.  Either something is blocking the house, or the house would not be on valid terrain.
                break;
            }

            case HousePlacementResult.BadRegion:
            {
                from.SendLocalizedMessage(501265);         // Housing cannot be created in this area.
                break;
            }

            case HousePlacementResult.BadRegionTemp:
            {
                from.SendLocalizedMessage(501270);         //Lord British has decreed a 'no build' period, thus you cannot build this house at this time.
                break;
            }

            case HousePlacementResult.BadRegionRaffle:
            {
                from.SendLocalizedMessage(1150493);         // You must have a deed for this plot of land in order to build here.
                break;
            }

            case HousePlacementResult.InvalidCastleKeep:
            {
                from.SendLocalizedMessage(1061122);         // Castles and keeps cannot be created here.
                break;
            }

            case HousePlacementResult.NoQueenLoyalty:
            {
                from.SendLocalizedMessage(1113707, "10000");         // You must have at lease ~1_MIN~ loyalty to the Gargoyle Queen to place a house in Ter Mur.
                break;
            }
            }

            return(false);
        }
示例#15
0
        private void AdjustMobileLocations()
        {
            Item targetitem = AttachedTo as Item;

            if (targetitem == null)
            {
                return;
            }

            // make sure nearby mobiles are in valid locations
            ArrayList mobilelist = new ArrayList();

            foreach (Mobile p in targetitem.GetMobilesInRange(0))
            {
                mobilelist.Add(p);
            }

            if (targetitem is BaseAddon)
            {
                BaseAddon addon = (BaseAddon)targetitem;
                if (addon.Components != null)
                {
                    foreach (AddonComponent i in addon.Components)
                    {
                        if (i != null)
                        {
                            foreach (Mobile p in i.GetMobilesInRange(0))
                            {
                                if (!mobilelist.Contains(p))
                                {
                                    mobilelist.Add(p);
                                }
                            }
                        }
                    }
                }
            }

            if (targetitem is BaseMulti && targetitem.Map != null)
            {
                // check all locations covered by the multi
                // go through all of the multi components
                MultiComponentList mcl = ((BaseMulti)targetitem).Components;

                if (mcl != null && mcl.List != null)
                {
                    for (int i = 0; i < mcl.List.Length; i++)
                    {
                        MultiTileEntry t = mcl.List[i];

                        int x = t.m_OffsetX + targetitem.X;
                        int y = t.m_OffsetY + targetitem.Y;
                        int z = t.m_OffsetZ + targetitem.Z;
                        foreach (Mobile p in targetitem.Map.GetMobilesInRange(new Point3D(x, y, z), 0))
                        {
                            if (!mobilelist.Contains(p))
                            {
                                mobilelist.Add(p);
                            }
                        }
                    }
                }
            }

            // relocate all mobiles found
            foreach (Mobile p in mobilelist)
            {
                if (p != null && p.Map != null)
                {
                    int x = p.Location.X;
                    int y = p.Location.Y;
                    int z = p.Location.Z;

                    // check the current location
                    if (!p.Map.CanFit(x, y, z, 16, true, false, true))
                    {
                        bool found = false;


                        for (int dx = 0; dx <= 10 && !found; dx++)
                        {
                            for (int dy = 0; dy <= 10 && !found; dy++)
                            {
                                // try moving it up in z to find a valid spot
                                for (int h = 1; h <= 39; h++)
                                {
                                    if (p.Map.CanFit(x + dx, y + dy, z + h, 16, true, false, true))
                                    {
                                        z    += h;
                                        x    += dx;
                                        y    += dy;
                                        found = true;
                                        break;
                                    }
                                }
                            }
                        }
                    }

                    // move them to the new location
                    p.MoveToWorld(new Point3D(x, y, z), p.Map);
                }
            }
        }
示例#16
0
        public virtual void AutoAddFixtures()
        {
            MultiComponentList components = MultiData.GetComponents(ItemID);

            Dictionary <int, List <MultiTileEntry> > teleporters = new Dictionary <int, List <MultiTileEntry> >();

            for (var index = 0; index < components.List.Length; index++)
            {
                MultiTileEntry entry = components.List[index];

                if (entry.m_Flags == 0)
                {
                    // Telepoters
                    if (entry.m_ItemID >= 0x181D && entry.m_ItemID <= 0x1828)
                    {
                        if (teleporters.ContainsKey(entry.m_ItemID))
                        {
                            teleporters[entry.m_ItemID].Add(entry);
                        }
                        else
                        {
                            teleporters[entry.m_ItemID] = new List <MultiTileEntry>();
                            teleporters[entry.m_ItemID].Add(entry);
                        }
                    }
                    else
                    {
                        ItemData data = TileData.ItemTable[entry.m_ItemID & TileData.MaxItemValue];

                        // door
                        if ((data.Flags & TileFlag.Door) != 0)
                        {
                            AddDoor(entry.m_ItemID, entry.m_OffsetX, entry.m_OffsetY, entry.m_OffsetZ);
                        }
                        else
                        {
                            Item st = new Static((int)entry.m_ItemID);

                            st.MoveToWorld(new Point3D(X + entry.m_OffsetX, Y + entry.m_OffsetY, entry.m_OffsetZ), Map);
                            AddFixture(st);
                        }
                    }
                }
            }

            for (var index = 0; index < Doors.Count; index++)
            {
                Item item = Doors[index];

                if (item is BaseDoor door)
                {
                    for (var i = 0; i < Doors.Count; i++)
                    {
                        Item houseDoor = Doors[i];

                        if (houseDoor is BaseDoor check && check != door && door.InRange(check.Location, 1))
                        {
                            door.Link  = check;
                            check.Link = door;
                        }
                    }
                }
            }

            foreach (KeyValuePair <int, List <MultiTileEntry> > kvp in teleporters)
            {
                if (kvp.Value.Count > 2)
                {
                    Utility.WriteConsoleColor(ConsoleColor.Yellow, string.Format("Warning: More than 2 teleporters detected for {0:X}!", kvp.Key));
                }
                else if (kvp.Value.Count <= 1)
                {
                    Utility.WriteConsoleColor(ConsoleColor.Yellow, string.Format("Warning: 1 or less teleporters detected for {0:X}!", kvp.Key));

                    continue;
                }

                AddTeleporters(kvp.Key, new Point3D(kvp.Value[0].m_OffsetX, kvp.Value[0].m_OffsetY, kvp.Value[0].m_OffsetZ), new Point3D(kvp.Value[1].m_OffsetX, kvp.Value[1].m_OffsetY, kvp.Value[1].m_OffsetZ));
            }

            teleporters.Clear();
        }
示例#17
0
        private static void DefineMultiArea_Callback(Mobile from, Map map, Point3D start, Point3D end, object state)
        {
            object[] multiargs = (object[])state;

            if (from != null && multiargs != null && map != null)
            {
                string dirname          = (string)multiargs[0];
                int    zmin             = (int)multiargs[1];
                int    zmax             = (int)multiargs[2];
                bool   includeitems     = true;
                bool   includestatics   = true;
                bool   includeinvisible = true;
                bool   includemultis    = true;

                ArrayList itemlist   = new ArrayList();
                ArrayList staticlist = new ArrayList();
                ArrayList tilelist   = new ArrayList();

                int sx = (start.X > end.X) ? end.X : start.X;
                int sy = (start.Y > end.Y) ? end.Y : start.Y;
                int ex = (start.X < end.X) ? end.X : start.X;
                int ey = (start.Y < end.Y) ? end.Y : start.Y;

                if (includeitems)
                {
                    IPooledEnumerable eable = map.GetItemsInBounds(new Rectangle2D(sx, sy, ex - sx + 1, ey - sy + 1));

                    foreach (Item item in eable)
                    {
                        if (item.Parent == null && (zmin == int.MinValue || (item.Location.Z >= zmin && item.Location.Z <= zmax)))
                        {
                            if ((includeinvisible || item.Visible) && (item.ItemID <= 65535))
                            {
                                itemlist.Add(item);
                            }
                        }
                    }
                    eable.Free();

                    int searchrange = 100;

                    eable = map.GetItemsInBounds(new Rectangle2D(sx - searchrange, sy - searchrange, ex - sy + searchrange * 2 + 1, ey - sy + searchrange * 2 + 1));

                    foreach (Item item in eable)
                    {
                        if (item.Parent == null)
                        {
                            if (item is BaseMulti && includemultis)
                            {
                                MultiComponentList mcl = ((BaseMulti)item).Components;
                                if (mcl != null && mcl.List != null)
                                {
                                    for (int i = 0; i < mcl.List.Length; i++)
                                    {
                                        MultiTileEntry t = mcl.List[i];

                                        int x      = t.m_OffsetX + item.X;
                                        int y      = t.m_OffsetY + item.Y;
                                        int z      = t.m_OffsetZ + item.Z;
                                        int itemID = t.m_ItemID & 0xFFFF;

                                        if (x >= sx && x <= ex && y >= sy && y <= ey && (zmin == int.MinValue || (z >= zmin && z <= zmax)))
                                        {
                                            tilelist.Add(new TileEntry(itemID, x, y, z));
                                        }
                                    }
                                }
                            }
                        }
                    }
                    eable.Free();
                }

                if (includestatics)
                {
                    for (int x = sx; x < ex; x++)
                    {
                        for (int y = sy; y < ey; y++)
                        {
                            StaticTile[] statics = map.Tiles.GetStaticTiles(x, y, false);

                            for (int j = 0; j < statics.Length; j++)
                            {
                                if ((zmin == int.MinValue || (statics[j].Z >= zmin && statics[j].Z <= zmax)))
                                {
                                    staticlist.Add(new TileEntry(statics[j].ID & 0xFFFF, x, y, statics[j].Z));
                                }
                            }
                        }
                    }
                }

                int nstatics = staticlist.Count;
                int nitems   = itemlist.Count;
                int ntiles   = tilelist.Count;

                int ntotal = nitems + nstatics + ntiles;

                int ninvisible = 0;
                int nmultis    = ntiles;

                foreach (Item item in itemlist)
                {
                    int x = item.X - from.X;
                    int y = item.Y - from.Y;
                    int z = item.Z - from.Z;

                    if (item.ItemID > 65535)
                    {
                        nmultis++;
                    }
                    if (!item.Visible)
                    {
                        ninvisible++;
                    }
                }

                try
                {
                    StreamWriter  op = new StreamWriter(dirname, false);
                    StringBuilder sb = new StringBuilder();

                    string convertString = "#:" + dirname + ":";
                    sb.Append(convertString);

                    if (sb != null)
                    {
                        op.WriteLine("1 version {0}", from.Name);
                        convertString = ("1 version " + from.Name + "?");
                        sb.Append(convertString);

                        op.WriteLine("{0} num components", ntotal);
                        convertString = (ntotal + " num components?");
                        sb.Append(convertString);

                        foreach (Item item in itemlist)
                        {
                            int x   = item.X - from.X;
                            int y   = item.Y - from.Y;
                            int z   = item.Z - from.Z;
                            int Vis = item.Visible ? 1 : 0;

                            if (item.Hue > 0)
                            {
                                op.WriteLine("{0} {1} {2} {3} {4} {5}", item.ItemID, x, y, z, item.Visible ? 1 : 0, item.Hue);
                                convertString = (item.ItemID + " " + x + " " + y + " " + z + " " + Vis + " " + item.Hue + "?");
                                sb.Append(convertString);
                            }
                            else
                            {
                                op.WriteLine("{0} {1} {2} {3} {4}", item.ItemID, x, y, z, item.Visible ? 1 : 0);
                                convertString = (item.ItemID + " " + x + " " + y + " " + z + " " + Vis + "?");
                                sb.Append(convertString);
                            }
                        }

                        if (includestatics)
                        {
                            foreach (TileEntry s in staticlist)
                            {
                                int x  = s.X - from.X;
                                int y  = s.Y - from.Y;
                                int z  = s.Z - from.Z;
                                int ID = s.ID;
                                op.WriteLine("{0} {1} {2} {3} {4}", ID, x, y, z, 1);
                                convertString = (ID + " " + x + " " + y + " " + z + " " + "1" + "?");
                                sb.Append(convertString);
                            }
                        }

                        if (includemultis)
                        {
                            foreach (TileEntry s in tilelist)
                            {
                                int x  = s.X - from.X;
                                int y  = s.Y - from.Y;
                                int z  = s.Z - from.Z;
                                int ID = s.ID;
                                op.WriteLine("{0} {1} {2} {3} {4}", ID, x, y, z, 1);
                                convertString = (ID + " " + x + " " + y + " " + z + " " + "1" + "?");
                                sb.Append(convertString);
                            }
                        }
                    }
                    op.Close();
                    //BlackBoxSender.SendBBCMD(sb.ToString(), from); //TODO: Return copy to Black Box
                }
                catch
                {
                    from.SendMessage("Error writing multi file {0}", dirname);
                    return;
                }
                from.SendMessage(66, "UO Black Box - UO Builder Results:");
                from.SendMessage(66, "Included {0} items", nitems);
                from.SendMessage(66, "{0} multis", nmultis);
                from.SendMessage(66, "{0} invisible", ninvisible);
                from.SendMessage(66, "Included {0} statics", nstatics);
                from.SendMessage(66, "File Saved!");
            }
        }
示例#18
0
        private static void DefineMultiArea_Callback(Mobile from, Map map, Point3D start, Point3D end, object state)
        {
            object[] multiargs = (object[])state;

            if (from != null && multiargs != null && map != null)
            {
                string dirname          = (string)multiargs[0];
                int    zmin             = (int)multiargs[1];
                int    zmax             = (int)multiargs[2];
                bool   includeitems     = (bool)multiargs[3];
                bool   includestatics   = (bool)multiargs[4];
                bool   includemultis    = (bool)multiargs[5];
                bool   includeinvisible = (bool)multiargs[6];
                bool   includeaddons    = (bool)multiargs[7];

                ArrayList itemlist   = new ArrayList();
                ArrayList staticlist = new ArrayList();
                ArrayList tilelist   = new ArrayList();

                int sx = (start.X > end.X) ? end.X : start.X;
                int sy = (start.Y > end.Y) ? end.Y : start.Y;
                int ex = (start.X < end.X) ? end.X : start.X;
                int ey = (start.Y < end.Y) ? end.Y : start.Y;

                // find all of the world-placed items within the specified area
                if (includeitems)
                {
                    // make the first pass for items only
                    IPooledEnumerable eable = map.GetItemsInBounds(new Rectangle2D(sx, sy, ex - sx + 1, ey - sy + 1));

                    foreach (Item item in eable)
                    {
                        // is it within the bounding area
                        if (item.Parent == null && (zmin == int.MinValue || (item.Location.Z >= zmin && item.Location.Z <= zmax)))
                        {
                            // add the item
                            if ((includeinvisible || item.Visible) && (item.ItemID <= MaxItemId))
                            {
                                itemlist.Add(item);
                            }
                        }
                    }

                    eable.Free();

                    int searchrange = 100;

                    // make the second expanded pass to pick up addon components and multi components
                    eable = map.GetItemsInBounds(new Rectangle2D(sx - searchrange, sy - searchrange, ex - sy + searchrange * 2 + 1,
                                                                 ey - sy + searchrange * 2 + 1));

                    foreach (Item item in eable)
                    {
                        // is it within the bounding area
                        if (item.Parent == null)
                        {
                            if (item is BaseAddon && includeaddons)
                            {
                                // go through all of the addon components
                                foreach (AddonComponent c in ((BaseAddon)item).Components)
                                {
                                    int x = c.X;
                                    int y = c.Y;
                                    int z = c.Z;

                                    if ((includeinvisible || item.Visible) && (item.ItemID <= MaxItemId || includemultis) &&
                                        (x >= sx && x <= ex && y >= sy && y <= ey && (zmin == int.MinValue || (z >= zmin && z <= zmax))))
                                    {
                                        itemlist.Add(c);
                                    }
                                }
                            }

                            if (item is BaseMulti && includemultis)
                            {
                                // go through all of the multi components
                                MultiComponentList mcl = ((BaseMulti)item).Components;
                                if (mcl != null && mcl.List != null)
                                {
                                    for (int i = 0; i < mcl.List.Length; i++)
                                    {
                                        MultiTileEntry t = mcl.List[i];

                                        int x      = t.m_OffsetX + item.X;
                                        int y      = t.m_OffsetY + item.Y;
                                        int z      = t.m_OffsetZ + item.Z;
                                        int itemID = t.m_ItemID & 0x3FFF;

                                        if (x >= sx && x <= ex && y >= sy && y <= ey && (zmin == int.MinValue || (z >= zmin && z <= zmax)))
                                        {
                                            tilelist.Add(new TileEntry(itemID, x, y, z));
                                        }
                                    }
                                }
                            }
                        }
                    }

                    eable.Free();
                }

                // find all of the static tiles within the specified area
                if (includestatics)
                {
                    // count the statics
                    for (int x = sx; x < ex; x++)
                    {
                        for (int y = sy; y < ey; y++)
                        {
                            StaticTile[] statics = map.Tiles.GetStaticTiles(x, y, false);

                            for (int j = 0; j < statics.Length; j++)
                            {
                                if ((zmin == int.MinValue || (statics[j].Z >= zmin && statics[j].Z <= zmax)))
                                {
                                    staticlist.Add(new TileEntry(statics[j].ID & 0x3FFF, x, y, statics[j].Z));
                                }
                            }
                        }
                    }
                }

                int nstatics = staticlist.Count;
                int nitems   = itemlist.Count;
                int ntiles   = tilelist.Count;

                int ntotal = nitems + nstatics + ntiles;

                int ninvisible = 0;
                int nmultis    = ntiles;
                int naddons    = 0;

                foreach (Item item in itemlist)
                {
                    int x = item.X - from.X;
                    int y = item.Y - from.Y;
                    int z = item.Z - from.Z;

                    if (item.ItemID > 16383)
                    {
                        nmultis++;
                    }
                    if (!item.Visible)
                    {
                        ninvisible++;
                    }
                    if (item is BaseAddon || item is AddonComponent)
                    {
                        naddons++;
                    }
                }

                try
                {
                    // open the file, overwrite any previous contents
                    StreamWriter op = new StreamWriter(dirname, false);

                    if (op != null)
                    {
                        // write the header
                        op.WriteLine("1 version {0}", from.Name);
                        op.WriteLine("{0} num components", ntotal);

                        // write out the items
                        foreach (Item item in itemlist)
                        {
                            int x = item.X - from.X;
                            int y = item.Y - from.Y;
                            int z = item.Z - from.Z;

                            if (item.Hue > 0)
                            {
                                // format is x y z visible hue
                                op.WriteLine("{0} {1} {2} {3} {4} {5}", item.ItemID, x, y, z, item.Visible ? 1 : 0, item.Hue);
                            }
                            else
                            {
                                // format is x y z visible
                                op.WriteLine("{0} {1} {2} {3} {4}", item.ItemID, x, y, z, item.Visible ? 1 : 0);
                            }
                        }

                        if (includestatics)
                        {
                            foreach (TileEntry s in staticlist)
                            {
                                int x  = s.X - from.X;
                                int y  = s.Y - from.Y;
                                int z  = s.Z - from.Z;
                                int ID = s.ID;
                                op.WriteLine("{0} {1} {2} {3} {4}", ID, x, y, z, 1);
                            }
                        }

                        if (includemultis)
                        {
                            foreach (TileEntry s in tilelist)
                            {
                                int x  = s.X - from.X;
                                int y  = s.Y - from.Y;
                                int z  = s.Z - from.Z;
                                int ID = s.ID;
                                op.WriteLine("{0} {1} {2} {3} {4}", ID, x, y, z, 1);
                            }
                        }
                    }

                    op.Close();
                }
                catch
                {
                    from.SendMessage("Error writing multi file {0}", dirname);
                    return;
                }

                from.SendMessage(66, "WriteMulti results:");

                if (includeitems)
                {
                    from.SendMessage(66, "Included {0} items", nitems);

                    if (includemultis)
                    {
                        from.SendMessage("{0} multis", nmultis);
                    }
                    else
                    {
                        from.SendMessage(33, "Ignored multis");
                    }

                    if (includeinvisible)
                    {
                        from.SendMessage("{0} invisible", ninvisible);
                    }
                    else
                    {
                        from.SendMessage(33, "Ignored invisible");
                    }

                    if (includeaddons)
                    {
                        from.SendMessage("{0} addons", naddons);
                    }
                    else
                    {
                        from.SendMessage(33, "Ignored addons");
                    }
                }
                else
                {
                    from.SendMessage(33, "Ignored items");
                }

                if (includestatics)
                {
                    from.SendMessage(66, "Included {0} statics", nstatics);
                }
                else
                {
                    from.SendMessage(33, "Ignored statics");
                }

                from.SendMessage(66, "Saved {0} components to {1}", ntotal, dirname);
            }
        }
示例#19
0
        public MultiComponentList(string FileName, Multis.ImportType Type)
        {
            m_Min = m_Max = Point.Empty;
            int itemcount;
            switch (Type)
            {
                case Multis.ImportType.TXT:
                    itemcount = 0;
                    using (StreamReader ip = new StreamReader(FileName))
                    {
                        string line;
                        while ((line = ip.ReadLine()) != null)
                        {
                            itemcount++;
                        }
                    }
                    m_SortedTiles = new MultiTileEntry[itemcount];
                    itemcount = 0;
                    m_Min.X = 10000;
                    m_Min.Y = 10000;
                    using (StreamReader ip = new StreamReader(FileName))
                    {
                        string line;
                        while ((line = ip.ReadLine()) != null)
                        {
                            string[] split = line.Split(' ');

                            string tmp = split[0];
                            tmp = tmp.Replace("0x", "");

                            m_SortedTiles[itemcount].m_ItemID = ushort.Parse(split[0]);
                            m_SortedTiles[itemcount].m_OffsetX = Convert.ToInt16(split[1]);
                            m_SortedTiles[itemcount].m_OffsetY = Convert.ToInt16(split[2]);
                            m_SortedTiles[itemcount].m_OffsetZ = Convert.ToInt16(split[3]);
                            m_SortedTiles[itemcount].m_Flags = Convert.ToInt32(split[4]);
                            m_SortedTiles[itemcount].m_Unk1 = 0;

                            MultiTileEntry e = m_SortedTiles[itemcount];

                            if (e.m_OffsetX < m_Min.X)
                                m_Min.X = e.m_OffsetX;

                            if (e.m_OffsetY < m_Min.Y)
                                m_Min.Y = e.m_OffsetY;

                            if (e.m_OffsetX > m_Max.X)
                                m_Max.X = e.m_OffsetX;

                            if (e.m_OffsetY > m_Max.Y)
                                m_Max.Y = e.m_OffsetY;

                            if (e.m_OffsetZ > m_maxHeight)
                                m_maxHeight = e.m_OffsetZ;

                            itemcount++;
                        }
                        int centerx = m_Max.X - (int)(Math.Round((m_Max.X - m_Min.X) / 2.0));
                        int centery = m_Max.Y - (int)(Math.Round((m_Max.Y - m_Min.Y) / 2.0));

                        m_Min = m_Max = Point.Empty;
                        int i = 0;
                        for (; i < m_SortedTiles.Length; i++)
                        {
                            m_SortedTiles[i].m_OffsetX -= (short)centerx;
                            m_SortedTiles[i].m_OffsetY -= (short)centery;
                            if (m_SortedTiles[i].m_OffsetX < m_Min.X)
                                m_Min.X = m_SortedTiles[i].m_OffsetX;
                            if (m_SortedTiles[i].m_OffsetX > m_Max.X)
                                m_Max.X = m_SortedTiles[i].m_OffsetX;

                            if (m_SortedTiles[i].m_OffsetY < m_Min.Y)
                                m_Min.Y = m_SortedTiles[i].m_OffsetY;
                            if (m_SortedTiles[i].m_OffsetY > m_Max.Y)
                                m_Max.Y = m_SortedTiles[i].m_OffsetY;
                        }
                    }
                    break;
                case Multis.ImportType.UOA:
                    itemcount = 0;

                    using (StreamReader ip = new StreamReader(FileName))
                    {
                        string line;
                        while ((line = ip.ReadLine()) != null)
                        {
                            ++itemcount;
                            if (itemcount == 4)
                            {
                                string[] split = line.Split(' ');
                                itemcount = Convert.ToInt32(split[0]);
                                break;
                            }
                        }
                    }
                    m_SortedTiles = new MultiTileEntry[itemcount];
                    itemcount = 0;
                    m_Min.X = 10000;
                    m_Min.Y = 10000;
                    using (StreamReader ip = new StreamReader(FileName))
                    {
                        string line;
                        int i = -1;
                        while ((line = ip.ReadLine()) != null)
                        {
                            ++i;
                            if (i < 4)
                                continue;
                            string[] split = line.Split(' ');

                            m_SortedTiles[itemcount].m_ItemID = Convert.ToUInt16(split[0]);
                            m_SortedTiles[itemcount].m_OffsetX = Convert.ToInt16(split[1]);
                            m_SortedTiles[itemcount].m_OffsetY = Convert.ToInt16(split[2]);
                            m_SortedTiles[itemcount].m_OffsetZ = Convert.ToInt16(split[3]);
                            m_SortedTiles[itemcount].m_Flags = Convert.ToInt32(split[4]);
                            m_SortedTiles[itemcount].m_Unk1 = 0;

                            MultiTileEntry e = m_SortedTiles[itemcount];

                            if (e.m_OffsetX < m_Min.X)
                                m_Min.X = e.m_OffsetX;

                            if (e.m_OffsetY < m_Min.Y)
                                m_Min.Y = e.m_OffsetY;

                            if (e.m_OffsetX > m_Max.X)
                                m_Max.X = e.m_OffsetX;

                            if (e.m_OffsetY > m_Max.Y)
                                m_Max.Y = e.m_OffsetY;

                            if (e.m_OffsetZ > m_maxHeight)
                                m_maxHeight = e.m_OffsetZ;

                            ++itemcount;
                        }
                        int centerx = m_Max.X - (int)(Math.Round((m_Max.X - m_Min.X) / 2.0));
                        int centery = m_Max.Y - (int)(Math.Round((m_Max.Y - m_Min.Y) / 2.0));

                        m_Min = m_Max = Point.Empty;
                        i = 0;
                        for (; i < m_SortedTiles.Length; ++i)
                        {
                            m_SortedTiles[i].m_OffsetX -= (short)centerx;
                            m_SortedTiles[i].m_OffsetY -= (short)centery;
                            if (m_SortedTiles[i].m_OffsetX < m_Min.X)
                                m_Min.X = m_SortedTiles[i].m_OffsetX;
                            if (m_SortedTiles[i].m_OffsetX > m_Max.X)
                                m_Max.X = m_SortedTiles[i].m_OffsetX;

                            if (m_SortedTiles[i].m_OffsetY < m_Min.Y)
                                m_Min.Y = m_SortedTiles[i].m_OffsetY;
                            if (m_SortedTiles[i].m_OffsetY > m_Max.Y)
                                m_Max.Y = m_SortedTiles[i].m_OffsetY;
                        }
                    }

                    break;
                case Multis.ImportType.UOAB:
                    using (FileStream fs = new FileStream(FileName, FileMode.Open, FileAccess.Read, FileShare.Read))
                    using (BinaryReader reader = new BinaryReader(fs))
                    {
                        if (reader.ReadInt16() != 1) //Version check
                            return;
                        string tmp;
                        tmp = Multis.ReadUOAString(reader); //Name
                        tmp = Multis.ReadUOAString(reader); //Category
                        tmp = Multis.ReadUOAString(reader); //Subsection
                        int width = reader.ReadInt32();
                        int height = reader.ReadInt32();
                        int uwidth = reader.ReadInt32();
                        int uheight = reader.ReadInt32();

                        int count = reader.ReadInt32();
                        itemcount = count;
                        m_SortedTiles = new MultiTileEntry[itemcount];
                        itemcount = 0;
                        m_Min.X = 10000;
                        m_Min.Y = 10000;
                        for (; itemcount < count; ++itemcount)
                        {
                            m_SortedTiles[itemcount].m_ItemID = (ushort)reader.ReadInt16();
                            m_SortedTiles[itemcount].m_OffsetX = reader.ReadInt16();
                            m_SortedTiles[itemcount].m_OffsetY = reader.ReadInt16();
                            m_SortedTiles[itemcount].m_OffsetZ = reader.ReadInt16();
                            reader.ReadInt16(); // level
                            m_SortedTiles[itemcount].m_Flags = 1;
                            reader.ReadInt16(); // hue
                            m_SortedTiles[itemcount].m_Unk1 = 0;

                            MultiTileEntry e = m_SortedTiles[itemcount];

                            if (e.m_OffsetX < m_Min.X)
                                m_Min.X = e.m_OffsetX;

                            if (e.m_OffsetY < m_Min.Y)
                                m_Min.Y = e.m_OffsetY;

                            if (e.m_OffsetX > m_Max.X)
                                m_Max.X = e.m_OffsetX;

                            if (e.m_OffsetY > m_Max.Y)
                                m_Max.Y = e.m_OffsetY;

                            if (e.m_OffsetZ > m_maxHeight)
                                m_maxHeight = e.m_OffsetZ;
                        }
                        int centerx = m_Max.X - (int)(Math.Round((m_Max.X - m_Min.X) / 2.0));
                        int centery = m_Max.Y - (int)(Math.Round((m_Max.Y - m_Min.Y) / 2.0));

                        m_Min = m_Max = Point.Empty;
                        itemcount = 0;
                        for (; itemcount < m_SortedTiles.Length; ++itemcount)
                        {
                            m_SortedTiles[itemcount].m_OffsetX -= (short)centerx;
                            m_SortedTiles[itemcount].m_OffsetY -= (short)centery;
                            if (m_SortedTiles[itemcount].m_OffsetX < m_Min.X)
                                m_Min.X = m_SortedTiles[itemcount].m_OffsetX;
                            if (m_SortedTiles[itemcount].m_OffsetX > m_Max.X)
                                m_Max.X = m_SortedTiles[itemcount].m_OffsetX;

                            if (m_SortedTiles[itemcount].m_OffsetY < m_Min.Y)
                                m_Min.Y = m_SortedTiles[itemcount].m_OffsetY;
                            if (m_SortedTiles[itemcount].m_OffsetY > m_Max.Y)
                                m_Max.Y = m_SortedTiles[itemcount].m_OffsetY;
                        }
                    }
                    break;

                case Multis.ImportType.WSC:
                    itemcount = 0;
                    using (StreamReader ip = new StreamReader(FileName))
                    {
                        string line;
                        while ((line = ip.ReadLine()) != null)
                        {
                            line = line.Trim();
                            if (line.StartsWith("SECTION WORLDITEM"))
                                ++itemcount;
                        }
                    }
                    m_SortedTiles = new MultiTileEntry[itemcount];
                    itemcount = 0;
                    m_Min.X = 10000;
                    m_Min.Y = 10000;
                    using (StreamReader ip = new StreamReader(FileName))
                    {
                        string line;
                        MultiTileEntry tempitem = new MultiTileEntry();
                        tempitem.m_ItemID = 0xFFFF;
                        tempitem.m_Flags = 1;
                        tempitem.m_Unk1 = 0;
                        while ((line = ip.ReadLine()) != null)
                        {
                            line = line.Trim();
                            if (line.StartsWith("SECTION WORLDITEM"))
                            {
                                if (tempitem.m_ItemID != 0xFFFF)
                                {
                                    m_SortedTiles[itemcount] = tempitem;
                                    ++itemcount;
                                }
                                tempitem.m_ItemID = 0xFFFF;
                            }
                            else if (line.StartsWith("ID"))
                            {
                                line = line.Remove(0, 2);
                                line = line.Trim();
                                tempitem.m_ItemID = Convert.ToUInt16(line);
                            }
                            else if (line.StartsWith("X"))
                            {
                                line = line.Remove(0, 1);
                                line = line.Trim();
                                tempitem.m_OffsetX = Convert.ToInt16(line);
                                if (tempitem.m_OffsetX < m_Min.X)
                                    m_Min.X = tempitem.m_OffsetX;
                                if (tempitem.m_OffsetX > m_Max.X)
                                    m_Max.X = tempitem.m_OffsetX;
                            }
                            else if (line.StartsWith("Y"))
                            {
                                line = line.Remove(0, 1);
                                line = line.Trim();
                                tempitem.m_OffsetY = Convert.ToInt16(line);
                                if (tempitem.m_OffsetY < m_Min.Y)
                                    m_Min.Y = tempitem.m_OffsetY;
                                if (tempitem.m_OffsetY > m_Max.Y)
                                    m_Max.Y = tempitem.m_OffsetY;
                            }
                            else if (line.StartsWith("Z"))
                            {
                                line = line.Remove(0, 1);
                                line = line.Trim();
                                tempitem.m_OffsetZ = Convert.ToInt16(line);
                                if (tempitem.m_OffsetZ > m_maxHeight)
                                    m_maxHeight = tempitem.m_OffsetZ;

                            }
                        }
                        if (tempitem.m_ItemID != 0xFFFF)
                            m_SortedTiles[itemcount] = tempitem;

                        int centerx = m_Max.X - (int)(Math.Round((m_Max.X - m_Min.X) / 2.0));
                        int centery = m_Max.Y - (int)(Math.Round((m_Max.Y - m_Min.Y) / 2.0));

                        m_Min = m_Max = Point.Empty;
                        int i = 0;
                        for (; i < m_SortedTiles.Length; i++)
                        {
                            m_SortedTiles[i].m_OffsetX -= (short)centerx;
                            m_SortedTiles[i].m_OffsetY -= (short)centery;
                            if (m_SortedTiles[i].m_OffsetX < m_Min.X)
                                m_Min.X = m_SortedTiles[i].m_OffsetX;
                            if (m_SortedTiles[i].m_OffsetX > m_Max.X)
                                m_Max.X = m_SortedTiles[i].m_OffsetX;

                            if (m_SortedTiles[i].m_OffsetY < m_Min.Y)
                                m_Min.Y = m_SortedTiles[i].m_OffsetY;
                            if (m_SortedTiles[i].m_OffsetY > m_Max.Y)
                                m_Max.Y = m_SortedTiles[i].m_OffsetY;
                        }
                    }
                    break;
            }
            ConvertList();
        }
示例#20
0
        public MultiComponentList( BinaryReader reader, int count )
        {
            m_Min = m_Max = Point.Empty;

            MultiTileEntry[] allTiles = new MultiTileEntry[count];

            for ( int i = 0; i < count; ++i )
            {
                allTiles[i].m_ItemID = reader.ReadInt16();
                allTiles[i].m_OffsetX = reader.ReadInt16();
                allTiles[i].m_OffsetY = reader.ReadInt16();
                allTiles[i].m_OffsetZ = reader.ReadInt16();
                allTiles[i].m_Flags = reader.ReadInt32();

                MultiTileEntry e = allTiles[i];

                if ( e.m_OffsetX < m_Min.X )
                    m_Min.X = e.m_OffsetX;

                if ( e.m_OffsetY < m_Min.Y )
                    m_Min.Y = e.m_OffsetY;

                if ( e.m_OffsetX > m_Max.X )
                    m_Max.X = e.m_OffsetX;

                if ( e.m_OffsetY > m_Max.Y )
                    m_Max.Y = e.m_OffsetY;
            }

            m_Center = new Point( -m_Min.X, -m_Min.Y );
            m_Width = (m_Max.X - m_Min.X) + 1;
            m_Height = (m_Max.Y - m_Min.Y) + 1;

            TileList[][] tiles = new TileList[m_Width][];
            m_Tiles = new Tile[m_Width][][];

            for ( int x = 0; x < m_Width; ++x )
            {
                tiles[x] = new TileList[m_Height];
                m_Tiles[x] = new Tile[m_Height][];

                for ( int y = 0; y < m_Height; ++y )
                    tiles[x][y] = new TileList();
            }

            for ( int i = 0; i < allTiles.Length; ++i )
            {
                int xOffset = allTiles[i].m_OffsetX + m_Center.X;
                int yOffset = allTiles[i].m_OffsetY + m_Center.Y;

                tiles[xOffset][yOffset].Add( (short)((allTiles[i].m_ItemID & 0x3FFF) + 0x4000), (sbyte)allTiles[i].m_OffsetZ );
            }

            for ( int x = 0; x < m_Width; ++x )
            {
                for ( int y = 0; y < m_Height; ++y )
                {
                    m_Tiles[x][y] = tiles[x][y].ToArray();

                    if ( m_Tiles[x][y].Length > 1 )
                        Array.Sort( m_Tiles[x][y] );
                }
            }
        }
		public void AddFixtures( Mobile from, MultiTileEntry[] list )
		{
            if (m_Fixtures == null)
                m_Fixtures = new List<Item>();

			uint keyValue = 0;

			for ( int i = 0; i < list.Length; ++i )
			{
				MultiTileEntry mte = list[i];
				int itemID = mte.m_ItemID & TileData.MaxItemValue;

				if ( itemID >= 0x181D && itemID < 0x1829 )
				{
					HouseTeleporter tp = new HouseTeleporter( itemID );

					AddFixture( tp, mte );
				}
				else
				{
					BaseDoor door = null;

					if ( itemID >= 0x675 && itemID < 0x6F5 )
					{
						int type = ( itemID - 0x675 ) / 16;
						DoorFacing facing = (DoorFacing) ( ( ( itemID - 0x675 ) / 2 ) % 8 );

						switch ( type )
						{
							case 0:
								door = new GenericHouseDoor( facing, 0x675, 0xEC, 0xF3 );
								break;
							case 1:
								door = new GenericHouseDoor( facing, 0x685, 0xEC, 0xF3 );
								break;
							case 2:
								door = new GenericHouseDoor( facing, 0x695, 0xEB, 0xF2 );
								break;
							case 3:
								door = new GenericHouseDoor( facing, 0x6A5, 0xEA, 0xF1 );
								break;
							case 4:
								door = new GenericHouseDoor( facing, 0x6B5, 0xEA, 0xF1 );
								break;
							case 5:
								door = new GenericHouseDoor( facing, 0x6C5, 0xEC, 0xF3 );
								break;
							case 6:
								door = new GenericHouseDoor( facing, 0x6D5, 0xEA, 0xF1 );
								break;
							case 7:
								door = new GenericHouseDoor( facing, 0x6E5, 0xEA, 0xF1 );
								break;
						}
					}
					else if ( itemID >= 0x314 && itemID < 0x364 )
					{
						int type = ( itemID - 0x314 ) / 16;
						DoorFacing facing = (DoorFacing) ( ( ( itemID - 0x314 ) / 2 ) % 8 );

						switch ( type )
						{
							case 0:
								door = new GenericHouseDoor( facing, 0x314, 0xED, 0xF4 );
								break;
							case 1:
								door = new GenericHouseDoor( facing, 0x324, 0xED, 0xF4 );
								break;
							case 2:
								door = new GenericHouseDoor( facing, 0x334, 0xED, 0xF4 );
								break;
							case 3:
								door = new GenericHouseDoor( facing, 0x344, 0xED, 0xF4 );
								break;
							case 4:
								door = new GenericHouseDoor( facing, 0x354, 0xED, 0xF4 );
								break;
						}
					}
					else if ( itemID >= 0x824 && itemID < 0x834 )
					{
						DoorFacing facing = (DoorFacing) ( ( ( itemID - 0x824 ) / 2 ) % 8 );
						door = new GenericHouseDoor( facing, 0x824, 0xEC, 0xF3 );
					}
					else if ( itemID >= 0x839 && itemID < 0x849 )
					{
						DoorFacing facing = (DoorFacing) ( ( ( itemID - 0x839 ) / 2 ) % 8 );
						door = new GenericHouseDoor( facing, 0x839, 0xEB, 0xF2 );
					}
					else if ( itemID >= 0x84C && itemID < 0x85C )
					{
						DoorFacing facing = (DoorFacing) ( ( ( itemID - 0x84C ) / 2 ) % 8 );
						door = new GenericHouseDoor( facing, 0x84C, 0xEC, 0xF3 );
					}
					else if ( itemID >= 0x866 && itemID < 0x876 )
					{
						DoorFacing facing = (DoorFacing) ( ( ( itemID - 0x866 ) / 2 ) % 8 );
						door = new GenericHouseDoor( facing, 0x866, 0xEB, 0xF2 );
					}
					else if ( itemID >= 0xE8 && itemID < 0xF8 )
					{
						DoorFacing facing = (DoorFacing) ( ( ( itemID - 0xE8 ) / 2 ) % 8 );
						door = new GenericHouseDoor( facing, 0xE8, 0xED, 0xF4 );
					}
					else if ( itemID >= 0x1FED && itemID < 0x1FFD )
					{
						DoorFacing facing = (DoorFacing) ( ( ( itemID - 0x1FED ) / 2 ) % 8 );
						door = new GenericHouseDoor( facing, 0x1FED, 0xEC, 0xF3 );
					}
					else if ( itemID >= 0x241F && itemID < 0x2421 )
					{
						//DoorFacing facing = (DoorFacing)(((itemID - 0x241F) / 2) % 8);
						door = new GenericHouseDoor( DoorFacing.NorthCCW, 0x2415, -1, -1 );
					}
					else if ( itemID >= 0x2423 && itemID < 0x2425 )
					{
						//DoorFacing facing = (DoorFacing)(((itemID - 0x241F) / 2) % 8);
						//This one and the above one are 'special' cases, ie: OSI had the ItemID pattern discombobulated for these
						door = new GenericHouseDoor( DoorFacing.WestCW, 0x2423, -1, -1 );
					}
					else if ( itemID >= 0x2A05 && itemID < 0x2A1D )
					{
						DoorFacing facing = (DoorFacing) ( ( ( ( itemID - 0x2A05 ) / 2 ) % 4 ) + 8 );

						int sound = ( itemID >= 0x2A0D && itemID < 0x2a15 ) ? 0x539 : -1;

						door = new GenericHouseDoor( facing, 0x29F5 + ( 8 * ( ( itemID - 0x2A05 ) / 8 ) ), sound, sound );
					}

						// Mondain's Legacy
					else if ( itemID == 0x31AE )
						door = new GenericHouseDoor( DoorFacing.WestCCW, 0x31AE - ( 2 * (int) DoorFacing.WestCCW ), 0xEA, 0xF1 );
					else if ( itemID == 0x31AC )
						door = new GenericHouseDoor( DoorFacing.EastCW, 0x31AC - ( 2 * (int) DoorFacing.EastCW ), 0xEA, 0xF1 );
					else if ( itemID == 0x2D48 )
						door = new GenericHouseDoor( DoorFacing.SouthCCW, 0x2D48 - ( 2 * (int) DoorFacing.SouthCCW ), 0xEA, 0xF1 );
					else if ( itemID == 0x2D46 )
						door = new GenericHouseDoor( DoorFacing.NorthCW, 0x2D46 - ( 2 * (int) DoorFacing.NorthCW ), 0xEA, 0xF1 );

					else if ( itemID == 0x2D65 )
						door = new GenericHouseDoor( DoorFacing.WestCCW, 0x2D65 - ( 2 * (int) DoorFacing.WestCCW ), 0xEA, 0xF1 );
					else if ( itemID == 0x31A0 )
						door = new GenericHouseDoor( DoorFacing.EastCW, 0x31A0 - ( 2 * (int) DoorFacing.EastCW ), 0xEA, 0xF1 );
					else if ( itemID == 0x2D63 )
						door = new GenericHouseDoor( DoorFacing.SouthCCW, 0x2D63 - ( 2 * (int) DoorFacing.SouthCCW ), 0xEA, 0xF1 );
					else if ( itemID == 0x31A2 )
						door = new GenericHouseDoor( DoorFacing.NorthCW, 0x31A2 - ( 2 * (int) DoorFacing.NorthCW ), 0xEA, 0xF1 );

					else if ( itemID == 0x2D69 )
						door = new GenericHouseDoor( DoorFacing.WestCCW, 0x2D69 - ( 2 * (int) DoorFacing.WestCCW ), 0xEA, 0xF1 );
					else if ( itemID == 0x31A4 )
						door = new GenericHouseDoor( DoorFacing.EastCW, 0x31A4 - ( 2 * (int) DoorFacing.EastCW ), 0xEA, 0xF1 );
					else if ( itemID == 0x2D67 )
						door = new GenericHouseDoor( DoorFacing.SouthCCW, 0x2D67 - ( 2 * (int) DoorFacing.SouthCCW ), 0xEA, 0xF1 );
					else if ( itemID == 0x31A6 )
						door = new GenericHouseDoor( DoorFacing.NorthCW, 0x31A6 - ( 2 * (int) DoorFacing.NorthCW ), 0xEA, 0xF1 );

					else if ( itemID == 0x2D6D )
						door = new GenericHouseDoor( DoorFacing.WestCCW, 0x2D6D - ( 2 * (int) DoorFacing.WestCCW ), 0xEA, 0xF1 );
					else if ( itemID == 0x31AA )
						door = new GenericHouseDoor( DoorFacing.EastCW, 0x31AA - ( 2 * (int) DoorFacing.EastCW ), 0xEA, 0xF1 );
					else if ( itemID == 0x2D6B )
						door = new GenericHouseDoor( DoorFacing.SouthCCW, 0x2D6B - ( 2 * (int) DoorFacing.SouthCCW ), 0xEA, 0xF1 );
					else if ( itemID == 0x31A8 )
						door = new GenericHouseDoor( DoorFacing.NorthCW, 0x31A8 - ( 2 * (int) DoorFacing.NorthCW ), 0xEA, 0xF1 );

					else if ( itemID == 0x2FE4 )
						door = new GenericHouseDoor( DoorFacing.WestCCW, 0x2FE4 - ( 2 * (int) DoorFacing.WestCCW ), 0xEA, 0xF1 );
					else if ( itemID == 0x319C )
						door = new GenericHouseDoor( DoorFacing.EastCW, 0x319C - ( 2 * (int) DoorFacing.EastCW ), 0xEA, 0xF1 );
					else if ( itemID == 0x2FE2 )
						door = new GenericHouseDoor( DoorFacing.SouthCCW, 0x2FE2 - ( 2 * (int) DoorFacing.SouthCCW ), 0xEA, 0xF1 );
					else if ( itemID == 0x319E )
						door = new GenericHouseDoor( DoorFacing.NorthCW, 0x319E - ( 2 * (int) DoorFacing.NorthCW ), 0xEA, 0xF1 );

						// 9th Anniversary
					else if ( itemID >= 0x367B && itemID < 0x369B )
					{
						int type = ( itemID - 0x367B ) / 16;
						DoorFacing facing = (DoorFacing) ( ( ( itemID - 0x367B ) / 2 ) % 8 );

						switch ( type )
						{
							case 0:
								door = new GenericHouseDoor( facing, 0x367B, 0xED, 0xF4 );
								break;
							case 1:
								door = new GenericHouseDoor( facing, 0x368B, 0xED, 0xF4 );
								break;
						}
					}

						// Stygian Abyss
					else if ( itemID >= 0x409B && itemID <= 0x5148 )
					{
						int baseId = -1;

						for ( int j = m_SADoorIds.Length - 1; j >= 0; j-- )
						{
							baseId = m_SADoorIds[j];

							if ( itemID >= baseId )
								break;
						}

						int facing = ( ( itemID - baseId ) / 2 ) % 8;

						if ( itemID >= 0x50C8 && itemID <= 0x50D6 ) // special case
						{
							facing = ( facing % 2 ) + ( ( ( facing / 2 ) % 2 != 0 ) ? 6 : 2 );
						}
						else
						{
							if ( ( facing / 2 ) % 2 == 0 )
								facing += 2;
						}

						door = new GenericHouseDoor( (DoorFacing) facing, itemID - ( 2 * facing ), 0xEA, 0xF1 );
					}

					if ( door != null )
					{
						if ( keyValue == 0 )
							keyValue = CreateKeys( from );

						door.Locked = true;
						door.KeyValue = keyValue;

						AddDoor( door, mte.m_OffsetX, mte.m_OffsetY, mte.m_OffsetZ );
						m_Fixtures.Add( door );
					}
				}
			}

			for ( int i = 0; i < m_Fixtures.Count; ++i )
			{
				Item fixture = (Item) m_Fixtures[i];

				if ( fixture is HouseTeleporter )
				{
					HouseTeleporter tp = (HouseTeleporter) fixture;

					for ( int j = 1; j <= m_Fixtures.Count; ++j )
					{
						HouseTeleporter check = m_Fixtures[( i + j ) % m_Fixtures.Count] as HouseTeleporter;

						if ( check != null && check.ItemID == tp.ItemID )
						{
							tp.Target = check;
							break;
						}
					}
				}
				else if ( fixture is BaseHouseDoor )
				{
					BaseHouseDoor door = (BaseHouseDoor) fixture;

					if ( door.Link != null )
						continue;

					DoorFacing linkFacing;
					int xOffset, yOffset;

					switch ( door.Facing )
					{
						default:
						case DoorFacing.WestCW:
							linkFacing = DoorFacing.EastCCW;
							xOffset = 1;
							yOffset = 0;
							break;
						case DoorFacing.EastCCW:
							linkFacing = DoorFacing.WestCW;
							xOffset = -1;
							yOffset = 0;
							break;
						case DoorFacing.WestCCW:
							linkFacing = DoorFacing.EastCW;
							xOffset = 1;
							yOffset = 0;
							break;
						case DoorFacing.EastCW:
							linkFacing = DoorFacing.WestCCW;
							xOffset = -1;
							yOffset = 0;
							break;
						case DoorFacing.SouthCW:
							linkFacing = DoorFacing.NorthCCW;
							xOffset = 0;
							yOffset = -1;
							break;
						case DoorFacing.NorthCCW:
							linkFacing = DoorFacing.SouthCW;
							xOffset = 0;
							yOffset = 1;
							break;
						case DoorFacing.SouthCCW:
							linkFacing = DoorFacing.NorthCW;
							xOffset = 0;
							yOffset = -1;
							break;
						case DoorFacing.NorthCW:
							linkFacing = DoorFacing.SouthCCW;
							xOffset = 0;
							yOffset = 1;
							break;
						case DoorFacing.SouthSW:
							linkFacing = DoorFacing.SouthSE;
							xOffset = 1;
							yOffset = 0;
							break;
						case DoorFacing.SouthSE:
							linkFacing = DoorFacing.SouthSW;
							xOffset = -1;
							yOffset = 0;
							break;
						case DoorFacing.WestSN:
							linkFacing = DoorFacing.WestSS;
							xOffset = 0;
							yOffset = 1;
							break;
						case DoorFacing.WestSS:
							linkFacing = DoorFacing.WestSN;
							xOffset = 0;
							yOffset = -1;
							break;
					}

					for ( int j = i + 1; j < m_Fixtures.Count; ++j )
					{
						BaseHouseDoor check = m_Fixtures[j] as BaseHouseDoor;

						if ( check != null && check.Link == null && check.Facing == linkFacing && ( check.X - door.X ) == xOffset && ( check.Y - door.Y ) == yOffset && ( check.Z == door.Z ) )
						{
							check.Link = door;
							door.Link = check;
							break;
						}
					}
				}
			}
		}
示例#22
0
		public DesignStateDetailed( int serial, int revision, int xMin, int yMin, int xMax, int yMax, MultiTileEntry[] tiles )
			: base( 0xD8 )
		{
			EnsureCapacity( 17 + (tiles.Length * 5) );

			Write( (byte)0x03 ); // Compression Type
			Write( (byte)0x00 ); // Unknown
			Write( (int)serial );
			Write( (int)revision );
			Write( (short)tiles.Length );
			Write( (short)0 ); // Buffer length : reserved
			Write( (byte)0 ); // Plane count : reserved

			int totalLength = 1; // includes plane count

			int width = (xMax - xMin) + 1;
			int height = (yMax - yMin) + 1;

			m_PlaneBuffers = new byte[9][];

			lock (m_PlaneBufferPool)
				for (int i = 0; i < m_PlaneBuffers.Length; ++i)
					m_PlaneBuffers[i] = m_PlaneBufferPool.AcquireBuffer();

			m_StairBuffers = new byte[6][];

			lock (m_StairBufferPool)
				for (int i = 0; i < m_StairBuffers.Length; ++i)
					m_StairBuffers[i] = m_StairBufferPool.AcquireBuffer();

			Clear( m_PlaneBuffers[0], width * height * 2 );

			for( int i = 0; i < 4; ++i )
			{
				Clear( m_PlaneBuffers[1 + i], (width - 1) * (height - 2) * 2 );
				Clear( m_PlaneBuffers[5 + i], width * (height - 1) * 2 );
			}

			int totalStairsUsed = 0;

			for( int i = 0; i < tiles.Length; ++i )
			{
				MultiTileEntry mte = tiles[i];
				int x = mte.m_OffsetX - xMin;
				int y = mte.m_OffsetY - yMin;
				int z = mte.m_OffsetZ;
				bool floor = (TileData.ItemTable[mte.m_ItemID & TileData.MaxItemValue].Height <= 0);
				int plane, size;

				switch( z )
				{
					case 0: plane = 0; break;
					case 7: plane = 1; break;
					case 27: plane = 2; break;
					case 47: plane = 3; break;
					case 67: plane = 4; break;
					default:
					{
						int stairBufferIndex = (totalStairsUsed / MaxItemsPerStairBuffer);
						byte[] stairBuffer = m_StairBuffers[stairBufferIndex];

						int byteIndex = (totalStairsUsed % MaxItemsPerStairBuffer) * 5;

						stairBuffer[byteIndex++] = (byte)(mte.m_ItemID >> 8);
						stairBuffer[byteIndex++] = (byte)mte.m_ItemID;

						stairBuffer[byteIndex++] = (byte)mte.m_OffsetX;
						stairBuffer[byteIndex++] = (byte)mte.m_OffsetY;
						stairBuffer[byteIndex++] = (byte)mte.m_OffsetZ;

						++totalStairsUsed;

						continue;
					}
				}

				if( plane == 0 )
				{
					size = height;
				}
				else if( floor )
				{
					size = height - 2;
					x -= 1;
					y -= 1;
				}
				else
				{
					size = height - 1;
					plane += 4;
				}

				int index = ((x * size) + y) * 2;

				if( x < 0 || y < 0 || y >= size || (index + 1) >= 0x400 )
				{
					int stairBufferIndex = (totalStairsUsed / MaxItemsPerStairBuffer);
					byte[] stairBuffer = m_StairBuffers[stairBufferIndex];

					int byteIndex = (totalStairsUsed % MaxItemsPerStairBuffer) * 5;

					stairBuffer[byteIndex++] = (byte)(mte.m_ItemID >> 8);
					stairBuffer[byteIndex++] = (byte)mte.m_ItemID;

					stairBuffer[byteIndex++] = (byte)mte.m_OffsetX;
					stairBuffer[byteIndex++] = (byte)mte.m_OffsetY;
					stairBuffer[byteIndex++] = (byte)mte.m_OffsetZ;

					++totalStairsUsed;
				}
				else
				{
					m_PlaneUsed[plane] = true;
					m_PlaneBuffers[plane][index] = (byte)(mte.m_ItemID >> 8);
					m_PlaneBuffers[plane][index + 1] = (byte)mte.m_ItemID;
				}
			}

			int planeCount = 0;

			byte[] m_DeflatedBuffer = null;
			lock (m_DeflatedBufferPool)
				m_DeflatedBuffer = m_DeflatedBufferPool.AcquireBuffer();

			for( int i = 0; i < m_PlaneBuffers.Length; ++i )
			{
				if (!m_PlaneUsed[i])
				{
					m_PlaneBufferPool.ReleaseBuffer(m_PlaneBuffers[i]);
					continue;
				}

				++planeCount;

				int size = 0;

				if( i == 0 )
					size = width * height * 2;
				else if( i < 5 )
					size = (width - 1) * (height - 2) * 2;
				else
					size = width * (height - 1) * 2;

				byte[] inflatedBuffer = m_PlaneBuffers[i];

				int deflatedLength = m_DeflatedBuffer.Length;
				ZLibError ce = Compression.Pack( m_DeflatedBuffer, ref deflatedLength, inflatedBuffer, size, ZLibQuality.Default );

				if( ce != ZLibError.Okay )
				{
					Console.WriteLine( "ZLib error: {0} (#{1})", ce, (int)ce );
					deflatedLength = 0;
					size = 0;
				}

				Write( (byte)(0x20 | i) );
				Write( (byte)size );
				Write( (byte)deflatedLength );
				Write( (byte)(((size >> 4) & 0xF0) | ((deflatedLength >> 8) & 0xF)) );
				Write( m_DeflatedBuffer, 0, deflatedLength );

				totalLength += 4 + deflatedLength;
				lock (m_PlaneBufferPool)
					m_PlaneBufferPool.ReleaseBuffer(inflatedBuffer);
			}

			int totalStairBuffersUsed = (totalStairsUsed + (MaxItemsPerStairBuffer - 1)) / MaxItemsPerStairBuffer;

			for( int i = 0; i < totalStairBuffersUsed; ++i )
			{
				++planeCount;

				int count = (totalStairsUsed - (i * MaxItemsPerStairBuffer));

				if( count > MaxItemsPerStairBuffer )
					count = MaxItemsPerStairBuffer;

				int size = count * 5;

				byte[] inflatedBuffer = m_StairBuffers[i];

				int deflatedLength = m_DeflatedBuffer.Length;
				ZLibError ce = Compression.Pack( m_DeflatedBuffer, ref deflatedLength, inflatedBuffer, size, ZLibQuality.Default );

				if( ce != ZLibError.Okay )
				{
					Console.WriteLine( "ZLib error: {0} (#{1})", ce, (int)ce );
					deflatedLength = 0;
					size = 0;
				}

				Write( (byte)(9 + i) );
				Write( (byte)size );
				Write( (byte)deflatedLength );
				Write( (byte)(((size >> 4) & 0xF0) | ((deflatedLength >> 8) & 0xF)) );
				Write( m_DeflatedBuffer, 0, deflatedLength );

				totalLength += 4 + deflatedLength;
			}

			lock (m_StairBufferPool)
				for (int i = 0; i < m_StairBuffers.Length; ++i)
					m_StairBufferPool.ReleaseBuffer(m_StairBuffers[i]);

			lock (m_DeflatedBufferPool)
				m_DeflatedBufferPool.ReleaseBuffer(m_DeflatedBuffer);

			m_Stream.Seek( 15, System.IO.SeekOrigin.Begin );

			Write( (short)totalLength ); // Buffer length
			Write( (byte)planeCount ); // Plane count
		}
示例#23
0
        public MultiComponentList(List <MultiTileEntry> arr)
        {
            _min = _max = Point.Empty;
            int itemCount = arr.Count;

            SortedTiles = new MultiTileEntry[itemCount];
            _min.X      = 10000;
            _min.Y      = 10000;
            int i = 0;

            foreach (MultiTileEntry entry in arr)
            {
                if (entry.m_OffsetX < _min.X)
                {
                    _min.X = entry.m_OffsetX;
                }

                if (entry.m_OffsetY < _min.Y)
                {
                    _min.Y = entry.m_OffsetY;
                }

                if (entry.m_OffsetX > _max.X)
                {
                    _max.X = entry.m_OffsetX;
                }

                if (entry.m_OffsetY > _max.Y)
                {
                    _max.Y = entry.m_OffsetY;
                }

                if (entry.m_OffsetZ > MaxHeight)
                {
                    MaxHeight = entry.m_OffsetZ;
                }

                SortedTiles[i] = entry;

                ++i;
            }
            arr.Clear();

            int centerX = _max.X - (int)(Math.Round((_max.X - _min.X) / 2.0));
            int centerY = _max.Y - (int)(Math.Round((_max.Y - _min.Y) / 2.0));

            _min = _max = Point.Empty;
            for (i = 0; i < SortedTiles.Length; ++i)
            {
                SortedTiles[i].m_OffsetX -= (short)centerX;
                SortedTiles[i].m_OffsetY -= (short)centerY;
                if (SortedTiles[i].m_OffsetX < _min.X)
                {
                    _min.X = SortedTiles[i].m_OffsetX;
                }

                if (SortedTiles[i].m_OffsetX > _max.X)
                {
                    _max.X = SortedTiles[i].m_OffsetX;
                }

                if (SortedTiles[i].m_OffsetY < _min.Y)
                {
                    _min.Y = SortedTiles[i].m_OffsetY;
                }

                if (SortedTiles[i].m_OffsetY > _max.Y)
                {
                    _max.Y = SortedTiles[i].m_OffsetY;
                }
            }
            ConvertList();
        }
示例#24
0
        public MultiComponentList(BinaryReader reader, int count)
        {
            m_Min = m_Max = Point.Empty;

            MultiTileEntry[] allTiles = new MultiTileEntry[count];

            for (int i = 0; i < count; ++i)
            {
                allTiles[i].m_ItemID  = reader.ReadInt16();
                allTiles[i].m_OffsetX = reader.ReadInt16();
                allTiles[i].m_OffsetY = reader.ReadInt16();
                allTiles[i].m_OffsetZ = reader.ReadInt16();
                allTiles[i].m_Flags   = reader.ReadInt32();

                MultiTileEntry e = allTiles[i];

                if (e.m_OffsetX < m_Min.X)
                {
                    m_Min.X = e.m_OffsetX;
                }

                if (e.m_OffsetY < m_Min.Y)
                {
                    m_Min.Y = e.m_OffsetY;
                }

                if (e.m_OffsetX > m_Max.X)
                {
                    m_Max.X = e.m_OffsetX;
                }

                if (e.m_OffsetY > m_Max.Y)
                {
                    m_Max.Y = e.m_OffsetY;
                }
            }

            m_Center = new Point(-m_Min.X, -m_Min.Y);
            m_Width  = (m_Max.X - m_Min.X) + 1;
            m_Height = (m_Max.Y - m_Min.Y) + 1;

            TileList[][] tiles = new TileList[m_Width][];
            m_Tiles = new Tile[m_Width][][];

            for (int x = 0; x < m_Width; ++x)
            {
                tiles[x]   = new TileList[m_Height];
                m_Tiles[x] = new Tile[m_Height][];

                for (int y = 0; y < m_Height; ++y)
                {
                    tiles[x][y] = new TileList();
                }
            }

            for (int i = 0; i < allTiles.Length; ++i)
            {
                int xOffset = allTiles[i].m_OffsetX + m_Center.X;
                int yOffset = allTiles[i].m_OffsetY + m_Center.Y;

                tiles[xOffset][yOffset].Add((short)((allTiles[i].m_ItemID & 0x3FFF) + 0x4000), (sbyte)allTiles[i].m_OffsetZ);
            }

            for (int x = 0; x < m_Width; ++x)
            {
                for (int y = 0; y < m_Height; ++y)
                {
                    m_Tiles[x][y] = tiles[x][y].ToArray();

                    if (m_Tiles[x][y].Length > 1)
                    {
                        Array.Sort(m_Tiles[x][y]);
                    }
                }
            }
        }
示例#25
0
        public MultiComponentList(MTileList[][] newTiles, int count, int width, int height)
        {
            _min        = _max = Point.Empty;
            SortedTiles = new MultiTileEntry[count];
            _center     = new Point((int)Math.Round(width / 2.0) - 1, (int)Math.Round(height / 2.0) - 1);
            if (_center.X < 0)
            {
                _center.X = width / 2;
            }

            if (_center.Y < 0)
            {
                _center.Y = height / 2;
            }

            MaxHeight = -128;

            int counter = 0;

            for (int x = 0; x < width; ++x)
            {
                for (int y = 0; y < height; ++y)
                {
                    foreach (var mTile in newTiles[x][y].ToArray())
                    {
                        SortedTiles[counter].m_ItemID  = mTile.Id;
                        SortedTiles[counter].m_OffsetX = (short)(x - _center.X);
                        SortedTiles[counter].m_OffsetY = (short)(y - _center.Y);
                        SortedTiles[counter].m_OffsetZ = mTile.Z;
                        SortedTiles[counter].m_Flags   = mTile.Flag;
                        SortedTiles[counter].m_Unk1    = 0;

                        if (SortedTiles[counter].m_OffsetX < _min.X)
                        {
                            _min.X = SortedTiles[counter].m_OffsetX;
                        }

                        if (SortedTiles[counter].m_OffsetX > _max.X)
                        {
                            _max.X = SortedTiles[counter].m_OffsetX;
                        }

                        if (SortedTiles[counter].m_OffsetY < _min.Y)
                        {
                            _min.Y = SortedTiles[counter].m_OffsetY;
                        }

                        if (SortedTiles[counter].m_OffsetY > _max.Y)
                        {
                            _max.Y = SortedTiles[counter].m_OffsetY;
                        }

                        if (SortedTiles[counter].m_OffsetZ > MaxHeight)
                        {
                            MaxHeight = SortedTiles[counter].m_OffsetZ;
                        }

                        ++counter;
                    }
                }
            }
            ConvertList();
        }
示例#26
0
文件: Multis.cs 项目: credzba/Razor
        public MultiComponentList(string FileName, Multis.ImportType Type)
        {
            m_Min = m_Max = Point.Empty;
            int itemcount;

            switch (Type)
            {
            case Multis.ImportType.TXT:
                itemcount = 0;
                using (StreamReader ip = new StreamReader(FileName))
                {
                    string line;
                    while ((line = ip.ReadLine()) != null)
                    {
                        itemcount++;
                    }
                }

                m_SortedTiles = new MultiTileEntry[itemcount];
                itemcount     = 0;
                m_Min.X       = 10000;
                m_Min.Y       = 10000;
                using (StreamReader ip = new StreamReader(FileName))
                {
                    string line;
                    while ((line = ip.ReadLine()) != null)
                    {
                        string[] split = line.Split(' ');

                        string tmp = split[0];
                        tmp = tmp.Replace("0x", "");

                        m_SortedTiles[itemcount].m_ItemID =
                            ushort.Parse(tmp, System.Globalization.NumberStyles.HexNumber);
                        m_SortedTiles[itemcount].m_OffsetX = Convert.ToInt16(split[1]);
                        m_SortedTiles[itemcount].m_OffsetY = Convert.ToInt16(split[2]);
                        m_SortedTiles[itemcount].m_OffsetZ = Convert.ToInt16(split[3]);
                        m_SortedTiles[itemcount].m_Flags   = Convert.ToInt32(split[4]);
                        m_SortedTiles[itemcount].m_Unk1    = 0;

                        MultiTileEntry e = m_SortedTiles[itemcount];

                        if (e.m_OffsetX < m_Min.X)
                        {
                            m_Min.X = e.m_OffsetX;
                        }

                        if (e.m_OffsetY < m_Min.Y)
                        {
                            m_Min.Y = e.m_OffsetY;
                        }

                        if (e.m_OffsetX > m_Max.X)
                        {
                            m_Max.X = e.m_OffsetX;
                        }

                        if (e.m_OffsetY > m_Max.Y)
                        {
                            m_Max.Y = e.m_OffsetY;
                        }

                        if (e.m_OffsetZ > m_maxHeight)
                        {
                            m_maxHeight = e.m_OffsetZ;
                        }

                        itemcount++;
                    }

                    int centerx = m_Max.X - (int)(Math.Round((m_Max.X - m_Min.X) / 2.0));
                    int centery = m_Max.Y - (int)(Math.Round((m_Max.Y - m_Min.Y) / 2.0));

                    m_Min = m_Max = Point.Empty;
                    int i = 0;
                    for (; i < m_SortedTiles.Length; i++)
                    {
                        m_SortedTiles[i].m_OffsetX -= (short)centerx;
                        m_SortedTiles[i].m_OffsetY -= (short)centery;
                        if (m_SortedTiles[i].m_OffsetX < m_Min.X)
                        {
                            m_Min.X = m_SortedTiles[i].m_OffsetX;
                        }
                        if (m_SortedTiles[i].m_OffsetX > m_Max.X)
                        {
                            m_Max.X = m_SortedTiles[i].m_OffsetX;
                        }

                        if (m_SortedTiles[i].m_OffsetY < m_Min.Y)
                        {
                            m_Min.Y = m_SortedTiles[i].m_OffsetY;
                        }
                        if (m_SortedTiles[i].m_OffsetY > m_Max.Y)
                        {
                            m_Max.Y = m_SortedTiles[i].m_OffsetY;
                        }
                    }
                }

                break;

            case Multis.ImportType.UOA:
                itemcount = 0;

                using (StreamReader ip = new StreamReader(FileName))
                {
                    string line;
                    while ((line = ip.ReadLine()) != null)
                    {
                        ++itemcount;
                        if (itemcount == 4)
                        {
                            string[] split = line.Split(' ');
                            itemcount = Convert.ToInt32(split[0]);
                            break;
                        }
                    }
                }

                m_SortedTiles = new MultiTileEntry[itemcount];
                itemcount     = 0;
                m_Min.X       = 10000;
                m_Min.Y       = 10000;
                using (StreamReader ip = new StreamReader(FileName))
                {
                    string line;
                    int    i = -1;
                    while ((line = ip.ReadLine()) != null)
                    {
                        ++i;
                        if (i < 4)
                        {
                            continue;
                        }
                        string[] split = line.Split(' ');

                        m_SortedTiles[itemcount].m_ItemID  = Convert.ToUInt16(split[0]);
                        m_SortedTiles[itemcount].m_OffsetX = Convert.ToInt16(split[1]);
                        m_SortedTiles[itemcount].m_OffsetY = Convert.ToInt16(split[2]);
                        m_SortedTiles[itemcount].m_OffsetZ = Convert.ToInt16(split[3]);
                        m_SortedTiles[itemcount].m_Flags   = Convert.ToInt32(split[4]);
                        m_SortedTiles[itemcount].m_Unk1    = 0;

                        MultiTileEntry e = m_SortedTiles[itemcount];

                        if (e.m_OffsetX < m_Min.X)
                        {
                            m_Min.X = e.m_OffsetX;
                        }

                        if (e.m_OffsetY < m_Min.Y)
                        {
                            m_Min.Y = e.m_OffsetY;
                        }

                        if (e.m_OffsetX > m_Max.X)
                        {
                            m_Max.X = e.m_OffsetX;
                        }

                        if (e.m_OffsetY > m_Max.Y)
                        {
                            m_Max.Y = e.m_OffsetY;
                        }

                        if (e.m_OffsetZ > m_maxHeight)
                        {
                            m_maxHeight = e.m_OffsetZ;
                        }

                        ++itemcount;
                    }

                    int centerx = m_Max.X - (int)(Math.Round((m_Max.X - m_Min.X) / 2.0));
                    int centery = m_Max.Y - (int)(Math.Round((m_Max.Y - m_Min.Y) / 2.0));

                    m_Min = m_Max = Point.Empty;
                    i     = 0;
                    for (; i < m_SortedTiles.Length; ++i)
                    {
                        m_SortedTiles[i].m_OffsetX -= (short)centerx;
                        m_SortedTiles[i].m_OffsetY -= (short)centery;
                        if (m_SortedTiles[i].m_OffsetX < m_Min.X)
                        {
                            m_Min.X = m_SortedTiles[i].m_OffsetX;
                        }
                        if (m_SortedTiles[i].m_OffsetX > m_Max.X)
                        {
                            m_Max.X = m_SortedTiles[i].m_OffsetX;
                        }

                        if (m_SortedTiles[i].m_OffsetY < m_Min.Y)
                        {
                            m_Min.Y = m_SortedTiles[i].m_OffsetY;
                        }
                        if (m_SortedTiles[i].m_OffsetY > m_Max.Y)
                        {
                            m_Max.Y = m_SortedTiles[i].m_OffsetY;
                        }
                    }
                }

                break;

            case Multis.ImportType.UOAB:
                using (FileStream fs = new FileStream(FileName, FileMode.Open, FileAccess.Read, FileShare.Read))
                    using (BinaryReader reader = new BinaryReader(fs))
                    {
                        if (reader.ReadInt16() != 1) //Version check
                        {
                            return;
                        }
                        string tmp;
                        tmp = Multis.ReadUOAString(reader); //Name
                        tmp = Multis.ReadUOAString(reader); //Category
                        tmp = Multis.ReadUOAString(reader); //Subsection
                        int width   = reader.ReadInt32();
                        int height  = reader.ReadInt32();
                        int uwidth  = reader.ReadInt32();
                        int uheight = reader.ReadInt32();

                        int count = reader.ReadInt32();
                        itemcount     = count;
                        m_SortedTiles = new MultiTileEntry[itemcount];
                        itemcount     = 0;
                        m_Min.X       = 10000;
                        m_Min.Y       = 10000;
                        for (; itemcount < count; ++itemcount)
                        {
                            m_SortedTiles[itemcount].m_ItemID  = (ushort)reader.ReadInt16();
                            m_SortedTiles[itemcount].m_OffsetX = reader.ReadInt16();
                            m_SortedTiles[itemcount].m_OffsetY = reader.ReadInt16();
                            m_SortedTiles[itemcount].m_OffsetZ = reader.ReadInt16();
                            reader.ReadInt16(); // level
                            m_SortedTiles[itemcount].m_Flags = 1;
                            reader.ReadInt16(); // hue
                            m_SortedTiles[itemcount].m_Unk1 = 0;

                            MultiTileEntry e = m_SortedTiles[itemcount];

                            if (e.m_OffsetX < m_Min.X)
                            {
                                m_Min.X = e.m_OffsetX;
                            }

                            if (e.m_OffsetY < m_Min.Y)
                            {
                                m_Min.Y = e.m_OffsetY;
                            }

                            if (e.m_OffsetX > m_Max.X)
                            {
                                m_Max.X = e.m_OffsetX;
                            }

                            if (e.m_OffsetY > m_Max.Y)
                            {
                                m_Max.Y = e.m_OffsetY;
                            }

                            if (e.m_OffsetZ > m_maxHeight)
                            {
                                m_maxHeight = e.m_OffsetZ;
                            }
                        }

                        int centerx = m_Max.X - (int)(Math.Round((m_Max.X - m_Min.X) / 2.0));
                        int centery = m_Max.Y - (int)(Math.Round((m_Max.Y - m_Min.Y) / 2.0));

                        m_Min     = m_Max = Point.Empty;
                        itemcount = 0;
                        for (; itemcount < m_SortedTiles.Length; ++itemcount)
                        {
                            m_SortedTiles[itemcount].m_OffsetX -= (short)centerx;
                            m_SortedTiles[itemcount].m_OffsetY -= (short)centery;
                            if (m_SortedTiles[itemcount].m_OffsetX < m_Min.X)
                            {
                                m_Min.X = m_SortedTiles[itemcount].m_OffsetX;
                            }
                            if (m_SortedTiles[itemcount].m_OffsetX > m_Max.X)
                            {
                                m_Max.X = m_SortedTiles[itemcount].m_OffsetX;
                            }

                            if (m_SortedTiles[itemcount].m_OffsetY < m_Min.Y)
                            {
                                m_Min.Y = m_SortedTiles[itemcount].m_OffsetY;
                            }
                            if (m_SortedTiles[itemcount].m_OffsetY > m_Max.Y)
                            {
                                m_Max.Y = m_SortedTiles[itemcount].m_OffsetY;
                            }
                        }
                    }

                break;

            case Multis.ImportType.WSC:
                itemcount = 0;
                using (StreamReader ip = new StreamReader(FileName))
                {
                    string line;
                    while ((line = ip.ReadLine()) != null)
                    {
                        line = line.Trim();
                        if (line.StartsWith("SECTION WORLDITEM"))
                        {
                            ++itemcount;
                        }
                    }
                }

                m_SortedTiles = new MultiTileEntry[itemcount];
                itemcount     = 0;
                m_Min.X       = 10000;
                m_Min.Y       = 10000;
                using (StreamReader ip = new StreamReader(FileName))
                {
                    string         line;
                    MultiTileEntry tempitem = new MultiTileEntry();
                    tempitem.m_ItemID = 0xFFFF;
                    tempitem.m_Flags  = 1;
                    tempitem.m_Unk1   = 0;
                    while ((line = ip.ReadLine()) != null)
                    {
                        line = line.Trim();
                        if (line.StartsWith("SECTION WORLDITEM"))
                        {
                            if (tempitem.m_ItemID != 0xFFFF)
                            {
                                m_SortedTiles[itemcount] = tempitem;
                                ++itemcount;
                            }

                            tempitem.m_ItemID = 0xFFFF;
                        }
                        else if (line.StartsWith("ID"))
                        {
                            line = line.Remove(0, 2);
                            line = line.Trim();
                            tempitem.m_ItemID = Convert.ToUInt16(line);
                        }
                        else if (line.StartsWith("X"))
                        {
                            line = line.Remove(0, 1);
                            line = line.Trim();
                            tempitem.m_OffsetX = Convert.ToInt16(line);
                            if (tempitem.m_OffsetX < m_Min.X)
                            {
                                m_Min.X = tempitem.m_OffsetX;
                            }
                            if (tempitem.m_OffsetX > m_Max.X)
                            {
                                m_Max.X = tempitem.m_OffsetX;
                            }
                        }
                        else if (line.StartsWith("Y"))
                        {
                            line = line.Remove(0, 1);
                            line = line.Trim();
                            tempitem.m_OffsetY = Convert.ToInt16(line);
                            if (tempitem.m_OffsetY < m_Min.Y)
                            {
                                m_Min.Y = tempitem.m_OffsetY;
                            }
                            if (tempitem.m_OffsetY > m_Max.Y)
                            {
                                m_Max.Y = tempitem.m_OffsetY;
                            }
                        }
                        else if (line.StartsWith("Z"))
                        {
                            line = line.Remove(0, 1);
                            line = line.Trim();
                            tempitem.m_OffsetZ = Convert.ToInt16(line);
                            if (tempitem.m_OffsetZ > m_maxHeight)
                            {
                                m_maxHeight = tempitem.m_OffsetZ;
                            }
                        }
                    }

                    if (tempitem.m_ItemID != 0xFFFF)
                    {
                        m_SortedTiles[itemcount] = tempitem;
                    }

                    int centerx = m_Max.X - (int)(Math.Round((m_Max.X - m_Min.X) / 2.0));
                    int centery = m_Max.Y - (int)(Math.Round((m_Max.Y - m_Min.Y) / 2.0));

                    m_Min = m_Max = Point.Empty;
                    int i = 0;
                    for (; i < m_SortedTiles.Length; i++)
                    {
                        m_SortedTiles[i].m_OffsetX -= (short)centerx;
                        m_SortedTiles[i].m_OffsetY -= (short)centery;
                        if (m_SortedTiles[i].m_OffsetX < m_Min.X)
                        {
                            m_Min.X = m_SortedTiles[i].m_OffsetX;
                        }
                        if (m_SortedTiles[i].m_OffsetX > m_Max.X)
                        {
                            m_Max.X = m_SortedTiles[i].m_OffsetX;
                        }

                        if (m_SortedTiles[i].m_OffsetY < m_Min.Y)
                        {
                            m_Min.Y = m_SortedTiles[i].m_OffsetY;
                        }
                        if (m_SortedTiles[i].m_OffsetY > m_Max.Y)
                        {
                            m_Max.Y = m_SortedTiles[i].m_OffsetY;
                        }
                    }
                }

                break;
            }

            ConvertList();
        }
示例#27
0
        public MultiComponentList(string fileName, Multis.ImportType type)
        {
            _min = _max = Point.Empty;

            int itemCount;

            switch (type)
            {
            case Multis.ImportType.TXT:
            {
                itemCount = 0;
                using (var ip = new StreamReader(fileName))
                {
                    while (ip.ReadLine() != null)
                    {
                        itemCount++;
                    }
                }
                SortedTiles = new MultiTileEntry[itemCount];
                itemCount   = 0;
                _min.X      = 10000;
                _min.Y      = 10000;
                using (var ip = new StreamReader(fileName))
                {
                    string line;
                    while ((line = ip.ReadLine()) != null)
                    {
                        string[] split = line.Split(' ');

                        string tmp = split[0];
                        tmp = tmp.Replace("0x", "");

                        SortedTiles[itemCount].m_ItemID  = ushort.Parse(tmp, System.Globalization.NumberStyles.HexNumber);
                        SortedTiles[itemCount].m_OffsetX = Convert.ToInt16(split[1]);
                        SortedTiles[itemCount].m_OffsetY = Convert.ToInt16(split[2]);
                        SortedTiles[itemCount].m_OffsetZ = Convert.ToInt16(split[3]);
                        SortedTiles[itemCount].m_Flags   = Convert.ToInt32(split[4]);
                        SortedTiles[itemCount].m_Unk1    = 0;

                        MultiTileEntry e = SortedTiles[itemCount];

                        if (e.m_OffsetX < _min.X)
                        {
                            _min.X = e.m_OffsetX;
                        }

                        if (e.m_OffsetY < _min.Y)
                        {
                            _min.Y = e.m_OffsetY;
                        }

                        if (e.m_OffsetX > _max.X)
                        {
                            _max.X = e.m_OffsetX;
                        }

                        if (e.m_OffsetY > _max.Y)
                        {
                            _max.Y = e.m_OffsetY;
                        }

                        if (e.m_OffsetZ > MaxHeight)
                        {
                            MaxHeight = e.m_OffsetZ;
                        }

                        itemCount++;
                    }
                    int centerX = _max.X - (int)(Math.Round((_max.X - _min.X) / 2.0));
                    int centerY = _max.Y - (int)(Math.Round((_max.Y - _min.Y) / 2.0));

                    _min = _max = Point.Empty;
                    int i = 0;
                    for (; i < SortedTiles.Length; i++)
                    {
                        SortedTiles[i].m_OffsetX -= (short)centerX;
                        SortedTiles[i].m_OffsetY -= (short)centerY;
                        if (SortedTiles[i].m_OffsetX < _min.X)
                        {
                            _min.X = SortedTiles[i].m_OffsetX;
                        }

                        if (SortedTiles[i].m_OffsetX > _max.X)
                        {
                            _max.X = SortedTiles[i].m_OffsetX;
                        }

                        if (SortedTiles[i].m_OffsetY < _min.Y)
                        {
                            _min.Y = SortedTiles[i].m_OffsetY;
                        }

                        if (SortedTiles[i].m_OffsetY > _max.Y)
                        {
                            _max.Y = SortedTiles[i].m_OffsetY;
                        }
                    }
                }
                break;
            }

            case Multis.ImportType.UOA:
            {
                itemCount = 0;

                using (var ip = new StreamReader(fileName))
                {
                    string line;
                    while ((line = ip.ReadLine()) != null)
                    {
                        ++itemCount;

                        if (itemCount != 4)
                        {
                            continue;
                        }

                        string[] split = line.Split(' ');
                        itemCount = Convert.ToInt32(split[0]);
                        break;
                    }
                }
                SortedTiles = new MultiTileEntry[itemCount];
                itemCount   = 0;
                _min.X      = 10000;
                _min.Y      = 10000;
                using (var ip = new StreamReader(fileName))
                {
                    string line;
                    int    i = -1;
                    while ((line = ip.ReadLine()) != null)
                    {
                        ++i;
                        if (i < 4)
                        {
                            continue;
                        }

                        string[] split = line.Split(' ');

                        SortedTiles[itemCount].m_ItemID  = Convert.ToUInt16(split[0]);
                        SortedTiles[itemCount].m_OffsetX = Convert.ToInt16(split[1]);
                        SortedTiles[itemCount].m_OffsetY = Convert.ToInt16(split[2]);
                        SortedTiles[itemCount].m_OffsetZ = Convert.ToInt16(split[3]);
                        SortedTiles[itemCount].m_Flags   = Convert.ToInt32(split[4]);
                        SortedTiles[itemCount].m_Unk1    = 0;

                        MultiTileEntry e = SortedTiles[itemCount];

                        if (e.m_OffsetX < _min.X)
                        {
                            _min.X = e.m_OffsetX;
                        }

                        if (e.m_OffsetY < _min.Y)
                        {
                            _min.Y = e.m_OffsetY;
                        }

                        if (e.m_OffsetX > _max.X)
                        {
                            _max.X = e.m_OffsetX;
                        }

                        if (e.m_OffsetY > _max.Y)
                        {
                            _max.Y = e.m_OffsetY;
                        }

                        if (e.m_OffsetZ > MaxHeight)
                        {
                            MaxHeight = e.m_OffsetZ;
                        }

                        ++itemCount;
                    }

                    int centerX = _max.X - (int)(Math.Round((_max.X - _min.X) / 2.0));
                    int centerY = _max.Y - (int)(Math.Round((_max.Y - _min.Y) / 2.0));

                    _min = _max = Point.Empty;
                    i    = 0;
                    for (; i < SortedTiles.Length; ++i)
                    {
                        SortedTiles[i].m_OffsetX -= (short)centerX;
                        SortedTiles[i].m_OffsetY -= (short)centerY;
                        if (SortedTiles[i].m_OffsetX < _min.X)
                        {
                            _min.X = SortedTiles[i].m_OffsetX;
                        }

                        if (SortedTiles[i].m_OffsetX > _max.X)
                        {
                            _max.X = SortedTiles[i].m_OffsetX;
                        }

                        if (SortedTiles[i].m_OffsetY < _min.Y)
                        {
                            _min.Y = SortedTiles[i].m_OffsetY;
                        }

                        if (SortedTiles[i].m_OffsetY > _max.Y)
                        {
                            _max.Y = SortedTiles[i].m_OffsetY;
                        }
                    }
                }

                break;
            }

            case Multis.ImportType.UOAB:
            {
                using (var fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
                    using (var reader = new BinaryReader(fs))
                    {
                        if (reader.ReadInt16() != 1) // Version check
                        {
                            return;
                        }

                        _ = Multis.ReadUOAString(reader);
                        _ = Multis.ReadUOAString(reader); // Category
                        _ = Multis.ReadUOAString(reader); // Subsection

                        _ = reader.ReadInt32();
                        _ = reader.ReadInt32();
                        _ = reader.ReadInt32();
                        _ = reader.ReadInt32();

                        int count = reader.ReadInt32();
                        itemCount   = count;
                        SortedTiles = new MultiTileEntry[itemCount];
                        itemCount   = 0;
                        _min.X      = 10000;
                        _min.Y      = 10000;
                        for (; itemCount < count; ++itemCount)
                        {
                            SortedTiles[itemCount].m_ItemID  = (ushort)reader.ReadInt16();
                            SortedTiles[itemCount].m_OffsetX = reader.ReadInt16();
                            SortedTiles[itemCount].m_OffsetY = reader.ReadInt16();
                            SortedTiles[itemCount].m_OffsetZ = reader.ReadInt16();
                            reader.ReadInt16(); // level
                            SortedTiles[itemCount].m_Flags = 1;
                            reader.ReadInt16(); // hue
                            SortedTiles[itemCount].m_Unk1 = 0;

                            MultiTileEntry e = SortedTiles[itemCount];

                            if (e.m_OffsetX < _min.X)
                            {
                                _min.X = e.m_OffsetX;
                            }

                            if (e.m_OffsetY < _min.Y)
                            {
                                _min.Y = e.m_OffsetY;
                            }

                            if (e.m_OffsetX > _max.X)
                            {
                                _max.X = e.m_OffsetX;
                            }

                            if (e.m_OffsetY > _max.Y)
                            {
                                _max.Y = e.m_OffsetY;
                            }

                            if (e.m_OffsetZ > MaxHeight)
                            {
                                MaxHeight = e.m_OffsetZ;
                            }
                        }
                        int centerx = _max.X - (int)(Math.Round((_max.X - _min.X) / 2.0));
                        int centery = _max.Y - (int)(Math.Round((_max.Y - _min.Y) / 2.0));

                        _min      = _max = Point.Empty;
                        itemCount = 0;
                        for (; itemCount < SortedTiles.Length; ++itemCount)
                        {
                            SortedTiles[itemCount].m_OffsetX -= (short)centerx;
                            SortedTiles[itemCount].m_OffsetY -= (short)centery;
                            if (SortedTiles[itemCount].m_OffsetX < _min.X)
                            {
                                _min.X = SortedTiles[itemCount].m_OffsetX;
                            }

                            if (SortedTiles[itemCount].m_OffsetX > _max.X)
                            {
                                _max.X = SortedTiles[itemCount].m_OffsetX;
                            }

                            if (SortedTiles[itemCount].m_OffsetY < _min.Y)
                            {
                                _min.Y = SortedTiles[itemCount].m_OffsetY;
                            }

                            if (SortedTiles[itemCount].m_OffsetY > _max.Y)
                            {
                                _max.Y = SortedTiles[itemCount].m_OffsetY;
                            }
                        }
                    }
                break;
            }

            case Multis.ImportType.WSC:
            {
                itemCount = 0;
                using (var ip = new StreamReader(fileName))
                {
                    string line;
                    while ((line = ip.ReadLine()) != null)
                    {
                        line = line.Trim();
                        if (line.StartsWith("SECTION WORLDITEM"))
                        {
                            ++itemCount;
                        }
                    }
                }
                SortedTiles = new MultiTileEntry[itemCount];
                itemCount   = 0;
                _min.X      = 10000;
                _min.Y      = 10000;
                using (var ip = new StreamReader(fileName))
                {
                    string line;
                    var    tempItem = new MultiTileEntry
                    {
                        m_ItemID = 0xFFFF,
                        m_Flags  = 1,
                        m_Unk1   = 0
                    };

                    while ((line = ip.ReadLine()) != null)
                    {
                        line = line.Trim();
                        if (line.StartsWith("SECTION WORLDITEM"))
                        {
                            if (tempItem.m_ItemID != 0xFFFF)
                            {
                                SortedTiles[itemCount] = tempItem;
                                ++itemCount;
                            }
                            tempItem.m_ItemID = 0xFFFF;
                        }
                        else if (line.StartsWith("ID"))
                        {
                            line = line.Remove(0, 2);
                            line = line.Trim();
                            tempItem.m_ItemID = Convert.ToUInt16(line);
                        }
                        else if (line.StartsWith("X"))
                        {
                            line = line.Remove(0, 1);
                            line = line.Trim();
                            tempItem.m_OffsetX = Convert.ToInt16(line);
                            if (tempItem.m_OffsetX < _min.X)
                            {
                                _min.X = tempItem.m_OffsetX;
                            }

                            if (tempItem.m_OffsetX > _max.X)
                            {
                                _max.X = tempItem.m_OffsetX;
                            }
                        }
                        else if (line.StartsWith("Y"))
                        {
                            line = line.Remove(0, 1);
                            line = line.Trim();
                            tempItem.m_OffsetY = Convert.ToInt16(line);
                            if (tempItem.m_OffsetY < _min.Y)
                            {
                                _min.Y = tempItem.m_OffsetY;
                            }

                            if (tempItem.m_OffsetY > _max.Y)
                            {
                                _max.Y = tempItem.m_OffsetY;
                            }
                        }
                        else if (line.StartsWith("Z"))
                        {
                            line = line.Remove(0, 1);
                            line = line.Trim();
                            tempItem.m_OffsetZ = Convert.ToInt16(line);
                            if (tempItem.m_OffsetZ > MaxHeight)
                            {
                                MaxHeight = tempItem.m_OffsetZ;
                            }
                        }
                    }
                    if (tempItem.m_ItemID != 0xFFFF)
                    {
                        SortedTiles[itemCount] = tempItem;
                    }

                    int centerX = _max.X - (int)(Math.Round((_max.X - _min.X) / 2.0));
                    int centerY = _max.Y - (int)(Math.Round((_max.Y - _min.Y) / 2.0));

                    _min = _max = Point.Empty;
                    int i = 0;
                    for (; i < SortedTiles.Length; i++)
                    {
                        SortedTiles[i].m_OffsetX -= (short)centerX;
                        SortedTiles[i].m_OffsetY -= (short)centerY;
                        if (SortedTiles[i].m_OffsetX < _min.X)
                        {
                            _min.X = SortedTiles[i].m_OffsetX;
                        }

                        if (SortedTiles[i].m_OffsetX > _max.X)
                        {
                            _max.X = SortedTiles[i].m_OffsetX;
                        }

                        if (SortedTiles[i].m_OffsetY < _min.Y)
                        {
                            _min.Y = SortedTiles[i].m_OffsetY;
                        }

                        if (SortedTiles[i].m_OffsetY > _max.Y)
                        {
                            _max.Y = SortedTiles[i].m_OffsetY;
                        }
                    }
                }
                break;
            }
            }
            ConvertList();
        }