private static void CombineAutotilers(Autotiler basic, List <string> additions, RandoSettings settings) { var counts = new Dictionary <char, int>(); var r = new Random((int)settings.IntSeed); // uhhhhhhh this is intensely sketchy var lookup = (IDictionary)typeof(Autotiler).GetField("lookup", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(basic); foreach (char k in lookup.Keys) { counts[k] = 1; } foreach (var path in additions) { var advanced = new Autotiler(path); var lookup2 = (IDictionary)typeof(Autotiler).GetField("lookup", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(advanced); foreach (char k in lookup2.Keys) { if (counts.ContainsKey(k)) { counts[k]++; if (r.Next(counts[k]) == 0) { lookup[k] = lookup2[k]; } } else { counts[k] = 1; lookup[k] = lookup2[k]; } } } }
public static Autotiler.Generated GenerateOverlay(this Autotiler tiler, VirtualMap <char> tileMap, int x, int y, VirtualMap <char> mapData) { Autotiler.Behaviour behaviour = new Autotiler.Behaviour { EdgesExtend = true, EdgesIgnoreOutOfLevel = true, PaddingIgnoreOutOfLevel = true }; return(tiler.Generate(mapData, x, y, tileMap, behaviour)); }
private static Autotiler.Generated Generate(this Autotiler tiler, VirtualMap <char> mapData, int startX, int startY, VirtualMap <char> forceData, Autotiler.Behaviour behaviour) { usingCustomAutotiler = true; forceData_CustomAutotiler = forceData; startPoint_CustomAutotiler = new Point(startX, startY); TileGrid tileGrid = new TileGrid(8, 8, forceData.Columns, forceData.Rows); AnimatedTiles animatedTiles = new AnimatedTiles(forceData.Columns, forceData.Rows, GFX.AnimatedTilesBank); Rectangle empty = new Rectangle(startX, startY, forceData.Columns, forceData.Rows); for (int i = startX; i < startX + forceData.Columns; i += 50) { for (int j = startY; j < startY + forceData.Rows; j += 50) { if (!mapData.AnyInSegmentAtTile(i, j)) { j = j / 50 * 50; } else { int k = i; int num = Math.Min(i + 50, startX + forceData.Columns); while (k < num) { int l = j; int num2 = Math.Min(j + 50, startY + forceData.Rows); while (l < num2) { object tiles = m_TileHandler.Invoke(tiler, new object[] { mapData, k, l, empty, forceData[k - startX, l - startY], behaviour }); if (tiles != null) { (Calc.Random as PositionRandom)?.SetPosition(k - startX, l - startY); // Positional Randomization for TileSeedController tileGrid.Tiles[k - startX, l - startY] = Calc.Random.Choose(f_Tiles_Textures.GetValue(tiles)); if (f_Tiles_HasOverlays.GetValue(tiles)) { animatedTiles.Set(k - startX, l - startY, Calc.Random.Choose(f_Tiles_OverlapSprites.GetValue(tiles)), 1f, 1f); } } l++; } k++; } } } } usingCustomAutotiler = false; return(new Autotiler.Generated { TileGrid = tileGrid, SpriteOverlay = animatedTiles }); }
public WindowToolList(Autotiler bg, Autotiler fg) { BGTilesets = new List <string> { "Air" }; foreach (Tileset t in bg.GetTilesetList()) { BGTilesets.Add(MiscHelper.CleanCamelCase(t.Path.StartsWith("bg") ? t.Path.Substring(2) : t.Path)); } FGTilesets = new List <string> { "Air" }; foreach (Tileset t in fg.GetTilesetList()) { FGTilesets.Add(MiscHelper.CleanCamelCase(t.Path)); } Placements = new Dictionary <string, Placement>(EntityRegistry.GetRegisteredPlacements()); Tools = new List <string>() { "TileBrush", "TileRectangle", "Entity" }; // Hardcoded tool names to force a specific tool order that's familliar to Ahorn users. foreach (string tool in ToolManager.Tools.Keys) { if (!Tools.Contains(tool)) { Tools.Add(tool); } } SelectedTool = "TileBrush"; Searches = new Dictionary <string, string>(); foreach (string tool in Tools) { string searchGroup = ToolManager.Tools[tool].GetSearchGroup(); if (!Searches.ContainsKey(searchGroup)) { Searches.Add(searchGroup, ""); } } }
// Mods can't access patch_ classes directly. // We thus expose any new members through extensions. /// <summary> /// Get the filename of the file belonging to the Autotiler. /// </summary> // TODO: Is this the file path? What is this exactly? public static string GetFilename(this Autotiler self) => ((patch_Autotiler)self).Filename;
private static bool Autotiler_CheckTile(On.Celeste.Autotiler.orig_CheckTile orig, Autotiler self, object set, VirtualMap <char> mapData, int x, int y, Rectangle forceFill, Autotiler.Behaviour behaviour) { if (usingCustomAutotiler) { Point origin = startPoint_CustomAutotiler; char c = forceData_CustomAutotiler[x - origin.X, y - origin.Y]; if (IsEmpty(c)) { forceFill = Rectangle.Empty; } else if ((bool)m_TerrainType_Ignore.Invoke(set, new object[] { c })) { // Hack to make sure `ignores` attributes are respected return(false); } } return(orig(self, set, mapData, x, y, forceFill, behaviour)); }
public static Autotiler.Generated GenerateOverlay(this Autotiler tiler, VirtualMap <char> tileMap, int x, int y, VirtualMap <char> mapData, Autotiler.Behaviour behaviour) { return(tiler.Generate(mapData, x, y, tileMap, behaviour)); }