@modlock/modlock 0.0.0-stage → 0.1.64

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/console.js ADDED
@@ -0,0 +1,40 @@
1
+ /*! Includes protobuf-es-lite under the Apache License 2.0: https://www.apache.org/licenses/LICENSE-2.0 */
2
+
3
+ // js/src/console.ts
4
+ import { serverCommand } from "modlock";
5
+ function set(name, value) {
6
+ return serverCommand(`${name} ${format(value)}`);
7
+ }
8
+ function format(value) {
9
+ if (typeof value === "boolean") {
10
+ return value ? "1" : "0";
11
+ }
12
+ return typeof value === "string" ? `"${value}"` : String(value);
13
+ }
14
+ function run(name, ...args) {
15
+ return serverCommand([name, ...args].join(" "));
16
+ }
17
+ function apply(settings) {
18
+ const refused = [];
19
+ for (const [name, value] of Object.entries(settings)) {
20
+ if (value !== void 0 && !serverCommand(name + " " + format(value))) {
21
+ refused.push(name);
22
+ }
23
+ }
24
+ return refused;
25
+ }
26
+ var arena = {
27
+ sv_hibernate_when_empty: false,
28
+ citadel_solo_bot_match: false,
29
+ citadel_koth_enabled: false,
30
+ citadel_trooper_spawn_enabled: false,
31
+ citadel_neutral_spawn_enabled: false,
32
+ citadel_spawn_practice_bots: false,
33
+ citadel_start_players_on_zipline: false
34
+ };
35
+ export {
36
+ apply,
37
+ arena,
38
+ run,
39
+ set
40
+ };
package/curve.d.ts ADDED
@@ -0,0 +1,149 @@
1
+ import type { CameraValue, Vector } from './host.gen.js';
2
+ /**
3
+ * LerpShape is the shape the game's own lerp gives a move: Valve's bias and
4
+ * gain curves, each linear at 0.5. An omitted value is linear.
5
+ */
6
+ export interface LerpShape {
7
+ /** bias below 0.5 starts slow and speeds up; above, starts fast. */
8
+ readonly bias?: number;
9
+ /** gain above 0.5 starts and ends slow; below, fast at both ends. */
10
+ readonly gain?: number;
11
+ }
12
+ /**
13
+ * Ease maps the fraction of a span played, 0 to 1, to the fraction moved. An
14
+ * ease with a lerp shape is one the game draws itself, so a move with it
15
+ * plays as one lerp.
16
+ */
17
+ export interface Ease {
18
+ (t: number): number;
19
+ readonly lerp?: LerpShape;
20
+ }
21
+ /** ease holds the common easing curves. */
22
+ export declare const ease: {
23
+ /** linear moves at an even pace. */
24
+ readonly linear: Ease;
25
+ /** bias is the game's bias curve; see LerpShape. */
26
+ readonly bias: (b: number) => Ease;
27
+ /** gain is the game's gain curve; see LerpShape. */
28
+ readonly gain: (g: number) => Ease;
29
+ /** in starts slow and speeds up. */
30
+ readonly in: (t: number) => number;
31
+ /** out starts fast and slows to a stop. */
32
+ readonly out: (t: number) => number;
33
+ /** inOut starts and ends slow. */
34
+ readonly inOut: (t: number) => number;
35
+ /** sine starts and ends slow, more gently than inOut. */
36
+ readonly sine: (t: number) => number;
37
+ /** back passes its end a little and settles back onto it. */
38
+ readonly back: (t: number) => number;
39
+ /** elastic overshoots its end and rings down onto it. */
40
+ readonly elastic: (t: number) => number;
41
+ /** bounce drops onto its end and bounces to rest. */
42
+ readonly bounce: (t: number) => number;
43
+ };
44
+ /** CameraSpan is one piece of a curve. */
45
+ export interface CameraSpan {
46
+ /** duration is how long the span plays, in seconds. */
47
+ readonly duration: number;
48
+ /** at returns the value a fraction u of the way through, 0 to 1. */
49
+ readonly at: (u: number) => CameraValue;
50
+ /**
51
+ * lerp marks a span the game plays as one lerp from at(0) to at(1) with this
52
+ * shape; a span without it is sampled.
53
+ */
54
+ readonly lerp?: LerpShape;
55
+ }
56
+ /** CameraCurve is a list of spans played in order. */
57
+ export type CameraCurve = readonly CameraSpan[];
58
+ /** CameraKey is one point of a keyframed curve. */
59
+ export interface CameraKey {
60
+ /** at is the time of the key, in seconds after the curve starts. */
61
+ at: number;
62
+ /** value is the param's value at the key. */
63
+ value: CameraValue;
64
+ /** ease shapes the move from the key before this one; omitted, linear. */
65
+ ease?: Ease;
66
+ }
67
+ /** KeyframeOptions shapes the curve between keys. */
68
+ export interface KeyframeOptions {
69
+ /**
70
+ * smooth passes through the keys on a curve, without corners, instead of a
71
+ * straight line from each to the next.
72
+ */
73
+ smooth?: boolean;
74
+ }
75
+ /** line moves from one value to another over a duration. */
76
+ export declare function line(from: CameraValue, to: CameraValue, duration: number, shape?: Ease): CameraCurve;
77
+ /** hold keeps a value for a duration. */
78
+ export declare function hold(value: CameraValue, duration: number): CameraCurve;
79
+ /**
80
+ * keyframes passes through keys in time order. A key's ease shapes the move
81
+ * into it; two keys at one time make a jump, and two with one value a hold.
82
+ * The curve starts at the first key, so a first key after zero waits there.
83
+ */
84
+ export declare function keyframes(keys: readonly CameraKey[], options?: KeyframeOptions): CameraCurve;
85
+ /** ThroughOptions times a curve through points by its speed. */
86
+ export interface ThroughOptions extends KeyframeOptions {
87
+ /** speed is how far the param moves each second. */
88
+ speed: number;
89
+ /** ease shapes each move between two points; omitted, linear. */
90
+ ease?: Ease;
91
+ }
92
+ /**
93
+ * through moves through points at a speed, so each move takes as long as its
94
+ * distance needs.
95
+ */
96
+ export declare function through(points: readonly CameraValue[], options: ThroughOptions): CameraCurve;
97
+ /** OrbitOptions circles a point. */
98
+ export interface OrbitOptions {
99
+ /** center is the point the circle goes around. */
100
+ center: Vector;
101
+ /** radius is the circle's radius. */
102
+ radius: number;
103
+ /** duration is how long the orbit takes, in seconds. */
104
+ duration: number;
105
+ /** turns is how many times it goes around; omitted, 1. Negative turns clockwise. */
106
+ turns?: number;
107
+ /** start is the angle it starts at, in degrees from the x axis; omitted, 0. */
108
+ start?: number;
109
+ /** rise is how far it climbs over the whole orbit; omitted, 0. */
110
+ rise?: number;
111
+ /** ease shapes the pace around the circle; omitted, linear. */
112
+ ease?: Ease;
113
+ }
114
+ /** orbit circles a point, for the target param, as a spiral when it rises. */
115
+ export declare function orbit(options: OrbitOptions): CameraCurve;
116
+ /** WaveOptions swings a number around zero. */
117
+ export interface WaveOptions {
118
+ /** amplitude is how far the first swing reaches. */
119
+ amplitude: number;
120
+ /** frequency is how many full swings it makes each second. */
121
+ frequency: number;
122
+ /** duration is how long it swings, in seconds. */
123
+ duration: number;
124
+ /**
125
+ * decay shrinks the swings to nothing by the end when true, as a shake
126
+ * settles; omitted, they keep their size.
127
+ */
128
+ decay?: boolean;
129
+ }
130
+ /** wave swings a number to either side of zero and ends at zero. */
131
+ export declare function wave(options: WaveOptions): CameraCurve;
132
+ /** chain plays curves one after another. */
133
+ export declare function chain(...curves: readonly CameraCurve[]): CameraCurve;
134
+ /**
135
+ * reverse plays a curve backward. A gain curve is its own mirror and stays one
136
+ * lerp; a biased span backward is no bias curve, so it is sampled.
137
+ */
138
+ export declare function reverse(curve: CameraCurve): CameraCurve;
139
+ /** repeat plays a curve a number of times. */
140
+ export declare function repeat(curve: CameraCurve, times: number): CameraCurve;
141
+ /** pingPong plays a curve forward and then backward. */
142
+ export declare function pingPong(curve: CameraCurve): CameraCurve;
143
+ /** durationOf returns how long a curve plays, in seconds. */
144
+ export declare function durationOf(curve: CameraCurve): number;
145
+ /**
146
+ * valueAt returns a curve's value a number of seconds in, or its last value
147
+ * once it has ended. An empty curve has no value.
148
+ */
149
+ export declare function valueAt(curve: CameraCurve, seconds: number): CameraValue | undefined;
package/dropper.d.ts ADDED
@@ -0,0 +1,69 @@
1
+ import { type MovementSample, type Player } from './host.gen.js';
2
+ import { type LoadedSpot, type Spot } from './spot.js';
3
+ /** CatalogEntry is one object builders can drop. */
4
+ export interface CatalogEntry {
5
+ /** name is what builders read in the catalog. */
6
+ readonly name: string;
7
+ /** category groups entries in the catalog, such as Crates. */
8
+ readonly category: string;
9
+ /** model is the model's path, which the mode precached. */
10
+ readonly model: string;
11
+ /** scale multiplies the model's size; the default is 1. */
12
+ readonly scale?: number;
13
+ /** bounce makes the object launch heroes upward at this speed. */
14
+ readonly bounce?: number;
15
+ }
16
+ /**
17
+ * dropperButtons are the keys a builder uses, which the mode includes in
18
+ * watchInput: fire drops, melee picks up or puts back, parry deletes, reload
19
+ * turns, the first two abilities page the catalog and the third undoes.
20
+ */
21
+ export declare const dropperButtons: bigint;
22
+ /** Dropper is in-game building for one mode's spot. */
23
+ export declare class Dropper {
24
+ private readonly catalog;
25
+ spot: LoadedSpot;
26
+ /** changed is called with the spot after every drop, move and delete. */
27
+ changed?: (spot: Spot) => void;
28
+ /** capacity bounds how many objects the spot holds. */
29
+ capacity: number;
30
+ private builders;
31
+ constructor(catalog: readonly CatalogEntry[], spot: LoadedSpot);
32
+ /** building reports whether player is building. */
33
+ building(player: Player): boolean;
34
+ /** toggle starts or stops building for player. */
35
+ toggle(player: Player): void;
36
+ /** stop ends building for player, putting back an object they held. */
37
+ stop(player: Player): void;
38
+ /** replace swaps the spot builders drop into, as when a saved spot loads. */
39
+ replace(spot: LoadedSpot): void;
40
+ /**
41
+ * frame moves each builder's preview to their aim, drops builders who
42
+ * left, and launches heroes standing on bouncing objects.
43
+ */
44
+ frame(movement: readonly MovementSample[]): void;
45
+ /** input applies a builder's key presses. */
46
+ input(player: Player, pressed: bigint): void;
47
+ /** select shows the catalog entry at index, wrapping at either end. */
48
+ select(player: Player, index: number): void;
49
+ /** turn turns player's preview by degrees. */
50
+ turn(player: Player, degrees: number): void;
51
+ /** face sets player's preview to face degrees, and shows it on the panel's slider. */
52
+ face(player: Player, degrees: number): void;
53
+ /** undo removes player's newest drop that still stands. */
54
+ undo(player: Player): void;
55
+ /** object returns what the builder's preview stands for. */
56
+ private object;
57
+ /** aim places the builder's preview where they look. */
58
+ private aim;
59
+ /** preview draws the builder's preview at their aim, or hides it. */
60
+ private preview;
61
+ /** drop places the preview as a solid object. */
62
+ private drop;
63
+ /** pickUp lifts the aimed object to move it, or puts a held one back. */
64
+ private pickUp;
65
+ /** delete removes the aimed object. */
66
+ private delete;
67
+ /** draw shows the builder the catalog and their keys. */
68
+ private draw;
69
+ }