isaacscript-common 87.4.0 → 87.5.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/classes/features/callbackLogic/ItemPickupDetection.d.ts.map +1 -1
- package/dist/classes/features/callbackLogic/ItemPickupDetection.js +6 -2
- package/dist/classes/features/callbackLogic/ItemPickupDetection.lua +6 -1
- package/dist/enums/ModCallbackCustom.d.ts +5 -4
- package/dist/enums/ModCallbackCustom.d.ts.map +1 -1
- package/dist/enums/ModCallbackCustom.js +5 -4
- package/dist/functions/entities.d.ts +3 -3
- package/dist/functions/entities.d.ts.map +1 -1
- package/dist/functions/entities.js +5 -4
- package/dist/functions/entities.lua +4 -11
- package/dist/functions/gridEntities.d.ts.map +1 -1
- package/dist/functions/gridEntities.js +6 -0
- package/dist/functions/gridEntities.lua +9 -5
- package/dist/functions/players.d.ts +2 -0
- package/dist/functions/players.d.ts.map +1 -1
- package/dist/functions/players.js +2 -0
- package/dist/functions/players.lua +2 -0
- package/dist/index.lua +432 -0
- package/dist/index.rollup.d.ts +15 -10
- package/dist/indexLua.lua +432 -0
- package/dist/interfaces/private/AddCallbackParametersCustom.d.ts +5 -3
- package/dist/interfaces/private/AddCallbackParametersCustom.d.ts.map +1 -1
- package/dist/isaacscript-common.lua +948 -452
- package/dist/lualib_bundle.lua +58 -0
- package/dist/tsdoc-metadata.json +1 -1
- package/package.json +2 -2
- package/src/classes/features/callbackLogic/ItemPickupDetection.ts +6 -2
- package/src/enums/ModCallbackCustom.ts +5 -4
- package/src/functions/entities.ts +5 -11
- package/src/functions/gridEntities.ts +12 -0
- package/src/functions/players.ts +2 -0
- package/src/interfaces/private/AddCallbackParametersCustom.ts +8 -3
package/dist/lualib_bundle.lua
CHANGED
|
@@ -2027,6 +2027,64 @@ do
|
|
|
2027
2027
|
end
|
|
2028
2028
|
}
|
|
2029
2029
|
end
|
|
2030
|
+
function Set.prototype.union(self, other)
|
|
2031
|
+
local result = __TS__New(Set, self)
|
|
2032
|
+
for ____, item in __TS__Iterator(other) do
|
|
2033
|
+
result:add(item)
|
|
2034
|
+
end
|
|
2035
|
+
return result
|
|
2036
|
+
end
|
|
2037
|
+
function Set.prototype.intersection(self, other)
|
|
2038
|
+
local result = __TS__New(Set)
|
|
2039
|
+
for ____, item in __TS__Iterator(self) do
|
|
2040
|
+
if other:has(item) then
|
|
2041
|
+
result:add(item)
|
|
2042
|
+
end
|
|
2043
|
+
end
|
|
2044
|
+
return result
|
|
2045
|
+
end
|
|
2046
|
+
function Set.prototype.difference(self, other)
|
|
2047
|
+
local result = __TS__New(Set, self)
|
|
2048
|
+
for ____, item in __TS__Iterator(other) do
|
|
2049
|
+
result:delete(item)
|
|
2050
|
+
end
|
|
2051
|
+
return result
|
|
2052
|
+
end
|
|
2053
|
+
function Set.prototype.symmetricDifference(self, other)
|
|
2054
|
+
local result = __TS__New(Set, self)
|
|
2055
|
+
for ____, item in __TS__Iterator(other) do
|
|
2056
|
+
if self:has(item) then
|
|
2057
|
+
result:delete(item)
|
|
2058
|
+
else
|
|
2059
|
+
result:add(item)
|
|
2060
|
+
end
|
|
2061
|
+
end
|
|
2062
|
+
return result
|
|
2063
|
+
end
|
|
2064
|
+
function Set.prototype.isSubsetOf(self, other)
|
|
2065
|
+
for ____, item in __TS__Iterator(self) do
|
|
2066
|
+
if not other:has(item) then
|
|
2067
|
+
return false
|
|
2068
|
+
end
|
|
2069
|
+
end
|
|
2070
|
+
return true
|
|
2071
|
+
end
|
|
2072
|
+
function Set.prototype.isSupersetOf(self, other)
|
|
2073
|
+
for ____, item in __TS__Iterator(other) do
|
|
2074
|
+
if not self:has(item) then
|
|
2075
|
+
return false
|
|
2076
|
+
end
|
|
2077
|
+
end
|
|
2078
|
+
return true
|
|
2079
|
+
end
|
|
2080
|
+
function Set.prototype.isDisjointFrom(self, other)
|
|
2081
|
+
for ____, item in __TS__Iterator(self) do
|
|
2082
|
+
if other:has(item) then
|
|
2083
|
+
return false
|
|
2084
|
+
end
|
|
2085
|
+
end
|
|
2086
|
+
return true
|
|
2087
|
+
end
|
|
2030
2088
|
Set[Symbol.species] = Set
|
|
2031
2089
|
end
|
|
2032
2090
|
|
package/dist/tsdoc-metadata.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isaacscript-common",
|
|
3
|
-
"version": "87.
|
|
3
|
+
"version": "87.5.0",
|
|
4
4
|
"description": "Helper functions and features for IsaacScript mods.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"isaac",
|
|
@@ -37,6 +37,6 @@
|
|
|
37
37
|
"lint": "tsx --tsconfig ./scripts/tsconfig.json ./scripts/lint.mts"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"isaac-typescript-definitions": "^42.0
|
|
40
|
+
"isaac-typescript-definitions": "^42.2.0"
|
|
41
41
|
}
|
|
42
42
|
}
|
|
@@ -5,6 +5,7 @@ import type {
|
|
|
5
5
|
import { ItemType } from "isaac-typescript-definitions";
|
|
6
6
|
import { ModCallbackCustom } from "../../../enums/ModCallbackCustom";
|
|
7
7
|
import { defaultMapGetPlayer } from "../../../functions/playerDataStructures";
|
|
8
|
+
import { dequeueItem } from "../../../functions/players";
|
|
8
9
|
import { asNumber } from "../../../functions/types";
|
|
9
10
|
import type { PickingUpItem } from "../../../types/PickingUpItem";
|
|
10
11
|
import {
|
|
@@ -78,7 +79,7 @@ export class ItemPickupDetection extends Feature {
|
|
|
78
79
|
private queueNotEmpty(player: EntityPlayer, pickingUpItem: PickingUpItem) {
|
|
79
80
|
const queuedItem = player.QueuedItem.Item;
|
|
80
81
|
if (queuedItem === undefined || queuedItem.Type === ItemType.NULL) {
|
|
81
|
-
// This should never happen, since the `EntityPlayer.IsItemQueueEmpty` method returned
|
|
82
|
+
// This should never happen, since the `EntityPlayer.IsItemQueueEmpty` method returned false.
|
|
82
83
|
return;
|
|
83
84
|
}
|
|
84
85
|
|
|
@@ -90,7 +91,10 @@ export class ItemPickupDetection extends Feature {
|
|
|
90
91
|
pickingUpItem.itemType = queuedItem.Type;
|
|
91
92
|
pickingUpItem.subType = queuedItem.ID as CollectibleType | TrinketType;
|
|
92
93
|
|
|
93
|
-
this.preItemPickup.fire(player, pickingUpItem);
|
|
94
|
+
const shouldBeGranted = this.preItemPickup.fire(player, pickingUpItem);
|
|
95
|
+
if (shouldBeGranted === false) {
|
|
96
|
+
dequeueItem(player);
|
|
97
|
+
}
|
|
94
98
|
}
|
|
95
99
|
}
|
|
96
100
|
}
|
|
@@ -1648,8 +1648,8 @@ export enum ModCallbackCustom {
|
|
|
1648
1648
|
POST_PLAYER_COLLECTIBLE_REMOVED,
|
|
1649
1649
|
|
|
1650
1650
|
/**
|
|
1651
|
-
* Fires from the `ENTITY_TAKE_DMG` callback when a player takes fatal damage.
|
|
1652
|
-
* prevent the fatal damage.
|
|
1651
|
+
* Fires from the `ENTITY_TAKE_DMG` callback when a player takes fatal damage. You can optionally
|
|
1652
|
+
* return false to prevent the fatal damage.
|
|
1653
1653
|
*
|
|
1654
1654
|
* Note that this function does properly take into account Guppy's Collar, Broken Ankh, Spirit
|
|
1655
1655
|
* Shackles, and Mysterious Paper. It also takes into account using The Bible on Satan.
|
|
@@ -2450,7 +2450,8 @@ export enum ModCallbackCustom {
|
|
|
2450
2450
|
|
|
2451
2451
|
/**
|
|
2452
2452
|
* Fires from the `POST_PEFFECT_UPDATE_REORDERED` callback when an item becomes queued (i.e. when
|
|
2453
|
-
* the player begins to hold the item above their head).
|
|
2453
|
+
* the player begins to hold the item above their head). You can optionally return false if you
|
|
2454
|
+
* want the item to not be granted to the player.
|
|
2454
2455
|
*
|
|
2455
2456
|
* Note that this callback will only fire once per Forgotten/Soul pair.
|
|
2456
2457
|
*
|
|
@@ -2464,7 +2465,7 @@ export enum ModCallbackCustom {
|
|
|
2464
2465
|
* function preItemPickup(
|
|
2465
2466
|
* player: EntityPlayer,
|
|
2466
2467
|
* pickingUpItem: PickingUpItem,
|
|
2467
|
-
* ):
|
|
2468
|
+
* ): boolean | undefined {}
|
|
2468
2469
|
* ```
|
|
2469
2470
|
*/
|
|
2470
2471
|
PRE_ITEM_PICKUP,
|
|
@@ -640,8 +640,8 @@ export function setEntityRandomColor(entity: Entity): void {
|
|
|
640
640
|
}
|
|
641
641
|
|
|
642
642
|
/**
|
|
643
|
-
* Helper function to spawn an entity.
|
|
644
|
-
*
|
|
643
|
+
* Helper function to spawn an entity. Always use this instead of the `Isaac.Spawn` method, since
|
|
644
|
+
* using that method can crash the game.
|
|
645
645
|
*
|
|
646
646
|
* Also see the `spawnWithSeed` helper function.
|
|
647
647
|
*
|
|
@@ -653,7 +653,7 @@ export function setEntityRandomColor(entity: Entity): void {
|
|
|
653
653
|
* @param spawner Optional. The entity that will be the `SpawnerEntity`. Default is undefined.
|
|
654
654
|
* @param seedOrRNG Optional. The seed or RNG object to use to generate the `InitSeed` of the
|
|
655
655
|
* entity. Default is undefined, which will make the entity spawn with a random
|
|
656
|
-
* seed
|
|
656
|
+
* seed.
|
|
657
657
|
*/
|
|
658
658
|
export function spawn(
|
|
659
659
|
entityType: EntityType,
|
|
@@ -666,6 +666,7 @@ export function spawn(
|
|
|
666
666
|
): Entity {
|
|
667
667
|
const room = game.GetRoom();
|
|
668
668
|
|
|
669
|
+
// We do an explicit check to prevent run-time errors in Lua environments.
|
|
669
670
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
670
671
|
if (positionOrGridIndex === undefined) {
|
|
671
672
|
const entityID = getEntityIDFromConstituents(entityType, variant, subType);
|
|
@@ -679,14 +680,7 @@ export function spawn(
|
|
|
679
680
|
: room.GetGridPosition(positionOrGridIndex);
|
|
680
681
|
|
|
681
682
|
if (seedOrRNG === undefined) {
|
|
682
|
-
|
|
683
|
-
entityType,
|
|
684
|
-
variant,
|
|
685
|
-
subType,
|
|
686
|
-
position,
|
|
687
|
-
velocity,
|
|
688
|
-
spawner,
|
|
689
|
-
);
|
|
683
|
+
seedOrRNG = newRNG();
|
|
690
684
|
}
|
|
691
685
|
|
|
692
686
|
const seed = isRNG(seedOrRNG) ? seedOrRNG.Next() : seedOrRNG;
|
|
@@ -1219,6 +1219,18 @@ export function spawnGridEntityWithVariant(
|
|
|
1219
1219
|
): GridEntity | undefined {
|
|
1220
1220
|
const room = game.GetRoom();
|
|
1221
1221
|
|
|
1222
|
+
// We do an explicit check to prevent run-time errors in Lua environments.
|
|
1223
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
1224
|
+
if (gridIndexOrPosition === undefined) {
|
|
1225
|
+
const gridEntityID = getGridEntityIDFromConstituents(
|
|
1226
|
+
gridEntityType,
|
|
1227
|
+
variant,
|
|
1228
|
+
);
|
|
1229
|
+
error(
|
|
1230
|
+
`Failed to spawn grid entity ${gridEntityID} since an undefined position was passed to the "spawnGridEntityWithVariant" function.`,
|
|
1231
|
+
);
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1222
1234
|
const existingGridEntity = isVector(gridIndexOrPosition)
|
|
1223
1235
|
? room.GetGridEntityFromPos(gridIndexOrPosition)
|
|
1224
1236
|
: room.GetGridEntity(gridIndexOrPosition);
|
package/src/functions/players.ts
CHANGED
|
@@ -73,6 +73,8 @@ export function canPlayerCrushRocks(player: EntityPlayer): boolean {
|
|
|
73
73
|
*
|
|
74
74
|
* Under the hood, this clones the `QueuedItemData`, since directly setting the `Item` field to
|
|
75
75
|
* `undefined` does not work for some reason.
|
|
76
|
+
*
|
|
77
|
+
* This method was discovered by im_tem.
|
|
76
78
|
*/
|
|
77
79
|
export function dequeueItem(player: EntityPlayer): boolean {
|
|
78
80
|
if (player.QueuedItem.Item === undefined) {
|
|
@@ -975,12 +975,17 @@ export interface AddCallbackParametersCustom {
|
|
|
975
975
|
];
|
|
976
976
|
|
|
977
977
|
[ModCallbackCustom.PRE_ITEM_PICKUP]:
|
|
978
|
-
| [
|
|
978
|
+
| [
|
|
979
|
+
callback: (
|
|
980
|
+
player: EntityPlayer,
|
|
981
|
+
pickingUpItem: PickingUpItem,
|
|
982
|
+
) => boolean | undefined,
|
|
983
|
+
]
|
|
979
984
|
| [
|
|
980
985
|
callback: (
|
|
981
986
|
player: EntityPlayer,
|
|
982
987
|
pickingUpItem: PickingUpItemCollectible,
|
|
983
|
-
) =>
|
|
988
|
+
) => boolean | undefined,
|
|
984
989
|
itemType: ItemType.PASSIVE | ItemType.ACTIVE | ItemType.FAMILIAR,
|
|
985
990
|
collectibleType?: CollectibleType,
|
|
986
991
|
]
|
|
@@ -988,7 +993,7 @@ export interface AddCallbackParametersCustom {
|
|
|
988
993
|
callback: (
|
|
989
994
|
player: EntityPlayer,
|
|
990
995
|
pickingUpItem: PickingUpItemTrinket,
|
|
991
|
-
) =>
|
|
996
|
+
) => boolean | undefined,
|
|
992
997
|
itemType: ItemType.TRINKET,
|
|
993
998
|
trinketType?: TrinketType,
|
|
994
999
|
];
|