Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
Terraria.Utils Class Reference

Classes

struct  ChaseResults
 

Public Member Functions

delegate bool TileActionAttempt (int x, int y)
 
delegate void LaserLineFraming (int stage, Vector2 currentPosition, float distanceLeft, Rectangle lastFrame, out float distanceCovered, out Rectangle frame, out Vector2 origin, out Color color)
 
delegate Color ColorLerpMethod (float percent)
 

Static Public Member Functions

static Color ColorLerp_BlackToWhite (float percent)
 
static double Lerp (double value1, double value2, double amount)
 
static Vector2 Round (Vector2 input)
 
static bool IsPowerOfTwo (int x)
 
static float SmoothStep (float min, float max, float x)
 
static double SmoothStep (double min, double max, double x)
 
static float UnclampedSmoothStep (float min, float max, float x)
 
static double UnclampedSmoothStep (double min, double max, double x)
 
static Dictionary< string, stringParseArguements (string[] args)
 
static void Swap< T > (ref T t1, ref T t2)
 
static T Clamp< T > (T value, T min, T max)
 
static float Turn01ToCyclic010 (float value)
 
static float PingPongFrom01To010 (float value)
 
static float MultiLerp (float percent, params float[] floats)
 
static float WrappedLerp (float value1, float value2, float percent)
 
static float GetLerpValue (float from, float to, float t, bool clamped=false)
 
static float Remap (float fromValue, float fromMin, float fromMax, float toMin, float toMax, bool clamped=true)
 
static void ClampWithinWorld (ref int minX, ref int minY, ref int maxX, ref int maxY, bool lastValuesInclusiveToIteration=false, int fluffX=0, int fluffY=0)
 
static ChaseResults GetChaseResults (Vector2 chaserPosition, float chaserSpeed, Vector2 runnerPosition, Vector2 runnerVelocity)
 
static Vector2 FactorAcceleration (Vector2 currentVelocity, float timeToInterception, Vector2 descendOfProjectile, int framesOfLenience)
 
static bool SolveQuadratic (float a, float b, float c, out float result1, out float result2)
 
static double GetLerpValue (double from, double to, double t, bool clamped=false)
 
static float GetDayTimeAs24FloatStartingFromMidnight ()
 
static Vector2 GetDayTimeAsDirectionIn24HClock ()
 
static Vector2 GetDayTimeAsDirectionIn24HClock (float timeFrom0To24)
 
static string[] ConvertMonoArgsToDotNet (string[] brokenArgs)
 
static T Max< T > (params T[] args)
 
static float LineRectangleDistance (Rectangle rect, Vector2 lineStart, Vector2 lineEnd)
 
static List< List< TextSnippet > > WordwrapStringSmart (string text, Color c, DynamicSpriteFont font, int maxWidth, int maxLines)
 
static string[] WordwrapString (string text, DynamicSpriteFont font, int maxWidth, int maxLines, out int lineAmount)
 
static Rectangle CenteredRectangle (Vector2 center, Vector2 size)
 
static Vector2 Vector2FromElipse (Vector2 angleVector, Vector2 elipseSizes)
 
static bool FloatIntersect (float r1StartX, float r1StartY, float r1Width, float r1Height, float r2StartX, float r2StartY, float r2Width, float r2Height)
 
static long CoinsCount (out bool overFlowing, Item[] inv, params int[] ignoreSlots)
 
static int[] CoinsSplit (long count)
 
static long CoinsCombineStacks (out bool overFlowing, params long[] coinCounts)
 
static void PoofOfSmoke (Vector2 position)
 
static Vector2 ToScreenPosition (this Vector2 worldPosition)
 
static string PrettifyPercentDisplay (float percent, string originalFormat)
 
static void TrimTextIfNeeded (ref string text, DynamicSpriteFont font, float scale, float maxWidth)
 
static string FormatWith (string original, object obj)
 
static bool TryCreatingDirectory (string folderPath)
 
static void OpenFolder (string folderPath)
 
static byte[] ToByteArray (this string str)
 
static float NextFloat (this UnifiedRandom r)
 
static float NextFloatDirection (this UnifiedRandom r)
 
static float NextFloat (this UnifiedRandom random, FloatRange range)
 
