protected override IEnumerable <IRenderable> RenderFootprint(WorldRenderer wr, CPos topLeft, Dictionary <CPos, PlaceBuildingCellType> footprint,
                                                                     PlaceBuildingCellType filter = PlaceBuildingCellType.Invalid | PlaceBuildingCellType.Valid | PlaceBuildingCellType.LineBuild)
        {
            var cellPalette = wr.Palette(info.Palette);
            var linePalette = wr.Palette(info.LineBuildSegmentPalette);
            var topLeftPos  = wr.World.Map.CenterOfCell(topLeft);

            var candidateSafeTiles = unpathableCells.Update(topLeft);

            foreach (var c in footprint)
            {
                if ((c.Value & filter) == 0)
                {
                    continue;
                }

                var tile = HasFlag(c.Value, PlaceBuildingCellType.Invalid) ? buildBlocked :
                           candidateSafeTiles.Contains(c.Key) && info.UnsafeTerrainTypes.Contains(wr.World.Map.GetTerrainInfo(c.Key).Type)
                                        ? buildUnsafe : buildOk;

                var pal    = HasFlag(c.Value, PlaceBuildingCellType.LineBuild) ? linePalette : cellPalette;
                var pos    = wr.World.Map.CenterOfCell(c.Key);
                var offset = new WVec(0, 0, topLeftPos.Z - pos.Z);
                yield return(new SpriteRenderable(tile, pos, offset, -511, pal, 1f, true));
            }
        }
Ejemplo n.º 2
0
        protected override IEnumerable <IRenderable> RenderFootprint(WorldRenderer wr, CPos topLeft, Dictionary <CPos, PlaceBuildingCellType> footprint,
                                                                     PlaceBuildingCellType filter = PlaceBuildingCellType.Invalid | PlaceBuildingCellType.Valid | PlaceBuildingCellType.LineBuild)
        {
            var palette    = wr.Palette(info.Palette);
            var topLeftPos = wr.World.Map.CenterOfCell(topLeft);

            var candidateSafeTiles = unpathableCells.Update(topLeft);

            foreach (var c in footprint)
            {
                if ((c.Value & filter) == 0)
                {
                    continue;
                }

                var isUnsafe      = checkUnsafeTiles && candidateSafeTiles.Contains(c.Key) && info.UnsafeTerrainTypes.Contains(wr.World.Map.GetTerrainInfo(c.Key).Type);
                var tile          = (c.Value & PlaceBuildingCellType.Invalid) != 0 ? blockedTile : isUnsafe ? unsafeTile : validTile;
                var sequenceAlpha = (c.Value & PlaceBuildingCellType.Invalid) != 0 ? blockedAlpha : isUnsafe ? unsafeAlpha : validAlpha;

                var pos        = wr.World.Map.CenterOfCell(c.Key);
                var offset     = new WVec(0, 0, topLeftPos.Z - pos.Z);
                var traitAlpha = (c.Value & PlaceBuildingCellType.LineBuild) != 0 ? info.LineBuildFootprintAlpha : info.FootprintAlpha;
                yield return(new SpriteRenderable(tile, pos, offset, -511, palette, 1f, sequenceAlpha * traitAlpha, float3.Ones, TintModifiers.IgnoreWorldTint, true));
            }
        }
Ejemplo n.º 3
0
        protected virtual IEnumerable <IRenderable> RenderFootprint(WorldRenderer wr, CPos topLeft, Dictionary <CPos, PlaceBuildingCellType> footprint,
                                                                    PlaceBuildingCellType filter = PlaceBuildingCellType.Invalid | PlaceBuildingCellType.Valid | PlaceBuildingCellType.LineBuild)
        {
            var palette    = wr.Palette(info.Palette);
            var topLeftPos = wr.World.Map.CenterOfCell(topLeft);

            foreach (var c in footprint)
            {
                if ((c.Value & filter) == 0)
                {
                    continue;
                }

                var tile   = (c.Value & PlaceBuildingCellType.Invalid) != 0 ? buildBlocked : buildOk;
                var pos    = wr.World.Map.CenterOfCell(c.Key);
                var offset = new WVec(0, 0, topLeftPos.Z - pos.Z);
                var alpha  = (c.Value & PlaceBuildingCellType.LineBuild) != 0 ? info.LineBuildFootprintAlpha : info.FootprintAlpha;
                yield return(new SpriteRenderable(tile, pos, offset, -511, palette, 1f, alpha, float3.Ones, TintModifiers.IgnoreWorldTint, true));
            }
        }
Ejemplo n.º 4
0
        protected virtual IEnumerable <IRenderable> RenderFootprint(WorldRenderer wr, CPos topLeft, Dictionary <CPos, PlaceBuildingCellType> footprint,
                                                                    PlaceBuildingCellType filter = PlaceBuildingCellType.Invalid | PlaceBuildingCellType.Valid | PlaceBuildingCellType.LineBuild)
        {
            var cellPalette = wr.Palette(info.Palette);
            var linePalette = wr.Palette(info.LineBuildSegmentPalette);
            var topLeftPos  = wr.World.Map.CenterOfCell(topLeft);

            foreach (var c in footprint)
            {
                if ((c.Value & filter) == 0)
                {
                    continue;
                }

                var tile   = HasFlag(c.Value, PlaceBuildingCellType.Invalid) ? buildBlocked : buildOk;
                var pal    = HasFlag(c.Value, PlaceBuildingCellType.LineBuild) ? linePalette : cellPalette;
                var pos    = wr.World.Map.CenterOfCell(c.Key);
                var offset = new WVec(0, 0, topLeftPos.Z - pos.Z);
                yield return(new SpriteRenderable(tile, pos, offset, -511, pal, 1f, true, true));
            }
        }
Ejemplo n.º 5
0
 protected static bool HasFlag(PlaceBuildingCellType value, PlaceBuildingCellType flag)
 {
     // PERF: Enum.HasFlag is slower and requires allocations.
     return((value & flag) == value);
 }