Skip to content

Commit

Permalink
Merge pull request #55 from EvenTorset/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
EvenTorset authored Sep 1, 2024
2 parents 5c28cc8 + 57b1258 commit 7fffa9f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 17 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [15.1.0] - 2024-09-01

### Highlights
- Added a `depth` argument to the `clone` method on nodes that controls how many levels of descendants to clone. It defaults to `Infinity` (same behavior as before), and can be set to 0 to not clone any child nodes.
- Updated links in the readme to work with the FXR Playground update.

## [15.0.0] - 2024-08-28

### Highlights
Expand Down Expand Up @@ -171,6 +177,7 @@
- External values 2000 and 70200 for AC6 have been documented thanks to lugia19.
- Fixed action 301 (EqualDistanceEmitter) missing a type for one of its fields, potentially causing issues when writing to DS3's structure.

[15.1.0]: https://github.com/EvenTorset/fxr/compare/v15.0.0...v15.1.0
[15.0.0]: https://github.com/EvenTorset/fxr/compare/v14.1.0...v15.0.0
[14.1.0]: https://github.com/EvenTorset/fxr/compare/v14.0.1...v14.1.0
[14.0.1]: https://github.com/EvenTorset/fxr/compare/v14.0.0...v14.0.1
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ Once it has been read, you can change things in the FXR object to whatever you n

Once you have made your changes to the FXR object, you can write it to a file if you're using Node.js, or you can generate an ArrayBuffer with the file's content if you need it to run in the browser.

[Open in FXR Playground](https://fxr-playground.pages.dev/#examples/readme/edit)
[Open in FXR Playground](https://fxr-playground.pages.dev/shared/examples/readme/edit)
```js
import { FXR, Game, Recolor, hex } from '@cccode/fxr'

// Parse file
const fxr = await FXR.read('f000450360.fxr', Game.EldenRing)
const fxr = await FXR.read('f000450360.fxr')

// Make some changes to the FXR here.

Expand All @@ -58,7 +58,7 @@ await fxr.saveAs('f000450360_edit.fxr', Game.EldenRing)
## Creating new FXR files
Creating brand new FXR files from scratch requires some knowledge about their structure, but below is an example to get started. The example creates lots of thin rectangular particles that change color over time in a cylindrical volume.

[Open in FXR Playground](https://fxr-playground.pages.dev/#examples/readme/create)
[Open in FXR Playground](https://fxr-playground.pages.dev/shared/examples/readme/create)
```js
import {
FXR,
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cccode/fxr",
"version": "15.0.0",
"version": "15.1.0",
"description": "JavaScript library for creating and editing FXR files for Dark Souls 3, Sekiro, Elden Ring, and Armored Core 6.",
"author": "CCCode",
"type": "module",
Expand Down
22 changes: 11 additions & 11 deletions src/fxr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9771,7 +9771,7 @@ abstract class Node {
getNodes(game: Game): Node[] { return [] }
abstract toJSON(): any
minify(): Node { return this }
abstract clone(): Node
abstract clone(depth: number): Node

static fromJSON(obj: any): Node {
if (obj instanceof Node) {
Expand Down Expand Up @@ -10424,12 +10424,12 @@ class GenericNode extends Node {
)
}

clone(): GenericNode {
clone(depth: number = Infinity): GenericNode {
return new GenericNode(
this.type,
this.actions.map(e => e.clone()),
this.effects.map(e => e.clone()),
this.nodes.map(e => e.clone()),
depth > 0 ? this.nodes.map(e => e.clone(depth - 1)) : [],
)
}

Expand Down Expand Up @@ -10512,9 +10512,9 @@ class RootNode extends Node {
}
}

clone(): RootNode {
clone(depth: number = Infinity): RootNode {
return new RootNode(
this.nodes.map(e => e.clone()),
depth > 0 ? this.nodes.map(e => e.clone(depth - 1)) : [],
this.unk70x.clone() as ActionSlots.Unknown70xAction,
this.unk10100.clone() as ActionSlots.Unknown10100Action,
this.unk10400.clone() as ActionSlots.Unknown10400Action,
Expand Down Expand Up @@ -10676,10 +10676,10 @@ class LevelsOfDetailNode extends NodeWithEffects {
).mapStates(...this.stateEffectMap)
}

clone(): LevelsOfDetailNode {
clone(depth: number = Infinity): LevelsOfDetailNode {
return new LevelsOfDetailNode(
this.effects.map(e => e.clone()),
this.nodes.map(e => e.clone()),
depth > 0 ? this.nodes.map(e => e.clone(depth - 1)) : [],
)
}

Expand Down Expand Up @@ -10736,10 +10736,10 @@ class BasicNode extends NodeWithEffects {
).mapStates(...this.stateEffectMap)
}

clone(): BasicNode {
clone(depth: number = Infinity): BasicNode {
return new BasicNode(
this.effects.map(e => e.clone()),
this.nodes.map(e => e.clone()),
depth > 0 ? this.nodes.map(e => e.clone(depth - 1)) : [],
)
}

Expand Down Expand Up @@ -10790,10 +10790,10 @@ class NodeEmitterNode extends NodeWithEffects {
).mapStates(...this.stateEffectMap)
}

clone(): NodeEmitterNode {
clone(depth: number = Infinity): NodeEmitterNode {
return new NodeEmitterNode(
this.effects.map(e => e.clone()),
this.nodes.map(e => e.clone()),
depth > 0 ? this.nodes.map(e => e.clone(depth - 1)) : [],
)
}

Expand Down

0 comments on commit 7fffa9f

Please sign in to comment.