rpgmaker-mz-mcp 1.0.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/LICENSE +21 -0
- package/README.md +425 -0
- package/dist/events/commandBuilders.d.ts +405 -0
- package/dist/events/commandBuilders.d.ts.map +1 -0
- package/dist/events/commandBuilders.js +554 -0
- package/dist/events/commandBuilders.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +105 -0
- package/dist/index.js.map +1 -0
- package/dist/registry.d.ts +81 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +49 -0
- package/dist/registry.js.map +1 -0
- package/dist/tiles/autotile.d.ts +65 -0
- package/dist/tiles/autotile.d.ts.map +1 -0
- package/dist/tiles/autotile.js +201 -0
- package/dist/tiles/autotile.js.map +1 -0
- package/dist/tiles/catalog/dungeon.d.ts +16 -0
- package/dist/tiles/catalog/dungeon.d.ts.map +1 -0
- package/dist/tiles/catalog/dungeon.js +765 -0
- package/dist/tiles/catalog/dungeon.js.map +1 -0
- package/dist/tiles/catalog/index.d.ts +78 -0
- package/dist/tiles/catalog/index.d.ts.map +1 -0
- package/dist/tiles/catalog/index.js +115 -0
- package/dist/tiles/catalog/index.js.map +1 -0
- package/dist/tiles/catalog/inside.d.ts +16 -0
- package/dist/tiles/catalog/inside.d.ts.map +1 -0
- package/dist/tiles/catalog/inside.js +765 -0
- package/dist/tiles/catalog/inside.js.map +1 -0
- package/dist/tiles/catalog/outside.d.ts +16 -0
- package/dist/tiles/catalog/outside.d.ts.map +1 -0
- package/dist/tiles/catalog/outside.js +799 -0
- package/dist/tiles/catalog/outside.js.map +1 -0
- package/dist/tiles/catalog/overworld.d.ts +16 -0
- package/dist/tiles/catalog/overworld.d.ts.map +1 -0
- package/dist/tiles/catalog/overworld.js +585 -0
- package/dist/tiles/catalog/overworld.js.map +1 -0
- package/dist/tiles/catalog/sf.d.ts +16 -0
- package/dist/tiles/catalog/sf.d.ts.map +1 -0
- package/dist/tiles/catalog/sf.js +1313 -0
- package/dist/tiles/catalog/sf.js.map +1 -0
- package/dist/tiles/paint.d.ts +20 -0
- package/dist/tiles/paint.d.ts.map +1 -0
- package/dist/tiles/paint.js +65 -0
- package/dist/tiles/paint.js.map +1 -0
- package/dist/tiles/png.d.ts +11 -0
- package/dist/tiles/png.d.ts.map +1 -0
- package/dist/tiles/png.js +180 -0
- package/dist/tiles/png.js.map +1 -0
- package/dist/tiles/tileCodec.d.ts +95 -0
- package/dist/tiles/tileCodec.d.ts.map +1 -0
- package/dist/tiles/tileCodec.js +186 -0
- package/dist/tiles/tileCodec.js.map +1 -0
- package/dist/tiles/tileFlags.d.ts +98 -0
- package/dist/tiles/tileFlags.d.ts.map +1 -0
- package/dist/tiles/tileFlags.js +129 -0
- package/dist/tiles/tileFlags.js.map +1 -0
- package/dist/tiles/tilegeom.d.ts +29 -0
- package/dist/tiles/tilegeom.d.ts.map +1 -0
- package/dist/tiles/tilegeom.js +111 -0
- package/dist/tiles/tilegeom.js.map +1 -0
- package/dist/tiles/transparency.d.ts +22 -0
- package/dist/tiles/transparency.d.ts.map +1 -0
- package/dist/tiles/transparency.js +59 -0
- package/dist/tiles/transparency.js.map +1 -0
- package/dist/tools/actorTools.d.ts +48 -0
- package/dist/tools/actorTools.d.ts.map +1 -0
- package/dist/tools/actorTools.js +154 -0
- package/dist/tools/actorTools.js.map +1 -0
- package/dist/tools/allTools.d.ts +8 -0
- package/dist/tools/allTools.d.ts.map +1 -0
- package/dist/tools/allTools.js +56 -0
- package/dist/tools/allTools.js.map +1 -0
- package/dist/tools/assetTools.d.ts +113 -0
- package/dist/tools/assetTools.d.ts.map +1 -0
- package/dist/tools/assetTools.js +97 -0
- package/dist/tools/assetTools.js.map +1 -0
- package/dist/tools/batchTools.d.ts +3 -0
- package/dist/tools/batchTools.d.ts.map +1 -0
- package/dist/tools/batchTools.js +138 -0
- package/dist/tools/batchTools.js.map +1 -0
- package/dist/tools/battleTools.d.ts +72 -0
- package/dist/tools/battleTools.d.ts.map +1 -0
- package/dist/tools/battleTools.js +322 -0
- package/dist/tools/battleTools.js.map +1 -0
- package/dist/tools/catalogTools.d.ts +3 -0
- package/dist/tools/catalogTools.d.ts.map +1 -0
- package/dist/tools/catalogTools.js +134 -0
- package/dist/tools/catalogTools.js.map +1 -0
- package/dist/tools/classTools.d.ts +85 -0
- package/dist/tools/classTools.d.ts.map +1 -0
- package/dist/tools/classTools.js +279 -0
- package/dist/tools/classTools.js.map +1 -0
- package/dist/tools/commonEventTools.d.ts +32 -0
- package/dist/tools/commonEventTools.d.ts.map +1 -0
- package/dist/tools/commonEventTools.js +150 -0
- package/dist/tools/commonEventTools.js.map +1 -0
- package/dist/tools/eventCommandTools.d.ts +37 -0
- package/dist/tools/eventCommandTools.d.ts.map +1 -0
- package/dist/tools/eventCommandTools.js +893 -0
- package/dist/tools/eventCommandTools.js.map +1 -0
- package/dist/tools/eventPageTools.d.ts +112 -0
- package/dist/tools/eventPageTools.d.ts.map +1 -0
- package/dist/tools/eventPageTools.js +597 -0
- package/dist/tools/eventPageTools.js.map +1 -0
- package/dist/tools/itemTools.d.ts +82 -0
- package/dist/tools/itemTools.d.ts.map +1 -0
- package/dist/tools/itemTools.js +380 -0
- package/dist/tools/itemTools.js.map +1 -0
- package/dist/tools/listTools.d.ts +58 -0
- package/dist/tools/listTools.d.ts.map +1 -0
- package/dist/tools/listTools.js +99 -0
- package/dist/tools/listTools.js.map +1 -0
- package/dist/tools/mapTools.d.ts +270 -0
- package/dist/tools/mapTools.d.ts.map +1 -0
- package/dist/tools/mapTools.js +1066 -0
- package/dist/tools/mapTools.js.map +1 -0
- package/dist/tools/moveTools.d.ts +43 -0
- package/dist/tools/moveTools.d.ts.map +1 -0
- package/dist/tools/moveTools.js +240 -0
- package/dist/tools/moveTools.js.map +1 -0
- package/dist/tools/objectTools.d.ts +12 -0
- package/dist/tools/objectTools.d.ts.map +1 -0
- package/dist/tools/objectTools.js +221 -0
- package/dist/tools/objectTools.js.map +1 -0
- package/dist/tools/paintTools.d.ts +3 -0
- package/dist/tools/paintTools.d.ts.map +1 -0
- package/dist/tools/paintTools.js +134 -0
- package/dist/tools/paintTools.js.map +1 -0
- package/dist/tools/pluginScanTools.d.ts +22 -0
- package/dist/tools/pluginScanTools.d.ts.map +1 -0
- package/dist/tools/pluginScanTools.js +119 -0
- package/dist/tools/pluginScanTools.js.map +1 -0
- package/dist/tools/pluginTools.d.ts +11 -0
- package/dist/tools/pluginTools.d.ts.map +1 -0
- package/dist/tools/pluginTools.js +63 -0
- package/dist/tools/pluginTools.js.map +1 -0
- package/dist/tools/projectTools.d.ts +11 -0
- package/dist/tools/projectTools.d.ts.map +1 -0
- package/dist/tools/projectTools.js +74 -0
- package/dist/tools/projectTools.js.map +1 -0
- package/dist/tools/skillTools.d.ts +83 -0
- package/dist/tools/skillTools.d.ts.map +1 -0
- package/dist/tools/skillTools.js +369 -0
- package/dist/tools/skillTools.js.map +1 -0
- package/dist/tools/stateTools.d.ts +28 -0
- package/dist/tools/stateTools.d.ts.map +1 -0
- package/dist/tools/stateTools.js +161 -0
- package/dist/tools/stateTools.js.map +1 -0
- package/dist/tools/systemTools.d.ts +86 -0
- package/dist/tools/systemTools.d.ts.map +1 -0
- package/dist/tools/systemTools.js +342 -0
- package/dist/tools/systemTools.js.map +1 -0
- package/dist/tools/tileTools.d.ts +9 -0
- package/dist/tools/tileTools.d.ts.map +1 -0
- package/dist/tools/tileTools.js +34 -0
- package/dist/tools/tileTools.js.map +1 -0
- package/dist/tools/tileTransparency.d.ts +40 -0
- package/dist/tools/tileTransparency.d.ts.map +1 -0
- package/dist/tools/tileTransparency.js +156 -0
- package/dist/tools/tileTransparency.js.map +1 -0
- package/dist/tools/tilesetTools.d.ts +23 -0
- package/dist/tools/tilesetTools.d.ts.map +1 -0
- package/dist/tools/tilesetTools.js +209 -0
- package/dist/tools/tilesetTools.js.map +1 -0
- package/dist/tools/validationTools.d.ts +50 -0
- package/dist/tools/validationTools.d.ts.map +1 -0
- package/dist/tools/validationTools.js +229 -0
- package/dist/tools/validationTools.js.map +1 -0
- package/dist/utils/commit.d.ts +62 -0
- package/dist/utils/commit.d.ts.map +1 -0
- package/dist/utils/commit.js +119 -0
- package/dist/utils/commit.js.map +1 -0
- package/dist/utils/fileHandler.d.ts +49 -0
- package/dist/utils/fileHandler.d.ts.map +1 -0
- package/dist/utils/fileHandler.js +137 -0
- package/dist/utils/fileHandler.js.map +1 -0
- package/dist/utils/records.d.ts +8 -0
- package/dist/utils/records.d.ts.map +1 -0
- package/dist/utils/records.js +10 -0
- package/dist/utils/records.js.map +1 -0
- package/dist/utils/types.d.ts +465 -0
- package/dist/utils/types.d.ts.map +1 -0
- package/dist/utils/types.js +5 -0
- package/dist/utils/types.js.map +1 -0
- package/dist/validation/assets.d.ts +53 -0
- package/dist/validation/assets.d.ts.map +1 -0
- package/dist/validation/assets.js +198 -0
- package/dist/validation/assets.js.map +1 -0
- package/dist/validation/createRefs.d.ts +37 -0
- package/dist/validation/createRefs.d.ts.map +1 -0
- package/dist/validation/createRefs.js +89 -0
- package/dist/validation/createRefs.js.map +1 -0
- package/dist/validation/eventCommands.d.ts +70 -0
- package/dist/validation/eventCommands.d.ts.map +1 -0
- package/dist/validation/eventCommands.js +273 -0
- package/dist/validation/eventCommands.js.map +1 -0
- package/dist/validation/gate.d.ts +56 -0
- package/dist/validation/gate.d.ts.map +1 -0
- package/dist/validation/gate.js +50 -0
- package/dist/validation/gate.js.map +1 -0
- package/dist/validation/moveCommands.d.ts +31 -0
- package/dist/validation/moveCommands.d.ts.map +1 -0
- package/dist/validation/moveCommands.js +123 -0
- package/dist/validation/moveCommands.js.map +1 -0
- package/dist/validation/pluginCommands.d.ts +83 -0
- package/dist/validation/pluginCommands.d.ts.map +1 -0
- package/dist/validation/pluginCommands.js +134 -0
- package/dist/validation/pluginCommands.js.map +1 -0
- package/dist/validation/pluginManifest.d.ts +67 -0
- package/dist/validation/pluginManifest.d.ts.map +1 -0
- package/dist/validation/pluginManifest.js +199 -0
- package/dist/validation/pluginManifest.js.map +1 -0
- package/dist/validation/references.d.ts +57 -0
- package/dist/validation/references.d.ts.map +1 -0
- package/dist/validation/references.js +314 -0
- package/dist/validation/references.js.map +1 -0
- package/package.json +67 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RPG Maker MZ tile-flag codec.
|
|
3
|
+
*
|
|
4
|
+
* Every tileset carries a parallel `flags[]` array — one bit-packed word per
|
|
5
|
+
* tile id (index === tile id, length 8192) — that the *editor* sets and the
|
|
6
|
+
* *engine* reads to decide movement and behaviour. None of it is legible from
|
|
7
|
+
* the integer alone, so this module decodes a flag word into a curated view
|
|
8
|
+
* (4-direction passability, terrain tag, ladder/bush/counter/damage) and
|
|
9
|
+
* reproduces the engine's layered passage logic for a stack of tiles.
|
|
10
|
+
*
|
|
11
|
+
* All functions are pure (no I/O). Bit meanings and the passage algorithm are
|
|
12
|
+
* taken verbatim from `rmmz_objects.js` `Game_Map` (corescript v1.7.0):
|
|
13
|
+
* - passage bits: down 0x01, left 0x02, right 0x04, up 0x08 (SET = blocked)
|
|
14
|
+
* - 0x10 [*] "star": drawn above the character, no effect on passage
|
|
15
|
+
* - 0x20 ladder, 0x40 bush, 0x80 counter, 0x100 damage floor
|
|
16
|
+
* - terrain tag: flag >> 12 (0–7)
|
|
17
|
+
*/
|
|
18
|
+
/** Passage bit per compass direction. A SET bit means "blocked" that way. */
|
|
19
|
+
export declare const PASSAGE_BITS: {
|
|
20
|
+
readonly down: 1;
|
|
21
|
+
readonly left: 2;
|
|
22
|
+
readonly right: 4;
|
|
23
|
+
readonly up: 8;
|
|
24
|
+
};
|
|
25
|
+
export declare const STAR_BIT = 16;
|
|
26
|
+
export declare const LADDER_BIT = 32;
|
|
27
|
+
export declare const BUSH_BIT = 64;
|
|
28
|
+
export declare const COUNTER_BIT = 128;
|
|
29
|
+
export declare const DAMAGE_BIT = 256;
|
|
30
|
+
export type Direction = keyof typeof PASSAGE_BITS;
|
|
31
|
+
/** Per-direction passability — `true` means a character can walk off the tile that way. */
|
|
32
|
+
export interface Passability {
|
|
33
|
+
down: boolean;
|
|
34
|
+
left: boolean;
|
|
35
|
+
right: boolean;
|
|
36
|
+
up: boolean;
|
|
37
|
+
}
|
|
38
|
+
/** A decoded single-tile flag word — the curated view `get_tile_flags` returns. */
|
|
39
|
+
export interface TileFlags {
|
|
40
|
+
/** The raw bit-packed flag word. */
|
|
41
|
+
raw: number;
|
|
42
|
+
/**
|
|
43
|
+
* Passability read from this one tile in isolation (SET passage bit → not
|
|
44
|
+
* passable that way). Note the engine resolves the *cell's* passability by
|
|
45
|
+
* layering the stacked tiles — see `layeredPassability`.
|
|
46
|
+
*/
|
|
47
|
+
passage: Passability;
|
|
48
|
+
/** [*] "star": tile drawn above the character; has no effect on cell passage. */
|
|
49
|
+
star: boolean;
|
|
50
|
+
ladder: boolean;
|
|
51
|
+
bush: boolean;
|
|
52
|
+
counter: boolean;
|
|
53
|
+
/** Damage floor — standing on it hurts. */
|
|
54
|
+
damage: boolean;
|
|
55
|
+
/** Terrain tag 0–7 (0 = none) — a designer-assigned marker read by events/plugins. */
|
|
56
|
+
terrainTag: number;
|
|
57
|
+
}
|
|
58
|
+
/** Decode one tile's flag word into the curated single-tile view. */
|
|
59
|
+
export declare function decodeFlags(flag: number): TileFlags;
|
|
60
|
+
/**
|
|
61
|
+
* Reproduce `Game_Map.checkPassage`: walk a cell's stacked tile flags (upper
|
|
62
|
+
* layer first) and let the first non-star tile decide. A `[*]` star tile has no
|
|
63
|
+
* effect and is skipped; if every tile is a star (or the stack is empty), the
|
|
64
|
+
* cell is impassable — matching the engine's `return false` fall-through.
|
|
65
|
+
*
|
|
66
|
+
* @param stackFlags flag words of the stacked tiles, upper-layer-first.
|
|
67
|
+
* @param bit one of `PASSAGE_BITS`.
|
|
68
|
+
*/
|
|
69
|
+
export declare function checkPassage(stackFlags: number[], bit: number): boolean;
|
|
70
|
+
/** Layered 4-direction passability for a cell, from its stacked tile flags (upper-first). */
|
|
71
|
+
export declare function layeredPassability(stackFlags: number[]): Passability;
|
|
72
|
+
/**
|
|
73
|
+
* Reproduce `Game_Map.terrainTag`: the terrain tag of the first stacked tile
|
|
74
|
+
* (upper-layer-first) that carries a non-zero tag, else 0.
|
|
75
|
+
*/
|
|
76
|
+
export declare function layeredTerrainTag(stackFlags: number[]): number;
|
|
77
|
+
/** A partial update to a tile's curated flags — only the named fields change. */
|
|
78
|
+
export interface FlagUpdate {
|
|
79
|
+
/** Walkability per direction (`true` = walkable). Only the given directions change. */
|
|
80
|
+
passage?: Partial<Passability>;
|
|
81
|
+
star?: boolean;
|
|
82
|
+
ladder?: boolean;
|
|
83
|
+
bush?: boolean;
|
|
84
|
+
counter?: boolean;
|
|
85
|
+
damage?: boolean;
|
|
86
|
+
/** Terrain tag 0–7. */
|
|
87
|
+
terrainTag?: number;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Merge a partial flag update onto an existing flag word — the inverse of
|
|
91
|
+
* `decodeFlags`, but *non-destructive*: only the bits named in `update` change,
|
|
92
|
+
* so any reserved/unknown bits and any field the caller omits are preserved.
|
|
93
|
+
* `passage` is expressed as walkability (`true` = walkable that way) and inverted
|
|
94
|
+
* to the engine's blocked-bit convention (a SET passage bit means *blocked*).
|
|
95
|
+
* Throws on a terrain tag outside 0–7.
|
|
96
|
+
*/
|
|
97
|
+
export declare function encodeFlags(current: number, update: FlagUpdate): number;
|
|
98
|
+
//# sourceMappingURL=tileFlags.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tileFlags.d.ts","sourceRoot":"","sources":["../../src/tiles/tileFlags.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,6EAA6E;AAC7E,eAAO,MAAM,YAAY;;;;;CAKf,CAAC;AAEX,eAAO,MAAM,QAAQ,KAAO,CAAC;AAC7B,eAAO,MAAM,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OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,uBAAuB;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAOD;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,MAAM,CAsBvE"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RPG Maker MZ tile-flag codec.
|
|
3
|
+
*
|
|
4
|
+
* Every tileset carries a parallel `flags[]` array — one bit-packed word per
|
|
5
|
+
* tile id (index === tile id, length 8192) — that the *editor* sets and the
|
|
6
|
+
* *engine* reads to decide movement and behaviour. None of it is legible from
|
|
7
|
+
* the integer alone, so this module decodes a flag word into a curated view
|
|
8
|
+
* (4-direction passability, terrain tag, ladder/bush/counter/damage) and
|
|
9
|
+
* reproduces the engine's layered passage logic for a stack of tiles.
|
|
10
|
+
*
|
|
11
|
+
* All functions are pure (no I/O). Bit meanings and the passage algorithm are
|
|
12
|
+
* taken verbatim from `rmmz_objects.js` `Game_Map` (corescript v1.7.0):
|
|
13
|
+
* - passage bits: down 0x01, left 0x02, right 0x04, up 0x08 (SET = blocked)
|
|
14
|
+
* - 0x10 [*] "star": drawn above the character, no effect on passage
|
|
15
|
+
* - 0x20 ladder, 0x40 bush, 0x80 counter, 0x100 damage floor
|
|
16
|
+
* - terrain tag: flag >> 12 (0–7)
|
|
17
|
+
*/
|
|
18
|
+
/** Passage bit per compass direction. A SET bit means "blocked" that way. */
|
|
19
|
+
export const PASSAGE_BITS = {
|
|
20
|
+
down: 0x01,
|
|
21
|
+
left: 0x02,
|
|
22
|
+
right: 0x04,
|
|
23
|
+
up: 0x08,
|
|
24
|
+
};
|
|
25
|
+
export const STAR_BIT = 0x10;
|
|
26
|
+
export const LADDER_BIT = 0x20;
|
|
27
|
+
export const BUSH_BIT = 0x40;
|
|
28
|
+
export const COUNTER_BIT = 0x80;
|
|
29
|
+
export const DAMAGE_BIT = 0x100;
|
|
30
|
+
/** Decode one tile's flag word into the curated single-tile view. */
|
|
31
|
+
export function decodeFlags(flag) {
|
|
32
|
+
return {
|
|
33
|
+
raw: flag,
|
|
34
|
+
passage: {
|
|
35
|
+
down: (flag & PASSAGE_BITS.down) === 0,
|
|
36
|
+
left: (flag & PASSAGE_BITS.left) === 0,
|
|
37
|
+
right: (flag & PASSAGE_BITS.right) === 0,
|
|
38
|
+
up: (flag & PASSAGE_BITS.up) === 0,
|
|
39
|
+
},
|
|
40
|
+
star: (flag & STAR_BIT) !== 0,
|
|
41
|
+
ladder: (flag & LADDER_BIT) !== 0,
|
|
42
|
+
bush: (flag & BUSH_BIT) !== 0,
|
|
43
|
+
counter: (flag & COUNTER_BIT) !== 0,
|
|
44
|
+
damage: (flag & DAMAGE_BIT) !== 0,
|
|
45
|
+
terrainTag: flag >> 12,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Reproduce `Game_Map.checkPassage`: walk a cell's stacked tile flags (upper
|
|
50
|
+
* layer first) and let the first non-star tile decide. A `[*]` star tile has no
|
|
51
|
+
* effect and is skipped; if every tile is a star (or the stack is empty), the
|
|
52
|
+
* cell is impassable — matching the engine's `return false` fall-through.
|
|
53
|
+
*
|
|
54
|
+
* @param stackFlags flag words of the stacked tiles, upper-layer-first.
|
|
55
|
+
* @param bit one of `PASSAGE_BITS`.
|
|
56
|
+
*/
|
|
57
|
+
export function checkPassage(stackFlags, bit) {
|
|
58
|
+
for (const flag of stackFlags) {
|
|
59
|
+
if ((flag & STAR_BIT) !== 0)
|
|
60
|
+
continue; // [*] no effect on passage
|
|
61
|
+
return (flag & bit) === 0; // first non-star tile decides
|
|
62
|
+
}
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
/** Layered 4-direction passability for a cell, from its stacked tile flags (upper-first). */
|
|
66
|
+
export function layeredPassability(stackFlags) {
|
|
67
|
+
return {
|
|
68
|
+
down: checkPassage(stackFlags, PASSAGE_BITS.down),
|
|
69
|
+
left: checkPassage(stackFlags, PASSAGE_BITS.left),
|
|
70
|
+
right: checkPassage(stackFlags, PASSAGE_BITS.right),
|
|
71
|
+
up: checkPassage(stackFlags, PASSAGE_BITS.up),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Reproduce `Game_Map.terrainTag`: the terrain tag of the first stacked tile
|
|
76
|
+
* (upper-layer-first) that carries a non-zero tag, else 0.
|
|
77
|
+
*/
|
|
78
|
+
export function layeredTerrainTag(stackFlags) {
|
|
79
|
+
for (const flag of stackFlags) {
|
|
80
|
+
const tag = flag >> 12;
|
|
81
|
+
if (tag > 0)
|
|
82
|
+
return tag;
|
|
83
|
+
}
|
|
84
|
+
return 0;
|
|
85
|
+
}
|
|
86
|
+
// --- encode (the write side, inverse of decodeFlags) ------------------------
|
|
87
|
+
const TERRAIN_TAG_SHIFT = 12;
|
|
88
|
+
const TERRAIN_TAG_MASK = 0x7 << TERRAIN_TAG_SHIFT;
|
|
89
|
+
/** Set or clear a single bit in a word. */
|
|
90
|
+
function withBit(word, bit, on) {
|
|
91
|
+
return on ? word | bit : word & ~bit;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Merge a partial flag update onto an existing flag word — the inverse of
|
|
95
|
+
* `decodeFlags`, but *non-destructive*: only the bits named in `update` change,
|
|
96
|
+
* so any reserved/unknown bits and any field the caller omits are preserved.
|
|
97
|
+
* `passage` is expressed as walkability (`true` = walkable that way) and inverted
|
|
98
|
+
* to the engine's blocked-bit convention (a SET passage bit means *blocked*).
|
|
99
|
+
* Throws on a terrain tag outside 0–7.
|
|
100
|
+
*/
|
|
101
|
+
export function encodeFlags(current, update) {
|
|
102
|
+
let word = current;
|
|
103
|
+
if (update.passage) {
|
|
104
|
+
for (const dir of Object.keys(PASSAGE_BITS)) {
|
|
105
|
+
const walkable = update.passage[dir];
|
|
106
|
+
if (walkable !== undefined) {
|
|
107
|
+
word = withBit(word, PASSAGE_BITS[dir], !walkable); // SET bit = blocked
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (update.star !== undefined)
|
|
112
|
+
word = withBit(word, STAR_BIT, update.star);
|
|
113
|
+
if (update.ladder !== undefined)
|
|
114
|
+
word = withBit(word, LADDER_BIT, update.ladder);
|
|
115
|
+
if (update.bush !== undefined)
|
|
116
|
+
word = withBit(word, BUSH_BIT, update.bush);
|
|
117
|
+
if (update.counter !== undefined)
|
|
118
|
+
word = withBit(word, COUNTER_BIT, update.counter);
|
|
119
|
+
if (update.damage !== undefined)
|
|
120
|
+
word = withBit(word, DAMAGE_BIT, update.damage);
|
|
121
|
+
if (update.terrainTag !== undefined) {
|
|
122
|
+
if (!Number.isInteger(update.terrainTag) || update.terrainTag < 0 || update.terrainTag > 7) {
|
|
123
|
+
throw new Error(`terrainTag must be an integer 0–7 (got ${update.terrainTag})`);
|
|
124
|
+
}
|
|
125
|
+
word = (word & ~TERRAIN_TAG_MASK) | (update.terrainTag << TERRAIN_TAG_SHIFT);
|
|
126
|
+
}
|
|
127
|
+
return word;
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=tileFlags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tileFlags.js","sourceRoot":"","sources":["../../src/tiles/tileFlags.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,6EAA6E;AAC7E,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;IACV,KAAK,EAAE,IAAI;IACX,EAAE,EAAE,IAAI;CACA,CAAC;AAEX,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,CAAC;AAC7B,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC;AAC/B,MAAM,CAAC,MAAM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29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RPG Maker MZ tileset-sheet geometry: where, in pixels, each tile's
|
|
3
|
+
* representative sample lives on its sheet PNG — the `src/` counterpart of
|
|
4
|
+
* `.claude/skills/tileset-catalog/scripts/tilegeom.mjs`.
|
|
5
|
+
*
|
|
6
|
+
* Mirrors `Tilemap.prototype._addAutotile` / `_addNormalTile` from rmmz_core.js
|
|
7
|
+
* (v1.7.0), restricted to the *static shape-0* (fully-surrounded) appearance of
|
|
8
|
+
* each autotile kind — the exact tile a paint command places as an autotile base,
|
|
9
|
+
* and the interior fill of a tiled field — plus the flat-sheet grid formula.
|
|
10
|
+
* Tiles are 48px; autotile quarters are 24px. Pure integer arithmetic.
|
|
11
|
+
*/
|
|
12
|
+
export declare const TILE = 48;
|
|
13
|
+
/** First autotile kind on each A-sheet: A1=0, A2=16, A3=48, A4=80. */
|
|
14
|
+
export declare const BASE_KIND: Record<'A1' | 'A2' | 'A3' | 'A4', number>;
|
|
15
|
+
/**
|
|
16
|
+
* For an autotile `kind`, return the top-left pixel `[sx, sy]` of each 24px
|
|
17
|
+
* source quarter (TL, TR, BL, BR) for its shape-0 sample. Reproduces the engine's
|
|
18
|
+
* bx/by block math for A1–A4.
|
|
19
|
+
*/
|
|
20
|
+
export declare function autotileSample(kind: number): [number, number][];
|
|
21
|
+
/**
|
|
22
|
+
* Flat-sheet (A5/B–E) tile → top-left pixel of its 48px cell. Mirrors
|
|
23
|
+
* `_addNormalTile`: each sheet is two side-by-side 8-wide half-columns.
|
|
24
|
+
*/
|
|
25
|
+
export declare function flatSample(localIndex: number): {
|
|
26
|
+
sx: number;
|
|
27
|
+
sy: number;
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=tilegeom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tilegeom.d.ts","sourceRoot":"","sources":["../../src/tiles/tilegeom.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,eAAO,MAAM,IAAI,KAAK,CAAC;AAwBvB,sEAAsE;AACtE,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,EAAE,MAAM,CAK/D,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CA8C/D;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAIzE"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RPG Maker MZ tileset-sheet geometry: where, in pixels, each tile's
|
|
3
|
+
* representative sample lives on its sheet PNG — the `src/` counterpart of
|
|
4
|
+
* `.claude/skills/tileset-catalog/scripts/tilegeom.mjs`.
|
|
5
|
+
*
|
|
6
|
+
* Mirrors `Tilemap.prototype._addAutotile` / `_addNormalTile` from rmmz_core.js
|
|
7
|
+
* (v1.7.0), restricted to the *static shape-0* (fully-surrounded) appearance of
|
|
8
|
+
* each autotile kind — the exact tile a paint command places as an autotile base,
|
|
9
|
+
* and the interior fill of a tiled field — plus the flat-sheet grid formula.
|
|
10
|
+
* Tiles are 48px; autotile quarters are 24px. Pure integer arithmetic.
|
|
11
|
+
*/
|
|
12
|
+
export const TILE = 48;
|
|
13
|
+
const Q = TILE / 2; // 24 — autotile quarter size
|
|
14
|
+
// Shape-0 (all-neighbours-connected) quarter source coords [TL,TR,BL,BR], in
|
|
15
|
+
// 24px units, from the engine's *_AUTOTILE_TABLE first entries.
|
|
16
|
+
const FLOOR0 = [
|
|
17
|
+
[2, 4],
|
|
18
|
+
[1, 4],
|
|
19
|
+
[2, 3],
|
|
20
|
+
[1, 3],
|
|
21
|
+
];
|
|
22
|
+
const WALL0 = [
|
|
23
|
+
[2, 2],
|
|
24
|
+
[1, 2],
|
|
25
|
+
[2, 1],
|
|
26
|
+
[1, 1],
|
|
27
|
+
];
|
|
28
|
+
const WATERFALL0 = [
|
|
29
|
+
[2, 0],
|
|
30
|
+
[1, 0],
|
|
31
|
+
[2, 1],
|
|
32
|
+
[1, 1],
|
|
33
|
+
];
|
|
34
|
+
/** First autotile kind on each A-sheet: A1=0, A2=16, A3=48, A4=80. */
|
|
35
|
+
export const BASE_KIND = {
|
|
36
|
+
A1: 0,
|
|
37
|
+
A2: 16,
|
|
38
|
+
A3: 48,
|
|
39
|
+
A4: 80,
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* For an autotile `kind`, return the top-left pixel `[sx, sy]` of each 24px
|
|
43
|
+
* source quarter (TL, TR, BL, BR) for its shape-0 sample. Reproduces the engine's
|
|
44
|
+
* bx/by block math for A1–A4.
|
|
45
|
+
*/
|
|
46
|
+
export function autotileSample(kind) {
|
|
47
|
+
const tx = kind % 8;
|
|
48
|
+
const ty = Math.floor(kind / 8);
|
|
49
|
+
let bx = 0;
|
|
50
|
+
let by = 0;
|
|
51
|
+
let table = FLOOR0;
|
|
52
|
+
if (kind < 16) {
|
|
53
|
+
// A1 (animated water / waterfall). Static frame 0 (waterSurfaceIndex 0).
|
|
54
|
+
if (kind === 0) {
|
|
55
|
+
bx = 0;
|
|
56
|
+
by = 0;
|
|
57
|
+
}
|
|
58
|
+
else if (kind === 1) {
|
|
59
|
+
bx = 0;
|
|
60
|
+
by = 3;
|
|
61
|
+
}
|
|
62
|
+
else if (kind === 2) {
|
|
63
|
+
bx = 6;
|
|
64
|
+
by = 0;
|
|
65
|
+
}
|
|
66
|
+
else if (kind === 3) {
|
|
67
|
+
bx = 6;
|
|
68
|
+
by = 3;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
bx = Math.floor(tx / 4) * 8;
|
|
72
|
+
by = ty * 6 + (Math.floor(tx / 2) % 2) * 3;
|
|
73
|
+
if (kind % 2 === 0) {
|
|
74
|
+
// water: bx += waterSurfaceIndex(0)
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
bx += 6; // waterfall
|
|
78
|
+
table = WATERFALL0;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else if (kind < 48) {
|
|
83
|
+
// A2 ground: bx = tx*2, by = (ty-2)*3
|
|
84
|
+
bx = tx * 2;
|
|
85
|
+
by = (ty - 2) * 3;
|
|
86
|
+
}
|
|
87
|
+
else if (kind < 80) {
|
|
88
|
+
// A3 buildings/walls: bx = tx*2, by = (ty-6)*2, WALL table
|
|
89
|
+
bx = tx * 2;
|
|
90
|
+
by = (ty - 6) * 2;
|
|
91
|
+
table = WALL0;
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
// A4 walls: alternating wall-top (even ty, FLOOR) / wall-side (odd ty, WALL)
|
|
95
|
+
bx = tx * 2;
|
|
96
|
+
by = Math.floor((ty - 10) * 2.5 + (ty % 2 === 1 ? 0.5 : 0));
|
|
97
|
+
if (ty % 2 === 1)
|
|
98
|
+
table = WALL0;
|
|
99
|
+
}
|
|
100
|
+
return table.map(([qsx, qsy]) => [(bx * 2 + qsx) * Q, (by * 2 + qsy) * Q]);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Flat-sheet (A5/B–E) tile → top-left pixel of its 48px cell. Mirrors
|
|
104
|
+
* `_addNormalTile`: each sheet is two side-by-side 8-wide half-columns.
|
|
105
|
+
*/
|
|
106
|
+
export function flatSample(localIndex) {
|
|
107
|
+
const col = (Math.floor(localIndex / 128) % 2) * 8 + (localIndex % 8);
|
|
108
|
+
const row = Math.floor((localIndex % 256) / 8) % 16;
|
|
109
|
+
return { sx: col * TILE, sy: row * TILE };
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=tilegeom.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tilegeom.js","sourceRoot":"","sources":["../../src/tiles/tilegeom.ts"],"names":[],"mappings":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EAA6E;QAC7E,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QACZ,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,GAAG,GAAG,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5D,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC;YAAE,KAAK,GAAG,KAAK,CAAC;IAClC,CAAC;IACD,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAqB,CAAC,CAAC;AACjG,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,UAAkB;IAC3C,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;IACtE,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,UAAU,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;IACpD,OAAO,EAAE,EAAE,EAAE,GAAG,GAAG,IAAI,EAAE,EAAE,EAAE,GAAG,GAAG,IAAI,EAAE,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tile transparency classification (pure, no I/O). Given a decoded tileset sheet
|
|
3
|
+
* and a tile's slot role + local index, measure how much of the tile's
|
|
4
|
+
* *representative sample* is transparent (alpha below opaque) — the signal behind
|
|
5
|
+
* the catalog's "needs a base" flag and the paint-time layer-0 warning.
|
|
6
|
+
*
|
|
7
|
+
* Why shape-0 for autotiles: shape-0 is the interior fill of a tiled field, so
|
|
8
|
+
* "is shape-0 transparent?" is exactly "does a field of this tile leave the map's
|
|
9
|
+
* void showing?". Flat tiles have no shape — the whole 48px cell is the sample.
|
|
10
|
+
*/
|
|
11
|
+
import { DecodedImage } from './png.js';
|
|
12
|
+
/** A tileset sheet's slot role (the 9 `tilesetNames` positions). */
|
|
13
|
+
export type TileRole = 'A1' | 'A2' | 'A3' | 'A4' | 'A5' | 'B' | 'C' | 'D' | 'E';
|
|
14
|
+
/**
|
|
15
|
+
* The fraction (0–1) of a tile's representative sample that is transparent.
|
|
16
|
+
* Returns 0 when the tile's sample falls entirely outside the image (a sheet
|
|
17
|
+
* smaller than the catalog expects) — treated as "no measurable transparency".
|
|
18
|
+
*/
|
|
19
|
+
export declare function tileTransparentFraction(img: DecodedImage, role: TileRole, localIndex: number): number;
|
|
20
|
+
/** Whether a tile's transparent fraction is high enough that it needs a base. */
|
|
21
|
+
export declare function needsBase(fraction: number): boolean;
|
|
22
|
+
//# sourceMappingURL=transparency.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transparency.d.ts","sourceRoot":"","sources":["../../src/tiles/transparency.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAKxC,oEAAoE;AACpE,MAAM,MAAM,QAAQ,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAqChF;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,YAAY,EACjB,IAAI,EAAE,QAAQ,EACd,UAAU,EAAE,MAAM,GACjB,MAAM,CAiBR;AAED,iFAAiF;AACjF,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEnD"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { TILE, BASE_KIND, autotileSample, flatSample } from './tilegeom.js';
|
|
2
|
+
const Q = TILE / 2; // 24 — autotile quarter size
|
|
3
|
+
/** A pixel with alpha below this counts as transparent. */
|
|
4
|
+
const ALPHA_OPAQUE_MIN = 128;
|
|
5
|
+
/**
|
|
6
|
+
* A tile "needs a base" when more than this fraction of its sample is
|
|
7
|
+
* transparent. A small non-zero cutoff ignores stray anti-aliasing at a flat
|
|
8
|
+
* tile's edge while still catching any real see-through interior.
|
|
9
|
+
*/
|
|
10
|
+
const NEEDS_BASE_CUTOFF = 0.02;
|
|
11
|
+
function isAutotileRole(role) {
|
|
12
|
+
return role === 'A1' || role === 'A2' || role === 'A3' || role === 'A4';
|
|
13
|
+
}
|
|
14
|
+
/** Accumulate {transparent, total} pixels over a rectangle, clamped to the image. */
|
|
15
|
+
function sampleRect(img, sx, sy, w, h) {
|
|
16
|
+
let transparent = 0;
|
|
17
|
+
let total = 0;
|
|
18
|
+
for (let y = sy; y < sy + h; y++) {
|
|
19
|
+
if (y < 0 || y >= img.height)
|
|
20
|
+
continue;
|
|
21
|
+
for (let x = sx; x < sx + w; x++) {
|
|
22
|
+
if (x < 0 || x >= img.width)
|
|
23
|
+
continue;
|
|
24
|
+
total++;
|
|
25
|
+
if (img.data[(y * img.width + x) * 4 + 3] < ALPHA_OPAQUE_MIN)
|
|
26
|
+
transparent++;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return { transparent, total };
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The fraction (0–1) of a tile's representative sample that is transparent.
|
|
33
|
+
* Returns 0 when the tile's sample falls entirely outside the image (a sheet
|
|
34
|
+
* smaller than the catalog expects) — treated as "no measurable transparency".
|
|
35
|
+
*/
|
|
36
|
+
export function tileTransparentFraction(img, role, localIndex) {
|
|
37
|
+
let transparent = 0;
|
|
38
|
+
let total = 0;
|
|
39
|
+
if (isAutotileRole(role)) {
|
|
40
|
+
const kind = BASE_KIND[role] + localIndex;
|
|
41
|
+
for (const [sx, sy] of autotileSample(kind)) {
|
|
42
|
+
const r = sampleRect(img, sx, sy, Q, Q);
|
|
43
|
+
transparent += r.transparent;
|
|
44
|
+
total += r.total;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
const { sx, sy } = flatSample(localIndex);
|
|
49
|
+
const r = sampleRect(img, sx, sy, TILE, TILE);
|
|
50
|
+
transparent += r.transparent;
|
|
51
|
+
total += r.total;
|
|
52
|
+
}
|
|
53
|
+
return total ? transparent / total : 0;
|
|
54
|
+
}
|
|
55
|
+
/** Whether a tile's transparent fraction is high enough that it needs a base. */
|
|
56
|
+
export function needsBase(fraction) {
|
|
57
|
+
return fraction > NEEDS_BASE_CUTOFF;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=transparency.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transparency.js","sourceRoot":"","sources":["../../src/tiles/transparency.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE5E,MAAM,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,6BAA6B;AAKjD,2DAA2D;AAC3D,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAE7B;;;;GAIG;AACH,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAE/B,SAAS,cAAc,CAAC,IAAc;IACpC,OAAO,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,IAAI,CAAC;AAC1E,CAAC;AAED,qFAAqF;AACrF,SAAS,UAAU,CACjB,GAAiB,EACjB,EAAU,EACV,EAAU,EACV,CAAS,EACT,CAAS;IAET,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,IAAI,CAA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AAU,CAAC,UAAU,CAAC,CAAC;QAC1C,MAAM,CAAC,GAAG,UAAU,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QAC9C,WAAW,IAAI,CAAC,CAAC,WAAW,CAAC;QAC7B,KAAK,IAAI,CAAC,CAAC,KAAK,CAAC;IACnB,CAAC;IACD,OAAO,KAAK,CAAC,CAAC,CAAC,WAAW,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACzC,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,SAAS,CAAC,QAAgB;IACxC,OAAO,QAAQ,GAAG,iBAAiB,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Actor } from '../utils/types.js';
|
|
2
|
+
import { ToolDefinition } from '../registry.js';
|
|
3
|
+
/**
|
|
4
|
+
* A blank actor mirroring what the RPG Maker MZ editor writes for a freshly-created
|
|
5
|
+
* actor (the "New Actor" shape from newdata/data/Actors.json): class 1, level 1-99,
|
|
6
|
+
* five empty equip slots, no traits, empty graphic/name fields. Pure so the template
|
|
7
|
+
* shape can be unit-tested.
|
|
8
|
+
*
|
|
9
|
+
* Every field is present — `create_actor` previously wrote only the fields a caller
|
|
10
|
+
* passed, so an actor made with just `name` was missing `equips`/`traits`/etc.
|
|
11
|
+
* entirely, which crashes the engine on load (Game_Actor reads `equips.length` and
|
|
12
|
+
* concats `traits` unconditionally). Field order mirrors the editor's on-disk shape.
|
|
13
|
+
*/
|
|
14
|
+
export declare function defaultActor(): Omit<Actor, 'id'>;
|
|
15
|
+
/**
|
|
16
|
+
* Get all actors from the project
|
|
17
|
+
*/
|
|
18
|
+
export declare function getActors(projectPath: string): Promise<(Actor | null)[]>;
|
|
19
|
+
/**
|
|
20
|
+
* Update an actor's data
|
|
21
|
+
*/
|
|
22
|
+
export declare function updateActor(projectPath: string, actorId: number, updates: Partial<Actor>): Promise<Actor>;
|
|
23
|
+
/**
|
|
24
|
+
* Build one new actor record against the current array — the shared per-record
|
|
25
|
+
* source of truth for both `create_actor` and `batch_create`. Pure: allocates the
|
|
26
|
+
* next unused id (max existing + 1), then merges the caller's defined fields over
|
|
27
|
+
* the {@link defaultActor} template with the computed id last so it always wins.
|
|
28
|
+
* Does not push or commit — the caller owns persistence (batch pushes N records
|
|
29
|
+
* onto the same array, then writes once).
|
|
30
|
+
*/
|
|
31
|
+
export declare function buildActorRecord(existing: (Actor | null)[], input: Partial<Omit<Actor, 'id'>>): Actor;
|
|
32
|
+
/**
|
|
33
|
+
* Create a new actor. Only `name` is required; any omitted field falls back to the
|
|
34
|
+
* editor's new-actor default (see {@link defaultActor}) so the record is always
|
|
35
|
+
* complete. Allocates the next unused id (max existing + 1) and writes through the
|
|
36
|
+
* commit choke point.
|
|
37
|
+
*/
|
|
38
|
+
export declare function createActor(projectPath: string, overrides: Partial<Omit<Actor, 'id'>>): Promise<Actor>;
|
|
39
|
+
/**
|
|
40
|
+
* Delete an actor
|
|
41
|
+
*/
|
|
42
|
+
export declare function deleteActor(projectPath: string, actorId: number): Promise<boolean>;
|
|
43
|
+
/**
|
|
44
|
+
* Search actors by name
|
|
45
|
+
*/
|
|
46
|
+
export declare function searchActors(projectPath: string, searchTerm: string): Promise<Actor[]>;
|
|
47
|
+
export declare const actorToolDefinitions: ToolDefinition[];
|
|
48
|
+
//# sourceMappingURL=actorTools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actorTools.d.ts","sourceRoot":"","sources":["../../src/tools/actorTools.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGhD;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,IAAI,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAiBhD;AAED;;GAEG;AACH,wBAAsB,SAAS,CAAC,WAAW,EAAE,MAA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