Пример #1
0
        BuildingDist FragmentShader(VertexOut vertex, Field <BuildingDist> Path, Field <data> Data, Field <unit> Unit)
        {
            BuildingDist output = BuildingDist.Nothing;

            data data_here = Data[Here];
            unit unit_here = Unit[Here];

            if (Something(data_here) && (IsBuilding(unit_here) || unit_here.type == UnitType.DragonLord || unit_here.type == UnitType.Necromancer))
            {
                float type = unit_here.type;
                if (type == UnitType.DragonLord)
                {
                    type = UnitType.DragonLordIcon;
                }
                if (type == UnitType.Necromancer)
                {
                    type = UnitType.NecromancerIcon;
                }

                set_type(ref output, type);
                set_player(ref output, unit_here.player);
                output.diff = CenterOffset;
                output.dist = _0;
            }
            else
            {
                BuildingDist
                    right = Path[RightOne],
                    up    = Path[UpOne],
                    left  = Path[LeftOne],
                    down  = Path[DownOne];

                float min_dist = _255;
                if (left.dist < min_dist)
                {
                    output.player_and_type = left.player_and_type; min_dist = left.dist;  output.diff = left.diff - vec(_1, _0);
                }
                if (down.dist < min_dist)
                {
                    output.player_and_type = down.player_and_type; min_dist = down.dist;  output.diff = down.diff - vec(_0, _1);
                }
                if (right.dist < min_dist)
                {
                    output.player_and_type = right.player_and_type; min_dist = right.dist; output.diff = right.diff + vec(_1, _0);
                }
                if (up.dist < min_dist)
                {
                    output.player_and_type = up.player_and_type; min_dist = up.dist;    output.diff = up.diff + vec(_0, _1);
                }

                output.dist = min_dist + _1;
            }

            return(output);
        }
Пример #2
0
        color FragmentShader(VertexOut vertex, Field <BuildingDist> BuildingDistances, Field <building> Data, Field <unit> Unit, float blend, float radius, [Player.Vals] float player)
        {
            BuildingDist info = BuildingDistances[Here];

            if (info.dist > _15)
            {
                return(color.TransparentBlack);
            }

            vec2 subcell_pos = get_subcell_pos(vertex, BuildingDistances.Size);

            // Get the building data by following the offset
            vec2     offset = Float(info.diff - Pathfinding_ToSpecial.CenterOffset);
            var      index  = new RelativeIndex(offset.x, offset.y);
            building b      = Data[index];
            unit     u      = Unit[index];

            // Get the distance from here to the building center
            float l = length(255 * (info.diff - Pathfinding_ToSpecial.CenterOffset) - (subcell_pos - vec(.5f, .5f)));

            // Draw pixel
            if (fake_selected(b) && u.player == player)
            {
                if (l > .8f * radius && l < radius * 1.15f)
                {
                    color clr = SelectedUnitColor.Get(get_player(info)) * .75f;
                    clr.a = 1;
                    return(clr * blend);
                }

                if (l < radius)
                {
                    color clr = BuildingMarkerColors.Get(get_player(info), get_type(info)) * 1f;
                    clr.a = 1;
                    return(clr * blend);
                }
            }
            else
            {
                if (l < radius)
                {
                    color clr = BuildingMarkerColors.Get(get_player(info), get_type(info));
                    return(clr * blend);
                }
            }

            return(color.TransparentBlack);
        }
Пример #3
0
 protected static void set_player(ref BuildingDist u, float player)
 {
     u.player_and_type = player + get_type(u) * type_offset;
 }
Пример #4
0
 protected static float get_player(BuildingDist u)
 {
     return(u.player_and_type - get_type(u) * type_offset);
 }
Пример #5
0
 protected static void set_type(ref BuildingDist u, float type)
 {
     u.player_and_type = get_player(u) + type * type_offset;
 }
Пример #6
0
 protected static float get_type(BuildingDist u)
 {
     return(fint_round(u.player_and_type / type_offset));
 }