isaacscript-common 1.2.152 → 1.2.155

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.
@@ -4,14 +4,17 @@ local Set = ____lualib.Set
4
4
  local __TS__New = ____lualib.__TS__New
5
5
  local Map = ____lualib.Map
6
6
  local ____exports = {}
7
- local hasSubscriptions, postEffectRenderCustomEntity, getPositionOffset, getAnimation, POSITION_OFFSET_MULTIPLIER
7
+ local hasSubscriptions, postEffectRenderCustomEntity, isPlayerPastDoorThreshold, getPositionOffset, getAnimation, POSITION_OFFSET_MULTIPLIER, v
8
8
  local ____cachedClasses = require("cachedClasses")
9
9
  local game = ____cachedClasses.game
10
10
  local ____exports = require("features.saveDataManager.exports")
11
11
  local saveDataManager = ____exports.saveDataManager
12
12
  local ____doors = require("functions.doors")
13
13
  local doorSlotToDirection = ____doors.doorSlotToDirection
14
- local getDoors = ____doors.getDoors
14
+ local ____player = require("functions.player")
15
+ local getClosestPlayer = ____player.getClosestPlayer
16
+ local ____utils = require("functions.utils")
17
+ local ensureAllCases = ____utils.ensureAllCases
15
18
  local ____vector = require("functions.vector")
16
19
  local directionToVector = ____vector.directionToVector
17
20
  local ____postCustomDoorEnter = require("callbacks.subscriptions.postCustomDoorEnter")
@@ -20,16 +23,66 @@ local postCustomDoorEnterHasSubscriptions = ____postCustomDoorEnter.postCustomDo
20
23
  function hasSubscriptions(self)
21
24
  return postCustomDoorEnterHasSubscriptions(nil)
22
25
  end
23
- function postEffectRenderCustomEntity(self)
26
+ function postEffectRenderCustomEntity(self, effect)
24
27
  if not hasSubscriptions(nil) then
25
28
  return
26
29
  end
27
- local doors = getDoors(nil)
28
- if #doors == 0 then
30
+ local ptrHash = GetPtrHash(effect)
31
+ local doorData = v.room.doors:get(ptrHash)
32
+ if doorData == nil then
29
33
  return
30
34
  end
31
- local door = doors[1]
32
- 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
33
86
  end
34
87
  function getPositionOffset(self, doorSlot)
35
88
  local direction = doorSlotToDirection(nil, doorSlot)
@@ -38,15 +91,15 @@ function getPositionOffset(self, doorSlot)
38
91
  end
39
92
  function getAnimation(self, effect)
40
93
  repeat
41
- local ____switch15 = effect.State
42
- local ____cond15 = ____switch15 == DoorState.STATE_OPEN
43
- if ____cond15 then
94
+ local ____switch24 = effect.State
95
+ local ____cond24 = ____switch24 == DoorState.STATE_OPEN
96
+ if ____cond24 then
44
97
  do
45
98
  return "Opened"
46
99
  end
47
100
  end
48
- ____cond15 = ____cond15 or ____switch15 == DoorState.STATE_CLOSED
49
- if ____cond15 then
101
+ ____cond24 = ____cond24 or ____switch24 == DoorState.STATE_CLOSED
102
+ if ____cond24 then
50
103
  do
51
104
  return "Closed"
52
105
  end
@@ -58,9 +111,9 @@ function getAnimation(self, effect)
58
111
  end
59
112
  until true
60
113
  end
61
- POSITION_OFFSET_MULTIPLIER = 23
114
+ POSITION_OFFSET_MULTIPLIER = -23
62
115
  local initializedEffectVariants = __TS__New(Set)
63
- local v = {room = {doors = __TS__New(Map)}}
116
+ v = {room = {doors = __TS__New(Map)}}
64
117
  function ____exports.postCustomDoorEnterCallbackInit(self)
65
118
  saveDataManager(nil, "postCustomDoorEnter", v, hasSubscriptions)
66
119
  end
@@ -100,5 +153,8 @@ function ____exports.spawnCustomDoor(self, effectVariant, doorSlot)
100
153
  wall.CollisionClass = GridCollisionClass.COLLISION_WALL_EXCEPT_PLAYER
101
154
  end
102
155
  end
