public bool VisitBlock( World world, Vector3I pos, Block block, Player owner, ref int restDistance, IList<BlockUpdate> updates, Block sending )
{
if ( Block.Air != block ) //hit a building
{
if ( owner.bluePortal.Count > 0 ) {
if ( pos == owner.bluePortal[0] || pos == owner.bluePortal[1] ) {
return false;
}
}
if ( owner.orangePortal.Count > 0 ) {
if ( pos == owner.orangePortal[0] || pos == owner.orangePortal[1] ) {
return false;
}
}
//blue portal
if ( sending == Block.Water ) {
if ( CanPlacePortal( pos.X, pos.Y, pos.Z, world.Map ) ) {
if ( owner.bluePortal.Count > 0 ) {
int i = 0;
foreach ( Vector3I b in owner.bluePortal ) {
world.Map.QueueUpdate( new BlockUpdate( null, b, owner.blueOld[i] ) );
i++;
}
owner.blueOld.Clear();
owner.bluePortal.Clear();
}
owner.blueOld.Add( world.Map.GetBlock( pos ) );
owner.blueOld.Add( world.Map.GetBlock( pos.X, pos.Y, pos.Z + 1 ) );
owner.orangeOut = owner.Position.R;
for ( double z = pos.Z; z < pos.Z + 2; z++ ) {
world.Map.QueueUpdate( new BlockUpdate( null, ( short )( pos.X ), ( short )( pos.Y ), ( short )z, Block.Water ) );
owner.bluePortal.Add( new Vector3I( ( int )pos.X, ( int )pos.Y, ( int )z ) );
}
return false;
} else {
return false;
}
}
//orange portal
else if ( sending == Block.Lava ) {
if ( CanPlacePortal( pos.X, pos.Y, pos.Z, world.Map ) ) {
if ( owner.orangePortal.Count > 0 ) {
int i = 0;
foreach ( Vector3I b in owner.orangePortal ) {
world.Map.QueueUpdate( new BlockUpdate( null, b, owner.orangeOld[i] ) );
i++;
}
owner.orangeOld.Clear();
owner.orangePortal.Clear();
}
owner.orangeOld.Add( world.Map.GetBlock( pos ) );
owner.orangeOld.Add( world.Map.GetBlock( pos.X, pos.Y, pos.Z + 1 ) );
owner.blueOut = owner.Position.R;
for ( double z = pos.Z; z < pos.Z + 2; z++ ) {
world.Map.QueueUpdate( new BlockUpdate( null, ( short )( pos.X ), ( short )( pos.Y ), ( short )z, Block.Lava ) );
owner.orangePortal.Add( new Vector3I( ( int )pos.X, ( int )pos.Y, ( int )z ) );
}
return false;
} else {
return false;
}
}
updates.Add( new BlockUpdate( null, pos, world.Map.GetBlock( pos ) ) ); //restore
restDistance = 0;
return false;
}
return true;
}