parse floor tiles and height of blades outdoors

This commit is contained in:
2022-06-10 21:50:50 +00:00
parent f44ca0bb48
commit 6909db0e3f
2 changed files with 60 additions and 6 deletions

View File

@@ -7,8 +7,8 @@ import data.blades.TileMap;
using StringTools;
class Scenario {
public var outdoorSections:TileArray<TileMap>;
public var towns:Array<TileMap>;
public var outdoorSections:TileArray<TileMap> = [];
public var towns:Array<TileMap> = [];
public var name = "";
public var description1 = "";
public var description2 = "";
@@ -93,8 +93,45 @@ class Scenario {
stream.readCString(16*16-1)];
}];
// After the intro paragpraphs there are a lot of unknown bytes that could possibly be metadata of the first outdoor section's tiles
// 1D30 08 is the first outdoor section
stream.unknownUntil("0x1D38");
// outdoor section rows
for (y in 0...outdoorHeight) {
scen.outdoorSections[y] = [];
for (x in 0...outdoorWidth) {
var outdoorWidth = 48;
var outdoorHeight = 48;
// section name, max length 21, followed by floor tile columns
var sec = new TileMap(outdoorWidth, outdoorHeight, stream.readCString(19));
trace(sec.name);
for (y in 0...outdoorHeight) {
for (x in 0...outdoorWidth) {
sec.setFloor(x, y, stream.readByte());
}
}
// floor heights
for (y in 0...outdoorHeight) {
for (x in 0...outdoorWidth) {
sec.setFloorHeight(x, y, stream.readByte());
}
}
stream.tracePosition();
// TODO all the other outdoor section stuff
scen.outdoorSections[x][y] = sec;
// TODO don't, obviously:
break;
}
// TODO don't, obviously:
break;
}
// TODO all the other stuff
return scen;
}
}

View File

@@ -1,23 +1,40 @@
package data.blades;
typedef TileArray<T> = Array<Array<Int>>;
typedef TileArray<T> = Array<Array<T>>;
class TileMap {
private var floorCodes:TileArray<Int>;
// TODO might need encapsulation
public var floorCodes:TileArray<Int>;
public var floorHeights:TileArray<Int>;
private var terrainCodes:TileArray<Int>;
private var width = 0;
private var height = 0;
public var name = "";
private function tileArray<T>(defaultValue:T) {
return [for (x in 0...width) [for (y in 0...height) defaultValue]];
}
public function new(width, height) {
public function new(width, height, name) {
this.width = width;
this.height = height;
this.name = name;
floorCodes = tileArray(255);
terrainCodes = tileArray(0);
floorHeights = tileArray(9);
}
public function setFloor(x, y, code) {
floorCodes[x][y] = code;
}
public function setFloorHeight(x, y, height) {
floorHeights[x][y] = height;
}
public function setTerrain(x, y, code) {
terrainCodes[x][y] = code;
}
}