isaacscript-common 1.0.502 → 1.0.506

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.
@@ -2,7 +2,8 @@
2
2
  local ____exports = {}
3
3
  local hasSubscriptions, postNewRoom, preEntitySpawn, checkRoomChanged, currentRoomTopLeftWallPtrHash
4
4
  local ____gridEntity = require("functions.gridEntity")
5
- local getTopLeftWall = ____gridEntity.getTopLeftWall
5
+ local getTopLeftWallGridIndex = ____gridEntity.getTopLeftWallGridIndex
6
+ local spawnGridEntity = ____gridEntity.spawnGridEntity
6
7
  local ____postNewRoomEarly = require("callbacks.subscriptions.postNewRoomEarly")
7
8
  local postNewRoomEarlyFire = ____postNewRoomEarly.postNewRoomEarlyFire
8
9
  local postNewRoomEarlyHasSubscriptions = ____postNewRoomEarly.postNewRoomEarlyHasSubscriptions
@@ -22,14 +23,14 @@ function preEntitySpawn(self)
22
23
  checkRoomChanged(nil)
23
24
  end
24
25
  function checkRoomChanged(self)
25
- local topLeftWall = getTopLeftWall(nil)
26
- local ____temp_0
26
+ local game = Game()
27
+ local room = game:GetRoom()
28
+ local topLeftWallGridIndex = getTopLeftWallGridIndex(nil)
29
+ local topLeftWall = room:GetGridEntity(topLeftWallGridIndex)
27
30
  if topLeftWall == nil then
28
- ____temp_0 = nil
29
- else
30
- ____temp_0 = GetPtrHash(topLeftWall)
31
+ topLeftWall = spawnGridEntity(nil, GridEntityType.GRID_WALL, topLeftWallGridIndex)
31
32
  end
32
- local topLeftWallPtrHash = ____temp_0
33
+ local topLeftWallPtrHash = GetPtrHash(topLeftWall)
33
34
  if topLeftWallPtrHash ~= currentRoomTopLeftWallPtrHash then
34
35
  currentRoomTopLeftWallPtrHash = topLeftWallPtrHash
35
36
  postNewRoomEarlyFire(nil)
@@ -44,6 +44,15 @@ export declare function isDoorToMines(door: GridEntityDoor): boolean;
44
44
  export declare function isDoorToMomsHeart(door: GridEntityDoor): boolean;
45
45
  export declare function isRepentanceDoor(door: GridEntityDoor): boolean;
46
46
  export declare function isSecretRoomDoor(door: GridEntityDoor): boolean;
47
+ /**
48
+ * Helper function to reset an unlocked door back to a locked state. Doing this is non-trivial
49
+ * because in addition to calling the `SetLocked()` method, you must also:
50
+ *
51
+ * - Modify the `VisitedCount` of the room's `RoomDescription` to be set to 0.
52
+ * - Set the variant to `DoorVariant.DOOR_LOCKED`.
53
+ * - Close the door.
54
+ */
55
+ export declare function lockDoor(door: GridEntityDoor): void;
47
56
  /**
48
57
  * For the purposes of this function, doors to Secret Rooms or Super Secret Rooms that have not been
49
58
  * discovered yet will not be opened.
@@ -125,6 +125,15 @@ function ____exports.isDoorToMomsHeart(self, door)
125
125
  local filename = sprite:GetFilename()
126
126
  return filename == "gfx/grid/Door_MomsHeart.anm2"
127
127
  end
128
+ function ____exports.lockDoor(self, door)
129
+ local game = Game()
130
+ local level = game:GetLevel()
131
+ local roomDesc = level:GetRoomByIdx(door.TargetRoomIndex)
132
+ roomDesc.VisitedCount = 0
133
+ door:SetVariant(DoorVariant.DOOR_LOCKED)
134
+ door:SetLocked(true)
135
+ door:Close(true)
136
+ end
128
137
  function ____exports.openAllDoors(self)
129
138
  for ____, door in ipairs(____exports.getDoors(nil)) do
130
139
  door:Open()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.0.502",
3
+ "version": "1.0.506",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",