Пример #1
0
        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));
                        }
                    }
                }
            }
        }
Пример #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);
        }
Пример #3
0
        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);
        }
Пример #4
0
 public Tile(Map.BBTile tile, Vec2I pos)
 {
     BB.AssertNotNull(tile);
     this.tile = tile;
     this.pos  = pos;
 }
Пример #5
0
 protected abstract TileSprite GetSprite(Map.BBTile tile, Vec2I pos, Vec2I subTile);
Пример #6
0
 protected abstract bool HasSprite(Map.BBTile tile, Vec2I pos, Vec2I subTile);
Пример #7
0
 protected override TileSprite GetSprite(Map.BBTile tile, Vec2I pos, Vec2I subTile)
 => tile.bldgMain.GetSpriteOver(pos);
Пример #8
0
 protected override bool HasSprite(Map.BBTile tile, Vec2I pos, Vec2I subTile)
 => tile.bldgMain != null && tile.bldgMain.Oversized() && subTile == Vec2I.zero;
Пример #9
0
 protected override bool HasSprite(Map.BBTile tile, Vec2I pos, Vec2I subTile)
 => tile.bldgMain != null && (tile.bldgMain.TiledRender() || subTile == Vec2I.zero);
Пример #10
0
 protected override TileSprite GetSprite(Map.BBTile tile, Vec2I pos, Vec2I subTile)
 => tile.terrain.GetSprite(map, pos, subTile);
Пример #11
0
 // TODO:Kludge
 protected override bool HasSprite(Map.BBTile tile, Vec2I pos, Vec2I subTile)
 => tile.terrain.def != Terrain.K_grassDef;
Пример #12
0
 protected override bool HasSprite(Map.BBTile tile, Vec2I pos, Vec2I subTile) => true;