void Generate_Generic_LittleStructs( VoxelSector Sector, VoxelSector ObjectToPlace, GenericCharCanvas LocationMap, int Offset ) { int x, z, xs, ys, zs, GenerationRadius; //ZLightSpeedRandom Random; VoxelGfx_Tree TreeMaker = new VoxelGfx_Tree(); //int Seed; ushort ZoneType= 0 ; // uint RandNum; xs = Sector.Pos_x << VoxelSector.ZVOXELBLOCSHIFT_X; ys = Sector.Pos_y << VoxelSector.ZVOXELBLOCSHIFT_Y; zs = Sector.Pos_z << VoxelSector.ZVOXELBLOCSHIFT_Z; //Seed = xs + 3524*ys + 234 * zs; /* Sector.SetCube(0,20,0, 2); Sector.SetCube(15,20,15, 2); return; */ uint SizeMask; SizeMask = (uint)( LocationMap.Width - 1 ); GenerationRadius = 5; for( x = xs - GenerationRadius; x < ( xs + 16 + GenerationRadius ); x++ ) for( z = zs - GenerationRadius; z < ( zs + 16 + GenerationRadius ); z++ ) { //if ((RandNum = Random.GetNumber( abs(x) + ( abs(z) << 8 ) )) < (4194304 * 50)) // 6 // if ( (((x & 7) == 0) && ((z & 7) == 0)) ) if( LocationMap.GetPoint_Fast( (int)(SizeMask - ( ( x + Offset ) & SizeMask )), (int)(( z + Offset ) & SizeMask) ) > 128 ) { ZVector3L Position; ZVector3L OffsetRec; Position.x = x - xs; Position.z = z - zs; Position.y = GetZoneHeight( x, z, ZoneType ) - ys; OffsetRec.x = Position.x; OffsetRec.y = Position.y; OffsetRec.z = Position.z; OffsetRec.x -= T3dTemplate_1.Handle_x; OffsetRec.y -= T3dTemplate_1.Handle_y; OffsetRec.z -= T3dTemplate_1.Handle_z; if( OffsetRec.y < 74 && OffsetRec.y > -10 ) { // if ( (x== (75-512)) && (z==(103-512)) ) MANUAL_BREAKPOINT; // if (this.Canva_4.GetPoint_Secure(xs & 0xFF,zs & 0xFF)) Sector.BlitSector( ObjectToPlace, ref OffsetRec ); } } } }
void AddTreeOn( VoxelSector Sector, VoxelSector[] TemplateTable, uint ModelCount, ushort VoxelType ) { int x, y, z, i; uint Rnd; VoxelSector Template; ZVector3L Pos; i = 0; RandomGen.Reset(); random_seed[0] = i; random_seed[1] = 0; random_seed[2] = 0; random_seed[3] = 0; for( z = 0; z < VoxelSector.ZVOXELBLOCSIZE_Z; z++ ) for( x = 0; x < VoxelSector.ZVOXELBLOCSIZE_X; x++ ) for( y = 0; y < VoxelSector.ZVOXELBLOCSIZE_Y; y++ ) { random_seed[0] = i; Rnd = (uint)RandomGen.GetEntropy( 32, false ); if( Sector.Data.Data[i] == VoxelType && y < 60 && ( Rnd < 200000000 ) ) //100000000 { if( Sector.Data.Data[i + 1] == 0 ) { Template = TemplateTable[Rnd % ModelCount]; Pos.x = x - Template.Handle_x; Pos.y = y + 1 - Template.Handle_y; Pos.z = z - Template.Handle_z; //Sector.SetCube(Pos.x,Pos.y+1,Pos.z,1); Sector.BlitSector( Template, ref Pos ); } } i++; } }