isaacscript-common 1.2.173 → 1.2.174

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.
@@ -29,7 +29,9 @@ end
29
29
  function checkRoomChanged(self)
30
30
  local room = game:GetRoom()
31
31
  local topLeftWallGridIndex = getTopLeftWallGridIndex(nil)
32
+ local rightOfTopWallGridIndex = topLeftWallGridIndex + 1
32
33
  local topLeftWall = room:GetGridEntity(topLeftWallGridIndex)
34
+ local topLeftWall2 = room:GetGridEntity(rightOfTopWallGridIndex)
33
35
  if topLeftWall == nil then
34
36
  topLeftWall = spawnGridEntity(nil, GridEntityType.GRID_WALL, topLeftWallGridIndex)
35
37
  if topLeftWall == nil then
@@ -38,8 +40,6 @@ function checkRoomChanged(self)
38
40
  end
39
41
  log("Spawned a new wall (1) for the PostNewRoomEarly callback.")
40
42
  end
41
- local rightOfTopWallGridIndex = topLeftWallGridIndex + 1
42
- local topLeftWall2 = room:GetGridEntity(rightOfTopWallGridIndex)
43
43
  if topLeftWall2 == nil then
44
44
  topLeftWall2 = spawnGridEntity(nil, GridEntityType.GRID_WALL, rightOfTopWallGridIndex)
45
45
  if topLeftWall2 == nil then
@@ -5,7 +5,7 @@ local Set = ____lualib.Set
5
5
  local __TS__ArrayPush = ____lualib.__TS__ArrayPush
6
6
  local __TS__Iterator = ____lualib.__TS__Iterator
7
7
  local ____exports = {}
8
- local newPlayerInventory, useItemD4, postPlayerInit, postItemPickup, v
8
+ local newPlayerInventory, useItemD4, postGameStarted, postItemPickup, v
9
9
  local ____DefaultMap = require("classes.DefaultMap")
10
10
  local DefaultMap = ____DefaultMap.DefaultMap
11
11
  local ____ModCallbacksCustom = require("enums.ModCallbacksCustom")
@@ -17,6 +17,7 @@ local copyArray = ____array.copyArray
17
17
  local ____collectibleSet = require("functions.collectibleSet")
18
18
  local getCollectibleSet = ____collectibleSet.getCollectibleSet
19
19
  local ____player = require("functions.player")
20
+ local getAllPlayers = ____player.getAllPlayers
20
21
  local getPlayerIndex = ____player.getPlayerIndex
21
22
  local ____utils = require("functions.utils")
22
23
  local ____repeat = ____utils["repeat"]
@@ -42,11 +43,13 @@ function useItemD4(self, _collectibleType, _rng, player)
42
43
  local inventory = newPlayerInventory(nil, player)
43
44
  v.run.playersInventory:set(playerIndex, inventory)
44
45
  end
45
- function postPlayerInit(self, player)
46
- local playerIndex = getPlayerIndex(nil, player)
47
- if not v.run.playersInventory:has(playerIndex) then
48
- local inventory = newPlayerInventory(nil, player)
49
- v.run.playersInventory:set(playerIndex, inventory)
46
+ function postGameStarted(self)
47
+ for ____, player in ipairs(getAllPlayers(nil)) do
48
+ local playerIndex = getPlayerIndex(nil, player)
49
+ if not v.run.playersInventory:has(playerIndex) then
50
+ local inventory = newPlayerInventory(nil, player)
51
+ v.run.playersInventory:set(playerIndex, inventory)
52
+ end
50
53
  end
51
54
  end
52
55
  function postItemPickup(self, player, pickingUpItem)
@@ -64,7 +67,7 @@ v = {run = {playersInventory = __TS__New(
64
67
  function ____exports.playerInventoryInit(self, mod)
65
68
  saveDataManager(nil, "playerInventory", v)
66
69
  mod:AddCallback(ModCallbacks.MC_USE_ITEM, useItemD4, CollectibleType.COLLECTIBLE_D4)
67
- mod:AddCallback(ModCallbacks.MC_POST_PLAYER_INIT, postPlayerInit)
70
+ mod:AddCallback(ModCallbacks.MC_POST_GAME_STARTED, postGameStarted)
68
71
  mod:AddCallbackCustom(ModCallbacksCustom.MC_POST_ITEM_PICKUP, postItemPickup)
69
72
  end
70
73
  function ____exports.getPlayerInventory(self, player)
@@ -5,6 +5,13 @@
5
5
  * 1000.0 in a room XML file, but `GridEntityType.GRID_ROCK` is equal to 2.
6
6
  */
7
7
  export declare function convertXMLGridEntityType(gridEntityXMLType: int, gridEntityXMLVariant: int): [int, int] | undefined;
8
+ /**
9
+ * Gets the entities that have a hitbox that overlaps with any part of the square that the grid
10
+ * entity is on.
11
+ *
12
+ * Note that this function will not work properly in the PostNewRoom callback, since entities do not
13
+ * have collision yet in that callback.
14
+ */
8
15
  export declare function getCollidingEntitiesWithGridEntity(gridEntity: GridEntity): Entity[];
9
16
  /**
10
17
  * Helper function to get every grid entity in the current room.
@@ -112,13 +112,9 @@ function ____exports.getCollidingEntitiesWithGridEntity(self, gridEntity)
112
112
  local gridEntityCollisionTopLeft = Vector(gridEntity.Position.X - DISTANCE_OF_GRID_TILE / 2, gridEntity.Position.Y - DISTANCE_OF_GRID_TILE / 2)
113
113
  local gridEntityCollisionBottomRight = Vector(gridEntity.Position.X + DISTANCE_OF_GRID_TILE / 2, gridEntity.Position.Y + DISTANCE_OF_GRID_TILE / 2)
114
114
  local closeEntities = Isaac.FindInRadius(gridEntity.Position, DISTANCE_OF_GRID_TILE * 2)
115
- local closeEntitiesThatCollideWithGrid = __TS__ArrayFilter(
116
- closeEntities,
117
- function(____, entity) return entity:CollidesWithGrid() end
118
- )
119
115
  return __TS__ArrayFilter(
120
- closeEntitiesThatCollideWithGrid,
121
- function(____, entity) return isCircleIntersectingRectangle(
116
+ closeEntities,
117
+ function(____, entity) return entity:CollidesWithGrid() and isCircleIntersectingRectangle(
122
118
  nil,
123
119
  entity.Position,
124
120
  entity.Size + 0.1,
@@ -47,8 +47,8 @@ export declare function characterGetsBlackHeartFromEternalHeart(character: Playe
47
47
  * Helper function to get every player with no restrictions, by using `Game.GetNumPlayers` and
48
48
  * `Isaac.GetPlayer`.
49
49
  *
50
- * This function is almost never what you want to use. For most intents and purposes, use the
51
- * `getPlayers` helper function instead to get a filtered list of players.
50
+ * This function is almost never what you want to use. For most purposes, use the `getPlayers`
51
+ * helper function instead to get a filtered list of players.
52
52
  */
53
53
  export declare function getAllPlayers(): EntityPlayer[];
54
54
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.173",
3
+ "version": "1.2.174",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",