isaacscript-common 20.7.2 → 20.9.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 CHANGED
@@ -3299,6 +3299,19 @@ export declare function doesPlayerHaveAllBlackHearts(player: EntityPlayer): bool
3299
3299
  */
3300
3300
  export declare function doesPlayerHaveAllSoulHearts(player: EntityPlayer): boolean;
3301
3301
 
3302
+ /**
3303
+ * Helper function to measure a vector to see if it has a non-zero length using a threshold to
3304
+ * ignore extremely small values.
3305
+ *
3306
+ * Use this function instead of explicitly checking if the length is 0 because vectors in the game
3307
+ * are unlikely to ever be exactly set to 0. Instead, they will always have some miniscule length.
3308
+ *
3309
+ * @param vector The vector to measure.
3310
+ * @param threshold Optional. The threshold from 0 to consider to be a non-zero vector. Default is
3311
+ * 0.01.
3312
+ */
3313
+ export declare function doesVectorHaveAnyLength(vector: Vector, threshold?: number): boolean;
3314
+
3302
3315
  export declare const DOGMA_ROOM_GRID_INDEX = 109;
3303
3316
 
3304
3317
  export declare const DOOR_HITBOX_RADIUS = 11;
@@ -6929,6 +6942,26 @@ export declare function inHomeCloset(): boolean;
6929
6942
  */
6930
6943
  export declare function initArray<T>(defaultValue: T, size: int): T[];
6931
6944
 
6945
+ /**
6946
+ * Helper function to instantiate an array of mod features all at once. Use this function if your
6947
+ * mod uses the pattern of expressing mod features as `ModFeature` classes.
6948
+ *
6949
+ * For example:
6950
+ *
6951
+ * ```ts
6952
+ * const features = [
6953
+ * MyFeature1,
6954
+ * MyFeature2,
6955
+ * MyFeature3,
6956
+ * ] as const;
6957
+ * initModFeatures(mod, modFeatures);
6958
+ * ```
6959
+ *
6960
+ * @returns An array of the instantiated features in the same order that the constructors were
6961
+ * passed in.
6962
+ */
6963
+ export declare function initModFeatures(mod: ModUpgraded, modFeatures: Array<typeof ModFeature>): ModFeature[];
6964
+
6932
6965
  /** Helper function to determine if the current room shape is one of the four L room shapes. */
6933
6966
  export declare function inLRoom(): boolean;
6934
6967
 
