isaacscript-common 19.1.0 → 20.0.0
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.
- package/dist/index.d.ts +15 -8
- package/dist/isaacscript-common.lua +8 -6
- package/dist/src/classes/ModFeature.d.ts +12 -7
- package/dist/src/classes/ModFeature.d.ts.map +1 -1
- package/dist/src/classes/ModFeature.lua +2 -2
- package/dist/src/functions/playerCenter.d.ts +4 -1
- package/dist/src/functions/playerCenter.d.ts.map +1 -1
- package/dist/src/functions/playerCenter.lua +7 -3
- package/package.json +1 -1
- package/src/classes/ModFeature.ts +16 -11
- package/src/functions/playerCenter.ts +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -11294,26 +11294,31 @@ declare class ModdedElementSets extends Feature {
|
|
|
11294
11294
|
export declare class ModFeature {
|
|
11295
11295
|
private mod;
|
|
11296
11296
|
/**
|
|
11297
|
-
* An optional
|
|
11297
|
+
* An optional method that allows for conditional callback execution. If specified, any class
|
|
11298
11298
|
* method that is annotated with a `@Callback` or `@CallbackCustom` decorator will only be fired
|
|
11299
11299
|
* if the executed conditional function returns true.
|
|
11300
11300
|
*
|
|
11301
11301
|
* This property is used to easily turn entire mod features on and off (rather than repeating
|
|
11302
11302
|
* conditional logic and early returning at the beginning of every callback function).
|
|
11303
11303
|
*
|
|
11304
|
-
*
|
|
11304
|
+
* Since the specific information for the firing callback is passed as arguments into the
|
|
11305
|
+
* conditional method, you can also write logic that would only apply to a specific type of
|
|
11306
|
+
* callback.
|
|
11307
|
+
*
|
|
11308
|
+
* By default, this is set to null, which means that all callback methods will fire
|
|
11309
|
+
* unconditionally. Override this property in your class if you need to use it.
|
|
11305
11310
|
*
|
|
11306
11311
|
* The function has the following signature:
|
|
11307
11312
|
*
|
|
11308
11313
|
* ```ts
|
|
11309
|
-
* (
|
|
11310
|
-
* vanilla:
|
|
11311
|
-
* modCallback: ModCallback
|
|
11312
|
-
* ...callbackArgs: unknown[]
|
|
11314
|
+
* <T extends boolean>(
|
|
11315
|
+
* vanilla: T, // Whether or not this is a vanilla or custom callback.
|
|
11316
|
+
* modCallback: T extends true ? ModCallback : ModCallbackCustom,
|
|
11317
|
+
* ...callbackArgs: unknown[] // This would be e.g. `pickup: EntityPickup` for the `POST_PICKUP_INIT` callback.
|
|
11313
11318
|
* ) => boolean;
|
|
11314
11319
|
* ```
|
|
11315
11320
|
*/
|
|
11316
|
-
protected
|
|
11321
|
+
protected shouldCallbackMethodsFire: (<T extends boolean>(vanilla: T, modCallback: T extends true ? ModCallback : ModCallbackCustom, ...callbackArgs: unknown[]) => boolean) | null;
|
|
11317
11322
|
/**
|
|
11318
11323
|
* Whether or not the feature has registered its callbacks yet (and submitted its variables to the
|
|
11319
11324
|
* save data manager, if any).
|
|
@@ -11451,8 +11456,10 @@ export declare const MOVEMENT_ACTIONS_SET: ReadonlySet<ButtonAction>;
|
|
|
11451
11456
|
* If there is more than one player, they will be distributed around the center in a circle.
|
|
11452
11457
|
*
|
|
11453
11458
|
* This function emulates what happens in the vanilla game when you travel to a new floor.
|
|
11459
|
+
*
|
|
11460
|
+
* @param radius Optional. The radius of the circle. Default is 10.
|
|
11454
11461
|
*/
|
|
11455
|
-
export declare function movePlayersToCenter(): void;
|
|
11462
|
+
export declare function movePlayersToCenter(radius?: float): void;
|
|
11456
11463
|
|
|
11457
11464
|
/**
|
|
11458
11465
|
* A cached version of the class returned from the `MusicManager()` constructor.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
--[[
|
|
2
2
|
|
|
3
|
-
isaacscript-common
|
|
3
|
+
isaacscript-common 20.0.0
|
|
4
4
|
|
|
5
5
|
This is the "isaacscript-common" library, which was created with the IsaacScript tool.
|
|
6
6
|
|
|
@@ -38046,8 +38046,10 @@ function movePlayerAndTheirFamiliars(self, player, position)
|
|
|
38046
38046
|
familiar.Position = position
|
|
38047
38047
|
end
|
|
38048
38048
|
end
|
|
38049
|
-
|
|
38050
|
-
|
|
38049
|
+
function ____exports.movePlayersToCenter(self, radius)
|
|
38050
|
+
if radius == nil then
|
|
38051
|
+
radius = 10
|
|
38052
|
+
end
|
|
38051
38053
|
local isGreedMode = game:IsGreedMode()
|
|
38052
38054
|
local startingPosition = isGreedMode and NEW_FLOOR_STARTING_POSITION_GREED_MODE or NEW_FLOOR_STARTING_POSITION_NORMAL_MODE
|
|
38053
38055
|
local players = getAllPlayers(nil)
|
|
@@ -38062,7 +38064,7 @@ function ____exports.movePlayersToCenter(self)
|
|
|
38062
38064
|
local circlePoints = getCircleDiscretizedPoints(
|
|
38063
38065
|
nil,
|
|
38064
38066
|
startingPosition,
|
|
38065
|
-
|
|
38067
|
+
radius,
|
|
38066
38068
|
#players,
|
|
38067
38069
|
1,
|
|
38068
38070
|
1,
|
|
@@ -49508,7 +49510,7 @@ function initDecoratedCallbacks(self, modFeature, constructor, tstlClassName, va
|
|
|
49508
49510
|
end
|
|
49509
49511
|
function addCallback(self, modFeature, modFeatureConstructor, mod, modCallback, callback, parameters, vanilla)
|
|
49510
49512
|
local function wrappedCallback(____, ...)
|
|
49511
|
-
local conditionalFunc = modFeature.
|
|
49513
|
+
local conditionalFunc = modFeature.shouldCallbackMethodsFire
|
|
49512
49514
|
if conditionalFunc ~= nil then
|
|
49513
49515
|
local shouldRun = conditionalFunc(nil, vanilla, modCallback, ...)
|
|
49514
49516
|
if not shouldRun then
|
|
@@ -49603,7 +49605,7 @@ function ModFeature.prototype.____constructor(self, mod, init)
|
|
|
49603
49605
|
if init == nil then
|
|
49604
49606
|
init = true
|
|
49605
49607
|
end
|
|
49606
|
-
self.
|
|
49608
|
+
self.shouldCallbackMethodsFire = nil
|
|
49607
49609
|
self.initialized = false
|
|
49608
49610
|
self.mod = mod
|
|
49609
49611
|
if init then
|
|
@@ -39,26 +39,31 @@ export declare const MOD_FEATURE_CUSTOM_CALLBACKS_KEY = "__customCallbacks";
|
|
|
39
39
|
export declare class ModFeature {
|
|
40
40
|
private mod;
|
|
41
41
|
/**
|
|
42
|
-
* An optional
|
|
42
|
+
* An optional method that allows for conditional callback execution. If specified, any class
|
|
43
43
|
* method that is annotated with a `@Callback` or `@CallbackCustom` decorator will only be fired
|
|
44
44
|
* if the executed conditional function returns true.
|
|
45
45
|
*
|
|
46
46
|
* This property is used to easily turn entire mod features on and off (rather than repeating
|
|
47
47
|
* conditional logic and early returning at the beginning of every callback function).
|
|
48
48
|
*
|
|
49
|
-
*
|
|
49
|
+
* Since the specific information for the firing callback is passed as arguments into the
|
|
50
|
+
* conditional method, you can also write logic that would only apply to a specific type of
|
|
51
|
+
* callback.
|
|
52
|
+
*
|
|
53
|
+
* By default, this is set to null, which means that all callback methods will fire
|
|
54
|
+
* unconditionally. Override this property in your class if you need to use it.
|
|
50
55
|
*
|
|
51
56
|
* The function has the following signature:
|
|
52
57
|
*
|
|
53
58
|
* ```ts
|
|
54
|
-
* (
|
|
55
|
-
* vanilla:
|
|
56
|
-
* modCallback: ModCallback
|
|
57
|
-
* ...callbackArgs: unknown[]
|
|
59
|
+
* <T extends boolean>(
|
|
60
|
+
* vanilla: T, // Whether or not this is a vanilla or custom callback.
|
|
61
|
+
* modCallback: T extends true ? ModCallback : ModCallbackCustom,
|
|
62
|
+
* ...callbackArgs: unknown[] // This would be e.g. `pickup: EntityPickup` for the `POST_PICKUP_INIT` callback.
|
|
58
63
|
* ) => boolean;
|
|
59
64
|
* ```
|
|
60
65
|
*/
|
|
61
|
-
protected
|
|
66
|
+
protected shouldCallbackMethodsFire: (<T extends boolean>(vanilla: T, modCallback: T extends true ? ModCallback : ModCallbackCustom, ...callbackArgs: unknown[]) => boolean) | null;
|
|
62
67
|
/**
|
|
63
68
|
* Whether or not the feature has registered its callbacks yet (and submitted its variables to the
|
|
64
69
|
* save data manager, if any).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModFeature.d.ts","sourceRoot":"","sources":["../../../src/classes/ModFeature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CA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modFeature, constructor, tstlClassName, va
|
|
|
64
64
|
end
|
|
65
65
|
function addCallback(self, modFeature, modFeatureConstructor, mod, modCallback, callback, parameters, vanilla)
|
|
66
66
|
local function wrappedCallback(____, ...)
|
|
67
|
-
local conditionalFunc = modFeature.
|
|
67
|
+
local conditionalFunc = modFeature.shouldCallbackMethodsFire
|
|
68
68
|
if conditionalFunc ~= nil then
|
|
69
69
|
local shouldRun = conditionalFunc(nil, vanilla, modCallback, ...)
|
|
70
70
|
if not shouldRun then
|
|
@@ -190,7 +190,7 @@ function ModFeature.prototype.____constructor(self, mod, init)
|
|
|
190
190
|
if init == nil then
|
|
191
191
|
init = true
|
|
192
192
|
end
|
|
193
|
-
self.
|
|
193
|
+
self.shouldCallbackMethodsFire = nil
|
|
194
194
|
self.initialized = false
|
|
195
195
|
self.mod = mod
|
|
196
196
|
if init then
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
1
2
|
/**
|
|
2
3
|
* Helper function to move all of the players to where they would normally go when arriving at a new
|
|
3
4
|
* floor. (In normal mode, this is the center of the room. In Greed Mode, this is below the top
|
|
@@ -6,6 +7,8 @@
|
|
|
6
7
|
* If there is more than one player, they will be distributed around the center in a circle.
|
|
7
8
|
*
|
|
8
9
|
* This function emulates what happens in the vanilla game when you travel to a new floor.
|
|
10
|
+
*
|
|
11
|
+
* @param radius Optional. The radius of the circle. Default is 10.
|
|
9
12
|
*/
|
|
10
|
-
export declare function movePlayersToCenter(): void;
|
|
13
|
+
export declare function movePlayersToCenter(radius?: float): void;
|
|
11
14
|
//# sourceMappingURL=playerCenter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playerCenter.d.ts","sourceRoot":"","sources":["../../../src/functions/playerCenter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"playerCenter.d.ts","sourceRoot":"","sources":["../../../src/functions/playerCenter.ts"],"names":[],"mappings":";AAUA;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,GAAE,KAAU,GAAG,IAAI,CAqC5D"}
|
|
@@ -20,7 +20,6 @@ function movePlayerAndTheirFamiliars(self, player, position)
|
|
|
20
20
|
familiar.Position = position
|
|
21
21
|
end
|
|
22
22
|
end
|
|
23
|
-
local CIRCLE_RADIUS_BETWEEN_PLAYERS = 50
|
|
24
23
|
--- Helper function to move all of the players to where they would normally go when arriving at a new
|
|
25
24
|
-- floor. (In normal mode, this is the center of the room. In Greed Mode, this is below the top
|
|
26
25
|
-- door.)
|
|
@@ -28,7 +27,12 @@ local CIRCLE_RADIUS_BETWEEN_PLAYERS = 50
|
|
|
28
27
|
-- If there is more than one player, they will be distributed around the center in a circle.
|
|
29
28
|
--
|
|
30
29
|
-- This function emulates what happens in the vanilla game when you travel to a new floor.
|
|
31
|
-
|
|
30
|
+
--
|
|
31
|
+
-- @param radius Optional. The radius of the circle. Default is 10.
|
|
32
|
+
function ____exports.movePlayersToCenter(self, radius)
|
|
33
|
+
if radius == nil then
|
|
34
|
+
radius = 10
|
|
35
|
+
end
|
|
32
36
|
local isGreedMode = game:IsGreedMode()
|
|
33
37
|
local startingPosition = isGreedMode and NEW_FLOOR_STARTING_POSITION_GREED_MODE or NEW_FLOOR_STARTING_POSITION_NORMAL_MODE
|
|
34
38
|
local players = getAllPlayers(nil)
|
|
@@ -43,7 +47,7 @@ function ____exports.movePlayersToCenter(self)
|
|
|
43
47
|
local circlePoints = getCircleDiscretizedPoints(
|
|
44
48
|
nil,
|
|
45
49
|
startingPosition,
|
|
46
|
-
|
|
50
|
+
radius,
|
|
47
51
|
#players,
|
|
48
52
|
1,
|
|
49
53
|
1,
|
package/package.json
CHANGED
|
@@ -74,29 +74,34 @@ export class ModFeature {
|
|
|
74
74
|
private mod: ModUpgradedBase;
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
|
-
* An optional
|
|
77
|
+
* An optional method that allows for conditional callback execution. If specified, any class
|
|
78
78
|
* method that is annotated with a `@Callback` or `@CallbackCustom` decorator will only be fired
|
|
79
79
|
* if the executed conditional function returns true.
|
|
80
80
|
*
|
|
81
81
|
* This property is used to easily turn entire mod features on and off (rather than repeating
|
|
82
82
|
* conditional logic and early returning at the beginning of every callback function).
|
|
83
83
|
*
|
|
84
|
-
*
|
|
84
|
+
* Since the specific information for the firing callback is passed as arguments into the
|
|
85
|
+
* conditional method, you can also write logic that would only apply to a specific type of
|
|
86
|
+
* callback.
|
|
87
|
+
*
|
|
88
|
+
* By default, this is set to null, which means that all callback methods will fire
|
|
89
|
+
* unconditionally. Override this property in your class if you need to use it.
|
|
85
90
|
*
|
|
86
91
|
* The function has the following signature:
|
|
87
92
|
*
|
|
88
93
|
* ```ts
|
|
89
|
-
* (
|
|
90
|
-
* vanilla:
|
|
91
|
-
* modCallback: ModCallback
|
|
92
|
-
* ...callbackArgs: unknown[]
|
|
94
|
+
* <T extends boolean>(
|
|
95
|
+
* vanilla: T, // Whether or not this is a vanilla or custom callback.
|
|
96
|
+
* modCallback: T extends true ? ModCallback : ModCallbackCustom,
|
|
97
|
+
* ...callbackArgs: unknown[] // This would be e.g. `pickup: EntityPickup` for the `POST_PICKUP_INIT` callback.
|
|
93
98
|
* ) => boolean;
|
|
94
99
|
* ```
|
|
95
100
|
*/
|
|
96
|
-
protected
|
|
97
|
-
| ((
|
|
98
|
-
vanilla:
|
|
99
|
-
modCallback: ModCallback
|
|
101
|
+
protected shouldCallbackMethodsFire:
|
|
102
|
+
| (<T extends boolean>(
|
|
103
|
+
vanilla: T,
|
|
104
|
+
modCallback: T extends true ? ModCallback : ModCallbackCustom,
|
|
100
105
|
...callbackArgs: unknown[]
|
|
101
106
|
) => boolean)
|
|
102
107
|
| null = null;
|
|
@@ -250,7 +255,7 @@ function addCallback(
|
|
|
250
255
|
// first argument. (Otherwise, the method will not be able to properly access `this`.
|
|
251
256
|
const wrappedCallback = (...callbackArgs: unknown[]) => {
|
|
252
257
|
// eslint-disable-next-line @typescript-eslint/dot-notation
|
|
253
|
-
const conditionalFunc = modFeature["
|
|
258
|
+
const conditionalFunc = modFeature["shouldCallbackMethodsFire"];
|
|
254
259
|
if (conditionalFunc !== null) {
|
|
255
260
|
const shouldRun = conditionalFunc(vanilla, modCallback, ...callbackArgs);
|
|
256
261
|
if (!shouldRun) {
|
|
@@ -8,8 +8,6 @@ import { getPlayerFamiliars } from "./familiars";
|
|
|
8
8
|
import { getCircleDiscretizedPoints } from "./math";
|
|
9
9
|
import { getAllPlayers } from "./playerIndex";
|
|
10
10
|
|
|
11
|
-
const CIRCLE_RADIUS_BETWEEN_PLAYERS = 50;
|
|
12
|
-
|
|
13
11
|
/**
|
|
14
12
|
* Helper function to move all of the players to where they would normally go when arriving at a new
|
|
15
13
|
* floor. (In normal mode, this is the center of the room. In Greed Mode, this is below the top
|
|
@@ -18,8 +16,10 @@ const CIRCLE_RADIUS_BETWEEN_PLAYERS = 50;
|
|
|
18
16
|
* If there is more than one player, they will be distributed around the center in a circle.
|
|
19
17
|
*
|
|
20
18
|
* This function emulates what happens in the vanilla game when you travel to a new floor.
|
|
19
|
+
*
|
|
20
|
+
* @param radius Optional. The radius of the circle. Default is 10.
|
|
21
21
|
*/
|
|
22
|
-
export function movePlayersToCenter(): void {
|
|
22
|
+
export function movePlayersToCenter(radius: float = 10): void {
|
|
23
23
|
const isGreedMode = game.IsGreedMode();
|
|
24
24
|
const startingPosition = isGreedMode
|
|
25
25
|
? NEW_FLOOR_STARTING_POSITION_GREED_MODE
|
|
@@ -41,7 +41,7 @@ export function movePlayersToCenter(): void {
|
|
|
41
41
|
// (This is what happens in vanilla.)
|
|
42
42
|
const circlePoints = getCircleDiscretizedPoints(
|
|
43
43
|
startingPosition,
|
|
44
|
-
|
|
44
|
+
radius,
|
|
45
45
|
players.length,
|
|
46
46
|
1,
|
|
47
47
|
1,
|