HouseLoader

HouseLoader is what’s responsible for mapping a user’s House for WaspLib to be able to interact with it.

All THouseLoader methods are helper methods for the TRSHouse and you shouldn’t have to call them for anything.

When loaded either by HouseFormTab or via the HouseViewer, it’s map should look something like this:

_images/houseloadermap.png

And this map should look like whatever the account’s POH looks like on the minimap as that’s how we will be able to navigate it.


THouseLoader

Helper record used by the TRSHouse to load and/or map a POH.


THouseLoader.Init

procedure THouseLoader.Init();

Internal method automatically called for your when you use TScriptForm.CreateHouseBuilder(). You don’t usually have to call it yourself.


THouseLoader.GetRoomImageBox

function THouseLoader.GetRoomImageBox(room: EHouseRoom): TBox;

Internal method used to get the box of the EHouseRoom you pass in.

This box is a box of the following image:

_images/rooms_image.png

Example:

{$I WaspLib/osrs.simba}
begin
  WriteLn House.Loader.GetRoomImageBox(EHouseRoom.SUPERIOR_GARDEN);
end;

THouseLoader.GetRoomImage

function THouseLoader.GetRoomImage(room: EHouseRoom): TImage;

Internal method used to retrieve a image of the EHouseRoom you pass in.

Example:

{$I WaspLib/osrs.simba}
var
  img: TImage;
begin
  img := House.Loader.GetRoomImage(EHouseRoom.ACHIEVEMENT_GALLERY);
  img.Show();
end;
_images/achievement_gallery_img.png

THouseLoader.GetIconImage

function THouseLoader.GetIconImage(room: EHouseRoom): TImage;

Internal method used to retrieve a image of the EHouseRoom with it’s icons. The only purpose of this is for debugging or displaying a room for a user as having a room with it’s icons drawn makes it much easier to identify the room visually for a human.

Example:

{$I WaspLib/osrs.simba}
var
  img: TImage;
begin
  img := House.Loader.GetIconImage(EHouseRoom.ACHIEVEMENT_GALLERY);
  img.Show();
end;
_images/achievement_gallery_icons.png

THouseLoader.WriteRoom

procedure THouseLoader.WriteRoom(room: EHouseRoom; index: TPoint);

Internal method used to write a room to THouseLoader.Rooms cache. This uses an TPoint as a room index in a 2D array of EHouseRoom.

Unless you know what you are doing, you definitly should not use this for anything.

If you do use this for some reason, keep in mind that THouseLoader.Map won’t get updated. The easier way is to updated it is to call THouseLoader.Redraw which will redraw the whole map. Read it’s documentation for more information about it.

Example:

House.Loader.WriteRoom(EHouseRoom.SUPERIOR_GARDEN, [3,3]);

THouseLoader.ReadRoom

function THouseLoader.ReadRoom(index: TPoint): EHouseRoom;

Internal method used to read a cached room in THouseLoader.Rooms. This uses an TPoint as a room index.

Unless you know what you are doing, you don’t need this, but there’s no harm in using it.

Example:

WriteLn House.Loader.ReadRoom([3,3]);

THouseLoader.PrintRooms

procedure THouseLoader.PrintRooms();

Debugging helper method used to read a cached rooms in THouseLoader.Rooms. This will print the whole cache nicely formated in a way that is human friendly like you were looking at the house map.

Unless you know what you are doing, you don’t need this, but there’s no harm in using it.

Example:

House.Setup();
House.Loader.PrintRooms();

THouseLoader.DrawMap

procedure THouseLoader.DrawMap(img: TImage; room: EHouseRoom; p: TPoint);
procedure THouseLoader.DrawMap(room: EHouseRoom; color: Integer; p: TPoint); overload;

Methods used to draw the POH map and cache the rooms drawn in THouseLoader.Rooms.

Example:

House.Loader.DrawMap(EHouseRoom.SUPERIOR_GARDEN, POH.GrassColor, [3,3]);
House.Loader.Show();
House.Loader.PrintRooms();

THouseLoader.Redraw

procedure THouseLoader.Redraw();

Redraws THouseLoader.Map based on the information being held at THouseLoader.Rooms. This redraws the the whole house map from scratch so if you just want to draw a single room, there’s lighter ways to do do it, such as:

var
  index: TPoint;
  img: TImage;
begin
  index := [5,5];
  img := House.Loader.GetRoomImage(EHouseRoom.ACHIEVEMENT_GALLERY).RotateClockWise(3);
  House.Loader.Map.DrawImage(img, [House.Loader.SIZE * index.X, House.Loader.SIZE * index.Y]);
end;