Better-Scenes / RimConnect-mod

A Twitch integration for the game RimWorld
GNU General Public License v3.0
15 stars 8 forks source link

Fix map finding function to make sure it's always relevant #12

Open InfinitySamurai opened 4 years ago

InfinitySamurai commented 4 years ago

Currently there are some issue with the map that is found. It's usually the one that is currently being viewed by the player. This causes issues with some mod integrations such as the new z-level mod. At a suggestion from their discord, we could use something a bit more robust such as:

var map = Find.WorldObjects.MapParents.Where(x => x.Tile == Find.CurrentMap.Tile
                    && x.HasMap && x.Map != null && x.Map.IsPlayerHome).FirstOrDefault().Map;

Worthwhile exploring this and seeing if this snippet is fit for purpose