static T NextFromList< T > (this UnifiedRandom random, params T[] objs)
 
static T NextFromCollection< T > (this UnifiedRandom random, List< T > objs)
 
static int Next (this UnifiedRandom random, IntRange range)
 
static Vector2 NextVector2Square (this UnifiedRandom r, float min, float max)
 
static Vector2 NextVector2FromRectangle (this UnifiedRandom r, Rectangle rect)
 
static Vector2 NextVector2Unit (this UnifiedRandom r, float startRotation=0f, float rotationRange=(float) Math.PI *2f)
 
static Vector2 NextVector2Circular (this UnifiedRandom r, float circleHalfWidth, float circleHalfHeight)
 
static Vector2 NextVector2CircularEdge (this UnifiedRandom r, float circleHalfWidth, float circleHalfHeight)
 
static int Width (this Asset< Texture2D > asset)
 
static int Height (this Asset< Texture2D > asset)
 
static Rectangle Frame (this Asset< Texture2D > tex, int horizontalFrames=1, int verticalFrames=1, int frameX=0, int frameY=0, int sizeOffsetX=0, int sizeOffsetY=0)
 
static Rectangle OffsetSize (this Rectangle rect, int xSize, int ySize)
 
static Vector2 Size (this Asset< Texture2D > tex)
 
static Rectangle Frame (this Texture2D tex, int horizontalFrames=1, int verticalFrames=1, int frameX=0, int frameY=0, int sizeOffsetX=0, int sizeOffsetY=0)
 
static Vector2 OriginFlip (this Rectangle rect, Vector2 origin, SpriteEffects effects)
 
static Vector2 Size (this Texture2D tex)
 
static void WriteRGB (this BinaryWriter bb, Color c)
 
static void WriteVector2 (this BinaryWriter bb, Vector2 v)
 
static void WritePackedVector2 (this BinaryWriter bb, Vector2 v)
 
static Color ReadRGB (this BinaryReader bb)
 
static Vector2 ReadVector2 (this BinaryReader bb)
 
static Vector2 ReadPackedVector2 (this BinaryReader bb)
 
static Vector2 Left (this Rectangle r)
 
static Vector2 Right (this Rectangle r)
 
static Vector2 Top (this Rectangle r)
 
static Vector2 Bottom (this Rectangle r)
 
static Vector2 TopLeft (this Rectangle r)
 
static Vector2 TopRight (this Rectangle r)
 
static Vector2 BottomLeft (this Rectangle r)
 
static Vector2 BottomRight (this Rectangle r)
 
static Vector2 Center (this Rectangle r)
 
static Vector2 Size (this Rectangle r)
 
static float Distance (this Rectangle r, Vector2 point)
 
static Vector2 ClosestPointInRect (this Rectangle r, Vector2 point)
 
static Rectangle Modified (this Rectangle r, int x, int y, int w, int h)
 
static bool IntersectsConeFastInaccurate (this Rectangle targetRect, Vector2 coneCenter, float coneLength, float coneRotation, float maximumAngle)
 
static bool IntersectsConeSlowMoreAccurate (this Rectangle targetRect, Vector2 coneCenter, float coneLength, float coneRotation, float maximumAngle)
 
static bool DoesFitInCone (Vector2 point, Vector2 coneCenter, float coneLength, float coneRotation, float maximumAngle)
 
static float ToRotation (this Vector2 v)
 
static Vector2 ToRotationVector2 (this float f)
 
static Vector2 RotatedBy (this Vector2 spinningpoint, double radians, Vector2 center=default(Vector2))
 
static Vector2D RotatedBy (this Vector2D spinningpoint, double radians, Vector2D center=default(Vector2D))
 
static Vector2 RotatedByRandom (this Vector2 spinninpoint, double maxRadians)
 
static Vector2 Floor (this Vector2 vec)
 
static bool HasNaNs (this Vector2 vec)
 
static bool Between (this Vector2 vec, Vector2 minimum, Vector2 maximum)
 
static Vector2 ToVector2 (this Point p)
 
static Vector2 ToVector2 (this Point16 p)
 
static Vector2D ToVector2D (this Point p)
 
