Rooms always appear on a BB+ run. These can range from classrooms or faculty rooms. Here are the basics to making your first room.
Creating a room is simple. To do so, first do the Basics. Now, in RegisterImportant (The tutorial will mainly be in that function), simply have
RoomAsset CustomRoom = ScriptableObject.CreateInstance<RoomAsset>();
This creates a room asset. You can rename CustomRoom to whatever you want. Now, we have to set it up. Give it a name by putting CustomRoom.name = "TestRoom";. Of course you can rename TestRoom to whatever you want. Remember it tho!
Okay, so what do we do now? How do we make this room the way we want the room to be? Firstly, if this room is a classroom, and has a notebook, put CustomRoom.hasActivity = true;, else put CustomRoom.hasActivity = false;
Now that's done, if hasActivity is false, put CustomRoom.activity = new ActivityData();. We'll get back to if it's true.
Now the simple room data is made.
Now how do we make the room, a room? (Make the room exist) Say hello to Cells. These are just tiles in a map, and what makes the map exist. There are a lot of types of cells.
Adding a cell is easy, just put:
CustomRoom.cells.Add(new CellData()
{
pos = new IntVector2(x,y),
type = 12
});
Now you're probably confused on pos and type. Let's get to pos first. Think of the pos as a 2d grid, where x is the x and y is the y. The type is more complicated, so PixelGuy has provided me this photo:
If you're still confused, I'll explain.
When the type is 12, you add up 8 and 4, thus those walls with the associated numbers will be there, and the other ones (1 and 2) will not. Here's a simple code snippet from my (WIP) mod that creates a simple 3x3 room: Here.
Now let's say you've finished the room because you have a lot of time (This takes a while.) Now we want to be able to enter the room, otherwise this room is pointless. Say hello to potentialDoorPositions! These can make a door spawn, and you can have multiple of these.
Let's say you've made the 3x3 room (if you used this as the code). What you can do is spawn a door in one of the sides, just do
CustomRoomO.potentialDoorPositions.Add(new IntVector2(1, 0));, you can also put it in other positions that has a wall.
Alright, now the room is finally a room, now let's add stuff in it.
Now we have to add a notebook in the room. How can we do this? Remember when hasActivity is true and I said we'll get back to it? Well that's what this section is about!
If hasActivity is true, aka if you want a notebook in your classroom, add the following in this link. Make sure it's below defining the roomAsset's name.
Also, the position can be any position you want. Just remember that one tile is 10 in Vector3, because it uses Vector3 instead of IntVector2, for better precision. Rotation doesn't matter.
To add desks, big desks, chairs, etc., put the following: Here. Like notebooks, position uses Vector3, and rotation affects the object. Here is the list of objects you can replace "Chair_Test" with:
BigDesk - The desk for notebooks.
Desk - The desk for students.
Chair_Test - A chair.
These are all I could find, if there are any more please tell me.
Now we want our room to spawn in our floor. First, at the end of setting up the room (at the very bottom of the function) add this line: assetMan.Add<RoomAsset>("CustomRoom", CustomRoom);
Also add these right above the assetMan line:
CustomRoomOne.category = RoomCategory.Class;
MTM101BaldiDevAPI.roomAssetMeta.Add(new RoomAssetMeta(this.Info, CustomRoomOne));
Now in LoadLevelData, add this:
if (floorName == "F1")
{
var gr = floorObject.roomGroup.First(x => x.name == "Class");
gr.potentialRooms = gr.potentialRooms.AddToArray(new WeightedRoomAsset
{
selection = CustomRoomOne,
weight = 150
});
}
This should make it so the level generator will generate the new room. The selection is the room you want, and the weight is how often it can spawn. Also, in the if statement, it doesn't have to be F1 (Floor 1). It can be all floors (floorNumber >= 1 && floorName.StartsWith("F")), or just one!
We now have a custom room! You can now add other things by looking at other pages in this site, or head over to Publish your Mod to finish your mod! If there are any bugs, please tell me.