public LandblockStruct(CellLandblock landblock) { Init(); Height = landblock.Height; Terrain = landblock.Terrain; // originally called from LScape.update_block() Generate(landblock.Id, 1, LandDefs.Direction.Unknown); }
/// <summary> /// Returns TRUE if x,y is located on a road cell /// </summary> public static bool OnRoad(ObjectDesc obj, CellLandblock landblock, float x, float y) { var cellX = (int)Math.Floor(x / LandblockMesh.CellSize); var cellY = (int)Math.Floor(y / LandblockMesh.CellSize); var terrain = landblock.Terrain[cellX * LandblockMesh.CellDim + cellY]; // ensure within bounds? return((terrain & 0x3) != 0); // TODO: more complicated check for within road range }
public Mapper() { FoundLandblocks = 0; for (var x = 0; x < LANDSIZE; x++) { for (var y = 0; y < LANDSIZE; y++) { land[x, y] = new LandData(); } } Parallel.For(0, 255 * 255, i => { var block_x = i / 255; var block_y = i % 255; var key = (uint)(block_x << 24 | block_y << 16 | 0xFFFF); if (DatManager.CellDat.AllFiles.ContainsKey(key)) // Ensures we either have a full cell, or prevents crashes { CellLandblock landblock = DatManager.CellDat.ReadFromDat <CellLandblock>(key); int startX = block_x * 8; int startY = LANDSIZE - block_y * 8 - 1; for (var x = 0; x < 9; x++) { for (var y = 0; y < 9; y++) { var type = landblock.Terrain[x * 9 + y]; var newZ = landblock.Height[x * 9 + y]; // Write new data point land[startY - y, startX + x].Type = type; land[startY - y, startX + x].Z = GetLandheight(newZ); land[startY - y, startX + x].Used = true; uint itex = (uint)((type >> 2) & 0x3F); if (itex < 16 || itex > 20) { land[startY - y, startX + x].Blocked = false; } else { land[startY - y, startX + x].Blocked = true; } } } FoundLandblocks++; } }); CreateMap(); }
/// <summary> /// Loads the meshes for the landblock /// </summary> public void LoadMeshes(List <AceObject> objects) { CellLandblock = DatManager.CellDat.ReadFromDat <CellLandblock>(Id.Raw | 0xFFFF); LandblockInfo = DatManager.CellDat.ReadFromDat <LandblockInfo>((uint)Id.Landblock << 16 | 0xFFFE); LandblockMesh = new LandblockMesh(Id); LoadLandObjects(); LoadBuildings(); LoadWeenies(objects); LoadScenery(); }
public Landblock(CellLandblock landblock) : base(landblock) { Init(); ID = landblock.Id; BlockInfoExists = landblock.HasObjects; if (BlockInfoExists) { Info = (LandblockInfo)DBObj.Get(new QualifiedDataID(2, ID - 1)); } BlockCoord = LandDefs.blockid_to_lcoord(landblock.Id).Value; _landblock = landblock; get_land_limits(); }
public Landblock(CellLandblock landblock) : base(landblock) { Init(); ID = landblock.Id; //Console.WriteLine("Loading landblock " + ID.ToString("X8")); BlockInfoExists = landblock.HasObjects; if (BlockInfoExists) { Info = DBObj.GetLandblockInfo(ID - 1); } BlockCoord = LandDefs.blockid_to_lcoord(landblock.Id).Value; _landblock = landblock; get_land_limits(); }
public Mapper(List <Color> MapColors = null) { FoundLandblocks = 0; foreach (var entry in DatManager.CellDat.AllFiles) { if ((entry.Key & 0x0000FFFF) == 0x0000FFFF) { var block_x = entry.Key >> 24; var block_y = (entry.Key & 0x00FF0000) >> 16; int startX = (int)(block_x * 8); int startY = (int)(LANDSIZE - block_y * 8 - 1); CellLandblock landblock = DatManager.CellDat.ReadFromDat <CellLandblock>(entry.Key); for (var x = 0; x < 9; x++) { for (var y = 0; y < 9; y++) { var type = landblock.Terrain[x * 9 + y]; var newZ = landblock.Height[x * 9 + y]; // Write new data point land[startY - y, startX + x].Type = type; land[startY - y, startX + x].Z = RegionHelper.GetLandheight(newZ); land[startY - y, startX + x].Used = true; uint itex = (uint)((type >> 2) & 0x3F); if (itex < 16 || itex > 20) { land[startY - y, startX + x].Blocked = false; } else { land[startY - y, startX + x].Blocked = true; } } } FoundLandblocks++; } } CreateMap(MapColors); }