static Vector2D ToVector2D (this Point16 p)
 
static Vector2 ToWorldCoordinates (this Point p, float autoAddX=8f, float autoAddY=8f)
 
static Vector2 ToWorldCoordinates (this Point16 p, float autoAddX=8f, float autoAddY=8f)
 
static Vector2 MoveTowards (this Vector2 currentPosition, Vector2 targetPosition, float maxAmountAllowedToMove)
 
static Point16 ToTileCoordinates16 (this Vector2 vec)
 
static Point16 ToTileCoordinates16 (this Vector2D vec)
 
static Point ToTileCoordinates (this Vector2 vec)
 
static Point ToTileCoordinates (this Vector2D vec)
 
static Point ToPoint (this Vector2 v)
 
static Point ToPoint (this Vector2D v)
 
static Vector2D ToVector2D (this Vector2 v)
 
static Vector2 SafeNormalize (this Vector2 v, Vector2 defaultValue)
 
static Vector2 ClosestPointOnLine (this Vector2 P, Vector2 A, Vector2 B)
 
static bool RectangleLineCollision (Vector2 rectTopLeft, Vector2 rectBottomRight, Vector2 lineStart, Vector2 lineEnd)
 
static Vector2 RotateRandom (this Vector2 spinninpoint, double maxRadians)
 
static float AngleTo (this Vector2 Origin, Vector2 Target)
 
static float AngleFrom (this Vector2 Origin, Vector2 Target)
 
static Vector2 rotateTowards (Vector2 currentPosition, Vector2 currentVelocity, Vector2 targetPosition, float maxChange)
 
static float Distance (this Vector2 Origin, Vector2 Target)
 
static float DistanceSQ (this Vector2 Origin, Vector2 Target)
 
static Vector2 DirectionTo (this Vector2 Origin, Vector2 Target)
 
static Vector2 DirectionFrom (this Vector2 Origin, Vector2 Target)
 
static bool WithinRange (this Vector2 Origin, Vector2 Target, float MaxRange)
 
static Vector2 XY (this Vector4 vec)
 
static Vector2 ZW (this Vector4 vec)
 
static Vector3 XZW (this Vector4 vec)
 
static Vector3 YZW (this Vector4 vec)
 
static Color MultiplyRGB (this Color firstColor, Color secondColor)
 
static Color MultiplyRGBA (this Color firstColor, Color secondColor)
 
static string Hex3 (this Color color)
 
static string Hex4 (this Color color)
 
static int ToDirectionInt (this bool value)
 
static int ToInt (this bool value)
 
static int ModulusPositive (this int myInteger, int modulusNumber)
 
static float AngleLerp (this float curAngle, float targetAngle, float amount)
 
static float AngleTowards (this float curAngle, float targetAngle, float maxChange)
 
static bool deepCompare (this int[] firstArray, int[] secondArray)
 
static List< int > GetTrueIndexes (this bool[] array)
 
static List< int > GetTrueIndexes (params bool[][] arrays)
 
static int Count< T > (this T[] arr, T value)
 
static bool PressingShift (this KeyboardState kb)
 
static bool PressingControl (this KeyboardState kb)
 
static R[] MapArray< T, R > (T[] array, Func< T, R > mapper)
 
static bool PlotLine (Point16 p0, Point16 p1, TileActionAttempt plot, bool jump=true)
 
static bool PlotLine (Point p0, Point p1, TileActionAttempt plot, bool jump=true)
 
static int RandomNext (ref ulong seed, int bits)
 
static ulong RandomNextSeed (ulong seed)
 
static float RandomFloat (ref ulong seed)
 
static int RandomInt (ref ulong seed, int max)
 
static int RandomInt (ref ulong seed, int min, int max)
 
static bool PlotTileLine (Vector2 start, Vector2 end, float width, TileActionAttempt plot)
 
static bool PlotTileLine (Vector2D start, Vector2D end, double width, TileActionAttempt plot)
 
static bool PlotTileTale (Vector2D start, Vector2D end, double width, TileActionAttempt plot)
 
static bool PlotTileArea (int x, int y, TileActionAttempt plot)
 
static int RandomConsecutive (double random, int odds)
 
