📚 Native/Misc

此类是一个功能组合类,可能包含开发阶段会用到的功能合集。

📒 Static Function

📘 Misc.Lerp()

执行一段Lerp差值计算。

function Lerp( a: float, b: float, t: float ): float

📘 Misc.LerpAngle()

执行一段LerpAngle差值计算,与普通Lerp不同的是,这将自动计算并重置360度时的角度信息。

function LerpAngle( a: float, b: float, t: float ): float

📘 Misc.LerpVector()

执行一段LerpVector差值计算。

function LerpVector( a: Vector, b: Vector, t: float ): Vector

📘 Misc.LerpColor()

执行一段LerpColor差值计算。

function LerpColor( a: Color, b: Color, t: float ): Color

📘 Misc.Clamp()

将一个数值限制在指定大小范围内。

function Clamp( value: float, min: float, max: float ): float

📘 Misc.HEXToColor()

将一段HEX格式颜色代码转换为颜色对象(#FFFFFF)。

function HEXToColor( hex: string ): Color

📘 Misc.ColorToHEX()

将颜色对象转换为HEX格式颜色代码(#FFFFFF)。

hasAlpha参数决定是否包含后面2位透明度。

function ColorToHEX( color: Color, hasAlpha: bool = false ): string

📘 Misc.GetModelByPropID()

获取指定道具使用的模型ID,如不存在则返回-1

function GetModelByPropID( prop: int ): int

📘 Misc.GetRandomPropID()

获取随机道具ID(可根据道具类型筛选,默认参数不筛选-1),如不存在则返回-1

function GetRandomPropID( type: int = -1 ): int

📘 Misc.GetPropLevelColor()

获取引擎内置道具等级颜色。

function GetPropLevelColor( level: int ): Color

📘 Misc.GetModelBoundSize()

获取指定模型的标准包围尺寸,如不存在则返回-1

function GetModelBoundSize( model: int ): float

📘 Misc.GetPropSourceData()

获取指定游戏道具原始数据,如果未被重写过,则返回引擎原始数据。

function GetPropSourceData( prop: int, keyPath: string ): any

📘 Misc.GetVehicleSourceData()

获取指定游戏载具原始数据,如果未被重写过,则返回引擎原始数据。

function GetVehicleSourceData( vehicle: int, keyPath: string ): any

📘 Misc.SnapVector()

获取按比例对齐后的Vector坐标。

function SnapVector( input: Vector, snapValue: float ): Vector

📘 Misc.SnapVector2()

获取按比例对齐后的Vector2坐标。

function SnapVector2( input: Vector, snapValue: float ): Vector2

📘 Misc.SnapVectorAxis()

获取按比例对齐后的Vector坐标(按轴分配)。

function SnapVectorAxis( input: Vector, snapValue: Vector ): Vector

📘 Misc.SnapVector2Axis()

获取按比例对齐后的Vector2坐标(按轴分配)。

function SnapVector2Axis( input: Vector2, snapValue: Vector2 ): Vector2

📘 Misc.VectorToString()

序列化Vector到字符串格式(x|y|z)。

function VectorToString( input: Vector ): string

📘 Misc.StringToVector()

反序列化字符串格式(x|y|z)到Vector

function StringToVector( input: string ): Vector

📘 Misc.Vector2ToString()

序列化Vector2到字符串格式(x|y)。

function Vector2ToString( input: Vector2 ): string

📘 Misc.StringToVector2()

反序列化字符串格式(x|y)到Vector2

function StringToVector2( input: string ): Vector2

📘 Misc.InPoly()

获取某个点是否在多边形点范围内(X\Z是否在某片2D形状范围内)。

注意:此方法判断坐标系只需要X\Z轴,Y轴数值可以忽略(最低要求输入3个多边形点,最多支持8个多边形点验证)。

function InPoly( pos: Vector, p1: Vector, p2: Vector, p3: Vector, p4: Vector = null, p5: Vector = null, p6: Vector = null, p7: Vector = null, p8: Vector = null ): bool
DLog(InPoly(Vector(0, 0, 0), Vector(-10, 0, -10), Vector(-10, 0, 10), Vector(10, 0, 10), Vector(10, 0, -10))); //返回true

📘 Misc.Distance()

获取两个坐标点之间的距离,单位是沙盘引擎世界距离。

注意:此方法将获得精准的距离数据,如果大量调用可能会影响性能,考虑使用距离平方(DistanceSqrt)。

function Distance( pos: Vector, pos2: Vector ): float

📘 Misc.DistanceSqrt()

获取两个坐标点之间的距离平方

注意:此方法将获得距离平方,应该使用Distance * Distance作为最终距离判断。

function DistanceSqrt( pos: Vector, pos2: Vector ): float

📘 Misc.GreaterDistance()

获取两个坐标点之间距离是否大于目标距离。

注意:此方法内部使用距离平方运算,距离可能不会特别精准(但性能更高),可以按照常规Distance方式使用。

function GreaterDistance( pos: Vector, pos2: Vector, distance: float ): bool

📘 Misc.IsUBBText()

检查文本是否包含UBB\HTML格式。

注意:此方法只会检查受引擎支持的标签(例如:img | color | size等,不会检查自定义标签)。

function IsUBBText( text: string ): bool