@datamoc/mw_games 0.1.2 → 0.2.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/README.md +42 -17
- package/dist/actors/Aura.d.ts +29 -0
- package/dist/actors/Aura.d.ts.map +1 -0
- package/dist/actors/Aura.js +69 -0
- package/dist/actors/Aura.js.map +1 -0
- package/dist/actors/ItemStatusEffect.d.ts +27 -0
- package/dist/actors/ItemStatusEffect.d.ts.map +1 -0
- package/dist/actors/ItemStatusEffect.js +35 -0
- package/dist/actors/ItemStatusEffect.js.map +1 -0
- package/dist/actors/Support.d.ts +32 -0
- package/dist/actors/Support.d.ts.map +1 -0
- package/dist/actors/Support.js +60 -0
- package/dist/actors/Support.js.map +1 -0
- package/dist/actors/Traits.d.ts +29 -0
- package/dist/actors/Traits.d.ts.map +1 -0
- package/dist/actors/Traits.js +21 -0
- package/dist/actors/Traits.js.map +1 -0
- package/dist/actors/index.d.ts +8 -0
- package/dist/actors/index.d.ts.map +1 -1
- package/dist/actors/index.js +4 -0
- package/dist/actors/index.js.map +1 -1
- package/dist/assets/Streaming.d.ts +40 -0
- package/dist/assets/Streaming.d.ts.map +1 -0
- package/dist/assets/Streaming.js +79 -0
- package/dist/assets/Streaming.js.map +1 -0
- package/dist/assets/index.d.ts +13 -0
- package/dist/assets/index.d.ts.map +1 -1
- package/dist/assets/index.js +19 -0
- package/dist/assets/index.js.map +1 -1
- package/dist/audio/Captions.d.ts +15 -0
- package/dist/audio/Captions.d.ts.map +1 -0
- package/dist/audio/Captions.js +4 -0
- package/dist/audio/Captions.js.map +1 -0
- package/dist/audio/Midi.d.ts +75 -0
- package/dist/audio/Midi.d.ts.map +1 -0
- package/dist/audio/Midi.js +186 -0
- package/dist/audio/Midi.js.map +1 -0
- package/dist/audio/Orchestrator.d.ts +40 -0
- package/dist/audio/Orchestrator.d.ts.map +1 -0
- package/dist/audio/Orchestrator.js +48 -0
- package/dist/audio/Orchestrator.js.map +1 -0
- package/dist/audio/Sound.d.ts +3 -0
- package/dist/audio/Sound.d.ts.map +1 -1
- package/dist/audio/Sound.js +4 -0
- package/dist/audio/Sound.js.map +1 -1
- package/dist/audio/Synth.d.ts +35 -0
- package/dist/audio/Synth.d.ts.map +1 -0
- package/dist/audio/Synth.js +96 -0
- package/dist/audio/Synth.js.map +1 -0
- package/dist/audio/index.d.ts +8 -0
- package/dist/audio/index.d.ts.map +1 -1
- package/dist/audio/index.js +4 -0
- package/dist/audio/index.js.map +1 -1
- package/dist/board/Army.d.ts +17 -0
- package/dist/board/Army.d.ts.map +1 -0
- package/dist/board/Army.js +48 -0
- package/dist/board/Army.js.map +1 -0
- package/dist/board/FogOfWar.d.ts +23 -0
- package/dist/board/FogOfWar.d.ts.map +1 -0
- package/dist/board/FogOfWar.js +40 -0
- package/dist/board/FogOfWar.js.map +1 -0
- package/dist/board/Tactics.d.ts +2 -0
- package/dist/board/Tactics.d.ts.map +1 -1
- package/dist/board/Tactics.js +29 -7
- package/dist/board/Tactics.js.map +1 -1
- package/dist/board/index.d.ts +5 -1
- package/dist/board/index.d.ts.map +1 -1
- package/dist/board/index.js +3 -1
- package/dist/board/index.js.map +1 -1
- package/dist/core/Feedback.d.ts +23 -0
- package/dist/core/Feedback.d.ts.map +1 -0
- package/dist/core/Feedback.js +35 -0
- package/dist/core/Feedback.js.map +1 -0
- package/dist/core/Game.d.ts +11 -0
- package/dist/core/Game.d.ts.map +1 -1
- package/dist/core/Game.js +54 -0
- package/dist/core/Game.js.map +1 -1
- package/dist/core/Input.d.ts +58 -0
- package/dist/core/Input.d.ts.map +1 -1
- package/dist/core/Input.js +135 -0
- package/dist/core/Input.js.map +1 -1
- package/dist/core/Loading.d.ts +48 -0
- package/dist/core/Loading.d.ts.map +1 -0
- package/dist/core/Loading.js +102 -0
- package/dist/core/Loading.js.map +1 -0
- package/dist/core/News.d.ts +46 -0
- package/dist/core/News.d.ts.map +1 -0
- package/dist/core/News.js +79 -0
- package/dist/core/News.js.map +1 -0
- package/dist/core/PlayerInput.d.ts +38 -0
- package/dist/core/PlayerInput.d.ts.map +1 -0
- package/dist/core/PlayerInput.js +57 -0
- package/dist/core/PlayerInput.js.map +1 -0
- package/dist/core/RunHistory.d.ts +43 -0
- package/dist/core/RunHistory.d.ts.map +1 -0
- package/dist/core/RunHistory.js +41 -0
- package/dist/core/RunHistory.js.map +1 -0
- package/dist/core/Sanitize.d.ts +56 -0
- package/dist/core/Sanitize.d.ts.map +1 -0
- package/dist/core/Sanitize.js +87 -0
- package/dist/core/Sanitize.js.map +1 -0
- package/dist/core/Save.d.ts +31 -7
- package/dist/core/Save.d.ts.map +1 -1
- package/dist/core/Save.js +56 -0
- package/dist/core/Save.js.map +1 -1
- package/dist/core/SaveSync.d.ts +26 -0
- package/dist/core/SaveSync.d.ts.map +1 -0
- package/dist/core/SaveSync.js +52 -0
- package/dist/core/SaveSync.js.map +1 -0
- package/dist/core/Scramble.d.ts +13 -0
- package/dist/core/Scramble.d.ts.map +1 -0
- package/dist/core/Scramble.js +44 -0
- package/dist/core/Scramble.js.map +1 -0
- package/dist/core/Spawner.d.ts +48 -0
- package/dist/core/Spawner.d.ts.map +1 -0
- package/dist/core/Spawner.js +65 -0
- package/dist/core/Spawner.js.map +1 -0
- package/dist/core/Tween.d.ts +25 -0
- package/dist/core/Tween.d.ts.map +1 -0
- package/dist/core/Tween.js +60 -0
- package/dist/core/Tween.js.map +1 -0
- package/dist/core/UndoHistory.d.ts +37 -0
- package/dist/core/UndoHistory.d.ts.map +1 -0
- package/dist/core/UndoHistory.js +49 -0
- package/dist/core/UndoHistory.js.map +1 -0
- package/dist/core/index.d.ts +20 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +11 -0
- package/dist/core/index.js.map +1 -1
- package/dist/i18n/Fluent.d.ts +7 -0
- package/dist/i18n/Fluent.d.ts.map +1 -0
- package/dist/i18n/Fluent.js +86 -0
- package/dist/i18n/Fluent.js.map +1 -0
- package/dist/i18n/index.d.ts +15 -1
- package/dist/i18n/index.d.ts.map +1 -1
- package/dist/i18n/index.js +17 -2
- package/dist/i18n/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/mw_games.global.js +351 -79
- package/dist/render/Camera.d.ts +29 -2
- package/dist/render/Camera.d.ts.map +1 -1
- package/dist/render/Camera.js +40 -11
- package/dist/render/Camera.js.map +1 -1
- package/dist/render/Capabilities.d.ts +51 -0
- package/dist/render/Capabilities.d.ts.map +1 -0
- package/dist/render/Capabilities.js +56 -0
- package/dist/render/Capabilities.js.map +1 -0
- package/dist/render/ColorBlindness.d.ts +16 -0
- package/dist/render/ColorBlindness.d.ts.map +1 -0
- package/dist/render/ColorBlindness.js +41 -0
- package/dist/render/ColorBlindness.js.map +1 -0
- package/dist/render/Minimap.d.ts +52 -0
- package/dist/render/Minimap.d.ts.map +1 -0
- package/dist/render/Minimap.js +95 -0
- package/dist/render/Minimap.js.map +1 -0
- package/dist/render/Viewport.d.ts +46 -0
- package/dist/render/Viewport.d.ts.map +1 -0
- package/dist/render/Viewport.js +52 -0
- package/dist/render/Viewport.js.map +1 -0
- package/dist/render/index.d.ts +9 -1
- package/dist/render/index.d.ts.map +1 -1
- package/dist/render/index.js +5 -1
- package/dist/render/index.js.map +1 -1
- package/dist/roguelike/Stealth.d.ts +34 -0
- package/dist/roguelike/Stealth.d.ts.map +1 -0
- package/dist/roguelike/Stealth.js +35 -0
- package/dist/roguelike/Stealth.js.map +1 -0
- package/dist/roguelike/index.d.ts +2 -0
- package/dist/roguelike/index.d.ts.map +1 -1
- package/dist/roguelike/index.js +1 -0
- package/dist/roguelike/index.js.map +1 -1
- package/dist/rpg/Collision.d.ts +42 -0
- package/dist/rpg/Collision.d.ts.map +1 -0
- package/dist/rpg/Collision.js +77 -0
- package/dist/rpg/Collision.js.map +1 -0
- package/dist/rpg/FreeMover.d.ts +45 -0
- package/dist/rpg/FreeMover.d.ts.map +1 -0
- package/dist/rpg/FreeMover.js +68 -0
- package/dist/rpg/FreeMover.js.map +1 -0
- package/dist/rpg/Marshal.d.ts +65 -0
- package/dist/rpg/Marshal.d.ts.map +1 -0
- package/dist/rpg/Marshal.js +393 -0
- package/dist/rpg/Marshal.js.map +1 -0
- package/dist/rpg/Quest.d.ts +41 -0
- package/dist/rpg/Quest.d.ts.map +1 -1
- package/dist/rpg/Quest.js +39 -6
- package/dist/rpg/Quest.js.map +1 -1
- package/dist/rpg/index.d.ts +7 -1
- package/dist/rpg/index.d.ts.map +1 -1
- package/dist/rpg/index.js +3 -0
- package/dist/rpg/index.js.map +1 -1
- package/dist/stage/DialogueStage.d.ts +1 -2
- package/dist/stage/DialogueStage.d.ts.map +1 -1
- package/dist/stage/DialogueStage.js +7 -22
- package/dist/stage/DialogueStage.js.map +1 -1
- package/dist/stage/index.d.ts +1 -1
- package/dist/stage/index.d.ts.map +1 -1
- package/dist/stage/script.d.ts +29 -0
- package/dist/stage/script.d.ts.map +1 -1
- package/dist/stage/script.js +0 -0
- package/dist/stage/script.js.map +1 -1
- package/dist/three-d/Character3D.d.ts +48 -0
- package/dist/three-d/Character3D.d.ts.map +1 -0
- package/dist/three-d/Character3D.js +96 -0
- package/dist/three-d/Character3D.js.map +1 -0
- package/dist/three-d/Engine3D.d.ts +23 -0
- package/dist/three-d/Engine3D.d.ts.map +1 -0
- package/dist/three-d/Engine3D.js +45 -0
- package/dist/three-d/Engine3D.js.map +1 -0
- package/dist/three-d/Grid.d.ts +14 -0
- package/dist/three-d/Grid.d.ts.map +1 -0
- package/dist/three-d/Grid.js +13 -0
- package/dist/three-d/Grid.js.map +1 -0
- package/dist/three-d/Heightmap.d.ts +35 -0
- package/dist/three-d/Heightmap.d.ts.map +1 -0
- package/dist/three-d/Heightmap.js +29 -0
- package/dist/three-d/Heightmap.js.map +1 -0
- package/dist/three-d/Models.d.ts +12 -0
- package/dist/three-d/Models.d.ts.map +1 -0
- package/dist/three-d/Models.js +14 -0
- package/dist/three-d/Models.js.map +1 -0
- package/dist/three-d/TileGrid3D.d.ts +21 -0
- package/dist/three-d/TileGrid3D.d.ts.map +1 -0
- package/dist/three-d/TileGrid3D.js +65 -0
- package/dist/three-d/TileGrid3D.js.map +1 -0
- package/dist/three-d/Vox.d.ts +24 -0
- package/dist/three-d/Vox.d.ts.map +1 -0
- package/dist/three-d/Vox.js +93 -0
- package/dist/three-d/Vox.js.map +1 -0
- package/dist/three-d/index.d.ts +13 -0
- package/dist/three-d/index.d.ts.map +1 -0
- package/dist/three-d/index.js +7 -0
- package/dist/three-d/index.js.map +1 -0
- package/dist/ui/Bar.d.ts +49 -0
- package/dist/ui/Bar.d.ts.map +1 -0
- package/dist/ui/Bar.js +70 -0
- package/dist/ui/Bar.js.map +1 -0
- package/dist/ui/BitmapLabel.d.ts +42 -0
- package/dist/ui/BitmapLabel.d.ts.map +1 -0
- package/dist/ui/BitmapLabel.js +59 -0
- package/dist/ui/BitmapLabel.js.map +1 -0
- package/dist/ui/Button.d.ts +52 -0
- package/dist/ui/Button.d.ts.map +1 -0
- package/dist/ui/Button.js +147 -0
- package/dist/ui/Button.js.map +1 -0
- package/dist/ui/FloatingText.d.ts +28 -0
- package/dist/ui/FloatingText.d.ts.map +1 -0
- package/dist/ui/FloatingText.js +39 -0
- package/dist/ui/FloatingText.js.map +1 -0
- package/dist/ui/HelpScreen.d.ts +29 -0
- package/dist/ui/HelpScreen.d.ts.map +1 -0
- package/dist/ui/HelpScreen.js +39 -0
- package/dist/ui/HelpScreen.js.map +1 -0
- package/dist/ui/IconGrid.d.ts +8 -0
- package/dist/ui/IconGrid.d.ts.map +1 -1
- package/dist/ui/IconGrid.js +27 -1
- package/dist/ui/IconGrid.js.map +1 -1
- package/dist/ui/Label.d.ts +9 -0
- package/dist/ui/Label.d.ts.map +1 -1
- package/dist/ui/Label.js +24 -1
- package/dist/ui/Label.js.map +1 -1
- package/dist/ui/ListView.d.ts +11 -0
- package/dist/ui/ListView.d.ts.map +1 -1
- package/dist/ui/ListView.js +55 -1
- package/dist/ui/ListView.js.map +1 -1
- package/dist/ui/LoadingScreen.d.ts +31 -0
- package/dist/ui/LoadingScreen.d.ts.map +1 -0
- package/dist/ui/LoadingScreen.js +60 -0
- package/dist/ui/LoadingScreen.js.map +1 -0
- package/dist/ui/MessageBox.d.ts +26 -0
- package/dist/ui/MessageBox.d.ts.map +1 -1
- package/dist/ui/MessageBox.js +62 -13
- package/dist/ui/MessageBox.js.map +1 -1
- package/dist/ui/RebindScreen.d.ts +55 -0
- package/dist/ui/RebindScreen.d.ts.map +1 -0
- package/dist/ui/RebindScreen.js +114 -0
- package/dist/ui/RebindScreen.js.map +1 -0
- package/dist/ui/Toast.d.ts +44 -0
- package/dist/ui/Toast.d.ts.map +1 -0
- package/dist/ui/Toast.js +89 -0
- package/dist/ui/Toast.js.map +1 -0
- package/dist/ui/VerticalLabel.d.ts +5 -0
- package/dist/ui/VerticalLabel.d.ts.map +1 -1
- package/dist/ui/VerticalLabel.js +18 -7
- package/dist/ui/VerticalLabel.js.map +1 -1
- package/dist/ui/Window.d.ts +6 -0
- package/dist/ui/Window.d.ts.map +1 -1
- package/dist/ui/Window.js +16 -1
- package/dist/ui/Window.js.map +1 -1
- package/dist/ui/WindowStack.d.ts +1 -0
- package/dist/ui/WindowStack.d.ts.map +1 -1
- package/dist/ui/WindowStack.js +4 -1
- package/dist/ui/WindowStack.js.map +1 -1
- package/dist/ui/index.d.ts +17 -1
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.js +9 -1
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/theme.d.ts +21 -0
- package/dist/ui/theme.d.ts.map +1 -1
- package/dist/ui/theme.js +42 -0
- package/dist/ui/theme.js.map +1 -1
- package/dist/version.d.ts +13 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +13 -0
- package/dist/version.js.map +1 -0
- package/dist/world/Environment.d.ts +35 -0
- package/dist/world/Environment.d.ts.map +1 -0
- package/dist/world/Environment.js +55 -0
- package/dist/world/Environment.js.map +1 -0
- package/dist/world/index.d.ts +2 -0
- package/dist/world/index.d.ts.map +1 -1
- package/dist/world/index.js +1 -0
- package/dist/world/index.js.map +1 -1
- package/package.json +40 -4
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Container, Graphics } from 'pixi.js';
|
|
2
|
+
import { Camera } from './Camera.js';
|
|
3
|
+
/**
|
|
4
|
+
* One player's own rectangle of the screen, for a same-screen local multiplayer layout: a
|
|
5
|
+
* `Camera` whose world is offset to start at `x`/`y` instead of the corner of the canvas,
|
|
6
|
+
* and clipped to `width`/`height` so it never bleeds into a neighbouring player's share of
|
|
7
|
+
* the screen. A game with a single `Viewport` covering the whole canvas behaves exactly like
|
|
8
|
+
* a game using a bare `Camera` directly - this adds a screen region and a mask around it,
|
|
9
|
+
* nothing else.
|
|
10
|
+
*/
|
|
11
|
+
export class Viewport {
|
|
12
|
+
constructor(options) {
|
|
13
|
+
/** add this to `Game.current.stage`, the way a single-camera game already adds `camera.world` */
|
|
14
|
+
this.container = new Container();
|
|
15
|
+
this.clip = new Graphics();
|
|
16
|
+
this.camera = new Camera(options);
|
|
17
|
+
this.container.addChild(this.camera.world);
|
|
18
|
+
this.container.addChild(this.clip);
|
|
19
|
+
this.container.mask = this.clip;
|
|
20
|
+
this.resize(options.x, options.y, options.width, options.height);
|
|
21
|
+
}
|
|
22
|
+
/** moves and/or resizes this viewport's own rectangle of the screen */
|
|
23
|
+
resize(x, y, width, height) {
|
|
24
|
+
this.camera.setViewport(width, height, x, y);
|
|
25
|
+
this.clip.clear().rect(x, y, width, height).fill(0xffffff);
|
|
26
|
+
}
|
|
27
|
+
update(dt) {
|
|
28
|
+
this.camera.update(dt);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The two even halves of `width`×`height` a two-player split screen typically wants -
|
|
33
|
+
* side by side for a landscape screen, stacked for a portrait one - as plain rectangles a
|
|
34
|
+
* game hands straight to two `Viewport`s (or to `resize` on a resize event). Not the only
|
|
35
|
+
* reasonable split, so not baked into `Viewport` itself: a game wanting an L-shaped, uneven,
|
|
36
|
+
* or three/four-player layout lays out its own rectangles the same way.
|
|
37
|
+
*/
|
|
38
|
+
export function splitScreenHalves(width, height) {
|
|
39
|
+
if (width >= height) {
|
|
40
|
+
const half = Math.floor(width / 2);
|
|
41
|
+
return [
|
|
42
|
+
{ x: 0, y: 0, width: half, height },
|
|
43
|
+
{ x: half, y: 0, width: width - half, height },
|
|
44
|
+
];
|
|
45
|
+
}
|
|
46
|
+
const half = Math.floor(height / 2);
|
|
47
|
+
return [
|
|
48
|
+
{ x: 0, y: 0, width, height: half },
|
|
49
|
+
{ x: 0, y: half, width, height: height - half },
|
|
50
|
+
];
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=Viewport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Viewport.js","sourceRoot":"","sources":["../../src/render/Viewport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAsB,MAAM,aAAa,CAAC;AAUzD;;;;;;;GAOG;AACH,MAAM,OAAO,QAAQ;IAQpB,YAAY,OAAwB;QALpC,iGAAiG;QACxF,cAAS,GAAG,IAAI,SAAS,EAAE,CAAC;QAEpB,SAAI,GAAG,IAAI,QAAQ,EAAE,CAAC;QAGtC,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC;QAClC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC3C,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,CAAC,SAAS,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QAChC,IAAI,CAAC,MAAM,C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AM,EAAE,MAAM,GAAG,IAAI,EAAE;KAC/C,CAAC;AACH,CAAC"}
|
package/dist/render/index.d.ts
CHANGED
|
@@ -4,8 +4,14 @@ export { TintedSprite, registerColorTransform } from './TintedSprite.ts';
|
|
|
4
4
|
export { AnimatedSprite, Animation } from './AnimatedSprite.ts';
|
|
5
5
|
export type { AnimationOptions } from './AnimatedSprite.ts';
|
|
6
6
|
export { SpriteSheet } from './SpriteSheet.ts';
|
|
7
|
-
export { Camera, createCamera } from './Camera.ts';
|
|
7
|
+
export { Camera, createCamera, snapZoom } from './Camera.ts';
|
|
8
8
|
export type { CameraOptions } from './Camera.ts';
|
|
9
|
+
export { Viewport, splitScreenHalves } from './Viewport.ts';
|
|
10
|
+
export type { ViewportOptions } from './Viewport.ts';
|
|
11
|
+
export { createColorBlindnessFilter, COLOR_BLINDNESS_MATRICES } from './ColorBlindness.ts';
|
|
12
|
+
export type { ColorBlindnessType } from './ColorBlindness.ts';
|
|
13
|
+
export { Minimap, newlyRevealed } from './Minimap.ts';
|
|
14
|
+
export type { MinimapOptions } from './Minimap.ts';
|
|
9
15
|
export { TileMap, EMPTY, tileFrame, tileFrameSheet, tileFrameIndex } from './TileMap.ts';
|
|
10
16
|
export type { TileMapOptions } from './TileMap.ts';
|
|
11
17
|
export { LayeredSprite } from './LayeredSprite.ts';
|
|
@@ -15,4 +21,6 @@ export { ActorAnimator } from './ActorAnimator.ts';
|
|
|
15
21
|
export type { ActorAnimationState, ActorAnimatorOptions } from './ActorAnimator.ts';
|
|
16
22
|
export { blobIndex, autotileFrames, BLOB_SHAPES } from './Autotile.ts';
|
|
17
23
|
export type { NeighborMask } from './Autotile.ts';
|
|
24
|
+
export { inspectGraphicsCapabilities, detectWebGpu, RENDERING_DECISIONS } from './Capabilities.ts';
|
|
25
|
+
export type { GraphicsCapabilities, GraphicsProbe, GraphicsWorkload, RenderingDecision, WebGpuDetection } from './Capabilities.ts';
|
|
18
26
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/render/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,qBAAqB,EACrB,YAAY,EACZ,WAAW,EACX,YAAY,GACZ,MAAM,4BAA4B,CAAC;AACpC,YAAY,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE9D,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChE,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/render/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,qBAAqB,EACrB,YAAY,EACZ,WAAW,EACX,YAAY,GACZ,MAAM,4BAA4B,CAAC;AACpC,YAAY,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE9D,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChE,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC7D,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAC5D,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,0BAA0B,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC3F,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACtD,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACzF,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAE1E,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,YAAY,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAEpF,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACvE,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,EAAE,2BAA2B,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACnG,YAAY,EAAE,oBAAoB,EAAE,aAAa,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/render/index.js
CHANGED
|
@@ -2,10 +2,14 @@ export { ColorTransformBatcher, packColorAdd, packTintAdd, NO_COLOR_ADD, } from
|
|
|
2
2
|
export { TintedSprite, registerColorTransform } from './TintedSprite.js';
|
|
3
3
|
export { AnimatedSprite, Animation } from './AnimatedSprite.js';
|
|
4
4
|
export { SpriteSheet } from './SpriteSheet.js';
|
|
5
|
-
export { Camera, createCamera } from './Camera.js';
|
|
5
|
+
export { Camera, createCamera, snapZoom } from './Camera.js';
|
|
6
|
+
export { Viewport, splitScreenHalves } from './Viewport.js';
|
|
7
|
+
export { createColorBlindnessFilter, COLOR_BLINDNESS_MATRICES } from './ColorBlindness.js';
|
|
8
|
+
export { Minimap, newlyRevealed } from './Minimap.js';
|
|
6
9
|
export { TileMap, EMPTY, tileFrame, tileFrameSheet, tileFrameIndex } from './TileMap.js';
|
|
7
10
|
export { LayeredSprite } from './LayeredSprite.js';
|
|
8
11
|
export { Projectile } from './Projectile.js';
|
|
9
12
|
export { ActorAnimator } from './ActorAnimator.js';
|
|
10
13
|
export { blobIndex, autotileFrames, BLOB_SHAPES } from './Autotile.js';
|
|
14
|
+
export { inspectGraphicsCapabilities, detectWebGpu, RENDERING_DECISIONS } from './Capabilities.js';
|
|
11
15
|
//# sourceMappingURL=index.js.map
|
package/dist/render/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/render/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,qBAAqB,EACrB,YAAY,EACZ,WAAW,EACX,YAAY,GACZ,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/render/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,qBAAqB,EACrB,YAAY,EACZ,WAAW,EACX,YAAY,GACZ,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE7D,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAE5D,OAAO,EAAE,0BAA0B,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAG3F,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAEtD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEzF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGvE,OAAO,EAAE,2BAA2B,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Step } from './Pathfinder.ts';
|
|
2
|
+
/**
|
|
3
|
+
* A unit that stays undetected in clear sight, independent of terrain, until an enemy comes
|
|
4
|
+
* within a fixed radius - the primitive under every "hidden unless someone's right next to
|
|
5
|
+
* you" mechanic. `FieldOfView` is the other half of visibility (can an observer's line of
|
|
6
|
+
* sight even reach this cell); this is a separate, distance-only check layered on top of it,
|
|
7
|
+
* not a change to how `FieldOfView` itself works.
|
|
8
|
+
*/
|
|
9
|
+
export interface StealthOptions {
|
|
10
|
+
/** an observer this close or closer reveals the unit, in `chebyshevDistance` steps */
|
|
11
|
+
radius: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Tracks one hidden unit's detection state. Detection is one-way and sticky: once found, a
|
|
15
|
+
* unit stays found until something explicitly re-hides it (`reset`), the same way a real
|
|
16
|
+
* ambush does not un-happen because the enemy that spotted you wandered off again.
|
|
17
|
+
*/
|
|
18
|
+
export declare class Stealth {
|
|
19
|
+
private detected;
|
|
20
|
+
private radius;
|
|
21
|
+
constructor(options: StealthOptions);
|
|
22
|
+
get isDetected(): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Checks `observers` against `hidden`'s position, and returns `true` only on the call
|
|
25
|
+
* that first brings one within range - the discoverer's move should be spent on that
|
|
26
|
+
* call, and that call alone, never on every later check while the unit stays in range.
|
|
27
|
+
* Already-detected units always return `false` here; read `isDetected` for their
|
|
28
|
+
* ongoing state instead.
|
|
29
|
+
*/
|
|
30
|
+
checkDetection(hidden: Step, observers: readonly Step[]): boolean;
|
|
31
|
+
/** hides the unit again - a smoke bomb, breaking line of sight for long enough, a new floor */
|
|
32
|
+
reset(): void;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=Stealth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Stealth.d.ts","sourceRoot":"","sources":["../../src/roguelike/Stealth.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC9B,sFAAsF;IACtF,MAAM,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,qBAAa,OAAO;IACnB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,MAAM,CAAS;IAEvB,YAAY,OAAO,EAAE,cAAc,EAElC;IAED,IAAI,UAAU,IAAI,OAAO,CAExB;IAED;;;;;;OAMG;IACH,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,IAAI,EAAE,GAAG,OAAO,CAKhE;IAED,+FAA+F;IAC/F,KAAK,IAAI,IAAI,CAEZ;CACD"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { chebyshevDistance } from './Targeting.js';
|
|
2
|
+
/**
|
|
3
|
+
* Tracks one hidden unit's detection state. Detection is one-way and sticky: once found, a
|
|
4
|
+
* unit stays found until something explicitly re-hides it (`reset`), the same way a real
|
|
5
|
+
* ambush does not un-happen because the enemy that spotted you wandered off again.
|
|
6
|
+
*/
|
|
7
|
+
export class Stealth {
|
|
8
|
+
constructor(options) {
|
|
9
|
+
this.detected = false;
|
|
10
|
+
this.radius = options.radius;
|
|
11
|
+
}
|
|
12
|
+
get isDetected() {
|
|
13
|
+
return this.detected;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Checks `observers` against `hidden`'s position, and returns `true` only on the call
|
|
17
|
+
* that first brings one within range - the discoverer's move should be spent on that
|
|
18
|
+
* call, and that call alone, never on every later check while the unit stays in range.
|
|
19
|
+
* Already-detected units always return `false` here; read `isDetected` for their
|
|
20
|
+
* ongoing state instead.
|
|
21
|
+
*/
|
|
22
|
+
checkDetection(hidden, observers) {
|
|
23
|
+
if (this.detected)
|
|
24
|
+
return false;
|
|
25
|
+
const found = observers.some((observer) => chebyshevDistance(hidden, observer) <= this.radius);
|
|
26
|
+
if (found)
|
|
27
|
+
this.detected = true;
|
|
28
|
+
return found;
|
|
29
|
+
}
|
|
30
|
+
/** hides the unit again - a smoke bomb, breaking line of sight for long enough, a new floor */
|
|
31
|
+
reset() {
|
|
32
|
+
this.detected = false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=Stealth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Stealth.js","sourceRoot":"","sources":["../../src/roguelike/Stealth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAenD;;;;GAIG;AACH,MAAM,OAAO,OAAO;IAInB,YAAY,OAAuB;QAH3B,aAAQ,GAAG,KAAK,CAAC;QAIxB,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAC9B,CAAC;IAED,IAAI,UAAU;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC;IACtB,CAAC;IAED;;;;;;OAMG;IACH,cAAc,CAAC,MAAY,EAAE,SAA0B;QACtD,IAAI,IAAI,CAAC,QAAQ;YAAE,OAAO,KAAK,CAAC;QAChC,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,iBAAiB,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC;QAC/F,IAAI,KAAK;YAAE,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QAChC,OAAO,KAAK,CAAC;IACd,CAAC;IAED,+FAA+F;IAC/F,KAAK;QACJ,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;IACvB,CAAC;CACD"}
|
|
@@ -20,4 +20,6 @@ export { BossPhases, AbilityCycle } from './Boss.ts';
|
|
|
20
20
|
export { Blob } from './Blob.ts';
|
|
21
21
|
export { CombatHooks } from './Combat.ts';
|
|
22
22
|
export type { CombatEvent, CombatHook, DamageContext } from './Combat.ts';
|
|
23
|
+
export { Stealth } from './Stealth.ts';
|
|
24
|
+
export type { StealthOptions } from './Stealth.ts';
|
|
23
25
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/roguelike/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1E,YAAY,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEpD,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC3F,YAAY,EAAE,cAAc,EAAE,MAAM,eAA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C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE1E,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/roguelike/index.js
CHANGED
|
@@ -12,4 +12,5 @@ export { coneCells, chainTargets, knockbackPath } from './Targeting.js';
|
|
|
12
12
|
export { BossPhases, AbilityCycle } from './Boss.js';
|
|
13
13
|
export { Blob } from './Blob.js';
|
|
14
14
|
export { CombatHooks } from './Combat.js';
|
|
15
|
+
export { Stealth } from './Stealth.js';
|
|
15
16
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/roguelike/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG1E,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAG3F,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAG/D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGjD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,cAAc,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE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cAAc,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lightweight 2D collision: overlap tests for AABBs and circles, plus a resolver that stops
|
|
3
|
+
* a moving AABB at the edge of a solid tile instead of passing through it.
|
|
4
|
+
*
|
|
5
|
+
* This is not a rigid-body physics engine - out of scope for a tile/turn-first framework the
|
|
6
|
+
* way a full 3D engine is (see item 45's own caution) - it is the missing primitive behind
|
|
7
|
+
* `rpg.FreeMover`'s own doc comment: "both own position and animation only, nothing about
|
|
8
|
+
* collision or passability". A game wires this in itself; `FreeMover` stays unopinionated
|
|
9
|
+
* about whether a game wants tile solidity, circle-vs-circle hits, or no collision at all.
|
|
10
|
+
*/
|
|
11
|
+
export interface AABB {
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
}
|
|
17
|
+
export interface Circle {
|
|
18
|
+
x: number;
|
|
19
|
+
y: number;
|
|
20
|
+
radius: number;
|
|
21
|
+
}
|
|
22
|
+
export declare function aabbOverlap(a: AABB, b: AABB): boolean;
|
|
23
|
+
export declare function circleOverlap(a: Circle, b: Circle): boolean;
|
|
24
|
+
export declare function circleAabbOverlap(circle: Circle, box: AABB): boolean;
|
|
25
|
+
/** true when tile `(tileX, tileY)` blocks movement */
|
|
26
|
+
export type SolidTile = (tileX: number, tileY: number) => boolean;
|
|
27
|
+
export interface ResolveTileMoveOptions {
|
|
28
|
+
tileSize: number;
|
|
29
|
+
isSolid: SolidTile;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Moves `box` by `(dx, dy)`, one axis at a time, stopping flush against the edge of the
|
|
33
|
+
* first solid tile it would otherwise enter rather than tunnelling through it at high
|
|
34
|
+
* speed. Axis separation (resolve the whole x move, then the whole y move against the
|
|
35
|
+
* already-resolved x) is the standard, simple choice for an axis-aligned tile grid - a full
|
|
36
|
+
* swept-AABB solver buys nothing here since every tile edge is already axis-aligned.
|
|
37
|
+
*/
|
|
38
|
+
export declare function resolveAabbAgainstTiles(box: AABB, dx: number, dy: number, options: ResolveTileMoveOptions): {
|
|
39
|
+
x: number;
|
|
40
|
+
y: number;
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=Collision.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Collision.d.ts","sourceRoot":"","sources":["../../src/rpg/Collision.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,MAAM,WAAW,IAAI;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,MAAM;IACtB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,GAAG,OAAO,CAErD;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAK3D;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,GAAG,OAAO,CAMpE;AAED,sDAAsD;AACtD,MAAM,MAAM,SAAS,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;AAElE,MAAM,WAAW,sBAAsB;IACtC,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,SAAS,CAAC;CACnB;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,sBAAsB,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAOpI"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lightweight 2D collision: overlap tests for AABBs and circles, plus a resolver that stops
|
|
3
|
+
* a moving AABB at the edge of a solid tile instead of passing through it.
|
|
4
|
+
*
|
|
5
|
+
* This is not a rigid-body physics engine - out of scope for a tile/turn-first framework the
|
|
6
|
+
* way a full 3D engine is (see item 45's own caution) - it is the missing primitive behind
|
|
7
|
+
* `rpg.FreeMover`'s own doc comment: "both own position and animation only, nothing about
|
|
8
|
+
* collision or passability". A game wires this in itself; `FreeMover` stays unopinionated
|
|
9
|
+
* about whether a game wants tile solidity, circle-vs-circle hits, or no collision at all.
|
|
10
|
+
*/
|
|
11
|
+
export function aabbOverlap(a, b) {
|
|
12
|
+
return a.x < b.x + b.width && a.x + a.width > b.x && a.y < b.y + b.height && a.y + a.height > b.y;
|
|
13
|
+
}
|
|
14
|
+
export function circleOverlap(a, b) {
|
|
15
|
+
const dx = a.x - b.x;
|
|
16
|
+
const dy = a.y - b.y;
|
|
17
|
+
const r = a.radius + b.radius;
|
|
18
|
+
return dx * dx + dy * dy < r * r;
|
|
19
|
+
}
|
|
20
|
+
export function circleAabbOverlap(circle, box) {
|
|
21
|
+
const closestX = clamp(circle.x, box.x, box.x + box.width);
|
|
22
|
+
const closestY = clamp(circle.y, box.y, box.y + box.height);
|
|
23
|
+
const dx = circle.x - closestX;
|
|
24
|
+
const dy = circle.y - closestY;
|
|
25
|
+
return dx * dx + dy * dy < circle.radius * circle.radius;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Moves `box` by `(dx, dy)`, one axis at a time, stopping flush against the edge of the
|
|
29
|
+
* first solid tile it would otherwise enter rather than tunnelling through it at high
|
|
30
|
+
* speed. Axis separation (resolve the whole x move, then the whole y move against the
|
|
31
|
+
* already-resolved x) is the standard, simple choice for an axis-aligned tile grid - a full
|
|
32
|
+
* swept-AABB solver buys nothing here since every tile edge is already axis-aligned.
|
|
33
|
+
*/
|
|
34
|
+
export function resolveAabbAgainstTiles(box, dx, dy, options) {
|
|
35
|
+
const { tileSize, isSolid } = options;
|
|
36
|
+
if (!(tileSize > 0))
|
|
37
|
+
throw new Error('collision tileSize must be positive');
|
|
38
|
+
const x = sweepAxis(box.x, box.y, box.width, box.height, dx, tileSize, isSolid, true);
|
|
39
|
+
const y = sweepAxis(x, box.y, box.width, box.height, dy, tileSize, isSolid, false);
|
|
40
|
+
return { x, y };
|
|
41
|
+
}
|
|
42
|
+
function sweepAxis(x, y, width, height, delta, tileSize, isSolid, horizontal) {
|
|
43
|
+
if (delta === 0)
|
|
44
|
+
return horizontal ? x : y;
|
|
45
|
+
const position = horizontal ? x : y;
|
|
46
|
+
const size = horizontal ? width : height;
|
|
47
|
+
const target = position + delta;
|
|
48
|
+
//the perpendicular span of tiles the box's edge sweeps across while moving
|
|
49
|
+
const crossStart = Math.floor((horizontal ? y : x) / tileSize);
|
|
50
|
+
const crossEnd = Math.floor(((horizontal ? y + height : x + width) - 1e-6) / tileSize);
|
|
51
|
+
const solidAt = (leading, cross) => horizontal ? isSolid(leading, cross) : isSolid(cross, leading);
|
|
52
|
+
if (delta > 0) {
|
|
53
|
+
const fromCell = Math.floor((position + size - 1e-6) / tileSize);
|
|
54
|
+
const toCell = Math.floor((target + size - 1e-6) / tileSize);
|
|
55
|
+
for (let cell = fromCell + 1; cell <= toCell; cell++) {
|
|
56
|
+
for (let cross = crossStart; cross <= crossEnd; cross++) {
|
|
57
|
+
if (solidAt(cell, cross))
|
|
58
|
+
return cell * tileSize - size;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
const fromCell = Math.floor(position / tileSize);
|
|
64
|
+
const toCell = Math.floor(target / tileSize);
|
|
65
|
+
for (let cell = fromCell - 1; cell >= toCell; cell--) {
|
|
66
|
+
for (let cross = crossStart; cross <= crossEnd; cross++) {
|
|
67
|
+
if (solidAt(cell, cross))
|
|
68
|
+
return (cell + 1) * tileSize;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return target;
|
|
73
|
+
}
|
|
74
|
+
function clamp(value, min, max) {
|
|
75
|
+
return value < min ? min : value > max ? max : value;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=Collision.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Collision.js","sourceRoot":"","sources":["../../src/rpg/Collision.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAeH,MAAM,UAAU,WAAW,CAAC,CAAO,EAAE,CAAO;IAC3C,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;AACnG,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,CAAS,EAAE,CAAS;IACjD,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACrB,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACrB,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9B,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,MAAc,EAAE,GAAS;IAC1D,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,C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KAAK,IAAI,QAAQ,EAAE,KAAK,EAAE,EAAE,CAAC;gBACzD,IAAI,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC;oBAAE,OAAO,IAAI,GAAG,QAAQ,GAAG,IAAI,CAAC;YACzD,CAAC;QACF,CAAC;IACF,CAAC;SAAM,CAAC;QACP,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAAC,CAAC;QACjD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,QAAQ,CAAC,CAAC;QAC7C,KAAK,IAAI,IAAI,GAAG,QAAQ,GAAG,CAAC,EAAE,IAAI,IAAI,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC;YACtD,KAAK,IAAI,KAAK,GAAG,UAAU,EAAE,KAAK,IAAI,QAAQ,EAAE,KAAK,EAAE,EAAE,CAAC;gBACzD,IAAI,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC;oBAAE,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC;YACxD,CAAC;QACF,CAAC;IACF,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC;AAED,SAAS,KAAK,CAAC,KAAa,EAAE,GAAW,EAAE,GAAW;IACrD,OAAO,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { AnimatedSprite } from '../render/AnimatedSprite.ts';
|
|
2
|
+
export interface FreeMoverOptions {
|
|
3
|
+
/** world units crossed per second */
|
|
4
|
+
speed?: number;
|
|
5
|
+
/**
|
|
6
|
+
* An animation to play while moving, given the current facing in radians (0 along +x,
|
|
7
|
+
* increasing clockwise in screen space). Bucketing that into however many directions a
|
|
8
|
+
* sprite sheet actually has (4, 8, whatever) is the game's own job - this stays
|
|
9
|
+
* unopinionated about how many facings exist, the same way `GridMover`'s callbacks are
|
|
10
|
+
* unopinionated about animation names.
|
|
11
|
+
*/
|
|
12
|
+
walkAnimation?: (facing: number) => string;
|
|
13
|
+
/** an animation to play while standing still, given the current facing in radians */
|
|
14
|
+
idleAnimation?: (facing: number) => string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Movement not snapped to any grid: a float position plus a continuous facing angle, for a
|
|
18
|
+
* twin-stick shooter, a bullet-hell, or any top-down game whose player moves and aims freely
|
|
19
|
+
* rather than stepping cell to cell. `rpg.GridMover` is the tile-to-tile counterpart to this;
|
|
20
|
+
* both own position and animation only, nothing about collision or passability.
|
|
21
|
+
*/
|
|
22
|
+
export declare class FreeMover {
|
|
23
|
+
x: number;
|
|
24
|
+
y: number;
|
|
25
|
+
/** radians; unchanged while not moving, so a stopped unit keeps facing where it last went */
|
|
26
|
+
facing: number;
|
|
27
|
+
private sprite;
|
|
28
|
+
private speed;
|
|
29
|
+
private options;
|
|
30
|
+
private moving;
|
|
31
|
+
constructor(sprite: AnimatedSprite, x: number, y: number, options?: FreeMoverOptions);
|
|
32
|
+
get isMoving(): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Moves this frame along `(dx, dy)`, which need not be normalized - only its direction
|
|
35
|
+
* and whether it is nonzero matter, so a caller can pass a raw stick reading straight
|
|
36
|
+
* through. `(0, 0)` stops the unit in place, facing whichever way it was last moving.
|
|
37
|
+
*/
|
|
38
|
+
move(dx: number, dy: number, dt: number): void;
|
|
39
|
+
/** faces a direction without moving, the free-movement equivalent of `GridMover.turnTo` */
|
|
40
|
+
turnTo(dx: number, dy: number): void;
|
|
41
|
+
private place;
|
|
42
|
+
private playWalk;
|
|
43
|
+
private playIdle;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=FreeMover.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FreeMover.d.ts","sourceRoot":"","sources":["../../src/rpg/FreeMover.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAElE,MAAM,WAAW,gBAAgB;IAChC,qCAAqC;IACrC,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;IAE3C,qFAAqF;IACrF,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;CAC3C;AAED;;;;;GAKG;AACH,qBAAa,SAAS;IACrB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IAEV,6FAA6F;IAC7F,MAAM,SAAK;IAEX,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,OAAO,CAAmB;IAClC,OAAO,CAAC,MAAM,CAAS;IAEvB,YAAY,MAAM,EAAE,cAAc,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB,EASvF;IAED,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED;;;;OAIG;IACH,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAkB7C;IAED,2FAA2F;IAC3F,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAInC;IAED,OAAO,CAAC,KAAK;IAKb,OAAO,CAAC,QAAQ;IAKhB,OAAO,CAAC,QAAQ;CAIhB"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Movement not snapped to any grid: a float position plus a continuous facing angle, for a
|
|
3
|
+
* twin-stick shooter, a bullet-hell, or any top-down game whose player moves and aims freely
|
|
4
|
+
* rather than stepping cell to cell. `rpg.GridMover` is the tile-to-tile counterpart to this;
|
|
5
|
+
* both own position and animation only, nothing about collision or passability.
|
|
6
|
+
*/
|
|
7
|
+
export class FreeMover {
|
|
8
|
+
constructor(sprite, x, y, options = {}) {
|
|
9
|
+
/** radians; unchanged while not moving, so a stopped unit keeps facing where it last went */
|
|
10
|
+
this.facing = 0;
|
|
11
|
+
this.moving = false;
|
|
12
|
+
this.sprite = sprite;
|
|
13
|
+
this.x = x;
|
|
14
|
+
this.y = y;
|
|
15
|
+
this.speed = options.speed ?? 4;
|
|
16
|
+
this.options = options;
|
|
17
|
+
this.place();
|
|
18
|
+
this.playIdle();
|
|
19
|
+
}
|
|
20
|
+
get isMoving() {
|
|
21
|
+
return this.moving;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Moves this frame along `(dx, dy)`, which need not be normalized - only its direction
|
|
25
|
+
* and whether it is nonzero matter, so a caller can pass a raw stick reading straight
|
|
26
|
+
* through. `(0, 0)` stops the unit in place, facing whichever way it was last moving.
|
|
27
|
+
*/
|
|
28
|
+
move(dx, dy, dt) {
|
|
29
|
+
const length = Math.hypot(dx, dy);
|
|
30
|
+
if (length > 0) {
|
|
31
|
+
this.facing = Math.atan2(dy, dx);
|
|
32
|
+
this.x += (dx / length) * this.speed * dt;
|
|
33
|
+
this.y += (dy / length) * this.speed * dt;
|
|
34
|
+
if (!this.moving) {
|
|
35
|
+
this.moving = true;
|
|
36
|
+
this.playWalk();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
else if (this.moving) {
|
|
40
|
+
this.moving = false;
|
|
41
|
+
this.playIdle();
|
|
42
|
+
}
|
|
43
|
+
this.place();
|
|
44
|
+
this.sprite.update(dt);
|
|
45
|
+
}
|
|
46
|
+
/** faces a direction without moving, the free-movement equivalent of `GridMover.turnTo` */
|
|
47
|
+
turnTo(dx, dy) {
|
|
48
|
+
if (this.moving || (dx === 0 && dy === 0))
|
|
49
|
+
return;
|
|
50
|
+
this.facing = Math.atan2(dy, dx);
|
|
51
|
+
this.playIdle();
|
|
52
|
+
}
|
|
53
|
+
place() {
|
|
54
|
+
this.sprite.x = this.x;
|
|
55
|
+
this.sprite.y = this.y;
|
|
56
|
+
}
|
|
57
|
+
playWalk() {
|
|
58
|
+
const name = this.options.walkAnimation?.(this.facing);
|
|
59
|
+
if (name && this.sprite.has(name))
|
|
60
|
+
this.sprite.play(name);
|
|
61
|
+
}
|
|
62
|
+
playIdle() {
|
|
63
|
+
const name = this.options.idleAnimation?.(this.facing);
|
|
64
|
+
if (name && this.sprite.has(name))
|
|
65
|
+
this.sprite.play(name);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=FreeMover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FreeMover.js","sourceRoot":"","sources":["../../src/rpg/FreeMover.ts"],"names":[],"mappings":"AAmBA;;;;;GAKG;AACH,MAAM,OAAO,SAAS;IAYrB,YAAY,MAAsB,EAAE,CAAS,EAAE,CAAS,EAAE,OAAO,GAAqB,EAAE;QARxF,6FAA6F;QAC7F,WAAM,GAAG,CAAC,CAAC;QAKH,WAAM,GAAG,KAAK,CAAC;QAGtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QACX,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QACX,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,CAAC,CAAC;QAChC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvB,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,IAAI,CAAC,QAAQ,EAAE,CAAC;IACjB,CAAC;IAED,IAAI,QAAQ;QACX,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IAED;;;;OAIG;IACH,IAAI,CAAC,EAAU,EAAE,EAAU,EAAE,EAAU;QACtC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,CA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,aAAa,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvD,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3D,CAAC;IAEO,QAAQ;QACf,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvD,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3D,CAAC;CACD"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ruby's `Marshal` binary serialisation format (version 4.8, unchanged since Ruby 1.8) -
|
|
3
|
+
* the container `Game.rxdata` and every other RPG Maker XP/VX save are written in. This is
|
|
4
|
+
* format engineering, not RPG Maker's own code or content: the byte layout below is Ruby's
|
|
5
|
+
* own standard-library format, learned the ordinary way any undocumented format is, by
|
|
6
|
+
* reading real files in it. Nothing here knows what an RPG Maker save's own classes
|
|
7
|
+
* (`Game_Party`, `Game_Actor`) mean; it only turns the container's bytes into a faithful,
|
|
8
|
+
* generic JS shape a game can then interpret however it needs to. See CLAUDE.md's licence
|
|
9
|
+
* convention and ROADMAP.md item 100 for where this line sits.
|
|
10
|
+
*
|
|
11
|
+
* What decodes: nil, true, false, Fixnum, Bignum, Float, String, Symbol, Array, Hash
|
|
12
|
+
* (including one with a default value, read separately via `hashDefaultOf` rather than as a
|
|
13
|
+
* fake entry - a real Hash key equal to any string sentinel would otherwise collide with
|
|
14
|
+
* it), and Object (`o`, a class name plus its instance variables) - everything a plain-data
|
|
15
|
+
* save file actually needs. `_dump`/`_load` values
|
|
16
|
+
* (`u`) decode to their class name plus the opaque bytes their own `_load` would need,
|
|
17
|
+
* since that per-class binary layout is a second, undocumented format nested inside this
|
|
18
|
+
* one and out of scope the same way a container format never explains the media it holds.
|
|
19
|
+
* `marshal_dump`/`marshal_load` values (`U`) decode fully, since their payload is an
|
|
20
|
+
* ordinary Marshal value. Backreferences (`@`, `;`) resolve against the same link tables a
|
|
21
|
+
* real Ruby `Marshal.load` keeps, so a value referenced twice decodes to the same object
|
|
22
|
+
* twice rather than being duplicated.
|
|
23
|
+
*/
|
|
24
|
+
/** an RPG Maker (or any other) object: its class name and every instance variable, by name */
|
|
25
|
+
export interface RubyObject {
|
|
26
|
+
class: string;
|
|
27
|
+
ivars: Record<string, unknown>;
|
|
28
|
+
}
|
|
29
|
+
/** a value only `_dump`/`_load` on its own class could decode further - see the module doc */
|
|
30
|
+
export interface RubyUserDefined {
|
|
31
|
+
class: string;
|
|
32
|
+
raw: Uint8Array;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Marks a JS string as a Ruby Symbol rather than a String when encoding - `decodeMarshal`
|
|
36
|
+
* maps both to a plain JS string (the distinction rarely matters for reading a save back),
|
|
37
|
+
* but writing needs to know which one to produce. `RubyObject.ivars`' keys are always
|
|
38
|
+
* written as symbols regardless, since that half of the format has no other option.
|
|
39
|
+
*/
|
|
40
|
+
export declare class RubySymbol {
|
|
41
|
+
readonly name: string;
|
|
42
|
+
constructor(name: string);
|
|
43
|
+
}
|
|
44
|
+
/** the default value of a Hash decoded from `Hash.new(default)` (Marshal's `}` tag), if any */
|
|
45
|
+
export declare function hashDefaultOf(hash: Map<unknown, unknown>): unknown;
|
|
46
|
+
/** marks a Map for `encodeMarshal` to write back out as a `Hash.new(default)`, tag `}` */
|
|
47
|
+
export declare function withHashDefault(hash: Map<unknown, unknown>, defaultValue: unknown): Map<unknown, unknown>;
|
|
48
|
+
/** decodes one Marshal document (a whole `.rxdata` file, or any other Marshal dump) */
|
|
49
|
+
export declare function decodeMarshal(bytes: Uint8Array): unknown;
|
|
50
|
+
/**
|
|
51
|
+
* Encodes one Marshal document from the same shapes `decodeMarshal` produces: `null`,
|
|
52
|
+
* `boolean`, `number` (written as a Fixnum when it is a safe integer, a Float otherwise),
|
|
53
|
+
* `string` (a Marshal String, unless wrapped in `RubySymbol`), `Array`, `Map` (a Hash, key
|
|
54
|
+
* order preserved), and `RubyObject`.
|
|
55
|
+
*
|
|
56
|
+
* Every value is written fresh rather than reusing Ruby's own backreference scheme for a
|
|
57
|
+
* repeated string, symbol or object - valid Marshal either way, since backreferences are an
|
|
58
|
+
* optional size optimisation, not something a reader is required to produce. A save written
|
|
59
|
+
* this way is larger than Ruby's own `Marshal.dump` would make it, never incorrect.
|
|
60
|
+
* `RubyUserDefined` (a `_dump`/`_load` value) cannot be re-encoded at all, for the same
|
|
61
|
+
* reason `decodeMarshal` cannot interpret its bytes: that per-class binary layout is a
|
|
62
|
+
* second format this module was never taught.
|
|
63
|
+
*/
|
|
64
|
+
export declare function encodeMarshal(value: unknown): Uint8Array;
|
|
65
|
+
//# sourceMappingURL=Marshal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Marshal.d.ts","sourceRoot":"","sources":["../../src/rpg/Marshal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,8FAA8F;AAC9F,MAAM,WAAW,UAAU;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAED,8FAA8F;AAC9F,MAAM,WAAW,eAAe;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,UAAU,CAAC;CAChB;AAED;;;;;GAKG;AACH,qBAAa,UAAU;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,YAAY,IAAI,EAAE,MAAM,EAEvB;CACD;AASD,+FAA+F;AAC/F,wBAAgB,aAAa,CAAC,IAAI,EAAE,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,OAAO,CAElE;AAED,0FAA0F;AAC1F,wBAAgB,eAAe,CAAC,IAAI,EAAE,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,YAAY,EAAE,OAAO,GAAG,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAGzG;AAyND,uFAAuF;AACvF,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAExD;AAMD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,CAIxD"}
|