isaacscript-common 30.11.9 → 30.12.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.
- package/dist/index.rollup.d.ts +110 -1
- package/dist/isaacscript-common.lua +59 -1
- package/dist/src/functions/npcDataStructures.d.ts +104 -0
- package/dist/src/functions/npcDataStructures.d.ts.map +1 -0
- package/dist/src/functions/npcDataStructures.lua +113 -0
- package/dist/src/functions/playerDataStructures.d.ts +1 -1
- package/dist/src/functions/playerDataStructures.d.ts.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.lua +8 -0
- package/package.json +2 -2
- package/src/functions/npcDataStructures.ts +154 -0
- package/src/functions/playerDataStructures.ts +3 -3
- package/src/index.ts +1 -0
package/dist/index.rollup.d.ts
CHANGED
|
@@ -3342,6 +3342,32 @@ export declare class DefaultMap<Key, Value, Args extends unknown[] = []> extends
|
|
|
3342
3342
|
*/
|
|
3343
3343
|
export declare function defaultMapGetHash<V, A extends unknown[]>(map: DefaultMap<PtrHash, V, A>, entity: Entity, ...extraArgs: A): V;
|
|
3344
3344
|
|
|
3345
|
+
/**
|
|
3346
|
+
* Helper function to make using default maps with an index of `PtrHash` easier. Use this instead of
|
|
3347
|
+
* the `DefaultMap.getAndSetDefault` method if you have a default map of this type.
|
|
3348
|
+
*
|
|
3349
|
+
* For example:
|
|
3350
|
+
*
|
|
3351
|
+
* ```ts
|
|
3352
|
+
* const v = {
|
|
3353
|
+
* run: {
|
|
3354
|
+
* npcsSpeedBoost: new DefaultMap<PtrHash, int>(0),
|
|
3355
|
+
* },
|
|
3356
|
+
* };
|
|
3357
|
+
*
|
|
3358
|
+
* function npcUpdate(npc: EntityNPC) {
|
|
3359
|
+
* const speedBoost = defaultMapGetNPC(v.run.npcsSpeedBoost, npc);
|
|
3360
|
+
* // Do something with the speed boost.
|
|
3361
|
+
* }
|
|
3362
|
+
* ```
|
|
3363
|
+
*
|
|
3364
|
+
* Note that not all NPCs should be stored in a map with a `PtrHash` as an index, so only use this
|
|
3365
|
+
* in the situations where that would be okay. (For example, Dark Esau should never be stored in a
|
|
3366
|
+
* map like this, because the scope of `PtrHash` is per room and Dark Esau is persistent between
|
|
3367
|
+
* rooms.)
|
|
3368
|
+
*/
|
|
3369
|
+
export declare function defaultMapGetNPC<V, Args extends unknown[]>(map: DefaultMap<PtrHash, V, Args>, npc: EntityNPC, ...extraArgs: Args): V;
|
|
3370
|
+
|
|
3345
3371
|
/**
|
|
3346
3372
|
* Helper function to make using default maps with an index of `PlayerIndex` easier. Use this
|
|
3347
3373
|
* instead of the `DefaultMap.getAndSetDefault` method if you have a default map of this type.
|
|
@@ -3360,7 +3386,7 @@ export declare function defaultMapGetHash<V, A extends unknown[]>(map: DefaultMa
|
|
|
3360
3386
|
* }
|
|
3361
3387
|
* ```
|
|
3362
3388
|
*/
|
|
3363
|
-
export declare function defaultMapGetPlayer<V,
|
|
3389
|
+
export declare function defaultMapGetPlayer<V, Args extends unknown[]>(map: DefaultMap<PlayerIndex, V, Args>, player: EntityPlayer, ...extraArgs: Args): V;
|
|
3364
3390
|
|
|
3365
3391
|
/**
|
|
3366
3392
|
* Helper function to set a value for a `DefaultMap` that corresponds to an entity, assuming that
|
|
@@ -3371,6 +3397,15 @@ export declare function defaultMapGetPlayer<V, A extends unknown[]>(map: Default
|
|
|
3371
3397
|
*/
|
|
3372
3398
|
export declare function defaultMapSetHash<V>(map: Map<PtrHash, V>, entity: Entity, value: V): void;
|
|
3373
3399
|
|
|
3400
|
+
/**
|
|
3401
|
+
* Helper function to make using maps with an index of `PtrHash` easier. Use this instead of the
|
|
3402
|
+
* `Map.set` method if you have a map of this type.
|
|
3403
|
+
*
|
|
3404
|
+
* Since `Map` and `DefaultMap` set values in the same way, this function is simply an alias for the
|
|
3405
|
+
* `mapSetNPC` helper function.
|
|
3406
|
+
*/
|
|
3407
|
+
export declare function defaultMapSetNPC<V>(map: Map<PtrHash, V>, npc: EntityNPC, value: V): void;
|
|
3408
|
+
|
|
3374
3409
|
/**
|
|
3375
3410
|
* Helper function to make using maps with an index of `PlayerIndex` easier. Use this instead of the
|
|
3376
3411
|
* `Map.set` method if you have a map of this type.
|
|
@@ -9298,12 +9333,40 @@ export declare type LowercaseKeys<T> = StartsWithLowercase<keyof T>;
|
|
|
9298
9333
|
*/
|
|
9299
9334
|
export declare function map<T, U>(array: T[], func: (value: T, index: number, array: T[]) => U): U[];
|
|
9300
9335
|
|
|
9336
|
+
/**
|
|
9337
|
+
* Helper function to make using maps with an type of `PtrHash` easier. Use this instead of the
|
|
9338
|
+
* `Map.delete` method if you have a set of this type.
|
|
9339
|
+
*/
|
|
9340
|
+
export declare function mapDeleteNPC(map: Map<PtrHash, unknown>, npc: EntityNPC): boolean;
|
|
9341
|
+
|
|
9301
9342
|
/**
|
|
9302
9343
|
* Helper function to make using maps with an type of `PlayerIndex` easier. Use this instead of the
|
|
9303
9344
|
* `Map.delete` method if you have a set of this type.
|
|
9304
9345
|
*/
|
|
9305
9346
|
export declare function mapDeletePlayer(map: Map<PlayerIndex, unknown>, player: EntityPlayer): boolean;
|
|
9306
9347
|
|
|
9348
|
+
/**
|
|
9349
|
+
* Helper function to make using maps with an index of `PtrHash` easier. Use this instead of the
|
|
9350
|
+
* `Map.get` method if you have a map of this type.
|
|
9351
|
+
*
|
|
9352
|
+
* For example:
|
|
9353
|
+
*
|
|
9354
|
+
* ```ts
|
|
9355
|
+
* const v = {
|
|
9356
|
+
* run: {
|
|
9357
|
+
* npcsSpeedBoost: new Map<PtrHash, int>(),
|
|
9358
|
+
* },
|
|
9359
|
+
* };
|
|
9360
|
+
*
|
|
9361
|
+
* function incrementSpeedBoost(npc: EntityNPC) {
|
|
9362
|
+
* const oldSpeedBoost = mapGetNPC(v.run.npcsSpeedBoost, npc);
|
|
9363
|
+
* const newSpeedBoost = oldSpeedBoost + 0.1;
|
|
9364
|
+
* mapSetNPC(v.run.npcsSpeedBoost, npc);
|
|
9365
|
+
* }
|
|
9366
|
+
* ```
|
|
9367
|
+
*/
|
|
9368
|
+
export declare function mapGetNPC<V>(map: Map<PtrHash, V>, npc: EntityNPC): V | undefined;
|
|
9369
|
+
|
|
9307
9370
|
/**
|
|
9308
9371
|
* Helper function to make using maps with an index of `PlayerIndex` easier. Use this instead of the
|
|
9309
9372
|
* `Map.get` method if you have a map of this type.
|
|
@@ -9326,6 +9389,12 @@ export declare function mapDeletePlayer(map: Map<PlayerIndex, unknown>, player:
|
|
|
9326
9389
|
*/
|
|
9327
9390
|
export declare function mapGetPlayer<V>(map: Map<PlayerIndex, V>, player: EntityPlayer): V | undefined;
|
|
9328
9391
|
|
|
9392
|
+
/**
|
|
9393
|
+
* Helper function to make using maps with an index of `PtrHash` easier. Use this instead of the
|
|
9394
|
+
* `Map.has` method if you have a map of this type.
|
|
9395
|
+
*/
|
|
9396
|
+
export declare function mapHasNPC<V>(map: Map<PtrHash, V>, npc: EntityNPC): boolean;
|
|
9397
|
+
|
|
9329
9398
|
/**
|
|
9330
9399
|
* Helper function to make using maps with an index of `PlayerIndex` easier. Use this instead of the
|
|
9331
9400
|
* `Map.has` method if you have a map of this type.
|
|
@@ -9351,6 +9420,28 @@ export declare const MAPPING_COLLECTIBLES: readonly [CollectibleType.COMPASS, Co
|
|
|
9351
9420
|
*/
|
|
9352
9421
|
export declare function mapSetHash<V>(map: Map<PtrHash, V>, entity: Entity, value: V): void;
|
|
9353
9422
|
|
|
9423
|
+
/**
|
|
9424
|
+
* Helper function to make using maps with an index of `PtrHash` easier. Use this instead of the
|
|
9425
|
+
* `Map.set` method if you have a map of this type.
|
|
9426
|
+
*
|
|
9427
|
+
* For example:
|
|
9428
|
+
*
|
|
9429
|
+
* ```ts
|
|
9430
|
+
* const v = {
|
|
9431
|
+
* run: {
|
|
9432
|
+
* npcsSpeedBoost: new Map<PtrHash, int>(),
|
|
9433
|
+
* },
|
|
9434
|
+
* };
|
|
9435
|
+
*
|
|
9436
|
+
* function incrementSpeedBoost(npc: EntityNPC) {
|
|
9437
|
+
* const oldSpeedBoost = mapGetNPC(v.run.npcsSpeedBoost, npc);
|
|
9438
|
+
* const newSpeedBoost = oldSpeedBoost + 0.1;
|
|
9439
|
+
* mapSetNPC(v.run.npcsSpeedBoost, npc);
|
|
9440
|
+
* }
|
|
9441
|
+
* ```
|
|
9442
|
+
*/
|
|
9443
|
+
export declare function mapSetNPC<V>(map: Map<PtrHash, V>, npc: EntityNPC, value: V): void;
|
|
9444
|
+
|
|
9354
9445
|
/**
|
|
9355
9446
|
* Helper function to make using maps with an index of `PlayerIndex` easier. Use this instead of the
|
|
9356
9447
|
* `Map.set` method if you have a map of this type.
|
|
@@ -15402,6 +15493,12 @@ export declare function setActiveItem(player: EntityPlayer, collectibleType: Col
|
|
|
15402
15493
|
*/
|
|
15403
15494
|
export declare function setAdd<T>(set: Set<T>, ...elements: T[]): void;
|
|
15404
15495
|
|
|
15496
|
+
/**
|
|
15497
|
+
* Helper function to make using sets with an type of `PtrHash` easier. Use this instead of the
|
|
15498
|
+
* `Set.add` method if you have a set of this type.
|
|
15499
|
+
*/
|
|
15500
|
+
export declare function setAddNPC(set: Set<PtrHash>, npc: EntityNPC): Set<PtrHash>;
|
|
15501
|
+
|
|
15405
15502
|
/**
|
|
15406
15503
|
* Helper function to make using sets with an type of `PlayerIndex` easier. Use this instead of the
|
|
15407
15504
|
* `Set.add` method if you have a set of this type.
|
|
@@ -15498,6 +15595,12 @@ export declare function setCollectiblesRerolledForItemTracker(): void;
|
|
|
15498
15595
|
*/
|
|
15499
15596
|
export declare function setCollectibleSubType(collectible: EntityPickup, newCollectibleType: CollectibleType): void;
|
|
15500
15597
|
|
|
15598
|
+
/**
|
|
15599
|
+
* Helper function to make using sets with an type of `PtrHash` easier. Use this instead of the
|
|
15600
|
+
* `Set.delete` method if you have a set of this type.
|
|
15601
|
+
*/
|
|
15602
|
+
export declare function setDeleteNPC(set: Set<PtrHash>, npc: EntityNPC): boolean;
|
|
15603
|
+
|
|
15501
15604
|
/**
|
|
15502
15605
|
* Helper function to make using sets with an type of `PlayerIndex` easier. Use this instead of the
|
|
15503
15606
|
* `Set.delete` method if you have a set of this type.
|
|
@@ -15582,6 +15685,12 @@ export declare function setGridEntityInvisible(gridEntity: GridEntity): void;
|
|
|
15582
15685
|
*/
|
|
15583
15686
|
export declare function setHas<T>(set: Set<T> | ReadonlySet<T>, ...elements: T[]): boolean;
|
|
15584
15687
|
|
|
15688
|
+
/**
|
|
15689
|
+
* Helper function to make using sets with an type of `PtrHash` easier. Use this instead of the
|
|
15690
|
+
* `Set.has` method if you have a set of this type.
|
|
15691
|
+
*/
|
|
15692
|
+
export declare function setHasNPC(set: Set<PtrHash>, npc: EntityNPC): boolean;
|
|
15693
|
+
|
|
15585
15694
|
/**
|
|
15586
15695
|
* Helper function to make using sets with an type of `PlayerIndex` easier. Use this instead of the
|
|
15587
15696
|
* `Set.has` method if you have a set of this type.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
--[[
|
|
2
2
|
|
|
3
|
-
isaacscript-common 30.
|
|
3
|
+
isaacscript-common 30.12.1
|
|
4
4
|
|
|
5
5
|
This is the "isaacscript-common" library, which was created with the IsaacScript tool.
|
|
6
6
|
|
|
@@ -53460,6 +53460,48 @@ function ____exports.initModFeatures(self, mod, modFeatures)
|
|
|
53460
53460
|
end
|
|
53461
53461
|
return instantiatedModFeatures
|
|
53462
53462
|
end
|
|
53463
|
+
return ____exports
|
|
53464
|
+
end,
|
|
53465
|
+
["src.functions.npcDataStructures"] = function(...)
|
|
53466
|
+
local ____lualib = require("lualib_bundle")
|
|
53467
|
+
local Map = ____lualib.Map
|
|
53468
|
+
local Set = ____lualib.Set
|
|
53469
|
+
local ____exports = {}
|
|
53470
|
+
function ____exports.mapSetNPC(self, map, npc, value)
|
|
53471
|
+
local ptrHash = GetPtrHash(npc)
|
|
53472
|
+
map:set(ptrHash, value)
|
|
53473
|
+
end
|
|
53474
|
+
function ____exports.defaultMapGetNPC(self, map, npc, ...)
|
|
53475
|
+
local ptrHash = GetPtrHash(npc)
|
|
53476
|
+
return map:getAndSetDefault(ptrHash, ...)
|
|
53477
|
+
end
|
|
53478
|
+
function ____exports.defaultMapSetNPC(self, map, npc, value)
|
|
53479
|
+
____exports.mapSetNPC(nil, map, npc, value)
|
|
53480
|
+
end
|
|
53481
|
+
function ____exports.mapDeleteNPC(self, map, npc)
|
|
53482
|
+
local ptrHash = GetPtrHash(npc)
|
|
53483
|
+
return map:delete(ptrHash)
|
|
53484
|
+
end
|
|
53485
|
+
function ____exports.mapGetNPC(self, map, npc)
|
|
53486
|
+
local ptrHash = GetPtrHash(npc)
|
|
53487
|
+
return map:get(ptrHash)
|
|
53488
|
+
end
|
|
53489
|
+
function ____exports.mapHasNPC(self, map, npc)
|
|
53490
|
+
local ptrHash = GetPtrHash(npc)
|
|
53491
|
+
return map:has(ptrHash)
|
|
53492
|
+
end
|
|
53493
|
+
function ____exports.setAddNPC(self, set, npc)
|
|
53494
|
+
local ptrHash = GetPtrHash(npc)
|
|
53495
|
+
return set:add(ptrHash)
|
|
53496
|
+
end
|
|
53497
|
+
function ____exports.setDeleteNPC(self, set, npc)
|
|
53498
|
+
local ptrHash = GetPtrHash(npc)
|
|
53499
|
+
return set:delete(ptrHash)
|
|
53500
|
+
end
|
|
53501
|
+
function ____exports.setHasNPC(self, set, npc)
|
|
53502
|
+
local ptrHash = GetPtrHash(npc)
|
|
53503
|
+
return set:has(ptrHash)
|
|
53504
|
+
end
|
|
53463
53505
|
return ____exports
|
|
53464
53506
|
end,
|
|
53465
53507
|
["src.functions.pressurePlate"] = function(...)
|
|
@@ -54374,6 +54416,14 @@ do
|
|
|
54374
54416
|
end
|
|
54375
54417
|
end
|
|
54376
54418
|
end
|
|
54419
|
+
do
|
|
54420
|
+
local ____export = require("src.functions.npcDataStructures")
|
|
54421
|
+
for ____exportKey, ____exportValue in pairs(____export) do
|
|
54422
|
+
if ____exportKey ~= "default" then
|
|
54423
|
+
____exports[____exportKey] = ____exportValue
|
|
54424
|
+
end
|
|
54425
|
+
end
|
|
54426
|
+
end
|
|
54377
54427
|
do
|
|
54378
54428
|
local ____export = require("src.functions.npcs")
|
|
54379
54429
|
for ____exportKey, ____exportValue in pairs(____export) do
|
|
@@ -55482,6 +55532,14 @@ do
|
|
|
55482
55532
|
end
|
|
55483
55533
|
end
|
|
55484
55534
|
end
|
|
55535
|
+
do
|
|
55536
|
+
local ____export = require("src.functions.npcDataStructures")
|
|
55537
|
+
for ____exportKey, ____exportValue in pairs(____export) do
|
|
55538
|
+
if ____exportKey ~= "default" then
|
|
55539
|
+
____exports[____exportKey] = ____exportValue
|
|
55540
|
+
end
|
|
55541
|
+
end
|
|
55542
|
+
end
|
|
55485
55543
|
do
|
|
55486
55544
|
local ____export = require("src.functions.npcs")
|
|
55487
55545
|
for ____exportKey, ____exportValue in pairs(____export) do
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
2
|
+
/// <reference types="isaac-typescript-definitions" />
|
|
3
|
+
import { DefaultMap } from "../classes/DefaultMap";
|
|
4
|
+
/**
|
|
5
|
+
* Helper function to make using default maps with an index of `PtrHash` easier. Use this instead of
|
|
6
|
+
* the `DefaultMap.getAndSetDefault` method if you have a default map of this type.
|
|
7
|
+
*
|
|
8
|
+
* For example:
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* const v = {
|
|
12
|
+
* run: {
|
|
13
|
+
* npcsSpeedBoost: new DefaultMap<PtrHash, int>(0),
|
|
14
|
+
* },
|
|
15
|
+
* };
|
|
16
|
+
*
|
|
17
|
+
* function npcUpdate(npc: EntityNPC) {
|
|
18
|
+
* const speedBoost = defaultMapGetNPC(v.run.npcsSpeedBoost, npc);
|
|
19
|
+
* // Do something with the speed boost.
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* Note that not all NPCs should be stored in a map with a `PtrHash` as an index, so only use this
|
|
24
|
+
* in the situations where that would be okay. (For example, Dark Esau should never be stored in a
|
|
25
|
+
* map like this, because the scope of `PtrHash` is per room and Dark Esau is persistent between
|
|
26
|
+
* rooms.)
|
|
27
|
+
*/
|
|
28
|
+
export declare function defaultMapGetNPC<V, Args extends unknown[]>(map: DefaultMap<PtrHash, V, Args>, npc: EntityNPC, ...extraArgs: Args): V;
|
|
29
|
+
/**
|
|
30
|
+
* Helper function to make using maps with an index of `PtrHash` easier. Use this instead of the
|
|
31
|
+
* `Map.set` method if you have a map of this type.
|
|
32
|
+
*
|
|
33
|
+
* Since `Map` and `DefaultMap` set values in the same way, this function is simply an alias for the
|
|
34
|
+
* `mapSetNPC` helper function.
|
|
35
|
+
*/
|
|
36
|
+
export declare function defaultMapSetNPC<V>(map: Map<PtrHash, V>, npc: EntityNPC, value: V): void;
|
|
37
|
+
/**
|
|
38
|
+
* Helper function to make using maps with an type of `PtrHash` easier. Use this instead of the
|
|
39
|
+
* `Map.delete` method if you have a set of this type.
|
|
40
|
+
*/
|
|
41
|
+
export declare function mapDeleteNPC(map: Map<PtrHash, unknown>, npc: EntityNPC): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Helper function to make using maps with an index of `PtrHash` easier. Use this instead of the
|
|
44
|
+
* `Map.get` method if you have a map of this type.
|
|
45
|
+
*
|
|
46
|
+
* For example:
|
|
47
|
+
*
|
|
48
|
+
* ```ts
|
|
49
|
+
* const v = {
|
|
50
|
+
* run: {
|
|
51
|
+
* npcsSpeedBoost: new Map<PtrHash, int>(),
|
|
52
|
+
* },
|
|
53
|
+
* };
|
|
54
|
+
*
|
|
55
|
+
* function incrementSpeedBoost(npc: EntityNPC) {
|
|
56
|
+
* const oldSpeedBoost = mapGetNPC(v.run.npcsSpeedBoost, npc);
|
|
57
|
+
* const newSpeedBoost = oldSpeedBoost + 0.1;
|
|
58
|
+
* mapSetNPC(v.run.npcsSpeedBoost, npc);
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export declare function mapGetNPC<V>(map: Map<PtrHash, V>, npc: EntityNPC): V | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Helper function to make using maps with an index of `PtrHash` easier. Use this instead of the
|
|
65
|
+
* `Map.has` method if you have a map of this type.
|
|
66
|
+
*/
|
|
67
|
+
export declare function mapHasNPC<V>(map: Map<PtrHash, V>, npc: EntityNPC): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Helper function to make using maps with an index of `PtrHash` easier. Use this instead of the
|
|
70
|
+
* `Map.set` method if you have a map of this type.
|
|
71
|
+
*
|
|
72
|
+
* For example:
|
|
73
|
+
*
|
|
74
|
+
* ```ts
|
|
75
|
+
* const v = {
|
|
76
|
+
* run: {
|
|
77
|
+
* npcsSpeedBoost: new Map<PtrHash, int>(),
|
|
78
|
+
* },
|
|
79
|
+
* };
|
|
80
|
+
*
|
|
81
|
+
* function incrementSpeedBoost(npc: EntityNPC) {
|
|
82
|
+
* const oldSpeedBoost = mapGetNPC(v.run.npcsSpeedBoost, npc);
|
|
83
|
+
* const newSpeedBoost = oldSpeedBoost + 0.1;
|
|
84
|
+
* mapSetNPC(v.run.npcsSpeedBoost, npc);
|
|
85
|
+
* }
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
export declare function mapSetNPC<V>(map: Map<PtrHash, V>, npc: EntityNPC, value: V): void;
|
|
89
|
+
/**
|
|
90
|
+
* Helper function to make using sets with an type of `PtrHash` easier. Use this instead of the
|
|
91
|
+
* `Set.add` method if you have a set of this type.
|
|
92
|
+
*/
|
|
93
|
+
export declare function setAddNPC(set: Set<PtrHash>, npc: EntityNPC): Set<PtrHash>;
|
|
94
|
+
/**
|
|
95
|
+
* Helper function to make using sets with an type of `PtrHash` easier. Use this instead of the
|
|
96
|
+
* `Set.delete` method if you have a set of this type.
|
|
97
|
+
*/
|
|
98
|
+
export declare function setDeleteNPC(set: Set<PtrHash>, npc: EntityNPC): boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Helper function to make using sets with an type of `PtrHash` easier. Use this instead of the
|
|
101
|
+
* `Set.has` method if you have a set of this type.
|
|
102
|
+
*/
|
|
103
|
+
export declare function setHasNPC(set: Set<PtrHash>, npc: EntityNPC): boolean;
|
|
104
|
+
//# sourceMappingURL=npcDataStructures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"npcDataStructures.d.ts","sourceRoot":"","sources":["../../../src/functions/npcDataStructures.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,IAAI,SAAS,OAAO,EAAE,EACxD,GAAG,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,EAAE,IAAI,CAAC,EACjC,GAAG,EAAE,SAAS,EACd,GAAG,SAAS,EAAE,IAAI,GACjB,CAAC,CAGH;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAChC,GAAG,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,EACpB,GAAG,EAAE,SAAS,EACd,KAAK,EAAE,CAAC,GACP,IAAI,CAEN;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,EAC1B,GAAG,EAAE,SAAS,GACb,OAAO,CAGT;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,SAAS,CAAC,CAAC,EACzB,GAAG,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,EACpB,GAAG,EAAE,SAAS,GACb,CAAC,GAAG,SAAS,CAGf;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,SAAS,GAAG,OAAO,CAG1E;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,SAAS,CAAC,CAAC,EACzB,GAAG,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,EACpB,GAAG,EAAE,SAAS,EACd,KAAK,EAAE,CAAC,GACP,IAAI,CAGN;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC,CAGzE;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,SAAS,GAAG,OAAO,CAGvE;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,SAAS,GAAG,OAAO,CAGpE"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local Map = ____lualib.Map
|
|
3
|
+
local Set = ____lualib.Set
|
|
4
|
+
local ____exports = {}
|
|
5
|
+
--- Helper function to make using maps with an index of `PtrHash` easier. Use this instead of the
|
|
6
|
+
-- `Map.set` method if you have a map of this type.
|
|
7
|
+
--
|
|
8
|
+
-- For example:
|
|
9
|
+
--
|
|
10
|
+
-- ```ts
|
|
11
|
+
-- const v = {
|
|
12
|
+
-- run: {
|
|
13
|
+
-- npcsSpeedBoost: new Map<PtrHash, int>(),
|
|
14
|
+
-- },
|
|
15
|
+
-- };
|
|
16
|
+
--
|
|
17
|
+
-- function incrementSpeedBoost(npc: EntityNPC) {
|
|
18
|
+
-- const oldSpeedBoost = mapGetNPC(v.run.npcsSpeedBoost, npc);
|
|
19
|
+
-- const newSpeedBoost = oldSpeedBoost + 0.1;
|
|
20
|
+
-- mapSetNPC(v.run.npcsSpeedBoost, npc);
|
|
21
|
+
-- }
|
|
22
|
+
-- ```
|
|
23
|
+
function ____exports.mapSetNPC(self, map, npc, value)
|
|
24
|
+
local ptrHash = GetPtrHash(npc)
|
|
25
|
+
map:set(ptrHash, value)
|
|
26
|
+
end
|
|
27
|
+
--- Helper function to make using default maps with an index of `PtrHash` easier. Use this instead of
|
|
28
|
+
-- the `DefaultMap.getAndSetDefault` method if you have a default map of this type.
|
|
29
|
+
--
|
|
30
|
+
-- For example:
|
|
31
|
+
--
|
|
32
|
+
-- ```ts
|
|
33
|
+
-- const v = {
|
|
34
|
+
-- run: {
|
|
35
|
+
-- npcsSpeedBoost: new DefaultMap<PtrHash, int>(0),
|
|
36
|
+
-- },
|
|
37
|
+
-- };
|
|
38
|
+
--
|
|
39
|
+
-- function npcUpdate(npc: EntityNPC) {
|
|
40
|
+
-- const speedBoost = defaultMapGetNPC(v.run.npcsSpeedBoost, npc);
|
|
41
|
+
-- // Do something with the speed boost.
|
|
42
|
+
-- }
|
|
43
|
+
-- ```
|
|
44
|
+
--
|
|
45
|
+
-- Note that not all NPCs should be stored in a map with a `PtrHash` as an index, so only use this
|
|
46
|
+
-- in the situations where that would be okay. (For example, Dark Esau should never be stored in a
|
|
47
|
+
-- map like this, because the scope of `PtrHash` is per room and Dark Esau is persistent between
|
|
48
|
+
-- rooms.)
|
|
49
|
+
function ____exports.defaultMapGetNPC(self, map, npc, ...)
|
|
50
|
+
local ptrHash = GetPtrHash(npc)
|
|
51
|
+
return map:getAndSetDefault(ptrHash, ...)
|
|
52
|
+
end
|
|
53
|
+
--- Helper function to make using maps with an index of `PtrHash` easier. Use this instead of the
|
|
54
|
+
-- `Map.set` method if you have a map of this type.
|
|
55
|
+
--
|
|
56
|
+
-- Since `Map` and `DefaultMap` set values in the same way, this function is simply an alias for the
|
|
57
|
+
-- `mapSetNPC` helper function.
|
|
58
|
+
function ____exports.defaultMapSetNPC(self, map, npc, value)
|
|
59
|
+
____exports.mapSetNPC(nil, map, npc, value)
|
|
60
|
+
end
|
|
61
|
+
--- Helper function to make using maps with an type of `PtrHash` easier. Use this instead of the
|
|
62
|
+
-- `Map.delete` method if you have a set of this type.
|
|
63
|
+
function ____exports.mapDeleteNPC(self, map, npc)
|
|
64
|
+
local ptrHash = GetPtrHash(npc)
|
|
65
|
+
return map:delete(ptrHash)
|
|
66
|
+
end
|
|
67
|
+
--- Helper function to make using maps with an index of `PtrHash` easier. Use this instead of the
|
|
68
|
+
-- `Map.get` method if you have a map of this type.
|
|
69
|
+
--
|
|
70
|
+
-- For example:
|
|
71
|
+
--
|
|
72
|
+
-- ```ts
|
|
73
|
+
-- const v = {
|
|
74
|
+
-- run: {
|
|
75
|
+
-- npcsSpeedBoost: new Map<PtrHash, int>(),
|
|
76
|
+
-- },
|
|
77
|
+
-- };
|
|
78
|
+
--
|
|
79
|
+
-- function incrementSpeedBoost(npc: EntityNPC) {
|
|
80
|
+
-- const oldSpeedBoost = mapGetNPC(v.run.npcsSpeedBoost, npc);
|
|
81
|
+
-- const newSpeedBoost = oldSpeedBoost + 0.1;
|
|
82
|
+
-- mapSetNPC(v.run.npcsSpeedBoost, npc);
|
|
83
|
+
-- }
|
|
84
|
+
-- ```
|
|
85
|
+
function ____exports.mapGetNPC(self, map, npc)
|
|
86
|
+
local ptrHash = GetPtrHash(npc)
|
|
87
|
+
return map:get(ptrHash)
|
|
88
|
+
end
|
|
89
|
+
--- Helper function to make using maps with an index of `PtrHash` easier. Use this instead of the
|
|
90
|
+
-- `Map.has` method if you have a map of this type.
|
|
91
|
+
function ____exports.mapHasNPC(self, map, npc)
|
|
92
|
+
local ptrHash = GetPtrHash(npc)
|
|
93
|
+
return map:has(ptrHash)
|
|
94
|
+
end
|
|
95
|
+
--- Helper function to make using sets with an type of `PtrHash` easier. Use this instead of the
|
|
96
|
+
-- `Set.add` method if you have a set of this type.
|
|
97
|
+
function ____exports.setAddNPC(self, set, npc)
|
|
98
|
+
local ptrHash = GetPtrHash(npc)
|
|
99
|
+
return set:add(ptrHash)
|
|
100
|
+
end
|
|
101
|
+
--- Helper function to make using sets with an type of `PtrHash` easier. Use this instead of the
|
|
102
|
+
-- `Set.delete` method if you have a set of this type.
|
|
103
|
+
function ____exports.setDeleteNPC(self, set, npc)
|
|
104
|
+
local ptrHash = GetPtrHash(npc)
|
|
105
|
+
return set:delete(ptrHash)
|
|
106
|
+
end
|
|
107
|
+
--- Helper function to make using sets with an type of `PtrHash` easier. Use this instead of the
|
|
108
|
+
-- `Set.has` method if you have a set of this type.
|
|
109
|
+
function ____exports.setHasNPC(self, set, npc)
|
|
110
|
+
local ptrHash = GetPtrHash(npc)
|
|
111
|
+
return set:has(ptrHash)
|
|
112
|
+
end
|
|
113
|
+
return ____exports
|
|
@@ -19,7 +19,7 @@ import { PlayerIndex } from "../types/PlayerIndex";
|
|
|
19
19
|
* }
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
|
-
export declare function defaultMapGetPlayer<V,
|
|
22
|
+
export declare function defaultMapGetPlayer<V, Args extends unknown[]>(map: DefaultMap<PlayerIndex, V, Args>, player: EntityPlayer, ...extraArgs: Args): V;
|
|
23
23
|
/**
|
|
24
24
|
* Helper function to make using maps with an index of `PlayerIndex` easier. Use this instead of the
|
|
25
25
|
* `Map.set` method if you have a map of this type.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playerDataStructures.d.ts","sourceRoot":"","sources":["../../../src/functions/playerDataStructures.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGnD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"playerDataStructures.d.ts","sourceRoot":"","sources":["../../../src/functions/playerDataStructures.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGnD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,mBAA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AAO,CAGT;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,GAAG,CAAC,WAAW,CAAC,EACrB,MAAM,EAAE,YAAY,GACnB,OAAO,CAGT"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -77,6 +77,7 @@ export * from "./functions/mergeTests";
|
|
|
77
77
|
export * from "./functions/minimap";
|
|
78
78
|
export * from "./functions/modFeatures";
|
|
79
79
|
export * from "./functions/nextStage";
|
|
80
|
+
export * from "./functions/npcDataStructures";
|
|
80
81
|
export * from "./functions/npcs";
|
|
81
82
|
export * from "./functions/pickupVariants";
|
|
82
83
|
export * from "./functions/pickups";
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAA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mB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,yCAAyC,CAAC;AACxD,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC"}
|
package/dist/src/index.lua
CHANGED
|
@@ -631,6 +631,14 @@ do
|
|
|
631
631
|
end
|
|
632
632
|
end
|
|
633
633
|
end
|
|
634
|
+
do
|
|
635
|
+
local ____export = require("src.functions.npcDataStructures")
|
|
636
|
+
for ____exportKey, ____exportValue in pairs(____export) do
|
|
637
|
+
if ____exportKey ~= "default" then
|
|
638
|
+
____exports[____exportKey] = ____exportValue
|
|
639
|
+
end
|
|
640
|
+
end
|
|
641
|
+
end
|
|
634
642
|
do
|
|
635
643
|
local ____export = require("src.functions.npcs")
|
|
636
644
|
for ____exportKey, ____exportValue in pairs(____export) do
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isaacscript-common",
|
|
3
|
-
"version": "30.
|
|
3
|
+
"version": "30.12.1",
|
|
4
4
|
"description": "Helper functions and features for IsaacScript mods.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"isaac",
|
|
@@ -25,6 +25,6 @@
|
|
|
25
25
|
"main": "dist/src/index",
|
|
26
26
|
"types": "dist/index.rollup.d.ts",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"isaac-typescript-definitions": "^13.0.
|
|
28
|
+
"isaac-typescript-definitions": "^13.0.15"
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { DefaultMap } from "../classes/DefaultMap";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Helper function to make using default maps with an index of `PtrHash` easier. Use this instead of
|
|
5
|
+
* the `DefaultMap.getAndSetDefault` method if you have a default map of this type.
|
|
6
|
+
*
|
|
7
|
+
* For example:
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* const v = {
|
|
11
|
+
* run: {
|
|
12
|
+
* npcsSpeedBoost: new DefaultMap<PtrHash, int>(0),
|
|
13
|
+
* },
|
|
14
|
+
* };
|
|
15
|
+
*
|
|
16
|
+
* function npcUpdate(npc: EntityNPC) {
|
|
17
|
+
* const speedBoost = defaultMapGetNPC(v.run.npcsSpeedBoost, npc);
|
|
18
|
+
* // Do something with the speed boost.
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* Note that not all NPCs should be stored in a map with a `PtrHash` as an index, so only use this
|
|
23
|
+
* in the situations where that would be okay. (For example, Dark Esau should never be stored in a
|
|
24
|
+
* map like this, because the scope of `PtrHash` is per room and Dark Esau is persistent between
|
|
25
|
+
* rooms.)
|
|
26
|
+
*/
|
|
27
|
+
export function defaultMapGetNPC<V, Args extends unknown[]>(
|
|
28
|
+
map: DefaultMap<PtrHash, V, Args>,
|
|
29
|
+
npc: EntityNPC,
|
|
30
|
+
...extraArgs: Args
|
|
31
|
+
): V {
|
|
32
|
+
const ptrHash = GetPtrHash(npc);
|
|
33
|
+
return map.getAndSetDefault(ptrHash, ...extraArgs);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Helper function to make using maps with an index of `PtrHash` easier. Use this instead of the
|
|
38
|
+
* `Map.set` method if you have a map of this type.
|
|
39
|
+
*
|
|
40
|
+
* Since `Map` and `DefaultMap` set values in the same way, this function is simply an alias for the
|
|
41
|
+
* `mapSetNPC` helper function.
|
|
42
|
+
*/
|
|
43
|
+
export function defaultMapSetNPC<V>(
|
|
44
|
+
map: Map<PtrHash, V>,
|
|
45
|
+
npc: EntityNPC,
|
|
46
|
+
value: V,
|
|
47
|
+
): void {
|
|
48
|
+
mapSetNPC(map, npc, value);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Helper function to make using maps with an type of `PtrHash` easier. Use this instead of the
|
|
53
|
+
* `Map.delete` method if you have a set of this type.
|
|
54
|
+
*/
|
|
55
|
+
export function mapDeleteNPC(
|
|
56
|
+
map: Map<PtrHash, unknown>,
|
|
57
|
+
npc: EntityNPC,
|
|
58
|
+
): boolean {
|
|
59
|
+
const ptrHash = GetPtrHash(npc);
|
|
60
|
+
return map.delete(ptrHash);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Helper function to make using maps with an index of `PtrHash` easier. Use this instead of the
|
|
65
|
+
* `Map.get` method if you have a map of this type.
|
|
66
|
+
*
|
|
67
|
+
* For example:
|
|
68
|
+
*
|
|
69
|
+
* ```ts
|
|
70
|
+
* const v = {
|
|
71
|
+
* run: {
|
|
72
|
+
* npcsSpeedBoost: new Map<PtrHash, int>(),
|
|
73
|
+
* },
|
|
74
|
+
* };
|
|
75
|
+
*
|
|
76
|
+
* function incrementSpeedBoost(npc: EntityNPC) {
|
|
77
|
+
* const oldSpeedBoost = mapGetNPC(v.run.npcsSpeedBoost, npc);
|
|
78
|
+
* const newSpeedBoost = oldSpeedBoost + 0.1;
|
|
79
|
+
* mapSetNPC(v.run.npcsSpeedBoost, npc);
|
|
80
|
+
* }
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export function mapGetNPC<V>(
|
|
84
|
+
map: Map<PtrHash, V>,
|
|
85
|
+
npc: EntityNPC,
|
|
86
|
+
): V | undefined {
|
|
87
|
+
const ptrHash = GetPtrHash(npc);
|
|
88
|
+
return map.get(ptrHash);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Helper function to make using maps with an index of `PtrHash` easier. Use this instead of the
|
|
93
|
+
* `Map.has` method if you have a map of this type.
|
|
94
|
+
*/
|
|
95
|
+
export function mapHasNPC<V>(map: Map<PtrHash, V>, npc: EntityNPC): boolean {
|
|
96
|
+
const ptrHash = GetPtrHash(npc);
|
|
97
|
+
return map.has(ptrHash);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Helper function to make using maps with an index of `PtrHash` easier. Use this instead of the
|
|
102
|
+
* `Map.set` method if you have a map of this type.
|
|
103
|
+
*
|
|
104
|
+
* For example:
|
|
105
|
+
*
|
|
106
|
+
* ```ts
|
|
107
|
+
* const v = {
|
|
108
|
+
* run: {
|
|
109
|
+
* npcsSpeedBoost: new Map<PtrHash, int>(),
|
|
110
|
+
* },
|
|
111
|
+
* };
|
|
112
|
+
*
|
|
113
|
+
* function incrementSpeedBoost(npc: EntityNPC) {
|
|
114
|
+
* const oldSpeedBoost = mapGetNPC(v.run.npcsSpeedBoost, npc);
|
|
115
|
+
* const newSpeedBoost = oldSpeedBoost + 0.1;
|
|
116
|
+
* mapSetNPC(v.run.npcsSpeedBoost, npc);
|
|
117
|
+
* }
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
export function mapSetNPC<V>(
|
|
121
|
+
map: Map<PtrHash, V>,
|
|
122
|
+
npc: EntityNPC,
|
|
123
|
+
value: V,
|
|
124
|
+
): void {
|
|
125
|
+
const ptrHash = GetPtrHash(npc);
|
|
126
|
+
map.set(ptrHash, value);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Helper function to make using sets with an type of `PtrHash` easier. Use this instead of the
|
|
131
|
+
* `Set.add` method if you have a set of this type.
|
|
132
|
+
*/
|
|
133
|
+
export function setAddNPC(set: Set<PtrHash>, npc: EntityNPC): Set<PtrHash> {
|
|
134
|
+
const ptrHash = GetPtrHash(npc);
|
|
135
|
+
return set.add(ptrHash);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Helper function to make using sets with an type of `PtrHash` easier. Use this instead of the
|
|
140
|
+
* `Set.delete` method if you have a set of this type.
|
|
141
|
+
*/
|
|
142
|
+
export function setDeleteNPC(set: Set<PtrHash>, npc: EntityNPC): boolean {
|
|
143
|
+
const ptrHash = GetPtrHash(npc);
|
|
144
|
+
return set.delete(ptrHash);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Helper function to make using sets with an type of `PtrHash` easier. Use this instead of the
|
|
149
|
+
* `Set.has` method if you have a set of this type.
|
|
150
|
+
*/
|
|
151
|
+
export function setHasNPC(set: Set<PtrHash>, npc: EntityNPC): boolean {
|
|
152
|
+
const ptrHash = GetPtrHash(npc);
|
|
153
|
+
return set.has(ptrHash);
|
|
154
|
+
}
|
|
@@ -20,10 +20,10 @@ import { getPlayerIndex } from "./playerIndex";
|
|
|
20
20
|
* }
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
|
-
export function defaultMapGetPlayer<V,
|
|
24
|
-
map: DefaultMap<PlayerIndex, V,
|
|
23
|
+
export function defaultMapGetPlayer<V, Args extends unknown[]>(
|
|
24
|
+
map: DefaultMap<PlayerIndex, V, Args>,
|
|
25
25
|
player: EntityPlayer,
|
|
26
|
-
...extraArgs:
|
|
26
|
+
...extraArgs: Args
|
|
27
27
|
): V {
|
|
28
28
|
const playerIndex = getPlayerIndex(player);
|
|
29
29
|
return map.getAndSetDefault(playerIndex, ...extraArgs);
|
package/src/index.ts
CHANGED
|
@@ -77,6 +77,7 @@ export * from "./functions/mergeTests";
|
|
|
77
77
|
export * from "./functions/minimap";
|
|
78
78
|
export * from "./functions/modFeatures";
|
|
79
79
|
export * from "./functions/nextStage";
|
|
80
|
+
export * from "./functions/npcDataStructures";
|
|
80
81
|
export * from "./functions/npcs";
|
|
81
82
|
export * from "./functions/pickupVariants";
|
|
82
83
|
export * from "./functions/pickups";
|