isaacscript-common 1.0.449 → 1.0.450

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.
@@ -0,0 +1,8 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ /**
3
+ * Helper function to get a room position that is not overlapping with a grid entity, a heaven door,
4
+ * or a player. The `Room.FindFreePickupSpawnPosition()` function will return locations that are
5
+ * overlap with heaven doors and players, so use this function instead if you want to account for
6
+ * those specific situations.
7
+ */
8
+ export declare function findFreePosition(startingPosition: Vector): Vector;
@@ -0,0 +1,35 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ local ____exports = {}
3
+ local ____constants = require("constants")
4
+ local DISTANCE_OF_GRID_TILE = ____constants.DISTANCE_OF_GRID_TILE
5
+ local ____entity = require("functions.entity")
6
+ local anyEntityCloserThan = ____entity.anyEntityCloserThan
7
+ local getEffects = ____entity.getEffects
8
+ local ____player = require("functions.player")
9
+ local getPlayerCloserThan = ____player.getPlayerCloserThan
10
+ function ____exports.findFreePosition(self, startingPosition)
11
+ local game = Game()
12
+ local room = game:GetRoom()
13
+ local heavenDoors = getEffects(nil, EffectVariant.HEAVEN_LIGHT_DOOR, 0)
14
+ do
15
+ local i = 0
16
+ while i < 100 do
17
+ do
18
+ local position = room:FindFreePickupSpawnPosition(startingPosition, i)
19
+ local closePlayer = getPlayerCloserThan(nil, position, DISTANCE_OF_GRID_TILE)
20
+ if closePlayer ~= nil then
21
+ goto __continue3
22
+ end
23
+ local isCloseHeavenDoor = anyEntityCloserThan(nil, heavenDoors, position, DISTANCE_OF_GRID_TILE)
24
+ if isCloseHeavenDoor then
25
+ goto __continue3
26
+ end
27
+ return position
28
+ end
29
+ ::__continue3::
30
+ i = i + 1
31
+ end
32
+ end
33
+ return room:FindFreePickupSpawnPosition(startingPosition)
34
+ end
35
+ return ____exports
package/dist/index.d.ts CHANGED
@@ -30,6 +30,7 @@ export * from "./functions/pickups";
30
30
  export * from "./functions/player";
31
31
  export * from "./functions/playerHealth";
32
32
  export * from "./functions/pocketItems";
33
+ export * from "./functions/position";
33
34
  export * from "./functions/random";
34
35
  export * from "./functions/revive";
35
36
  export * from "./functions/rooms";
package/dist/index.lua CHANGED
@@ -251,6 +251,14 @@ do
251
251
  end
252
252
  end
253
253
  end
254
+ do
255
+ local ____export = require("functions.position")
256
+ for ____exportKey, ____exportValue in pairs(____export) do
257
+ if ____exportKey ~= "default" then
258
+ ____exports[____exportKey] = ____exportValue
259
+ end
260
+ end
261
+ end
254
262
  do
255
263
  local ____export = require("functions.random")
256
264
  for ____exportKey, ____exportValue in pairs(____export) do
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.0.449",
3
+ "version": "1.0.450",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",
@@ -25,7 +25,7 @@
25
25
  "dist/**/*.d.ts"
26
26
  ],
27
27
  "devDependencies": {
28
- "isaac-typescript-definitions": "^1.0.275",
28
+ "isaac-typescript-definitions": "^1.0.276",
29
29
  "isaacscript-lint": "^1.0.67",
30
30
  "typedoc": "^0.22.9",
31
31
  "typescript": "4.4.4",