-
Notifications
You must be signed in to change notification settings - Fork 10
Custom Room Shapes
This custom room shape function was introduced in Version 1.9. If you are using an integrated version of the API from before 27 April 2020, you will not have this feature.
First, you must create the room's sprites and animations. There should be two sprites (small map and large map) for each state: Unvisited, Semivisited (Left room without clearing it), Visited and Current. If your room matches the size of any other room (eg 2x1), make sure that the crop x and crop y match the size of the base room (this is important for bounded map culling).
For examples on spriting rooms, see gfx/ui/minimap1.png in the game's resources, and gfx/ui/minimapapi/custom_minimap1.png in MinimapAPI's mod folder.
If you do not understand any of the arguments below or how to use them, check out the data file for MinimapAPI to see what values are set for other rooms scripts/minimapapi/data.lua
MinimapAPI:AddRoomShape(
id,
small_anims,
large_anims,
Vector gridpivot,
Vector gridsize,
array<Vector> positions,
array<Vector> iconpositions,
Vector iconpositioncenter,
array<Vector> largeiconpositions,
Vector largeiconpositioncenter,
array<Vector> adjacentcoords,
optional array<DoorSlot> doorslots
)
-
id is any value used to identify the shape. Used as the value for Shape when adding a room. It is recommended you use a unique string, but numbers or even tables can be used instead.
-
small_anims represents the sprites to be used for the room on the minimap (when small) and should be a table that contains four animation tables like this: {sprite=(a sprite object),anim=(a string with the name of an animation),frame=(the frame number)}. The small_anims table must be laid out like so: {RoomUnvisited=(anim table),RoomVisited=(anim table),RoomCurrent=(anim table),RoomSemivisited=(anim table)}.
-
large_anims is the same as small_anims but for large sprites.
-
gridpivot is the "top left" position of the room shape. It should always be (0,0) unless the room does not occupy the top left of its own bounding box (for example, an LTL room).
-
gridsize is the bound size of the room. For 1x1, IH and IV rooms, this is (1,1). For IIV and 1x2, this is (1,2). For all L rooms and 2x2, this is (2,2).
-
positions is a list of Vectors. Each vector is an occupied grid space. For 1x1 rooms, there will only be one occupied grid space, so there will only be one vector, (0,0). For 2x2 rooms, there are four occupied grid spaces, and so the list would be {(0,0),(1,0),(0,1),(1,1)}.
-
iconpositions is the same as above, but for icons. (0,0) is the top left of the room, (0.5,0.5) is the bottom right of the top left room. (1,0) would be one room to the right and so on.
-
iconpositioncenter is a Vector. It represents the position of an icon if there is only one icon in the room. Ideally, this should be in the center of the room.
-
largeiconpositions are the same as iconpositions but for when the map is large.
-
largeiconpositioncenter are the same as iconpositioncenter but for when the map is large.
-
adjacentcoords should be a list of Vectors representing all positions adjacent to this room type. For a 1x1 room this would be {(-1,0),(0,-1),(1,0),(0,1)}
-
doorslots is a list of DoorSlots that this room has. If the room is larger than 2x2, you may want to extend this beyond the vanilla game's enums using
MinimapAPI:GetDoorSlotValue(number doorgroup, number doordir)
, which can return a larger DoorSlot value. This argument is optional.
This is for rooms that are large or oddly shaped where making individual sprites would be suboptimal.
TODO: Implement this!