@nanoforge-dev/schematics 2.2.1 → 2.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/CHANGELOG.md +474 -0
- package/README.md +12 -15
- package/dist/collection.json +8 -23
- package/dist/index.cjs +21 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -7
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +19 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -4
- package/dist/index.js.map +1 -1
- package/dist/libs/component/component.factory.d.ts +1 -3
- package/dist/libs/component/component.factory.d.ts.map +1 -1
- package/dist/libs/component/component.factory.js +2 -1
- package/dist/libs/component/component.factory.js.map +1 -1
- package/dist/libs/project/files/js/.dockerignore +5 -0
- package/dist/libs/project/files/js/Dockerfile +36 -0
- package/dist/libs/project/files/js/README.md +53 -0
- package/dist/libs/project/files/js/assets/__dot__gitkeep +0 -0
- package/dist/libs/project/files/js/jsconfig.json +36 -0
- package/dist/libs/project/files/js/nanoforge.config.js +10 -0
- package/dist/libs/project/files/js/package.json.template +29 -0
- package/dist/libs/project/files/js/pnpm-workspace.yaml.template +3 -0
- package/dist/libs/project/files/js/src/components/drawable-circle-2d.component.js +404 -0
- package/dist/libs/project/files/js/src/components/position-2d.component.js +42 -0
- package/dist/libs/project/files/js/src/main.js +43 -0
- package/dist/libs/project/files/js/src/systems/draw-2d.system.js +33 -0
- package/dist/libs/project/files/js/src/systems/move-2d.system.js +34 -0
- package/dist/libs/project/files/js/src/systems/position-sync.system.js +35 -0
- package/dist/libs/project/files/ts/.dockerignore +5 -0
- package/dist/libs/project/files/ts/Dockerfile +36 -0
- package/dist/libs/project/files/ts/README.md +53 -0
- package/dist/libs/project/files/ts/assets/__dot__gitkeep +0 -0
- package/dist/libs/project/files/ts/nanoforge.config.ts +5 -0
- package/dist/libs/project/files/ts/package.json.template +29 -0
- package/dist/libs/project/files/ts/pnpm-workspace.yaml.template +3 -0
- package/dist/libs/project/files/ts/src/components/drawable-circle-2d.component.ts +367 -0
- package/dist/libs/project/files/ts/src/components/position-2d.component.ts +35 -0
- package/dist/libs/project/files/ts/src/main.ts +40 -0
- package/dist/libs/project/files/ts/src/systems/draw-2d.system.ts +25 -0
- package/dist/libs/project/files/ts/src/systems/move-2d.system.ts +26 -0
- package/dist/libs/project/files/ts/src/systems/position-sync.system.ts +27 -0
- package/dist/libs/project/files/ts/tsconfig.json +42 -0
- package/dist/libs/project/project.factory.d.ts +64 -0
- package/dist/libs/project/project.factory.d.ts.map +1 -0
- package/dist/libs/project/project.factory.js +127 -0
- package/dist/libs/project/project.factory.js.map +1 -0
- package/dist/libs/project/schema.json +83 -0
- package/dist/libs/system/system.factory.d.ts +1 -3
- package/dist/libs/system/system.factory.d.ts.map +1 -1
- package/dist/libs/system/system.factory.js +2 -1
- package/dist/libs/system/system.factory.js.map +1 -1
- package/dist/libs/workspace/files/js/.dockerignore +5 -0
- package/dist/libs/workspace/files/js/Dockerfile +36 -0
- package/dist/libs/workspace/files/js/README.md +51 -0
- package/dist/libs/workspace/files/js/__dot__gitignore +137 -0
- package/dist/libs/{application → workspace}/files/js/jsconfig.json +1 -2
- package/dist/libs/workspace/files/js/nanoforge.config.js +6 -0
- package/dist/libs/workspace/files/js/package.json.template +19 -0
- package/dist/libs/workspace/files/js/pnpm-workspace.yaml.template +6 -0
- package/dist/libs/workspace/files/ts/.dockerignore +5 -0
- package/dist/libs/workspace/files/ts/Dockerfile +36 -0
- package/dist/libs/workspace/files/ts/README.md +51 -0
- package/dist/libs/workspace/files/ts/__dot__gitignore +134 -0
- package/dist/libs/workspace/files/ts/nanoforge.config.ts +6 -0
- package/dist/libs/workspace/files/ts/package.json.template +20 -0
- package/dist/libs/workspace/files/ts/pnpm-workspace.yaml.template +6 -0
- package/dist/libs/{application → workspace}/files/ts/tsconfig.json +1 -2
- package/dist/libs/workspace/schema.json +45 -0
- package/dist/libs/workspace/workspace.factory.d.ts +42 -0
- package/dist/libs/workspace/workspace.factory.d.ts.map +1 -0
- package/dist/libs/workspace/workspace.factory.js +116 -0
- package/dist/libs/workspace/workspace.factory.js.map +1 -0
- package/package.json +23 -21
- package/dist/libs/application/application.factory.d.ts +0 -59
- package/dist/libs/application/application.factory.d.ts.map +0 -1
- package/dist/libs/application/application.factory.js +0 -57
- package/dist/libs/application/application.factory.js.map +0 -1
- package/dist/libs/application/files/js/.prettierignore +0 -8
- package/dist/libs/application/files/js/README.md +0 -166
- package/dist/libs/application/files/js/eslint.config.js +0 -11
- package/dist/libs/application/files/js/package.json.template +0 -48
- package/dist/libs/application/files/js/pnpm-workspace.yaml.template +0 -3
- package/dist/libs/application/files/js/prettier.config.js +0 -6
- package/dist/libs/application/files/ts/.prettierignore +0 -8
- package/dist/libs/application/files/ts/README.md +0 -166
- package/dist/libs/application/files/ts/eslint.config.js +0 -15
- package/dist/libs/application/files/ts/package.json.template +0 -52
- package/dist/libs/application/files/ts/pnpm-workspace.yaml.template +0 -3
- package/dist/libs/application/files/ts/prettier.config.js +0 -6
- package/dist/libs/application/schema.json +0 -70
- package/dist/libs/configuration/configuration.factory.d.ts +0 -31
- package/dist/libs/configuration/configuration.factory.d.ts.map +0 -1
- package/dist/libs/configuration/configuration.factory.js +0 -97
- package/dist/libs/configuration/configuration.factory.js.map +0 -1
- package/dist/libs/configuration/files/nanoforge.config.json +0 -1
- package/dist/libs/configuration/schema.json +0 -34
- package/dist/libs/docker/docker.factory.d.ts +0 -19
- package/dist/libs/docker/docker.factory.d.ts.map +0 -1
- package/dist/libs/docker/docker.factory.js +0 -20
- package/dist/libs/docker/docker.factory.js.map +0 -1
- package/dist/libs/docker/files/.dockerignore +0 -1
- package/dist/libs/docker/files/Dockerfile +0 -25
- package/dist/libs/docker/schema.json +0 -19
- package/dist/libs/part-base/files/js/__nanoforgeFolder__/client.save.json +0 -77
- package/dist/libs/part-base/files/js/__nanoforgeFolder__/server.save.json +0 -49
- package/dist/libs/part-base/files/js/__part__/components/example.component.js +0 -72
- package/dist/libs/part-base/files/js/__part__/init/after-init.js +0 -12
- package/dist/libs/part-base/files/js/__part__/init/after-registry-init.js +0 -14
- package/dist/libs/part-base/files/js/__part__/init/after-run.js +0 -12
- package/dist/libs/part-base/files/js/__part__/init/before-init.js +0 -13
- package/dist/libs/part-base/files/js/__part__/init/before-registry-init.js +0 -14
- package/dist/libs/part-base/files/js/__part__/init/before-run.js +0 -12
- package/dist/libs/part-base/files/js/__part__/systems/example.system.js +0 -44
- package/dist/libs/part-base/files/ts/__nanoforgeFolder__/client.save.json +0 -77
- package/dist/libs/part-base/files/ts/__nanoforgeFolder__/server.save.json +0 -49
- package/dist/libs/part-base/files/ts/__part__/components/example.component.ts +0 -55
- package/dist/libs/part-base/files/ts/__part__/init/after-init.ts +0 -5
- package/dist/libs/part-base/files/ts/__part__/init/after-registry-init.ts +0 -6
- package/dist/libs/part-base/files/ts/__part__/init/after-run.ts +0 -5
- package/dist/libs/part-base/files/ts/__part__/init/before-init.ts +0 -5
- package/dist/libs/part-base/files/ts/__part__/init/before-registry-init.ts +0 -6
- package/dist/libs/part-base/files/ts/__part__/init/before-run.ts +0 -5
- package/dist/libs/part-base/files/ts/__part__/systems/example.system.ts +0 -31
- package/dist/libs/part-base/part-base.factory.d.ts +0 -31
- package/dist/libs/part-base/part-base.factory.d.ts.map +0 -1
- package/dist/libs/part-base/part-base.factory.js +0 -33
- package/dist/libs/part-base/part-base.factory.js.map +0 -1
- package/dist/libs/part-base/schema.json +0 -35
- package/dist/libs/part-main/part-main.factory.d.ts +0 -39
- package/dist/libs/part-main/part-main.factory.d.ts.map +0 -1
- package/dist/libs/part-main/part-main.factory.js +0 -252
- package/dist/libs/part-main/part-main.factory.js.map +0 -1
- package/dist/libs/part-main/schema.json +0 -43
- /package/dist/libs/{application → project}/files/js/__dot__gitignore +0 -0
- /package/dist/libs/{application → project}/files/ts/__dot__gitignore +0 -0
- /package/dist/libs/{application → workspace}/files/js/__dot__env +0 -0
- /package/dist/libs/{application → workspace}/files/ts/__dot__env +0 -0
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
# <%= name %>
|
|
2
|
-
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
## Prerequisites
|
|
6
|
-
|
|
7
|
-
- [Node.js](https://nodejs.org/) 18+
|
|
8
|
-
- Package manager: **<%= packageManager %>**
|
|
9
|
-
- [NanoForge CLI](https://www.npmjs.com/package/@nanoforge-dev/cli): `<%= packageManager %> install -g @nanoforge-dev/cli`
|
|
10
|
-
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
## Installation
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
<%= packageManager %> install
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
|
-
## Development
|
|
22
|
-
|
|
23
|
-
Start the game in watch mode with hot reload:
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
nf dev
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
<% if (editor) { %>Open the visual editor (optional — lets you edit entities, components and systems without touching code):
|
|
30
|
-
```bash
|
|
31
|
-
nf editor
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
<% } %>---
|
|
35
|
-
|
|
36
|
-
## Project structure
|
|
37
|
-
|
|
38
|
-
```
|
|
39
|
-
<%= name %>/
|
|
40
|
-
├── .nanoforge/ # NanoForge internal save files (do not edit manually)
|
|
41
|
-
├── client/ # Client-side code (runs in the browser)
|
|
42
|
-
│ ├── static/ # Static assets
|
|
43
|
-
│ ├── components/ # ECS components
|
|
44
|
-
│ ├── systems/ # ECS systems<% if (initFunctions) { %>
|
|
45
|
-
│ └── init/ # Lifecycle hooks (before-init, after-run, …)<% } %><% if (server) { %>
|
|
46
|
-
├── server/ # Server-side code
|
|
47
|
-
│ ├── static/
|
|
48
|
-
│ ├── components/
|
|
49
|
-
│ ├── systems/<% if (initFunctions) { %>
|
|
50
|
-
│ └── init/<% } %><% } %>
|
|
51
|
-
├── package.json
|
|
52
|
-
├── jsconfig.json
|
|
53
|
-
└── nanoforge.config.json # Game configuration
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
---
|
|
57
|
-
|
|
58
|
-
## Modifying the game
|
|
59
|
-
|
|
60
|
-
### Add a component
|
|
61
|
-
|
|
62
|
-
```bash
|
|
63
|
-
nf generate component <name> --part client
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
A component is a plain class that holds data for an entity. Edit the generated file in `client/components/`:
|
|
67
|
-
|
|
68
|
-
```js
|
|
69
|
-
export class MyComponent {
|
|
70
|
-
constructor(speed) {
|
|
71
|
-
this.speed = speed;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export default MyComponent.name;
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
### Add a system
|
|
79
|
-
|
|
80
|
-
```bash
|
|
81
|
-
nf generate system <name> --part client
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
A system is a function that runs every tick and operates on entities that have specific components. Edit the generated file in `client/systems/`:
|
|
85
|
-
|
|
86
|
-
```js
|
|
87
|
-
import { MyComponent } from "../components/my.component.js";
|
|
88
|
-
|
|
89
|
-
export const mySystem = (registry, ctx) => {
|
|
90
|
-
const entities = registry.getZipper([MyComponent]);
|
|
91
|
-
|
|
92
|
-
entities.forEach((entity) => {
|
|
93
|
-
entity.MyComponent.speed += 1;
|
|
94
|
-
});
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
export default mySystem.name;
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
<% if (server) { %>
|
|
101
|
-
### Server-side code
|
|
102
|
-
|
|
103
|
-
Server components and systems live in `server/` and are imported from `@nanoforge-dev/ecs-server`. They follow the same pattern as the client side.
|
|
104
|
-
|
|
105
|
-
Configure the server connection in `.env`:
|
|
106
|
-
|
|
107
|
-
| Variable | Default | Description |
|
|
108
|
-
|---------------------------------------|-------------|---------------------------------|
|
|
109
|
-
| `NANOFORGE_CLIENT_SERVER_ADDRESS` | `127.0.0.1` | Server address (client-side) |
|
|
110
|
-
| `NANOFORGE_CLIENT_SERVER_TCP_PORT` | `4444` | TCP port the client connects to |
|
|
111
|
-
| `NANOFORGE_CLIENT_SERVER_UDP_PORT` | `4445` | UDP port the client connects to |
|
|
112
|
-
| `NANOFORGE_SERVER_LISTENING_TCP_PORT` | `4444` | TCP port the server listens on |
|
|
113
|
-
| `NANOFORGE_SERVER_LISTENING_UDP_PORT` | `4445` | UDP port the server listens on |
|
|
114
|
-
|
|
115
|
-
<% } %>---
|
|
116
|
-
|
|
117
|
-
## Build
|
|
118
|
-
|
|
119
|
-
Compile the game for production:
|
|
120
|
-
|
|
121
|
-
```bash
|
|
122
|
-
<%= packageManager %> run build
|
|
123
|
-
# or
|
|
124
|
-
nf build
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
Output is written to the `.nanoforge/` directory.
|
|
128
|
-
|
|
129
|
-
---
|
|
130
|
-
|
|
131
|
-
## Run
|
|
132
|
-
|
|
133
|
-
Start the game server and open it in a browser:
|
|
134
|
-
|
|
135
|
-
```bash
|
|
136
|
-
<%= packageManager %> run start
|
|
137
|
-
# or
|
|
138
|
-
nf start
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
<% if (lint) { %>---
|
|
142
|
-
|
|
143
|
-
## Code quality
|
|
144
|
-
|
|
145
|
-
```bash
|
|
146
|
-
# Check formatting and linting
|
|
147
|
-
<%= packageManager %> run lint
|
|
148
|
-
|
|
149
|
-
# Auto-fix formatting and linting
|
|
150
|
-
<%= packageManager %> run format
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
<% } %>---
|
|
154
|
-
|
|
155
|
-
## CLI reference
|
|
156
|
-
|
|
157
|
-
| Command | Description |
|
|
158
|
-
|--------------------------------|-------------------------------------------|
|
|
159
|
-
| `nf dev` | Start in development mode with hot reload |
|
|
160
|
-
| `nf build` | Build for production |
|
|
161
|
-
| `nf start` | Run the built game |
|
|
162
|
-
| `nf generate component <name>` | Scaffold a new component |
|
|
163
|
-
| `nf generate system <name>` | Scaffold a new system |<% if (editor) { %>
|
|
164
|
-
| `nf editor` | Open the visual editor |<% } %>
|
|
165
|
-
|
|
166
|
-
Full CLI documentation: <https://docs.nanoforge.eu>
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import pluginJs from "@eslint/js";
|
|
2
|
-
import eslintConfigPrettier from "eslint-config-prettier";
|
|
3
|
-
import globals from "globals";
|
|
4
|
-
|
|
5
|
-
export default [
|
|
6
|
-
{ files: ["{client,server}/**/*.{js}"] },
|
|
7
|
-
{ languageOptions: { globals: globals.node } },
|
|
8
|
-
|
|
9
|
-
pluginJs.configs.recommended,
|
|
10
|
-
eslintConfigPrettier,
|
|
11
|
-
];
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "<%= name %>",
|
|
3
|
-
"version": "<%= version %>",
|
|
4
|
-
"description": "<%= description %>",
|
|
5
|
-
"author": "<%= author %>",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"build": "nf build",
|
|
8
|
-
"start": "nf start"<% if (lint) { %>,
|
|
9
|
-
"lint": "prettier --check . && eslint --format=pretty \"{client,server}/**/*.js\"",
|
|
10
|
-
"format": "prettier --write . && eslint --fix --format=pretty \"{client,server}/**/*.js\""<% } %>
|
|
11
|
-
},
|
|
12
|
-
"devDependencies": {<% if (lint) { %>
|
|
13
|
-
"@eslint/js": "^9.39.0",<% } %>
|
|
14
|
-
"@nanoforge-dev/asset-manager": "^1",
|
|
15
|
-
"@nanoforge-dev/cli": "latest",
|
|
16
|
-
"@nanoforge-dev/common": "^1",
|
|
17
|
-
"@nanoforge-dev/config": "^1",
|
|
18
|
-
"@nanoforge-dev/core": "^1",<% if (editor) { %>
|
|
19
|
-
"@nanoforge-dev/core-editor": "^1",<% } %>
|
|
20
|
-
"@nanoforge-dev/ecs-client": "^1",<% if (server) { %>
|
|
21
|
-
"@nanoforge-dev/ecs-server": "^1",<% } %>
|
|
22
|
-
"@nanoforge-dev/graphics-2d": "^1",<% if (editor) { %>
|
|
23
|
-
"@nanoforge-dev/graphics-2d-editor": "^1",<% } %>
|
|
24
|
-
"@nanoforge-dev/input": "^1",
|
|
25
|
-
"@nanoforge-dev/music": "^1",<% if (server) { %>
|
|
26
|
-
"@nanoforge-dev/network-client": "^1",
|
|
27
|
-
"@nanoforge-dev/network-server": "^1",<% } %>
|
|
28
|
-
"@nanoforge-dev/sound": "^1"<% if (lint) { %>,
|
|
29
|
-
"eslint": "^9.39.0",
|
|
30
|
-
"eslint-config-prettier": "^10.1.8",
|
|
31
|
-
"eslint-plugin-prettier": "^5.5.4",
|
|
32
|
-
"globals": "^16.5.0",
|
|
33
|
-
"lint-staged": "^16.2.6",
|
|
34
|
-
"prettier": "^3.6.2"<% } %>
|
|
35
|
-
},<% if (lint) { %>
|
|
36
|
-
"lint-staged": {
|
|
37
|
-
"**/*.js": [
|
|
38
|
-
"prettier --write"
|
|
39
|
-
],
|
|
40
|
-
"{client,server}/**/*.js": [
|
|
41
|
-
"eslint --fix"
|
|
42
|
-
]
|
|
43
|
-
},<% } %><% if (packageManager === "pnpm") { %>
|
|
44
|
-
"pnpm": {
|
|
45
|
-
"neverBuiltDependencies": []
|
|
46
|
-
},<% } %>
|
|
47
|
-
"private": true
|
|
48
|
-
}
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
# <%= name %>
|
|
2
|
-
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
## Prerequisites
|
|
6
|
-
|
|
7
|
-
- [Node.js](https://nodejs.org/) 18+
|
|
8
|
-
- Package manager: **<%= packageManager %>**
|
|
9
|
-
- [NanoForge CLI](https://www.npmjs.com/package/@nanoforge-dev/cli): `<%= packageManager %> install -g @nanoforge-dev/cli`
|
|
10
|
-
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
## Installation
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
<%= packageManager %> install
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
|
-
## Development
|
|
22
|
-
|
|
23
|
-
Start the game in watch mode with hot reload:
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
nf dev
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
<% if (editor) { %>Open the visual editor (optional — lets you edit entities, components and systems without touching code):
|
|
30
|
-
```bash
|
|
31
|
-
nf editor
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
<% } %>---
|
|
35
|
-
|
|
36
|
-
## Project structure
|
|
37
|
-
|
|
38
|
-
```
|
|
39
|
-
<%= name %>/
|
|
40
|
-
├── .nanoforge/ # NanoForge internal save files (do not edit manually)
|
|
41
|
-
├── client/ # Client-side code (runs in the browser)
|
|
42
|
-
│ ├── static/ # Static assets
|
|
43
|
-
│ ├── components/ # ECS components
|
|
44
|
-
│ ├── systems/ # ECS systems<% if (initFunctions) { %>
|
|
45
|
-
│ └── init/ # Lifecycle hooks (before-init, after-run, …)<% } %><% if (server) { %>
|
|
46
|
-
├── server/ # Server-side code
|
|
47
|
-
│ ├── static/
|
|
48
|
-
│ ├── components/
|
|
49
|
-
│ ├── systems/<% if (initFunctions) { %>
|
|
50
|
-
│ └── init/<% } %><% } %>
|
|
51
|
-
├── package.json
|
|
52
|
-
├── tsconfig.json
|
|
53
|
-
└── nanoforge.config.json # Game configuration
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
---
|
|
57
|
-
|
|
58
|
-
## Modifying the game
|
|
59
|
-
|
|
60
|
-
### Add a component
|
|
61
|
-
|
|
62
|
-
```bash
|
|
63
|
-
nf generate component <name> --part client
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
A component is a plain class that holds data for an entity. Edit the generated file in `client/components/`:
|
|
67
|
-
|
|
68
|
-
```ts
|
|
69
|
-
export class MyComponent {
|
|
70
|
-
constructor(public speed: number) {}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export default MyComponent.name;
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
### Add a system
|
|
77
|
-
|
|
78
|
-
```bash
|
|
79
|
-
nf generate system <name> --part client
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
A system is a function that runs every tick and operates on entities that have specific components. Edit the generated file in `client/systems/`:
|
|
83
|
-
|
|
84
|
-
```ts
|
|
85
|
-
import { type Context } from "@nanoforge-dev/common";
|
|
86
|
-
import { type Registry } from "@nanoforge-dev/ecs-client";
|
|
87
|
-
import { MyComponent } from "../components/my.component";
|
|
88
|
-
|
|
89
|
-
export const mySystem = (registry: Registry, ctx: Context) => {
|
|
90
|
-
const entities = registry.getZipper([MyComponent]);
|
|
91
|
-
|
|
92
|
-
entities.forEach((entity) => {
|
|
93
|
-
entity.MyComponent.speed += 1;
|
|
94
|
-
});
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
export default mySystem.name;
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
<% if (server) { %>
|
|
101
|
-
### Server-side code
|
|
102
|
-
|
|
103
|
-
Server components and systems live in `server/` and are imported from `@nanoforge-dev/ecs-server`. They follow the same pattern as the client side.
|
|
104
|
-
|
|
105
|
-
Configure the server connection in `.env`:
|
|
106
|
-
|
|
107
|
-
| Variable | Default | Description |
|
|
108
|
-
|---------------------------------------|-------------|---------------------------------|
|
|
109
|
-
| `NANOFORGE_CLIENT_SERVER_ADDRESS` | `127.0.0.1` | Server address (client-side) |
|
|
110
|
-
| `NANOFORGE_CLIENT_SERVER_TCP_PORT` | `4444` | TCP port the client connects to |
|
|
111
|
-
| `NANOFORGE_CLIENT_SERVER_UDP_PORT` | `4445` | UDP port the client connects to |
|
|
112
|
-
| `NANOFORGE_SERVER_LISTENING_TCP_PORT` | `4444` | TCP port the server listens on |
|
|
113
|
-
| `NANOFORGE_SERVER_LISTENING_UDP_PORT` | `4445` | UDP port the server listens on |
|
|
114
|
-
|
|
115
|
-
<% } %>---
|
|
116
|
-
|
|
117
|
-
## Build
|
|
118
|
-
|
|
119
|
-
Compile the game for production:
|
|
120
|
-
|
|
121
|
-
```bash
|
|
122
|
-
<%= packageManager %> run build
|
|
123
|
-
# or
|
|
124
|
-
nf build
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
Output is written to the `.nanoforge/` directory.
|
|
128
|
-
|
|
129
|
-
---
|
|
130
|
-
|
|
131
|
-
## Run
|
|
132
|
-
|
|
133
|
-
Start the game server and open it in a browser:
|
|
134
|
-
|
|
135
|
-
```bash
|
|
136
|
-
<%= packageManager %> run start
|
|
137
|
-
# or
|
|
138
|
-
nf start
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
<% if (lint) { %>---
|
|
142
|
-
|
|
143
|
-
## Code quality
|
|
144
|
-
|
|
145
|
-
```bash
|
|
146
|
-
# Check formatting and linting
|
|
147
|
-
<%= packageManager %> run lint
|
|
148
|
-
|
|
149
|
-
# Auto-fix formatting and linting
|
|
150
|
-
<%= packageManager %> run format
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
<% } %>---
|
|
154
|
-
|
|
155
|
-
## CLI reference
|
|
156
|
-
|
|
157
|
-
| Command | Description |
|
|
158
|
-
|--------------------------------|-------------------------------------------|
|
|
159
|
-
| `nf dev` | Start in development mode with hot reload |
|
|
160
|
-
| `nf build` | Build for production |
|
|
161
|
-
| `nf start` | Run the built game |
|
|
162
|
-
| `nf generate component <name>` | Scaffold a new component |
|
|
163
|
-
| `nf generate system <name>` | Scaffold a new system |<% if (editor) { %>
|
|
164
|
-
| `nf editor` | Open the visual editor |<% } %>
|
|
165
|
-
|
|
166
|
-
Full CLI documentation: <https://docs.nanoforge.eu>
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import pluginJs from "@eslint/js";
|
|
2
|
-
import eslintConfigPrettier from "eslint-config-prettier";
|
|
3
|
-
import globals from "globals";
|
|
4
|
-
import tseslint from "typescript-eslint";
|
|
5
|
-
|
|
6
|
-
export default [
|
|
7
|
-
{ files: ["{client,server}/**/*.{ts}"] },
|
|
8
|
-
{ languageOptions: { globals: globals.node } },
|
|
9
|
-
|
|
10
|
-
pluginJs.configs.recommended,
|
|
11
|
-
...tseslint.configs.recommended,
|
|
12
|
-
...tseslint.configs.strict,
|
|
13
|
-
eslintConfigPrettier,
|
|
14
|
-
{ ignores: ["**/*.js", "**/*.d.ts"] },
|
|
15
|
-
];
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "<%= name %>",
|
|
3
|
-
"version": "<%= version %>",
|
|
4
|
-
"description": "<%= description %>",
|
|
5
|
-
"author": "<%= author %>",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"build": "nf build",
|
|
8
|
-
"start": "nf start"<% if (lint) { %>,
|
|
9
|
-
"lint": "prettier --check . && eslint --format=pretty \"{client,server}/**/*.ts\"",
|
|
10
|
-
"format": "prettier --write . && eslint --fix --format=pretty \"{client,server}/**/*.ts\""<% } %>
|
|
11
|
-
},
|
|
12
|
-
"devDependencies": {<% if (lint) { %>
|
|
13
|
-
"@eslint/js": "^9.39.0",<% } %>
|
|
14
|
-
"@nanoforge-dev/asset-manager": "^1",
|
|
15
|
-
"@nanoforge-dev/cli": "latest",
|
|
16
|
-
"@nanoforge-dev/common": "^1",
|
|
17
|
-
"@nanoforge-dev/config": "^1",
|
|
18
|
-
"@nanoforge-dev/core": "^1",<% if (editor) { %>
|
|
19
|
-
"@nanoforge-dev/core-editor": "^1",<% } %>
|
|
20
|
-
"@nanoforge-dev/ecs-client": "^1",<% if (server) { %>
|
|
21
|
-
"@nanoforge-dev/ecs-server": "^1",<% } %>
|
|
22
|
-
"@nanoforge-dev/graphics-2d": "^1",<% if (editor) { %>
|
|
23
|
-
"@nanoforge-dev/graphics-2d-editor": "^1",<% } %>
|
|
24
|
-
"@nanoforge-dev/input": "^1",
|
|
25
|
-
"@nanoforge-dev/music": "^1",<% if (server) { %>
|
|
26
|
-
"@nanoforge-dev/network-client": "^1",
|
|
27
|
-
"@nanoforge-dev/network-server": "^1",<% } %>
|
|
28
|
-
"@nanoforge-dev/sound": "^1",<% if (lint) { %>
|
|
29
|
-
"@typescript-eslint/eslint-plugin": "^8.46.2",
|
|
30
|
-
"@typescript-eslint/parser": "^8.46.2",
|
|
31
|
-
"eslint": "^9.39.0",
|
|
32
|
-
"eslint-config-prettier": "^10.1.8",
|
|
33
|
-
"eslint-plugin-prettier": "^5.5.4",
|
|
34
|
-
"globals": "^16.5.0",
|
|
35
|
-
"lint-staged": "^16.2.6",
|
|
36
|
-
"prettier": "^3.6.2",<% } %>
|
|
37
|
-
"typescript": "^5.9.3"<% if (lint) { %>,
|
|
38
|
-
"typescript-eslint": "^8.46.2"<% } %>
|
|
39
|
-
},<% if (lint) { %>
|
|
40
|
-
"lint-staged": {
|
|
41
|
-
"**/*.ts": [
|
|
42
|
-
"prettier --write"
|
|
43
|
-
],
|
|
44
|
-
"{client,server}/**/*.ts": [
|
|
45
|
-
"eslint --fix"
|
|
46
|
-
]
|
|
47
|
-
},<% } %><% if (packageManager === "pnpm") { %>
|
|
48
|
-
"pnpm": {
|
|
49
|
-
"neverBuiltDependencies": []
|
|
50
|
-
},<% } %>
|
|
51
|
-
"private": true
|
|
52
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
-
"$id": "SchematicsNanoForgeBaseApplication",
|
|
4
|
-
"title": "NanoForge Base Application Options Schema",
|
|
5
|
-
"type": "object",
|
|
6
|
-
"properties": {
|
|
7
|
-
"name": {
|
|
8
|
-
"type": "string",
|
|
9
|
-
"description": "The name of the application",
|
|
10
|
-
"default": "nanoforge-app"
|
|
11
|
-
},
|
|
12
|
-
"version": {
|
|
13
|
-
"type": "string",
|
|
14
|
-
"description": "NanoForge application version",
|
|
15
|
-
"default": "0.0.0"
|
|
16
|
-
},
|
|
17
|
-
"author": {
|
|
18
|
-
"type": "string",
|
|
19
|
-
"description": "NanoForge application author",
|
|
20
|
-
"default": ""
|
|
21
|
-
},
|
|
22
|
-
"description": {
|
|
23
|
-
"type": "string",
|
|
24
|
-
"description": "NanoForge application description",
|
|
25
|
-
"default": ""
|
|
26
|
-
},
|
|
27
|
-
"directory": {
|
|
28
|
-
"type": "string",
|
|
29
|
-
"description": "NanoForge application destination directory"
|
|
30
|
-
},
|
|
31
|
-
"language": {
|
|
32
|
-
"type": "string",
|
|
33
|
-
"enum": ["ts", "js"],
|
|
34
|
-
"description": "NanoForge application language",
|
|
35
|
-
"default": "ts"
|
|
36
|
-
},
|
|
37
|
-
"strict": {
|
|
38
|
-
"type": "boolean",
|
|
39
|
-
"description": "With strict mode (TypeScript or JavaScript but only on compatible editor)",
|
|
40
|
-
"default": true
|
|
41
|
-
},
|
|
42
|
-
"lint": {
|
|
43
|
-
"type": "boolean",
|
|
44
|
-
"description": "Generate lint files",
|
|
45
|
-
"default": true
|
|
46
|
-
},
|
|
47
|
-
"packageManager": {
|
|
48
|
-
"type": "string",
|
|
49
|
-
"enum": ["npm", "yarn", "pnpm", "bun"],
|
|
50
|
-
"description": "NanoForge application package manager",
|
|
51
|
-
"default": "npm"
|
|
52
|
-
},
|
|
53
|
-
"server": {
|
|
54
|
-
"type": "boolean",
|
|
55
|
-
"description": "Configure a server for the application",
|
|
56
|
-
"default": false
|
|
57
|
-
},
|
|
58
|
-
"editor": {
|
|
59
|
-
"type": "boolean",
|
|
60
|
-
"description": "Add editor dependencies",
|
|
61
|
-
"default": false
|
|
62
|
-
},
|
|
63
|
-
"initFunctions": {
|
|
64
|
-
"type": "boolean",
|
|
65
|
-
"description": "Add init functions to the application",
|
|
66
|
-
"default": false
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
"required": ["name"]
|
|
70
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Rule } from "@angular-devkit/schematics";
|
|
2
|
-
|
|
3
|
-
//#region src/libs/configuration/configuration.schema.d.ts
|
|
4
|
-
interface ConfigurationSchema {
|
|
5
|
-
/**
|
|
6
|
-
* The name of the application
|
|
7
|
-
*/
|
|
8
|
-
name: string;
|
|
9
|
-
/**
|
|
10
|
-
* NanoForge application destination directory
|
|
11
|
-
*/
|
|
12
|
-
directory: string;
|
|
13
|
-
/**
|
|
14
|
-
* Configure a server for the application
|
|
15
|
-
*/
|
|
16
|
-
server: boolean;
|
|
17
|
-
/**
|
|
18
|
-
* NanoForge Application language
|
|
19
|
-
*/
|
|
20
|
-
language: "js" | "ts";
|
|
21
|
-
/**
|
|
22
|
-
* Add init functions to the application
|
|
23
|
-
*/
|
|
24
|
-
initFunctions: boolean;
|
|
25
|
-
}
|
|
26
|
-
//#endregion
|
|
27
|
-
//#region src/libs/configuration/configuration.factory.d.ts
|
|
28
|
-
declare const main: (schema: ConfigurationSchema) => Rule;
|
|
29
|
-
//#endregion
|
|
30
|
-
export { main };
|
|
31
|
-
//# sourceMappingURL=configuration.factory.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.factory.d.ts","names":["name","directory","server","language","initFunctions"],"sources":["../../../src/libs/configuration/configuration.schema.d.ts","../../../src/libs/configuration/configuration.factory.ts"],"mappings":";;;UAAiB,mBAAA;;;AAAjB;EAIEA,IAAAA;EAJkC;;;EASlCC,SAAAA;EAeAG;;AAAa;EAVbF,MAAAA;;ACqEF;;EDhEEC,QAAAA;ECgE2B;;;ED3D3BC,aAAAA;AAAAA;;;cC2DW,IAAA,GAAQ,MAAA,EAAQ,mBAAA,KAAsB,IAUlD"}
|