Terraria.Lighting.GetColor4Slice_New C# (CSharp) Method

GetColor4Slice_New() public static method

public static GetColor4Slice_New ( int centerX, int centerY, VertexColors &vertices, Color centerColor, float scale = 1f ) : void
centerX int
centerY int
vertices VertexColors
centerColor Color
scale float
return void
        public static void GetColor4Slice_New(int centerX, int centerY, out VertexColors vertices, Color centerColor, float scale = 1f)
        {
            int index1 = centerX - Lighting.firstTileX + Lighting.offScreenTiles;
            int index2 = centerY - Lighting.firstTileY + Lighting.offScreenTiles;
            if (index1 <= 0 || index2 <= 0 || (index1 >= Main.screenWidth / 16 + Lighting.offScreenTiles * 2 + 10 - 1 || index2 >= Main.screenHeight / 16 + Lighting.offScreenTiles * 2 - 1))
            {
                vertices.BottomLeftColor = Color.Black;
                vertices.BottomRightColor = Color.Black;
                vertices.TopLeftColor = Color.Black;
                vertices.TopRightColor = Color.Black;
            }
            else
            {
                float num1 = (float)centerColor.R / (float)byte.MaxValue;
                float num2 = (float)centerColor.G / (float)byte.MaxValue;
                float num3 = (float)centerColor.B / (float)byte.MaxValue;
                Lighting.LightingState lightingState1 = Lighting.states[index1][index2 - 1];
                Lighting.LightingState lightingState2 = Lighting.states[index1][index2 + 1];
                Lighting.LightingState lightingState3 = Lighting.states[index1 - 1][index2];
                Lighting.LightingState lightingState4 = Lighting.states[index1 + 1][index2];
                Lighting.LightingState lightingState5 = Lighting.states[index1 - 1][index2 - 1];
                Lighting.LightingState lightingState6 = Lighting.states[index1 + 1][index2 - 1];
                Lighting.LightingState lightingState7 = Lighting.states[index1 - 1][index2 + 1];
                Lighting.LightingState lightingState8 = Lighting.states[index1 + 1][index2 + 1];
                float num4 = (float)((double)Lighting.brightness * (double)scale * (double)byte.MaxValue * 0.25);
                float num5 = (lightingState1.r + lightingState5.r + lightingState3.r + num1) * num4;
                float num6 = (lightingState1.g + lightingState5.g + lightingState3.g + num2) * num4;
                float num7 = (lightingState1.b + lightingState5.b + lightingState3.b + num3) * num4;
                if ((double)num5 > (double)byte.MaxValue)
                    num5 = (float)byte.MaxValue;
                if ((double)num6 > (double)byte.MaxValue)
                    num6 = (float)byte.MaxValue;
                if ((double)num7 > (double)byte.MaxValue)
                    num7 = (float)byte.MaxValue;
                vertices.TopLeftColor = new Color((int)(byte)num5, (int)(byte)num6, (int)(byte)num7, (int)byte.MaxValue);
                float num8 = (lightingState1.r + lightingState6.r + lightingState4.r + num1) * num4;
                float num9 = (lightingState1.g + lightingState6.g + lightingState4.g + num2) * num4;
                float num10 = (lightingState1.b + lightingState6.b + lightingState4.b + num3) * num4;
                if ((double)num8 > (double)byte.MaxValue)
                    num8 = (float)byte.MaxValue;
                if ((double)num9 > (double)byte.MaxValue)
                    num9 = (float)byte.MaxValue;
                if ((double)num10 > (double)byte.MaxValue)
                    num10 = (float)byte.MaxValue;
                vertices.TopRightColor = new Color((int)(byte)num8, (int)(byte)num9, (int)(byte)num10, (int)byte.MaxValue);
                float num11 = (lightingState2.r + lightingState7.r + lightingState3.r + num1) * num4;
                float num12 = (lightingState2.g + lightingState7.g + lightingState3.g + num2) * num4;
                float num13 = (lightingState2.b + lightingState7.b + lightingState3.b + num3) * num4;
                if ((double)num11 > (double)byte.MaxValue)
                    num11 = (float)byte.MaxValue;
                if ((double)num12 > (double)byte.MaxValue)
                    num12 = (float)byte.MaxValue;
                if ((double)num13 > (double)byte.MaxValue)
                    num13 = (float)byte.MaxValue;
                vertices.BottomLeftColor = new Color((int)(byte)num11, (int)(byte)num12, (int)(byte)num13, (int)byte.MaxValue);
                float num14 = (lightingState2.r + lightingState8.r + lightingState4.r + num1) * num4;
                float num15 = (lightingState2.g + lightingState8.g + lightingState4.g + num2) * num4;
                float num16 = (lightingState2.b + lightingState8.b + lightingState4.b + num3) * num4;
                if ((double)num14 > (double)byte.MaxValue)
                    num14 = (float)byte.MaxValue;
                if ((double)num15 > (double)byte.MaxValue)
                    num15 = (float)byte.MaxValue;
                if ((double)num16 > (double)byte.MaxValue)
                    num16 = (float)byte.MaxValue;
                vertices.BottomRightColor = new Color((int)(byte)num14, (int)(byte)num15, (int)(byte)num16, (int)byte.MaxValue);
            }
        }

Same methods

Lighting::GetColor4Slice_New ( int centerX, int centerY, VertexColors &vertices, float scale = 1f ) : void