isaacscript-common 1.2.151 → 1.2.154

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.
Files changed (53) hide show
  1. package/dist/callbacks/postCustomDoorEnter.d.ts +27 -3
  2. package/dist/callbacks/postCustomDoorEnter.lua +133 -11
  3. package/dist/callbacks/subscriptions/postCustomDoorEnter.d.ts +1 -1
  4. package/dist/callbacks/subscriptions/postCustomDoorEnter.lua +12 -6
  5. package/dist/features/extraConsoleCommands/commands.lua +4 -4
  6. package/dist/features/runInNFrames.d.ts +2 -2
  7. package/dist/features/runInNFrames.lua +7 -7
  8. package/dist/features/saveDataManager/load.lua +2 -2
  9. package/dist/functions/cards.lua +12 -12
  10. package/dist/functions/challenges.lua +4 -4
  11. package/dist/functions/doors.d.ts +1 -0
  12. package/dist/functions/doors.lua +7 -2
  13. package/dist/functions/log.lua +4 -0
  14. package/dist/functions/math.lua +4 -44
  15. package/dist/functions/pills.lua +12 -12
  16. package/dist/functions/player.lua +4 -4
  17. package/dist/functions/stage.lua +3 -46
  18. package/dist/functions/transformations.lua +4 -4
  19. package/dist/functions/vector.lua +3 -40
  20. package/dist/index.d.ts +1 -16
  21. package/dist/index.lua +2 -120
  22. package/dist/objects/callbackRegisterFunctions.d.ts +4 -0
  23. package/dist/objects/callbackRegisterFunctions.lua +160 -0
  24. package/dist/objects/cardDescriptions.d.ts +5 -0
  25. package/dist/objects/cardDescriptions.lua +106 -0
  26. package/dist/objects/cardNames.d.ts +5 -0
  27. package/dist/objects/cardNames.lua +106 -0
  28. package/dist/objects/cardTypes.d.ts +6 -0
  29. package/dist/objects/cardTypes.lua +108 -0
  30. package/dist/objects/challengeNames.d.ts +5 -0
  31. package/dist/objects/challengeNames.lua +53 -0
  32. package/dist/objects/characterNames.d.ts +5 -0
  33. package/dist/objects/characterNames.lua +49 -0
  34. package/dist/objects/directionToVector.d.ts +4 -0
  35. package/dist/objects/directionToVector.lua +10 -0
  36. package/dist/objects/doorSlotToDirection.d.ts +4 -0
  37. package/dist/objects/doorSlotToDirection.lua +15 -0
  38. package/dist/objects/pillEffectClasses.d.ts +6 -0
  39. package/dist/objects/pillEffectClasses.lua +61 -0
  40. package/dist/objects/pillEffectNames.d.ts +5 -0
  41. package/dist/objects/pillEffectNames.lua +58 -0
  42. package/dist/objects/pillEffectTypes.d.ts +6 -0
  43. package/dist/objects/pillEffectTypes.lua +60 -0
  44. package/dist/objects/roomTypeNames.d.ts +5 -0
  45. package/dist/objects/roomTypeNames.lua +37 -0
  46. package/dist/objects/stageTypeToLetter.d.ts +4 -0
  47. package/dist/objects/stageTypeToLetter.lua +11 -0
  48. package/dist/objects/transformationNames.d.ts +5 -0
  49. package/dist/objects/transformationNames.lua +22 -0
  50. package/dist/types/ModUpgraded.d.ts +2 -2
  51. package/dist/types/ModUpgraded.lua +5 -425
  52. package/dist/upgradeMod.lua +1 -1
  53. package/package.json +2 -2
@@ -1,8 +1,32 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  /**
3
- * Helper function to spawn a custom muting all sound effects and music.
3
+ * `isaacscript-common` provides custom doors that can be spawned where any wall segment is. If you
4
+ * use this feature, you must first call this initialization function at the beginning of your mod.
4
5
  *
5
- * Use this function to set things back to normal after having used [[`disableAllSounds`]].
6
+ * Each kind of custom door that you create must have an entry in the "content/entities2.xml" file,
7
+ * like so:
6
8
  *
9
+ * ```xml
10
+ * <entity id="1000" name="Foo Custom Door" anm2path="grid/door_foo.anm2" />
11
+ * ```
12
+ *
13
+ * (Custom door entities must have an id of "1000", which corresponds to an effect. If you do not
14
+ * specify the variant, then the game will automatically assign it.)
15
+ *
16
+ * Next, pass the variant into this function:
17
+ *
18
+ * ```ts
19
+ * const modVanilla = RegisterMod("My Mod", 1);
20
+ * const mod = upgradeMod(modVanilla);
21
+ * const fooEffectVariant = Isaac.GetEntityVariantByName("Foo Custom Door");
22
+ * initCustomDoor(mod, fooEffectVariant);
23
+ * ```
24
+ */
25
+ export declare function initCustomDoor(mod: Mod, effectVariant: int): void;
26
+ /**
27
+ * Helper function to spawn a custom door. Handle when a player enters the door by hooking the
28
+ * custom `MC_POST_CUSTOM_DOOR_ENTER` callback.
29
+ *
30
+ * Before using this function, you must first initialize it with the `initCustomDoor` function.
7
31
  */
