Example #1
0
    ///////////////////////////////////////////////////////////////////////////

    protected override void DrawCircle(FogCircle shape)
    {
        int      fogradius    = Mathf.RoundToInt(shape.Radius * _Map.PixelSize);
        int      fogradiussqr = fogradius * fogradius;
        DrawInfo info         = new DrawInfo(_Map, shape, fogradius, fogradius);

        // view angle stuff
        float dotangle = 1 - shape.Angle / 90;

        for (int y = info.yMin; y <= info.yMax; ++y)
        {
            for (int x = info.xMin; x <= info.xMax; ++x)
            {
                // is pixel within circle radius
                Vector2 centeroffset = new Vector2(x, y) - info.fogCenterPos;
                if (shape.VisibleCells == null && centeroffset.sqrMagnitude >= fogradiussqr)
                {
                    continue;
                }

                // check if in view angle
                if (dotangle > -0.99f && Vector2.Dot(centeroffset.normalized, info.fogForward) <= dotangle)
                {
                    continue;
                }

                // can see pixel
                Vector2_1 offset = new Vector2_1(x, y) - info.fogEyePos;
                if (!LineOfSightCanSee(shape, offset.vector2, fogradius))
                {
                    continue;
                }

                if (!LineOfSightCanSeeCell(shape, offset))
                {
                    continue;
                }

                Unfog(x, y, shape.GetFallOff(centeroffset.magnitude / (_Map.PixelSize * shape.Radius)));
            }
        }
    }