public static bool Prefix(MethodBase __originalMethod, Section __instance, MapMeshFlag changeType) { if (p.Active) { for (int i = 0; i < __instance.layers.Count; i++) { SectionLayer sectionLayer = __instance.layers[i]; if ((sectionLayer.relevantChangeTypes & changeType) != MapMeshFlag.None) { try { var prof = p.Start(__instance.layers[i].GetType().FullName, __originalMethod); sectionLayer.Regenerate(); prof.Stop(); } catch (Exception ex) { Log.Error(string.Concat(new object[] { "Could not regenerate layer ", sectionLayer.ToStringSafe <SectionLayer>(), ": ", ex }), false); } } } return(false); } return(true); }
static bool Prefix(MapDrawer __instance) { Map map = __instance.map; if (!copyFrom.TryGetValue(map.uniqueID, out MapDrawer keepDrawer)) { return(true); } map.mapDrawer = keepDrawer; keepDrawer.map = map; foreach (Section section in keepDrawer.sections) { section.map = map; for (int i = 0; i < section.layers.Count; i++) { SectionLayer layer = section.layers[i]; if (!ShouldKeep(layer)) { section.layers[i] = (SectionLayer)Activator.CreateInstance(layer.GetType(), section); } else if (layer is SectionLayer_LightingOverlay lighting) { lighting.glowGrid = map.glowGrid.glowGrid; } else if (layer is SectionLayer_TerrainScatter scatter) { scatter.scats.Do(s => s.map = map); } } } foreach (Section s in keepDrawer.sections) { foreach (SectionLayer layer in s.layers) { if (!ShouldKeep(layer)) { layer.Regenerate(); } } } copyFrom.Remove(map.uniqueID); return(false); }