8
- export declare function spawnCustomDoor(_customDoorType: int, _anm2: string, _slot: DoorSlot): void;
32
+ export declare function spawnCustomDoor(effectVariant: int, doorSlot: DoorSlot): void;
@@ -2,34 +2,156 @@
2
2
  local ____lualib = require("lualib_bundle")
3
3
  local Set = ____lualib.Set
4
4
  local __TS__New = ____lualib.__TS__New
5
+ local Map = ____lualib.Map
5
6
  local ____exports = {}
6
- local hasSubscriptions, postRender
7
+ local hasSubscriptions, postEffectRenderCustomEntity, isPlayerPastDoorThreshold, getPositionOffset, getAnimation, POSITION_OFFSET_MULTIPLIER, v
8
+ local ____cachedClasses = require("cachedClasses")
9
+ local game = ____cachedClasses.game
7
10
  local ____exports = require("features.saveDataManager.exports")
8
11
  local saveDataManager = ____exports.saveDataManager
9
12
  local ____doors = require("functions.doors")
10
- local getDoors = ____doors.getDoors
13
+ local doorSlotToDirection = ____doors.doorSlotToDirection
14
+ local ____player = require("functions.player")
15
+ local getClosestPlayer = ____player.getClosestPlayer
16
+ local ____utils = require("functions.utils")
17
+ local ensureAllCases = ____utils.ensureAllCases
18
+ local ____vector = require("functions.vector")
19
+ local directionToVector = ____vector.directionToVector
11
20
  local ____postCustomDoorEnter = require("callbacks.subscriptions.postCustomDoorEnter")
12
21
  local postCustomDoorEnterFire = ____postCustomDoorEnter.postCustomDoorEnterFire
13
22
  local postCustomDoorEnterHasSubscriptions = ____postCustomDoorEnter.postCustomDoorEnterHasSubscriptions
14
23
  function hasSubscriptions(self)
15
24
  return postCustomDoorEnterHasSubscriptions(nil)
16
25
  end
17
- function postRender(self)
26
+ function postEffectRenderCustomEntity(self, effect)
18
27
  if not hasSubscriptions(nil) then
19
28
  return
20
29
  end
21
- local doors = getDoors(nil)
22
- if #doors == 0 then
30
+ local ptrHash = GetPtrHash(effect)
31
+ local doorData = v.room.doors:get(ptrHash)
32
+ if doorData == nil then
23
33
  return
24
34
  end
25
- local door = doors[1]
26
- postCustomDoorEnterFire(nil, door)
35
+ local direction = doorSlotToDirection(nil, doorData.slot)
36
+ local player = getClosestPlayer(nil, effect.Position)
37
+ if isPlayerPastDoorThreshold(nil, effect, player, direction) then
38
+ postCustomDoorEnterFire(
39
+ nil,
40
+ player,
41
+ effect.Variant,
42
+ doorData.slot,
43
+ direction
44
+ )
45
+ end
46
+ end
47
+ function isPlayerPastDoorThreshold(self, effect, player, direction)
48
+ repeat
49
+ local ____switch10 = direction
50
+ local ____cond10 = ____switch10 == Direction.NO_DIRECTION
51
+ if ____cond10 then
52
+ do
53
+ return false
54
+ end
55
+ end
56
+ ____cond10 = ____cond10 or ____switch10 == Direction.UP
57
+ if ____cond10 then
58
+ do
59
+ return player.Position.Y <= effect.Position.Y
60
+ end
61
+ end
62
+ ____cond10 = ____cond10 or ____switch10 == Direction.RIGHT
63
+ if ____cond10 then
64
+ do
65
+ return player.Position.X >= effect.Position.X
66
+ end
67
+ end
68
+ ____cond10 = ____cond10 or ____switch10 == Direction.DOWN
69
+ if ____cond10 then
70
+ do
71
+ return player.Position.Y >= effect.Position.Y
72
+ end
73
+ end
74
+ ____cond10 = ____cond10 or ____switch10 == Direction.LEFT
75
+ if ____cond10 then
76
+ do
77
+ return player.Position.X <= effect.Position.X
78
+ end
79
+ end
80
+ do
81
+ do
82
+ return ensureAllCases(nil, direction)
83
+ end
84
+ end
85
+ until true
86
+ end
87
+ function getPositionOffset(self, doorSlot)
88
+ local direction = doorSlotToDirection(nil, doorSlot)
89
+ local vector = directionToVector(nil, direction)
90
+ return vector * POSITION_OFFSET_MULTIPLIER
91
+ end
92
+ function getAnimation(self, effect)
93
+ repeat
94
+ local ____switch24 = effect.State
95
+ local ____cond24 = ____switch24 == DoorState.STATE_OPEN
96
+ if ____cond24 then
97
+ do
98
+ return "Opened"
99
+ end
100
+ end
101
+ ____cond24 = ____cond24 or ____switch24 == DoorState.STATE_CLOSED
102
+ if ____cond24 then
103
+ do
104
+ return "Closed"
105
+ end
106
+ end
107
+ do
108
+ do
109
+ return "Opened"
110
+ end
111
+ end
112
+ until true
27
113
  end
