Terraria.Lighting.GetColor9Slice C# (CSharp) Method

GetColor9Slice() public static method

public static GetColor9Slice ( int centerX, int centerY, Color &slices ) : void
centerX int
centerY int
slices Color
return void
        public static void GetColor9Slice(int centerX, int centerY, ref Color[] slices)
        {
            int num1 = centerX - Lighting.firstTileX + Lighting.offScreenTiles;
            int num2 = centerY - Lighting.firstTileY + Lighting.offScreenTiles;
            if (num1 <= 0 || num2 <= 0 || (num1 >= Main.screenWidth / 16 + Lighting.offScreenTiles * 2 + 10 - 1 || num2 >= Main.screenHeight / 16 + Lighting.offScreenTiles * 2 - 1))
            {
                for (int index = 0; index < 9; ++index)
                    slices[index] = Color.Black;
            }
            else
            {
                int index1 = 0;
                for (int index2 = num1 - 1; index2 <= num1 + 1; ++index2)
                {
                    Lighting.LightingState[] lightingStateArray = Lighting.states[index2];
                    for (int index3 = num2 - 1; index3 <= num2 + 1; ++index3)
                    {
                        Lighting.LightingState lightingState = lightingStateArray[index3];
                        int num3 = (int)((double)byte.MaxValue * (double)lightingState.r * (double)Lighting.brightness);
                        int num4 = (int)((double)byte.MaxValue * (double)lightingState.g * (double)Lighting.brightness);
                        int num5 = (int)((double)byte.MaxValue * (double)lightingState.b * (double)Lighting.brightness);
                        if (num3 > (int)byte.MaxValue)
                            num3 = (int)byte.MaxValue;
                        if (num4 > (int)byte.MaxValue)
                            num4 = (int)byte.MaxValue;
                        if (num5 > (int)byte.MaxValue)
                            num5 = (int)byte.MaxValue;
                        slices[index1] = new Color((int)(byte)num3, (int)(byte)num4, (int)(byte)num5, (int)byte.MaxValue);
                        index1 += 3;
                    }
                    index1 -= 8;
                }
            }
        }