diff --git a/package-lock.json b/package-lock.json index 3b7dd3b..bbade42 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,8 +10,9 @@ "hasInstallScript": true, "license": "MIT", "devDependencies": { - "@ca-ts/algo": "npm:@jsr/ca-ts__algo@^0.2.0", + "@ca-ts/algo": "npm:@jsr/ca-ts__algo@^0.4.0", "@ca-ts/rle": "npm:@jsr/ca-ts__rle@^0.8.0", + "@ca-ts/rule": "npm:@jsr/ca-ts__rule@^0.2.0", "babylonjs": "^7.29.0", "typescript": "^5.6.3", "vite": "^5.4.1" @@ -19,9 +20,9 @@ }, "node_modules/@ca-ts/algo": { "name": "@jsr/ca-ts__algo", - "version": "0.2.0", - "resolved": "https://npm.jsr.io/~/11/@jsr/ca-ts__algo/0.2.0.tgz", - "integrity": "sha512-dJdq4IATSpQiq8NQJaM0yNT6nGUCPv55N3uGOT+W4BuxxXZEJtr2XrzsdhVVTmB+Ixp9mck/8R0HoRyhKENCdA==", + "version": "0.4.0", + "resolved": "https://npm.jsr.io/~/11/@jsr/ca-ts__algo/0.4.0.tgz", + "integrity": "sha512-OJluqZ3pzrW16PViGIqabDZDdNmZkSnnXOBCqzyn8ndRBAecsaCE1RTq/ocjOhMHstO04BpJUw/OWC0hMunTLw==", "dev": true }, "node_modules/@ca-ts/rle": { @@ -31,6 +32,13 @@ "integrity": "sha512-i5qMBkWp8xRM2DSMRTFzAR3z1duw6J2aAv84YDpeaQljkNwKbGfawPNeDSy/tLWUCrYhEO/lqIN9kI2CkIXjig==", "dev": true }, + "node_modules/@ca-ts/rule": { + "name": "@jsr/ca-ts__rule", + "version": "0.2.0", + "resolved": "https://npm.jsr.io/~/11/@jsr/ca-ts__rule/0.2.0.tgz", + "integrity": "sha512-EF4RJx9reZ1KSeDVTegKLEaHsk3rEjAxUSrqHh9acacqdxvHTumhalxNyfYKqFq6DJkZdHxKDniOTICjnQ+lnQ==", + "dev": true + }, "node_modules/@esbuild/aix-ppc64": { "version": "0.21.5", "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz", diff --git a/package.json b/package.json index 25391d8..a4f27db 100644 --- a/package.json +++ b/package.json @@ -19,11 +19,11 @@ "preview": "vite preview" }, "devDependencies": { - "@ca-ts/algo": "npm:@jsr/ca-ts__algo@^0.2.0", + "@ca-ts/algo": "npm:@jsr/ca-ts__algo@^0.4.0", "@ca-ts/rle": "npm:@jsr/ca-ts__rle@^0.8.0", + "@ca-ts/rule": "npm:@jsr/ca-ts__rule@^0.2.0", "babylonjs": "^7.29.0", "typescript": "^5.6.3", "vite": "^5.4.1" - }, - "dependencies": {} + } } diff --git a/src/lib/setRLE.ts b/src/lib/setRLE.ts index c1b3506..767ea4d 100644 --- a/src/lib/setRLE.ts +++ b/src/lib/setRLE.ts @@ -1,9 +1,16 @@ import type { BitWorld } from "@ca-ts/algo/bit"; import { parseRLE } from "@ca-ts/rle"; +import { parseRule } from "@ca-ts/rule"; export function setRLE(bitWorld: BitWorld, sourceRLE: string) { const data = parseRLE(sourceRLE); + try { + bitWorld.setRule(parseRule(data.ruleString).transition); + } catch { + bitWorld.setRule({ birth: [3], survive: [2, 3] }); + } + const width = data.size?.width ?? 0; const height = data.size?.height ?? 0;