@evitcastudio/kit 3.2.2 → 3.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +224 -224
- package/lib/bundle/cli/cli.js +1876 -133
- package/lib/bundle/cli/kit-game-templates/multi/_gitignore +180 -180
- package/lib/bundle/cli/kit-game-templates/multi/package.json +5 -1
- package/lib/bundle/cli/kit-game-templates/multi/resource.json +7 -1
- package/lib/bundle/cli/kit-game-templates/multi/src/client/packets/s-packets.ts +4 -4
- package/lib/bundle/cli/kit-game-templates/multi/src/server/packets/c-packets.ts +4 -4
- package/lib/bundle/cli/kit-game-templates/single/_gitignore +180 -180
- package/lib/bundle/cli/kit-game-templates/single/package.json +5 -1
- package/lib/bundle/cli/kit-game-templates/single/resource.json +7 -1
- package/lib/cli/app-bundler.d.ts.map +1 -1
- package/lib/cli/app-bundler.js +15 -3
- package/lib/cli/resource-builder.d.ts.map +1 -1
- package/lib/cli/resource-builder.js +135 -29
- package/lib/cli-runner.cjs +1 -1
- package/lib/types/vylo.d.ts +3848 -3848
- package/lib/vendor/vyi/index.js +26 -26
- package/package.json +74 -73
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 Jared Bates, Evitca Studio, "doubleactii"
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Jared Bates, Evitca Studio, "doubleactii"
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,225 +1,225 @@
|
|
|
1
|
-
# Kit
|
|
2
|
-
|
|
3
|
-
**Kit** is a lightweight, extensible 2D framework for game development in the [Vylocity Game Engine](https://www.vylocity.com/). Designed to be simple and modular, Kit empowers developers to build complex projects quickly through a robust plugin-driven architecture.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
bun install -g @evitcastudio/kit
|
|
9
|
-
```
|
|
10
|
-
> **Note:** The `-g` flag ensures the `kit` CLI tool is globally available in your PATH.
|
|
11
|
-
|
|
12
|
-
## CLI Reference & Usage
|
|
13
|
-
|
|
14
|
-
Kit includes a CLI tool (`kit`) for scaffolding projects, building game assets, generating plugin boilerplate, and diagnosing your environment.
|
|
15
|
-
|
|
16
|
-
### Global Options
|
|
17
|
-
- `-v, --verbose`: Enables verbose output and detailed debugging logs.
|
|
18
|
-
- `-h, --help`: Displays help and usage information for any command.
|
|
19
|
-
- `-V, --version`: Displays the installed Kit CLI version.
|
|
20
|
-
|
|
21
|
-
---
|
|
22
|
-
|
|
23
|
-
### `kit init [name]`
|
|
24
|
-
Initializes a new game project for the Vylocity Game Engine. If run without arguments or flags, an interactive prompt will guide you through project setup.
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
# Interactive setup
|
|
28
|
-
kit init
|
|
29
|
-
|
|
30
|
-
# Quick start with flags
|
|
31
|
-
kit init my-game --single --install
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
#### Flags & Options:
|
|
35
|
-
| Flag / Option | Type | Default | Description |
|
|
36
|
-
| :--- | :--- | :--- | :--- |
|
|
37
|
-
| `[name]` | `string` | `kit-project` | The name of the project folder to create. |
|
|
38
|
-
| `-s, --single` | `boolean` | `false` | Quick-starts a single-player game template. |
|
|
39
|
-
| `-m, --multi` | `boolean` | `false` | Quick-starts a multiplayer game template (pass both `-s` and `-m` for both). |
|
|
40
|
-
| `-f, --force` | `boolean` | `false` | Overwrites the destination folder if it already exists without aborting. |
|
|
41
|
-
| `-i, --install` | `boolean` | `false` | Automatically runs `bun install` inside the new project directory after creation. |
|
|
42
|
-
|
|
43
|
-
---
|
|
44
|
-
|
|
45
|
-
### `kit build`
|
|
46
|
-
Builds resources and compiles game application code. Automatically detects whether your project is **Singleplayer** or **Multiplayer**, compiles TypeScript entrypoints to `dist/`, copies static web files (`.html`, `.css`, `.ico`, vendor directories), hashes raw assets into unique identifiers (`.vyr`), mirrors custom subdirectories, and exports metadata manifests (`resource.json`, `bounds.json`, `icon-points.json`, and `sizes.json`).
|
|
47
|
-
|
|
48
|
-
```bash
|
|
49
|
-
# Zero-config build (auto-detects project architecture, builds ./src to ./dist)
|
|
50
|
-
kit build
|
|
51
|
-
|
|
52
|
-
# Production ready build (minified, obfuscated identifiers, stripped sourcemaps)
|
|
53
|
-
kit build -p
|
|
54
|
-
|
|
55
|
-
# Watch mode: auto-rebuilds on source or resource changes
|
|
56
|
-
kit build --watch
|
|
57
|
-
|
|
58
|
-
# Build only raw resources with custom directories
|
|
59
|
-
kit build -i ./src/resources -o ./dist --no-app
|
|
60
|
-
|
|
61
|
-
# Save the resource manifest to a custom location
|
|
62
|
-
kit build --manifest ./dist/resource.json
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
#### Flags & Options:
|
|
66
|
-
| Flag / Option | Type | Required | Default | Description |
|
|
67
|
-
| :--- | :--- | :--- | :--- | :--- |
|
|
68
|
-
| `-i, --in <path>` | `string` | No | `./src/resources` | Input directory containing raw game assets (`.vyi`, `.vym`, `.vyint`, audio, etc.). |
|
|
69
|
-
| `-o, --out <path>` | `string` | No | `./dist` | Destination directory where processed `resources/` and bundled app files will be written. |
|
|
70
|
-
| `-m, --manifest <path>` | `string` | No | `./resource.json` | Path where the resource lookup JSON should be saved. If omitted, defaults to `./resource.json` in the current working directory. |
|
|
71
|
-
| `-w, --watch` | `boolean` | No | `false` | Watches the source and resource directories for changes and triggers automatic incremental rebuilds. |
|
|
72
|
-
| `-is, --ignore-sound` | `boolean` | No | `false` | Skips processing and copying sound and music files (`.mp3`, `.ogg`, `.wav`, etc.). |
|
|
73
|
-
| `-p, --prod` | `boolean` | No | `false` | Production mode: enables full minification, identifier obfuscation/mangling, and strips sourcemaps. |
|
|
74
|
-
| `--minify` | `boolean` | No | `false` | Minifies bundled JavaScript syntax, whitespace, and variable names. |
|
|
75
|
-
| `--obfuscate` | `boolean` | No | `false` | Mangles and obfuscates identifiers across bundled output. |
|
|
76
|
-
| `--sourcemap <mode>` | `string` | No | `linked` (`none` in prod) | Sourcemap mode (`none`, `linked`, `inline`, `external`). |
|
|
77
|
-
| `--app` / `--no-app` | `boolean` | No | `true` (auto) | Toggles application code bundling. Enabled automatically if `src/index.ts` or `src/client/index.ts` exists. |
|
|
78
|
-
|
|
79
|
-
#### What is the Resource Manifest (`resource.json`)?
|
|
80
|
-
A manifest is an index or lookup table. `kit build` obfuscates asset names into unique identifiers (`uuid.vyr`) as a security benefit to protect and hide original asset filenames in production. It generates `resource.json` mapping your original human-readable asset names to their engine identifiers:
|
|
81
|
-
```json
|
|
82
|
-
{
|
|
83
|
-
"icon": [
|
|
84
|
-
{
|
|
85
|
-
"fileName": "player.vyi",
|
|
86
|
-
"resourceIdentifier": "3cf72322-6b92-4ea5-bbca-b96fae1fe440.vyr"
|
|
87
|
-
}
|
|
88
|
-
],
|
|
89
|
-
"map": [ ... ],
|
|
90
|
-
"sound": [ ... ]
|
|
91
|
-
}
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
#### Custom Asset Subdirectories (Automatic Pass-Through)
|
|
95
|
-
Any subdirectories inside your resource folder (e.g. `src/resources/images`, `src/resources/fonts`, `src/resources/emitters`, `src/resources/particles`, etc.) are automatically mirrored to `<out>/resources/<folder>/`. Non-engine files remain in their original form.
|
|
96
|
-
|
|
97
|
-
---
|
|
98
|
-
|
|
99
|
-
### `kit create <type> <name>`
|
|
100
|
-
Scaffolds boilerplate files inside an existing Kit project following standard architectural conventions.
|
|
101
|
-
|
|
102
|
-
```bash
|
|
103
|
-
# Generate a typed plugin
|
|
104
|
-
kit create plugin Inventory
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
#### Types:
|
|
108
|
-
- `plugin`: Creates a new TypeScript file at `src/plugins/<name>.ts` that subclasses `KitPlugin` with typed lifecycle hooks (`onRegistered()`) ready to extend.
|
|
109
|
-
|
|
110
|
-
---
|
|
111
|
-
|
|
112
|
-
### `kit host`
|
|
113
|
-
Hosts the game project locally for development and testing.
|
|
114
|
-
|
|
115
|
-
```bash
|
|
116
|
-
# Host the dist folder on port 8090
|
|
117
|
-
kit host
|
|
118
|
-
|
|
119
|
-
# Build before hosting and specify custom port
|
|
120
|
-
kit host -b -p 8080
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
#### Options:
|
|
124
|
-
- `-p, --port <number>`: Port to bind the server to (default: `8090`).
|
|
125
|
-
- `-d, --dir <path>`: Directory containing built files to serve (default: `./dist`).
|
|
126
|
-
- `-b, --build`: Trigger a `kit build` before starting the server.
|
|
127
|
-
|
|
128
|
-
#### Behavior:
|
|
129
|
-
- **Singleplayer / Client Projects:** Spawns a lightweight local HTTP server powered by Bun that serves `dist/index.html` and static assets with local and network LAN URLs.
|
|
130
|
-
- **Multiplayer Projects:** Automatically launches the backend node server (`dist/server.js`) with configured settings (`dist/settings.json`).
|
|
131
|
-
|
|
132
|
-
---
|
|
133
|
-
|
|
134
|
-
### `kit doctor`
|
|
135
|
-
Inspects your local environment and current project health.
|
|
136
|
-
|
|
137
|
-
```bash
|
|
138
|
-
kit doctor
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
#### What it checks:
|
|
142
|
-
- **Bun Runtime:** Verifies that Bun is installed and detects the version.
|
|
143
|
-
- **Git Installation:** Verifies that Git is accessible in your `PATH`.
|
|
144
|
-
- **Project Structure:** If executed within a game project, checks `package.json`, `@evitcastudio/kit` framework dependencies, and asset folders (`src/resources`).
|
|
145
|
-
- **Project Architecture:** Detects whether the project is **Singleplayer** (`src/index.ts`), **Multiplayer** (`src/client` & `src/server`), or **Dedicated Server**.
|
|
146
|
-
- **Build Pipeline:** Verifies that a valid build pipeline is configured (either native `kit build` in `package.json` or legacy `bun-build.ts`).
|
|
147
|
-
|
|
148
|
-
---
|
|
149
|
-
|
|
150
|
-
## Runtime Resource Loading
|
|
151
|
-
|
|
152
|
-
> **Note:** This process is preconfigured for you if you used `kit init`.
|
|
153
|
-
|
|
154
|
-
`Kit.setResources()` should be called **before** `VYLO.load()`.
|
|
155
|
-
|
|
156
|
-
```typescript
|
|
157
|
-
import resourceJSON from 'resource.json';
|
|
158
|
-
|
|
159
|
-
// Initialize the engine with mapped resources
|
|
160
|
-
await Kit.setResources(resourceJSON);
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
## Local Development & Testing
|
|
165
|
-
|
|
166
|
-
Once your project is scaffolded and dependencies are installed and the project has been built, you can run your game locally.
|
|
167
|
-
|
|
168
|
-
### Running the Game
|
|
169
|
-
|
|
170
|
-
```bash
|
|
171
|
-
# For Single-Player or Multiplayer games
|
|
172
|
-
bun run host
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
### Accessing the Game
|
|
176
|
-
|
|
177
|
-
The server will be available at the following locations after being hosted:
|
|
178
|
-
|
|
179
|
-
> **Singleplayer**
|
|
180
|
-
[http://localhost:8090](http://localhost:8090) defined in `./bun-serve.ts`
|
|
181
|
-
|
|
182
|
-
> **Multiplayer or Singleplayer & Multiplayer**
|
|
183
|
-
[http://localhost:30000](http://localhost:30000) defined in `./src/server/settings.json`
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
## Plugin Architecture
|
|
187
|
-
|
|
188
|
-
```ts
|
|
189
|
-
import { Plugin } from 'custom-plugin';
|
|
190
|
-
|
|
191
|
-
// Register a single plugin
|
|
192
|
-
const plugin = Kit.registerPlugin(Plugin);
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
```ts
|
|
196
|
-
// Register multiple plugins
|
|
197
|
-
import { Plugin1 } from 'custom-plugin1';
|
|
198
|
-
import { Plugin2 } from 'custom-plugin2';
|
|
199
|
-
|
|
200
|
-
const plugins = Kit.registerPlugins([Plugin1, Plugin2]);
|
|
201
|
-
|
|
202
|
-
// After being registered, kit can find the plugin by name.
|
|
203
|
-
const plugin1 = Kit.getPlugin('plugin1-name');
|
|
204
|
-
const plugin2 = Kit.getPlugin('plugin2-name');
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
### Listening for plugin events
|
|
208
|
-
|
|
209
|
-
Plugins emit events, this is how they pass relevant data to other plugins or the main thread.
|
|
210
|
-
By listening to these events you can act on this data.
|
|
211
|
-
|
|
212
|
-
```js
|
|
213
|
-
const listener = (pEvent: EmitterEvent) => {
|
|
214
|
-
const { data, timestamp } = pEvent;
|
|
215
|
-
// Here you can use the data that the event sent down.
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
// Choose to listen to specific event from a plugin
|
|
219
|
-
Kit.on('plugin-name', 'event-name', listener);
|
|
220
|
-
|
|
221
|
-
// You can also stop listening for an event
|
|
222
|
-
Kit.off('plugin-name', 'event-name', listener);
|
|
223
|
-
```
|
|
224
|
-
|
|
1
|
+
# Kit
|
|
2
|
+
|
|
3
|
+
**Kit** is a lightweight, extensible 2D framework for game development in the [Vylocity Game Engine](https://www.vylocity.com/). Designed to be simple and modular, Kit empowers developers to build complex projects quickly through a robust plugin-driven architecture.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bun install -g @evitcastudio/kit
|
|
9
|
+
```
|
|
10
|
+
> **Note:** The `-g` flag ensures the `kit` CLI tool is globally available in your PATH.
|
|
11
|
+
|
|
12
|
+
## CLI Reference & Usage
|
|
13
|
+
|
|
14
|
+
Kit includes a CLI tool (`kit`) for scaffolding projects, building game assets, generating plugin boilerplate, and diagnosing your environment.
|
|
15
|
+
|
|
16
|
+
### Global Options
|
|
17
|
+
- `-v, --verbose`: Enables verbose output and detailed debugging logs.
|
|
18
|
+
- `-h, --help`: Displays help and usage information for any command.
|
|
19
|
+
- `-V, --version`: Displays the installed Kit CLI version.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
### `kit init [name]`
|
|
24
|
+
Initializes a new game project for the Vylocity Game Engine. If run without arguments or flags, an interactive prompt will guide you through project setup.
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# Interactive setup
|
|
28
|
+
kit init
|
|
29
|
+
|
|
30
|
+
# Quick start with flags
|
|
31
|
+
kit init my-game --single --install
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
#### Flags & Options:
|
|
35
|
+
| Flag / Option | Type | Default | Description |
|
|
36
|
+
| :--- | :--- | :--- | :--- |
|
|
37
|
+
| `[name]` | `string` | `kit-project` | The name of the project folder to create. |
|
|
38
|
+
| `-s, --single` | `boolean` | `false` | Quick-starts a single-player game template. |
|
|
39
|
+
| `-m, --multi` | `boolean` | `false` | Quick-starts a multiplayer game template (pass both `-s` and `-m` for both). |
|
|
40
|
+
| `-f, --force` | `boolean` | `false` | Overwrites the destination folder if it already exists without aborting. |
|
|
41
|
+
| `-i, --install` | `boolean` | `false` | Automatically runs `bun install` inside the new project directory after creation. |
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
### `kit build`
|
|
46
|
+
Builds resources and compiles game application code. Automatically detects whether your project is **Singleplayer** or **Multiplayer**, compiles TypeScript entrypoints to `dist/`, copies static web files (`.html`, `.css`, `.ico`, vendor directories), hashes raw assets into unique identifiers (`.vyr`), mirrors custom subdirectories, and exports metadata manifests (`resource.json`, `bounds.json`, `icon-points.json`, and `sizes.json`).
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
# Zero-config build (auto-detects project architecture, builds ./src to ./dist)
|
|
50
|
+
kit build
|
|
51
|
+
|
|
52
|
+
# Production ready build (minified, obfuscated identifiers, stripped sourcemaps)
|
|
53
|
+
kit build -p
|
|
54
|
+
|
|
55
|
+
# Watch mode: auto-rebuilds on source or resource changes
|
|
56
|
+
kit build --watch
|
|
57
|
+
|
|
58
|
+
# Build only raw resources with custom directories
|
|
59
|
+
kit build -i ./src/resources -o ./dist --no-app
|
|
60
|
+
|
|
61
|
+
# Save the resource manifest to a custom location
|
|
62
|
+
kit build --manifest ./dist/resource.json
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
#### Flags & Options:
|
|
66
|
+
| Flag / Option | Type | Required | Default | Description |
|
|
67
|
+
| :--- | :--- | :--- | :--- | :--- |
|
|
68
|
+
| `-i, --in <path>` | `string` | No | `./src/resources` | Input directory containing raw game assets (`.vyi`, `.vym`, `.vyint`, audio, etc.). |
|
|
69
|
+
| `-o, --out <path>` | `string` | No | `./dist` | Destination directory where processed `resources/` and bundled app files will be written. |
|
|
70
|
+
| `-m, --manifest <path>` | `string` | No | `./resource.json` | Path where the resource lookup JSON should be saved. If omitted, defaults to `./resource.json` in the current working directory. |
|
|
71
|
+
| `-w, --watch` | `boolean` | No | `false` | Watches the source and resource directories for changes and triggers automatic incremental rebuilds. |
|
|
72
|
+
| `-is, --ignore-sound` | `boolean` | No | `false` | Skips processing and copying sound and music files (`.mp3`, `.ogg`, `.wav`, etc.). |
|
|
73
|
+
| `-p, --prod` | `boolean` | No | `false` | Production mode: enables full minification, identifier obfuscation/mangling, and strips sourcemaps. |
|
|
74
|
+
| `--minify` | `boolean` | No | `false` | Minifies bundled JavaScript syntax, whitespace, and variable names. |
|
|
75
|
+
| `--obfuscate` | `boolean` | No | `false` | Mangles and obfuscates identifiers across bundled output. |
|
|
76
|
+
| `--sourcemap <mode>` | `string` | No | `linked` (`none` in prod) | Sourcemap mode (`none`, `linked`, `inline`, `external`). |
|
|
77
|
+
| `--app` / `--no-app` | `boolean` | No | `true` (auto) | Toggles application code bundling. Enabled automatically if `src/index.ts` or `src/client/index.ts` exists. |
|
|
78
|
+
|
|
79
|
+
#### What is the Resource Manifest (`resource.json`)?
|
|
80
|
+
A manifest is an index or lookup table. `kit build` obfuscates asset names into unique identifiers (`uuid.vyr`) as a security benefit to protect and hide original asset filenames in production. It generates `resource.json` mapping your original human-readable asset names to their engine identifiers:
|
|
81
|
+
```json
|
|
82
|
+
{
|
|
83
|
+
"icon": [
|
|
84
|
+
{
|
|
85
|
+
"fileName": "player.vyi",
|
|
86
|
+
"resourceIdentifier": "3cf72322-6b92-4ea5-bbca-b96fae1fe440.vyr"
|
|
87
|
+
}
|
|
88
|
+
],
|
|
89
|
+
"map": [ ... ],
|
|
90
|
+
"sound": [ ... ]
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
#### Custom Asset Subdirectories (Automatic Pass-Through)
|
|
95
|
+
Any subdirectories inside your resource folder (e.g. `src/resources/images`, `src/resources/fonts`, `src/resources/emitters`, `src/resources/particles`, etc.) are automatically mirrored to `<out>/resources/<folder>/`. Non-engine files remain in their original form.
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
### `kit create <type> <name>`
|
|
100
|
+
Scaffolds boilerplate files inside an existing Kit project following standard architectural conventions.
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
# Generate a typed plugin
|
|
104
|
+
kit create plugin Inventory
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
#### Types:
|
|
108
|
+
- `plugin`: Creates a new TypeScript file at `src/plugins/<name>.ts` that subclasses `KitPlugin` with typed lifecycle hooks (`onRegistered()`) ready to extend.
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
### `kit host`
|
|
113
|
+
Hosts the game project locally for development and testing.
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
# Host the dist folder on port 8090
|
|
117
|
+
kit host
|
|
118
|
+
|
|
119
|
+
# Build before hosting and specify custom port
|
|
120
|
+
kit host -b -p 8080
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
#### Options:
|
|
124
|
+
- `-p, --port <number>`: Port to bind the server to (default: `8090`).
|
|
125
|
+
- `-d, --dir <path>`: Directory containing built files to serve (default: `./dist`).
|
|
126
|
+
- `-b, --build`: Trigger a `kit build` before starting the server.
|
|
127
|
+
|
|
128
|
+
#### Behavior:
|
|
129
|
+
- **Singleplayer / Client Projects:** Spawns a lightweight local HTTP server powered by Bun that serves `dist/index.html` and static assets with local and network LAN URLs.
|
|
130
|
+
- **Multiplayer Projects:** Automatically launches the backend node server (`dist/server.js`) with configured settings (`dist/settings.json`).
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
### `kit doctor`
|
|
135
|
+
Inspects your local environment and current project health.
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
kit doctor
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
#### What it checks:
|
|
142
|
+
- **Bun Runtime:** Verifies that Bun is installed and detects the version.
|
|
143
|
+
- **Git Installation:** Verifies that Git is accessible in your `PATH`.
|
|
144
|
+
- **Project Structure:** If executed within a game project, checks `package.json`, `@evitcastudio/kit` framework dependencies, and asset folders (`src/resources`).
|
|
145
|
+
- **Project Architecture:** Detects whether the project is **Singleplayer** (`src/index.ts`), **Multiplayer** (`src/client` & `src/server`), or **Dedicated Server**.
|
|
146
|
+
- **Build Pipeline:** Verifies that a valid build pipeline is configured (either native `kit build` in `package.json` or legacy `bun-build.ts`).
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## Runtime Resource Loading
|
|
151
|
+
|
|
152
|
+
> **Note:** This process is preconfigured for you if you used `kit init`.
|
|
153
|
+
|
|
154
|
+
`Kit.setResources()` should be called **before** `VYLO.load()`.
|
|
155
|
+
|
|
156
|
+
```typescript
|
|
157
|
+
import resourceJSON from 'resource.json';
|
|
158
|
+
|
|
159
|
+
// Initialize the engine with mapped resources
|
|
160
|
+
await Kit.setResources(resourceJSON);
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
## Local Development & Testing
|
|
165
|
+
|
|
166
|
+
Once your project is scaffolded and dependencies are installed and the project has been built, you can run your game locally.
|
|
167
|
+
|
|
168
|
+
### Running the Game
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
# For Single-Player or Multiplayer games
|
|
172
|
+
bun run host
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Accessing the Game
|
|
176
|
+
|
|
177
|
+
The server will be available at the following locations after being hosted:
|
|
178
|
+
|
|
179
|
+
> **Singleplayer**
|
|
180
|
+
[http://localhost:8090](http://localhost:8090) defined in `./bun-serve.ts`
|
|
181
|
+
|
|
182
|
+
> **Multiplayer or Singleplayer & Multiplayer**
|
|
183
|
+
[http://localhost:30000](http://localhost:30000) defined in `./src/server/settings.json`
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
## Plugin Architecture
|
|
187
|
+
|
|
188
|
+
```ts
|
|
189
|
+
import { Plugin } from 'custom-plugin';
|
|
190
|
+
|
|
191
|
+
// Register a single plugin
|
|
192
|
+
const plugin = Kit.registerPlugin(Plugin);
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
```ts
|
|
196
|
+
// Register multiple plugins
|
|
197
|
+
import { Plugin1 } from 'custom-plugin1';
|
|
198
|
+
import { Plugin2 } from 'custom-plugin2';
|
|
199
|
+
|
|
200
|
+
const plugins = Kit.registerPlugins([Plugin1, Plugin2]);
|
|
201
|
+
|
|
202
|
+
// After being registered, kit can find the plugin by name.
|
|
203
|
+
const plugin1 = Kit.getPlugin('plugin1-name');
|
|
204
|
+
const plugin2 = Kit.getPlugin('plugin2-name');
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Listening for plugin events
|
|
208
|
+
|
|
209
|
+
Plugins emit events, this is how they pass relevant data to other plugins or the main thread.
|
|
210
|
+
By listening to these events you can act on this data.
|
|
211
|
+
|
|
212
|
+
```js
|
|
213
|
+
const listener = (pEvent: EmitterEvent) => {
|
|
214
|
+
const { data, timestamp } = pEvent;
|
|
215
|
+
// Here you can use the data that the event sent down.
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// Choose to listen to specific event from a plugin
|
|
219
|
+
Kit.on('plugin-name', 'event-name', listener);
|
|
220
|
+
|
|
221
|
+
// You can also stop listening for an event
|
|
222
|
+
Kit.off('plugin-name', 'event-name', listener);
|
|
223
|
+
```
|
|
224
|
+
|
|
225
225
|
For more information check out the [wiki](https://github.com/EvitcaStudio/Kit/wiki)
|