public override void RefreshTile(Vec3I gridPos, TM.ITilemap tilemap) { Vec2I pos = GridToTile(gridPos); Vec2I subTile = GridToSubTile(gridPos); Map.BBTile tile = GetTile(pos); if (!disableRefresh || HasSprite(tile, pos, subTile)) { tilemap.RefreshTile(gridPos); } if (disableRefresh) { return; } for (int tx = 0; tx < 2; ++tx) { for (int ty = 0; ty < 2; ++ty) { Vec2I t = pos + new Vec2I(tx + subTile.x - 1, ty + subTile.y - 1); if (t != pos) { t *= 2; for (int i = 0; i < 4; ++i) { tilemap.RefreshTile(new Vec3I(t.x + (i >> 1), t.y + (i % 2), 0)); } } } } }
protected override TileSprite GetSprite(Map.BBTile tile, Vec2I pos, Vec2I subTile) { if (grassSprite == null) { var atlas = map.game.assets.atlases.Get(Terrain.K_grassDef.atlas); Vec2I spritePos = Terrain.K_grassDef.spriteFrames[0] + Tiling.SpriteOffset(Tiling.TileType.Base); grassSprite = atlas.GetSprite(spritePos, Vec2I.one); } return(grassSprite); }
public override void GetTileData(Vec3I gridPos, TM.ITilemap itilemap, ref TM.TileData tileData) { Vec2I pos = GridToTile(gridPos); Vec2I subTile = GridToSubTile(gridPos); Map.BBTile tile = GetTile(pos); TileSprite sprite = HasSprite(tile, pos, subTile) ? GetSprite(tile, pos, subTile) : null; tileData = new TM.TileData { sprite = sprite.sprite, color = sprite.color, transform = sprite.xform, gameObject = null, flags = TM.TileFlags.None, colliderType = ColliderType.None }; // Unity so broken (requires tileData.color to be set also *shrug*) tilemap.SetColor(gridPos, sprite.color); }
public Tile(Map.BBTile tile, Vec2I pos) { BB.AssertNotNull(tile); this.tile = tile; this.pos = pos; }
protected abstract TileSprite GetSprite(Map.BBTile tile, Vec2I pos, Vec2I subTile);
protected abstract bool HasSprite(Map.BBTile tile, Vec2I pos, Vec2I subTile);
protected override TileSprite GetSprite(Map.BBTile tile, Vec2I pos, Vec2I subTile) => tile.bldgMain.GetSpriteOver(pos);
protected override bool HasSprite(Map.BBTile tile, Vec2I pos, Vec2I subTile) => tile.bldgMain != null && tile.bldgMain.Oversized() && subTile == Vec2I.zero;
protected override bool HasSprite(Map.BBTile tile, Vec2I pos, Vec2I subTile) => tile.bldgMain != null && (tile.bldgMain.TiledRender() || subTile == Vec2I.zero);
protected override TileSprite GetSprite(Map.BBTile tile, Vec2I pos, Vec2I subTile) => tile.terrain.GetSprite(map, pos, subTile);
// TODO:Kludge protected override bool HasSprite(Map.BBTile tile, Vec2I pos, Vec2I subTile) => tile.terrain.def != Terrain.K_grassDef;
protected override bool HasSprite(Map.BBTile tile, Vec2I pos, Vec2I subTile) => true;