isaacscript-common 5.0.0 → 5.0.1

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,7 +1,10 @@
1
1
  import { ActiveSlot } from "isaac-typescript-definitions";
2
2
  /**
3
- * Helper function to add a charge to the player's active item. Will play the appropriate sound
4
- * effect, depending on whether the charge is partially full or completely full.
3
+ * Helper function to add a charge to the player's active item. Will flash the HUD and play the
4
+ * appropriate sound effect, depending on whether the charge is partially full or completely full.
5
+ *
6
+ * If the player's active item is already fully charged, then this function will return 0 and not
7
+ * flash the HUD or play a sound effect.
5
8
  *
6
9
  * This function will take the following things into account:
7
10
  * - The Battery
@@ -12,7 +15,8 @@ import { ActiveSlot } from "isaac-typescript-definitions";
12
15
  * @param numCharges Optional. The amount of charges to grant. Default is 1.
13
16
  * @param playSoundEffect Optional. Whether to play a charge-related sound effect. Default is true.
14
17
  * @returns The amount of charges that were actually granted. For example, if the active item was
15
- * already fully charged, this function would return 0.
18
+ * only one away from a full charge, but the `numCharges` provided to this function was 2,
19
+ * then this function would return 1.
16
20
  */
17
21
  export declare function addCharge(player: EntityPlayer, activeSlot: ActiveSlot, numCharges?: number, playSoundEffect?: boolean): int;