28
- local v = {run = {disableSoundSet = __TS__New(Set)}}
29
- function ____exports.postCustomDoorEnterCallbackInit(self, mod)
114
+ POSITION_OFFSET_MULTIPLIER = 23
115
+ local initializedEffectVariants = __TS__New(Set)
116
+ v = {room = {doors = __TS__New(Map)}}
117
+ function ____exports.postCustomDoorEnterCallbackInit(self)
30
118
  saveDataManager(nil, "postCustomDoorEnter", v, hasSubscriptions)
31
- mod:AddCallback(ModCallbacks.MC_POST_RENDER, postRender)
32
119
  end
33
- function ____exports.spawnCustomDoor(self, _customDoorType, _anm2, _slot)
120
+ function ____exports.initCustomDoor(self, mod, effectVariant)
121
+ initializedEffectVariants:add(effectVariant)
122
+ mod:AddCallback(ModCallbacks.MC_POST_EFFECT_RENDER, postEffectRenderCustomEntity, effectVariant)
123
+ end
124
+ function ____exports.spawnCustomDoor(self, effectVariant, doorSlot)
125
+ if not initializedEffectVariants:has(effectVariant) then
126
+ error("In order to spawn custom doors, you must first initialize them with the \"initCustomDoor\" function at the beginning of your mod.")
127
+ end
128
+ local room = game:GetRoom()
129
+ local roomClear = room:IsClear()
130
+ local position = room:GetDoorSlotPosition(doorSlot)
131
+ local effect = Isaac.Spawn(
132
+ EntityType.ENTITY_EFFECT,
133
+ effectVariant,
134
+ 0,
135
+ position,
136
+ Vector.Zero,
137
+ nil
138
+ ):ToEffect()
139
+ if effect == nil then
140
+ error("Failed to spawn a custom door with variant: " .. tostring(effectVariant))
141
+ end
142
+ effect.State = roomClear and DoorState.STATE_OPEN or DoorState.STATE_CLOSED
143
+ effect.RenderZOffset = -10000
144
+ effect.PositionOffset = getPositionOffset(nil, doorSlot)
145
+ local sprite = effect:GetSprite()
146
+ local animation = getAnimation(nil, effect)
147
+ sprite:Play(animation, true)
148
+ sprite.Rotation = doorSlot * 90 - 90
149
+ if effect.State == DoorState.STATE_OPEN then
150
+ local gridIndex = room:GetGridIndex(position)
151
+ local wall = room:GetGridEntity(gridIndex)
152
+ if wall ~= nil then
153
+ wall.CollisionClass = GridCollisionClass.COLLISION_WALL_EXCEPT_PLAYER
154
+ end
155
+ end
34
156
  end
35
157
  return ____exports
@@ -1,2 +1,2 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
- export declare type PostCustomDoorEnterCallbackType = (door: GridEntityDoor) => void;
2
+ export declare type PostCustomDoorEnterCallbackType = (player: EntityPlayer, effectVariant: int, doorSlot: DoorSlot, direction: Direction) => void;
@@ -6,18 +6,24 @@ local subscriptions = {}
6
6
  function ____exports.postCustomDoorEnterHasSubscriptions(self)
7
7
  return #subscriptions > 0
8
8
  end
9
- function ____exports.postCustomDoorEnterRegister(self, callback, doorVariant)
10
- __TS__ArrayPush(subscriptions, {callback, doorVariant})
9
+ function ____exports.postCustomDoorEnterRegister(self, callback, effectVariant)
10
+ __TS__ArrayPush(subscriptions, {callback, effectVariant})
11
11
  end
12
- function ____exports.postCustomDoorEnterFire(self, door)
12
+ function ____exports.postCustomDoorEnterFire(self, player, effectVariant, doorSlot, direction)
13
13
  for ____, ____value in ipairs(subscriptions) do
14
14
  local callback = ____value[1]
15
- local doorVariant = ____value[2]
15
+ local callbackEffectVariant = ____value[2]
16
16
  do
17
- if doorVariant ~= nil and doorVariant ~= door:GetVariant() then
17
+ if effectVariant ~= callbackEffectVariant then
18
18
  goto __continue5
19
19
  end
20
- callback(nil, door)
20
+ callback(
21
+ nil,
22
+ player,
23
+ effectVariant,
24
+ doorSlot,
25
+ direction
26
+ )
21
27
  end
