isaacscript-common 1.0.347 → 1.0.348

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.
@@ -1,8 +1,22 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  export declare function getAngleDifference(angle1: float, angle2: float): float;
3
- export declare function getCircleDiscretizedPoints(centerPos: Vector, distance: int, numPoints: int): Vector[];
3
+ /**
4
+ * Helper function to get an array of equidistant points on the circumference around a circle.
5
+ * Useful for equally distributing things in a circle pattern.
6
+ *
7
+ * @param centerPos A position that represents the center of the center to get the points from.
8
+ * @param radius The radius of the circle.
9
+ * @param numPoints The number of points on the circumference of the circle to get.
10
+ * @param xMultiplier An optional multiplier to get the points around an oval. Default is 1.
11
+ * @param yMultiplier An optional multiplier to get the points around an oval. Default is 1.
12
+ * @param initialDirection By default, the first point on the circle will be on the top center, but
13
+ * this can be optionally changed by specifying this argument.
14
+ */
15
+ export declare function getCircleDiscretizedPoints(centerPos: Vector, radius: float, numPoints: int, xMultiplier?: number, yMultiplier?: number, initialDirection?: Direction): Vector[];
4
16
  export declare function isEven(num: int): boolean;
5
17
  export declare function isOdd(num: int): boolean;
18
+ export declare function lerp(a: number, b: number, pos: float): number;
19
+ export declare function lerpAngleDegrees(aStart: number, aEnd: number, percent: float): number;
6
20
  /**
7
21
  * If rounding fails, this function returns 0.
8
22
  * From: http://lua-users.org/wiki/SimpleRound
@@ -1,17 +1,72 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  require("lualib_bundle");
3
3
  local ____exports = {}
4
+ local ____util = require("functions.util")
5
+ local ensureAllCases = ____util.ensureAllCases
6
+ local getCircleInitialPosition
7
+ function getCircleInitialPosition(self, direction, radius)
8
+ repeat
9
+ local ____switch6 = direction
10
+ local ____cond6 = ____switch6 == Direction.NO_DIRECTION
11
+ if ____cond6 then
12
+ do
13
+ return Vector.Zero
14
+ end
15
+ end
16
+ ____cond6 = ____cond6 or (____switch6 == Direction.LEFT)
17
+ if ____cond6 then
18
+ do
19
+ return Vector(-radius, 0)
20
+ end
21
+ end
22
+ ____cond6 = ____cond6 or (____switch6 == Direction.UP)
23
+ if ____cond6 then
24
+ do
25
+ return Vector(0, -radius)
26
+ end
27
+ end
28
+ ____cond6 = ____cond6 or (____switch6 == Direction.RIGHT)
29
+ if ____cond6 then
30
+ do
31
+ return Vector(radius, 0)
32
+ end
33
+ end
34
+ ____cond6 = ____cond6 or (____switch6 == Direction.DOWN)
35
+ if ____cond6 then
36
+ do
37
+ return Vector(0, radius)
38
+ end
39
+ end
40
+ do
41
+ do
42
+ ensureAllCases(nil, direction)
43
+ return Vector.Zero
44
+ end
45
+ end
46
+ until true
47
+ end
4
48
  function ____exports.getAngleDifference(self, angle1, angle2)
5
49
  local subtractedAngle = angle1 - angle2
6
50
  return ((subtractedAngle + 180) % 360) - 180
7
51
  end
8
- function ____exports.getCircleDiscretizedPoints(self, centerPos, distance, numPoints)
52
+ function ____exports.getCircleDiscretizedPoints(self, centerPos, radius, numPoints, xMultiplier, yMultiplier, initialDirection)
53
+ if xMultiplier == nil then
54
+ xMultiplier = 1
55
+ end
56
+ if yMultiplier == nil then
57
+ yMultiplier = 1
58
+ end
59
+ if initialDirection == nil then
60
+ initialDirection = Direction.UP
61
+ end
62
+ local initialPosition = getCircleInitialPosition(nil, initialDirection, radius)
9
63
  local positions = {}
10
- local leftOfCenter = Vector(-distance, 0)
11
64
  do
12
65
  local i = 0
13
66
  while i < numPoints do
14
- local rotatedPosition = leftOfCenter:Rotated((i * 360) / numPoints)
67
+ local rotatedPosition = initialPosition:Rotated((i * 360) / numPoints)
68
+ rotatedPosition.X = rotatedPosition.X * xMultiplier
69
+ rotatedPosition.Y = rotatedPosition.Y * yMultiplier
15
70
  local positionFromCenter = centerPos + rotatedPosition
16
71
  __TS__ArrayPush(positions, positionFromCenter)
17
72
  i = i + 1
@@ -25,6 +80,12 @@ end
25
80
  function ____exports.isOdd(self, num)
26
81
  return (num & 1) == 1
27
82
  end
83
+ function ____exports.lerp(self, a, b, pos)
84
+ return a + ((b - a) * pos)
85
+ end
86
+ function ____exports.lerpAngleDegrees(self, aStart, aEnd, percent)
87
+ return aStart + (____exports.getAngleDifference(nil, aStart, aEnd) * percent)
88
+ end
28
89
  function ____exports.round(self, num, numDecimalPlaces)
29
90
  if numDecimalPlaces == nil then
30
91
  numDecimalPlaces = 0
@@ -63,8 +63,6 @@ export declare function isGreedMode(): boolean;
63
63
  */
64
64
  export declare function isSerializedVector(object: unknown): boolean;
65
65
  export declare function isVector(object: unknown): boolean;
66
- export declare function lerp(a: number, b: number, pos: float): number;
67
- export declare function lerpAngleDegrees(aStart: number, aEnd: number, percent: float): number;
68
66
  /**
69
67
  * Whether or not the player is playing on a set seed (i.e. that they entered in a specific seed by
70
68
  * pressing tab on the character selection screen). When the player resets the game on a set seed,
@@ -3,8 +3,6 @@ require("lualib_bundle");
3
3
  local ____exports = {}
4
4
  local ____constants = require("constants")
5
5
  local VECTOR_BRAND = ____constants.VECTOR_BRAND
6
- local ____math = require("functions.math")
7
- local getAngleDifference = ____math.getAngleDifference
8
6
  local HEX_STRING_LENGTH = 6
9
7
  function ____exports.copySet(self, oldSet)
10
8
  local newSet = __TS__New(Set)
@@ -75,12 +73,6 @@ function ____exports.isVector(self, object)
75
73
  local vectorMetatable = metatable
76
74
  return vectorMetatable.__type == "Vector"
77
75
  end
78
- function ____exports.lerp(self, a, b, pos)
79
- return a + ((b - a) * pos)
80
- end
81
- function ____exports.lerpAngleDegrees(self, aStart, aEnd, percent)
82
- return aStart + (getAngleDifference(nil, aStart, aEnd) * percent)
83
- end
84
76
  function ____exports.onSetSeed(self)
85
77
  local game = Game()
86
78
  local seeds = game:GetSeeds()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.0.347",
3
+ "version": "1.0.348",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",