156
+ local ptrHash = GetPtrHash(effect)
157
+ local doorData = {slot = doorSlot}
158
+ v.room.doors:set(ptrHash, doorData)
103
159
  end
104
160
  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 callbackEffectVariant ~= nil and callbackEffectVariant ~= effectVariant 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
@@ -264,7 +264,9 @@ export declare function sacrifice(): void;
264
264
  /** Warps to the first Secret Room on the floor. */
265
265
  export declare function secret(): void;
266
266
  /** Logs all of the current run's seed effects to the "log.txt" file. */
267
- export declare function seeds(): void;
267
+ export declare function seedsCommand(): void;
268
+ /** Changes to a seeded run, using the seed of the current run. */
269
+ export declare function seedStick(): void;
268
270
  /**
269
271
  * Sets a charge to the player's specified active item. You must provide the active slot number and
270
272
  * the number of charges to set.
@@ -755,10 +755,15 @@ end
755
755
  function ____exports.secret(self)
756
756
  warpToRoomType(nil, RoomType.ROOM_SECRET)
757
757
  end
758
- function ____exports.seeds(self)
758
+ function ____exports.seedsCommand(self)
759
759
  logAllSeedEffects()
760
760
  printConsole(nil, "Logged the seed effects to the \"log.txt\" file.")
761
761
  end
762
+ function ____exports.seedStick(self)
763
+ local seeds = game:GetSeeds()
764
+ local startSeedString = seeds:GetStartSeedString()
765
+ Isaac.ExecuteCommand("seed " .. startSeedString)
766
+ end
762
767
  function ____exports.setCharges(self, params)
763
768
  if params == "" then
764
769
  printConsole(nil, "You must specify a slot number and a charge amount. (Use 0 for the primary slot, 1 for the Schoolbag slot, 2 for the pocket item slot, and 3 for the Dice Bag slot.)")
@@ -173,7 +173,8 @@ commandFunctionsMap:set("rottenhearts", commands.rottenHearts)
173
173
  commandFunctionsMap:set("s", commands.s)
174
174
  commandFunctionsMap:set("sacrifice", commands.sacrifice)
175
175
  commandFunctionsMap:set("secret", commands.secret)
176
- commandFunctionsMap:set("seeds", commands.seeds)
176
+ commandFunctionsMap:set("seeds", commands.seedsCommand)
177
+ commandFunctionsMap:set("seedstick", commands.seedStick)
177
178
  commandFunctionsMap:set("setcharges", commands.setCharges)
178
179
  commandFunctionsMap:set("setposition", commands.setPosition)
179
180
  commandFunctionsMap:set("sh", commands.sh)
package/dist/index.d.ts CHANGED
@@ -70,6 +70,10 @@ export * from "./functions/trinketSet";
70
70
  export * from "./functions/ui";
71
71
  export * from "./functions/utils";
72
72
  export * from "./functions/vector";
73
+ export * from "./maps/cardMap";
74
+ export * from "./maps/characterMap";
75
+ export * from "./maps/pillEffectMap";
76
+ export * from "./maps/roomTypeMap";
73
77
  export * from "./types/AnyEntity";
74
78
  export * from "./types/CallbackParametersCustom";
75
79
  export * from "./types/CardType";
package/dist/index.lua CHANGED
@@ -568,6 +568,38 @@ do
568
568
  end
569
569
  end
570
570
  end
571
+ do
572
+ local ____export = require("maps.cardMap")
573
+ for ____exportKey, ____exportValue in pairs(____export) do
574
+ if ____exportKey ~= "default" then
575
+ ____exports[____exportKey] = ____exportValue
576
+ end
577
+ end
578
+ end
579
+ do
580
+ local ____export = require("maps.characterMap")
581
+ for ____exportKey, ____exportValue in pairs(____export) do
582
+ if ____exportKey ~= "default" then
583
+ ____exports[____exportKey] = ____exportValue
584
+ end
585
+ end
586
+ end
587
+ do
588
+ local ____export = require("maps.pillEffectMap")
589
+ for ____exportKey, ____exportValue in pairs(____export) do
590
+ if ____exportKey ~= "default" then
591
+ ____exports[____exportKey] = ____exportValue
592
+ end
593
+ end
594
+ end
595
+ do
596
+ local ____export = require("maps.roomTypeMap")
597
+ for ____exportKey, ____exportValue in pairs(____export) do
598
+ if ____exportKey ~= "default" then
599
+ ____exports[____exportKey] = ____exportValue
600
+ end
601
+ end
602
+ end
571
603
  do
572
604
  local ____export = require("types.CardType")
573
605
  for ____exportKey, ____exportValue in pairs(____export) do
@@ -233,6 +233,7 @@ export interface CallbackParametersCustom {
233
233
  callback: PostBoneSwingCallbackType
234
234
  ];
235
235
  [ModCallbacksCustom.MC_POST_CUSTOM_DOOR_ENTER]: [
236
- callback: PostCustomDoorEnterCallbackType
236
+ callback: PostCustomDoorEnterCallbackType,
237
+ effectVariant?: int
237
238
  ];
238
239
  }
@@ -8,11 +8,11 @@ export declare class ModUpgraded implements Mod {
8
8
  /** End-users can optionally enable verbose-mode, which helps troubleshoot crashes. */
