From 2d8baccaf60c6407428fca8ba17dfa607d392ed3 Mon Sep 17 00:00:00 2001 From: Scott Anderson <662325+scottanderson@users.noreply.github.com> Date: Wed, 18 Sep 2024 15:28:36 -0400 Subject: [PATCH] sort-keys --- .eslintrc.json | 1 + ts/Grade.ts | 2 +- ts/HasLocationRotation.ts | 4 +- ts/RailroadMap.ts | 38 +- ts/SplineTrackType.ts | 16 +- ts/Studio.ts | 17 +- ts/StudioEditor.ts | 2 + ts/frames.ts | 833 +++++++++++++++++++------------------- ts/importer.ts | 14 +- ts/industries.ts | 434 ++++++++++---------- ts/parser.ts | 29 +- ts/splines.ts | 2 +- ts/tool-circularize.ts | 4 +- ts/tool-parallel.ts | 6 +- ts/util-catmullrom.ts | 4 +- ts/util.ts | 16 +- 16 files changed, 712 insertions(+), 710 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index a867627..dbcb88b 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -61,6 +61,7 @@ "no-undef": "error", "no-unused-vars": "off", // @typescript-eslint/no-unused-vars "require-jsdoc": "off", + "sort-keys": ["error", "asc", {"caseSensitive": false, "natural": false, "minKeys": 2}], "space-infix-ops": "off" } } diff --git a/ts/Grade.ts b/ts/Grade.ts index 29b2430..55eccf6 100644 --- a/ts/Grade.ts +++ b/ts/Grade.ts @@ -37,7 +37,7 @@ export function calculateGrade(controlPoints: Vector[]): Grade[] { const dz = controlPoints[i + 1].z - cp.z; const length = Math.sqrt((dx * dx) + (dy * dy)); const grade = Math.abs(dz) / length; - return {length, height: dz, grade}; + return {grade, height: dz, length}; }); } diff --git a/ts/HasLocationRotation.ts b/ts/HasLocationRotation.ts index 2163058..a00d4c9 100644 --- a/ts/HasLocationRotation.ts +++ b/ts/HasLocationRotation.ts @@ -11,9 +11,9 @@ export interface HasLocationRotation { export function localToWorld(transform: HasLocationRotation, curve: HermiteCurve): HermiteCurve { const {startPoint, endPoint, startTangent, endTangent} = curve; return { - startPoint: vectorSum(transform.location, rotateVector(startPoint, transform.rotation)), endPoint: vectorSum(transform.location, rotateVector(endPoint, transform.rotation)), - startTangent: rotateVector(startTangent, transform.rotation), endTangent: rotateVector(endTangent, transform.rotation), + startPoint: vectorSum(transform.location, rotateVector(startPoint, transform.rotation)), + startTangent: rotateVector(startTangent, transform.rotation), }; } diff --git a/ts/RailroadMap.ts b/ts/RailroadMap.ts index 2103b62..9db9c5f 100644 --- a/ts/RailroadMap.ts +++ b/ts/RailroadMap.ts @@ -274,7 +274,7 @@ export class RailroadMap { const pitch = radiansToDegrees(Math.atan2(direction.z, Math.sqrt(direction.x * direction.x + direction.y * direction.y))); const location = vectorSum({x: 0, y: 0, z: 100}, point); - const rotation = {yaw, pitch, roll: 0}; + const rotation = {pitch, roll: 0, yaw}; return {location, rotation}; } @@ -631,26 +631,26 @@ export class RailroadMap { const vertical = unknownProperty(ml, 'vertical'); const defaultNumber = (option: unknown, n: number) => typeof option === 'undefined' ? n : Number(option); return { - pan: { - x: defaultNumber(x, 0), - y: defaultNumber(y, 0), - }, - zoom: defaultNumber(zoom, 1), mergeLimits: { bearing: defaultNumber(bearing, 10), - inclination: defaultNumber(inclination, 2.5), horizontal: defaultNumber(horizontal, 10), + inclination: defaultNumber(inclination, 2.5), vertical: defaultNumber(vertical, 1), }, + pan: { + x: defaultNumber(x, 0), + y: defaultNumber(y, 0), + }, + zoom: defaultNumber(zoom, 1), }; } writeOptions() { const key = `railroadstudio.${this.railroad.saveGame.uniqueWorldId}`; const options: MapOptions = { + mergeLimits: this.mergeLimits, pan: this.panFrom(), zoom: this.panZoom.getZoom(), - mergeLimits: this.mergeLimits, }; localStorage.setItem(key, JSON.stringify(options)); } @@ -824,11 +824,14 @@ export class RailroadMap { let listeners: { [key: string]: (e: Event) => unknown }; return svgPanZoom(this.svg.node, { - zoomScaleSensitivity: 0.5, - minZoom: 0.5, - maxZoom: 500, beforePan: beforePan, customEventsHandler: { + destroy: () => { + // Unregister listeners + for (const eventName of Object.keys(listeners)) { + this.svg.node.removeEventListener(eventName, listeners[eventName]); + } + }, haltEventListeners: [], init: (options) => { let mouseDown = false; @@ -933,15 +936,12 @@ export class RailroadMap { options.svgElement.addEventListener(eventName, listeners[eventName]); } }, - destroy: () => { - // Unregister listeners - for (const eventName of Object.keys(listeners)) { - this.svg.node.removeEventListener(eventName, listeners[eventName]); - } - }, }, + maxZoom: 500, + minZoom: 0.5, onPan: onPanZoom, onZoom: onPanZoom, + zoomScaleSensitivity: 0.5, }); } @@ -1806,7 +1806,7 @@ export class RailroadMap { const bezier = hermiteToBezier(spline); const sharpest = cubicBezierMinRadius(bezier); const length = cubicBezierLength(bezier); - console.log({index, sharpest, spline, steepest, length}); + console.log({index, length, sharpest, spline, steepest}); } break; case MapToolMode.delete: @@ -1892,7 +1892,7 @@ export class RailroadMap { const {location, rotation} = this.rerailLocation(e, spline, this.toolFrame); const {name, number, type, state} = this.toolFrame; // Copy the frame to the new location - const frame: Frame = {location, name, number, rotation, type, state}; + const frame: Frame = {location, name, number, rotation, state, type}; this.railroad.frames.push(frame); this.setMapModified(true); // Update the map diff --git a/ts/SplineTrackType.ts b/ts/SplineTrackType.ts index 5d0365f..1bd254c 100644 --- a/ts/SplineTrackType.ts +++ b/ts/SplineTrackType.ts @@ -55,31 +55,31 @@ export enum SplineTrackType { } const secondLegSwitchLeft = { - startPoint: {x: 0, y: 0, z: 0}, - startTangent: {x: 1879.3, y: 0, z: 0}, endPoint: {x: 1879.3, y: 0, z: 0}, endTangent: {x: 1879.3, y: 0, z: 0}, + startPoint: {x: 0, y: 0, z: 0}, + startTangent: {x: 1879.3, y: 0, z: 0}, }; const secondLegSwitchRight = { - startPoint: {x: 0, y: 0, z: 0}, - startTangent: {x: 2153.67, y: 0, z: 0}, endPoint: {x: 1863.4, y: 184.8, z: 0}, endTangent: {x: 2125.36, y: 348.04, z: 0}, + startPoint: {x: 0, y: 0, z: 0}, + startTangent: {x: 2153.67, y: 0, z: 0}, }; const switchCross45 = { - startPoint: {x: 87.9, y: 212.1, z: 0}, - startTangent: {x: 424.2, y: -424.2, z: 0}, endPoint: {x: 512.1, y: -212.1, z: 0}, endTangent: {x: 424.2, y: -424.2, z: 0}, + startPoint: {x: 87.9, y: 212.1, z: 0}, + startTangent: {x: 424.2, y: -424.2, z: 0}, }; const switchCross90 = { - startPoint: {x: 191.2, y: -191.2, z: 0}, - startTangent: {x: 0, y: 382.4, z: 0}, endPoint: {x: 191.2, y: 191.2, z: 0}, endTangent: {x: 0, y: 382.4, z: 0}, + startPoint: {x: 191.2, y: -191.2, z: 0}, + startTangent: {x: 0, y: 382.4, z: 0}, }; export const switchExtraLegs: Partial> = { diff --git a/ts/Studio.ts b/ts/Studio.ts index 9ddfa77..8f42d5f 100644 --- a/ts/Studio.ts +++ b/ts/Studio.ts @@ -746,11 +746,11 @@ export class Studio { isFrameType(f.type) && (frameDefinitions[f.type][c] ?? false); const labels = { engine: `Engines (${railroad.frames.filter((f) => frameInCategory(f, 'engine')).length})`, - tender: `Tenders (${railroad.frames.filter((f) => frameInCategory(f, 'tender')).length})`, - handcar: `Handcars (${railroad.frames.filter((f) => frameInCategory(f, 'handcar')).length})`, freight: `Freight (${railroad.frames.filter((f) => frameInCategory(f, 'freight')).length})`, - passenger: `Passenger (${railroad.frames.filter((f) => frameInCategory(f, 'passenger')).length})`, + handcar: `Handcars (${railroad.frames.filter((f) => frameInCategory(f, 'handcar')).length})`, mow: `Maintenance (${railroad.frames.filter((f) => frameInCategory(f, 'mow')).length})`, + passenger: `Passenger (${railroad.frames.filter((f) => frameInCategory(f, 'passenger')).length})`, + tender: `Tenders (${railroad.frames.filter((f) => frameInCategory(f, 'tender')).length})`, }; const anyInCategory = (c: typeof frameCategories[number]): boolean => railroad.frames.some((f) => frameInCategory(f, c)); @@ -1020,8 +1020,8 @@ export class Studio { !spline.type.includes('switch') && !spline.type.includes('bumper')) .map((spline) => { - const {startPoint, startTangent, endPoint, endTangent} = spline; - return {startPoint, startTangent, endPoint, endTangent}; + const {endPoint, endTangent, startPoint, startTangent} = spline; + return {endPoint, endTangent, startPoint, startTangent}; }), ); // Calculate minimum radius @@ -1216,8 +1216,8 @@ export class Studio { tooltip = `Expected ${key} to in range [${minValue}, ${maxValue}]`; } const options: InputTextOptions = { - min: String(minValue), max: String(maxValue), + min: String(minValue), step: 'step' in meta && meta.step ? String(meta.step) : undefined, }; const displayValue = (value: number) => Number.isInteger(value) ? String(value) : value.toFixed(1); @@ -1290,7 +1290,7 @@ export class Studio { const limits: Partial> = cargoLimits[frame.type]; const limit = isCargoType(freightType) ? limits[freightType] ?? 0 : 0; const max = String(limit); - const options: InputTextOptions = {min: '0', max}; + const options: InputTextOptions = {max, min: '0'}; const form = editNumber(this, frame.state.freightAmount, options, setAmount); if (isCargoType(freightType) && typeof limits[freightType] !== 'undefined' && @@ -1577,7 +1577,8 @@ export class Studio { if (player.rotation) { td = document.createElement('td'); const setPlayerRotation = (r: number) => player.rotation = r; - td.replaceChildren(editNumber(this, player.rotation, {min: '-180', max: '180'}, setPlayerRotation)); + const options: InputTextOptions = {max: '180', min: '-180'}; + td.replaceChildren(editNumber(this, player.rotation, options, setPlayerRotation)); tr.appendChild(td); } // Permissions diff --git a/ts/StudioEditor.ts b/ts/StudioEditor.ts index 379f115..535d0f6 100644 --- a/ts/StudioEditor.ts +++ b/ts/StudioEditor.ts @@ -385,6 +385,7 @@ export function editQuaternion( saveValue: (value: Quaternion) => Quaternion, ) { const encode = (v: Quaternion): number[] => [v.x, v.y, v.z, v.w]; + // eslint-disable-next-line sort-keys const decode = (t: number[]): Quaternion => fp32q({x: t[0], y: t[1], z: t[2], w: t[3]}); const display = (t: number[]) => { const xZero = t[0] === 0; @@ -406,6 +407,7 @@ export function editRotator( saveValue: (value: Rotator) => Rotator, ) { const encode = (r: Rotator): number[] => [r.roll, r.yaw, r.pitch]; + // eslint-disable-next-line sort-keys const decode = (t: number[]): Rotator => fp32r({roll: t[0], yaw: t[1], pitch: t[2]}); const display = (t: number[]) => { if (t[0] === 0 && t[2] === 0) { diff --git a/ts/frames.ts b/ts/frames.ts index 9d01204..add59af 100644 --- a/ts/frames.ts +++ b/ts/frames.ts @@ -139,13 +139,6 @@ export const frameDefinitions: Record = { '622D': { engine: true, length: 760, - name: 'D&RGW Class 48', - min: { - headlightType: 1, - paintType: 1, - reverserValue: -1, - smokestackType: 1, - }, max: { boilerFireTemp: 400, boilerFuelAmount: 70, @@ -162,34 +155,34 @@ export const frameDefinitions: Record = { tenderFuelAmount: 144, tenderWaterAmount: 1600, }, - }, - - 'boxcar': { - freight: true, - length: 822.82, - name: 'Boxcar', min: { headlightType: 1, paintType: 1, + reverserValue: -1, smokestackType: 1, }, + name: 'D&RGW Class 48', + }, + + 'boxcar': { + freight: true, + length: 822.82, max: { brakeValue: 1, headlightType: 1, paintType: 7, smokestackType: 1, }, - }, - - 'caboose': { - length: 679, - name: 'Bobber Caboose', - passenger: true, min: { headlightType: 1, paintType: 1, smokestackType: 1, }, + name: 'Boxcar', + }, + + 'caboose': { + length: 679, max: { boilerFireTemp: 400, boilerFuelAmount: 50, @@ -207,18 +200,18 @@ export const frameDefinitions: Record = { smokestackType: 1, tenderFuelAmount: 15, }, - }, - - 'Class125': { - engine: true, - length: 1097, - name: 'D&RGW Class 125', min: { headlightType: 1, paintType: 1, - reverserValue: -1, smokestackType: 1, }, + name: 'Bobber Caboose', + passenger: true, + }, + + 'Class125': { + engine: true, + length: 1097, max: { boilerFireTemp: 400, boilerFuelAmount: 70, @@ -236,18 +229,18 @@ export const frameDefinitions: Record = { sanderAmount: 100, smokestackType: 7, }, - }, - - 'Class125_Tender': { - coal: true, - tender: true, - length: 720, - name: 'D&RGW Class 125 Tender', min: { headlightType: 1, paintType: 1, + reverserValue: -1, smokestackType: 1, }, + name: 'D&RGW Class 125', + }, + + 'Class125_Tender': { + coal: true, + length: 720, max: { brakeValue: 1, headlightType: 10, @@ -256,19 +249,19 @@ export const frameDefinitions: Record = { tenderFuelAmount: 7000, tenderWaterAmount: 9500, }, + min: { + headlightType: 1, + paintType: 1, + smokestackType: 1, + }, + name: 'D&RGW Class 125 Tender', + tender: true, }, 'Class47': { coal: true, engine: true, length: 932, - name: 'D&RG Class 47', - min: { - headlightType: 1, - paintType: 1, - reverserValue: -1, - smokestackType: 1, - }, max: { boilerFireTemp: 400, boilerFuelAmount: 70, @@ -285,18 +278,18 @@ export const frameDefinitions: Record = { sanderAmount: 100, smokestackType: 8, }, - }, - - 'Class47_Tender': { - coal: true, - length: 672, - name: 'D&RG Class 47 Tender', - tender: true, min: { headlightType: 1, paintType: 1, + reverserValue: -1, smokestackType: 1, }, + name: 'D&RG Class 47', + }, + + 'Class47_Tender': { + coal: true, + length: 672, max: { brakeValue: 1, headlightType: 8, @@ -305,18 +298,18 @@ export const frameDefinitions: Record = { tenderFuelAmount: 5000, tenderWaterAmount: 5000, }, - }, - - 'class70': { - engine: true, - name: 'D&RG Class 70', - length: 892, min: { headlightType: 1, paintType: 1, - reverserValue: -1, smokestackType: 1, }, + name: 'D&RG Class 47 Tender', + tender: true, + }, + + 'class70': { + engine: true, + length: 892, max: { boilerFireTemp: 400, boilerFuelAmount: 100, @@ -326,26 +319,26 @@ export const frameDefinitions: Record = { brakeValue: 1, compressorAirPressure: 100, compressorValveValue: 1, + headlightType: 3, markerLightsFrontLeftState: 3, markerLightsFrontRightState: 3, paintType: 3, regulatorValue: 1, reverserValue: 1, - headlightType: 3, sanderAmount: 100, smokestackType: 3, }, - }, - - 'class70_tender': { - length: 654, - name: 'Class 70 Tender', - tender: true, min: { headlightType: 1, paintType: 1, + reverserValue: -1, smokestackType: 1, }, + name: 'D&RG Class 70', + }, + + 'class70_tender': { + length: 654, max: { brakeValue: 1, headlightType: 1, @@ -356,18 +349,18 @@ export const frameDefinitions: Record = { tenderFuelAmount: 1350, tenderWaterAmount: 9500, }, - }, - - 'climax': { - engine: true, - length: 850, - name: 'Climax', min: { headlightType: 1, paintType: 1, - reverserValue: -1, smokestackType: 1, }, + name: 'Class 70 Tender', + tender: true, + }, + + 'climax': { + engine: true, + length: 850, max: { boilerFireTemp: 400, boilerFuelAmount: 80, @@ -378,50 +371,50 @@ export const frameDefinitions: Record = { compressorAirPressure: 100, compressorValveValue: 1, generatorValveValue: 1, + headlightType: 1, paintType: 1, regulatorValue: 1, reverserValue: 1, - headlightType: 1, sanderAmount: 100, smokestackType: 3, tenderFuelAmount: 332, tenderWaterAmount: 3000, }, - }, - - 'coach_dsprr_1': { - passenger: true, - length: 1420, - width: 300, - name: 'Coach DSP&P RR No. 57', min: { headlightType: 1, paintType: 1, + reverserValue: -1, smokestackType: 1, }, + name: 'Climax', + }, + + 'coach_dsprr_1': { + length: 1420, max: { brakeValue: 1, headlightType: 1, - paintType: 5, - smokestackType: 1, markerLightsCenterState: 3, markerLightsFrontLeftState: 3, markerLightsFrontRightState: 3, markerLightsRearLeftState: 3, markerLightsRearRightState: 3, + paintType: 5, + smokestackType: 1, }, - }, - - 'cooke260': { - engine: true, - length: 834, - name: 'Cooke Mogul Wood', min: { headlightType: 1, paintType: 1, - reverserValue: -1, smokestackType: 1, }, + name: 'Coach DSP&P RR No. 57', + passenger: true, + width: 300, + }, + + 'cooke260': { + engine: true, + length: 834, max: { boilerFireTemp: 400, boilerFuelAmount: 80, @@ -438,19 +431,19 @@ export const frameDefinitions: Record = { sanderAmount: 100, smokestackType: 3, }, - }, - - 'cooke260_new': { - coal: true, - engine: true, - length: 834, - name: 'Cooke Mogul Coal', min: { headlightType: 1, paintType: 1, reverserValue: -1, smokestackType: 1, }, + name: 'Cooke Mogul Wood', + }, + + 'cooke260_new': { + coal: true, + engine: true, + length: 834, max: { boilerFireTemp: 400, boilerFuelAmount: 80, @@ -468,18 +461,18 @@ export const frameDefinitions: Record = { sanderAmount: 100, smokestackType: 5, }, - }, - - 'cooke260_new_tender': { - coal: true, - length: 642, - name: 'Cooke Mogul Coal Tender', - tender: true, min: { headlightType: 1, paintType: 1, + reverserValue: -1, smokestackType: 1, }, + name: 'Cooke Mogul Coal', + }, + + 'cooke260_new_tender': { + coal: true, + length: 642, max: { brakeValue: 1, headlightType: 1, @@ -490,39 +483,39 @@ export const frameDefinitions: Record = { tenderFuelAmount: 6000, tenderWaterAmount: 9500, }, - }, - - 'cooke260_tender': { - length: 642, - name: 'Cooke Mogul Wood Tender', - tender: true, min: { headlightType: 1, paintType: 1, smokestackType: 1, }, + name: 'Cooke Mogul Coal Tender', + tender: true, + }, + + 'cooke260_tender': { + length: 642, max: { brakeValue: 1, headlightType: 1, markerLightsRearLeftState: 3, markerLightsRearRightState: 3, paintType: 1, + smokestackType: 1, tenderFuelAmount: 1460, tenderWaterAmount: 9500, + }, + min: { + headlightType: 1, + paintType: 1, smokestackType: 1, }, + name: 'Cooke Mogul Wood Tender', + tender: true, }, 'cooke280': { engine: true, - name: 'Cooke Consolidation', length: 870, - min: { - headlightType: 1, - paintType: 1, - reverserValue: -1, - smokestackType: 1, - }, max: { boilerFireTemp: 400, boilerFuelAmount: 70, @@ -541,17 +534,17 @@ export const frameDefinitions: Record = { sanderAmount: 100, smokestackType: 4, }, - }, - - 'cooke280_tender': { - tender: true, - name: 'Cooke Consolidation Tender', - length: 616, min: { headlightType: 1, paintType: 1, + reverserValue: -1, smokestackType: 1, }, + name: 'Cooke Consolidation', + }, + + 'cooke280_tender': { + length: 616, max: { brakeValue: 1, headlightType: 1, @@ -562,51 +555,52 @@ export const frameDefinitions: Record = { tenderFuelAmount: 1428, tenderWaterAmount: 9500, }, - }, - - 'DRGW_Gondola_33FT': { - length: 1030, - name: 'D&RGW 33FT Gondola', - freight: true, min: { headlightType: 1, paintType: 1, smokestackType: 1, }, + name: 'Cooke Consolidation Tender', + tender: true, + }, + + 'DRGW_Gondola_33FT': { + freight: true, + length: 1030, max: { brakeValue: 1, headlightType: 1, paintType: 4, smokestackType: 1, }, - }, - 'dspp_baggage': { - length: 1400, - name: 'DSP&P Baggage Car', - freight: true, min: { headlightType: 1, paintType: 1, smokestackType: 1, }, + name: 'D&RGW 33FT Gondola', + }, + + 'dspp_baggage': { + freight: true, + length: 1400, max: { brakeValue: 1, headlightType: 1, paintType: 2, smokestackType: 1, }, - }, - - 'eureka': { - engine: true, - length: 802.13, - name: 'Eureka', min: { headlightType: 1, paintType: 1, - reverserValue: -1, smokestackType: 1, }, + name: 'DSP&P Baggage Car', + }, + + 'eureka': { + engine: true, + length: 802.13, max: { boilerFireTemp: 400, boilerFuelAmount: 70, @@ -623,17 +617,17 @@ export const frameDefinitions: Record = { sanderAmount: 100, smokestackType: 1, }, - }, - - 'eureka_tender': { - length: 497, - name: 'Eureka Tender', - tender: true, min: { headlightType: 1, paintType: 1, + reverserValue: -1, smokestackType: 1, }, + name: 'Eureka', + }, + + 'eureka_tender': { + length: 497, max: { brakeValue: 1, headlightType: 1, @@ -644,19 +638,19 @@ export const frameDefinitions: Record = { tenderFuelAmount: 499, tenderWaterAmount: 3800, }, + min: { + headlightType: 1, + paintType: 1, + smokestackType: 1, + }, + name: 'Eureka Tender', + tender: true, }, 'Ferries242T': { coal: true, engine: true, length: 872, - name: 'Ferries & Cliff House 2-4-2T', - min: { - headlightType: 1, - paintType: 1, - reverserValue: -1, - smokestackType: 1, - }, max: { boilerFireTemp: 400, boilerFuelAmount: 70, @@ -674,103 +668,103 @@ export const frameDefinitions: Record = { smokestackType: 7, tenderFuelAmount: 1000, }, - }, - - 'flatcar_cordwood': { - freight: true, - length: 785.6, - name: 'Flatcar Tier 3', min: { headlightType: 1, paintType: 1, + reverserValue: -1, smokestackType: 1, }, + name: 'Ferries & Cliff House 2-4-2T', + }, + + 'flatcar_cordwood': { + freight: true, + length: 785.6, max: { brakeValue: 1, headlightType: 1, paintType: 7, smokestackType: 1, }, + min: { + headlightType: 1, + paintType: 1, + smokestackType: 1, + }, + name: 'Flatcar Tier 3', }, 'flatcar_hopper': { freight: true, length: 785.6, - name: 'Hopper', - min: { + max: { + brakeValue: 1, headlightType: 1, paintType: 1, smokestackType: 1, }, - max: { - brakeValue: 1, + min: { headlightType: 1, paintType: 1, smokestackType: 1, }, + name: 'Hopper', }, 'flatcar_logs': { freight: true, length: 818, - name: 'Flatcar Tier 1', - min: { - headlightType: 1, - paintType: 1, - smokestackType: 1, - }, max: { brakeValue: 1, headlightType: 1, paintType: 7, smokestackType: 1, }, - }, - - 'flatcar_stakes': { - freight: true, - length: 785.6, - name: 'Flatcar Tier 2', min: { headlightType: 1, paintType: 1, smokestackType: 1, }, + name: 'Flatcar Tier 1', + }, + + 'flatcar_stakes': { + freight: true, + length: 785.6, max: { brakeValue: 1, headlightType: 1, paintType: 7, smokestackType: 1, }, - }, - - 'flatcar_tanker': { - freight: true, - length: 804, - name: 'Tanker', min: { headlightType: 1, paintType: 1, smokestackType: 1, }, + name: 'Flatcar Tier 2', + }, + + 'flatcar_tanker': { + freight: true, + length: 804, max: { brakeValue: 1, headlightType: 1, paintType: 10, smokestackType: 1, }, - }, - - 'glenbrook': { - engine: true, - length: 837.83, - name: 'Glenbrook', min: { headlightType: 1, paintType: 1, - reverserValue: -1, smokestackType: 1, }, + name: 'Tanker', + }, + + 'glenbrook': { + engine: true, + length: 837.83, max: { boilerFireTemp: 400, boilerFuelAmount: 70, @@ -787,17 +781,17 @@ export const frameDefinitions: Record = { sanderAmount: 100, smokestackType: 5, }, - }, - - 'glenbrook_tender': { - length: 505, - name: 'Glenbrook Tender', - tender: true, min: { headlightType: 1, paintType: 1, + reverserValue: -1, smokestackType: 1, }, + name: 'Glenbrook', + }, + + 'glenbrook_tender': { + length: 505, max: { brakeValue: 1, headlightType: 1, @@ -806,18 +800,18 @@ export const frameDefinitions: Record = { tenderFuelAmount: 798, tenderWaterAmount: 3800, }, - }, - - 'handcar': { - handcar: true, - length: 235, - name: 'Handcar', min: { headlightType: 1, paintType: 1, - reverserValue: -1, smokestackType: 1, }, + name: 'Glenbrook Tender', + tender: true, + }, + + 'handcar': { + handcar: true, + length: 235, max: { boilerPressure: 120, boilerWaterLevel: 100, @@ -830,18 +824,18 @@ export const frameDefinitions: Record = { smokestackType: 1, tenderFuelAmount: 20, }, - }, - - 'heisler': { - engine: true, - length: 913.73, - name: 'Heisler', min: { headlightType: 1, paintType: 1, reverserValue: -1, smokestackType: 1, }, + name: 'Handcar', + }, + + 'heisler': { + engine: true, + length: 913.73, max: { boilerFireTemp: 400, boilerFuelAmount: 80, @@ -860,36 +854,36 @@ export const frameDefinitions: Record = { tenderFuelAmount: 454, tenderWaterAmount: 3000, }, - }, - - 'hopperBB': { - freight: true, - length: 760, - name: 'Carter Brothers Drop-Bottom Hopper', min: { headlightType: 1, paintType: 1, + reverserValue: -1, smokestackType: 1, }, + name: 'Heisler', + }, + + 'hopperBB': { + freight: true, + length: 760, max: { brakeValue: 1, headlightType: 1, paintType: 7, smokestackType: 1, }, + min: { + headlightType: 1, + paintType: 1, + smokestackType: 1, + }, + name: 'Carter Brothers Drop-Bottom Hopper', }, 'lima280': { coal: true, engine: true, length: 950, - name: 'Lima 2-8-0', - min: { - headlightType: 1, - paintType: 1, - reverserValue: -1, - smokestackType: 1, - }, max: { boilerFireTemp: 400, boilerFuelAmount: 70, @@ -904,18 +898,18 @@ export const frameDefinitions: Record = { sanderAmount: 100, smokestackType: 4, }, - }, - - 'lima280_tender': { - coal: true, - length: 620, - name: 'Lima 2-8-0 Tender', - tender: true, min: { headlightType: 1, paintType: 1, + reverserValue: -1, smokestackType: 1, }, + name: 'Lima 2-8-0', + }, + + 'lima280_tender': { + coal: true, + length: 620, max: { brakeValue: 1, headlightType: 1, @@ -924,18 +918,18 @@ export const frameDefinitions: Record = { tenderFuelAmount: 5400, tenderWaterAmount: 9000, }, - }, - - 'montezuma': { - engine: true, - length: 710, - name: 'Montezuma', min: { headlightType: 1, paintType: 1, - reverserValue: -1, smokestackType: 1, }, + name: 'Lima 2-8-0 Tender', + tender: true, + }, + + 'montezuma': { + engine: true, + length: 710, max: { boilerFireTemp: 400, boilerFuelAmount: 70, @@ -950,17 +944,17 @@ export const frameDefinitions: Record = { sanderAmount: 100, smokestackType: 3, }, - }, - - 'montezuma_tender': { - length: 420, - name: 'Montezuma Tender', - tender: true, min: { headlightType: 1, paintType: 1, + reverserValue: -1, smokestackType: 1, }, + name: 'Montezuma', + }, + + 'montezuma_tender': { + length: 420, max: { brakeValue: 1, headlightType: 1, @@ -969,18 +963,18 @@ export const frameDefinitions: Record = { tenderFuelAmount: 470, tenderWaterAmount: 5900, }, - }, - - 'mosca': { - engine: true, - length: 852, - name: 'Mosca', min: { headlightType: 1, paintType: 1, - reverserValue: -1, smokestackType: 1, }, + name: 'Montezuma Tender', + tender: true, + }, + + 'mosca': { + engine: true, + length: 852, max: { boilerFireTemp: 400, boilerFuelAmount: 70, @@ -995,17 +989,17 @@ export const frameDefinitions: Record = { sanderAmount: 100, smokestackType: 5, }, - }, - - 'mosca_tender': { - length: 530, - name: 'Mosca Tender', - tender: true, min: { headlightType: 1, paintType: 1, + reverserValue: -1, smokestackType: 1, }, + name: 'Mosca', + }, + + 'mosca_tender': { + length: 530, max: { brakeValue: 1, headlightType: 1, @@ -1014,187 +1008,187 @@ export const frameDefinitions: Record = { tenderFuelAmount: 854, tenderWaterAmount: 3800, }, - }, - - 'OahuWaterCar': { - length: 428, - name: 'Oahu Water Car', - freight: true, min: { headlightType: 1, paintType: 1, smokestackType: 1, }, + name: 'Mosca Tender', + tender: true, + }, + + 'OahuWaterCar': { + freight: true, + length: 428, max: { brakeValue: 1, headlightType: 1, paintType: 7, smokestackType: 1, }, - }, - - 'plantationcar_boxcar': { - freight: true, - length: 420, - name: 'EWA Plantation Box Car', min: { headlightType: 1, paintType: 1, smokestackType: 1, }, + name: 'Oahu Water Car', + }, + + 'plantationcar_boxcar': { + freight: true, + length: 420, max: { brakeValue: 1, headlightType: 1, paintType: 7, smokestackType: 1, }, - }, - - 'plantationcar_flatcar': { - freight: true, - length: 420, - name: 'Gregg Sugar Cane Cane Flat', min: { headlightType: 1, paintType: 1, smokestackType: 1, }, + name: 'EWA Plantation Box Car', + }, + + 'plantationcar_flatcar': { + freight: true, + length: 420, max: { brakeValue: 1, headlightType: 1, paintType: 7, smokestackType: 1, }, - }, - - 'plantationcar_flatcar_logs': { - freight: true, - length: 420, - name: 'Gregg Sugar Cane Logging Flat', min: { headlightType: 1, paintType: 1, smokestackType: 1, }, + name: 'Gregg Sugar Cane Cane Flat', + }, + + 'plantationcar_flatcar_logs': { + freight: true, + length: 420, max: { brakeValue: 1, headlightType: 1, paintType: 7, smokestackType: 1, }, - }, - - 'plantationcar_flatcar_stakes': { - freight: true, - length: 420, - name: 'Gregg Sugar Cane Stake Flat', min: { headlightType: 1, paintType: 1, smokestackType: 1, }, + name: 'Gregg Sugar Cane Logging Flat', + }, + + 'plantationcar_flatcar_stakes': { + freight: true, + length: 420, max: { brakeValue: 1, headlightType: 1, paintType: 7, smokestackType: 1, }, - }, - - 'plantationcar_flatcar_stakes_bulkhead': { - freight: true, - length: 420, - name: 'Gregg Sugar Cane Bulkhead Flat', min: { headlightType: 1, paintType: 1, smokestackType: 1, }, + name: 'Gregg Sugar Cane Stake Flat', + }, + + 'plantationcar_flatcar_stakes_bulkhead': { + freight: true, + length: 420, max: { brakeValue: 1, headlightType: 1, paintType: 7, smokestackType: 1, }, - }, - - 'plantationcar_hopper_large': { - freight: true, - length: 420, - name: 'Gregg Sugar Cane Lowside Gondola', min: { headlightType: 1, paintType: 1, smokestackType: 1, }, - max: { - brakeValue: 1, - headlightType: 1, - paintType: 7, - smokestackType: 1, - }, + name: 'Gregg Sugar Cane Bulkhead Flat', }, - 'plantationcar_hopper_medium': { + 'plantationcar_hopper_large': { freight: true, length: 420, - name: 'Gregg Sugar Cane Medium Gondola', + max: { + brakeValue: 1, + headlightType: 1, + paintType: 7, + smokestackType: 1, + }, min: { headlightType: 1, paintType: 1, smokestackType: 1, }, + name: 'Gregg Sugar Cane Lowside Gondola', + }, + + 'plantationcar_hopper_medium': { + freight: true, + length: 420, max: { brakeValue: 1, headlightType: 1, paintType: 7, smokestackType: 1, }, - }, - - 'plantationcar_hopper_small': { - freight: true, - length: 420, - name: 'Gregg Sugar Cane Highside Gondola', min: { headlightType: 1, paintType: 1, smokestackType: 1, }, + name: 'Gregg Sugar Cane Medium Gondola', + }, + + 'plantationcar_hopper_small': { + freight: true, + length: 420, max: { brakeValue: 1, headlightType: 1, paintType: 7, smokestackType: 1, }, - }, - - 'plantationcar_tanker': { - freight: true, - length: 420, - name: 'Waualua Agricultural Tank Car', min: { headlightType: 1, paintType: 1, smokestackType: 1, }, + name: 'Gregg Sugar Cane Highside Gondola', + }, + + 'plantationcar_tanker': { + freight: true, + length: 420, max: { brakeValue: 1, headlightType: 1, paintType: 7, smokestackType: 1, }, - }, - - 'plow': { - length: 530, - name: 'Snow Plow', - mow: true, min: { headlightType: 1, paintType: 1, smokestackType: 1, }, + name: 'Waualua Agricultural Tank Car', + }, + + 'plow': { + length: 530, max: { brakeValue: 1, headlightType: 1, @@ -1203,18 +1197,18 @@ export const frameDefinitions: Record = { paintType: 4, smokestackType: 1, }, - }, - - 'porter_040': { - engine: true, - length: 391.2, - name: 'Porter', min: { headlightType: 1, paintType: 1, - reverserValue: -1, smokestackType: 1, }, + mow: true, + name: 'Snow Plow', + }, + + 'porter_040': { + engine: true, + length: 391.2, max: { boilerFireTemp: 400, boilerFuelAmount: 50, @@ -1231,16 +1225,18 @@ export const frameDefinitions: Record = { tenderFuelAmount: 66, tenderWaterAmount: 800, }, + min: { + headlightType: 1, + paintType: 1, + reverserValue: -1, + smokestackType: 1, + }, + name: 'Porter', }, 'porter_042': { engine: true, length: 461.35, - name: 'Porter 2', - min: { - paintType: 1, - reverserValue: -1, - }, max: { boilerFireTemp: 400, boilerFuelAmount: 50, @@ -1257,19 +1253,17 @@ export const frameDefinitions: Record = { tenderFuelAmount: 164, tenderWaterAmount: 800, }, + min: { + paintType: 1, + reverserValue: -1, + }, + name: 'Porter 2', }, 'rubybasin': { coal: true, engine: true, length: 1029, - name: 'Ruby Basin', - min: { - headlightType: 1, - paintType: 1, - reverserValue: -1, - smokestackType: 1, - }, max: { boilerFireTemp: 400, boilerFuelAmount: 70, @@ -1287,18 +1281,18 @@ export const frameDefinitions: Record = { tenderFuelAmount: 1000, tenderWaterAmount: 3785, }, - }, - - 'shay': { - engine: true, - length: 804, - name: 'Shay', min: { headlightType: 1, paintType: 1, reverserValue: -1, smokestackType: 1, }, + name: 'Ruby Basin', + }, + + 'shay': { + engine: true, + length: 804, max: { boilerFireTemp: 400, boilerFuelAmount: 80, @@ -1315,86 +1309,86 @@ export const frameDefinitions: Record = { tenderFuelAmount: 317, tenderWaterAmount: 3000, }, - }, - - 'SideDumpCar': { - length: 330, - name: 'Westside Lumber Co. Side Dump car', - freight: true, min: { headlightType: 1, paintType: 1, + reverserValue: -1, smokestackType: 1, }, + name: 'Shay', + }, + + 'SideDumpCar': { + freight: true, + length: 330, max: { brakeValue: 1, headlightType: 1, paintType: 5, smokestackType: 1, }, - }, - - 'skeletoncar': { - freight: true, - length: 635, - name: 'Skeleton Car', min: { headlightType: 1, paintType: 1, smokestackType: 1, }, + name: 'Westside Lumber Co. Side Dump car', + }, + + 'skeletoncar': { + freight: true, + length: 635, max: { brakeValue: 1, headlightType: 1, paintType: 6, smokestackType: 1, }, - }, - - 'stockcar': { - freight: true, - length: 932, - name: 'Stock Car', min: { headlightType: 1, paintType: 1, smokestackType: 1, }, + name: 'Skeleton Car', + }, + + 'stockcar': { + freight: true, + length: 932, max: { brakeValue: 1, headlightType: 1, paintType: 7, smokestackType: 1, }, - }, - - 'tankcarNCO': { - freight: true, - length: 993, - name: 'Coffin Tank Car', min: { headlightType: 1, paintType: 1, smokestackType: 1, }, + name: 'Stock Car', + }, + + 'tankcarNCO': { + freight: true, + length: 993, max: { brakeValue: 1, headlightType: 1, paintType: 5, smokestackType: 1, }, - }, - - 'tenmile': { - engine: true, - length: 1174, - name: 'Tenmile', min: { headlightType: 1, paintType: 1, - reverserValue: -1, smokestackType: 1, }, + name: 'Coffin Tank Car', + }, + + 'tenmile': { + engine: true, + length: 1174, max: { boilerFireTemp: 400, boilerFuelAmount: 70, @@ -1412,19 +1406,19 @@ export const frameDefinitions: Record = { tenderFuelAmount: 3320, tenderWaterAmount: 1200, }, - }, - - 'tweetsie280': { - coal: true, - engine: true, - length: 914, - name: 'ET&WNC 2-8-0', min: { headlightType: 1, paintType: 1, reverserValue: -1, smokestackType: 1, }, + name: 'Tenmile', + }, + + 'tweetsie280': { + coal: true, + engine: true, + length: 914, max: { boilerFireTemp: 400, boilerFuelAmount: 70, @@ -1442,18 +1436,18 @@ export const frameDefinitions: Record = { sanderAmount: 100, smokestackType: 3, }, - }, - - 'tweetsie280_tender': { - coal: true, - tender: true, - length: 669, - name: 'ET&WNC 2-8-0 Tender', min: { headlightType: 1, paintType: 1, + reverserValue: -1, smokestackType: 1, }, + name: 'ET&WNC 2-8-0', + }, + + 'tweetsie280_tender': { + coal: true, + length: 669, max: { brakeValue: 1, headlightType: 1, @@ -1462,51 +1456,51 @@ export const frameDefinitions: Record = { tenderFuelAmount: 6000, tenderWaterAmount: 9500, }, - }, - - 'VentilatedBoxcarCC': { - length: 916, - name: 'Ventilated Boxcar', - freight: true, min: { headlightType: 1, paintType: 1, smokestackType: 1, }, + name: 'ET&WNC 2-8-0 Tender', + tender: true, + }, + + 'VentilatedBoxcarCC': { + freight: true, + length: 916, max: { brakeValue: 1, headlightType: 1, paintType: 6, smokestackType: 1, }, - }, - - 'WaterCar': { - length: 876, - name: 'Water Car', - freight: true, min: { headlightType: 1, paintType: 1, smokestackType: 1, }, + name: 'Ventilated Boxcar', + }, + + 'WaterCar': { + freight: true, + length: 876, max: { brakeValue: 1, headlightType: 1, paintType: 1, smokestackType: 1, }, - }, - - 'waycar': { - length: 615, - name: 'DSP&P Waycar', - passenger: true, min: { headlightType: 1, paintType: 1, smokestackType: 1, }, + name: 'Water Car', + }, + + 'waycar': { + length: 615, max: { boilerFireTemp: 400, boilerFuelAmount: 50, @@ -1523,6 +1517,13 @@ export const frameDefinitions: Record = { smokestackType: 1, tenderFuelAmount: 25, }, + min: { + headlightType: 1, + paintType: 1, + smokestackType: 1, + }, + name: 'DSP&P Waycar', + passenger: true, }, }; @@ -1560,8 +1561,8 @@ export const frameStateMetadata = { }, brakeValue: { name: 'Brake', - type: 'slider', step: 0.01, + type: 'slider', }, compressorAirPressure: { name: 'Compressor Air Pressure', @@ -1570,13 +1571,13 @@ export const frameStateMetadata = { }, compressorValveValue: { name: 'Compressor', - type: 'slider', step: 0.01, + type: 'slider', }, generatorValveValue: { name: 'Generator', - type: 'slider', step: 0.01, + type: 'slider', }, headlightType: { name: 'Headlight', @@ -1606,13 +1607,13 @@ export const frameStateMetadata = { }, regulatorValue: { name: 'Regulator', - type: 'slider', step: 0.01, + type: 'slider', }, reverserValue: { name: 'Reverser', - type: 'slider', step: 0.01, + type: 'slider', }, sanderAmount: { name: 'Sand', @@ -1688,9 +1689,9 @@ export const cargoLimits = { plantationcar_boxcar: { ['EFreightType::CrateTools']: 12, ['EFreightType::Grain']: 4, - ['EFreightType::SeedPallet']: 3, - ['EFreightType::OilBarrel']: 15, ['EFreightType::None']: 0, + ['EFreightType::OilBarrel']: 15, + ['EFreightType::SeedPallet']: 3, }, plantationcar_flatcar: { ['EFreightType::CrateTools']: 6, @@ -1713,20 +1714,20 @@ export const cargoLimits = { ['EFreightType::StrawBale']: 4, }, plantationcar_hopper_large: { - ['EFreightType::CrateTools']: 12, ['EFreightType::Coal']: 6, + ['EFreightType::CrateTools']: 12, ['EFreightType::IronOre']: 6, ['EFreightType::OilBarrel']: 15, }, plantationcar_hopper_medium: { - ['EFreightType::CrateTools']: 12, ['EFreightType::Coal']: 3, + ['EFreightType::CrateTools']: 12, ['EFreightType::IronOre']: 3, ['EFreightType::OilBarrel']: 15, }, plantationcar_hopper_small: { - ['EFreightType::CrateTools']: 6, ['EFreightType::Coal']: 2, + ['EFreightType::CrateTools']: 6, ['EFreightType::IronOre']: 2, ['EFreightType::OilBarrel']: 15, }, @@ -1743,8 +1744,8 @@ export const cargoLimits = { ['EFreightType::None']: 0, }, stockcar: { - ['EFreightType::CrateTools']: 32, ['EFreightType::Cattle']: 6, + ['EFreightType::CrateTools']: 32, ['EFreightType::None']: 0, }, tankcarNCO: { diff --git a/ts/importer.ts b/ts/importer.ts index 5da7d4e..95ca8cc 100644 --- a/ts/importer.ts +++ b/ts/importer.ts @@ -164,7 +164,6 @@ export function gvasToRailroad(gvas: Gvas): Railroad { name: frameName[i], number: frameNumber[i], rotation: frameRotation[i], - type: frameType[i], state: { boilerFireTemp: boilerFireTemp[i], boilerFuelAmount: boilerFuelAmount[i], @@ -195,6 +194,7 @@ export function gvasToRailroad(gvas: Gvas): Railroad { tenderFuelAmount: tenderFuelAmount[i], tenderWaterAmount: tenderWaterAmount[i], }, + type: frameType[i], }; frames.push(frame); } @@ -233,14 +233,14 @@ export function gvasToRailroad(gvas: Gvas): Railroad { const industryTypeTemp = industryType[i]; if (industryTypeTemp === null) throw new Error('Null industryType'); const industry: Industry = { - location: industryLocation[i], - rotation: industryRotation[i], inputs: [ industryStorageEduct1[i], industryStorageEduct2[i], industryStorageEduct3[i], industryStorageEduct4[i]], + location: industryLocation[i], outputs: [ industryStorageProduct1[i], industryStorageProduct2[i], industryStorageProduct3[i], industryStorageProduct4[i]], + rotation: industryRotation[i], type: industryTypeTemp, }; if (typeof industry.type === 'number' && industry.type > IndustryType.wood_rick) { @@ -272,12 +272,12 @@ export function gvasToRailroad(gvas: Gvas): Railroad { for (let i = 0; i < playerName.length; i++) { const player: Player = { id: optionalIndex(playerId, i), - name: playerName[i], location: optionalIndex(playerLocation, i), money: playerMoney[i], + name: playerName[i], + permissions: optionalIndex(permissions, i), rotation: optionalIndex(playerRotation, i), xp: playerXp[i], - permissions: optionalIndex(permissions, i), }; players.push(player); } @@ -295,8 +295,8 @@ export function gvasToRailroad(gvas: Gvas): Railroad { for (let i = 0; i < propNames.length; i++) { const prop: Prop = { name: propNames[i], - transform: propTransforms[i], text: propText[i], + transform: propTransforms[i], }; props.push(prop); } @@ -544,8 +544,8 @@ export function gvasToRailroad(gvas: Gvas): Railroad { sandhouses, saveGame, settings, - splineTracks, splines, + splineTracks, switches, turntables, vegetation, diff --git a/ts/industries.ts b/ts/industries.ts index 7ac65a0..e6bdaca 100644 --- a/ts/industries.ts +++ b/ts/industries.ts @@ -146,15 +146,20 @@ export const industryNames: Record = { 'engineshed_style4': 'Large Engine House (Old)', 'firewooddepot': 'Firewood Camp', 'freightdepot': 'Freight Depot', + 'GoldDredge': 'Gold Dredge', + 'GoldMine': 'Gold Mine', + 'GoldSmelter': 'Gold Smelter', 'ironoremine': 'Iron Mine', 'ironworks': 'Ironworks', 'logcamp': 'Logging Camp', 'MeatPackingPlant': 'Meat Packing Plant', 'oilfield': 'Oil Field', + 'RailExpressAgency': 'Rail Express Agency', 'Refinery': 'Refinery', 'Sandhouse': 'Sandhouse', 'sawmill': 'Sawmill', 'smelter': 'Smelter', + 'StampMill': 'Stamp Mill', 'telegraphoffice': 'Telegraph Office', 'watertower_1870_style1': '1870 Water Tower (Red)', 'watertower_1870_style2': '1870 Water Tower (Brown)', @@ -169,11 +174,6 @@ export const industryNames: Record = { 'WaterWell': 'Water Well', 'WheatFarm': 'Wheat Farm', 'Woodrick': 'Wood Rick', - 'GoldDredge': 'Gold Dredge', - 'GoldMine': 'Gold Mine', - 'StampMill': 'Stamp Mill', - 'GoldSmelter': 'Gold Smelter', - 'RailExpressAgency': 'Rail Express Agency', }; type FourStrings = [string, string, string, string]; @@ -181,38 +181,44 @@ const [input2, input3, input4] = ['Unused Input Slot 2', 'Unused Input Slot 3', const [output2, output3, output4] = ['Unused Output Slot 2', 'Unused Output Slot 3', 'Unused Output Slot 4']; export const industryInputLabels: Partial> = { + 'CattleFarm': ['Grain', 'Water', 'Straw Bale', input4], 'coalmine': ['Beams', 'Rails', input3, input4], + 'coaltower': ['Coal', input2, input3, input4], + 'firewooddepot': ['Logs', input2, input3, input4], + 'GoldDredge': ['Coal', 'Tool Crates', 'Steel Pipes', input4], + 'GoldMine': ['Coal', 'Beams', 'Rails', 'Tool Crates'], + 'GoldSmelter': ['Refined Gold', 'Coal', input3, input4], 'ironoremine': ['Lumber', 'Beams', input3, input4], 'ironworks': ['Raw Iron', 'Coal', 'Lumber', input4], + 'MeatPackingPlant': ['Cattle', 'Coal', input2, input4], 'oilfield': ['Steel Pipes', 'Beams', 'Tool Crates', input4], 'Refinery': ['Crude Oil', 'Steel Pipes', 'Lumber', input4], 'sawmill': ['Logs', input2, input3, input4], 'smelter': ['Cordwood', 'Iron Ore', input3, input4], - 'WheatFarm': ['Seed Pallet', 'Water', input3, input4], - 'CattleFarm': ['Grain', 'Water', 'Straw Bale', input4], - 'MeatPackingPlant': ['Cattle', 'Coal', input2, input4], - 'GoldDredge': ['Coal', 'Tool Crates', 'Steel Pipes', input4], - 'GoldMine': ['Coal', 'Beams', 'Rails', 'Tool Crates'], 'StampMill': ['Gold Ore', 'water', 'Coal', 'Cordwood'], - 'GoldSmelter': ['Refined Gold', 'Coal', input3, input4], - 'coaltower': ['Coal', input2, input3, input4], - 'firewooddepot': ['Logs', input2, input3, input4], + 'WheatFarm': ['Seed Pallet', 'Water', input3, input4], }; const water: FourStrings = ['Water', output2, output3, output4]; export const industryOutputLabels: Partial> = { + 'CattleFarm': ['Cattle', 'Cattle', output3, output4], 'coalmine': ['Coal', output2, output3, output4], 'coaltower': ['Coal', output2, output3, output4], 'firewooddepot': ['Firewood', 'Firewood', 'Firewood', 'Firewood'], 'freightdepot': ['Seed Pallet', output2, output3, output4], + 'GoldDredge': ['Gold Ore', output2, output3, output4], + 'GoldMine': ['Gold Ore', output2, output3, output4], + 'GoldSmelter': ['Gold Ingot', output2, output3, output4], 'ironoremine': ['Iron Ore', output2, output3, output4], 'ironworks': ['Steel Pipes', 'Tool Crates', output3, output4], 'logcamp': ['Logs', 'Cordwood', output3, output4], + 'MeatPackingPlant': ['Meat', output2, output3, output4], 'oilfield': ['Crude Oil', output2, output3, output4], 'Refinery': ['Oil Barrel', output2, output3, output4], 'Sandhouse': ['Sand', output2, output3, output4], 'sawmill': ['Lumber', 'Beams', output3, output4], 'smelter': ['Raw Iron', 'Rails', output3, output4], + 'StampMill': ['Refined Gold', output2, output3, output4], 'telegraphoffice': ['Unknown', output2, output3, output4], 'watertower_1870_style1': water, 'watertower_1870_style2': water, @@ -227,12 +233,6 @@ export const industryOutputLabels: Partial> = 'WaterWell': water, 'WheatFarm': ['Grain', 'Straw Bale', output3, output4], 'Woodrick': ['Firewood', 'Firewood', output3, output4], - 'CattleFarm': ['Cattle', 'Cattle', output3, output4], - 'MeatPackingPlant': ['Meat', output2, output3, output4], - 'GoldDredge': ['Gold Ore', output2, output3, output4], - 'GoldMine': ['Gold Ore', output2, output3, output4], - 'StampMill': ['Refined Gold', output2, output3, output4], - 'GoldSmelter': ['Gold Ingot', output2, output3, output4], }; export const gizmoSvgPaths = { @@ -254,11 +254,111 @@ const waterTower = { }; export const industrySvgPaths: Partial>> = { - 'logcamp': { + 'CattleFarm': { + 'building': combine( + rect(-1220, 2900, 1370, 1000), + rect(-920, -5100, 1200, 2050), + circle(-1650, 1300, 190), + ), + 'fence': combine( + rect(600, -3190, 1700, 3350), + rect(600, 550, 1700, 3350), + ), 'platform': combine( - rect(530, 1440, 300, 1250), - rect(2570, -1390, 2360 - 2570, 250 + 1390), + rect(-2150, -2250, 300, 1230), + rect(-2150, 1490, 300, 1000), + rect(2300, -1060, 600, 300), + rect(2300, 2650, 600, 300), + circle(-1825, 0, 320), + ), + }, + 'coalmine': { + 'building': combine( + rect(-180, -230, 2320, 790), + rect(3320, -180, 1080, 760), ), + 'platform': combine( + rect(-250, 2050, 300, -1050), + rect(-275, -1050, 300, -2050), + ), + }, + 'coaltower': { + 'building': rect(50, -900, 600, 600), + }, + 'enginehouse_alpine': engineHouse, + 'enginehouse_aspen': engineHouse, + 'enginehouse_barn': engineHouse, + 'enginehouse_princess': engineHouse, + 'engineshed_style1': largeEngineHouse, + 'engineshed_style2': largeEngineHouse, + 'engineshed_style3': largeEngineHouse, + 'engineshed_style4': largeEngineHouse, + 'firewooddepot': { + 'building': rect(150, 1000, 950, -1700), + }, + 'freightdepot': { + 'building': rectAbs(2100, -900, -2200, 900), + 'platform': polyRect(2200, -1000, + -3300, -700, + -2300, 1000), + }, + 'GoldDredge': { + 'building': + polyRect( + -1900, -750, 800, -250, + 2800, 150, 800, 700, + -1900, 150, -2900, -250, + ), + 'platform': rect(-3550, 2850, 5450, 300), + 'walkway': rect(-950, 800, 300, 2030), + }, + 'GoldMine': { + 'building': rect(-2295, -445, 2000, 850), + 'platform': rect(-595, -5715, 300, 5250), + }, + 'GoldSmelter': { + 'building': combine( + rect(-1550, -1250, 450, 2500), + rect(-1800, 590, 200, 250), + rect(-1800, -850, 200, 250), + polyRect( + -490, 3400, 500, 1800, + 1550, -1800, 1000, -1800, + 250, -2200, -350, -1800, + -1050, 1800, + ), + ), + 'platform': combine( + rect(-2550, -1250, 300, 950), + rect(1700, -1580, 650, 3050), + ), + }, + 'ironoremine': { + 'building': combine( + rotatedRect(650, -1670, 500, 750, 43), + polyRect(0, -500, + 500, -150, + 2200, 350, + 500, 1500), + ), + 'platform': combine( + rect(-200, 200, 300, -400), + rect(-200, 4600, 300, -3000), + ), + }, + 'ironworks': { + 'building': polyRectRel(3100, 1300, + -6800, -2600, + 5800, -1000, + 1000), + 'platform': combine( + rect(-4000, 2800, 2500, -300), + rect(-200, 2800, 1200, -300), + rect(-4530, -2780, 1080, -300), + rect(-2800, -2780, 4500, -300), + ), + }, + 'logcamp': { 'building': combine( rect(-150, 580, -630, 950), rect(3800, -2500, -600, 2100), @@ -272,67 +372,34 @@ export const industrySvgPaths: Partial ({ - startPoint, endPoint, - startTangent: fp32v(normalizeVector(startTangent, tangentLength)), endTangent: fp32v(normalizeVector(endTangent, tangentLength)), + startPoint, + startTangent: fp32v(normalizeVector(startTangent, tangentLength)), }); // Calculate the angle between the start and end tangent. const angle = angleBetweenVectors(startTangent, endTangent); diff --git a/ts/tool-parallel.ts b/ts/tool-parallel.ts index 7fddf20..2e541bc 100644 --- a/ts/tool-parallel.ts +++ b/ts/tool-parallel.ts @@ -16,20 +16,20 @@ export function parallelSpline(spline: Spline, offset: number): [Spline, Spline] const a = spline.controlPoints.map(mapper(offset)); const b = spline.controlPoints.map(mapper(-offset)); return [{ - segmentsVisible: spline.segmentsVisible.concat(), controlPoints: a, location: a[0], + segmentsVisible: spline.segmentsVisible.concat(), type: spline.type, }, { - segmentsVisible: spline.segmentsVisible.concat(), controlPoints: b, location: b[0], + segmentsVisible: spline.segmentsVisible.concat(), type: spline.type, }]; } export function parallelSplineTrack(spline: SplineTrack, offset: number): SplineTrack[] { - const yaw90 = {pitch: 0, yaw: 90, roll: 0}; + const yaw90 = {pitch: 0, roll: 0, yaw: 90}; const endDirXY = {x: spline.endTangent.x, y: spline.endTangent.y, z: 0}; const endOffset = rotateVector(normalizeVector(endDirXY, offset), yaw90); const endPointD = vectorDifference(spline.endPoint, endOffset); diff --git a/ts/util-catmullrom.ts b/ts/util-catmullrom.ts index ca72161..4df5c95 100644 --- a/ts/util-catmullrom.ts +++ b/ts/util-catmullrom.ts @@ -18,7 +18,7 @@ export function catmullRomToHermite(spline: CatmullRomSpline, i: number, scale = // Convert catmull-rom segment to hermite form const startTangent = scaleVector(vectorDifference(endPoint, prevPoint), scale); const endTangent = scaleVector(vectorDifference(nextPoint, startPoint), scale); - return {startPoint, startTangent, endPoint, endTangent}; + return {endPoint, endTangent, startPoint, startTangent}; } export const catmullRomToBezier = (spline: CatmullRomSpline, i: number) => @@ -36,7 +36,7 @@ export function catmullRomMinRadius(spline: CatmullRomSpline): CatmullRomOsculat const getSegmentResult = (i: number) => { const bezier = catmullRomToBezier(spline, i); const {center, location, radius, t} = cubicBezierMinRadius(bezier); - const result = {center, location, radius, t, i}; + const result = {center, i, location, radius, t}; return result; }; return Object.entries(spline.segmentsVisible) diff --git a/ts/util.ts b/ts/util.ts index dd4a8a9..a2d87ae 100644 --- a/ts/util.ts +++ b/ts/util.ts @@ -17,13 +17,13 @@ export function fp32(n: number): number { } export function fp32q(q: Quaternion): Quaternion { - const [x, y, z, w] = new Float32Array([q.x, q.y, q.z, q.w]); - return {x, y, z, w}; + const [w, x, y, z] = new Float32Array([q.w, q.x, q.y, q.z]); + return {w, x, y, z}; } export function fp32r(r: Rotator): Rotator { - const [roll, pitch, yaw] = new Float32Array([r.roll, r.pitch, r.yaw]); - return {roll, pitch, yaw}; + const [pitch, roll, yaw] = new Float32Array([r.pitch, r.roll, r.yaw]); + return {pitch, roll, yaw}; } export function fp32v(v: Vector): Vector { @@ -37,14 +37,14 @@ export function stringToText(str: GvasString): GvasText { if (lines.length === 0) return {flags: 0, values: []}; if (lines.length === 1) return {flags: 0, values: [str]}; return { - flags: 1, - guid: RRO_TEXT_GUID, - pattern: lines.map((_, i) => '{' + i + '}').join('
'), args: lines.map((line, i) => ({ - name: String(i), contentType: 2, + name: String(i), values: line ? [line] : [], })), + flags: 1, + guid: RRO_TEXT_GUID, + pattern: lines.map((_, i) => '{' + i + '}').join('
'), }; }