bevy-ts 0.1.0-alpha.5 → 0.1.0-alpha.6
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.
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
// The arena: a player
|
|
1
|
+
// The arena: a player, a HUD and the sun in TSX, the enemies placed by assets/levels/arena.bsn, a camera, and
|
|
2
2
|
// three systems that play. `bevy-ts dev src/game.tsx`.
|
|
3
3
|
import { app, type Commands, type Entity, type Local, type Mut, type Query, ref, type Res, Startup, Time, Transform, type u32, Update, type With, type Without } from "bevy-ts";
|
|
4
|
+
import { DirectionalLight } from "bevy-ts/bevy";
|
|
4
5
|
import { Foe, Health } from "./enemy.tsx";
|
|
5
6
|
import { Hud } from "./hud.tsx";
|
|
6
7
|
import { Player, PlayerUnit } from "./player.tsx";
|
|
7
8
|
|
|
8
|
-
/** The game's camera
|
|
9
|
-
*
|
|
9
|
+
/** The game's camera. It sits where the editor's first view does, so edit mode opens on the same
|
|
10
|
+
* view. */
|
|
10
11
|
export function stage(commands: Commands) {
|
|
11
12
|
commands.spawnNative("camera3d", { position: [-6, 5, 10], lookAt: [0, 0, 0] });
|
|
12
|
-
commands.spawnNative("directionalLight", { position: [3, 6, 2], lookAt: [0, 0, 0] });
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
/** Every 30 frames, each enemy within 10 units hurts the player by 5. */
|
|
@@ -44,6 +44,11 @@ export function cull(commands: Commands, enemies: Query<[Entity, Health], With<F
|
|
|
44
44
|
const player = ref();
|
|
45
45
|
app.scene("arena", () => (
|
|
46
46
|
<>
|
|
47
|
+
{/* The sun is scene, not a startup's, so edit mode shows the arena lit. At (3, 6, 2), looking at the origin. */}
|
|
48
|
+
<entity name="sun">
|
|
49
|
+
<DirectionalLight shadow_maps_enabled />
|
|
50
|
+
<Transform translation={[3, 6, 2]} rotation={[-0.4341, 0.4107, 0.2323, 0.7674]} />
|
|
51
|
+
</entity>
|
|
47
52
|
<PlayerUnit handle={player} />
|
|
48
53
|
<Hud player={player} />
|
|
49
54
|
</>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "cube",
|
|
3
3
|
"title": "Cube",
|
|
4
|
-
"description": "One cube bobbing on a sine wave: a component, a startup system and an update system.",
|
|
4
|
+
"description": "One cube bobbing on a sine wave: a scene, a component, a startup system and an update system.",
|
|
5
5
|
"entry": "src/game.ts"
|
|
6
6
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// The cube's scene: the cube and the sun, so edit mode shows them before any system runs.
|
|
2
|
+
// game.ts mounts it once `Mover` is defined.
|
|
3
|
+
import { DirectionalLight, Transform } from "bevy-ts/bevy";
|
|
4
|
+
import { Mover } from "./game.ts";
|
|
5
|
+
|
|
6
|
+
export const Cube = () => (
|
|
7
|
+
<>
|
|
8
|
+
{/* At (3, 6, 2), looking at the origin. */}
|
|
9
|
+
<entity name="sun">
|
|
10
|
+
<DirectionalLight shadow_maps_enabled />
|
|
11
|
+
<Transform translation={[3, 6, 2]} rotation={[-0.4341, 0.4107, 0.2323, 0.7674]} />
|
|
12
|
+
</entity>
|
|
13
|
+
<entity name="cube">
|
|
14
|
+
<Transform />
|
|
15
|
+
<mesh shape="cuboid" size={[1, 1, 1]} color="#ff8800" />
|
|
16
|
+
<Mover />
|
|
17
|
+
</entity>
|
|
18
|
+
</>
|
|
19
|
+
);
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { app, Component, type f32, Startup, Time, Transform, Update } from "bevy-ts";
|
|
2
2
|
import type { Commands, Mut, Query, Res } from "bevy-ts";
|
|
3
|
+
import { Cube } from "./cube.tsx";
|
|
3
4
|
|
|
4
5
|
export class Mover extends Component {
|
|
5
6
|
speed: f32 = 1;
|
|
6
7
|
amplitude: f32 = 2;
|
|
7
8
|
}
|
|
8
9
|
|
|
10
|
+
/** The game's camera; the cube and the sun are the scene's, in cube.tsx. */
|
|
9
11
|
export function scene(commands: Commands) {
|
|
10
12
|
commands.spawnNative("camera3d", { position: [-3, 3, 6], lookAt: [0, 0, 0] });
|
|
11
|
-
commands.spawnNative("directionalLight", { position: [3, 6, 2], lookAt: [0, 0, 0] });
|
|
12
|
-
const cube = commands.spawnNative("cuboid", { size: [1, 1, 1], color: "#f80" });
|
|
13
|
-
commands.entity(cube).insert(Mover.of());
|
|
14
13
|
}
|
|
15
14
|
|
|
16
15
|
export function bob(time: Res<Time>, q: Query<[Mover, Mut<Transform>]>) {
|
|
@@ -19,4 +18,5 @@ export function bob(time: Res<Time>, q: Query<[Mover, Mut<Transform>]>) {
|
|
|
19
18
|
});
|
|
20
19
|
}
|
|
21
20
|
|
|
21
|
+
app.scene("cube", Cube);
|
|
22
22
|
app.addSystems(Startup, scene).addSystems(Update, bob);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bevy-ts",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.6",
|
|
4
4
|
"description": "TypeScript for Bevy: components, systems and hot reload without recompiling Rust",
|
|
5
5
|
"license": "MIT OR Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -59,11 +59,11 @@
|
|
|
59
59
|
"examples"
|
|
60
60
|
],
|
|
61
61
|
"optionalDependencies": {
|
|
62
|
-
"@bevy-ts/darwin-arm64": "0.1.0-alpha.
|
|
63
|
-
"@bevy-ts/darwin-x64": "0.1.0-alpha.
|
|
64
|
-
"@bevy-ts/linux-arm64": "0.1.0-alpha.
|
|
65
|
-
"@bevy-ts/linux-x64": "0.1.0-alpha.
|
|
66
|
-
"@bevy-ts/win32-x64": "0.1.0-alpha.
|
|
62
|
+
"@bevy-ts/darwin-arm64": "0.1.0-alpha.6",
|
|
63
|
+
"@bevy-ts/darwin-x64": "0.1.0-alpha.6",
|
|
64
|
+
"@bevy-ts/linux-arm64": "0.1.0-alpha.6",
|
|
65
|
+
"@bevy-ts/linux-x64": "0.1.0-alpha.6",
|
|
66
|
+
"@bevy-ts/win32-x64": "0.1.0-alpha.6"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"json-schema-to-typescript": "^15.0.4",
|
package/protocol.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @generated by packages/bevy-ts/scripts/gen-protocol.mjs from protocol/bevy-ts.openrpc.json. Do not edit.
|
|
2
2
|
|
|
3
3
|
/** The protocol version these types describe. */
|
|
4
|
-
export const PROTOCOL_VERSION: "1.
|
|
4
|
+
export const PROTOCOL_VERSION: "1.19.0";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* An entity id: Entity::to_bits.
|
|
@@ -133,6 +133,13 @@ export type AssetLoadState = "not_loaded" | "loading" | "loaded" | "failed";
|
|
|
133
133
|
* via the `definition` "LevelHash".
|
|
134
134
|
*/
|
|
135
135
|
export type LevelHash = string;
|
|
136
|
+
/**
|
|
137
|
+
* Who opened a level: app.level (ts), add_level (rust), bevy-ts/level_open (editor) or a scene's sidecar.
|
|
138
|
+
*
|
|
139
|
+
* This interface was referenced by `ProtocolTypes`'s JSON-Schema
|
|
140
|
+
* via the `definition` "LevelOpener".
|
|
141
|
+
*/
|
|
142
|
+
export type LevelOpener = "ts" | "rust" | "editor" | "sidecar";
|
|
136
143
|
/**
|
|
137
144
|
* A value the writer prints: a number (a float), {int}, a bool, a string, {type, lanes} for a vector or {path} for a variant or constant.
|
|
138
145
|
*
|
|
@@ -307,6 +314,10 @@ export type LevelOp =
|
|
|
307
314
|
path: string[];
|
|
308
315
|
component: string;
|
|
309
316
|
};
|
|
317
|
+
/**
|
|
318
|
+
* Who opened a level: app.level (ts), add_level (rust), bevy-ts/level_open (editor) or a scene's sidecar.
|
|
319
|
+
*/
|
|
320
|
+
export type LevelOpener1 = "ts" | "rust" | "editor" | "sidecar";
|
|
310
321
|
|
|
311
322
|
/**
|
|
312
323
|
* This interface was referenced by `ProtocolTypes`'s JSON-Schema
|
|
@@ -1391,6 +1402,10 @@ export interface ViewportModeResult {
|
|
|
1391
1402
|
ui: boolean;
|
|
1392
1403
|
gamepadUnfocused: boolean;
|
|
1393
1404
|
paused: boolean;
|
|
1405
|
+
/**
|
|
1406
|
+
* Whether the game's TS `Startup` systems have run in this world: false under `bevy-ts dev --edit` until the first play or step (1.18). Absent from older engines: treat the game as started.
|
|
1407
|
+
*/
|
|
1408
|
+
started?: boolean;
|
|
1394
1409
|
}
|
|
1395
1410
|
/**
|
|
1396
1411
|
* The editor camera's pose.
|
|
@@ -1900,6 +1915,7 @@ export interface LevelInfo {
|
|
|
1900
1915
|
* The level's asset path.
|
|
1901
1916
|
*/
|
|
1902
1917
|
path: string;
|
|
1918
|
+
opener: LevelOpener;
|
|
1903
1919
|
/**
|
|
1904
1920
|
* The root file's hash as last applied.
|
|
1905
1921
|
*/
|
|
@@ -1921,6 +1937,55 @@ export interface LevelInfo {
|
|
|
1921
1937
|
export interface LevelListResult {
|
|
1922
1938
|
levels: LevelInfo[];
|
|
1923
1939
|
}
|
|
1940
|
+
/**
|
|
1941
|
+
* This interface was referenced by `ProtocolTypes`'s JSON-Schema
|
|
1942
|
+
* via the `definition` "LevelOpenParams".
|
|
1943
|
+
*/
|
|
1944
|
+
export interface LevelOpenParams {
|
|
1945
|
+
/**
|
|
1946
|
+
* An asset path ending in .bsn.
|
|
1947
|
+
*/
|
|
1948
|
+
file: string;
|
|
1949
|
+
}
|
|
1950
|
+
/**
|
|
1951
|
+
* This interface was referenced by `ProtocolTypes`'s JSON-Schema
|
|
1952
|
+
* via the `definition` "LevelOpenResult".
|
|
1953
|
+
*/
|
|
1954
|
+
export interface LevelOpenResult {
|
|
1955
|
+
status: "opened" | "failed";
|
|
1956
|
+
/**
|
|
1957
|
+
* opened: the level's level_list entry.
|
|
1958
|
+
*/
|
|
1959
|
+
level?: LevelInfo | null;
|
|
1960
|
+
/**
|
|
1961
|
+
* failed: invalid (not a .bsn path inside the asset root), not-found, or load (a file fails to parse or resolve).
|
|
1962
|
+
*/
|
|
1963
|
+
reason?: string | null;
|
|
1964
|
+
/**
|
|
1965
|
+
* failed: each with its file, line and column where known.
|
|
1966
|
+
*/
|
|
1967
|
+
diagnostics?: LevelDiagnostic[];
|
|
1968
|
+
}
|
|
1969
|
+
/**
|
|
1970
|
+
* This interface was referenced by `ProtocolTypes`'s JSON-Schema
|
|
1971
|
+
* via the `definition` "LevelCloseParams".
|
|
1972
|
+
*/
|
|
1973
|
+
export interface LevelCloseParams {
|
|
1974
|
+
/**
|
|
1975
|
+
* An open level's asset path.
|
|
1976
|
+
*/
|
|
1977
|
+
file: string;
|
|
1978
|
+
}
|
|
1979
|
+
/**
|
|
1980
|
+
* This interface was referenced by `ProtocolTypes`'s JSON-Schema
|
|
1981
|
+
* via the `definition` "LevelCloseResult".
|
|
1982
|
+
*/
|
|
1983
|
+
export interface LevelCloseResult {
|
|
1984
|
+
/**
|
|
1985
|
+
* False when the level was not open.
|
|
1986
|
+
*/
|
|
1987
|
+
closed: boolean;
|
|
1988
|
+
}
|
|
1924
1989
|
/**
|
|
1925
1990
|
* Give `entity`, or `level` and `namePath`.
|
|
1926
1991
|
*
|
|
@@ -2097,7 +2162,7 @@ export interface LevelApplyResult {
|
|
|
2097
2162
|
* via the `definition` "LevelWatchMessage".
|
|
2098
2163
|
*/
|
|
2099
2164
|
export interface LevelWatchMessage {
|
|
2100
|
-
event: "loaded" | "failed" | "written" | "external" | "rebased" | "conflict";
|
|
2165
|
+
event: "opened" | "closed" | "loaded" | "failed" | "written" | "external" | "rebased" | "conflict";
|
|
2101
2166
|
/**
|
|
2102
2167
|
* The file the event is about.
|
|
2103
2168
|
*/
|
|
@@ -2110,6 +2175,7 @@ export interface LevelWatchMessage {
|
|
|
2110
2175
|
id?: number | null;
|
|
2111
2176
|
reason?: string | null;
|
|
2112
2177
|
diagnostics?: LevelDiagnostic[];
|
|
2178
|
+
opener?: LevelOpener1;
|
|
2113
2179
|
}
|
|
2114
2180
|
/**
|
|
2115
2181
|
* This interface was referenced by `ProtocolTypes`'s JSON-Schema
|
|
@@ -2285,6 +2351,8 @@ export interface Methods {
|
|
|
2285
2351
|
"bevy-ts/asset_preview_control": { params: AssetPreviewControlParams; result: AssetPreviewControlResult; crate: "bevy-ts-viewport"; watch: false };
|
|
2286
2352
|
"bevy-ts/asset_preview_close": { params: AssetPreviewCloseParams; result: AssetPreviewCloseResult; crate: "bevy-ts-viewport"; watch: false };
|
|
2287
2353
|
"bevy-ts/level_list": { params: undefined; result: LevelListResult; crate: "bevy-ts-levels"; watch: false };
|
|
2354
|
+
"bevy-ts/level_open": { params: LevelOpenParams; result: LevelOpenResult; crate: "bevy-ts-levels"; watch: false };
|
|
2355
|
+
"bevy-ts/level_close": { params: LevelCloseParams; result: LevelCloseResult; crate: "bevy-ts-levels"; watch: false };
|
|
2288
2356
|
"bevy-ts/level_node": { params: LevelNodeParams; result: LevelNodeResult; crate: "bevy-ts-levels"; watch: false };
|
|
2289
2357
|
"bevy-ts/level_catalog": { params: undefined; result: LevelCatalogResult; crate: "bevy-ts-levels"; watch: false };
|
|
2290
2358
|
"bevy-ts/level_write": { params: LevelWriteParams; result: LevelWriteResult; crate: "bevy-ts-levels"; watch: false };
|