22
28
  ::__continue5::
23
29
  end
@@ -53,9 +53,9 @@ local ____pillEffectMap = require("maps.pillEffectMap")
53
53
  local PILL_EFFECT_MAP = ____pillEffectMap.PILL_EFFECT_MAP
54
54
  local ____roomTypeMap = require("maps.roomTypeMap")
55
55
  local ROOM_TYPE_MAP = ____roomTypeMap.ROOM_TYPE_MAP
56
- local ____roomTypeNameMap = require("maps.roomTypeNameMap")
57
- local DEFAULT_ROOM_TYPE_NAME = ____roomTypeNameMap.DEFAULT_ROOM_TYPE_NAME
58
- local ROOM_TYPE_NAME_MAP = ____roomTypeNameMap.ROOM_TYPE_NAME_MAP
56
+ local ____roomTypeNames = require("objects.roomTypeNames")
57
+ local DEFAULT_ROOM_TYPE_NAME = ____roomTypeNames.DEFAULT_ROOM_TYPE_NAME
58
+ local ROOM_TYPE_NAMES = ____roomTypeNames.ROOM_TYPE_NAMES
59
59
  local ____HealthType = require("types.HealthType")
60
60
  local HealthType = ____HealthType.HealthType
61
61
  local ____v = require("features.extraConsoleCommands.v")
@@ -182,7 +182,7 @@ function spawnTrapdoorOrCrawlspace(self, trapdoor)
182
182
  spawnGridEntityWithVariant(nil, gridEntityType, 0, gridIndex)
183
183
  end
184
184
  function warpToRoomType(self, roomType)
185
- local roomTypeName = ROOM_TYPE_NAME_MAP[roomType]
185
+ local roomTypeName = ROOM_TYPE_NAMES[roomType]
186
186
  if roomTypeName == nil or roomTypeName == DEFAULT_ROOM_TYPE_NAME then
