Refactor entity movement and add Math.Nearest function
Simplifies entity movement logic in client_entity.lua by improving coordinate comparison and updating behavior triggers. Adds a new Math.Nearest function in math.lua to round values to the nearest whole number.
This commit is contained in:
1 parent
debfb06231
commit
18748bd775
2 files changed
+23
-19
No files matched your search
@@ -3,7 +3,7 @@ Math = Math or {}
|
||||
|
||||
|
||||
---@class Math
|
||||
------@field public name string @add name field to class Car, you'll see it in code completion
|
||||
---@field public name string @add name field to class Car, you'll see it in code completion
|
||||
Math = {}
|
||||
|
||||
|
||||
@@ -44,6 +44,13 @@ function Math.Smooth(value, min, max)
|
||||
return value * value * (3 - 2 * value)
|
||||
end
|
||||
|
||||
--- Gets the nearest whole number.
|
||||
--- @param value number The value to round.
|
||||
--- @return number The rounded value.
|
||||
function Math.Nearest(value)
|
||||
return math.floor(value + 0.5)
|
||||
end
|
||||
|
||||
--- Maps a value from one range to another.
|
||||
---@param value number The value to map.
|
||||
---@param inMin number The minimum value for the provided value.
|
||||
|
||||
Reference in new issue
Block a user