@wildshard/shard-format 0.19.0 → 0.21.0
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wildshard/shard-format",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "The raw shardfile format: the spec, the validator and a validate CLI. The public, versioned contract every other repo builds on.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|
|
@@ -39,6 +39,10 @@ const STEER_BOOST_MIN = 1;
|
|
|
39
39
|
const STEER_LEAST = 0.005;
|
|
40
40
|
const STEER_SPEED_MAX = 60;
|
|
41
41
|
const STEER_TURN_MAX = Math.PI + Math.PI;
|
|
42
|
+
const STEER_PUSH_LEAST = 0;
|
|
43
|
+
const STEER_PUSH_MAX = 20;
|
|
44
|
+
/** SS-MS2a2: the look's wind on a sail, the ground direction it blows toward ([x, z], any length above 0) and the m/s a full sail adds straight downwind. */
|
|
45
|
+
const steerWind = v.strictObject({ toward: v.pipe(v.tuple([finite, finite]), v.someItem((axis: number): boolean => axis !== STEER_PUSH_LEAST, 'a wind push needs a direction')), push: bounded(STEER_PUSH_LEAST, STEER_PUSH_MAX) });
|
|
42
46
|
/** Numeric fixed policies compiled to the session's existing fenced guest driver. */
|
|
43
47
|
export const MoverDriverSchema: v.GenericSchema<MoverDriverRowsInput, MoverDriverRows> = v.variant('kind', [
|
|
44
48
|
v.strictObject({ kind: v.literal('waves'), damping: bounded(0, 1), waves: v.tuple([wave, wave, wave, wave]) }),
|
|
@@ -49,8 +53,8 @@ export const MoverDriverSchema: v.GenericSchema<MoverDriverRowsInput, MoverDrive
|
|
|
49
53
|
v.strictObject({ kind: v.literal('track') }),
|
|
50
54
|
v.strictObject({ kind: v.literal('pendulum'), axis: v.picklist(['x', 'y', 'z']), amplitude: bounded(0, Math.PI), period: bounded(0.005, 3600) }),
|
|
51
55
|
// SS-MS2a1: a vehicle its rider steers. Top speed (m/s), turn rate (rad/s), the boost multiplier, acceleration (m/s²),
|
|
52
|
-
// and whether it follows the ground under it or keeps its rest height. Board and leave are its carry's prompts.
|
|
53
|
-
v.strictObject({ kind: v.literal('steer'), speed: bounded(STEER_LEAST, STEER_SPEED_MAX), turn: bounded(STEER_LEAST, STEER_TURN_MAX), boost: bounded(STEER_BOOST_MIN, STEER_BOOST_MAX), accel: bounded(STEER_LEAST, STEER_ACCEL_MAX), ground: v.boolean() }),
|
|
56
|
+
// and whether it follows the ground under it or keeps its rest height. Board and leave are its carry's prompts; a wind push (SS-MS2a2) is optional.
|
|
57
|
+
v.strictObject({ kind: v.literal('steer'), speed: bounded(STEER_LEAST, STEER_SPEED_MAX), turn: bounded(STEER_LEAST, STEER_TURN_MAX), boost: bounded(STEER_BOOST_MIN, STEER_BOOST_MAX), accel: bounded(STEER_LEAST, STEER_ACCEL_MAX), ground: v.boolean(), wind: v.exactOptional(steerWind) }),
|
|
54
58
|
]);
|
|
55
59
|
/** Stop track, activation and fixed driver before ABI lowering. */
|
|
56
60
|
export const MoverMotionSchema: v.GenericSchema<MoverMotionRowsInput, MoverMotionRows> = v.strictObject({
|
|
@@ -99,7 +103,8 @@ export function lowerMoverMotion(input: unknown, rest: { at: { x: number; y: num
|
|
|
99
103
|
}
|
|
100
104
|
if (driver.kind === 'steer') {
|
|
101
105
|
if (trigger.kind !== 'interact' || Boolean(trigger.permission) || track !== undefined) { throw new Error('Steer driver requires an ungated board press without a clip'); }
|
|
102
|
-
|
|
106
|
+
const { wind } = driver, push = wind === undefined ? [] : [...wind.toward.map((axis: number): number => axis / Math.hypot(...wind.toward)), wind.push];
|
|
107
|
+
return { module: MOVER_DRIVER_MODULES.steer, input: [driver.speed, driver.turn, driver.boost, driver.accel, Number(driver.ground), rest.at.x, rest.at.y, rest.at.z, rest.euler.y, ...push] };
|
|
103
108
|
}
|
|
104
109
|
if (driver.kind === 'static') {
|
|
105
110
|
if (trigger.kind !== 'always' || track !== undefined) throw new Error('Static mover cannot consume a clip or interaction');
|
|
@@ -220,6 +225,7 @@ export type MoverDriverRows = ({
|
|
|
220
225
|
boost: number;
|
|
221
226
|
accel: number;
|
|
222
227
|
ground: boolean;
|
|
228
|
+
wind?: { toward: [number, number]; push: number };
|
|
223
229
|
});
|
|
224
230
|
interface MoverMotionRowsInputFields {
|
|
225
231
|
track?: MoverTrackRowsInput;
|