Terraria.Lighting.GetSubLight C# (CSharp) Method

GetSubLight() public static method

public static GetSubLight ( Vector2 position ) : Vector3
position Vector2
return Vector3
        public static Vector3 GetSubLight(Vector2 position)
        {
            Vector2 vector2_1 = position / 16f - new Vector2(0.5f, 0.5f);
            Vector2 vector2_2 = new Vector2(vector2_1.X % 1f, vector2_1.Y % 1f);
            int index1 = (int)vector2_1.X - Lighting.firstTileX + Lighting.offScreenTiles;
            int index2 = (int)vector2_1.Y - 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))
                return Vector3.One;
            Vector3 vector3_1 = Lighting.states[index1][index2].ToVector3();
            Vector3 vector3_2 = Lighting.states[index1 + 1][index2].ToVector3();
            Vector3 vector3_3 = Lighting.states[index1][index2 + 1].ToVector3();
            Vector3 vector3_4 = Lighting.states[index1 + 1][index2 + 1].ToVector3();
            return Vector3.Lerp(Vector3.Lerp(vector3_1, vector3_2, vector2_2.X), Vector3.Lerp(vector3_3, vector3_4, vector2_2.X), vector2_2.Y);
        }