TModLoader v1.4.4.9
TModLoader source code documentation
Loading...
Searching...
No Matches

◆ NearbySearchOrderedPosMap< T >()

static bool Terraria.ModLoader.PosData< T >.NearbySearchOrderedPosMap< T > ( PosData< T >[] posMap,
Point pt,
int distance,
out PosData< T > entry )
inlinestatic

Searches around the provided point to check for the nearest entry in the map for OrdereredSparse data Doesn't work with 'compressed' lookups from T:Terraria.ModLoader.PosData`1.OrderedSparseLookupBuilder

Parameters
posMap
pt
distanceThe distance between the provided Point and nearby entry
entry
Returns
True if successfully found an entry nearby

Definition at line 236 of file PosData.cs.

237 {
238 //IL_001c: Unknown result type (might be due to invalid IL or missing references)
239 //IL_002a: Unknown result type (might be due to invalid IL or missing references)
240 //IL_003e: Unknown result type (might be due to invalid IL or missing references)
241 //IL_0052: Unknown result type (might be due to invalid IL or missing references)
242 //IL_00c6: Unknown result type (might be due to invalid IL or missing references)
243 //IL_00e1: Unknown result type (might be due to invalid IL or missing references)
244 entry = new PosData<T>(-1, default(T));
245 if (posMap.Length == 0)
246 {
247 return false;
248 }
249 int minPos = CoordsToPos(Math.Max(pt.X - distance, 0), Math.Max(pt.Y - distance, 0));
250 int maxPos = CoordsToPos(Math.Min(pt.X + distance, Main.maxTilesX - 1), Math.Min(pt.Y + distance, Main.maxTilesY - 1));
251 if (posMap[0].pos > maxPos || posMap[^1].pos < minPos)
252 {
253 return false;
254 }
255 int num = Math.Max(posMap.FindIndex(minPos), 0);
256 int maximum = Math.Max(posMap.FindIndex(maxPos), 0);
257 int bestSqDist = distance * distance + 1;
258 for (int i = num; i < maximum; i++)
259 {
261 int dy = posData.Y - pt.Y;
262 if (dy >= -distance && dy <= distance)
263 {
264 int num2 = posData.X - pt.X;
265 int sqDist = num2 * num2 + dy * dy;
266 if (sqDist < bestSqDist)
267 {
269 entry = posData;
270 }
271 }
272 }
273 return entry.pos >= 0;
274 }
static int CoordsToPos(int x, int y)
Gets a Position ID based on the x,y position. If using in an order sensitive case,...
Definition PosData.cs:140

References Terraria.ModLoader.PosData< T >.CoordsToPos(), Terraria.Main.maxTilesX, Terraria.Main.maxTilesY, and Terraria.ModLoader.PosData< T >.pos.

+ Here is the call graph for this function: