public SolidTiles(Vector2 position, VirtualMap <char> data) //: base(position, 0.0f, 0.0f, true) { this.position = position; //this.Tag = (int)Tags.Global; //this.Depth = -10000; this.tileTypes = data; //this.EnableAssistModeChecks = false; //this.AllowStaticMovers = false; //this.Collider = (Collider)(this.Grid = new Grid(data.Columns, data.Rows, 8f, 8f)); //for (int x = 0; x < data.Columns; x += 50) //{ // for (int y = 0; y < data.Rows; y += 50) // { // if (data.AnyInSegmentAtTile(x, y)) // { // int index1 = x; // for (int index2 = Math.Min(index1 + 50, data.Columns); index1 < index2; ++index1) // { // int index3 = y; // for (int index4 = Math.Min(index3 + 50, data.Rows); index3 < index4; ++index3) // { // if (data[index1, index3] != '0') // this.Grid[index1, index3] = true; // } // } // } // } //} Autotiler.Generated map = Gfx.FGAutotiler.GenerateMap(data, true); this.Tiles = map.TileGrid; this.Tiles.VisualExtend = 1; //this.Add((Component)this.Tiles); //this.Add((Component)(this.AnimatedTiles = map.SpriteOverlay)); }
public FancyFallingBlock(EntityData data, Vector2 offset) : base(data.Position + offset, '3', data.Width, data.Height, data.Bool("finalBoss", false), data.Bool("behind", false), data.Bool("climbFall", true)) { baseData = new DynData <FallingBlock>(this); Remove(baseData.Get <TileGrid>("tiles")); Remove(Get <TileInterceptor>()); badLightOcclude = Get <LightOcclude>(); int newSeed = Calc.Random.Next(); Calc.PushRandom(newSeed); tileMap = GenerateTileMap(data.Attr("tileData", "")); Autotiler.Generated generated = GFX.FGAutotiler.GenerateMap(tileMap, default(Autotiler.Behaviour)); baseData["tiles"] = generated.TileGrid; Add(baseData.Get <TileGrid>("tiles")); Add(animatedTiles = generated.SpriteOverlay); Calc.PopRandom(); if (data.Bool("finalBoss", false)) { VirtualMap <char> tileMapHighlighted = GenerateTileMap(data.Attr("tileDataHighlight", "")); Calc.PushRandom(newSeed); TileGrid highlight = GFX.FGAutotiler.GenerateMap(tileMapHighlighted, default(Autotiler.Behaviour)).TileGrid; highlight.Alpha = 0f; baseData["highlight"] = highlight; Add(baseData.Get <TileGrid>("highlight")); Calc.PopRandom(); } ColliderList colliders = GenerateBetterColliderGrid(tileMap, 8, 8); AddLightOcclude(this, colliders); Collider = colliders; Add(new TileInterceptor(baseData.Get <TileGrid>("tiles"), false)); }
public patch_BackgroundTiles(Vector2 position, VirtualMap <char> data) { Position = position; Tag = Tags.Global; Autotiler.Generated generated = GFX.BGAutotiler.GenerateMap(data, paddingIgnoreOutOfLevel: false); Tiles = generated.TileGrid; Tiles.VisualExtend = 1; Add(Tiles); Add(AnimatedTiles = generated.SpriteOverlay); Depth = Depths.BGTerrain; }
private IEnumerator tileGlitcher() { glitcherAdded = true; Level level = Scene as Level; Vector2 pos = (Position - level.LevelOffset) / 8f; int ox = (int)Math.Round(pos.X + level.LevelSolidOffset.X); int oy = (int)Math.Round(pos.Y + level.LevelSolidOffset.Y); int tw = (int)Math.Ceiling(width / 8f); int th = (int)Math.Ceiling(height / 8f); bool glitchFg = target.Equals("FG") || target.Equals("Both"); bool glitchBg = target.Equals("BG") || target.Equals("Both"); cacheValidTiles(); List <Char> validFg = new List <char>(validFgTiles); List <Char> validBg = new List <char>(validBgTiles); if (allowAir) { validFg.Add('0'); validBg.Add('0'); } validFg = string.IsNullOrEmpty(customFgTiles) ? validFg : customFgTiles.Where(c => validFg.Contains(c)).ToList(); validBg = string.IsNullOrEmpty(customBgTiles) ? validBg : customBgTiles.Where(c => validBg.Contains(c)).ToList(); while (active) { if (glitchFg && validFg.Count > 0) { VirtualMap <char> fgData = level.SolidsData; VirtualMap <MTexture> fgTexes = level.SolidTiles.Tiles.Tiles; VirtualMap <bool> collision = ((Grid)level.SolidTiles.Collider).Data; VirtualMap <char> newFgData = new VirtualMap <char>(tw + 2, th + 2, '0'); for (int x = ox - 1; x < ox + tw + 1; x++) { for (int y = oy - 1; y < oy + th + 1; y++) { if (x > 0 && x < fgTexes.Columns && y > 0 && y < fgTexes.Rows && (transformAir || fgData[x, y] != '0')) { newFgData[x - ox + 1, y - oy + 1] = fgData[x, y]; if (Calc.Random.NextFloat() < threshold) { char value = validFg[Calc.Random.Next(validFg.Count)]; newFgData[x - ox + 1, y - oy + 1] = value; } } } } Autotiler.Generated newFgTiles = GFX.FGAutotiler.GenerateMap(newFgData, true); for (int x = ox - 1; x < ox + tw + 1; x++) { for (int y = oy - 1; y < oy + th + 1; y++) { if (x > 0 && x < fgTexes.Columns && y > 0 && y < fgTexes.Rows) { if (x >= ox && x < ox + tw && y >= oy && y < oy + th && fgTexes[x, y] != newFgTiles.TileGrid.Tiles[x - ox + 1, y - oy + 1]) { fgData[x, y] = newFgData[x - ox + 1, y - oy + 1]; fgTexes[x, y] = newFgTiles.TileGrid.Tiles[x - ox + 1, y - oy + 1]; bool newCollision = fgTexes[x, y] != null; if (collision[x, y] != newCollision) { collision[x, y] = newCollision; } } } } } } if (glitchBg && validBg.Count > 0) { VirtualMap <char> bgData = level.BgData; VirtualMap <MTexture> bgTexes = level.BgTiles.Tiles.Tiles; VirtualMap <char> newBgData = new VirtualMap <char>(tw + 2, th + 2, '0'); for (int x = ox - 1; x < ox + tw + 1; x++) { for (int y = oy - 1; y < oy + th + 1; y++) { if (x > 0 && x < bgTexes.Columns && y > 0 && y < bgTexes.Rows && (transformAir || bgData[x, y] != '0')) { newBgData[x - ox + 1, y - oy + 1] = bgData[x, y]; if (Calc.Random.NextFloat() < threshold) { char value = validBg[Calc.Random.Next(validBg.Count)]; newBgData[x - ox + 1, y - oy + 1] = value; } } } } Autotiler.Generated newBgTiles = GFX.BGAutotiler.GenerateMap(newBgData, true); for (int x = ox - 1; x < ox + tw + 1; x++) { for (int y = oy - 1; y < oy + th + 1; y++) { if (x > 0 && x < bgTexes.Columns && y > 0 && y < bgTexes.Rows) { if (x >= ox && x < ox + tw && y >= oy && y < oy + th && bgTexes[x, y] != newBgTiles.TileGrid.Tiles[x - ox + 1, y - oy + 1]) { bgData[x, y] = newBgData[x - ox + 1, y - oy + 1]; bgTexes[x, y] = newBgTiles.TileGrid.Tiles[x - ox + 1, y - oy + 1]; } } } } } yield return(rate); } glitcherAdded = false; yield return(true); }
private static void LevelLoader_LoadingThread(On.Celeste.LevelLoader.orig_LoadingThread orig, LevelLoader self) { orig(self); MapData mapData = self.Level.Session.MapData; var controllers = from level in mapData.Levels from entity in level.Entities where entity.Name == "FancyTileEntities/TileSeedController" select new { entity, level }; Rectangle mapTileBounds = mapData.TileBounds; SolidTiles fgTiles = self.Level.SolidTiles; BackgroundTiles bgTiles = self.Level.BgTiles; Regex regex = new Regex("\\r\\n|\\n\\r|\\n|\\r"); Autotiler.Behaviour behaviour = new Autotiler.Behaviour { EdgesExtend = true, EdgesIgnoreOutOfLevel = false, PaddingIgnoreOutOfLevel = true }; foreach (var controller in controllers) { EntityData data = controller.entity; LevelData level = controller.level; int randomSeed = data.Int("randomSeed", 42); Rectangle bounds = level.TileBounds; Rectangle tileBounds = self.Level.Session.MapData.TileBounds; if (data.Bool("fg", true)) { VirtualMap <char> map = new VirtualMap <char>(bounds.Width, bounds.Height, '0'); string[] array = regex.Split(level.Solids); for (int y = 0; y < array.Length; y++) { for (int x = 0; x < array[y].Length; x++) { map[x, y] = array[y][x]; } } Calc.PushRandom(randomSeed); Autotiler.Generated gen = Extensions.GenerateOverlay(GFX.FGAutotiler, map, bounds.X - tileBounds.Left, bounds.Y - tileBounds.Top, self.Level.SolidsData, behaviour); Calc.PopRandom(); int left = bounds.Left; int top = bounds.Top; for (int y = top; y < top + array.Length; y++) { for (int x = left; x < left + array[y - top].Length; x++) { fgTiles.Tiles.Tiles[x - mapTileBounds.Left, y - mapTileBounds.Top] = gen.TileGrid.Tiles[x - left, y - top]; } } } if (data.Bool("bg", true)) { VirtualMap <char> map = new VirtualMap <char>(bounds.Width, bounds.Height, '0'); string[] array = regex.Split(level.Bg); for (int y = 0; y < array.Length; y++) { for (int x = 0; x < array[y].Length; x++) { map[x, y] = array[y][x]; } } Calc.PushRandom(randomSeed); Autotiler.Generated gen = Extensions.GenerateOverlay(GFX.BGAutotiler, map, bounds.X - tileBounds.Left, bounds.Y - tileBounds.Top, self.Level.BgData, behaviour); Calc.PopRandom(); int left = bounds.Left; int top = bounds.Top; for (int y = top; y < top + array.Length; y++) { for (int x = left; x < left + array[y - top].Length; x++) { bgTiles.Tiles.Tiles[x - mapTileBounds.Left, y - mapTileBounds.Top] = gen.TileGrid.Tiles[x - left, y - top]; } } } } }