18
22
  /**
@@ -14,8 +14,11 @@ local ____playerIndex = require("functions.playerIndex")
14
14
  local getPlayers = ____playerIndex.getPlayers
15
15
  local ____roomShape = require("functions.roomShape")
16
16
  local getRoomShapeCharges = ____roomShape.getRoomShapeCharges
17
- --- Helper function to add a charge to the player's active item. Will play the appropriate sound
18
- -- effect, depending on whether the charge is partially full or completely full.
17
+ --- Helper function to add a charge to the player's active item. Will flash the HUD and play the
18
+ -- appropriate sound effect, depending on whether the charge is partially full or completely full.
19
+ --
20
+ -- If the player's active item is already fully charged, then this function will return 0 and not
21
+ -- flash the HUD or play a sound effect.
19
22
  --
20
23
  -- This function will take the following things into account:
21
24
  -- - The Battery
@@ -26,7 +29,8 @@ local getRoomShapeCharges = ____roomShape.getRoomShapeCharges
26
29
  -- @param numCharges Optional. The amount of charges to grant. Default is 1.
27
30
  -- @param playSoundEffect Optional. Whether to play a charge-related sound effect. Default is true.
28
31
  -- @returns The amount of charges that were actually granted. For example, if the active item was
29
- -- already fully charged, this function would return 0.
32
+ -- only one away from a full charge, but the `numCharges` provided to this function was 2,
33
+ -- then this function would return 1.
30
34
  function ____exports.addCharge(self, player, activeSlot, numCharges, playSoundEffect)
31
35
  if numCharges == nil then
32
36
  numCharges = 1
@@ -35,9 +39,9 @@ function ____exports.addCharge(self, player, activeSlot, numCharges, playSoundEf
35
39
  playSoundEffect = true
36
40
  end
37
41
  local hud = game:GetHUD()
38
- local totalCharge = ____exports.getTotalCharge(nil, player, activeSlot)
39
42
  local chargesToAdd = getClampedChargesToAdd(nil, player, activeSlot, numCharges)
40
43
  local modifiedChargesToAdd = getNumChargesWithAAAModifier(nil, player, activeSlot, chargesToAdd)
44
+ local totalCharge = ____exports.getTotalCharge(nil, player, activeSlot)
41
45
  local newCharge = totalCharge + modifiedChargesToAdd
42
46
  if newCharge == totalCharge then
43
47
  return 0
@@ -112,10 +116,10 @@ function getNumChargesWithAAAModifier(self, player, activeSlot, chargesToAdd)
112
116
  return chargesToAdd
113
117
  end
114
118
  if not hasBattery and activeCharge + chargesToAdd == maxCharges - 1 then
115
- return maxCharges + 1
119
+ return chargesToAdd + 1
116
120
  end
117
121
  if hasBattery and batteryCharge + chargesToAdd == maxCharges - 1 then
118
- return maxCharges + 1
122
+ return chargesToAdd + 1
119
123
  end
120
124
  return chargesToAdd
121
125
  end
@@ -0,0 +1,4 @@
1
+ import { DoorSlot, RoomShape } from "isaac-typescript-definitions";
2
+ export declare const ROOM_SHAPE_TO_DOOR_SLOT_COORDINATES: {
3
+ readonly [key in RoomShape]: ReadonlySet<DoorSlot>;
4
+ };
@@ -0,0 +1,46 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local Set = ____lualib.Set
3
+ local __TS__New = ____lualib.__TS__New
4
+ local ____exports = {}
5
+ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
6
+ local DoorSlot = ____isaac_2Dtypescript_2Ddefinitions.DoorSlot
7
+ local RoomShape = ____isaac_2Dtypescript_2Ddefinitions.RoomShape
8
+ local ALL_DOOR_SLOTS_SET = __TS__New(Set, {
9
+ DoorSlot.LEFT_0,
10
+ DoorSlot.UP_0,
11
+ DoorSlot.RIGHT_0,
12
+ DoorSlot.DOWN_0,
13
+ DoorSlot.LEFT_1,
14
+ DoorSlot.UP_1,
15
+ DoorSlot.RIGHT_1,
16
+ DoorSlot.DOWN_1
17
+ })
18
+ ____exports.ROOM_SHAPE_TO_DOOR_SLOT_COORDINATES = {
19
+ [RoomShape.SHAPE_1x1] = __TS__New(Set, {DoorSlot.LEFT_0, DoorSlot.UP_0, DoorSlot.RIGHT_0, DoorSlot.DOWN_0}),
20
+ [RoomShape.IH] = __TS__New(Set, {DoorSlot.LEFT_0, DoorSlot.RIGHT_0}),
21
+ [RoomShape.IV] = __TS__New(Set, {DoorSlot.UP_0, DoorSlot.DOWN_0}),
22
+ [RoomShape.SHAPE_1x2] = __TS__New(Set, {
23
+ DoorSlot.LEFT_0,
24
+ DoorSlot.UP_0,
25
+ DoorSlot.RIGHT_0,
26
+ DoorSlot.DOWN_0,
27
+ DoorSlot.LEFT_1,
28
+ DoorSlot.RIGHT_1
29
+ }),
30
+ [RoomShape.IIV] = __TS__New(Set, {DoorSlot.UP_0, DoorSlot.DOWN_0}),
31
+ [RoomShape.SHAPE_2x1] = __TS__New(Set, {
32
+ DoorSlot.LEFT_0,
33
+ DoorSlot.UP_0,
34
+ DoorSlot.RIGHT_0,
35
+ DoorSlot.DOWN_0,
36
+ DoorSlot.UP_1,
37
+ DoorSlot.DOWN_1
38
+ }),
39
+ [RoomShape.IIH] = __TS__New(Set, {DoorSlot.LEFT_0, DoorSlot.RIGHT_0}),
40
+ [RoomShape.SHAPE_2x2] = ALL_DOOR_SLOTS_SET,
41
+ [RoomShape.LTL] = ALL_DOOR_SLOTS_SET,
42
+ [RoomShape.LTR] = ALL_DOOR_SLOTS_SET,
43
+ [RoomShape.LBL] = ALL_DOOR_SLOTS_SET,
44
+ [RoomShape.LBR] = ALL_DOOR_SLOTS_SET
45
+ }
46
+ return ____exports
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "5.0.0",
3
+ "version": "5.0.1",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",