tModLoader  0.12 Alpha
A mod to make and play Terraria mods
Terraria.ModLoader.PosData< T > Class Template Reference

Classes

class  OrderedSparseLookupBuilder
 Efficient builder for PosData<T>[] lookups covering the whole world. Must add elements in ascending pos order. More...
 
class  OrderedSparseLookupReader
 

Public Member Functions

 PosData (int pos, T value)
 
 PosData (int x, int y, T value)
 

Static Public Member Functions

static int CoordsToPos (int x, int y)
 Gets a Position ID based on the x,y position. If using in an order sensitive case, see NextLocation. More...
 
static PosData< T > Find< T > (this PosData< T >[] posMap, int pos)
 Raw lookup function. Always returns the raw entry in the position map. Use if default values returned are a concern, as negative position returned are ~'null' More...
 
static int FindIndex< T > (this PosData< T >[] posMap, int pos)
 Searches for the value i for which More...
 
static int FindIndex< T > (this PosData< T >[] posMap, int x, int y)
 
static T Lookup< T > (this PosData< T >[] posMap, int pos)
 General purpose lookup function. Always returns a value (even if that value is default). See PosData<T>.OrderedSparseLookupBuilder.OrderedSparseLookupBuilder(int, bool, bool)for more info More...
 
static T Lookup< T > (this PosData< T >[] posMap, int x, int y)
 General purpose lookup function. Always returns a value (even if that value is default). See PosData<T>.OrderedSparseLookupBuilder.OrderedSparseLookupBuilder(int, bool, bool)for more info More...
 
static bool LookupExact< T > (this PosData< T >[] posMap, int pos, out T data)
 For use with uncompressed sparse data lookups. Checks that the exact position exists in the lookup table. More...
 
static bool LookupExact< T > (this PosData< T >[] posMap, int x, int y, out T data)
 For use with uncompressed sparse data lookups. Checks that the exact position exists in the lookup table. More...
 
static bool NearbySearchOrderedPosMap< T > (PosData< T >[] posMap, Point pt, int distance, out PosData< T > entry)
 Searches around the provided point to check for the nearest entry in the map for OrdereredSparse data Doesn't work with 'compressed' lookups from PosData<T>.OrderedSparseLookupBuilder More...
 

Public Attributes

readonly int pos
 
value
 

Static Public Attributes

static PosData< T > nullPosData = new PosData<T>(-1, default)
 

Properties

int X [get]
 
int Y [get]
 

Member Function Documentation

◆ CoordsToPos()

static int Terraria.ModLoader.PosData< T >.CoordsToPos ( int  x,
int  y 
)
static

Gets a Position ID based on the x,y position. If using in an order sensitive case, see NextLocation.

Parameters
posX
posY
Returns

◆ Find< T >()

static PosData<T> Terraria.ModLoader.PosData< T >.Find< T > ( this PosData< T >[]  posMap,
int  pos 
)
static

Raw lookup function. Always returns the raw entry in the position map. Use if default values returned are a concern, as negative position returned are ~'null'

◆ FindIndex< T >()

static int Terraria.ModLoader.PosData< T >.FindIndex< T > ( this PosData< T >[]  posMap,
int  pos 
)
static

Searches for the value i for which

posMap[i].pos < pos < posMap[i + 1].pos

Returns
The index of the nearest entry with PosData<T>.pos <= pos or -1 if pos < posMap [0].pos

◆ Lookup< T >() [1/2]

static T Terraria.ModLoader.PosData< T >.Lookup< T > ( this PosData< T >[]  posMap,
int  pos 
)
static

General purpose lookup function. Always returns a value (even if that value is default). See PosData<T>.OrderedSparseLookupBuilder.OrderedSparseLookupBuilder(int, bool, bool)for more info

◆ Lookup< T >() [2/2]

static T Terraria.ModLoader.PosData< T >.Lookup< T > ( this PosData< T >[]  posMap,
int  x,
int  y 
)
static

General purpose lookup function. Always returns a value (even if that value is default). See PosData<T>.OrderedSparseLookupBuilder.OrderedSparseLookupBuilder(int, bool, bool)for more info

◆ LookupExact< T >() [1/2]

static bool Terraria.ModLoader.PosData< T >.LookupExact< T > ( this PosData< T >[]  posMap,
int  pos,
out T  data 
)
static

For use with uncompressed sparse data lookups. Checks that the exact position exists in the lookup table.

◆ LookupExact< T >() [2/2]

static bool Terraria.ModLoader.PosData< T >.LookupExact< T > ( this PosData< T >[]  posMap,
int  x,
int  y,
out T  data 
)
static

For use with uncompressed sparse data lookups. Checks that the exact position exists in the lookup table.

◆ NearbySearchOrderedPosMap< T >()

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

Searches around the provided point to check for the nearest entry in the map for OrdereredSparse data Doesn't work with 'compressed' lookups from PosData<T>.OrderedSparseLookupBuilder

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