+void Area::RenderDebug(SDL_Surface *dest, const graphics::Sprite *tileset, const Vector<int> &inOffset) const {
+ SDL_Rect destRect;
+ destRect.x = inOffset.X();
+ destRect.y = inOffset.Y();
+ destRect.w = Width() * tileset->Width();
+ destRect.h = Height() * tileset->Height();
+ sdl::OutlineRect(dest, &destRect, SDL_MapRGB(dest->format, 0x00, 0x00, 0xFF));
+
+ Uint32 color(SDL_MapRGB(dest->format, 0xFF, 0x00, 0x00));
+
+ for (int i(0); i < numTiles; ++i) {
+ Vector<int> offset(
+ inOffset.X() + (i % width) * tileset->Width(),
+ inOffset.Y() + (i / width) * tileset->Height());
+ const Tile &tile(tiles[i]);
+
+ if (tile.BlocksNorth()) {
+ sdl::HorizontalLine(dest, offset, tileset->Width(), color);
+ }
+ if (tile.BlocksEast()) {
+ sdl::VerticalLine(dest, Vector<int>(offset.X() + tileset->Width() - 1, offset.Y()), tileset->Height(), color);
+ }
+ if (tile.BlocksSouth()) {
+ sdl::HorizontalLine(dest, Vector<int>(offset.X(), offset.Y() + tileset->Height() - 1), tileset->Width(), color);
+ }
+ if (tile.BlocksWest()) {
+ sdl::VerticalLine(dest, offset, tileset->Height(), color);
+ }
+ if (tile.IsLadder()) {
+ SDL_Rect rect;
+ rect.x = offset.X() + (tileset->Width() / 2) - 2;
+ rect.y = offset.Y();
+ rect.w = 4;
+ rect.h = tileset->Height();
+ SDL_FillRect(dest, &rect, color);
+ }
+ }
+}
+
+
+void Area::CreateTypeDescription() {
+ Area a;
+
+ TypeDescription &td(TypeDescription::Create(TYPE_ID, "Area"));
+ td.SetConstructor(&Construct);
+ td.SetSize(sizeof(Area));
+
+ td.AddField("battlebg", FieldDescription(((char *)&a.battlebg) - ((char *)&a), Interpreter::IMAGE_ID).SetReferenced());
+ td.AddField("tiles", FieldDescription(((char *)&a.tiles) - ((char *)&a), Tile::TYPE_ID).SetAggregate());
+ td.AddField("width", FieldDescription(((char *)&a.width) - ((char *)&a), Interpreter::NUMBER_ID));
+}
+
+void Area::Construct(void *data) {
+ new (data) Area;
+}
+