187
187
  printConsole(
188
188
  nil,
@@ -9,7 +9,7 @@
9
9
  * before the deferred function fires would cause a bug in your mod, then you should handle deferred
10
10
  * functions manually using serializable data.
11
11
  */
12
- export declare function runInNGameFrames(func: () => void, frames: int): void;
12
+ export declare function runInNGameFrames(func: () => void, gameFrames: int): void;
13
13
  /**
14
14
  * Supply a function to run N render frames from now in the PostRender callback.
15
15
  *
@@ -20,7 +20,7 @@ export declare function runInNGameFrames(func: () => void, frames: int): void;
20
20
  * before the deferred function fires would cause a bug in your mod, then you should handle deferred
21
21
  * functions manually using serializable data.
22
22
  */
23
- export declare function runInNRenderFrames(func: () => void, frames: int): void;
23
+ export declare function runInNRenderFrames(func: () => void, renderFrames: int): void;
24
24
  /**
25
25
  * Supply a function to run on the next PostUpdate callback.
26
26
  *
@@ -16,8 +16,8 @@ function postUpdate(self)
16
16
  checkExecuteQueuedFunctions(nil, gameFrameCount, v.run.queuedGameFunctionTuples)
17
17
  end
18
18
  function postRender(self)
19
- local isaacFrameCount = Isaac.GetFrameCount()
20
- checkExecuteQueuedFunctions(nil, isaacFrameCount, v.run.queuedRenderFunctionTuples)
19
+ local renderFrameCount = Isaac.GetFrameCount()
20
+ checkExecuteQueuedFunctions(nil, renderFrameCount, v.run.queuedRenderFunctionTuples)
21
21
  end
22
22
  function checkExecuteQueuedFunctions(self, frameCount, functionTuples)
23
23
  local functionsToFire = {}
@@ -46,17 +46,17 @@ function ____exports.runInNFramesInit(self, mod)
46
46
  mod:AddCallback(ModCallbacks.MC_POST_UPDATE, postUpdate)
47
47
  mod:AddCallback(ModCallbacks.MC_POST_RENDER, postRender)
48
48
  end
49
- function ____exports.runInNGameFrames(self, func, frames)
49
+ function ____exports.runInNGameFrames(self, func, gameFrames)
50
50
  errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
51
51
  local gameFrameCount = game:GetFrameCount()
52
- local functionFireFrame = gameFrameCount + frames
52
+ local functionFireFrame = gameFrameCount + gameFrames
53
53
  local tuple = {functionFireFrame, func}
54
54
  __TS__ArrayPush(v.run.queuedGameFunctionTuples, tuple)
55
55
  end
56
- function ____exports.runInNRenderFrames(self, func, frames)
56
+ function ____exports.runInNRenderFrames(self, func, renderFrames)
57
57
  errorIfFeaturesNotInitialized(nil, FEATURE_NAME)
58
- local isaacFrameCount = Isaac.GetFrameCount()
59
- local functionFireFrame = isaacFrameCount + frames
58
+ local renderFrameCount = Isaac.GetFrameCount()
59
+ local functionFireFrame = renderFrameCount + renderFrames
60
60
  local tuple = {functionFireFrame, func}
61
61
  __TS__ArrayPush(v.run.queuedRenderFunctionTuples, tuple)
62
62
  end
@@ -13,10 +13,10 @@ local SAVE_DATA_MANAGER_FEATURE_NAME = ____constants.SAVE_DATA_MANAGER_FEATURE_N
13
13
  local ____merge = require("features.saveDataManager.merge")
14
14
  local merge = ____merge.merge
15
15
  function readSaveDatFile(self, mod)
16
- local isaacFrameCount = Isaac.GetFrameCount()
16
+ local renderFrameCount = Isaac.GetFrameCount()
17
17
  local ok, jsonStringOrErrMsg = pcall(tryLoadModData, mod)
18
18
  if not ok then
19
- log((("Failed to read from the \"save#.dat\" file on Isaac frame " .. tostring(isaacFrameCount)) .. ": ") .. jsonStringOrErrMsg)
19
+ log((("Failed to read from the \"save#.dat\" file on render frame " .. tostring(renderFrameCount)) .. ": ") .. jsonStringOrErrMsg)
20
20
  return DEFAULT_MOD_DATA
21
21
  end
22
22
  if jsonStringOrErrMsg == nil then
@@ -8,15 +8,15 @@ local ____exports = {}
8
8
  local initCardObjects, CARD_TYPE_TO_CARDS_MAP, CARD_SET
9
9
  local ____cachedClasses = require("cachedClasses")
10
10
  local itemConfig = ____cachedClasses.itemConfig
11
- local ____cardDescriptionMap = require("maps.cardDescriptionMap")
12
- local CARD_DESCRIPTION_MAP = ____cardDescriptionMap.CARD_DESCRIPTION_MAP
13
- local DEFAULT_CARD_DESCRIPTION = ____cardDescriptionMap.DEFAULT_CARD_DESCRIPTION
14
- local ____cardNameMap = require("maps.cardNameMap")
15
- local CARD_NAME_MAP = ____cardNameMap.CARD_NAME_MAP
16
- local DEFAULT_CARD_NAME = ____cardNameMap.DEFAULT_CARD_NAME
17
- local ____cardTypeMap = require("maps.cardTypeMap")
18
- local CARD_TYPE_MAP = ____cardTypeMap.CARD_TYPE_MAP
19
- local DEFAULT_CARD_TYPE = ____cardTypeMap.DEFAULT_CARD_TYPE
11
+ local ____cardDescriptions = require("objects.cardDescriptions")
12
+ local CARD_DESCRIPTIONS = ____cardDescriptions.CARD_DESCRIPTIONS
13
+ local DEFAULT_CARD_DESCRIPTION = ____cardDescriptions.DEFAULT_CARD_DESCRIPTION
14
+ local ____cardNames = require("objects.cardNames")
15
+ local CARD_NAMES = ____cardNames.CARD_NAMES
16
+ local DEFAULT_CARD_NAME = ____cardNames.DEFAULT_CARD_NAME
17
+ local ____cardTypes = require("objects.cardTypes")
18
+ local CARD_TYPES = ____cardTypes.CARD_TYPES
19
+ local DEFAULT_CARD_TYPE = ____cardTypes.DEFAULT_CARD_TYPE
20
20
  local ____CardType = require("types.CardType")
21
21
  local CardType = ____CardType.CardType
22
22
  local ____math = require("functions.math")
@@ -69,7 +69,7 @@ function ____exports.getCardsOfType(self, ...)
69
69
  return matchingCards
70
70
  end
71
71
  function ____exports.getCardType(self, card)
72
- local cardType = CARD_TYPE_MAP[card]
72
+ local cardType = CARD_TYPES[card]
73
73
  return cardType == nil and DEFAULT_CARD_TYPE or cardType
74
74
  end
75
75
  function ____exports.getMaxCards(self)
@@ -78,7 +78,7 @@ end
78
78
  CARD_TYPE_TO_CARDS_MAP = __TS__New(Map)
79
79
  CARD_SET = __TS__New(Set)
80
80
  function ____exports.getCardDescription(self, card)
81
- local cardDescription = CARD_DESCRIPTION_MAP[card]
81
+ local cardDescription = CARD_DESCRIPTIONS[card]
82
82
  if cardDescription ~= nil then
83
83
  return cardDescription
84
84
  end
@@ -89,7 +89,7 @@ function ____exports.getCardDescription(self, card)
89
89
  return DEFAULT_CARD_DESCRIPTION
90
90
  end
91
91
  function ____exports.getCardName(self, card)
92
- local cardName = CARD_NAME_MAP[card]
92
+ local cardName = CARD_NAMES[card]
93
93
  if cardName ~= nil and cardName ~= DEFAULT_CARD_NAME then
94
94
  return cardName
95
95
  end
@@ -1,10 +1,10 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____exports = {}
3
- local ____challengeNameMap = require("maps.challengeNameMap")
4
- local CHALLENGE_NAME_MAP = ____challengeNameMap.CHALLENGE_NAME_MAP
5
- local DEFAULT_CHALLENGE_NAME = ____challengeNameMap.DEFAULT_CHALLENGE_NAME
3
+ local ____challengeNames = require("objects.challengeNames")
4
+ local CHALLENGE_NAMES = ____challengeNames.CHALLENGE_NAMES
5
+ local DEFAULT_CHALLENGE_NAME = ____challengeNames.DEFAULT_CHALLENGE_NAME
6
6
  function ____exports.getChallengeName(self, challenge)
7
- local challengeName = CHALLENGE_NAME_MAP[challenge]
7
+ local challengeName = CHALLENGE_NAMES[challenge]
8
8
  return challengeName == nil and DEFAULT_CHALLENGE_NAME or challengeName
9
9
  end
10
10
  return ____exports
@@ -5,6 +5,7 @@ export declare function closeAllDoors(): void;
5
5
  * without an animation.
6
6
  */
7
7
  export declare function closeDoorFast(door: GridEntityDoor): void;
8
+ export declare function doorSlotToDirection(doorSlot: DoorSlot): Direction;
8
9
  /**
9
10
  * Helper function to get all of the doors in the room. By default, it will return every door. You
10
11
  * can optionally specify one or more room types to return only the doors that match the specified
@@ -10,6 +10,8 @@ local ____cachedClasses = require("cachedClasses")
10
10
  local game = ____cachedClasses.game
11
11
  local ____constants = require("constants")
12
12
  local MAX_NUM_DOORS = ____constants.MAX_NUM_DOORS
13
+ local ____doorSlotToDirection = require("objects.doorSlotToDirection")
14
+ local DOOR_SLOT_TO_DIRECTION = ____doorSlotToDirection.DOOR_SLOT_TO_DIRECTION
13
15
  function ____exports.getDoors(self, ...)
14
16
  local roomTypes = {...}
15
17
  local room = game:GetRoom()
@@ -21,13 +23,13 @@ function ____exports.getDoors(self, ...)
21
23
  do
22
24
  local door = room:GetDoor(i)
23
25
  if door == nil then
24
- goto __continue7
26
+ goto __continue8
25
27
  end
26
28
  if #roomTypes == 0 or roomTypesSet:has(door.TargetRoomType) then
27
29
  __TS__ArrayPush(doors, door)
28
30
  end
29
31
  end
30
- ::__continue7::
32
+ ::__continue8::
31
33
  i = i + 1
32
34
  end
33
35
  end
@@ -61,6 +63,9 @@ function ____exports.closeDoorFast(self, door)
61
63
  local sprite = door:GetSprite()
62
64
  sprite:Play("Closed", true)
63
65
  end
66
+ function ____exports.doorSlotToDirection(self, doorSlot)
67
+ return DOOR_SLOT_TO_DIRECTION[doorSlot]
68
+ end
64
69
  function ____exports.getDoorsToRoomIndex(self, ...)
65
70
  local roomGridIndex = {...}
66
71
  local roomGridIndexesSet = __TS__New(Set, roomGridIndex)
@@ -214,6 +214,8 @@ function ____exports.logEntities(includeBackgroundEffects, entityTypeFilter)
214
214
  )
215
215
  if numMatchedEntities == 0 then
216
216
  ____exports.log("(no entities matched)")
217
+ else
218
+ ____exports.log(("(" .. tostring(numMatchedEntities)) .. " total entities)")
217
219
  end
218
220
  end
219
221
  function ____exports.logGridEntities(includeWalls, gridEntityTypeFilter)
@@ -278,6 +280,8 @@ function ____exports.logGridEntities(includeWalls, gridEntityTypeFilter)
278
280
  )
279
281
  if numMatchedEntities == 0 then
280
282
  ____exports.log("(no grid entities matched)")
283
+ else
284
+ ____exports.log(("(" .. tostring(numMatchedEntities)) .. " total grid entities)")
281
285
  end
282
286
  end
283
287
  function ____exports.logKColor(kColor)
@@ -2,49 +2,8 @@
2
2
  local ____lualib = require("lualib_bundle")
3
3
  local __TS__ArrayPush = ____lualib.__TS__ArrayPush
4
4
  local ____exports = {}
5
- local getCircleInitialPosition
6
- local ____utils = require("functions.utils")
7
- local ensureAllCases = ____utils.ensureAllCases
8
- function getCircleInitialPosition(self, direction, radius)
9
- repeat
10
- local ____switch6 = direction
11
- local ____cond6 = ____switch6 == Direction.NO_DIRECTION
12
- if ____cond6 then
13
- do
14
- return Vector.Zero
15
- end
16
- end
17
- ____cond6 = ____cond6 or ____switch6 == Direction.LEFT
18
- if ____cond6 then
19
- do
20
- return Vector(-radius, 0)
21
- end
22
- end
23
- ____cond6 = ____cond6 or ____switch6 == Direction.UP
24
- if ____cond6 then
25
- do
26
- return Vector(0, -radius)
27
- end
28
- end
29
- ____cond6 = ____cond6 or ____switch6 == Direction.RIGHT
30
- if ____cond6 then
31
- do
32
- return Vector(radius, 0)
33
- end
34
- end
35
- ____cond6 = ____cond6 or ____switch6 == Direction.DOWN
36
- if ____cond6 then
37
- do
38
- return Vector(0, radius)
39
- end
40
- end
41
- do
42
- do
43
- return ensureAllCases(nil, direction)
44
- end
45
- end
46
- until true
47
- end
5
+ local ____vector = require("functions.vector")
6
+ local directionToVector = ____vector.directionToVector
48
7
  function ____exports.getAngleDifference(self, angle1, angle2)
49
8
  local subtractedAngle = angle1 - angle2
50
9
  return (subtractedAngle + 180) % 360 - 180
@@ -59,7 +18,8 @@ function ____exports.getCircleDiscretizedPoints(self, centerPos, radius, numPoin
59
18
  if initialDirection == nil then
60
19
  initialDirection = Direction.UP
61
20
  end
62
- local initialPosition = getCircleInitialPosition(nil, initialDirection, radius)
21
+ local vector = directionToVector(nil, initialDirection)
22
+ local initialPosition = vector * radius
63
23
  local positions = {}
64
24
  do
65
25
  local i = 0
@@ -2,24 +2,24 @@
2
2
  local ____exports = {}
3
3
  local ____cachedClasses = require("cachedClasses")
4
4
  local itemConfig = ____cachedClasses.itemConfig
5
- local ____pillEffectClassMap = require("maps.pillEffectClassMap")
6
- local DEFAULT_PILL_EFFECT_CLASS = ____pillEffectClassMap.DEFAULT_PILL_EFFECT_CLASS
7
- local PILL_EFFECT_CLASS_MAP = ____pillEffectClassMap.PILL_EFFECT_CLASS_MAP
8
- local ____pillEffectNameMap = require("maps.pillEffectNameMap")
9
- local DEFAULT_PILL_EFFECT_NAME = ____pillEffectNameMap.DEFAULT_PILL_EFFECT_NAME
10
- local PILL_EFFECT_NAME_MAP = ____pillEffectNameMap.PILL_EFFECT_NAME_MAP
11
- local ____pillEffectTypeMap = require("maps.pillEffectTypeMap")
12
- local DEFAULT_PILL_EFFECT_TYPE = ____pillEffectTypeMap.DEFAULT_PILL_EFFECT_TYPE
13
- local PILL_EFFECT_TYPE_MAP = ____pillEffectTypeMap.PILL_EFFECT_TYPE_MAP
5
+ local ____pillEffectClasses = require("objects.pillEffectClasses")
6
+ local DEFAULT_PILL_EFFECT_CLASS = ____pillEffectClasses.DEFAULT_PILL_EFFECT_CLASS
7
+ local PILL_EFFECT_CLASSES = ____pillEffectClasses.PILL_EFFECT_CLASSES
8
+ local ____pillEffectNames = require("objects.pillEffectNames")
9
+ local DEFAULT_PILL_EFFECT_NAME = ____pillEffectNames.DEFAULT_PILL_EFFECT_NAME
10
+ local PILL_EFFECT_NAMES = ____pillEffectNames.PILL_EFFECT_NAMES
11
+ local ____pillEffectTypes = require("objects.pillEffectTypes")
12
+ local DEFAULT_PILL_EFFECT_TYPE = ____pillEffectTypes.DEFAULT_PILL_EFFECT_TYPE
13
+ local PILL_EFFECT_TYPES = ____pillEffectTypes.PILL_EFFECT_TYPES
14
14
  function ____exports.getMaxPillEffects(self)
15
15
  return itemConfig:GetPillEffects().Size - 1
16
16
  end
17
17
  function ____exports.getPillEffectClass(self, pillEffect)
18
- local pillEffectClass = PILL_EFFECT_CLASS_MAP[pillEffect]
18
+ local pillEffectClass = PILL_EFFECT_CLASSES[pillEffect]
19
19
  return pillEffectClass == nil and DEFAULT_PILL_EFFECT_CLASS or pillEffectClass
20
20
  end
21
21
  function ____exports.getPillEffectName(self, pillEffect)
22
- local pillEffectName = PILL_EFFECT_NAME_MAP[pillEffect]
22
+ local pillEffectName = PILL_EFFECT_NAMES[pillEffect]
23
23
  if pillEffectName ~= nil and pillEffectName ~= DEFAULT_PILL_EFFECT_NAME then
24
24
  return pillEffectName
25
25
  end
@@ -30,7 +30,7 @@ function ____exports.getPillEffectName(self, pillEffect)
30
30
  return DEFAULT_PILL_EFFECT_NAME
31
31
  end
32
32
  function ____exports.getPillEffectType(self, pillEffect)
33
- local pillEffectClass = PILL_EFFECT_TYPE_MAP[pillEffect]
33
+ local pillEffectClass = PILL_EFFECT_TYPES[pillEffect]
34
34
  return pillEffectClass == nil and DEFAULT_PILL_EFFECT_TYPE or pillEffectClass
35
35
  end
36
36
  return ____exports
@@ -22,9 +22,9 @@ local CHARACTERS_WITH_NO_RED_HEARTS = ____constants.CHARACTERS_WITH_NO_RED_HEART
22
22
  local CHARACTERS_WITH_NO_SOUL_HEARTS = ____constants.CHARACTERS_WITH_NO_SOUL_HEARTS
23
23
  local LOST_STYLE_PLAYER_TYPES = ____constants.LOST_STYLE_PLAYER_TYPES
24
24
  local MAX_VANILLA_CHARACTER = ____constants.MAX_VANILLA_CHARACTER
25
- local ____characterNameMap = require("maps.characterNameMap")
26
- local CHARACTER_NAME_MAP = ____characterNameMap.CHARACTER_NAME_MAP
27
- local DEFAULT_CHARACTER_NAME = ____characterNameMap.DEFAULT_CHARACTER_NAME
25
+ local ____characterNames = require("objects.characterNames")
26
+ local CHARACTER_NAMES = ____characterNames.CHARACTER_NAMES
27
+ local DEFAULT_CHARACTER_NAME = ____characterNames.DEFAULT_CHARACTER_NAME
28
28
  local ____HealthType = require("types.HealthType")
29
29
  local HealthType = ____HealthType.HealthType
30
30
  local ____array = require("functions.array")
@@ -265,7 +265,7 @@ function ____exports.getCharacterName(self, character)
265
265
  if character >= PlayerType.NUM_PLAYER_TYPES then
266
266
  return "unknown"
267
267
  end
268
- local characterName = CHARACTER_NAME_MAP[character]
268
+ local characterName = CHARACTER_NAMES[character]
269
269
  return characterName == nil and DEFAULT_CHARACTER_NAME or characterName
270
270
  end
271
271
  function ____exports.getClosestPlayer(self, position)
@@ -2,8 +2,8 @@
2
2
  local ____exports = {}
3
3
  local ____cachedClasses = require("cachedClasses")
4
4
  local game = ____cachedClasses.game
5
- local ____utils = require("functions.utils")
6
- local ensureAllCases = ____utils.ensureAllCases
5
+ local ____stageTypeToLetter = require("objects.stageTypeToLetter")
6
+ local STAGE_TYPE_TO_LETTER = ____stageTypeToLetter.STAGE_TYPE_TO_LETTER
7
7
  function ____exports.isRepentanceStage(self, stageType)
8
8
  return stageType == StageType.STAGETYPE_REPENTANCE or stageType == StageType.STAGETYPE_REPENTANCE_B
9
9
  end
@@ -13,50 +13,7 @@ function ____exports.onRepentanceStage(self)
13
13
  return ____exports.isRepentanceStage(nil, stageType)
14
14
  end
15
15
  function ____exports.stageTypeToLetter(self, stageType)
16
- repeat
17
- local ____switch15 = stageType
18
- local ____cond15 = ____switch15 == StageType.STAGETYPE_ORIGINAL
19
- if ____cond15 then
20
- do
21
- return ""
22
- end
23
- end
24
- ____cond15 = ____cond15 or ____switch15 == StageType.STAGETYPE_WOTL
25
- if ____cond15 then
26
- do
27
- return "a"
28
- end
29
- end
30
- ____cond15 = ____cond15 or ____switch15 == StageType.STAGETYPE_AFTERBIRTH
31
- if ____cond15 then
32
- do
33
- return "b"
34
- end
35
- end
36
- ____cond15 = ____cond15 or ____switch15 == StageType.STAGETYPE_GREEDMODE
37
- if ____cond15 then
38
- do
39
- return ""
40
- end
41
- end
42
- ____cond15 = ____cond15 or ____switch15 == StageType.STAGETYPE_REPENTANCE
43
- if ____cond15 then
44
- do
45
- return "c"
46
- end
47
- end
48
- ____cond15 = ____cond15 or ____switch15 == StageType.STAGETYPE_REPENTANCE_B
49
- if ____cond15 then
50
- do
51
- return "d"
52
- end
53
- end
54
- do
55
- do
56
- return ensureAllCases(nil, stageType)
57
- end
58
- end
59
- until true
16
+ return STAGE_TYPE_TO_LETTER[stageType]
60
17
  end
61
18
  function ____exports.getEffectiveStage(self)
62
19
  local level = game:GetLevel()