@wildshard/shard-format 0.6.0 → 0.8.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 +5 -2
- package/src/format/compendiumRows.ts +10 -8
- package/src/format/compendiumSketches.ts +10 -5
- package/src/format/creatures.ts +5 -3
- package/src/format/harvest-rows.ts +103 -0
- package/src/format/look-details-bytes.ts +133 -0
- package/src/format/look-details.ts +255 -0
- package/src/format/rows.ts +10 -5
- package/src/format/shardSchema.ts +21 -1
- package/src/format/speciesBookRows.ts +6 -5
- package/src/format/speciesLooks.ts +4 -3
- package/src/format/speciesPrograms.ts +18 -7
- package/src/format/strike-debris.ts +108 -0
- package/src/format/targets.ts +19 -2
- package/src/format/weaponProfiles.ts +6 -42
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wildshard/shard-format",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.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": {
|
|
@@ -247,6 +247,7 @@
|
|
|
247
247
|
"./postGraphDocument": "./src/format/postGraphDocument.ts",
|
|
248
248
|
"./postGraphLook": "./src/format/postGraphLook.ts",
|
|
249
249
|
"./postStack": "./src/format/postStack.ts",
|
|
250
|
+
"./look-details": "./src/format/look-details.ts",
|
|
250
251
|
"./look-light": "./src/format/look-light.ts",
|
|
251
252
|
"./look-render": "./src/format/look-render.ts",
|
|
252
253
|
"./pool-surface": "./src/format/pool-surface.ts",
|
|
@@ -395,7 +396,9 @@
|
|
|
395
396
|
"./worldSceneWeld": "./src/format/worldSceneWeld.ts",
|
|
396
397
|
"./worldScenes": "./src/format/worldScenes.ts",
|
|
397
398
|
"./worldTargets": "./src/format/worldTargets.ts",
|
|
398
|
-
"./worldUpdates": "./src/format/worldUpdates.ts"
|
|
399
|
+
"./worldUpdates": "./src/format/worldUpdates.ts",
|
|
400
|
+
"./strikeDebris": "./src/format/strike-debris.ts",
|
|
401
|
+
"./harvestRows": "./src/format/harvest-rows.ts"
|
|
399
402
|
},
|
|
400
403
|
"engines": {
|
|
401
404
|
"node": ">=24.18.0"
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { sketchReference } from './sketch.ts';
|
|
1
2
|
import * as v from 'valibot';
|
|
2
3
|
|
|
3
4
|
const key = v.pipe(v.string(), v.minLength(1), v.maxLength(128));
|
|
@@ -17,8 +18,11 @@ const entry = v.strictObject({ id: key, kind: entryKind, tab: key, name: text, n
|
|
|
17
18
|
const stat = v.strictObject({ label: text, value: v.picklist(['seen', 'taken', 'best', 'rarity', 'status']),
|
|
18
19
|
fallback: v.exactOptional(text), suffix: v.exactOptional(text), words: v.exactOptional(v.record(key, text)) });
|
|
19
20
|
const stats = v.pipe(v.array(stat), v.maxLength(8));
|
|
20
|
-
const
|
|
21
|
-
|
|
21
|
+
const iconSelectors = { entryKind: v.exactOptional(entryKind), matchKind: v.exactOptional(key) };
|
|
22
|
+
const legacyIcon = v.strictObject({ ...iconSelectors, icon: v.picklist(['antlers', 'ghost', 'ironhide', 'deer', 'boar', 'elk', 'bear']) });
|
|
23
|
+
const iconImage = v.pipe(text, v.check(sketchReference, 'bounded inert SVG data or admitted image hash'));
|
|
24
|
+
const imageIcon = v.strictObject({ ...iconSelectors, image: iconImage, tint: v.exactOptional(v.literal('currentColor')) });
|
|
25
|
+
const icon = v.union([imageIcon, legacyIcon]);
|
|
22
26
|
const cell = v.strictObject({ x: finite, y: finite, w: positive, h: positive });
|
|
23
27
|
const trophy = v.strictObject({ entry: key, outline: key, mount: v.exactOptional(v.strictObject({ kind: key, variant: key })), title: text });
|
|
24
28
|
const wall = v.strictObject({ cabin: natural, at: v.tuple([finite, finite, finite]), yaw: finite, width: positive,
|
|
@@ -47,12 +51,14 @@ export function journalRowRules(row: JournalRow): readonly string[] {
|
|
|
47
51
|
}
|
|
48
52
|
/** All raster images must be charged immutable library roots; logical URLs are resolved by the admitted product. */
|
|
49
53
|
export function journalImageRefs(row: JournalRow): readonly string[] {
|
|
54
|
+
const icons = row.icons.flatMap((value: Readonly<JournalIcon>): string[] => 'image' in value && !value.image.startsWith('data:') ? [value.image] : []);
|
|
50
55
|
return [...new Set([...row.entries.flatMap(value => [value.plate.sketch, ...value.plate.silhouette === undefined ? [] : [value.plate.silhouette]]),
|
|
51
|
-
...row.chalk === undefined ? [] : [row.chalk.atlas]])];
|
|
56
|
+
...row.chalk === undefined ? [] : [row.chalk.atlas], ...icons])];
|
|
52
57
|
}
|
|
53
58
|
|
|
54
59
|
/** Admitted data contracts, independent of validator implementation metadata. */
|
|
55
60
|
export type JournalRowInput = JournalRow;
|
|
61
|
+
type JournalIcon = { entryKind?: 'species' | 'variant' | 'elite' | 'boss' | 'place'; matchKind?: string } & ({ image: string; tint?: 'currentColor' } | { icon: 'antlers' | 'ghost' | 'ironhide' | 'deer' | 'boar' | 'elk' | 'bear' });
|
|
56
62
|
interface JournalRowFields {
|
|
57
63
|
kind: 'journal';
|
|
58
64
|
id: string;
|
|
@@ -68,11 +74,7 @@ interface JournalRowFields {
|
|
|
68
74
|
place: string;
|
|
69
75
|
default: string;
|
|
70
76
|
};
|
|
71
|
-
icons:
|
|
72
|
-
entryKind?: 'species' | 'variant' | 'elite' | 'boss' | 'place';
|
|
73
|
-
matchKind?: string;
|
|
74
|
-
icon: 'antlers' | 'ghost' | 'ironhide' | 'deer' | 'boar' | 'elk' | 'bear';
|
|
75
|
-
})[];
|
|
77
|
+
icons: JournalIcon[];
|
|
76
78
|
stats: {
|
|
77
79
|
place: ({
|
|
78
80
|
label: string;
|
|
@@ -3,14 +3,20 @@ import { parseSketchSvg, sketchReference, type CompendiumSketch } from './sketch
|
|
|
3
3
|
import type { ShardRows } from './rows.ts';
|
|
4
4
|
|
|
5
5
|
const prefix = 'data:image/svg+xml,';
|
|
6
|
+
type SketchRow = Readonly<{ kind: 'journal'; icons: readonly Readonly<{ image?: string; icon?: string }>[] }> | Readonly<{ kind?: never; entries: readonly Readonly<{ sketch: string }>[] }>;
|
|
7
|
+
function sketchRefs(row: SketchRow): string[] {
|
|
8
|
+
if (row.kind === 'journal') {
|
|
9
|
+
return row.icons.flatMap((value: Readonly<{ image?: string; icon?: string }>): string[] => value.image?.startsWith(prefix) === true ? [value.image] : []);
|
|
10
|
+
}
|
|
11
|
+
return row.entries.map((entry: Readonly<{ sketch: string }>): string => entry.sketch);
|
|
12
|
+
}
|
|
6
13
|
|
|
7
14
|
/** Resolve each distinct sketch once from already-admitted bytes and derive its extra raster cost. */
|
|
8
15
|
export function compendiumSketches(rows: Pick<ShardRows, 'compendiums'>, assets: ReadonlyMap<string, Uint8Array>): ReadonlyMap<string, CompendiumSketch> {
|
|
9
16
|
const result = new Map<string, CompendiumSketch>();
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const ref = entry.sketch; if (result.has(ref)) continue;
|
|
17
|
+
const refs = rows.compendiums.flatMap(sketchRefs);
|
|
18
|
+
for (const ref of refs) {
|
|
19
|
+
if (result.has(ref)) continue;
|
|
14
20
|
if (!sketchReference(ref)) throw new Error('Compendium sketch must be bounded inert SVG data or an admitted hash');
|
|
15
21
|
if (ref.startsWith(prefix)) result.set(ref, parseSketchSvg(decodeURIComponent(ref.slice(prefix.length))));
|
|
16
22
|
else {
|
|
@@ -18,6 +24,5 @@ export function compendiumSketches(rows: Pick<ShardRows, 'compendiums'>, assets:
|
|
|
18
24
|
result.set(ref, parseSketchSvg(new TextDecoder('utf-8', { fatal: true }).decode(bytes)));
|
|
19
25
|
}
|
|
20
26
|
}
|
|
21
|
-
}
|
|
22
27
|
return result;
|
|
23
28
|
}
|
package/src/format/creatures.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { StrikeDebrisSchema } from './strike-debris.ts';
|
|
2
|
+
import type { StrikeDebrisPolicy } from './strike-debris.ts';
|
|
1
3
|
import * as v from 'valibot';
|
|
2
4
|
import { ReturnProgramSchema } from './namedJsonContracts.ts';
|
|
3
5
|
import { NativeRidingSchema } from './nativeRiding.ts';
|
|
@@ -102,8 +104,8 @@ const strikeWeight = v.variant('kind', [
|
|
|
102
104
|
]);
|
|
103
105
|
const strikeTag = v.custom<`${string}.${string}`>(value => typeof value === 'string' && value.length <= 128 && /^[a-z][a-zA-Z0-9.-]*\.[a-zA-Z0-9.*-]+$/u.test(value));
|
|
104
106
|
/** Full native strike data, including its finite score program; no author callback is admitted. */
|
|
105
|
-
export const CreatureStrikeSchema: v.StrictObjectSchema<{ readonly id: v.GenericSchema<CreatureStrikeRowsInput['id'], CreatureStrikeRows['id']>; readonly shape: v.GenericSchema<CreatureStrikeRowsInput['shape'], CreatureStrikeRows['shape']>; readonly windup: v.GenericSchema<CreatureStrikeRowsInput['windup'], CreatureStrikeRows['windup']>; readonly active: v.GenericSchema<CreatureStrikeRowsInput['active'], CreatureStrikeRows['active']>; readonly recover: v.GenericSchema<CreatureStrikeRowsInput['recover'], CreatureStrikeRows['recover']>; readonly cooldown: v.GenericSchema<CreatureStrikeRowsInput['cooldown'], CreatureStrikeRows['cooldown']>; readonly range: v.GenericSchema<CreatureStrikeRowsInput['range'], CreatureStrikeRows['range']>; readonly damage: v.GenericSchema<CreatureStrikeRowsInput['damage'], CreatureStrikeRows['damage']>; readonly tags: v.SchemaWithPipe<readonly [v.ArraySchema<v.GenericSchema<CreatureStrikeRowsInput['tags'][number], CreatureStrikeRows['tags'][number]>, undefined>, v.MaxLengthAction<CreatureStrikeRows['tags'], 32, undefined>]>; readonly weight: v.GenericSchema<CreatureStrikeRowsInput['weight'], CreatureStrikeRows['weight']>; readonly units: v.ExactOptionalSchema<v.GenericSchema<Exclude<CreatureStrikeRowsInput['units'], undefined>, Exclude<CreatureStrikeRows['units'], undefined>>, undefined>; readonly alternatives: v.ExactOptionalSchema<v.GenericSchema<Exclude<CreatureStrikeRowsInput['alternatives'], undefined>, Exclude<CreatureStrikeRows['alternatives'], undefined>>, undefined>; readonly motion: v.ExactOptionalSchema<v.GenericSchema<Exclude<CreatureStrikeRowsInput['motion'], undefined>, Exclude<CreatureStrikeRows['motion'], undefined>>, undefined>; readonly eligibility: v.ExactOptionalSchema<v.GenericSchema<Exclude<CreatureStrikeRowsInput['eligibility'], undefined>, Exclude<CreatureStrikeRows['eligibility'], undefined>>, undefined>; }, undefined> = v.strictObject({
|
|
106
|
-
id: strikeId, shape: strikeShape, windup: strikeNonnegative, active: strikeNonnegative, recover: strikeNonnegative, cooldown: strikeNonnegative,
|
|
107
|
+
export const CreatureStrikeSchema: v.StrictObjectSchema<{ readonly debris: v.ExactOptionalSchema<v.GenericSchema<StrikeDebrisPolicy>, undefined>; readonly id: v.GenericSchema<CreatureStrikeRowsInput['id'], CreatureStrikeRows['id']>; readonly shape: v.GenericSchema<CreatureStrikeRowsInput['shape'], CreatureStrikeRows['shape']>; readonly windup: v.GenericSchema<CreatureStrikeRowsInput['windup'], CreatureStrikeRows['windup']>; readonly active: v.GenericSchema<CreatureStrikeRowsInput['active'], CreatureStrikeRows['active']>; readonly recover: v.GenericSchema<CreatureStrikeRowsInput['recover'], CreatureStrikeRows['recover']>; readonly cooldown: v.GenericSchema<CreatureStrikeRowsInput['cooldown'], CreatureStrikeRows['cooldown']>; readonly range: v.GenericSchema<CreatureStrikeRowsInput['range'], CreatureStrikeRows['range']>; readonly damage: v.GenericSchema<CreatureStrikeRowsInput['damage'], CreatureStrikeRows['damage']>; readonly tags: v.SchemaWithPipe<readonly [v.ArraySchema<v.GenericSchema<CreatureStrikeRowsInput['tags'][number], CreatureStrikeRows['tags'][number]>, undefined>, v.MaxLengthAction<CreatureStrikeRows['tags'], 32, undefined>]>; readonly weight: v.GenericSchema<CreatureStrikeRowsInput['weight'], CreatureStrikeRows['weight']>; readonly units: v.ExactOptionalSchema<v.GenericSchema<Exclude<CreatureStrikeRowsInput['units'], undefined>, Exclude<CreatureStrikeRows['units'], undefined>>, undefined>; readonly alternatives: v.ExactOptionalSchema<v.GenericSchema<Exclude<CreatureStrikeRowsInput['alternatives'], undefined>, Exclude<CreatureStrikeRows['alternatives'], undefined>>, undefined>; readonly motion: v.ExactOptionalSchema<v.GenericSchema<Exclude<CreatureStrikeRowsInput['motion'], undefined>, Exclude<CreatureStrikeRows['motion'], undefined>>, undefined>; readonly eligibility: v.ExactOptionalSchema<v.GenericSchema<Exclude<CreatureStrikeRowsInput['eligibility'], undefined>, Exclude<CreatureStrikeRows['eligibility'], undefined>>, undefined>; }, undefined> = v.strictObject({
|
|
108
|
+
debris: v.exactOptional(StrikeDebrisSchema), id: strikeId, shape: strikeShape, windup: strikeNonnegative, active: strikeNonnegative, recover: strikeNonnegative, cooldown: strikeNonnegative,
|
|
107
109
|
range: v.nullable(strikeNonnegative), damage: strikeNonnegative, tags: v.pipe(v.array(strikeTag), v.maxLength(32)), weight: strikeWeight,
|
|
108
110
|
units: v.exactOptional(v.picklist(['world', 'actor'])), alternatives: v.exactOptional(v.pipe(v.array(strikeShape), v.maxLength(16))),
|
|
109
111
|
motion: v.exactOptional(v.strictObject({ speed: v.exactOptional(strikeNonnegative), delay: v.exactOptional(strikeNonnegative),
|
|
@@ -165,7 +167,7 @@ export interface CreatureBodyRecipeRows { actions?: CreatureMemoryActionsRows; o
|
|
|
165
167
|
export type ShardCreaturesInput = { brains: (({ id: string; kind: 'pursue'; awareRadius: number; leashRadius: number; speed: number; returnSpeed: number; stopDistance: number; turnRate: number; thinkDivisor: number; attackCooldownTicks: number; wanderRadius: number; wanderEveryTicks: number; }) | (v.InferInput<typeof SkirmisherSchema>) | (v.InferInput<typeof GuardianSchema>) | (v.InferInput<typeof PerchHunterSchema>) | (v.InferInput<typeof ScriptBrainSchema>) | (v.InferInput<typeof RamGrazerSchema>) | (v.InferInput<typeof ChallengeGrazerSchema>) | (v.InferInput<typeof OrbitDiverSchema>) | (v.InferInput<typeof PatrolDiverSchema>) | (v.InferInput<typeof BurstFlyerSchema>) | (v.InferInput<typeof GrazerSchema>) | (v.InferInput<typeof DiverSchema>) | (v.InferInput<typeof GuardianPatternsSchema>) | (v.InferInput<typeof StalkerSchema>))[]; groups?: (v.InferInput<typeof GroupBrainSchema>)[] | undefined; spawns: ({ phaseOffset?: number | undefined; respawn?: number | undefined; home?: ShardCreatureHomeInput | undefined; id: string; species: string; variant: string; brain: (string) | null; strike: (string) | null; seed: number; scale: number; at: [number, number, number]; yaw: number; })[]; };
|
|
166
168
|
export interface ShardCreatures { brains: (({ id: string; kind: 'pursue'; awareRadius: number; leashRadius: number; speed: number; returnSpeed: number; stopDistance: number; turnRate: number; thinkDivisor: number; attackCooldownTicks: number; wanderRadius: number; wanderEveryTicks: number; }) | (v.InferOutput<typeof SkirmisherSchema>) | (v.InferOutput<typeof GuardianSchema>) | (v.InferOutput<typeof PerchHunterSchema>) | (v.InferOutput<typeof ScriptBrainSchema>) | (v.InferOutput<typeof RamGrazerSchema>) | (v.InferOutput<typeof ChallengeGrazerSchema>) | (v.InferOutput<typeof OrbitDiverSchema>) | (v.InferOutput<typeof PatrolDiverSchema>) | (v.InferOutput<typeof BurstFlyerSchema>) | (v.InferOutput<typeof GrazerSchema>) | (v.InferOutput<typeof DiverSchema>) | (v.InferOutput<typeof GuardianPatternsSchema>) | (v.InferOutput<typeof StalkerSchema>))[]; groups: (v.InferOutput<typeof GroupBrainSchema>)[]; spawns: ({ phaseOffset?: number | undefined; respawn?: number | undefined; home?: ShardCreatureHome | undefined; id: string; species: string; variant: string; brain: (string) | null; strike: (string) | null; seed: number; scale: number; at: [number, number, number]; yaw: number; })[]; }
|
|
167
169
|
export type CreatureStrikeRowsInput = CreatureStrikeRows;
|
|
168
|
-
export interface CreatureStrikeRows { id: string; shape: ({ kind: 'arc'; radius: number; halfAngle: number; yawOffset?: number; }) | ({ kind: 'lane'; length: number; width: number; }) | ({ kind: 'ring'; inner: number; outer: number; }) | ({ kind: 'wedge'; length: number; halfAngle: number; }) | ({ kind: 'point'; radius: number; exclusive?: boolean; }) | ({ kind: 'sphere'; radius: number; }); windup: number; active: number; recover: number; cooldown: number; range: (number) | null; damage: number; tags: (`${string}.${string}`)[]; weight: ({ kind: 'constant'; value: number; }) | ({ kind: 'horizontal-distance'; above: number; far: number; near: number; }); units?: 'world' | 'actor'; alternatives?: (({ kind: 'arc'; radius: number; halfAngle: number; yawOffset?: number; }) | ({ kind: 'lane'; length: number; width: number; }) | ({ kind: 'ring'; inner: number; outer: number; }) | ({ kind: 'wedge'; length: number; halfAngle: number; }) | ({ kind: 'point'; radius: number; exclusive?: boolean; }) | ({ kind: 'sphere'; radius: number; }))[]; motion?: { speed?: number; delay?: number; track?: 'none' | 'lead' | 'follow'; overshoot?: number; skid?: number; }; eligibility?: { maxDy?: number; jumpDodges?: boolean; }; }
|
|
170
|
+
export interface CreatureStrikeRows { debris?: StrikeDebrisPolicy; id: string; shape: ({ kind: 'arc'; radius: number; halfAngle: number; yawOffset?: number; }) | ({ kind: 'lane'; length: number; width: number; }) | ({ kind: 'ring'; inner: number; outer: number; }) | ({ kind: 'wedge'; length: number; halfAngle: number; }) | ({ kind: 'point'; radius: number; exclusive?: boolean; }) | ({ kind: 'sphere'; radius: number; }); windup: number; active: number; recover: number; cooldown: number; range: (number) | null; damage: number; tags: (`${string}.${string}`)[]; weight: ({ kind: 'constant'; value: number; }) | ({ kind: 'horizontal-distance'; above: number; far: number; near: number; }); units?: 'world' | 'actor'; alternatives?: (({ kind: 'arc'; radius: number; halfAngle: number; yawOffset?: number; }) | ({ kind: 'lane'; length: number; width: number; }) | ({ kind: 'ring'; inner: number; outer: number; }) | ({ kind: 'wedge'; length: number; halfAngle: number; }) | ({ kind: 'point'; radius: number; exclusive?: boolean; }) | ({ kind: 'sphere'; radius: number; }))[]; motion?: { speed?: number; delay?: number; track?: 'none' | 'lead' | 'follow'; overshoot?: number; skid?: number; }; eligibility?: { maxDy?: number; jumpDodges?: boolean; }; }
|
|
169
171
|
export type CreatureStrikesInput = unknown;
|
|
170
172
|
export type CreatureStrikes = (CreatureStrikeRows)[];
|
|
171
173
|
export interface NativeGroupRowsInput { id: string; herds: string; tokens: string; bounds: [number, number, number, number]; owned: (string)[]; contacts: { pack: CreatureStrikeRowsInput; herd: CreatureStrikeRowsInput; }; steps: (({ kind: 'group'; row: v.InferInput<typeof GroupBrainSchema>; adopt: (string) | null; guest?: { program: v.InferInput<typeof ReturnProgramSchema>; binding: v.InferInput<typeof GuardedHerdGuestSchema>; }; }) | ({ kind: 'delay'; program: v.InferInput<typeof ReturnProgramSchema>; signal: string; channel: string; }))[]; }
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import {
|
|
2
|
+
array,
|
|
3
|
+
check,
|
|
4
|
+
exactOptional,
|
|
5
|
+
integer,
|
|
6
|
+
maxLength,
|
|
7
|
+
maxValue,
|
|
8
|
+
minLength,
|
|
9
|
+
minValue,
|
|
10
|
+
number,
|
|
11
|
+
pipe,
|
|
12
|
+
regex,
|
|
13
|
+
strictObject,
|
|
14
|
+
string,
|
|
15
|
+
} from 'valibot'
|
|
16
|
+
|
|
17
|
+
import type { GenericSchema } from 'valibot'
|
|
18
|
+
|
|
19
|
+
/** Ordered deterministic drops; an omitted selector matches every admitted variant. */
|
|
20
|
+
interface HarvestDrop {
|
|
21
|
+
item: string
|
|
22
|
+
count: number
|
|
23
|
+
variants?: string[]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const MAX_ID_LENGTH = 128
|
|
27
|
+
const MAX_ITEMS = 64
|
|
28
|
+
const MIN_COUNT = 1
|
|
29
|
+
const EMPTY_TOTAL = 0
|
|
30
|
+
const identifier = pipe(
|
|
31
|
+
string(),
|
|
32
|
+
regex(/^[a-z][a-zA-Z0-9.:-]*$/u),
|
|
33
|
+
maxLength(MAX_ID_LENGTH),
|
|
34
|
+
)
|
|
35
|
+
const variants = pipe(
|
|
36
|
+
array(identifier),
|
|
37
|
+
minLength(MIN_COUNT),
|
|
38
|
+
maxLength(MAX_ITEMS),
|
|
39
|
+
check<string[], 'unique harvest variants'>(
|
|
40
|
+
(rows: readonly string[]): boolean => new Set(rows).size === rows.length,
|
|
41
|
+
'unique harvest variants',
|
|
42
|
+
),
|
|
43
|
+
)
|
|
44
|
+
const drop = strictObject({
|
|
45
|
+
item: identifier,
|
|
46
|
+
count: pipe(number(), integer(), minValue(MIN_COUNT), maxValue(MAX_ITEMS)),
|
|
47
|
+
variants: exactOptional(variants),
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
/** At most 64 item units across a species' entire declaration, even before selectors reduce it. */
|
|
51
|
+
const HarvestDropsSchema: GenericSchema<HarvestDrop[], HarvestDrop[]> = pipe(
|
|
52
|
+
array(drop),
|
|
53
|
+
maxLength(MAX_ITEMS),
|
|
54
|
+
check<HarvestDrop[], 'harvest item budget'>(
|
|
55
|
+
(rows: readonly Readonly<{ count: number }>[]): boolean =>
|
|
56
|
+
rows.reduce(
|
|
57
|
+
(total: number, row: Readonly<{ count: number }>): number =>
|
|
58
|
+
total + row.count,
|
|
59
|
+
EMPTY_TOTAL,
|
|
60
|
+
) <= MAX_ITEMS,
|
|
61
|
+
'harvest item budget',
|
|
62
|
+
),
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
interface HarvestSpecies {
|
|
66
|
+
readonly id: string
|
|
67
|
+
readonly variants: readonly Readonly<{ id: string }>[]
|
|
68
|
+
readonly spawnOnly?: readonly Readonly<{ id: string }>[]
|
|
69
|
+
readonly harvest?: readonly Readonly<{
|
|
70
|
+
item: string
|
|
71
|
+
count: number
|
|
72
|
+
variants?: readonly string[]
|
|
73
|
+
}>[]
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Row admission checks variants; full shard admission additionally checks the pack catalogue. */
|
|
77
|
+
function harvestSpeciesRules(
|
|
78
|
+
species: readonly HarvestSpecies[],
|
|
79
|
+
items?: ReadonlySet<string>,
|
|
80
|
+
): string[] {
|
|
81
|
+
const errors: string[] = []
|
|
82
|
+
for (const row of species) {
|
|
83
|
+
const known = new Set(
|
|
84
|
+
[...row.variants, ...(row.spawnOnly ?? [])].map(
|
|
85
|
+
(variant: Readonly<{ id: string }>): string => variant.id,
|
|
86
|
+
),
|
|
87
|
+
)
|
|
88
|
+
for (const entry of row.harvest ?? []) {
|
|
89
|
+
if (items !== undefined && !items.has(entry.item)) {
|
|
90
|
+
errors.push(`species ${row.id}: unknown harvest item ${entry.item}`)
|
|
91
|
+
}
|
|
92
|
+
for (const variant of entry.variants ?? []) {
|
|
93
|
+
if (!known.has(variant)) {
|
|
94
|
+
errors.push(`species ${row.id}: unknown harvest variant ${variant}`)
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return errors
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export { HarvestDropsSchema, harvestSpeciesRules }
|
|
103
|
+
export type { HarvestDrop, HarvestSpecies }
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The binary files behind `look.details` (meta SHARD-SOURCE AP32a), kept binary (engine G649: never base64). Plain
|
|
3
|
+
* arithmetic over bytes, so the same checks run in the browser, the Worker, the cook and Node.
|
|
4
|
+
*
|
|
5
|
+
* - A card mesh file: little-endian, no header: `vertices` × f32 xyz positions, `vertices` × f32 xyz normals, `vertices` ×
|
|
6
|
+
* f32 uv, then `triangles` × three u16 indices. Its length is exactly `32 × vertices + 6 × triangles` bytes.
|
|
7
|
+
* - A mask file: one u8 per region cell, row by row from the low corner.
|
|
8
|
+
* - A heights file: one u16 little-endian per region cell, the same order.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** A layer's card mesh: a binary file (by hash) and its counts. */
|
|
12
|
+
interface LookDetailMesh {
|
|
13
|
+
readonly file: string
|
|
14
|
+
readonly vertices: number
|
|
15
|
+
readonly triangles: number
|
|
16
|
+
}
|
|
17
|
+
/** A layer's three files, as bytes. */
|
|
18
|
+
interface LookDetailFiles {
|
|
19
|
+
readonly mesh: Readonly<Uint8Array>
|
|
20
|
+
readonly mask: Readonly<Uint8Array>
|
|
21
|
+
readonly heights: Readonly<Uint8Array>
|
|
22
|
+
}
|
|
23
|
+
/** The parts of a layer row its files are checked against. */
|
|
24
|
+
interface DetailFileRow {
|
|
25
|
+
readonly id: string
|
|
26
|
+
readonly mesh: LookDetailMesh
|
|
27
|
+
readonly region: { readonly columns: number; readonly rows: number }
|
|
28
|
+
}
|
|
29
|
+
/** A card mesh's attribute views over its file's bytes. */
|
|
30
|
+
interface LookDetailMeshViews {
|
|
31
|
+
readonly positions: Float32Array
|
|
32
|
+
readonly normals: Float32Array
|
|
33
|
+
readonly uvs: Float32Array
|
|
34
|
+
readonly indices: Uint16Array
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** At most this many triangles in one layer's card mesh. */
|
|
38
|
+
const DETAIL_MESH_TRIANGLES_MAX = 2000
|
|
39
|
+
/** At most this many vertices in one layer's card mesh. */
|
|
40
|
+
const DETAIL_MESH_VERTICES_MAX = 6000
|
|
41
|
+
const NONE = 0
|
|
42
|
+
const ONE = 1
|
|
43
|
+
const XYZ = 3
|
|
44
|
+
const UV = 2
|
|
45
|
+
const TRIANGLE = 3
|
|
46
|
+
const F32 = 4
|
|
47
|
+
const U16 = 2
|
|
48
|
+
|
|
49
|
+
/** The exact byte length of a card mesh file with these counts. */
|
|
50
|
+
function detailMeshBytes(vertices: number, triangles: number): number {
|
|
51
|
+
return vertices * (XYZ + XYZ + UV) * F32 + triangles * TRIANGLE * U16
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** The messages whose condition holds. */
|
|
55
|
+
function faultsOf(checks: readonly (readonly [boolean, string])[]): string[] {
|
|
56
|
+
return checks
|
|
57
|
+
.filter((entry: readonly [boolean, string]): boolean => entry[NONE])
|
|
58
|
+
.map((entry: readonly [boolean, string]): string => entry[ONE])
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** A fresh aligned copy of `length` bytes from `offset`. */
|
|
62
|
+
function aligned(
|
|
63
|
+
bytes: Readonly<Uint8Array>,
|
|
64
|
+
offset: number,
|
|
65
|
+
length: number,
|
|
66
|
+
): ArrayBuffer {
|
|
67
|
+
return bytes.slice(offset, offset + length).buffer
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** The card mesh's attribute views (copied, so any byte offset works). */
|
|
71
|
+
function detailMeshViews(
|
|
72
|
+
bytes: Readonly<Uint8Array>,
|
|
73
|
+
mesh: LookDetailMesh,
|
|
74
|
+
): LookDetailMeshViews {
|
|
75
|
+
const xyz = mesh.vertices * XYZ * F32
|
|
76
|
+
const uv = mesh.vertices * UV * F32
|
|
77
|
+
return {
|
|
78
|
+
indices: new Uint16Array(
|
|
79
|
+
aligned(bytes, xyz + xyz + uv, mesh.triangles * TRIANGLE * U16),
|
|
80
|
+
),
|
|
81
|
+
normals: new Float32Array(aligned(bytes, xyz, xyz)),
|
|
82
|
+
positions: new Float32Array(aligned(bytes, NONE, xyz)),
|
|
83
|
+
uvs: new Float32Array(aligned(bytes, xyz + xyz, uv)),
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** True when any index is `vertices` or more. */
|
|
88
|
+
function indexPast(indices: Readonly<Uint16Array>, vertices: number): boolean {
|
|
89
|
+
return indices.some((index: number): boolean => index >= vertices)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** The faults in one layer's files against its mesh counts and region grid, or none. */
|
|
93
|
+
function detailFileFaults(
|
|
94
|
+
row: DetailFileRow,
|
|
95
|
+
files: LookDetailFiles,
|
|
96
|
+
): string[] {
|
|
97
|
+
const { id, mesh } = row
|
|
98
|
+
const cells = row.region.columns * row.region.rows
|
|
99
|
+
const meshBytes = detailMeshBytes(mesh.vertices, mesh.triangles)
|
|
100
|
+
const sized = files.mesh.length === meshBytes
|
|
101
|
+
const past =
|
|
102
|
+
sized && indexPast(detailMeshViews(files.mesh, mesh).indices, mesh.vertices)
|
|
103
|
+
return faultsOf([
|
|
104
|
+
[
|
|
105
|
+
!sized,
|
|
106
|
+
`detail ${id}: mesh file holds ${String(files.mesh.length)} bytes, its counts need ${String(meshBytes)}`,
|
|
107
|
+
],
|
|
108
|
+
[past, `detail ${id}: an index past the last vertex`],
|
|
109
|
+
[
|
|
110
|
+
files.mask.length !== cells,
|
|
111
|
+
`detail ${id}: mask holds ${String(files.mask.length)} bytes, the region has ${String(cells)} cells`,
|
|
112
|
+
],
|
|
113
|
+
[
|
|
114
|
+
files.heights.length !== cells * U16,
|
|
115
|
+
`detail ${id}: heights hold ${String(files.heights.length)} bytes, the region needs ${String(cells * U16)}`,
|
|
116
|
+
],
|
|
117
|
+
])
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export {
|
|
121
|
+
DETAIL_MESH_TRIANGLES_MAX,
|
|
122
|
+
DETAIL_MESH_VERTICES_MAX,
|
|
123
|
+
detailFileFaults,
|
|
124
|
+
detailMeshBytes,
|
|
125
|
+
detailMeshViews,
|
|
126
|
+
faultsOf,
|
|
127
|
+
}
|
|
128
|
+
export type {
|
|
129
|
+
DetailFileRow,
|
|
130
|
+
LookDetailFiles,
|
|
131
|
+
LookDetailMesh,
|
|
132
|
+
LookDetailMeshViews,
|
|
133
|
+
}
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detail layers (meta SHARD-SOURCE AP32a): grass, ferns and other small clutter as a card mesh plus a density mask, scattered
|
|
3
|
+
* by the engine in a ring round the camera (its grass-carpet pattern, made general) instead of baked as thousands of instance
|
|
4
|
+
* matrices. Absent: no layers (no default is filled, so older shard files keep their bytes).
|
|
5
|
+
*
|
|
6
|
+
* One `look.details` row:
|
|
7
|
+
* - `id`: unique among the layers; it also seeds the scatter, so the same square metre always grows the same clumps.
|
|
8
|
+
* - `material`: a `look.materials` id (or a family) the cards draw with.
|
|
9
|
+
* - `mesh`: the card: a binary `file` (by hash) and its `vertices` and `triangles` counts (layout in
|
|
10
|
+
* `look-details-bytes.ts`). At most `DETAIL_MESH_TRIANGLES_MAX` triangles.
|
|
11
|
+
* - `region`: the mask's grid: its low `corner` ([x, z] metres), `cell` size, `columns` (along x), `rows` (along z), and
|
|
12
|
+
* the `span` of y its heights cover.
|
|
13
|
+
* - `mask`: a binary file, one u8 per cell, row by row from the low corner: 0 grows nothing, 255 grows `clumps` clumps.
|
|
14
|
+
* - `heights`: a binary file, one u16 per cell: the ground under the cell's centre, `span[0] + h / 65535 × (span[1] -
|
|
15
|
+
* span[0])`.
|
|
16
|
+
* - `clumps`: clumps in a full cell; `scale`, `tilt` (the most a clump leans, radians) and `tint` (two sRGB multipliers a
|
|
17
|
+
* clump's colour is picked between) vary each clump.
|
|
18
|
+
* - `sway`: wind on the cards (`amount` of lean, `rate` in cycles a second); absent: still.
|
|
19
|
+
* - `radius`: metres round the camera that grow the layer on desktop; phones grow half the radius (the engine's rule).
|
|
20
|
+
* - `shadow`: the cards cast shadows.
|
|
21
|
+
*
|
|
22
|
+
* The files stay binary (engine G649). Their sizes are checked against the row where the bytes are at hand
|
|
23
|
+
* (`detailFileFaults`); the shardfile rule checks they are declared binary files with no dependencies.
|
|
24
|
+
*/
|
|
25
|
+
import {
|
|
26
|
+
array,
|
|
27
|
+
boolean,
|
|
28
|
+
check,
|
|
29
|
+
exactOptional,
|
|
30
|
+
finite,
|
|
31
|
+
integer,
|
|
32
|
+
maxLength,
|
|
33
|
+
maxValue,
|
|
34
|
+
minValue,
|
|
35
|
+
number,
|
|
36
|
+
pipe,
|
|
37
|
+
regex,
|
|
38
|
+
string,
|
|
39
|
+
strictObject,
|
|
40
|
+
tuple,
|
|
41
|
+
} from 'valibot'
|
|
42
|
+
|
|
43
|
+
import {
|
|
44
|
+
DETAIL_MESH_TRIANGLES_MAX,
|
|
45
|
+
DETAIL_MESH_VERTICES_MAX,
|
|
46
|
+
} from './look-details-bytes.ts'
|
|
47
|
+
import { materialExists } from './materials.ts'
|
|
48
|
+
|
|
49
|
+
import type { LookDetailMesh } from './look-details-bytes.ts'
|
|
50
|
+
import type { GenericSchema } from 'valibot'
|
|
51
|
+
|
|
52
|
+
type Rgb = readonly [number, number, number]
|
|
53
|
+
type Pair = readonly [number, number]
|
|
54
|
+
|
|
55
|
+
/** A layer's mask grid. */
|
|
56
|
+
interface LookDetailRegion {
|
|
57
|
+
readonly corner: Pair
|
|
58
|
+
readonly cell: number
|
|
59
|
+
readonly columns: number
|
|
60
|
+
readonly rows: number
|
|
61
|
+
readonly span: Pair
|
|
62
|
+
}
|
|
63
|
+
/** Wind on a layer's cards. */
|
|
64
|
+
interface LookDetailSway {
|
|
65
|
+
readonly amount: number
|
|
66
|
+
readonly rate: number
|
|
67
|
+
}
|
|
68
|
+
/** One detail layer. */
|
|
69
|
+
interface LookDetail {
|
|
70
|
+
readonly id: string
|
|
71
|
+
readonly material: string
|
|
72
|
+
readonly mesh: LookDetailMesh
|
|
73
|
+
readonly region: LookDetailRegion
|
|
74
|
+
readonly mask: string
|
|
75
|
+
readonly heights: string
|
|
76
|
+
readonly clumps: number
|
|
77
|
+
readonly scale: Pair
|
|
78
|
+
readonly tilt: number
|
|
79
|
+
readonly tint: readonly [Rgb, Rgb]
|
|
80
|
+
readonly sway?: LookDetailSway
|
|
81
|
+
readonly radius: number
|
|
82
|
+
readonly shadow: boolean
|
|
83
|
+
}
|
|
84
|
+
/** A shardfile file entry, as the rule reads it. */
|
|
85
|
+
interface DetailFileEntry {
|
|
86
|
+
readonly hash: string
|
|
87
|
+
readonly kind: string
|
|
88
|
+
readonly dependencies: readonly string[]
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** At most this many detail layers in one look. */
|
|
92
|
+
const DETAIL_LAYERS_MAX = 8
|
|
93
|
+
/** At most this many mask columns or rows (512 × 512 cells). */
|
|
94
|
+
const DETAIL_SIDE_MAX = 512
|
|
95
|
+
/** At most this many clumps in a full cell. */
|
|
96
|
+
const DETAIL_CLUMPS_MAX = 64
|
|
97
|
+
const NONE = 0
|
|
98
|
+
const FULL = 1
|
|
99
|
+
const TRIANGLE = 3
|
|
100
|
+
const CELL_MIN = 0.5
|
|
101
|
+
const CELL_MAX = 8
|
|
102
|
+
const SCALE_MIN = 0.05
|
|
103
|
+
const SCALE_MAX = 20
|
|
104
|
+
const RATE_MIN = 0.05
|
|
105
|
+
const RATE_MAX = 10
|
|
106
|
+
const RADIUS_MIN = 4
|
|
107
|
+
const RADIUS_MAX = 200
|
|
108
|
+
|
|
109
|
+
/** The layers whose material names no `look.materials` entry or family. */
|
|
110
|
+
function detailMaterialFaults(
|
|
111
|
+
rows: readonly LookDetail[],
|
|
112
|
+
materials: Readonly<Record<string, unknown>>,
|
|
113
|
+
): string[] {
|
|
114
|
+
const missing = rows.filter(
|
|
115
|
+
(row: LookDetail): boolean => !materialExists(materials, row.material),
|
|
116
|
+
)
|
|
117
|
+
return missing.map(
|
|
118
|
+
(row: LookDetail): string =>
|
|
119
|
+
`detail ${row.id}: material ${row.material} is not declared`,
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** True when `hash` is a declared binary file with no dependencies. */
|
|
124
|
+
function plainBinary(
|
|
125
|
+
files: ReadonlyMap<string, DetailFileEntry>,
|
|
126
|
+
hash: string,
|
|
127
|
+
): boolean {
|
|
128
|
+
const file = files.get(hash)
|
|
129
|
+
return file?.kind === 'binary' && file.dependencies.length === NONE
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** The shardfile rules: every layer's material is declared and its three files are plain binaries. */
|
|
133
|
+
function detailLayerRules(
|
|
134
|
+
rows: readonly LookDetail[] | undefined,
|
|
135
|
+
materials: Readonly<Record<string, unknown>>,
|
|
136
|
+
files: readonly DetailFileEntry[],
|
|
137
|
+
): string[] {
|
|
138
|
+
const layers = rows ?? []
|
|
139
|
+
const byHash = new Map(
|
|
140
|
+
files.map((file: DetailFileEntry): [string, DetailFileEntry] => [
|
|
141
|
+
file.hash,
|
|
142
|
+
file,
|
|
143
|
+
]),
|
|
144
|
+
)
|
|
145
|
+
const refs = layers.flatMap((row: LookDetail): string[] => [
|
|
146
|
+
row.mesh.file,
|
|
147
|
+
row.mask,
|
|
148
|
+
row.heights,
|
|
149
|
+
])
|
|
150
|
+
const errors: string[] = []
|
|
151
|
+
if (detailMaterialFaults(layers, materials).length > NONE) {
|
|
152
|
+
errors.push('declared detail layer material')
|
|
153
|
+
}
|
|
154
|
+
if (!refs.every((hash: string): boolean => plainBinary(byHash, hash))) {
|
|
155
|
+
errors.push('detail layer files are declared binaries with no dependencies')
|
|
156
|
+
}
|
|
157
|
+
return errors
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** True when a layer's ranges run low to high and its mesh can index every triangle. */
|
|
161
|
+
function ordered(row: LookDetail): boolean {
|
|
162
|
+
const spans =
|
|
163
|
+
row.region.span[NONE] <= row.region.span[FULL] &&
|
|
164
|
+
row.scale[NONE] <= row.scale[FULL]
|
|
165
|
+
return spans && row.mesh.vertices >= TRIANGLE
|
|
166
|
+
}
|
|
167
|
+
/** True when no two layers share an id. */
|
|
168
|
+
function uniqueIds(rows: readonly LookDetail[]): boolean {
|
|
169
|
+
return (
|
|
170
|
+
new Set(rows.map((row: LookDetail): string => row.id)).size === rows.length
|
|
171
|
+
)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function range(low: number, high: number): GenericSchema<number, number> {
|
|
175
|
+
return pipe(number(), finite(), minValue(low), maxValue(high))
|
|
176
|
+
}
|
|
177
|
+
function count(low: number, high: number): GenericSchema<number, number> {
|
|
178
|
+
return pipe(number(), integer(), minValue(low), maxValue(high))
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const real = pipe(number(), finite())
|
|
182
|
+
const unit = range(NONE, FULL)
|
|
183
|
+
const rgb = tuple([unit, unit, unit])
|
|
184
|
+
const identity = pipe(string(), regex(/^[a-z0-9][a-z0-9._-]{0,63}$/u))
|
|
185
|
+
const hash = pipe(string(), regex(/^[a-f0-9]{64}$/u))
|
|
186
|
+
const side = count(FULL, DETAIL_SIDE_MAX)
|
|
187
|
+
const size = range(SCALE_MIN, SCALE_MAX)
|
|
188
|
+
const pair = tuple([real, real])
|
|
189
|
+
const MeshSchema = strictObject({
|
|
190
|
+
file: hash,
|
|
191
|
+
triangles: count(FULL, DETAIL_MESH_TRIANGLES_MAX),
|
|
192
|
+
vertices: count(FULL, DETAIL_MESH_VERTICES_MAX),
|
|
193
|
+
})
|
|
194
|
+
const RegionSchema = strictObject({
|
|
195
|
+
cell: range(CELL_MIN, CELL_MAX),
|
|
196
|
+
columns: side,
|
|
197
|
+
corner: pair,
|
|
198
|
+
rows: side,
|
|
199
|
+
span: pair,
|
|
200
|
+
})
|
|
201
|
+
const SwaySchema = strictObject({
|
|
202
|
+
amount: unit,
|
|
203
|
+
rate: range(RATE_MIN, RATE_MAX),
|
|
204
|
+
})
|
|
205
|
+
const DetailRowSchema: GenericSchema<LookDetail, LookDetail> = strictObject({
|
|
206
|
+
clumps: count(FULL, DETAIL_CLUMPS_MAX),
|
|
207
|
+
heights: hash,
|
|
208
|
+
id: identity,
|
|
209
|
+
mask: hash,
|
|
210
|
+
material: identity,
|
|
211
|
+
mesh: MeshSchema,
|
|
212
|
+
radius: range(RADIUS_MIN, RADIUS_MAX),
|
|
213
|
+
region: RegionSchema,
|
|
214
|
+
scale: tuple([size, size]),
|
|
215
|
+
shadow: boolean(),
|
|
216
|
+
sway: exactOptional(SwaySchema),
|
|
217
|
+
tilt: unit,
|
|
218
|
+
tint: tuple([rgb, rgb]),
|
|
219
|
+
})
|
|
220
|
+
const LookDetailSchema: GenericSchema<LookDetail, LookDetail> = pipe(
|
|
221
|
+
DetailRowSchema,
|
|
222
|
+
check<LookDetail, string>(
|
|
223
|
+
ordered,
|
|
224
|
+
'detail layer ranges run low to high and its mesh has a triangle',
|
|
225
|
+
),
|
|
226
|
+
)
|
|
227
|
+
/** `look.details`: at most `DETAIL_LAYERS_MAX` layers with unique ids. */
|
|
228
|
+
const LookDetailsSchema: GenericSchema<LookDetail[], LookDetail[]> = pipe(
|
|
229
|
+
array(LookDetailSchema),
|
|
230
|
+
maxLength(DETAIL_LAYERS_MAX),
|
|
231
|
+
check<LookDetail[], string>(uniqueIds, 'detail layer ids are unique'),
|
|
232
|
+
)
|
|
233
|
+
|
|
234
|
+
export {
|
|
235
|
+
DETAIL_CLUMPS_MAX,
|
|
236
|
+
DETAIL_LAYERS_MAX,
|
|
237
|
+
DETAIL_SIDE_MAX,
|
|
238
|
+
LookDetailsSchema,
|
|
239
|
+
detailLayerRules,
|
|
240
|
+
detailMaterialFaults,
|
|
241
|
+
}
|
|
242
|
+
export {
|
|
243
|
+
DETAIL_MESH_TRIANGLES_MAX,
|
|
244
|
+
DETAIL_MESH_VERTICES_MAX,
|
|
245
|
+
detailFileFaults,
|
|
246
|
+
detailMeshBytes,
|
|
247
|
+
detailMeshViews,
|
|
248
|
+
} from './look-details-bytes.ts'
|
|
249
|
+
export type {
|
|
250
|
+
DetailFileRow,
|
|
251
|
+
LookDetailFiles,
|
|
252
|
+
LookDetailMesh,
|
|
253
|
+
LookDetailMeshViews,
|
|
254
|
+
} from './look-details-bytes.ts'
|
|
255
|
+
export type { DetailFileEntry, LookDetail, LookDetailRegion, LookDetailSway }
|
package/src/format/rows.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { StrikeDebrisSchema, strikeDebrisCatalogueRules } from './strike-debris.ts';
|
|
2
|
+
import type { StrikeDebrisPolicy } from './strike-debris.ts';
|
|
3
|
+
import type { HarvestDrop } from './harvest-rows.ts';
|
|
4
|
+
import { HarvestDropsSchema, harvestSpeciesRules } from './harvest-rows.ts';
|
|
1
5
|
import { LootEconomySchema, BarterEconomySchema, lootEconomyRules } from './lootEconomy.ts';
|
|
2
6
|
import * as v from 'valibot';
|
|
3
7
|
import { isJsonData } from './json.ts';
|
|
@@ -22,7 +26,7 @@ const shape = v.variant('kind', [
|
|
|
22
26
|
v.strictObject({ kind: v.literal('wedge'), length: dimension, halfAngle: v.pipe(positive, v.maxValue(Math.PI)) }),
|
|
23
27
|
v.pipe(v.strictObject({ kind: v.literal('ring'), inner: nonnegative, outer: dimension }), v.check((r) => r.inner <= r.outer, 'ordered ring')),
|
|
24
28
|
]);
|
|
25
|
-
const strike: v.StrictObjectSchema<{ readonly id: v.GenericSchema<StrikeRowsInput['id'], StrikeRows['id']>; readonly shape: v.GenericSchema<StrikeRowsInput['shape'], StrikeRows['shape']>; readonly windup: v.GenericSchema<StrikeRowsInput['windup'], StrikeRows['windup']>; readonly active: v.GenericSchema<StrikeRowsInput['active'], StrikeRows['active']>; readonly recover: v.GenericSchema<StrikeRowsInput['recover'], StrikeRows['recover']>; readonly cooldown: v.GenericSchema<StrikeRowsInput['cooldown'], StrikeRows['cooldown']>; readonly range: v.GenericSchema<StrikeRowsInput['range'], StrikeRows['range']>; readonly damage: v.GenericSchema<StrikeRowsInput['damage'], StrikeRows['damage']>; readonly tags: v.SchemaWithPipe<readonly [v.ArraySchema<v.GenericSchema<`${string}.${string}`>, undefined>, v.MaxLengthAction<StrikeRows['tags'], 32, undefined>]>; readonly weight: v.GenericSchema<StrikeRowsInput['weight'], StrikeRows['weight']>; readonly speed: v.GenericSchema<StrikeRowsInput['speed'], StrikeRows['speed']>; }, undefined> = v.strictObject({ id, shape, windup: nonnegative, active: nonnegative, recover: nonnegative, cooldown: nonnegative, range: dimension, damage: nonnegative,
|
|
29
|
+
const strike: v.StrictObjectSchema<{ readonly debris: v.ExactOptionalSchema<v.GenericSchema<StrikeDebrisPolicy>, undefined>; readonly id: v.GenericSchema<StrikeRowsInput['id'], StrikeRows['id']>; readonly shape: v.GenericSchema<StrikeRowsInput['shape'], StrikeRows['shape']>; readonly windup: v.GenericSchema<StrikeRowsInput['windup'], StrikeRows['windup']>; readonly active: v.GenericSchema<StrikeRowsInput['active'], StrikeRows['active']>; readonly recover: v.GenericSchema<StrikeRowsInput['recover'], StrikeRows['recover']>; readonly cooldown: v.GenericSchema<StrikeRowsInput['cooldown'], StrikeRows['cooldown']>; readonly range: v.GenericSchema<StrikeRowsInput['range'], StrikeRows['range']>; readonly damage: v.GenericSchema<StrikeRowsInput['damage'], StrikeRows['damage']>; readonly tags: v.SchemaWithPipe<readonly [v.ArraySchema<v.GenericSchema<`${string}.${string}`>, undefined>, v.MaxLengthAction<StrikeRows['tags'], 32, undefined>]>; readonly weight: v.GenericSchema<StrikeRowsInput['weight'], StrikeRows['weight']>; readonly speed: v.GenericSchema<StrikeRowsInput['speed'], StrikeRows['speed']>; }, undefined> = v.strictObject({ debris: v.exactOptional(StrikeDebrisSchema), id, shape, windup: nonnegative, active: nonnegative, recover: nonnegative, cooldown: nonnegative, range: dimension, damage: nonnegative,
|
|
26
30
|
tags: v.pipe(v.array(v.custom<`${string}.${string}`>((value) => typeof value === 'string' && value.length <= 128 && /^[a-z][a-zA-Z0-9.-]*\.[a-zA-Z0-9.-]+$/u.test(value))), v.maxLength(32)), weight: nonnegative, speed: v.pipe(nonnegative, v.maxValue(15)) });
|
|
27
31
|
const numbers = v.strictObject({ overcast: unit, rain: unit, wet: unit, wind: unit, fog: unit });
|
|
28
32
|
const weather = v.strictObject({ id, states: v.pipe(v.array(v.strictObject({ id, next: id, length: ordered, numbers })), v.minLength(1), v.maxLength(64)), initial: numbers, soak: unit, dry: unit,
|
|
@@ -41,7 +45,7 @@ const flight = v.strictObject({ altitude: v.pipe(finite, v.minValue(-250), v.max
|
|
|
41
45
|
lockRange: v.exactOptional(v.pipe(positive, v.maxValue(600))), bank: v.exactOptional(v.pipe(finite, v.check(n => n > 0 && n < Math.PI / 2, 'flight bank between 0 and pi/2'))) });
|
|
42
46
|
const MAX_ABILITIES = 32;
|
|
43
47
|
const abilities = v.pipe(v.array(CreatureAbilitySchema), v.maxLength(MAX_ABILITIES));
|
|
44
|
-
const species = v.strictObject({ id, kind: id, label: text, aggressive: v.boolean(), lockable: v.boolean(), dims, flight: v.exactOptional(flight),
|
|
48
|
+
const species = v.strictObject({ id, kind: id, label: text, capExempt: v.exactOptional(v.boolean()), harvest: v.exactOptional(HarvestDropsSchema), aggressive: v.boolean(), lockable: v.boolean(), dims, flight: v.exactOptional(flight),
|
|
45
49
|
variants: v.pipe(v.array(variant), v.minLength(1), v.maxLength(64)),
|
|
46
50
|
type: v.exactOptional(CreatureTypeSchema), body: v.exactOptional(CreatureBodySchema),
|
|
47
51
|
temperament: v.exactOptional(CreatureTemperamentSchema), senses: v.exactOptional(CreatureSensesSchema),
|
|
@@ -62,7 +66,7 @@ const raw: v.StrictObjectSchema<{ readonly strikes: v.SchemaWithPipe<readonly [v
|
|
|
62
66
|
|
|
63
67
|
/** Reference, uniqueness and complete clock/weather transition rules for data rows. */
|
|
64
68
|
function rowRules(rows: ShardRows): string[] {
|
|
65
|
-
const errors: string[] =
|
|
69
|
+
const errors: string[] = harvestSpeciesRules(rows.species);
|
|
66
70
|
for (const list of Object.values(rows)) if (new Set(list.map((r) => r.id)).size !== list.length) errors.push('unique row ids');
|
|
67
71
|
for (const row of rows.loot) if (row.economy !== undefined && !('kind' in row.economy)) errors.push(...lootEconomyRules(row.economy));
|
|
68
72
|
for (const w of rows.weather) {
|
|
@@ -71,6 +75,7 @@ function rowRules(rows: ShardRows): string[] {
|
|
|
71
75
|
}
|
|
72
76
|
for (const d of rows.days) if (d.schedule[0]?.from !== 0 || d.schedule.at(-1)?.to !== 24 || d.schedule.some((s, i) => s.from >= s.to || (i > 0 && d.schedule[i - 1]?.to !== s.from))) errors.push('complete ordered day schedule');
|
|
73
77
|
const speciesIds = new Set(rows.species.map((s) => s.id));
|
|
78
|
+
errors.push(...strikeDebrisCatalogueRules(rows));
|
|
74
79
|
for (const s of rows.species) if (new Set(s.variants.map((r) => r.id)).size !== s.variants.length || s.variants.some((r) => r.scale[1] > 10)) errors.push('species variants');
|
|
75
80
|
const strikeIds = new Set<string>();
|
|
76
81
|
for (const strikeRow of rows.strikes) { strikeIds.add(strikeRow.id); }
|
|
@@ -102,13 +107,13 @@ function parseRows(input: unknown): ShardRows { return v.parse(RowsSchema, input
|
|
|
102
107
|
|
|
103
108
|
/** Admitted author data independent of validator implementation metadata. */
|
|
104
109
|
type StrikeRowsInput = StrikeRows;
|
|
105
|
-
interface StrikeRows { id: string; shape: ({ kind: 'point'; radius: number; }) | ({ kind: 'sphere'; radius: number; }) | ({ kind: 'lane'; length: number; width: number; }) | ({ kind: 'arc'; radius: number; halfAngle: number; }) | ({ kind: 'wedge'; length: number; halfAngle: number; }) | ({ kind: 'ring'; inner: number; outer: number; }); windup: number; active: number; recover: number; cooldown: number; range: number; damage: number; tags: (`${string}.${string}`)[]; weight: number; speed: number; }
|
|
110
|
+
interface StrikeRows { debris?: StrikeDebrisPolicy; id: string; shape: ({ kind: 'point'; radius: number; }) | ({ kind: 'sphere'; radius: number; }) | ({ kind: 'lane'; length: number; width: number; }) | ({ kind: 'arc'; radius: number; halfAngle: number; }) | ({ kind: 'wedge'; length: number; halfAngle: number; }) | ({ kind: 'ring'; inner: number; outer: number; }); windup: number; active: number; recover: number; cooldown: number; range: number; damage: number; tags: (`${string}.${string}`)[]; weight: number; speed: number; }
|
|
106
111
|
interface ShardRowsInput { strikes: (StrikeRowsInput)[]; weather: ({ id: string; states: ({ id: string; next: string; length: [number, number]; numbers: { overcast: number; rain: number; wet: number; wind: number; fog: number; }; })[]; initial: { overcast: number; rain: number; wet: number; wind: number; fog: number; }; soak: number; dry: number; modes: ({ id: string; hold: (string) | null; at: number; dry: boolean; })[]; })[]; days: ({ id: string; units: 'hour'; start: number; schedule: ({ phase: 'dawn' | 'day' | 'golden' | 'dusk' | 'night'; from: number; to: number; minutes: number; })[]; sun: { maxElevation: number; azimuthOffset: number; }; fixed: { midday: number; golden: number; sunset: number; night: number; }; presets: { dawn: number; noon: number; dusk: number; night: number; }; })[]; species: SpeciesRow[]; looks: ({ id: string; species: string; recipe: string; material?: (string) | null | undefined; parameters: Record<string, (number) | (boolean) | (string) | ((number)[])>; animation: { recipe: string; parameters: Record<string, (number) | (boolean) | (string) | ((number)[])>; }; })[]; compendiums: (({ id: string; className: string; title: string; tabs: ({ id: string; label: string; })[]; stamp: string; stats: ({ label: string; value: string; })[]; entries: ({ id: string; kind: 'species'; tab: string; name: string; notes: string; sketch: string; species: string; })[]; }) | (v.InferInput<typeof JournalRowSchema>))[]; loot: (({ id: string; gear: 'purse.coins'; finds: null; marks: null; charted: boolean; chime: string; economy?: v.InferInput<typeof LootEconomySchema>; }) | ({ id: string; economy: v.InferInput<typeof BarterEconomySchema>; }))[]; }
|
|
107
112
|
// oxlint-disable-next-line typescript/consistent-type-definitions -- Object.values needs the original implicit dictionary contract for row validation.
|
|
108
113
|
type ShardRows = { strikes: (StrikeRows)[]; weather: ({ id: string; states: ({ id: string; next: string; length: [number, number]; numbers: { overcast: number; rain: number; wet: number; wind: number; fog: number; }; })[]; initial: { overcast: number; rain: number; wet: number; wind: number; fog: number; }; soak: number; dry: number; modes: ({ id: string; hold: (string) | null; at: number; dry: boolean; })[]; })[]; days: ({ id: string; units: 'hour'; start: number; schedule: ({ phase: 'dawn' | 'day' | 'golden' | 'dusk' | 'night'; from: number; to: number; minutes: number; })[]; sun: { maxElevation: number; azimuthOffset: number; }; fixed: { midday: number; golden: number; sunset: number; night: number; }; presets: { dawn: number; noon: number; dusk: number; night: number; }; })[]; species: SpeciesRow[]; looks: ({ id: string; species: string; recipe: string; material: (string) | null; parameters: Record<string, (number) | (boolean) | (string) | ((number)[])>; animation: { recipe: string; parameters: Record<string, (number) | (boolean) | (string) | ((number)[])>; }; })[]; compendiums: (({ id: string; className: string; title: string; tabs: ({ id: string; label: string; })[]; stamp: string; stats: ({ label: string; value: string; })[]; entries: ({ id: string; kind: 'species'; tab: string; name: string; notes: string; sketch: string; species: string; })[]; }) | (v.InferOutput<typeof JournalRowSchema>))[]; loot: (({ id: string; gear: 'purse.coins'; finds: null; marks: null; charted: boolean; chime: string; economy?: v.InferOutput<typeof LootEconomySchema>; }) | ({ id: string; economy: v.InferOutput<typeof BarterEconomySchema>; }))[]; };
|
|
109
114
|
|
|
110
115
|
/** A species keeps its old fields, with optional explicit creature layers. */
|
|
111
|
-
interface SpeciesRow extends CreatureLayers { id: string; kind: string; label: string; aggressive: boolean; lockable: boolean; dims: { bodyY: number; bodyHalfLen: number; bodyRadius: number; headRadius: number; legLen: number; feet: ([number, number])[]; halfWidth: number; }; flight?: { altitude: number; above?: 'ground' | 'world'; climbRate: number; diveRate: number; lockRange?: number; bank?: number; }; variants: ({ id: string; label: string; rarity: 'common' | 'uncommon' | 'rare' | 'legendary'; weight: number; scale: [number, number]; hp: number; mods: { speed: number; chargeDist: number; damageTaken: number; chargeDamage: number; relentless: boolean; }; })[]; }
|
|
116
|
+
interface SpeciesRow extends CreatureLayers { capExempt?: boolean; harvest?: HarvestDrop[]; id: string; kind: string; label: string; aggressive: boolean; lockable: boolean; dims: { bodyY: number; bodyHalfLen: number; bodyRadius: number; headRadius: number; legLen: number; feet: ([number, number])[]; halfWidth: number; }; flight?: { altitude: number; above?: 'ground' | 'world'; climbRate: number; diveRate: number; lockRange?: number; bank?: number; }; variants: ({ id: string; label: string; rarity: 'common' | 'uncommon' | 'rare' | 'legendary'; weight: number; scale: [number, number]; hp: number; mods: { speed: number; chargeDist: number; damageTaken: number; chargeDamage: number; relentless: boolean; }; })[]; }
|
|
112
117
|
|
|
113
118
|
export { rowRules, RowsSchema, parseRows };
|
|
114
119
|
export type { StrikeRowsInput, StrikeRows, ShardRowsInput, ShardRows, SpeciesRow };
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { StrikeDebrisPolicy } from './strike-debris.ts';
|
|
2
|
+
import { strikeDebrisCatalogueRules } from './strike-debris.ts';
|
|
3
|
+
import { harvestSpeciesRules } from './harvest-rows.ts';
|
|
1
4
|
import { AdmissionLateSchema, lateLibraryRootsValid } from './admissionLate.ts';
|
|
2
5
|
import { ManifestMetadataSchema } from './minimap.ts';
|
|
3
6
|
import { hasDeclaredClientPage } from './runtimeBinds.ts';
|
|
@@ -58,6 +61,8 @@ import type { LookSky, LookSkyInput } from './look-sky.ts';
|
|
|
58
61
|
import { LookBloomSchema, LookLightSchema, LookToneSchema } from './look-light.ts';
|
|
59
62
|
import { LookVignetteSchema } from './look-render.ts';
|
|
60
63
|
import type { LookBloom, LookBloomInput, LookLight, LookLightInput, LookTone } from './look-light.ts';
|
|
64
|
+
import { LookDetailsSchema, detailLayerRules } from './look-details.ts';
|
|
65
|
+
import type { LookDetail } from './look-details.ts';
|
|
61
66
|
import type { LookVignette } from './look-render.ts';
|
|
62
67
|
|
|
63
68
|
const channel = v.pipe(finite, v.minValue(0), v.maxValue(1));
|
|
@@ -78,7 +83,7 @@ const rawSchema: v.GenericSchema<ShardfileRowsInput, ShardfileRows> & { readonly
|
|
|
78
83
|
map: v.exactOptional(MapSchema),
|
|
79
84
|
requires: RequiresSchema,
|
|
80
85
|
budgets: BudgetsSchema,
|
|
81
|
-
look: v.strictObject({ families: names, materials: v.optional(MaterialsSchema, {}), familyLooks: v.optional(FamilyLooksSchema, {}), curves: v.exactOptional(MaterialCurvesSchema), samplers: v.exactOptional(TextureSamplersSchema), post: v.exactOptional(PostStackSchema), sky: v.exactOptional(LookSkySchema), light: v.exactOptional(LookLightSchema), grade: lookGrade, clock: v.literal('engine'), day: v.optional(day), dayOverride: v.nullable(channel), keys: v.pipe(v.array(key), v.maxLength(64)) }),
|
|
86
|
+
look: v.strictObject({ families: names, materials: v.optional(MaterialsSchema, {}), familyLooks: v.optional(FamilyLooksSchema, {}), curves: v.exactOptional(MaterialCurvesSchema), samplers: v.exactOptional(TextureSamplersSchema), post: v.exactOptional(PostStackSchema), sky: v.exactOptional(LookSkySchema), light: v.exactOptional(LookLightSchema), details: v.exactOptional(LookDetailsSchema), grade: lookGrade, clock: v.literal('engine'), day: v.optional(day), dayOverride: v.nullable(channel), keys: v.pipe(v.array(key), v.maxLength(64)) }),
|
|
82
87
|
sim: SimSchema,
|
|
83
88
|
state: StateSchema,
|
|
84
89
|
migrations: v.optional(MigrationsSchema, []),
|
|
@@ -189,6 +194,7 @@ export interface Shardfile {
|
|
|
189
194
|
post?: v.InferOutput<typeof PostStackSchema>;
|
|
190
195
|
sky?: LookSky;
|
|
191
196
|
light?: LookLight;
|
|
197
|
+
details?: LookDetail[];
|
|
192
198
|
grade: { exposure: number; saturation: number; contrast: number; lut: string | null; bloom?: LookBloom; tone?: LookTone; vignette?: LookVignette };
|
|
193
199
|
clock: 'engine';
|
|
194
200
|
day?: v.InferOutput<typeof day> | undefined;
|
|
@@ -293,6 +299,17 @@ export function shardfileRules(s: Shardfile): string[] {
|
|
|
293
299
|
errors.push(...nativeGroundRules(s), ...navigationRules(s));
|
|
294
300
|
errors.push(...targetRules(s.targets, s, { panels: s.props?.panels ?? [], colliders: [...s.props?.colliders ?? [], ...s.meshCollision?.panels ?? []], models: s.props?.models ?? [] }));
|
|
295
301
|
errors.push(...itemRules(s.items, s.sim.scripts));
|
|
302
|
+
const debrisStrikes: Readonly<{debris?: StrikeDebrisPolicy}>[] = [];
|
|
303
|
+
for (const row of s.items.rows) {
|
|
304
|
+
if (row.kind === 'weapon' && row.profile?.family === 'melee') {
|
|
305
|
+
const { moves } = row.profile;
|
|
306
|
+
debrisStrikes.push(...moves.combo, moves.heavy);
|
|
307
|
+
if (moves.passes !== undefined) { debrisStrikes.push(moves.passes.left, moves.passes.right); }
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
errors.push(...strikeDebrisCatalogueRules({ strikes: debrisStrikes, species: s.rows.species }));
|
|
311
|
+
const harvestItems = new Set((s.items.catalogue ?? []).map((row: Readonly<{ id: string }>): string => row.id));
|
|
312
|
+
errors.push(...harvestSpeciesRules(s.rows.species, harvestItems));
|
|
296
313
|
if (s.migrations.some(step => step.equipmentSlots?.some(rename => !s.items.rows.some(row => row.kind === 'weapon' && row.slot === rename.to)))) errors.push('migration equipment slots resolve declared weapons');
|
|
297
314
|
if ((s.items.runtimeContexts?.length ?? 0) > 0 && !pageOwner && s.runtime?.binds?.includes('items') !== true) errors.push('native input contexts require their declared page or runtime owner');
|
|
298
315
|
if (s.items.rows.some((row) => row.kind === 'tool' && row.action === null) && s.runtime?.binds?.includes('items') !== true) errors.push('native tools require runtime.binds items');
|
|
@@ -304,6 +321,7 @@ export function shardfileRules(s: Shardfile): string[] {
|
|
|
304
321
|
try { validatePropsReferences(s.props, s); } catch { errors.push('declared prop references'); }
|
|
305
322
|
if (!materialExists(s.look.materials, s.props.family)) errors.push('declared prop material');
|
|
306
323
|
}
|
|
324
|
+
errors.push(...detailLayerRules(s.look.details, s.look.materials, s.files));
|
|
307
325
|
if (Math.abs(s.spawn.x) > CHUNK_HALF || Math.abs(s.spawn.z) > CHUNK_HALF || s.spawn.y < -CELL_BELOW || s.spawn.y > CELL_ABOVE) errors.push('player spawn in cell');
|
|
308
326
|
const conditions = new Set(s.hooks.conditions.map((row) => row.id)), scenes = new Set(s.hooks.scenes.map((row) => row.id));
|
|
309
327
|
const inputConditions = [...(s.plumbing?.input.flatMap(row => [row.when, row.hiddenWhen]) ?? []), ...s.items.contexts.map(row => row.extra?.hiddenWhen)];
|
|
@@ -397,6 +415,7 @@ interface ShardfileRowsInputFields {
|
|
|
397
415
|
post?: v.InferInput<typeof PostStackSchema>;
|
|
398
416
|
sky?: LookSkyInput;
|
|
399
417
|
light?: LookLightInput;
|
|
418
|
+
details?: LookDetail[];
|
|
400
419
|
grade: {
|
|
401
420
|
exposure: v.InferInput<typeof finite>;
|
|
402
421
|
saturation: v.InferInput<typeof finite>;
|
|
@@ -474,6 +493,7 @@ interface ShardfileRowsFields {
|
|
|
474
493
|
post?: v.InferOutput<typeof PostStackSchema>;
|
|
475
494
|
sky?: LookSky;
|
|
476
495
|
light?: LookLight;
|
|
496
|
+
details?: LookDetail[];
|
|
477
497
|
grade: {
|
|
478
498
|
exposure: v.InferOutput<typeof finite>;
|
|
479
499
|
saturation: v.InferOutput<typeof finite>;
|
|
@@ -21,6 +21,7 @@ export const CreatureGuestSchema: v.GenericSchema<CreatureGuestRowsInput, Creatu
|
|
|
21
21
|
}));
|
|
22
22
|
|
|
23
23
|
|
|
24
|
+
const bookMetadata=v.omit(SpeciesSchema,['harvest','capExempt']);
|
|
24
25
|
const text=v.pipe(v.string(),v.minLength(1),v.maxLength(4096)),number=v.pipe(v.number(),v.finite()),rgb=v.tuple([number,number,number]);
|
|
25
26
|
/** A species borrows its existing arena-room brain; initialization is finite
|
|
26
27
|
* ordered data, before the same original think/act/damage slots. */
|
|
@@ -34,7 +35,7 @@ export const ArenaRoomSpeciesControlSchema: v.GenericSchema<ArenaRoomSpeciesCont
|
|
|
34
35
|
/** Build-only species catalogue admission. Native consumers import row types. */
|
|
35
36
|
/** Packed body keys, rig contracts and painterly material measurements. */
|
|
36
37
|
const book=v.object({slug:text,body:v.unknown(),poses:v.optional(v.record(text,v.unknown())),program:v.optional(v.unknown()),
|
|
37
|
-
rows:v.pipe(v.array(v.object({metadata:
|
|
38
|
+
rows:v.pipe(v.array(v.object({metadata:bookMetadata,id:text,family:text,
|
|
38
39
|
rigContract:v.object({skeleton:text,clips:v.array(SkinClipNameSchema),sockets:v.array(text)}),
|
|
39
40
|
rig:v.optional(v.picklist(['quadruped','custom'])),pose:v.optional(v.object({grazeNeck:number,gallopTail:number})),gait:v.optional(v.object({trot:number,gallop:number})),
|
|
40
41
|
eyeGlow:v.optional(rgb),eyeGlowIntensity:v.optional(number),
|
|
@@ -75,10 +76,10 @@ export interface CreatureGuestRows { program: unknown; clock: string; playerKeys
|
|
|
75
76
|
export type ArenaRoomSpeciesControlRowsInput = ArenaRoomSpeciesControlRows;
|
|
76
77
|
export interface ArenaRoomSpeciesControlRows { kind: 'arena-room'; initialize: { flag: string; defaults: (({ field: string; source: 'value'; value: number; }) | ({ field: string; source: 'height'; }))[]; }; }
|
|
77
78
|
export type SpeciesLookBookRowsInput = unknown;
|
|
78
|
-
export interface SpeciesLookBookRows { slug: string; body: unknown; poses?: Record<string, unknown> | undefined; program?: unknown; rows: ({ metadata: v.InferOutput<typeof SpeciesSchema>; id: string; family: string; rigContract: { skeleton: string; clips: (v.InferOutput<typeof SkinClipNameSchema>)[]; sockets: (string)[]; }; rig?: 'quadruped' | 'custom' | undefined; pose?: { grazeNeck: number; gallopTail: number; } | undefined; gait?: { trot: number; gallop: number; } | undefined; eyeGlow?: [number, number, number] | undefined; eyeGlowIntensity?: number | undefined; variants: Record<string, { body: string; tint?: Record<string, [number, number, number]> | undefined; traits?: Record<string, (number) | (boolean)> | undefined; }>; projection?: v.InferOutput<typeof ActorProjectionV2Schema>; control?: ArenaRoomSpeciesControlRows; group?: v.InferOutput<typeof SpeciesGroupSchema> | undefined; directed?: v.InferOutput<typeof DirectedSpeciesSchema> | undefined; guard?: true | undefined; elite?: true | undefined; postPose?: { alive: string; dead?: string; envelopes?: v.InferOutput<typeof RidingPresentationSchema>; } | undefined; material: { rim: number; bands: number; }; })[]; }
|
|
79
|
+
export interface SpeciesLookBookRows { slug: string; body: unknown; poses?: Record<string, unknown> | undefined; program?: unknown; rows: ({ metadata: Omit<v.InferOutput<typeof SpeciesSchema>, 'harvest' | 'capExempt'>; id: string; family: string; rigContract: { skeleton: string; clips: (v.InferOutput<typeof SkinClipNameSchema>)[]; sockets: (string)[]; }; rig?: 'quadruped' | 'custom' | undefined; pose?: { grazeNeck: number; gallopTail: number; } | undefined; gait?: { trot: number; gallop: number; } | undefined; eyeGlow?: [number, number, number] | undefined; eyeGlowIntensity?: number | undefined; variants: Record<string, { body: string; tint?: Record<string, [number, number, number]> | undefined; traits?: Record<string, (number) | (boolean)> | undefined; }>; projection?: v.InferOutput<typeof ActorProjectionV2Schema>; control?: ArenaRoomSpeciesControlRows; group?: v.InferOutput<typeof SpeciesGroupSchema> | undefined; directed?: v.InferOutput<typeof DirectedSpeciesSchema> | undefined; guard?: true | undefined; elite?: true | undefined; postPose?: { alive: string; dead?: string; envelopes?: v.InferOutput<typeof RidingPresentationSchema>; } | undefined; material: { rim: number; bands: number; }; })[]; }
|
|
79
80
|
export type NativeSpeciesLookBookRowsInput = unknown;
|
|
80
|
-
export type NativeSpeciesLookBookRows = { body: v.InferOutput<typeof CompactSpeciesBodiesSchema>; } & { slug: string; body: unknown; poses?: Record<string, unknown> | undefined; program?: unknown; rows: ({ metadata: v.InferOutput<typeof SpeciesSchema>; id: string; family: string; rigContract: { skeleton: string; clips: (v.InferOutput<typeof SkinClipNameSchema>)[]; sockets: (string)[]; }; rig?: 'quadruped' | 'custom' | undefined; pose?: { grazeNeck: number; gallopTail: number; } | undefined; gait?: { trot: number; gallop: number; } | undefined; eyeGlow?: [number, number, number] | undefined; eyeGlowIntensity?: number | undefined; variants: Record<string, { body: string; tint?: Record<string, [number, number, number]> | undefined; traits?: Record<string, (number) | (boolean)> | undefined; }>; projection?: v.InferOutput<typeof ActorProjectionV2Schema>; control?: ArenaRoomSpeciesControlRows; group?: v.InferOutput<typeof SpeciesGroupSchema> | undefined; directed?: v.InferOutput<typeof DirectedSpeciesSchema> | undefined; guard?: true | undefined; elite?: true | undefined; postPose?: { alive: string; dead?: string; envelopes?: v.InferOutput<typeof RidingPresentationSchema>; } | undefined; material: { rim: number; bands: number; }; })[]; };
|
|
81
|
-
export interface SpeciesPresentationRowsInput { poses: Record<string, { prefix: string; group: string; scalars: (unknown)[]; look?: unknown; alive?: boolean; }>; packedBodies: v.InferInput<typeof CompactSpeciesBodiesSchema>; guest: CreatureGuestRowsInput; lookBook: Pick<{ slug: string; body: unknown; poses?: Record<string, unknown> | undefined; program?: unknown; rows: ({ metadata: v.InferInput<typeof SpeciesSchema>; id: string; family: string; rigContract: { skeleton: string; clips: (v.InferInput<typeof SkinClipNameSchema>)[]; sockets: (string)[]; }; rig?: 'quadruped' | 'custom' | undefined; pose?: { grazeNeck: number; gallopTail: number; } | undefined; gait?: { trot: number; gallop: number; } | undefined; eyeGlow?: [number, number, number] | undefined; eyeGlowIntensity?: number | undefined; variants: Record<string, { body: string; tint?: Record<string, [number, number, number]> | undefined; traits?: Record<string, (number) | (boolean)> | undefined; }>; projection?: v.InferInput<typeof ActorProjectionV2Schema>; control?: ArenaRoomSpeciesControlRowsInput; group?: v.InferInput<typeof SpeciesGroupSchema> | undefined; directed?: v.InferInput<typeof DirectedSpeciesSchema> | undefined; guard?: true | undefined; elite?: true | undefined; postPose?: { alive: string; dead?: string; envelopes?: v.InferInput<typeof RidingPresentationSchema>; } | undefined; material: { rim: number; bands: number; }; })[]; }, 'slug' | 'rows' | 'program'>; }
|
|
82
|
-
export interface SpeciesPresentationRows { poses: Record<string, { prefix: string; group: string; scalars: (unknown)[]; look?: unknown; alive?: boolean; }>; packedBodies: v.InferOutput<typeof CompactSpeciesBodiesSchema>; guest: CreatureGuestRows; lookBook: Pick<{ slug: string; body: unknown; poses?: Record<string, unknown> | undefined; program?: unknown; rows: ({ metadata: v.InferOutput<typeof SpeciesSchema>; id: string; family: string; rigContract: { skeleton: string; clips: (v.InferOutput<typeof SkinClipNameSchema>)[]; sockets: (string)[]; }; rig?: 'quadruped' | 'custom' | undefined; pose?: { grazeNeck: number; gallopTail: number; } | undefined; gait?: { trot: number; gallop: number; } | undefined; eyeGlow?: [number, number, number] | undefined; eyeGlowIntensity?: number | undefined; variants: Record<string, { body: string; tint?: Record<string, [number, number, number]> | undefined; traits?: Record<string, (number) | (boolean)> | undefined; }>; projection?: v.InferOutput<typeof ActorProjectionV2Schema>; control?: ArenaRoomSpeciesControlRows; group?: v.InferOutput<typeof SpeciesGroupSchema> | undefined; directed?: v.InferOutput<typeof DirectedSpeciesSchema> | undefined; guard?: true | undefined; elite?: true | undefined; postPose?: { alive: string; dead?: string; envelopes?: v.InferOutput<typeof RidingPresentationSchema>; } | undefined; material: { rim: number; bands: number; }; })[]; }, 'slug' | 'rows' | 'program'>; }
|
|
81
|
+
export type NativeSpeciesLookBookRows = { body: v.InferOutput<typeof CompactSpeciesBodiesSchema>; } & { slug: string; body: unknown; poses?: Record<string, unknown> | undefined; program?: unknown; rows: ({ metadata: Omit<v.InferOutput<typeof SpeciesSchema>, 'harvest' | 'capExempt'>; id: string; family: string; rigContract: { skeleton: string; clips: (v.InferOutput<typeof SkinClipNameSchema>)[]; sockets: (string)[]; }; rig?: 'quadruped' | 'custom' | undefined; pose?: { grazeNeck: number; gallopTail: number; } | undefined; gait?: { trot: number; gallop: number; } | undefined; eyeGlow?: [number, number, number] | undefined; eyeGlowIntensity?: number | undefined; variants: Record<string, { body: string; tint?: Record<string, [number, number, number]> | undefined; traits?: Record<string, (number) | (boolean)> | undefined; }>; projection?: v.InferOutput<typeof ActorProjectionV2Schema>; control?: ArenaRoomSpeciesControlRows; group?: v.InferOutput<typeof SpeciesGroupSchema> | undefined; directed?: v.InferOutput<typeof DirectedSpeciesSchema> | undefined; guard?: true | undefined; elite?: true | undefined; postPose?: { alive: string; dead?: string; envelopes?: v.InferOutput<typeof RidingPresentationSchema>; } | undefined; material: { rim: number; bands: number; }; })[]; };
|
|
82
|
+
export interface SpeciesPresentationRowsInput { poses: Record<string, { prefix: string; group: string; scalars: (unknown)[]; look?: unknown; alive?: boolean; }>; packedBodies: v.InferInput<typeof CompactSpeciesBodiesSchema>; guest: CreatureGuestRowsInput; lookBook: Pick<{ slug: string; body: unknown; poses?: Record<string, unknown> | undefined; program?: unknown; rows: ({ metadata: Omit<v.InferInput<typeof SpeciesSchema>, 'harvest' | 'capExempt'>; id: string; family: string; rigContract: { skeleton: string; clips: (v.InferInput<typeof SkinClipNameSchema>)[]; sockets: (string)[]; }; rig?: 'quadruped' | 'custom' | undefined; pose?: { grazeNeck: number; gallopTail: number; } | undefined; gait?: { trot: number; gallop: number; } | undefined; eyeGlow?: [number, number, number] | undefined; eyeGlowIntensity?: number | undefined; variants: Record<string, { body: string; tint?: Record<string, [number, number, number]> | undefined; traits?: Record<string, (number) | (boolean)> | undefined; }>; projection?: v.InferInput<typeof ActorProjectionV2Schema>; control?: ArenaRoomSpeciesControlRowsInput; group?: v.InferInput<typeof SpeciesGroupSchema> | undefined; directed?: v.InferInput<typeof DirectedSpeciesSchema> | undefined; guard?: true | undefined; elite?: true | undefined; postPose?: { alive: string; dead?: string; envelopes?: v.InferInput<typeof RidingPresentationSchema>; } | undefined; material: { rim: number; bands: number; }; })[]; }, 'slug' | 'rows' | 'program'>; }
|
|
83
|
+
export interface SpeciesPresentationRows { poses: Record<string, { prefix: string; group: string; scalars: (unknown)[]; look?: unknown; alive?: boolean; }>; packedBodies: v.InferOutput<typeof CompactSpeciesBodiesSchema>; guest: CreatureGuestRows; lookBook: Pick<{ slug: string; body: unknown; poses?: Record<string, unknown> | undefined; program?: unknown; rows: ({ metadata: Omit<v.InferOutput<typeof SpeciesSchema>, 'harvest' | 'capExempt'>; id: string; family: string; rigContract: { skeleton: string; clips: (v.InferOutput<typeof SkinClipNameSchema>)[]; sockets: (string)[]; }; rig?: 'quadruped' | 'custom' | undefined; pose?: { grazeNeck: number; gallopTail: number; } | undefined; gait?: { trot: number; gallop: number; } | undefined; eyeGlow?: [number, number, number] | undefined; eyeGlowIntensity?: number | undefined; variants: Record<string, { body: string; tint?: Record<string, [number, number, number]> | undefined; traits?: Record<string, (number) | (boolean)> | undefined; }>; projection?: v.InferOutput<typeof ActorProjectionV2Schema>; control?: ArenaRoomSpeciesControlRows; group?: v.InferOutput<typeof SpeciesGroupSchema> | undefined; directed?: v.InferOutput<typeof DirectedSpeciesSchema> | undefined; guard?: true | undefined; elite?: true | undefined; postPose?: { alive: string; dead?: string; envelopes?: v.InferOutput<typeof RidingPresentationSchema>; } | undefined; material: { rim: number; bands: number; }; })[]; }, 'slug' | 'rows' | 'program'>; }
|
|
83
84
|
export interface SpeciesActorsFileRowsInput { species: SpeciesPresentationRowsInput; page: { world: unknown; specimen: unknown; }; draws: v.InferInput<typeof FixedDrawRowsSchema>; pivots: ([number, number, number])[]; parts: (string)[]; radius: number; }
|
|
84
85
|
export interface SpeciesActorsFileRows { species: SpeciesPresentationRows; page: { world: unknown; specimen: unknown; }; draws: v.InferOutput<typeof FixedDrawRowsSchema>; pivots: ([number, number, number])[]; parts: (string)[]; radius: number; }
|
|
@@ -5,6 +5,7 @@ import { SkinClipNameSchema } from './skinData.ts';
|
|
|
5
5
|
import { ClientChannelsSchema, NumericPoseSchema } from './clientChannels.ts';
|
|
6
6
|
import { RidingPresentationSchema } from './riding.ts';
|
|
7
7
|
|
|
8
|
+
const lookMetadata = v.omit(SpeciesSchema, ['harvest', 'capExempt']);
|
|
8
9
|
const text=v.pipe(v.string(),v.minLength(1),v.maxLength(4096)),number=v.pipe(v.number(),v.finite()),rgb=v.tuple([number,number,number]);
|
|
9
10
|
const fur = v.object({ texSeed: number, tex: v.object({ contrast: number, grizzle: number, normalStrength: number,
|
|
10
11
|
bristle: number, strandLen: number, root: number }), roughness: number, sheen: number, sheenColor: rgb,
|
|
@@ -12,7 +13,7 @@ const fur = v.object({ texSeed: number, tex: v.object({ contrast: number, grizzl
|
|
|
12
13
|
const variantLook = v.object({ tint: v.exactOptional(v.record(text, rgb)), traits: v.exactOptional(v.record(text, number)),
|
|
13
14
|
fur: v.exactOptional(v.object({ rim: v.exactOptional(rgb), sheenColor: v.exactOptional(rgb), emissive: v.exactOptional(rgb), emissiveIntensity: v.exactOptional(number) })) });
|
|
14
15
|
/** Immutable species fields and a hull-only rest body; each spawn receives an independent body. */
|
|
15
|
-
export const HullSpeciesSchema: v.GenericSchema<HullSpeciesRowsInput, HullSpeciesRows> = v.object({ ...
|
|
16
|
+
export const HullSpeciesSchema: v.GenericSchema<HullSpeciesRowsInput, HullSpeciesRows> = v.object({ ...lookMetadata.entries, fur,
|
|
16
17
|
variants: v.array(v.object({ ...SpeciesSchema.entries.variants.item.entries, ...variantLook.entries })),
|
|
17
18
|
rigContract: v.object({ skeleton: text, clips: v.array(v.never()), sockets: v.array(text) }),
|
|
18
19
|
pose: v.object({ grazeNeck: number, gallopTail: number }),
|
|
@@ -129,7 +130,7 @@ export const DirectedSpeciesSchema: v.GenericSchema<DirectedSpeciesRowsInput, Di
|
|
|
129
130
|
});
|
|
130
131
|
|
|
131
132
|
/** Admitted data contracts, independent of validator implementation metadata. */
|
|
132
|
-
export type HullSpeciesRowsInput = Omit<v.InferInput<typeof SpeciesSchema>, keyof ({
|
|
133
|
+
export type HullSpeciesRowsInput = Omit<v.InferInput<typeof SpeciesSchema>, 'harvest' | 'capExempt' | keyof ({
|
|
133
134
|
fur: {
|
|
134
135
|
texSeed: number;
|
|
135
136
|
tex: {
|
|
@@ -368,7 +369,7 @@ export type HullSpeciesRowsInput = Omit<v.InferInput<typeof SpeciesSchema>, keyo
|
|
|
368
369
|
};
|
|
369
370
|
};
|
|
370
371
|
};
|
|
371
|
-
export type HullSpeciesRows = Omit<v.InferOutput<typeof SpeciesSchema>, keyof ({
|
|
372
|
+
export type HullSpeciesRows = Omit<v.InferOutput<typeof SpeciesSchema>, 'harvest' | 'capExempt' | keyof ({
|
|
372
373
|
fur: {
|
|
373
374
|
texSeed: number;
|
|
374
375
|
tex: {
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import type { StrikeDebrisCatalogue } from './strike-debris.ts';
|
|
2
|
+
import { strikeDebrisCatalogueRules } from './strike-debris.ts';
|
|
3
|
+
import type { HarvestDrop, HarvestSpecies } from './harvest-rows.ts';
|
|
4
|
+
import { HarvestDropsSchema, harvestSpeciesRules } from './harvest-rows.ts';
|
|
1
5
|
import * as v from 'valibot';
|
|
2
6
|
import { SpawnTablesSchema } from './spawnTables.ts';
|
|
3
7
|
import { isJsonData } from './json.ts';
|
|
@@ -40,8 +44,8 @@ const flight = v.strictObject({ altitude: finite, above: v.exactOptional(v.pickl
|
|
|
40
44
|
climbRate: positive, diveRate: positive, lockRange: v.exactOptional(positive),
|
|
41
45
|
bank: v.exactOptional(v.pipe(positive, v.check(n => n < Math.PI / 2, 'bank below pi/2'))) });
|
|
42
46
|
/** Strict species data, with bounded ordered variants and no native callback fields. */
|
|
43
|
-
const SpeciesSchema: v.StrictObjectSchema<{ readonly id: v.GenericSchema<SpeciesDataInput['id'], SpeciesData['id']>; readonly kind: v.GenericSchema<SpeciesDataInput['kind'], SpeciesData['kind']>; readonly label: v.GenericSchema<SpeciesDataInput['label'], SpeciesData['label']>; readonly variants: v.ArraySchema<v.StrictObjectSchema<{ readonly id: v.GenericSchema<SpeciesVariantDataInput['id'], SpeciesVariantData['id']>; readonly label: v.GenericSchema<SpeciesVariantDataInput['label'], SpeciesVariantData['label']>; readonly weight: v.GenericSchema<SpeciesVariantDataInput['weight'], SpeciesVariantData['weight']>; readonly rarity: v.GenericSchema<SpeciesVariantDataInput['rarity'], SpeciesVariantData['rarity']>; readonly scale: v.GenericSchema<SpeciesVariantDataInput['scale'], SpeciesVariantData['scale']>; readonly hp: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesVariantDataInput['hp'], undefined>, Exclude<SpeciesVariantData['hp'], undefined>>, undefined>; readonly mods: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesVariantDataInput['mods'], undefined>, Exclude<SpeciesVariantData['mods'], undefined>>, undefined>; }, undefined>, undefined>; readonly spawnOnly: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['spawnOnly'], undefined>, Exclude<SpeciesData['spawnOnly'], undefined>>, undefined>; readonly aggressive: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['aggressive'], undefined>, Exclude<SpeciesData['aggressive'], undefined>>, undefined>; readonly walkSpeed: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['walkSpeed'], undefined>, Exclude<SpeciesData['walkSpeed'], undefined>>, undefined>; readonly chargeSpeed: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['chargeSpeed'], undefined>, Exclude<SpeciesData['chargeSpeed'], undefined>>, undefined>; readonly chargeDamage: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['chargeDamage'], undefined>, Exclude<SpeciesData['chargeDamage'], undefined>>, undefined>; readonly chargeWindup: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['chargeWindup'], undefined>, Exclude<SpeciesData['chargeWindup'], undefined>>, undefined>; readonly ringRadius: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['ringRadius'], undefined>, Exclude<SpeciesData['ringRadius'], undefined>>, undefined>; readonly trampleRadius: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['trampleRadius'], undefined>, Exclude<SpeciesData['trampleRadius'], undefined>>, undefined>; readonly tuning: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['tuning'], undefined>, Exclude<SpeciesData['tuning'], undefined>>, undefined>; readonly sounds: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['sounds'], undefined>, Exclude<SpeciesData['sounds'], undefined>>, undefined>; readonly tick: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['tick'], undefined>, Exclude<SpeciesData['tick'], undefined>>, undefined>; readonly corpseFade: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['corpseFade'], undefined>, Exclude<SpeciesData['corpseFade'], undefined>>, undefined>; readonly blood: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['blood'], undefined>, Exclude<SpeciesData['blood'], undefined>>, undefined>; readonly flight: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['flight'], undefined>, Exclude<SpeciesData['flight'], undefined>>, undefined>; readonly lockable: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['lockable'], undefined>, Exclude<SpeciesData['lockable'], undefined>>, undefined>; }, undefined> = v.strictObject({
|
|
44
|
-
id, kind: id, label: text, variants: v.pipe(v.array(variant), v.minLength(1), v.maxLength(64)),
|
|
47
|
+
const SpeciesSchema: v.StrictObjectSchema<{ readonly capExempt: v.ExactOptionalSchema<v.BooleanSchema<undefined>, undefined>; readonly harvest: v.ExactOptionalSchema<typeof HarvestDropsSchema, undefined>; readonly id: v.GenericSchema<SpeciesDataInput['id'], SpeciesData['id']>; readonly kind: v.GenericSchema<SpeciesDataInput['kind'], SpeciesData['kind']>; readonly label: v.GenericSchema<SpeciesDataInput['label'], SpeciesData['label']>; readonly variants: v.ArraySchema<v.StrictObjectSchema<{ readonly id: v.GenericSchema<SpeciesVariantDataInput['id'], SpeciesVariantData['id']>; readonly label: v.GenericSchema<SpeciesVariantDataInput['label'], SpeciesVariantData['label']>; readonly weight: v.GenericSchema<SpeciesVariantDataInput['weight'], SpeciesVariantData['weight']>; readonly rarity: v.GenericSchema<SpeciesVariantDataInput['rarity'], SpeciesVariantData['rarity']>; readonly scale: v.GenericSchema<SpeciesVariantDataInput['scale'], SpeciesVariantData['scale']>; readonly hp: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesVariantDataInput['hp'], undefined>, Exclude<SpeciesVariantData['hp'], undefined>>, undefined>; readonly mods: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesVariantDataInput['mods'], undefined>, Exclude<SpeciesVariantData['mods'], undefined>>, undefined>; }, undefined>, undefined>; readonly spawnOnly: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['spawnOnly'], undefined>, Exclude<SpeciesData['spawnOnly'], undefined>>, undefined>; readonly aggressive: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['aggressive'], undefined>, Exclude<SpeciesData['aggressive'], undefined>>, undefined>; readonly walkSpeed: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['walkSpeed'], undefined>, Exclude<SpeciesData['walkSpeed'], undefined>>, undefined>; readonly chargeSpeed: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['chargeSpeed'], undefined>, Exclude<SpeciesData['chargeSpeed'], undefined>>, undefined>; readonly chargeDamage: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['chargeDamage'], undefined>, Exclude<SpeciesData['chargeDamage'], undefined>>, undefined>; readonly chargeWindup: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['chargeWindup'], undefined>, Exclude<SpeciesData['chargeWindup'], undefined>>, undefined>; readonly ringRadius: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['ringRadius'], undefined>, Exclude<SpeciesData['ringRadius'], undefined>>, undefined>; readonly trampleRadius: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['trampleRadius'], undefined>, Exclude<SpeciesData['trampleRadius'], undefined>>, undefined>; readonly tuning: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['tuning'], undefined>, Exclude<SpeciesData['tuning'], undefined>>, undefined>; readonly sounds: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['sounds'], undefined>, Exclude<SpeciesData['sounds'], undefined>>, undefined>; readonly tick: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['tick'], undefined>, Exclude<SpeciesData['tick'], undefined>>, undefined>; readonly corpseFade: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['corpseFade'], undefined>, Exclude<SpeciesData['corpseFade'], undefined>>, undefined>; readonly blood: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['blood'], undefined>, Exclude<SpeciesData['blood'], undefined>>, undefined>; readonly flight: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['flight'], undefined>, Exclude<SpeciesData['flight'], undefined>>, undefined>; readonly lockable: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['lockable'], undefined>, Exclude<SpeciesData['lockable'], undefined>>, undefined>; }, undefined> = v.strictObject({
|
|
48
|
+
id, kind: id, label: text, capExempt: v.exactOptional(v.boolean()), harvest: v.exactOptional(HarvestDropsSchema), variants: v.pipe(v.array(variant), v.minLength(1), v.maxLength(64)),
|
|
45
49
|
spawnOnly: v.exactOptional(v.pipe(v.array(variant), v.maxLength(64))), aggressive: v.exactOptional(v.boolean()),
|
|
46
50
|
walkSpeed: v.exactOptional(nonnegative), chargeSpeed: v.exactOptional(nonnegative), chargeDamage: v.exactOptional(nonnegative),
|
|
47
51
|
chargeWindup: v.exactOptional(nonnegative), ringRadius: v.exactOptional(nonnegative), trampleRadius: v.exactOptional(nonnegative),
|
|
@@ -53,7 +57,14 @@ const SpeciesSchema: v.StrictObjectSchema<{ readonly id: v.GenericSchema<Species
|
|
|
53
57
|
|
|
54
58
|
/** Callback-free gameplay metadata; rendering and policy ownership are admitted separately. */
|
|
55
59
|
|
|
56
|
-
|
|
60
|
+
// SpeciesSchema checks field shapes; readSpecies additionally checks row-local harvest references.
|
|
61
|
+
const NO_HARVEST_ERRORS = 0;
|
|
62
|
+
function readSpecies(input: unknown): SpeciesData {
|
|
63
|
+
const row = v.parse(SpeciesSchema, input);
|
|
64
|
+
const errors = harvestSpeciesRules([row]);
|
|
65
|
+
if (errors.length > NO_HARVEST_ERRORS) { throw new Error(errors.join('; ')); }
|
|
66
|
+
return row;
|
|
67
|
+
}
|
|
57
68
|
/** One existing SpeciesBrains owner receives these admitted policy/body rows and strike definitions. */
|
|
58
69
|
const SpeciesProgramSchema: v.GenericSchema<SpeciesProgramDataInput, SpeciesProgramData> = v.pipe(v.unknown(), v.check(isJsonData, 'Species program must be plain JSON'), v.strictObject({
|
|
59
70
|
species: v.pipe(v.array(v.strictObject({ ...SpeciesSchema.entries, brain: v.exactOptional(SpeciesBrainSchema),
|
|
@@ -61,7 +72,7 @@ const SpeciesProgramSchema: v.GenericSchema<SpeciesProgramDataInput, SpeciesProg
|
|
|
61
72
|
strikes: v.pipe(v.array(CreatureStrikeSchema), v.maxLength(256)),
|
|
62
73
|
modules: v.exactOptional(v.record(v.pipe(v.string(), v.minLength(1), v.maxLength(128)), v.pipe(v.string(), v.maxLength(400000)))),
|
|
63
74
|
}), v.check(value => new Set(value.species.map(row => row.kind)).size === value.species.length
|
|
64
|
-
&& new Set(value.strikes.map(row => row.id)).size === value.strikes.length, 'Unique program kinds and strikes'));
|
|
75
|
+
&& new Set(value.strikes.map(row => row.id)).size === value.strikes.length, 'Unique program kinds and strikes'), v.check<SpeciesProgramData, 'Species harvest references'>((value: Readonly<{ species: readonly HarvestSpecies[] }>): boolean => harvestSpeciesRules(value.species).length === NO_HARVEST_ERRORS, 'Species harvest references'), v.check<SpeciesProgramData, 'Strike debris references'>((value: StrikeDebrisCatalogue): boolean => strikeDebrisCatalogueRules(value).length === NO_HARVEST_ERRORS, 'Strike debris references'));
|
|
65
76
|
|
|
66
77
|
function readSpeciesProgram(input: unknown): SpeciesProgramData { return v.parse(SpeciesProgramSchema, input); }
|
|
67
78
|
|
|
@@ -82,15 +93,15 @@ const NativeHuntSchema: v.GenericSchema<NativeHuntRowsInput, NativeHuntRows> = v
|
|
|
82
93
|
const SpeciesProgramsSchema: v.GenericSchema<SpeciesProgramsInput, SpeciesPrograms> = v.pipe(v.unknown(), v.check(isJsonData, 'Species programs must be plain JSON'),
|
|
83
94
|
v.strictObject({ page: v.pipe(v.array(SpeciesSchema), v.maxLength(256)), native: v.pipe(v.array(SpeciesSchema), v.maxLength(256)), program: v.exactOptional(SpeciesProgramSchema),
|
|
84
95
|
spawns: v.exactOptional(SpawnTablesSchema), hunt: v.exactOptional(NativeHuntSchema) }),
|
|
85
|
-
v.check(value => [value.page, value.native].every(rows => new Set(rows.map(row => row.kind)).size === rows.length), 'Unique species kinds per owner'));
|
|
96
|
+
v.check(value => [value.page, value.native].every(rows => new Set(rows.map(row => row.kind)).size === rows.length), 'Unique species kinds per owner'), v.check<SpeciesPrograms, 'Species harvest references'>((value: Readonly<{ page: readonly HarvestSpecies[]; native: readonly HarvestSpecies[] }>): boolean => harvestSpeciesRules([...value.page, ...value.native]).length === NO_HARVEST_ERRORS, 'Species harvest references'));
|
|
86
97
|
|
|
87
98
|
function readSpeciesPrograms(input: unknown): SpeciesPrograms { return v.parse(SpeciesProgramsSchema, input); }
|
|
88
99
|
|
|
89
100
|
/** Validated species metadata independent of validator implementation types. */
|
|
90
101
|
type SpeciesVariantDataInput = SpeciesVariantData;
|
|
91
102
|
interface SpeciesVariantData { id: string; label: string; weight: number; rarity: 'common' | 'uncommon' | 'rare' | 'legendary'; scale: [number, number]; hp?: number; mods?: { speed?: number; chargeDist?: number; damageTaken?: number; chargeDamage?: number; relentless?: boolean; }; }
|
|
92
|
-
interface SpeciesDataInput { id: string; kind: string; label: string; variants: (SpeciesVariantDataInput)[]; spawnOnly?: (SpeciesVariantDataInput)[]; aggressive?: boolean; walkSpeed?: number; chargeSpeed?: number; chargeDamage?: number; chargeWindup?: number; ringRadius?: number; trampleRadius?: number; tuning?: { hp: number; sightRange: number; sightRangeGraze: number; sightCone: number; hearStill: number; hearCrouch: number; hearWalk: number; hearSprint: number; noticeRate: number; forgetRate: number; alertAt: number; boltAt: number; freezeMin: number; freezeMax: number; relaxAfter: number; panicDist: number; runSpeed: number; trotSpeed: number; fleeMinTime: number; fleeUntil: number; fleeUntilMax: number; fleeMaxTime: number; lookBack: number; waryTime: number; waryBoost: number; herdAlertRadius: number; herdBoltDelayMin: number; herdBoltDelayMax: number; impactSpook: number; impactAlert: number; stalk?: { detect: number; speed: number; giveUp: number; rechargeCd: number; huffMin: number; huffMax: number; roar: string; fleeBelowHp: number; fleeChance: number; }; }; sounds?: { call: string; hurt: string; callVariants?: (string)[]; callEvery?: [number, number]; }; tick?: 'ai' | 'always'; corpseFade?: number; blood?: boolean; flight?: { altitude: number; above?: 'ground' | 'world'; climbRate: number; diveRate: number; lockRange?: number; bank?: number; }; lockable?: boolean; }
|
|
93
|
-
interface SpeciesData { id: string; kind: string; label: string; variants: (SpeciesVariantData)[]; spawnOnly?: (SpeciesVariantData)[]; aggressive?: boolean; walkSpeed?: number; chargeSpeed?: number; chargeDamage?: number; chargeWindup?: number; ringRadius?: number; trampleRadius?: number; tuning?: { hp: number; sightRange: number; sightRangeGraze: number; sightCone: number; hearStill: number; hearCrouch: number; hearWalk: number; hearSprint: number; noticeRate: number; forgetRate: number; alertAt: number; boltAt: number; freezeMin: number; freezeMax: number; relaxAfter: number; panicDist: number; runSpeed: number; trotSpeed: number; fleeMinTime: number; fleeUntil: number; fleeUntilMax: number; fleeMaxTime: number; lookBack: number; waryTime: number; waryBoost: number; herdAlertRadius: number; herdBoltDelayMin: number; herdBoltDelayMax: number; impactSpook: number; impactAlert: number; stalk?: { detect: number; speed: number; giveUp: number; rechargeCd: number; huffMin: number; huffMax: number; roar: string; fleeBelowHp: number; fleeChance: number; }; }; sounds?: { call: string; hurt: string; callVariants?: (string)[]; callEvery?: [number, number]; }; tick?: 'ai' | 'always'; corpseFade?: number; blood?: boolean; flight?: { altitude: number; above?: 'ground' | 'world'; climbRate: number; diveRate: number; lockRange?: number; bank?: number; }; lockable?: boolean; }
|
|
103
|
+
interface SpeciesDataInput { capExempt?: boolean; harvest?: HarvestDrop[]; id: string; kind: string; label: string; variants: (SpeciesVariantDataInput)[]; spawnOnly?: (SpeciesVariantDataInput)[]; aggressive?: boolean; walkSpeed?: number; chargeSpeed?: number; chargeDamage?: number; chargeWindup?: number; ringRadius?: number; trampleRadius?: number; tuning?: { hp: number; sightRange: number; sightRangeGraze: number; sightCone: number; hearStill: number; hearCrouch: number; hearWalk: number; hearSprint: number; noticeRate: number; forgetRate: number; alertAt: number; boltAt: number; freezeMin: number; freezeMax: number; relaxAfter: number; panicDist: number; runSpeed: number; trotSpeed: number; fleeMinTime: number; fleeUntil: number; fleeUntilMax: number; fleeMaxTime: number; lookBack: number; waryTime: number; waryBoost: number; herdAlertRadius: number; herdBoltDelayMin: number; herdBoltDelayMax: number; impactSpook: number; impactAlert: number; stalk?: { detect: number; speed: number; giveUp: number; rechargeCd: number; huffMin: number; huffMax: number; roar: string; fleeBelowHp: number; fleeChance: number; }; }; sounds?: { call: string; hurt: string; callVariants?: (string)[]; callEvery?: [number, number]; }; tick?: 'ai' | 'always'; corpseFade?: number; blood?: boolean; flight?: { altitude: number; above?: 'ground' | 'world'; climbRate: number; diveRate: number; lockRange?: number; bank?: number; }; lockable?: boolean; }
|
|
104
|
+
interface SpeciesData { capExempt?: boolean; harvest?: HarvestDrop[]; id: string; kind: string; label: string; variants: (SpeciesVariantData)[]; spawnOnly?: (SpeciesVariantData)[]; aggressive?: boolean; walkSpeed?: number; chargeSpeed?: number; chargeDamage?: number; chargeWindup?: number; ringRadius?: number; trampleRadius?: number; tuning?: { hp: number; sightRange: number; sightRangeGraze: number; sightCone: number; hearStill: number; hearCrouch: number; hearWalk: number; hearSprint: number; noticeRate: number; forgetRate: number; alertAt: number; boltAt: number; freezeMin: number; freezeMax: number; relaxAfter: number; panicDist: number; runSpeed: number; trotSpeed: number; fleeMinTime: number; fleeUntil: number; fleeUntilMax: number; fleeMaxTime: number; lookBack: number; waryTime: number; waryBoost: number; herdAlertRadius: number; herdBoltDelayMin: number; herdBoltDelayMax: number; impactSpook: number; impactAlert: number; stalk?: { detect: number; speed: number; giveUp: number; rechargeCd: number; huffMin: number; huffMax: number; roar: string; fleeBelowHp: number; fleeChance: number; }; }; sounds?: { call: string; hurt: string; callVariants?: (string)[]; callEvery?: [number, number]; }; tick?: 'ai' | 'always'; corpseFade?: number; blood?: boolean; flight?: { altitude: number; above?: 'ground' | 'world'; climbRate: number; diveRate: number; lockRange?: number; bank?: number; }; lockable?: boolean; }
|
|
94
105
|
type SpeciesProgramDataInput = unknown;
|
|
95
106
|
interface SpeciesProgramData { species: ({ brain?: v.InferOutput<typeof SpeciesBrainSchema>; body?: v.InferOutput<typeof CreatureBodyRecipeSchema>; } & SpeciesData)[]; strikes: (v.InferOutput<typeof CreatureStrikeSchema>)[]; modules?: Record<string, string>; }
|
|
96
107
|
type NativeHuntRowsInput = NativeHuntRows;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import {
|
|
2
|
+
array,
|
|
3
|
+
boolean,
|
|
4
|
+
check,
|
|
5
|
+
custom,
|
|
6
|
+
exactOptional,
|
|
7
|
+
integer,
|
|
8
|
+
maxLength,
|
|
9
|
+
maxValue,
|
|
10
|
+
minValue,
|
|
11
|
+
number,
|
|
12
|
+
pipe,
|
|
13
|
+
regex,
|
|
14
|
+
strictObject,
|
|
15
|
+
string,
|
|
16
|
+
} from 'valibot'
|
|
17
|
+
|
|
18
|
+
import { isJsonData } from './json.ts'
|
|
19
|
+
|
|
20
|
+
import type { GenericSchema } from 'valibot'
|
|
21
|
+
|
|
22
|
+
/** A bounded contact effect, using the existing effects owner's material recipes. */
|
|
23
|
+
interface StrikeDebris {
|
|
24
|
+
surface: 'shell' | 'wood' | 'sand'
|
|
25
|
+
count: number
|
|
26
|
+
atFeet: boolean
|
|
27
|
+
sparks: boolean
|
|
28
|
+
}
|
|
29
|
+
/** A strike's default and optional target-species overrides, keyed by row id. */
|
|
30
|
+
interface StrikeDebrisPolicy {
|
|
31
|
+
default: StrikeDebris
|
|
32
|
+
overrides?: { target: string; effect: StrikeDebris }[]
|
|
33
|
+
}
|
|
34
|
+
const MAX_PARTICLES = 64
|
|
35
|
+
const MAX_OVERRIDES = 64
|
|
36
|
+
const MAX_ID = 128
|
|
37
|
+
const EMPTY = 0
|
|
38
|
+
const surface = custom<StrikeDebris['surface']>(
|
|
39
|
+
(value: unknown): boolean =>
|
|
40
|
+
value === 'shell' || value === 'wood' || value === 'sand',
|
|
41
|
+
)
|
|
42
|
+
const count = pipe(
|
|
43
|
+
number(),
|
|
44
|
+
integer(),
|
|
45
|
+
minValue(EMPTY),
|
|
46
|
+
maxValue(MAX_PARTICLES),
|
|
47
|
+
)
|
|
48
|
+
const effect: GenericSchema<StrikeDebris> = strictObject({
|
|
49
|
+
surface,
|
|
50
|
+
count,
|
|
51
|
+
atFeet: boolean(),
|
|
52
|
+
sparks: boolean(),
|
|
53
|
+
})
|
|
54
|
+
const target = pipe(
|
|
55
|
+
string(),
|
|
56
|
+
regex(/^[a-z][a-zA-Z0-9.:-]*$/u),
|
|
57
|
+
maxLength(MAX_ID),
|
|
58
|
+
)
|
|
59
|
+
const override = strictObject({ target, effect })
|
|
60
|
+
const overrides = pipe(
|
|
61
|
+
array(override),
|
|
62
|
+
maxLength(MAX_OVERRIDES),
|
|
63
|
+
check<NonNullable<StrikeDebrisPolicy['overrides']>, 'unique debris targets'>(
|
|
64
|
+
(rows: readonly Readonly<{ target: string }>[]): boolean => {
|
|
65
|
+
const identities = rows.map(
|
|
66
|
+
(row: Readonly<{ target: string }>): string => row.target,
|
|
67
|
+
)
|
|
68
|
+
return new Set(identities).size === rows.length
|
|
69
|
+
},
|
|
70
|
+
'unique debris targets',
|
|
71
|
+
),
|
|
72
|
+
)
|
|
73
|
+
const policy = strictObject({
|
|
74
|
+
default: effect,
|
|
75
|
+
overrides: exactOptional(overrides),
|
|
76
|
+
})
|
|
77
|
+
const StrikeDebrisSchema: GenericSchema<StrikeDebrisPolicy> = pipe(
|
|
78
|
+
custom<StrikeDebrisPolicy>(isJsonData, 'plain strike debris'),
|
|
79
|
+
policy,
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
interface DebrisReferences {
|
|
83
|
+
readonly overrides?: readonly Readonly<{ target: string }>[]
|
|
84
|
+
}
|
|
85
|
+
interface DebrisSource {
|
|
86
|
+
readonly debris?: DebrisReferences
|
|
87
|
+
}
|
|
88
|
+
interface StrikeDebrisCatalogue {
|
|
89
|
+
readonly strikes: readonly DebrisSource[]
|
|
90
|
+
readonly species: readonly Readonly<{ id: string }>[]
|
|
91
|
+
}
|
|
92
|
+
function strikeDebrisCatalogueRules(value: StrikeDebrisCatalogue): string[] {
|
|
93
|
+
const identities = value.species.map(
|
|
94
|
+
(row: Readonly<{ id: string }>): string => row.id,
|
|
95
|
+
)
|
|
96
|
+
const errors: string[] = []
|
|
97
|
+
const known = new Set(identities)
|
|
98
|
+
for (const strike of value.strikes) {
|
|
99
|
+
for (const row of strike.debris?.overrides ?? []) {
|
|
100
|
+
if (!known.has(row.target)) {
|
|
101
|
+
errors.push(`Unknown debris target species: ${row.target}`)
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return errors
|
|
106
|
+
}
|
|
107
|
+
export { StrikeDebrisSchema, strikeDebrisCatalogueRules }
|
|
108
|
+
export type { StrikeDebris, StrikeDebrisPolicy, StrikeDebrisCatalogue }
|
package/src/format/targets.ts
CHANGED
|
@@ -15,11 +15,15 @@ const prompt = { id, at: v.tuple([coord, coord, coord]), radius: v.pipe(finite,
|
|
|
15
15
|
/** A use target: its prompt runs `scene`. `unless` (TE-ENG6) names a `hooks.conditions` row: while it holds, the use is
|
|
16
16
|
* spent and its prompt is gone (a lit brazier). */
|
|
17
17
|
const interactionRow = v.strictObject({ ...prompt, scene: id, unless: v.exactOptional(id) });
|
|
18
|
+
const FLAG_NAME_MIN = 1;
|
|
19
|
+
const FLAG_NAME_MAX = 128;
|
|
20
|
+
const questFlag = v.pipe(v.string(), v.minLength(FLAG_NAME_MIN), v.maxLength(FLAG_NAME_MAX));
|
|
21
|
+
const itemActionRow = v.strictObject({ scene: id, item: id, action: v.picklist([3, 4]), setsFlag: v.exactOptional(questFlag) });
|
|
18
22
|
/** Named panels and colliders follow published state; interactions enqueue a named scene on the existing input path. */
|
|
19
23
|
export const TargetsSchema: v.GenericSchema<ShardTargetsInput, ShardTargets> = v.strictObject({
|
|
20
24
|
panels: v.pipe(v.array(v.strictObject({ panel: id, scope: v.picklist(['shared', 'player']), fieldId: v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(0x7fffffff)), equals: finite, visibleWhenMatched: v.boolean(), colliders: v.array(id), activeWhenMatched: v.boolean() })), v.maxLength(64)),
|
|
21
25
|
interactions: v.pipe(v.array(interactionRow), v.maxLength(64)),
|
|
22
|
-
itemActions: v.exactOptional(v.pipe(v.array(
|
|
26
|
+
itemActions: v.exactOptional(v.pipe(v.array(itemActionRow), v.maxLength(64))),
|
|
23
27
|
itemFields: v.exactOptional(v.pipe(v.array(v.strictObject({ item: id, fieldId: v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(0x7fffffff)), property: v.picklist(['fuel', 'lit', 'taken']) })), v.maxLength(64))),
|
|
24
28
|
/** TE-ENG3: a quest-giver who talks from rows. `at` is its feet; its talk prompt stands over them and reaches `radius`. E
|
|
25
29
|
* opens its `quests.dialogue` tree on the player's node. `figure` names the props model or panel that draws it; none: a
|
|
@@ -40,6 +44,15 @@ function idsOf(rows: readonly Readonly<{ id: string }>[]): Set<string> {
|
|
|
40
44
|
}
|
|
41
45
|
return out;
|
|
42
46
|
}
|
|
47
|
+
/** An item use writes only a flag declared by this shard's quest contract. */
|
|
48
|
+
function itemActionFlags(actions: readonly Readonly<{ setsFlag?: string }>[], flags: readonly string[]): string[] {
|
|
49
|
+
for (const row of actions) {
|
|
50
|
+
if (row.setsFlag !== undefined && !flags.includes(row.setsFlag)) {
|
|
51
|
+
return ['declared item action quest flags'];
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return [];
|
|
55
|
+
}
|
|
43
56
|
/** TE-ENG6: an interaction's `unless` names a declared condition a page can read: a shared field, or a player field an
|
|
44
57
|
* item projects (the page sees no other player field). */
|
|
45
58
|
function unlessRefused(
|
|
@@ -115,7 +128,7 @@ function talksRefused(
|
|
|
115
128
|
return false;
|
|
116
129
|
}
|
|
117
130
|
/** Refuse dangling identities, private fields and two writers for the same visual or collider. */
|
|
118
|
-
export function targetRules(targets: ShardTargets, shard: { state: v.InferOutput<typeof StateSchema>; hooks: ShardHooks; sim: { scripts: readonly string[]; bindings: ShardScriptBindings }; items: ShardItems; quests?: { dialogue: readonly { id: string }[] } }, props: { panels: readonly { id: string }[]; colliders: readonly { id: string }[]; models?: readonly { id: string }[] } | null): string[] {
|
|
131
|
+
export function targetRules(targets: ShardTargets, shard: { state: v.InferOutput<typeof StateSchema>; hooks: ShardHooks; sim: { scripts: readonly string[]; bindings: ShardScriptBindings }; items: ShardItems; quests?: { dialogue: readonly { id: string }[]; flags?: readonly string[] } }, props: { panels: readonly { id: string }[]; colliders: readonly { id: string }[]; models?: readonly { id: string }[] } | null): string[] {
|
|
119
132
|
const errors = hookRules({ conditions: targets.panels.map((row) => ({ id: row.panel, ...row })), scenes: [] }, shard.state);
|
|
120
133
|
const panels = new Set(props?.panels.map((row) => row.id)), colliders = new Set(props?.colliders.map((row) => row.id)), scenes = new Set(shard.hooks.scenes.map((row) => row.id));
|
|
121
134
|
const bound = targets.panels.flatMap((row) => row.colliders);
|
|
@@ -125,6 +138,8 @@ export function targetRules(targets: ShardTargets, shard: { state: v.InferOutput
|
|
|
125
138
|
if (targets.panels.length > 0 && shard.sim.bindings.length === 0) errors.push('target fields require script bindings');
|
|
126
139
|
const actions = targets.itemActions ?? [], fields = targets.itemFields ?? [];
|
|
127
140
|
if (new Set(actions.map((row) => row.scene)).size !== actions.length || actions.some((row) => !scenes.has(row.scene) || !shard.items.rows.some((item) => item.id === row.item && (item.kind === 'tool' || item.family === LEVER_FAMILY || item.family === MELEE_FAMILY && row.action === RACK_TAKE)))) errors.push('declared item action scenes');
|
|
141
|
+
// TC-E7: item uses may raise only a declared quest flag, for the player who uses the scene.
|
|
142
|
+
errors.push(...itemActionFlags(actions, shard.quests?.flags ?? []));
|
|
128
143
|
if (new Set(fields.map((row) => row.fieldId)).size !== fields.length || fields.some((row) => {
|
|
129
144
|
const field = shard.state.player.find((entry) => entry.id === row.fieldId);
|
|
130
145
|
return !projects(shard.items.rows, row) || field === undefined || field.privacy === 'host' || field.type !== (row.property === 'fuel' ? 'f64' : 'bool') || (field.min ?? 0) > 0 || (field.max ?? 1) < 1;
|
|
@@ -181,6 +196,8 @@ interface ShardTargetsFields {
|
|
|
181
196
|
scene: string;
|
|
182
197
|
item: string;
|
|
183
198
|
action: 3 | 4;
|
|
199
|
+
/** Raise this declared quest flag for the player whose item use is accepted. */
|
|
200
|
+
setsFlag?: string;
|
|
184
201
|
})[];
|
|
185
202
|
itemFields?: ({
|
|
186
203
|
item: string;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { StrikeDebrisSchema } from './strike-debris.ts';
|
|
2
|
+
import type { StrikeDebrisPolicy } from './strike-debris.ts';
|
|
1
3
|
import * as v from 'valibot';
|
|
2
4
|
import { isJsonData } from './json.ts';
|
|
3
5
|
import { ClientChannelsSchema, ClientChannelInputsSchema, ClientChannelPropertySchema } from './clientChannels.ts';
|
|
@@ -9,9 +11,9 @@ const duration = v.pipe(seconds, v.minValue(0.000001));
|
|
|
9
11
|
const count = v.pipe(scalar, v.integer(), v.maxValue(1024));
|
|
10
12
|
const slots = v.pipe(count, v.minValue(1));
|
|
11
13
|
const probability = v.pipe(scalar, v.maxValue(1));
|
|
12
|
-
const swing = v.pipe(v.strictObject({ windup: seconds, slashEnd: duration, total: duration, damage: scalar,
|
|
14
|
+
const swing: v.GenericSchema<MeleeSwingRows> = v.pipe(v.strictObject({ debris: v.exactOptional(StrikeDebrisSchema), windup: seconds, slashEnd: duration, total: duration, damage: scalar,
|
|
13
15
|
stagger: v.exactOptional(scalar), sweep: v.exactOptional(v.pipe(v.number(), v.finite(), v.minValue(-10000), v.maxValue(10000))), reach: v.exactOptional(positive) }),
|
|
14
|
-
v.check(row => row.windup <= row.slashEnd && row.slashEnd <= row.total, 'Ordered native swing phases'));
|
|
16
|
+
v.check<MeleeSwingRows, 'Ordered native swing phases'>((row: Readonly<Pick<MeleeSwingRows, 'windup' | 'slashEnd' | 'total'>>): boolean => row.windup <= row.slashEnd && row.slashEnd <= row.total, 'Ordered native swing phases'));
|
|
15
17
|
const flight = v.strictObject({ gravity: scalar, drag: scalar, windCoupling: scalar });
|
|
16
18
|
const cone = v.strictObject({ degrees: scalar, radius: v.picklist(['linear', 'sqrt']), axisScale: v.picklist([1, 2]) });
|
|
17
19
|
|
|
@@ -300,6 +302,7 @@ export const HeldBowFileSchema: v.GenericSchema<HeldBowFileRowsInput, HeldBowFil
|
|
|
300
302
|
|
|
301
303
|
|
|
302
304
|
/** Admitted data contracts, independent of validator implementation metadata. */
|
|
305
|
+
interface MeleeSwingRows { windup: number; slashEnd: number; total: number; damage: number; stagger?: number; sweep?: number; reach?: number; debris?: StrikeDebrisPolicy; }
|
|
303
306
|
export type MeleeWeaponProfileRowsInput = MeleeWeaponProfileRows;
|
|
304
307
|
interface MeleeWeaponProfileRowsFields {
|
|
305
308
|
family: 'melee';
|
|
@@ -310,46 +313,7 @@ interface MeleeWeaponProfileRowsFields {
|
|
|
310
313
|
comboGap: number;
|
|
311
314
|
chainLag: number;
|
|
312
315
|
heavyCharge: number;
|
|
313
|
-
moves: {
|
|
314
|
-
combo: ({
|
|
315
|
-
windup: number;
|
|
316
|
-
slashEnd: number;
|
|
317
|
-
total: number;
|
|
318
|
-
damage: number;
|
|
319
|
-
stagger?: number;
|
|
320
|
-
sweep?: number;
|
|
321
|
-
reach?: number;
|
|
322
|
-
})[];
|
|
323
|
-
heavy: {
|
|
324
|
-
windup: number;
|
|
325
|
-
slashEnd: number;
|
|
326
|
-
total: number;
|
|
327
|
-
damage: number;
|
|
328
|
-
stagger?: number;
|
|
329
|
-
sweep?: number;
|
|
330
|
-
reach?: number;
|
|
331
|
-
};
|
|
332
|
-
passes?: {
|
|
333
|
-
left: {
|
|
334
|
-
windup: number;
|
|
335
|
-
slashEnd: number;
|
|
336
|
-
total: number;
|
|
337
|
-
damage: number;
|
|
338
|
-
stagger?: number;
|
|
339
|
-
sweep?: number;
|
|
340
|
-
reach?: number;
|
|
341
|
-
};
|
|
342
|
-
right: {
|
|
343
|
-
windup: number;
|
|
344
|
-
slashEnd: number;
|
|
345
|
-
total: number;
|
|
346
|
-
damage: number;
|
|
347
|
-
stagger?: number;
|
|
348
|
-
sweep?: number;
|
|
349
|
-
reach?: number;
|
|
350
|
-
};
|
|
351
|
-
};
|
|
352
|
-
};
|
|
316
|
+
moves: { combo: MeleeSwingRows[]; heavy: MeleeSwingRows; passes?: {left: MeleeSwingRows; right: MeleeSwingRows}; };
|
|
353
317
|
mounted?: {
|
|
354
318
|
reach: number;
|
|
355
319
|
cooldown: number;
|