Hey everyone,
I have a local branch on OP2Utility that allows deleting a tileset from the MapData struct. It is pretty complicated though:
How a tileset is deleted:
- Find if a TileSetSource exists with given name
- Record tilesetSourceIndex and TileSetSource's TileCount
- Delete the TilesetSrouce
- Delete all TileInfos that originate from the TilesetSource
- Decrement all TileInfo's index to it's source TileSetSource (This way they do not index to the wrong tilesetSource)
- Set all Tiles on the map that came from the deleted tileset to a TileIndex 0 (usually blue)
- Decrement by one all Tiles on the map that have TileInfoIndices greater than the deleted TileSetSource (This way they match up with the new indexing of the TileInfo container.)
- Perform the same previous 2 operations on all TileGroups (This prevents a TileGroup from referencing a deleted tile and updates TileGroups with the new indexing of the TileInfo container.)
- Abort the operation if the tileset exists on a TerrainType
- Decrement all TerrainType TileInfos indexes that were decremented above
Okay, so this is not very useful right now. Mostly because of that second to last step where it is aborted if the tileset exists on a TerrainType. TerrainTypes represent multiple tilesets and how they interact. All tilesets in Outpost 2 belong to a TerrainType besides the first well that is just a blue tile. I did test the operation, and it worked properly by deleting Well0000.
I could design the algorithm to work by removing the removed tilesetSource range from the affected TerrainType. However, if this tileset were added back in, it would not automatically be restored into the TerrainType. And if you say deleted the tileset that had the tubes on it for the sand tiles, I doubt this would go well when you played. However, if you were smart, you could delete all sand tilesets and then everything would probably work fine. Then you would have a bunch of available tiles to design something else on.
So, for now I think I'll finish this branch up, which will allow for adding and deleting tilesets (as long as they do not belong to a TileType, which makes its usefulness limited).
We will have to decide how we want to handle adding new tilesets with the association of TerrainTypes. Since TerrainTypes span multiple tilesets, it isn't a clean solution. Maybe the 2 questions worth asking are
1. Leeor, do you plan on the Mapper supporting adding tilesets, and if so how do we want to handle tile metadata associated with a new tileset?
Creating, Adding, and removing tilesets could actually happen in a third-party tool. Maybe a command-line tool that consumes some sort of Yaml or Json or XML format with a raw tileset to add it into a map outside of the Mapper. This might save a lot of time hooking some sort of complex GUI screen into the Mapper to set it all up. But it isn't as slick as including it in the Mapper.
2. Is anyone burning to have the ability to extend Outpost 2 with new tilesets? If so, I'm going to happily work on this feature. If not, maybe just leaving it at this weak attempt for now indefinetly. I do want to commit it into the code base though even if it is just there to show someone in the future what to mostly do to delete a tileset.
Thanks,
Brett