static Vector2 RandomVector2 (UnifiedRandom random, float min, float max)
 
static Vector2D RandomVector2D (UnifiedRandom random, double min, double max)
 
static bool IndexInRange< T > (this T[] t, int index)
 
static bool IndexInRange< T > (this List< T > t, int index)
 
static T SelectRandom< T > (UnifiedRandom random, params T[] choices)
 
static void DrawBorderStringFourWay (SpriteBatch sb, DynamicSpriteFont font, string text, float x, float y, Color textColor, Color borderColor, Vector2 origin, float scale=1f)
 
static Vector2 DrawBorderString (SpriteBatch sb, string text, Vector2 pos, Color color, float scale=1f, float anchorx=0f, float anchory=0f, int maxCharactersDisplayed=-1)
 
static Vector2 DrawBorderStringBig (SpriteBatch spriteBatch, string text, Vector2 pos, Color color, float scale=1f, float anchorx=0f, float anchory=0f, int maxCharactersDisplayed=-1)
 
static void DrawInvBG (SpriteBatch sb, Rectangle R, Color c=default(Color))
 
static void DrawInvBG (SpriteBatch sb, float x, float y, float w, float h, Color c=default(Color))
 
static void DrawInvBG (SpriteBatch sb, int x, int y, int w, int h, Color c=default(Color))
 
static string ReadEmbeddedResource (string path)
 
static void DrawSplicedPanel (SpriteBatch sb, Texture2D texture, int x, int y, int w, int h, int leftEnd, int rightEnd, int topEnd, int bottomEnd, Color c)
 
static void DrawSettingsPanel (SpriteBatch spriteBatch, Vector2 position, float width, Color color)
 
static void DrawSettings2Panel (SpriteBatch spriteBatch, Vector2 position, float width, Color color)
 
static void DrawPanel (Texture2D texture, int edgeWidth, int edgeShove, SpriteBatch spriteBatch, Vector2 position, float width, Color color)
 
static void DrawRectangle (SpriteBatch sb, Vector2 start, Vector2 end, Color colorStart, Color colorEnd, float width)
 
static void DrawLaser (SpriteBatch sb, Texture2D tex, Vector2 start, Vector2 end, Vector2 scale, LaserLineFraming framing)
 
static void DrawLine (SpriteBatch spriteBatch, Point start, Point end, Color color)
 
static void DrawLine (SpriteBatch spriteBatch, Vector2 start, Vector2 end, Color color)
 
static void DrawLine (SpriteBatch spriteBatch, Vector2 start, Vector2 end, Color colorStart, Color colorEnd, float width)
 
static void DrawRectForTilesInWorld (SpriteBatch spriteBatch, Rectangle rect, Color color)
 
static void DrawRectForTilesInWorld (SpriteBatch spriteBatch, Point start, Point end, Color color)
 
static void DrawRect (SpriteBatch spriteBatch, Rectangle rect, Color color)
 
static void DrawRect (SpriteBatch spriteBatch, Vector2 start, Vector2 end, Color color)
 
static void DrawRect (SpriteBatch spriteBatch, Vector2 topLeft, Vector2 topRight, Vector2 bottomRight, Vector2 bottomLeft, Color color)
 
static void DrawCursorSingle (SpriteBatch sb, Color color, float rot=float.NaN, float scale=1f, Vector2 manualPosition=default(Vector2), int cursorSlot=0, int specialMode=0)
 

Static Public Attributes

const long MaxCoins = 999999999L
 
static Dictionary< DynamicSpriteFont, float[]> charLengths = new Dictionary<DynamicSpriteFont, float[]>()
 

Static Private Member Functions

static bool PlotLine (int x0, int y0, int x1, int y1, TileActionAttempt plot, bool jump=true)
 

Static Private Attributes

static Regex _substitutionRegex = new Regex("{(\\?(?:!)?)?([a-zA-Z][\\w\\.]*)}", RegexOptions.Compiled)
 
const ulong RANDOM_MULTIPLIER = 25214903917uL
 
const ulong RANDOM_ADD = 11uL
 
const ulong RANDOM_MASK = 281474976710655uL
 

Detailed Description

Definition at line 28 of file Utils.cs.


The documentation for this class was generated from the following file: