@wildshard/shard-format 0.37.1 → 0.38.1
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 +4 -1
- package/src/format/creature-attackable.ts +126 -0
- package/src/format/creature-layers.ts +8 -0
- package/src/format/creature-patrols.ts +151 -0
- package/src/format/creatures.ts +8 -5
- package/src/format/encounters.ts +24 -2
- package/src/format/groupBrains.ts +4 -0
- package/src/format/memory-armed.json +217 -0
- package/src/format/memory-armed.ts +64 -0
- package/src/format/memory-epoch.ts +4 -4
- package/src/format/memory-line.ts +19 -11
- package/src/format/memory-ratchet.ts +19 -20
- package/src/format/primitive-table.ts +224 -0
- package/src/format/primitives.ts +53 -180
- package/src/format/rows.ts +3 -2
- package/src/format/shardfile-assets.ts +1 -1
- package/src/format/skin-file.ts +1 -0
- package/src/format/skin-variants.ts +47 -1
- package/src/format/skinAssets.ts +11 -4
- package/src/format/skins.ts +4 -2
package/src/format/primitives.ts
CHANGED
|
@@ -1,31 +1,21 @@
|
|
|
1
|
+
import { PRIMITIVES } from './primitive-table.ts'
|
|
1
2
|
import { ACCEPTED_SECTION_VERSIONS, FIRST_VERSION } from './section-versions.ts'
|
|
2
3
|
|
|
4
|
+
import type { Primitive, PrimitiveSwitch } from './primitive-table.ts'
|
|
5
|
+
|
|
3
6
|
/**
|
|
4
7
|
* ONE-FORMAT OF17a (J365 (6), J367 (5), Q-T22 option (b), Q-T27 (a)): no host list ships. A section switches a primitive
|
|
5
8
|
* on, and the server works out the list from the product's sections. The families and their hosts are the verdict
|
|
6
|
-
* table, meta `docs/plans/one-format/HOSTS.md` (OF16a),
|
|
9
|
+
* table, meta `docs/plans/one-format/HOSTS.md` (OF16a), approved by Jake (OF16b, J420).
|
|
7
10
|
*
|
|
8
|
-
* `on` says what turns a family on: `always` (every product has it),
|
|
9
|
-
* object, or `later` while its row (`row`) has not given it a section
|
|
10
|
-
*
|
|
11
|
+
* `on` says what turns a family on: `always` (every product has it), one or more section paths whose value is a non-empty
|
|
12
|
+
* array or object (the first that matches names the section), or `later` while its row (`row`) has not given it a section
|
|
13
|
+
* yet. OF17d: a family a shard already declares in an existing section switches on from it. A family's version is its
|
|
14
|
+
* section's `@N` (`ACCEPTED_SECTION_VERSIONS`): changes are additive, and a removal follows SHARD-COMPAT's rollout.
|
|
11
15
|
*/
|
|
12
16
|
/** An empty array or object switches nothing on. */
|
|
13
17
|
const NONE = 0
|
|
14
18
|
|
|
15
|
-
interface PrimitiveSwitch {
|
|
16
|
-
readonly section: string
|
|
17
|
-
readonly path: readonly string[]
|
|
18
|
-
/** When set, the family is on only if some row of the list at `path` has this key. */
|
|
19
|
-
readonly having?: string
|
|
20
|
-
}
|
|
21
|
-
interface Primitive {
|
|
22
|
-
readonly name: string
|
|
23
|
-
/** The ONE-FORMAT row that builds it. */
|
|
24
|
-
readonly row: string
|
|
25
|
-
/** The server hosts and page features it replaces (HOSTS.md). A host split across two families sits in the first. */
|
|
26
|
-
readonly hosts: readonly string[]
|
|
27
|
-
readonly on: PrimitiveSwitch | 'always' | 'later'
|
|
28
|
-
}
|
|
29
19
|
/** One family the server switched on, at the version of the section that switched it; no `section` for `always`. */
|
|
30
20
|
interface DerivedPrimitive {
|
|
31
21
|
readonly name: string
|
|
@@ -33,156 +23,6 @@ interface DerivedPrimitive {
|
|
|
33
23
|
readonly version: number
|
|
34
24
|
}
|
|
35
25
|
|
|
36
|
-
const TABLE: readonly Primitive[] = [
|
|
37
|
-
{
|
|
38
|
-
name: 'collision',
|
|
39
|
-
row: 'OF41',
|
|
40
|
-
on: 'always',
|
|
41
|
-
hosts: ['collision', 'collision.pieces'],
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
name: 'plumbing',
|
|
45
|
-
row: 'OF18',
|
|
46
|
-
on: 'always',
|
|
47
|
-
hosts: [
|
|
48
|
-
'commands',
|
|
49
|
-
'decisions',
|
|
50
|
-
'engine.creatures.update',
|
|
51
|
-
'strings.register',
|
|
52
|
-
'content.catalogue',
|
|
53
|
-
'debug.expose',
|
|
54
|
-
'audio.cues',
|
|
55
|
-
'audio.scene',
|
|
56
|
-
'player.enter',
|
|
57
|
-
'bag.finds',
|
|
58
|
-
'state.adventure',
|
|
59
|
-
],
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
name: 'population',
|
|
63
|
-
row: 'OF29',
|
|
64
|
-
on: 'later',
|
|
65
|
-
hosts: [
|
|
66
|
-
'population.roster',
|
|
67
|
-
'population.spawn-script',
|
|
68
|
-
'population.shelter',
|
|
69
|
-
'population.environment',
|
|
70
|
-
'population.mixed',
|
|
71
|
-
'population.poses',
|
|
72
|
-
'population.reactions',
|
|
73
|
-
'population.settle',
|
|
74
|
-
'population.homes',
|
|
75
|
-
'population.wildlife',
|
|
76
|
-
],
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
name: 'elites',
|
|
80
|
-
row: 'OF33',
|
|
81
|
-
on: 'later',
|
|
82
|
-
hosts: [
|
|
83
|
-
'population.elites',
|
|
84
|
-
'population.elites-ready',
|
|
85
|
-
'riding.elites',
|
|
86
|
-
'riding.elites-ready',
|
|
87
|
-
'elite.entry',
|
|
88
|
-
'elite.construct',
|
|
89
|
-
],
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
name: 'boss',
|
|
93
|
-
row: 'OF34',
|
|
94
|
-
on: 'later',
|
|
95
|
-
hosts: ['boss.ground', 'boss.spawned', 'boss.held'],
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
name: 'boss.arena',
|
|
99
|
-
row: 'OF34',
|
|
100
|
-
on: 'later',
|
|
101
|
-
hosts: ['boss.arena', 'boss.open-arena'],
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
name: 'riding',
|
|
105
|
-
row: 'CC40',
|
|
106
|
-
on: {
|
|
107
|
-
section: 'actors/species',
|
|
108
|
-
path: ['rows', 'species'],
|
|
109
|
-
having: 'mount',
|
|
110
|
-
},
|
|
111
|
-
hosts: [
|
|
112
|
-
'riding.mounted',
|
|
113
|
-
'riding.roster',
|
|
114
|
-
'riding.groups',
|
|
115
|
-
'riding.hunt',
|
|
116
|
-
'riding.trample',
|
|
117
|
-
'riding.environment',
|
|
118
|
-
'riding.taming',
|
|
119
|
-
'riding.session',
|
|
120
|
-
'taming.entry',
|
|
121
|
-
],
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
name: 'patrol',
|
|
125
|
-
row: 'OF37',
|
|
126
|
-
on: 'later',
|
|
127
|
-
hosts: ['encounter.patrol', 'timed.encounters'],
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
name: 'held.melee',
|
|
131
|
-
row: 'OF38',
|
|
132
|
-
on: 'later',
|
|
133
|
-
hosts: [
|
|
134
|
-
'item.swept',
|
|
135
|
-
'held.melee',
|
|
136
|
-
'held.arms',
|
|
137
|
-
'held.claims',
|
|
138
|
-
'held.cosmetics',
|
|
139
|
-
],
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
name: 'held.ranged',
|
|
143
|
-
row: 'OF38',
|
|
144
|
-
on: 'later',
|
|
145
|
-
hosts: [
|
|
146
|
-
'item.ranged',
|
|
147
|
-
'combat.motion',
|
|
148
|
-
'ammunition',
|
|
149
|
-
'loadout',
|
|
150
|
-
'held.ranged-feel',
|
|
151
|
-
'held.ranged-page',
|
|
152
|
-
'combat.targets',
|
|
153
|
-
],
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
name: 'sky',
|
|
157
|
-
row: 'OF41',
|
|
158
|
-
on: { section: 'world/days', path: ['rows', 'days'] },
|
|
159
|
-
hosts: ['day.toon', 'day.keyed-sky', 'day.declared'],
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
name: 'weather',
|
|
163
|
-
row: 'OF41',
|
|
164
|
-
on: { section: 'world/weather', path: ['rows', 'weather'] },
|
|
165
|
-
hosts: [
|
|
166
|
-
'weather.program',
|
|
167
|
-
'weather.native',
|
|
168
|
-
'weather.forest',
|
|
169
|
-
'weather.fields',
|
|
170
|
-
],
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
name: 'water.sea',
|
|
174
|
-
row: 'OF40',
|
|
175
|
-
on: 'later',
|
|
176
|
-
hosts: ['water.sea', 'world.water'],
|
|
177
|
-
},
|
|
178
|
-
{ name: 'water.field', row: 'OF40', on: 'later', hosts: ['water.field'] },
|
|
179
|
-
{ name: 'grapple', row: 'OF41', on: 'later', hosts: ['grapple'] },
|
|
180
|
-
{ name: 'portal', row: 'OF41', on: 'later', hosts: ['portal.ride'] },
|
|
181
|
-
]
|
|
182
|
-
const PRIMITIVES: readonly Primitive[] = Object.freeze(
|
|
183
|
-
TABLE.map((row): Primitive => Object.freeze(row)),
|
|
184
|
-
)
|
|
185
|
-
|
|
186
26
|
/** Hosts HOSTS.md leaves out of the primitives: quest (Q-S5), opened as it is; Nalati's stealth entry (Q-S4). */
|
|
187
27
|
const OUT_OF_SCOPE_HOSTS: readonly string[] = Object.freeze([
|
|
188
28
|
'quest.body-scripts',
|
|
@@ -224,18 +64,49 @@ function filled(value: unknown): boolean {
|
|
|
224
64
|
Object.keys(value).length > NONE
|
|
225
65
|
)
|
|
226
66
|
}
|
|
227
|
-
|
|
67
|
+
/** A row's key, or a nested one by a dotted key (`arena.bounds`). */
|
|
68
|
+
function field(row: object, key: string): { has: boolean; value?: unknown } {
|
|
69
|
+
const keys = key.split('.')
|
|
70
|
+
const last = keys.pop() ?? key
|
|
71
|
+
const holder = at(row, keys)
|
|
72
|
+
if (typeof holder !== 'object' || holder === null) {
|
|
73
|
+
return { has: false }
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
has: Object.hasOwn(holder, last),
|
|
77
|
+
value: Object.getOwnPropertyDescriptor(holder, last)?.value,
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function rowCounts(row: unknown, rule: PrimitiveSwitch): boolean {
|
|
81
|
+
if (typeof row !== 'object' || row === null) {
|
|
82
|
+
return false
|
|
83
|
+
}
|
|
84
|
+
const { having, equals, lacking } = rule
|
|
85
|
+
if (lacking !== undefined && Object.hasOwn(row, lacking)) {
|
|
86
|
+
return false
|
|
87
|
+
}
|
|
228
88
|
if (having === undefined) {
|
|
89
|
+
return true
|
|
90
|
+
}
|
|
91
|
+
const found = field(row, having)
|
|
92
|
+
return found.has && (equals === undefined || found.value === equals)
|
|
93
|
+
}
|
|
94
|
+
function switchedOn(value: unknown, rule: PrimitiveSwitch): boolean {
|
|
95
|
+
if (rule.having === undefined && rule.lacking === undefined) {
|
|
229
96
|
return filled(value)
|
|
230
97
|
}
|
|
231
98
|
return (
|
|
232
99
|
Array.isArray(value) &&
|
|
233
|
-
value.some(
|
|
234
|
-
(row: unknown): boolean =>
|
|
235
|
-
typeof row === 'object' && row !== null && Object.hasOwn(row, having),
|
|
236
|
-
)
|
|
100
|
+
value.some((row: unknown): boolean => rowCounts(row, rule))
|
|
237
101
|
)
|
|
238
102
|
}
|
|
103
|
+
/** A family's switches, as a list. */
|
|
104
|
+
function switchesOf(on: Primitive['on']): readonly PrimitiveSwitch[] {
|
|
105
|
+
if (on === 'always' || on === 'later') {
|
|
106
|
+
return []
|
|
107
|
+
}
|
|
108
|
+
return 'section' in on ? [on] : on
|
|
109
|
+
}
|
|
239
110
|
function newest(section: string): number {
|
|
240
111
|
return Math.max(...(ACCEPTED_SECTION_VERSIONS[section] ?? [FIRST_VERSION]))
|
|
241
112
|
}
|
|
@@ -253,13 +124,13 @@ function derivePrimitives(
|
|
|
253
124
|
if (row.on === 'always') {
|
|
254
125
|
return [{ name: row.name, version: FIRST_VERSION }]
|
|
255
126
|
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
) {
|
|
127
|
+
const hit = switchesOf(row.on).find((rule: PrimitiveSwitch): boolean =>
|
|
128
|
+
switchedOn(at(sections.get(rule.section), rule.path), rule),
|
|
129
|
+
)
|
|
130
|
+
if (hit === undefined) {
|
|
260
131
|
return []
|
|
261
132
|
}
|
|
262
|
-
const { section } =
|
|
133
|
+
const { section } = hit
|
|
263
134
|
return [
|
|
264
135
|
{
|
|
265
136
|
name: row.name,
|
|
@@ -270,5 +141,7 @@ function derivePrimitives(
|
|
|
270
141
|
})
|
|
271
142
|
}
|
|
272
143
|
|
|
273
|
-
export type { DerivedPrimitive
|
|
274
|
-
export {
|
|
144
|
+
export type { DerivedPrimitive }
|
|
145
|
+
export type { Primitive, PrimitiveSwitch } from './primitive-table.ts'
|
|
146
|
+
export { PRIMITIVES } from './primitive-table.ts'
|
|
147
|
+
export { OUT_OF_SCOPE_HOSTS, derivePrimitives, primitiveOfHost, switchesOf }
|
package/src/format/rows.ts
CHANGED
|
@@ -7,7 +7,7 @@ import * as v from 'valibot';
|
|
|
7
7
|
import { isJsonData } from './json.ts';
|
|
8
8
|
import { sketchReference } from './sketch.ts';
|
|
9
9
|
import { JournalRowSchema, journalRowRules } from './compendiumRows.ts';
|
|
10
|
-
import { CreatureMountSchema, creatureMountRules, CreatureTypeSchema, CreatureBodySchema, CreatureTemperamentSchema, CreatureSensesSchema, CreatureAbilitySchema, CreaturePresentationSchema } from './creature-layers.ts';
|
|
10
|
+
import { CreatureAttackableSchema, CreatureMountSchema, creatureMountRules, CreatureTypeSchema, CreatureBodySchema, CreatureTemperamentSchema, CreatureSensesSchema, CreatureAbilitySchema, CreaturePresentationSchema } from './creature-layers.ts';
|
|
11
11
|
import type { CreatureAbilityInput, CreatureLayers } from './creature-layers.ts';
|
|
12
12
|
import { creatureSizeRules } from './creature-sizes.ts';
|
|
13
13
|
import { SKIN_CLIPS_RECIPE, SkinClipMapSchema } from './skins.ts';
|
|
@@ -52,7 +52,8 @@ const species = v.strictObject({ id, kind: id, label: text, capExempt: v.exactOp
|
|
|
52
52
|
variants: v.pipe(v.array(variant), v.minLength(1), v.maxLength(64)),
|
|
53
53
|
type: v.exactOptional(CreatureTypeSchema), body: v.exactOptional(CreatureBodySchema),
|
|
54
54
|
temperament: v.exactOptional(CreatureTemperamentSchema), senses: v.exactOptional(CreatureSensesSchema),
|
|
55
|
-
abilities: v.exactOptional(abilities), presentation: v.exactOptional(CreaturePresentationSchema), mount: v.exactOptional(CreatureMountSchema)
|
|
55
|
+
abilities: v.exactOptional(abilities), presentation: v.exactOptional(CreaturePresentationSchema), mount: v.exactOptional(CreatureMountSchema),
|
|
56
|
+
attackable: v.exactOptional(CreatureAttackableSchema) });
|
|
56
57
|
const parameter = v.union([finite, v.boolean(), text, v.pipe(v.array(finite), v.maxLength(16))]);
|
|
57
58
|
const animationParameters = v.record(id, parameter);
|
|
58
59
|
const lookAnimation = v.strictObject({
|
|
@@ -376,6 +376,6 @@ export function performanceReportLines(report: PerformanceReport): string[] {
|
|
|
376
376
|
|
|
377
377
|
/** Offline soft-cap policy and the fixed J408 line for playing and loading. */
|
|
378
378
|
export function offlineMemoryAdmission(policy: 'warn' | 'refuse'): MemoryAdmission {
|
|
379
|
-
//
|
|
379
|
+
// J424 / J426: the J408 line refuses only an armed zone (`memory-armed.ts`); every other zone reports.
|
|
380
380
|
return new MemoryAdmission(() => policy === 'warn' || MEMORY_GATES.reportOnly, (owner, kind): number => ratchetLimit(owner, kind, MEMORY_HARD_BYTES));
|
|
381
381
|
}
|
package/src/format/skin-file.ts
CHANGED
|
@@ -20,6 +20,8 @@ interface ResolvedSkinFile {
|
|
|
20
20
|
interface SkinLookFiles {
|
|
21
21
|
readonly skin: ResolvedSkinFile
|
|
22
22
|
readonly variants?: ReadonlyMap<string, ResolvedSkinFile>
|
|
23
|
+
/** The phone tier's lighter mesh (ONE-FORMAT CC51b): the same contract as `skin`, at most its triangles. */
|
|
24
|
+
readonly phone?: ResolvedSkinFile
|
|
23
25
|
}
|
|
24
26
|
type Source = Pick<Shardfile, 'rows' | 'files'>
|
|
25
27
|
type Look = ShardRows['looks'][number]
|
|
@@ -166,6 +168,33 @@ function resolveVariants(
|
|
|
166
168
|
return variants
|
|
167
169
|
}
|
|
168
170
|
|
|
171
|
+
function phoneLook(
|
|
172
|
+
skin: ResolvedSkinFile,
|
|
173
|
+
{
|
|
174
|
+
phone: hash,
|
|
175
|
+
look,
|
|
176
|
+
read,
|
|
177
|
+
variants,
|
|
178
|
+
}: {
|
|
179
|
+
phone: string
|
|
180
|
+
look: Look
|
|
181
|
+
read: (hash: string) => ResolvedSkinFile
|
|
182
|
+
variants: string | undefined
|
|
183
|
+
},
|
|
184
|
+
): SkinLookFiles {
|
|
185
|
+
if (variants !== undefined) {
|
|
186
|
+
throw new Error(`skin look ${look.id}: a variant look has no phone skin`)
|
|
187
|
+
}
|
|
188
|
+
const phone = read(hash)
|
|
189
|
+
if (skinContract(phone) !== skinContract(skin)) {
|
|
190
|
+
throw new Error(`skin look ${look.id}: phone skin rig or material differs`)
|
|
191
|
+
}
|
|
192
|
+
if (phone.row.cost.triangles > skin.row.cost.triangles) {
|
|
193
|
+
throw new Error(`skin look ${look.id}: phone skin draws more triangles`)
|
|
194
|
+
}
|
|
195
|
+
return { skin, phone }
|
|
196
|
+
}
|
|
197
|
+
|
|
169
198
|
/** Resolve exact variant coverage and compatible rig/material declarations once at admission/load. */
|
|
170
199
|
function resolveSkinLookFiles(
|
|
171
200
|
source: Source,
|
|
@@ -175,6 +204,14 @@ function resolveSkinLookFiles(
|
|
|
175
204
|
const parameters = skinLookParameters(look)
|
|
176
205
|
const read = skinReader(source, assets)
|
|
177
206
|
const skin = read(parameters.skin)
|
|
207
|
+
if (parameters.phone !== undefined) {
|
|
208
|
+
return phoneLook(skin, {
|
|
209
|
+
phone: parameters.phone,
|
|
210
|
+
look,
|
|
211
|
+
read,
|
|
212
|
+
variants: parameters.variants,
|
|
213
|
+
})
|
|
214
|
+
}
|
|
178
215
|
if (parameters.variants === undefined) {
|
|
179
216
|
return { skin }
|
|
180
217
|
}
|
|
@@ -186,5 +223,14 @@ function resolveSkinLookFiles(
|
|
|
186
223
|
return { skin, variants }
|
|
187
224
|
}
|
|
188
225
|
|
|
189
|
-
|
|
226
|
+
/** Every skin file a look draws: its skin, each variant's and the phone tier's. */
|
|
227
|
+
function lookSkins(resolved: SkinLookFiles): ResolvedSkinFile[] {
|
|
228
|
+
return [
|
|
229
|
+
resolved.skin,
|
|
230
|
+
...(resolved.variants?.values() ?? []),
|
|
231
|
+
...(resolved.phone === undefined ? [] : [resolved.phone]),
|
|
232
|
+
]
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export { lookSkins, resolveSkinLookFiles }
|
|
190
236
|
export type { ResolvedSkinFile, SkinLookFiles }
|
package/src/format/skinAssets.ts
CHANGED
|
@@ -21,18 +21,25 @@ import { SkinGlbMaterialsSchema, SkinPrimitiveSchema, skinMaterialsFault, skinPa
|
|
|
21
21
|
|
|
22
22
|
import { SKIN_LOOK_RECIPE, SKIN_CLIPS_RECIPE } from './skins.ts';
|
|
23
23
|
import type { SkinLookParameters } from './skins.ts';
|
|
24
|
-
import { resolveSkinLookFiles } from './skin-variants.ts';
|
|
24
|
+
import { lookSkins, resolveSkinLookFiles } from './skin-variants.ts';
|
|
25
25
|
import { skinLookParameters } from './skin-file.ts';
|
|
26
26
|
|
|
27
|
+
/** An optional look reference names a library `json` file. */
|
|
28
|
+
function libraryJson(library: readonly string[], kinds: ReadonlyMap<string, string>, hash: string | undefined): boolean {
|
|
29
|
+
return hash === undefined || kinds.get(hash) === 'json' && library.includes(hash);
|
|
30
|
+
}
|
|
31
|
+
|
|
27
32
|
/** Shardfile reference rules for skin looks: a library `json` file whose dependencies are exactly its row's `glb`. */
|
|
28
33
|
function skinLookRules(source: Pick<Shardfile, 'rows' | 'files' | 'library'>): string[] {
|
|
29
34
|
const errors: string[] = [], files = new Map(source.files.map((file) => [file.hash, file]));
|
|
35
|
+
const kinds = new Map<string, string>(); for (const file of source.files) {kinds.set(file.hash, file.kind);}
|
|
30
36
|
for (const row of source.rows.looks) {
|
|
31
37
|
if (row.recipe !== SKIN_LOOK_RECIPE) { if (row.animation.recipe === SKIN_CLIPS_RECIPE) {errors.push('skin clips without a skin look');} continue; }
|
|
32
38
|
let parameters: SkinLookParameters; try { parameters = skinLookParameters(row); } catch { errors.push('skin look parameters'); continue; }
|
|
33
|
-
const { skin, variants } = parameters, file = files.get(skin), glb = file?.dependencies.length === 1 ? files.get(file.dependencies[0] ?? '') : undefined;
|
|
39
|
+
const { skin, variants, phone } = parameters, file = files.get(skin), glb = file?.dependencies.length === 1 ? files.get(file.dependencies[0] ?? '') : undefined;
|
|
34
40
|
if (file?.kind !== 'json' || glb?.kind !== 'glb' || !source.library.includes(skin)) {errors.push('skin look file references');}
|
|
35
|
-
if (
|
|
41
|
+
if (!libraryJson(source.library, kinds, variants)) {errors.push('skin variant table references');}
|
|
42
|
+
if (!libraryJson(source.library, kinds, phone)) {errors.push('skin phone file references');}
|
|
36
43
|
}
|
|
37
44
|
return errors;
|
|
38
45
|
}
|
|
@@ -76,7 +83,7 @@ function validateSkinAssets(source: Pick<Shardfile, 'rows' | 'files'> & { readon
|
|
|
76
83
|
for (const look of source.rows.looks) {
|
|
77
84
|
if (look.recipe !== SKIN_LOOK_RECIPE) {continue;}
|
|
78
85
|
const resolved = resolveSkinLookFiles(source, look, assets);
|
|
79
|
-
const skins = new Map(
|
|
86
|
+
const skins = new Map(lookSkins(resolved).map((skin): [string, typeof resolved.skin] => [skin.hash, skin]));
|
|
80
87
|
for (const { row, binding } of skins.values()) {
|
|
81
88
|
|
|
82
89
|
validateCreatureBones(look.species, row.rig.sockets);
|
package/src/format/skins.ts
CHANGED
|
@@ -8,7 +8,7 @@ const SKIN_LOOK_RECIPE = 'platform.skin';
|
|
|
8
8
|
const SKIN_CLIPS_RECIPE = 'platform.clips';
|
|
9
9
|
const hash = v.pipe(v.string(), v.regex(/^[0-9a-f]{64}$/u));
|
|
10
10
|
/** The look row's parameters. */
|
|
11
|
-
const SkinLookParametersSchema: v.GenericSchema<SkinLookParametersRowsInput, SkinLookParametersRows> = v.strictObject({ skin: hash, variants: v.exactOptional(hash) });
|
|
11
|
+
const SkinLookParametersSchema: v.GenericSchema<SkinLookParametersRowsInput, SkinLookParametersRows> = v.strictObject({ skin: hash, variants: v.exactOptional(hash), phone: v.exactOptional(hash) });
|
|
12
12
|
/** Complete variant-to-skin declarations in one ordinary content-addressed JSON file. */
|
|
13
13
|
const VARIANTS_VERSION = 1;
|
|
14
14
|
const MIN_VARIANTS = 1;
|
|
@@ -43,13 +43,15 @@ const SkinClipParametersSchema: v.GenericSchema<SkinClipParametersRowsInput, Ski
|
|
|
43
43
|
const ShardSkinFileSchema: v.GenericSchema<ShardSkinFileRowsInput, ShardSkinFileRows> = v.strictObject({ row: v.unknown(), binding: v.unknown() });
|
|
44
44
|
|
|
45
45
|
/** A parsed skin look: the file it names and the attack span its clip was sampled with. */
|
|
46
|
-
|
|
46
|
+
/** `phone` (ONE-FORMAT CC51b) names a lighter skin file the phone tier draws instead: same rig, clips, sockets and material. */
|
|
47
|
+
interface SkinLookParameters { skin: string; variants?: string; phone?: string; attackSpan: number; clipMap?: SkinClipMap }
|
|
47
48
|
|
|
48
49
|
/** Admitted data contracts, independent of validator implementation metadata. */
|
|
49
50
|
type SkinLookParametersRowsInput = SkinLookParametersRows;
|
|
50
51
|
interface SkinLookParametersRowsFields {
|
|
51
52
|
skin: string;
|
|
52
53
|
variants?: string;
|
|
54
|
+
phone?: string;
|
|
53
55
|
}
|
|
54
56
|
type SkinLookParametersRows = { [Key in keyof SkinLookParametersRowsFields]: SkinLookParametersRowsFields[Key] };
|
|
55
57
|
interface SkinClipParametersRowsInputFields {
|