Repository navigation
Expand file tree
/
Copy pathpackages.zig
More file actions
62 lines (58 loc) · 2.33 KB
/
Copy pathpackages.zig
File metadata and controls
62 lines (58 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//! The packages that are made from declarations (`api.zig`), and where each is declared. The rest
//! are made by their own modules: the records (`records.zig`), the hooks (`hooks.zig`), the
//! interfaces (`interfaces.zig`), and the script's own object (`self`, `runtime.zig`).
const std = @import("std");
const script = @import("script.zig");
const runtime = @import("runtime.zig");
const api = @import("api.zig");
const core = @import("core.zig");
const world = @import("world.zig");
const nearby = @import("nearby.zig");
const drawing = @import("drawing.zig");
const input = @import("input.zig");
const camera = @import("camera.zig");
const audio = @import("audio.zig");
const storage = @import("storage.zig");
const async_package = @import("async.zig");
const vfs = @import("vfs.zig");
const util = @import("util.zig");
const orders = @import("orders.zig");
const radio = @import("radio.zig");
const options = @import("options.zig");
const postprocessing = @import("postprocessing.zig");
const shaders = @import("shaders.zig");
const rooms = @import("rooms.zig");
/// The namespace that declares `package`; null for a package made otherwise, or not made yet.
pub fn namespace(comptime package: script.Package) ?type {
return switch (package) {
.core => core.package,
.world => world.package,
.nearby => nearby.package,
.hud => drawing.Package(.hud),
.ui => drawing.Package(.ui),
.debug => drawing.debug,
.input => input.package,
.camera => camera.package,
.audio => audio.package,
.storage => storage.package,
.async => async_package.package,
.vfs => vfs.package,
.util => util.package,
.orders => orders.package,
.radio => radio.package,
.options => options.package,
.postprocessing => postprocessing.package,
.shaders => shaders.package,
.rooms => rooms.package,
.records, .hooks, .self, .interfaces => null,
};
}
/// Makes each declared package what `require` returns for it in `scripts`.
pub fn push(scripts: *runtime.Runtime) void {
inline for (comptime std.enums.values(script.Package)) |package| {
if (comptime namespace(package)) |Namespace| {
api.pushPackage(scripts.state, package, Namespace, @tagName(package));
scripts.setPackage(package);
}
}
}