@@ -1,6 +1,6 @@
1
1
  --[[
2
2
 
3
- isaacscript-common 20.7.2
3
+ isaacscript-common 20.9.0
4
4
 
5
5
  This is the "isaacscript-common" library, which was created with the IsaacScript tool.
6
6
 
@@ -17401,6 +17401,12 @@ function ____exports.deserializeVector(self, vector)
17401
17401
  end
17402
17402
  return Vector(x, y)
17403
17403
  end
17404
+ function ____exports.doesVectorHaveAnyLength(self, vector, threshold)
17405
+ if threshold == nil then
17406
+ threshold = 0.01
17407
+ end
17408
+ return vector:Length() >= threshold
17409
+ end
17404
17410
  function ____exports.getRandomVector(self, seedOrRNG)
17405
17411
  if seedOrRNG == nil then
17406
17412
  seedOrRNG = getRandomSeed(nil)
@@ -19745,6 +19751,7 @@ local ____types = require("src.functions.types")
19745
19751
  local asNumber = ____types.asNumber
19746
19752
  local isPrimitive = ____types.isPrimitive
19747
19753
  local ____vector = require("src.functions.vector")
19754
+ local doesVectorHaveAnyLength = ____vector.doesVectorHaveAnyLength
19748
19755
  local isVector = ____vector.isVector
19749
19756
  local vectorToString = ____vector.vectorToString
19750
19757
  function setPrimitiveEntityFields(self, entity, metatable, entityFields)
@@ -19935,7 +19942,7 @@ function ____exports.isEntityMoving(self, entity, threshold)
19935
19942
  if threshold == nil then
19936
19943
  threshold = 0.01
19937
19944
  end
19938
- return entity.Velocity:Length() >= threshold
19945
+ return doesVectorHaveAnyLength(nil, entity.Velocity, threshold)
19939
19946
  end
19940
19947
  function ____exports.isStoryBoss(self, entityType)
19941
19948
  return STORY_BOSSES_SET:has(entityType)
@@ -50903,6 +50910,20 @@ function ____exports.setRoomVisible(self, roomGridIndex, updateVisibility)
50903
50910
  end
50904
50911
  ____exports.addRoomDisplayFlag(nil, roomGridIndex, DisplayFlag.SHOW_ICON, updateVisibility)
50905
50912
  end
50913
+ return ____exports
50914
+ end,
50915
+ ["src.functions.modFeatures"] = function(...)
50916
+ local ____lualib = require("lualib_bundle")
50917
+ local __TS__New = ____lualib.__TS__New
50918
+ local ____exports = {}
50919
+ function ____exports.initModFeatures(self, mod, modFeatures)
50920
+ local instantiatedModFeatures = {}
50921
+ for ____, modFeature in ipairs(modFeatures) do
50922
+ local instantiatedModFeature = __TS__New(modFeature, mod)
50923
+ instantiatedModFeatures[#instantiatedModFeatures + 1] = instantiatedModFeature
50924
+ end
50925
+ return instantiatedModFeatures
50926
+ end
50906
50927
  return ____exports
50907
50928
  end,
50908
50929
  ["src.interfaces.PocketItemDescription"] = function(...)
@@ -51848,6 +51869,14 @@ do
51848
51869
  end
51849
51870
  end
51850
51871
  end
51872
+ do
51873
+ local ____export = require("src.functions.modFeatures")
51874
+ for ____exportKey, ____exportValue in pairs(____export) do
51875
+ if ____exportKey ~= "default" then
51876
+ ____exports[____exportKey] = ____exportValue
51877
+ end
51878
+ end
51879
+ end
51851
51880
  do
51852
51881
  local ____export = require("src.functions.nextStage")
51853
51882
  for ____exportKey, ____exportValue in pairs(____export) do
@@ -52900,6 +52929,14 @@ do
52900
52929
  end
52901
52930
  end
52902
52931
  end
52932
+ do
52933
+ local ____export = require("src.functions.modFeatures")
52934
+ for ____exportKey, ____exportValue in pairs(____export) do
52935
+ if ____exportKey ~= "default" then
52936
+ ____exports[____exportKey] = ____exportValue
52937
+ end
52938
+ end
52939
+ end
52903
52940
  do
52904
52941
  local ____export = require("src.functions.nextStage")
52905
52942
  for ____exportKey, ____exportValue in pairs(____export) do
@@ -27,6 +27,7 @@ local ____types = require("src.functions.types")
27
27
  local asNumber = ____types.asNumber
28
28
  local isPrimitive = ____types.isPrimitive
29
29
  local ____vector = require("src.functions.vector")
30
+ local doesVectorHaveAnyLength = ____vector.doesVectorHaveAnyLength
30
31
  local isVector = ____vector.isVector
31
32
  local vectorToString = ____vector.vectorToString
32
33
  function setPrimitiveEntityFields(self, entity, metatable, entityFields)
@@ -303,7 +304,7 @@ function ____exports.isEntityMoving(self, entity, threshold)
303
304
  if threshold == nil then
304
305
  threshold = 0.01
305
306
  end
306
- return entity.Velocity:Length() >= threshold
307
+ return doesVectorHaveAnyLength(nil, entity.Velocity, threshold)
307
308
  end
308
309
  --- Helper function to determine if the specified entity type is an end-game story boss, like Isaac,
309
310
  -- Blue Baby, Mega Satan, The Beast, and so on. This is useful because certain effects should only
@@ -0,0 +1,22 @@
1
+ import { ModFeature } from "../classes/ModFeature";
2
+ import { ModUpgraded } from "../types/ModUpgraded";
3
+ /**
4
+ * Helper function to instantiate an array of mod features all at once. Use this function if your
5
+ * mod uses the pattern of expressing mod features as `ModFeature` classes.
6
+ *
7
+ * For example:
8
+ *
9
+ * ```ts
10
+ * const features = [
11
+ * MyFeature1,
12
+ * MyFeature2,
13
+ * MyFeature3,
14
+ * ] as const;
15
+ * initModFeatures(mod, modFeatures);
16
+ * ```
17
+ *
18
+ * @returns An array of the instantiated features in the same order that the constructors were
19
+ * passed in.
20
+ */
21
+ export declare function initModFeatures(mod: ModUpgraded, modFeatures: Array<typeof ModFeature>): ModFeature[];
22
+ //# sourceMappingURL=modFeatures.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modFeatures.d.ts","sourceRoot":"","sources":["../../../src/functions/modFeatures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,WAAW,EAChB,WAAW,EAAE,KAAK,CAAC,OAAO,UAAU,CAAC,GACpC,UAAU,EAAE,CAUd"}
@@ -0,0 +1,28 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local __TS__New = ____lualib.__TS__New
3
+ local ____exports = {}
4
+ --- Helper function to instantiate an array of mod features all at once. Use this function if your
5
+ -- mod uses the pattern of expressing mod features as `ModFeature` classes.
6
+ --
7
+ -- For example:
8
+ --
9
+ -- ```ts
10
+ -- const features = [
11
+ -- MyFeature1,
12
+ -- MyFeature2,
13
+ -- MyFeature3,
14
+ -- ] as const;
15
+ -- initModFeatures(mod, modFeatures);
16
+ -- ```
17
+ --
18
+ -- @returns An array of the instantiated features in the same order that the constructors were
19
+ -- passed in.
20
+ function ____exports.initModFeatures(self, mod, modFeatures)
21
+ local instantiatedModFeatures = {}
22
+ for ____, modFeature in ipairs(modFeatures) do
23
+ local instantiatedModFeature = __TS__New(modFeature, mod)
24
+ instantiatedModFeatures[#instantiatedModFeatures + 1] = instantiatedModFeature
25
+ end
26
+ return instantiatedModFeatures
27
+ end
28
+ return ____exports
@@ -11,6 +11,18 @@ export declare function copyVector(vector: Vector): Vector;
11
11
  * the save data manager when reading data from the "save#.dat" file.)
12
12
  */
13
13
  export declare function deserializeVector(vector: SerializedVector): Vector;
14
+ /**
15
+ * Helper function to measure a vector to see if it has a non-zero length using a threshold to
16
+ * ignore extremely small values.
17
+ *
18
+ * Use this function instead of explicitly checking if the length is 0 because vectors in the game
19
+ * are unlikely to ever be exactly set to 0. Instead, they will always have some miniscule length.
20
+ *
21
+ * @param vector The vector to measure.
22
+ * @param threshold Optional. The threshold from 0 to consider to be a non-zero vector. Default is
23
+ * 0.01.
24
+ */
25
+ export declare function doesVectorHaveAnyLength(vector: Vector, threshold?: number): boolean;
14
26
  /**
15
27
  * Helper function to get a random vector between (-1, -1) and (1, 1).
16
28
  *
@@ -1 +1 @@
1
- {"version":3,"file":"vector.d.ts","sourceRoot":"","sources":["../../../src/functions/vector.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,yBAAyB,EACzB,SAAS,EACV,MAAM,8BAA8B,CAAC;AAatC,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IACvD,QAAQ,CAAC,uBAAuB,EAAE,MAAM,CAAC;IACzC,QAAQ,CAAC,MAAM,EAAE,yBAAyB,CAAC,MAAM,CAAC;CACnD,CAAC;AAKF,0DAA0D;AAC1D,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAA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B,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,SAAS,SAAO,GACf,OAAO,CAET;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC7B,SAAS,GAAE,IAAI,GAAG,GAAqB,GACtC,MAAM,CAOR;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,OAAO,GACd,MAAM,IAAI,gBAAgB,CAM5B;AAED,gFAAgF;AAChF,wBAAgB,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,MAAM,CAE1D;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,CAWhE;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAEtE;AAED,sEAAsE;AACtE,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAG3D;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,UAAQ,GAAG,MAAM,CAIpE"}
@@ -52,6 +52,21 @@ function ____exports.deserializeVector(self, vector)
52
52
  end
53
53
  return Vector(x, y)
54
54
  end
55
+ --- Helper function to measure a vector to see if it has a non-zero length using a threshold to
56
+ -- ignore extremely small values.
57
+ --
58
+ -- Use this function instead of explicitly checking if the length is 0 because vectors in the game
59
+ -- are unlikely to ever be exactly set to 0. Instead, they will always have some miniscule length.
60
+ --
61
+ -- @param vector The vector to measure.
62
+ -- @param threshold Optional. The threshold from 0 to consider to be a non-zero vector. Default is
63
+ -- 0.01.
64
+ function ____exports.doesVectorHaveAnyLength(self, vector, threshold)
65
+ if threshold == nil then
66
+ threshold = 0.01
67
+ end
68
+ return vector:Length() >= threshold
69
+ end
55
70
  --- Helper function to get a random vector between (-1, -1) and (1, 1).
56
71
  --
57
72
  -- To get random vectors with a bigger length, multiply this with a number.
@@ -73,6 +73,7 @@ export * from "./functions/math";
73
73
  export * from "./functions/merge";
74
74
  export * from "./functions/mergeTests";
75
75
  export * from "./functions/minimap";
76
+ export * from "./functions/modFeatures";
76
77
  export * from "./functions/nextStage";
77
78
  export * from "./functions/npcs";
78
79
  export * from "./functions/pickups";
@@ -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,2BAA2B,CAAC;AAC1C,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,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,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Ac,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mBAAmB,CAAC;AAClC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC"}
@@ -599,6 +599,14 @@ do
599
599
  end
600
600
  end
601
601
  end
602
+ do
603
+ local ____export = require("src.functions.modFeatures")
604
+ for ____exportKey, ____exportValue in pairs(____export) do
605
+ if ____exportKey ~= "default" then
606
+ ____exports[____exportKey] = ____exportValue
607
+ end
608
+ end
609
+ end
602
610
  do
603
611
  local ____export = require("src.functions.nextStage")
604
612
  for ____exportKey, ____exportValue in pairs(____export) do
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "20.7.2",
3
+ "version": "20.9.0",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -10,7 +10,7 @@ import { getRandom } from "./random";
10
10
  import { isRNG, newRNG } from "./rng";
11
11
  import { setSpriteOpacity } from "./sprites";
12
12
  import { asNumber, isPrimitive } from "./types";
13
- import { isVector, vectorToString } from "./vector";
13
+ import { doesVectorHaveAnyLength, isVector, vectorToString } from "./vector";
14
14
 
15
15
  /** From DeadInfinity. */
16
16
  const DAMAGE_FLASH_COLOR: Readonly<Color> = Color(
@@ -316,7 +316,7 @@ export function hasArmor(entity: Entity): boolean {
316
316
  * @param threshold Optional. The threshold from 0 to consider to be moving. Default is 0.01.
317
317
  */
318
318
  export function isEntityMoving(entity: Entity, threshold = 0.01): boolean {
319
- return entity.Velocity.Length() >= threshold;
319
+ return doesVectorHaveAnyLength(entity.Velocity, threshold);
320
320
  }
321
321
 
322
322
  /**
@@ -0,0 +1,35 @@
1
+ import { ModFeature } from "../classes/ModFeature";
2
+ import { ModUpgraded } from "../types/ModUpgraded";
3
+
4
+ /**
5
+ * Helper function to instantiate an array of mod features all at once. Use this function if your
6
+ * mod uses the pattern of expressing mod features as `ModFeature` classes.
7
+ *
8
+ * For example:
9
+ *
10
+ * ```ts
11
+ * const features = [
12
+ * MyFeature1,
13
+ * MyFeature2,
14
+ * MyFeature3,
15
+ * ] as const;
16
+ * initModFeatures(mod, modFeatures);
17
+ * ```
18
+ *
19
+ * @returns An array of the instantiated features in the same order that the constructors were
20
+ * passed in.
21
+ */
22
+ export function initModFeatures(
23
+ mod: ModUpgraded,
24
+ modFeatures: Array<typeof ModFeature>,
25
+ ): ModFeature[] {
26
+ const instantiatedModFeatures: ModFeature[] = [];
27
+
28
+ for (const modFeature of modFeatures) {
29
+ // eslint-disable-next-line new-cap
30
+ const instantiatedModFeature = new modFeature(mod);
31
+ instantiatedModFeatures.push(instantiatedModFeature);
32
+ }
33
+
34
+ return instantiatedModFeatures;
35
+ }
@@ -60,6 +60,24 @@ export function deserializeVector(vector: SerializedVector): Vector {
60
60
  return Vector(x, y);
61
61
  }
62
62
 
63
+ /**
64
+ * Helper function to measure a vector to see if it has a non-zero length using a threshold to
65
+ * ignore extremely small values.
66
+ *
67
+ * Use this function instead of explicitly checking if the length is 0 because vectors in the game
68
+ * are unlikely to ever be exactly set to 0. Instead, they will always have some miniscule length.
69
+ *
70
+ * @param vector The vector to measure.
71
+ * @param threshold Optional. The threshold from 0 to consider to be a non-zero vector. Default is
72
+ * 0.01.
73
+ */
74
+ export function doesVectorHaveAnyLength(
75
+ vector: Vector,
76
+ threshold = 0.01,
77
+ ): boolean {
78
+ return vector.Length() >= threshold;
79
+ }
80
+
63
81
  /**
64
82
  * Helper function to get a random vector between (-1, -1) and (1, 1).
65
83
  *
package/src/index.ts CHANGED
@@ -73,6 +73,7 @@ export * from "./functions/math";
73
73
  export * from "./functions/merge";
74
74
  export * from "./functions/mergeTests";
75
75
  export * from "./functions/minimap";
76
+ export * from "./functions/modFeatures";
76
77
  export * from "./functions/nextStage";
77
78
  export * from "./functions/npcs";
78
79
  export * from "./functions/pickups";