isaacscript-common 1.2.229 → 1.2.230

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.
@@ -0,0 +1,19 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ /** A collection of the four sprites necessary in order to render a charge bar. */
3
+ export interface ChargeBarSprites {
4
+ back: Sprite;
5
+ meter: Sprite;
6
+ meterBattery: Sprite;
7
+ lines: Sprite;
8
+ maxCharges: int;
9
+ }
10
+ /**
11
+ * Constructor for a `ChargeBarSprites` object. For more information, see the `renderChargeBar`
12
+ * helper function.
13
+ */
14
+ export declare function newChargeBarSprites(maxCharges: int): ChargeBarSprites;
15
+ /**
16
+ * Helper function to render a charge bar on the screen. First, call the `newChargeBarSprites`
17
+ * function to initialize the sprites, and then call this function on every render frame.
18
+ */
19
+ export declare function renderChargeBar(sprites: ChargeBarSprites, position: Vector, normalCharges: int, batteryCharges: int): void;
@@ -0,0 +1,42 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ local ____exports = {}
3
+ local getChargeBarClamp
4
+ function getChargeBarClamp(self, charges, maxCharges)
5
+ local meterMultiplier = 24 / maxCharges
6
+ local meterClip = 26 - charges * meterMultiplier
7
+ return Vector(0, meterClip)
8
+ end
9
+ local CHARGE_BAR_ANM2 = "gfx/ui/ui_chargebar.anm2"
10
+ function ____exports.newChargeBarSprites(self, maxCharges)
11
+ local back = Sprite()
12
+ back:Load(CHARGE_BAR_ANM2, true)
13
+ back:Play("BarEmpty", true)
14
+ local meter = Sprite()
15
+ meter:Load(CHARGE_BAR_ANM2, true)
16
+ meter:Play("BarFull", true)
17
+ local meterBattery = Sprite()
18
+ meterBattery:Load(CHARGE_BAR_ANM2, true)
19
+ meterBattery:Play("BarFull", true)
20
+ local lines = Sprite()
21
+ lines:Load(CHARGE_BAR_ANM2, true)
22
+ lines:Play(
23
+ "BarOverlay" .. tostring(maxCharges),
24
+ true
25
+ )
26
+ return {
27
+ back = back,
28
+ meter = meter,
29
+ meterBattery = meterBattery,
30
+ lines = lines,
31
+ maxCharges = maxCharges
32
+ }
33
+ end
34
+ function ____exports.renderChargeBar(self, sprites, position, normalCharges, batteryCharges)
35
+ sprites.back:Render(position, Vector.Zero, Vector.Zero)
36
+ local normalChargesClamp = getChargeBarClamp(nil, normalCharges, sprites.maxCharges)
37
+ sprites.meter:Render(position, normalChargesClamp, Vector.Zero)
38
+ local batteryChargesClamp = getChargeBarClamp(nil, batteryCharges, sprites.maxCharges)
39
+ sprites.meterBattery:Render(position, batteryChargesClamp, Vector.Zero)
40
+ sprites.lines:Render(position, Vector.Zero, Vector.Zero)
41
+ end
42
+ return ____exports
package/dist/index.d.ts CHANGED
@@ -35,6 +35,7 @@ export * from "./functions/cards";
35
35
  export * from "./functions/challenges";
36
36
  export * from "./functions/character";
37
37
  export * from "./functions/charge";
38
+ export * from "./functions/chargeBar";
38
39
  export * from "./functions/collectibleCacheFlag";
39
40
  export * from "./functions/collectibles";
40
41
  export * from "./functions/collectibleSet";
package/dist/index.lua CHANGED
@@ -289,6 +289,14 @@ do
289
289
  end
290
290
  end
291
291
  end
292
+ do
293
+ local ____export = require("functions.chargeBar")
294
+ for ____exportKey, ____exportValue in pairs(____export) do
295
+ if ____exportKey ~= "default" then
296
+ ____exports[____exportKey] = ____exportValue
297
+ end
298
+ end
299
+ end
292
300
  do
293
301
  local ____export = require("functions.collectibleCacheFlag")
294
302
  for ____exportKey, ____exportValue in pairs(____export) do
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.229",
3
+ "version": "1.2.230",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",