Hey all, I am working on rewriting my MapController class, it’s basically the class that loads/unloads my maps and handles all the getters/setters related to the map and coordinates system in the game. There will usually only ever be one MapController object that handles everything. When a map changes it runs a class internally that dumps the old map and rebuilds a new one whenever the player transitions into a new map.
There are certain situations where I need to pass the TiledMap class from MapController into other classes. For example, I build my lighting map based on property flags directly on each TiledMap file. It runs through a for loop, finds all the tiles that have a "lightSource = " flag, and applies a light over top of that tile that matches . Currently, to do that MapController creates the LightController object and passes TiledMap to it, then LightingController takes TiledMap and runs a for loop and starts the search under init().
My long-winded question is; would it be better to make Getter/Setters inside the MapController that interact with the TiledMap class, so LightingController has to run something like “.getTileId()” that will basically just go into and run “.getTileId()” and return the value to LightingController . . . or is it acceptable to go ahead and pass TiledMap to LightingController directly so it can just run TiledMap methods out of that class?
I guess the TL:DR version is, should LightingController run through MapController to access TiledMap, or should it be allowed direct access to the object that MapController created, by having MapController pass the current TiledMap Object to the LightingController?
Sorry if this all sounds confusing, it’s a bit hard to explain.
EDIT: Basically, what I am asking is, since MapController pretty much controls all aspects of TiledMap, should I only allow MapController direct access to TiledMap and force all the other classes that need to interact with the instance of TiledMap to do it through MapController?