# HouseMap The HouseMap is what's responsible for mapping a user's POH (Player owned house). - - - (THouseLoader)= ## type THouseLoader ```pascal type THouseLoader = record AMOUNT, SIZE: Int32; Map: TMufasaBitmap; Rooms: array of array of THouseRoom; //helpers: TeleportRooms: array of array of TTeleportRoom; RoomsBitmap, IconBitmap: TMufasaBitmap; RoomBitmaps, IconBitmaps: array [EHouseRoom] of TMufasaBitmap; Selected: record Matrix, Map: TPoint; end; HouseBounds: TBox; Decoration: EHouseDecoration; Colors: record Outdoors, Indoors, Dungeon: Int32; end; Config: TConfigJSON; end; ``` Helper record used by the {ref}`THouseHandler`. All `THouseLoader` methods are helper methods for the {ref}`THouseHandler` and you shouldn't have to call them for anything. - - - ## THouseLoader.Free() ```pascal procedure THouseLoader.Free(); ``` Internal method automatically called for your on script termination. You do not have to call it yourself. - - - ## THouseLoader.Init() ```pascal procedure THouseLoader.Init(size, amount: Int32); ``` Internal method automatically called for your when you use `TScriptForm.CreateHouseBuilder()`. You don't usually have to call it yourself. - - - ## THouseLoader.GetRoomBitmapBox() ```pascal function THouseLoader.GetRoomBitmapBox(room: EHouseRoom): TBox; ``` Internal method used to get the box of the {ref}`EHouseRoom` you pass in. This box is a box of the following image: ![poh rooms](../../../osr/walker/poh.png) Example: ```pascal {$I WaspLib/optional/handlers/poh.simba} begin WriteLn POH.Map.GetRoomBitmapBox(EHouseRoom.SUPERIOR_GARDEN); end; ``` - - - ## THouseLoader.GetRoomBitmap() ```pascal function THouseLoader.GetRoomBitmap(room: EHouseRoom; color: Int32 = -1): TMufasaBitmap; ``` Internal method used to retrieve a bitmap of the {ref}`EHouseRoom` you pass in. Example: ```pascal {$I WaspLib/optional/handlers/poh.simba} var bmp: TMufasaBitmap; begin bmp := POH.Map.GetRoomBitmap(EHouseRoom.SUPERIOR_GARDEN); bmp.Debug(); bmp.Free(); end; ``` - - - ## THouseLoader.WriteRoom() ```pascal 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 {ref}`EHouseRoom`. Unless you know what you are doing, you definitly should not use this for anything. Example: ```pascal POH.Map.WriteRoom(EHouseRoom.SUPERIOR_GARDEN, [3,3]); ``` - - - ## THouseLoader.ReadRoom() ```pascal 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: ```pascal WriteLn POH.Map.ReadRoom([3,3]); ``` - - - ## THouseLoader.PrintRooms() ```pascal 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. ```{note} :class: dropdown It's a extremely useful debugging tool when paired with `POH.Map.Map.Debug()`. ``` Example: ```pascal POH.Setup(); POH.Map.PrintRooms(); ``` - - - ## THouseLoader.DrawMap() ```pascal procedure THouseLoader.DrawMap(bmp: TMufasaBitmap; room: EHouseRoom; p: TPoint); procedure THouseLoader.DrawMap(room: EHouseRoom; color: Int32; p: TPoint); overload; ``` Methods used to draw the POH map and cache the rooms drawn in `THouseLoader.Rooms`. Example: ```pascal POH.Map.DrawMap(EHouseRoom.SUPERIOR_GARDEN, POH.GrassColor, [3,3]); POH.Map.Debug(); POH.Map.PrintRooms(); ```