本文整理汇总了C#中Server.Map.Bound方法的典型用法代码示例。如果您正苦于以下问题:C# Map.Bound方法的具体用法?C# Map.Bound怎么用?C# Map.Bound使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Server.Map
的用法示例。
在下文中一共展示了Map.Bound方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Freeze
public static void Freeze( Mobile from, Map targetMap, Point3D start3d, Point3D end3d )
{
Hashtable mapTable = new Hashtable();
if ( start3d == NullP3D && end3d == NullP3D )
{
if ( targetMap == null )
CommandLogging.WriteLine( from, "{0} {1} invoking freeze for every item in every map", from.AccessLevel, CommandLogging.Format( from ) );
else
CommandLogging.WriteLine( from, "{0} {1} invoking freeze for every item in {0}", from.AccessLevel, CommandLogging.Format( from ), targetMap );
foreach ( Item item in World.Items.Values )
{
if ( targetMap != null && item.Map != targetMap )
continue;
if ( item.Parent != null )
continue;
if ( item is Static || item is BaseFloor || item is BaseWall )
{
Map itemMap = item.Map;
if ( itemMap == null || itemMap == Map.Internal )
continue;
Hashtable table = (Hashtable)mapTable[itemMap];
if ( table == null )
mapTable[itemMap] = table = new Hashtable();
Point2D p = new Point2D( item.X >> 3, item.Y >> 3 );
DeltaState state = (DeltaState)table[p];
if ( state == null )
table[p] = state = new DeltaState( p );
state.m_List.Add( item );
}
}
}
else if ( targetMap != null )
{
Point2D start = targetMap.Bound( new Point2D( start3d ) ), end = targetMap.Bound( new Point2D( end3d ) );
CommandLogging.WriteLine( from, "{0} {1} invoking freeze from {2} to {3} in {4}", from.AccessLevel, CommandLogging.Format( from ), start, end, targetMap );
IPooledEnumerable eable = targetMap.GetItemsInBounds( new Rectangle2D( start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1 ) );
foreach ( Item item in eable )
{
if ( item is Static || item is BaseFloor || item is BaseWall )
{
Map itemMap = item.Map;
if ( itemMap == null || itemMap == Map.Internal )
continue;
Hashtable table = (Hashtable)mapTable[itemMap];
if ( table == null )
mapTable[itemMap] = table = new Hashtable();
Point2D p = new Point2D( item.X >> 3, item.Y >> 3 );
DeltaState state = (DeltaState)table[p];
if ( state == null )
table[p] = state = new DeltaState( p );
state.m_List.Add( item );
}
}
eable.Free();
}
if ( mapTable.Count == 0 )
{
from.SendGump( new NoticeGump( 1060637, 30720, "No freezable items were found. Only the following item types are frozen:<br> - Static<br> - BaseFloor<br> - BaseWall", 0xFFC000, 320, 240, null, null ) );
return;
}
bool badDataFile = false;
int totalFrozen = 0;
foreach ( DictionaryEntry de in mapTable )
{
Map map = (Map)de.Key;
Hashtable table = (Hashtable)de.Value;
TileMatrix matrix = map.Tiles;
using ( FileStream idxStream = OpenWrite( matrix.IndexStream ) )
{
using ( FileStream mulStream = OpenWrite( matrix.DataStream ) )
{
if ( idxStream == null || mulStream == null )
//.........这里部分代码省略.........
示例2: DoUnfreeze
private static void DoUnfreeze( Map map, Point2D start, Point2D end, ref bool badDataFile, ref int totalUnfrozen )
{
start = map.Bound( start );
end = map.Bound( end );
int xStartBlock = start.X >> 3;
int yStartBlock = start.Y >> 3;
int xEndBlock = end.X >> 3;
int yEndBlock = end.Y >> 3;
int xTileStart = start.X, yTileStart = start.Y;
int xTileWidth = end.X - start.X + 1, yTileHeight = end.Y - start.Y + 1;
TileMatrix matrix = map.Tiles;
using ( FileStream idxStream = OpenWrite( matrix.IndexStream ) )
{
using ( FileStream mulStream = OpenWrite( matrix.DataStream ) )
{
if ( idxStream == null || mulStream == null )
{
badDataFile = true;
return;
}
BinaryReader idxReader = new BinaryReader( idxStream );
BinaryWriter idxWriter = new BinaryWriter( idxStream );
BinaryWriter mulWriter = new BinaryWriter( mulStream );
for ( int x = xStartBlock; x <= xEndBlock; ++x )
{
for ( int y = yStartBlock; y <= yEndBlock; ++y )
{
int oldTileCount;
StaticTile[] oldTiles = ReadStaticBlock( idxReader, mulStream, x, y, matrix.BlockWidth, matrix.BlockHeight, out oldTileCount );
if ( oldTileCount < 0 )
continue;
int newTileCount = 0;
StaticTile[] newTiles = new StaticTile[oldTileCount];
int baseX = (x << 3) - xTileStart, baseY = (y << 3) - yTileStart;
for ( int i = 0; i < oldTileCount; ++i )
{
StaticTile oldTile = oldTiles[i];
int px = baseX + oldTile.m_X;
int py = baseY + oldTile.m_Y;
if ( px < 0 || px >= xTileWidth || py < 0 || py >= yTileHeight )
{
newTiles[newTileCount++] = oldTile;
}
else
{
++totalUnfrozen;
Item item = new Static( oldTile.m_ID & 0x3FFF );
item.Hue = oldTile.m_Hue;
item.MoveToWorld( new Point3D( px + xTileStart, py + yTileStart, oldTile.m_Z ), map );
}
}
int mulPos = -1;
int length = -1;
int extra = 0;
if ( newTileCount > 0 )
{
mulWriter.Seek( 0, SeekOrigin.End );
mulPos = (int)mulWriter.BaseStream.Position;
length = newTileCount * 7;
extra = 1;
for ( int i = 0; i < newTileCount; ++i )
{
StaticTile toWrite = newTiles[i];
mulWriter.Write( (short) toWrite.m_ID );
mulWriter.Write( (byte) toWrite.m_X );
mulWriter.Write( (byte) toWrite.m_Y );
mulWriter.Write( (sbyte) toWrite.m_Z );
mulWriter.Write( (short) toWrite.m_Hue );
}
mulWriter.Flush();
}
int idxPos = ((x * matrix.BlockHeight) + y) * 12;
idxWriter.Seek( idxPos, SeekOrigin.Begin );
idxWriter.Write( mulPos );
idxWriter.Write( length );
idxWriter.Write( extra );
//.........这里部分代码省略.........