Adding Default Maps
So, Tiny Louvre adds a new default map, the Tiny Louvre. This is a museum lot that lets players view a variety of both classical paintings I added to the game and paintings downloaded from online. And this was simple enough, right? I just used the [url=https://docs.tinylifegame.com/articles/custom_maps.html]Creating Custom Maps[/url] tutorial in the Tiny Life docs to create the custom map, exported it, and copied the [i].json[/i] file into [i]Content/TinyLouvre/Maps[/i]. But wait, it wasn't appearing in the map list. I guess that's to be expected, there's probably a method or event for telling the game what maps my mod adds. And yep, there's [url=https://docs.tinylifegame.com/api/TinyLife.World.Map.html#TinyLife_World_Map_OnGetStaticMaps]Map.OnGetStaticMaps[/url], which I can hook into without much fuss.
Hey, there it is!
I should make sure this works before I celebrate too much.
Check the map off, create the world, aaaaaand crash.
So, reading in modern day you might see something noteworthy in the [i]OnGetStaticMaps[/i] docs:
[quote]If this event is subscribed to and one or more custom maps are added to the list, the OnLoadStaticMap event should also be subscribed to to handle actually loading these maps.[/quote]
That's because ell added that to the docs while we were talking about this issue.
At the time, I had no idea I had to do something else to load the map, but it turns out I [i]also[/i] had to subscribe to
[url=https://docs.tinylifegame.com/api/TinyLife.World.Map.html#TinyLife_World_Map_OnLoadStaticMap]OnLoadStaticMap[/url].
Okay, so add a new bit to [i]AddGameContent[/i],
[code]Map.OnLoadStaticMap += (MapInfo mapInfo, Newtonsoft.Json.JsonSerializer serializer, ref Map map) =>
{
if(mapInfo.Name == "TinyLouvre")
map ??= info.Content.LoadJson