9
9
  Verbose: boolean;
10
10
  constructor(mod: Mod, verbose: boolean);
11
- AddCallback<T extends keyof CallbackParameters>(callbackID: T, ...args: CallbackParameters[T]): void;
11
+ AddCallback<T extends keyof CallbackParameters>(modCallbacks: T, ...args: CallbackParameters[T]): void;
12
12
  HasData(): boolean;
13
13
  LoadData(): string;
14
14
  RemoveCallback(callbackID: ModCallbacks, callback: () => void): void;
15
15
  RemoveData(): void;
16
16
  SaveData(data: string): void;
17
- AddCallbackCustom<T extends keyof CallbackParametersCustom>(callbackID: T, ...args: CallbackParametersCustom[T]): void;
17
+ AddCallbackCustom<T extends keyof CallbackParametersCustom>(modCallbacksCustom: T, ...args: CallbackParametersCustom[T]): void;
18
18
  }
@@ -27,12 +27,12 @@ function ModUpgraded.prototype.____constructor(self, mod, verbose)
27
27
  self.Mod = mod
28
28
  self.Verbose = verbose
29
29
  end
30
- function ModUpgraded.prototype.AddCallback(self, callbackID, ...)
30
+ function ModUpgraded.prototype.AddCallback(self, modCallbacks, ...)
31
31
  local args = {...}
32
32
  if self.Verbose then
33
33
  local callback = args[1]
34
34
  local optionalArg = args[2]
35
- local callbackName = getCallbackName(nil, callbackID)
35
+ local callbackName = getCallbackName(nil, modCallbacks)
36
36
  local debugMsg = getDebugPrependString(nil, callbackName)
37
37
  local function callbackWithLogger(____, ...)
38
38
  Isaac.DebugString(debugMsg .. " - START")
@@ -40,10 +40,10 @@ function ModUpgraded.prototype.AddCallback(self, callbackID, ...)
40
40
  Isaac.DebugString((debugMsg .. " - END - ") .. tostring(value))
41
41
  return value
42
42
  end
43
- self.Mod:AddCallback(callbackID, callbackWithLogger, optionalArg)
43
+ self.Mod:AddCallback(modCallbacks, callbackWithLogger, optionalArg)
44
44
  else
45
45
  self.Mod:AddCallback(
46
- callbackID,
46
+ modCallbacks,
47
47
  __TS__Spread(args)
48
48
  )
49
49
  end
@@ -63,10 +63,10 @@ end
63
63
  function ModUpgraded.prototype.SaveData(self, data)
64
64
  self.Mod:SaveData(data)
65
65
  end
66
- function ModUpgraded.prototype.AddCallbackCustom(self, callbackID, ...)
67
- local callbackRegisterFunction = CALLBACK_REGISTER_FUNCTIONS[callbackID]
66
+ function ModUpgraded.prototype.AddCallbackCustom(self, modCallbacksCustom, ...)
67
+ local callbackRegisterFunction = CALLBACK_REGISTER_FUNCTIONS[modCallbacksCustom]
68
68
  if callbackRegisterFunction == nil then
69
- error("Failed to find a callback registration function for custom callback: " .. tostring(callbackID))
69
+ error("Failed to find a callback registration function for custom callback: " .. tostring(modCallbacksCustom))
70
70
  end
71
71
  callbackRegisterFunction(nil, ...)
72
72
  end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.152",
3
+ "version": "1.2.155",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",