isaacscript-common 1.2.93 → 1.2.94
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/functions/math.d.ts +1 -1
- package/dist/functions/math.lua +19 -19
- package/package.json +1 -1
package/dist/functions/math.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
export declare function countSetBits(n: int): int;
|
|
2
3
|
export declare function getAngleDifference(angle1: float, angle2: float): float;
|
|
3
4
|
/**
|
|
4
5
|
* Helper function to get an array of equidistant points on the circumference around a circle.
|
|
@@ -13,7 +14,6 @@ export declare function getAngleDifference(angle1: float, angle2: float): float;
|
|
|
13
14
|
* this can be optionally changed by specifying this argument.
|
|
14
15
|
*/
|
|
15
16
|
export declare function getCircleDiscretizedPoints(centerPos: Vector, radius: float, numPoints: int, xMultiplier?: number, yMultiplier?: number, initialDirection?: Direction): Vector[];
|
|
16
|
-
export declare function getSetBits(n: int): int;
|
|
17
17
|
/**
|
|
18
18
|
* Helper function to check if a given position is within a given rectangle. This is an inclusive
|
|
19
19
|
* check, meaning that it will return true if the position is on the border of the rectangle.
|
package/dist/functions/math.lua
CHANGED
|
@@ -7,33 +7,33 @@ local ____utils = require("functions.utils")
|
|
|
7
7
|
local ensureAllCases = ____utils.ensureAllCases
|
|
8
8
|
function getCircleInitialPosition(self, direction, radius)
|
|
9
9
|
repeat
|
|
10
|
-
local
|
|
11
|
-
local
|
|
12
|
-
if
|
|
10
|
+
local ____switch8 = direction
|
|
11
|
+
local ____cond8 = ____switch8 == Direction.NO_DIRECTION
|
|
12
|
+
if ____cond8 then
|
|
13
13
|
do
|
|
14
14
|
return Vector.Zero
|
|
15
15
|
end
|
|
16
16
|
end
|
|
17
|
-
|
|
18
|
-
if
|
|
17
|
+
____cond8 = ____cond8 or ____switch8 == Direction.LEFT
|
|
18
|
+
if ____cond8 then
|
|
19
19
|
do
|
|
20
20
|
return Vector(-radius, 0)
|
|
21
21
|
end
|
|
22
22
|
end
|
|
23
|
-
|
|
24
|
-
if
|
|
23
|
+
____cond8 = ____cond8 or ____switch8 == Direction.UP
|
|
24
|
+
if ____cond8 then
|
|
25
25
|
do
|
|
26
26
|
return Vector(0, -radius)
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
|
-
|
|
30
|
-
if
|
|
29
|
+
____cond8 = ____cond8 or ____switch8 == Direction.RIGHT
|
|
30
|
+
if ____cond8 then
|
|
31
31
|
do
|
|
32
32
|
return Vector(radius, 0)
|
|
33
33
|
end
|
|
34
34
|
end
|
|
35
|
-
|
|
36
|
-
if
|
|
35
|
+
____cond8 = ____cond8 or ____switch8 == Direction.DOWN
|
|
36
|
+
if ____cond8 then
|
|
37
37
|
do
|
|
38
38
|
return Vector(0, radius)
|
|
39
39
|
end
|
|
@@ -45,6 +45,14 @@ function getCircleInitialPosition(self, direction, radius)
|
|
|
45
45
|
end
|
|
46
46
|
until true
|
|
47
47
|
end
|
|
48
|
+
function ____exports.countSetBits(self, n)
|
|
49
|
+
local count = 0
|
|
50
|
+
while n > 0 do
|
|
51
|
+
n = n & n - 1
|
|
52
|
+
count = count + 1
|
|
53
|
+
end
|
|
54
|
+
return count
|
|
55
|
+
end
|
|
48
56
|
function ____exports.getAngleDifference(self, angle1, angle2)
|
|
49
57
|
local subtractedAngle = angle1 - angle2
|
|
50
58
|
return (subtractedAngle + 180) % 360 - 180
|
|
@@ -74,14 +82,6 @@ function ____exports.getCircleDiscretizedPoints(self, centerPos, radius, numPoin
|
|
|
74
82
|
end
|
|
75
83
|
return positions
|
|
76
84
|
end
|
|
77
|
-
function ____exports.getSetBits(self, n)
|
|
78
|
-
local count = 0
|
|
79
|
-
while n > 0 do
|
|
80
|
-
n = n & n - 1
|
|
81
|
-
count = count + 1
|
|
82
|
-
end
|
|
83
|
-
return count
|
|
84
|
-
end
|
|
85
85
|
function ____exports.inRectangle(self, position, topLeft, bottomRight)
|
|
86
86
|
return position.X >= topLeft.X and position.X <= bottomRight.X and position.Y <= topLeft.Y and position.Y >= bottomRight.Y
|
|
87
87
|
end
|