private static void PlayerMoving( object sender, PlayerMovingEventArgs e )
{
if ( _world != null && e.Player.World == _world ) {
if ( _world.gameMode == GameMode.MineField && !Failed.Contains( e.Player ) ) {
if ( e.NewPosition != null ) {
Vector3I oldPos = new Vector3I( e.OldPosition.X / 32, e.OldPosition.Y / 32, e.OldPosition.Z / 32 );
Vector3I newPos = new Vector3I( e.NewPosition.X / 32, e.NewPosition.Y / 32, e.NewPosition.Z / 32 );
if ( oldPos.X != newPos.X || oldPos.Y != newPos.Y || oldPos.Z != newPos.Z ) {
if ( !_map.InBounds( newPos ) ) {
e.Player.TeleportTo( _map.Spawn );
newPos = ( Vector3I )_map.Spawn;
}
// Check if the player jumped, flew, whatevers
if ( newPos.Z > _ground + 2 ) {
e.Player.TeleportTo( e.OldPosition );
newPos = oldPos;
}
foreach ( Vector3I pos in Mines.Values ) {
if ( newPos == new Vector3I( pos.X, pos.Y, pos.Z + 2 ) ||
newPos == new Vector3I( pos.X, pos.Y, pos.Z + 1 ) ||
newPos == new Vector3I( pos.X, pos.Y, pos.Z ) ) {
_world.Map.QueueUpdate( new BlockUpdate( null, pos, Block.TNT ) );
_world.AddPhysicsTask( new TNTTask( _world, pos, null, true, false ), 0 );
Vector3I removed;
Mines.TryRemove( pos.ToString(), out removed );
}
}
if ( _map.GetBlock( newPos.X, newPos.Y, newPos.Z - 2 ) == Block.Green
&& !_stopped ) {
_stopped = true;
Stop( e.Player, true );
}
}
}
}
}
}