API Reference › Shared
Helper
ClassNamespace: SwiftlyS2.Shared · Assembly: SwiftlyS2.CS2.dll
public static class HelperInherits object
Methods
Convert the pointer to the protobuf class.
public static T AsProtobuf<T>(nint ptr, bool manuallyAllocated) where T : ITypedProtobuf<T>Parameters
Returns
T
The protobuf class.
Convert the pointer to the schema class.
public static T AsSchema<T>(nint ptr) where T : ISchemaClass<T>Parameters
- ptrnintThe pointer to the schema class.
Returns
T
The schema class.
Replace the color codes in the text with the corresponding color codes.
public static string Colored(this string text)Parameters
- textstringThe text to replace the color codes in.
Estimates the display width of a text string based on character types.
public static float EstimateTextWidth(string text)Parameters
- textstringThe text string to measure.
Estimates the display width of a character based on its type. Inspired by: https://github.com/spectreconsole/wcwidth
public static float GetCharWidth(char c)Parameters
- ccharThe character to measure.
Get the size of a schema class.
public static int GetSchemaSize<T>() where T : ISchemaClass<T>Parses a hex color string and returns the RGBA color components.
public static (int? r, int? g, int? b, int? a) ParseHexColor(string hexColor, bool alphaFirst = false)Parameters