Closed alux35 closed 3 years ago
The deluxe scarecrow range calculation is incorrect, at least according to some guy on reddit.
Here's an implementation using the distance calculation that he uses:
private static int[][] GetCircularMask(int radius)
{
int size = 2 * radius + 1;
int[][] result = new int[size][];
for (int i = 0; i < size; i++)
{
result[i] = new int[size];
for (int j = 0; j < size; j++)
{
int val = (Math.Truncate(Math.Sqrt((radius - i) * (radius - i) + (radius - j) * (radius - j))) <= radius) ? 1 : 0;
result[i][j] = val;
}
}
return result;
}
Tangentially related to this PR: I'm not sure it's a great idea to have all of the ranges in ModConfig, leading to SMAPI generating a 726 line config.json
file for the mod before the scarecrow ranges were moved over there (and thousands of lines after), but whatever. :shrug:
The Deluxe Scarecrow range is fixed now in Annosz's fork, so this PR is no longer necessary: https://github.com/Annosz/UIInfoSuite2
Moved scarecrow overlay calculation to the ModConfig file and added a calculation for the Deluxe Scarecrow. Changed code in ShowItemEffectRanges to pull the correct scarecrow for the current item and already placed items.