Skip to content

Commit

Permalink
Merge pull request #6 from EvenTorset/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
EvenTorset authored Mar 22, 2024
2 parents ed89a1f + 18171e7 commit b96d06b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
33 changes: 18 additions & 15 deletions fxr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13449,15 +13449,15 @@ abstract class Property<T extends ValueType, F extends PropertyFunction> impleme

}

class ValueProperty<T extends ValueType, F extends ValuePropertyFunction>
extends Property<T, F>
implements IModifiableProperty<T, F>, IValueProperty<T, F> {
class ValueProperty<T extends ValueType>
extends Property<T, ValuePropertyFunction>
implements IModifiableProperty<T, ValuePropertyFunction>, IValueProperty<T, ValuePropertyFunction> {

value: ValueTypeMap[T]

constructor(
valueType: T,
func: F,
func: ValuePropertyFunction,
value: ValueTypeMap[T],
modifiers: Modifier[] = []
) {
Expand Down Expand Up @@ -13490,25 +13490,25 @@ class ValueProperty<T extends ValueType, F extends ValuePropertyFunction>
}
}

static fromFields<T extends ValueType, F extends ValuePropertyFunction>(
static fromFields<T extends ValueType>(
valueType: T,
func: F,
func: ValuePropertyFunction,
modifiers: Modifier[],
fieldValues: number[]
): ValueProperty<T, F> {
): ValueProperty<T> {
switch (func) {
case PropertyFunction.Zero:
return new ZeroProperty(valueType).withModifiers(
...modifiers
) as unknown as ValueProperty<T, F>
) as unknown as ValueProperty<T>
case PropertyFunction.One:
return new OneProperty(valueType).withModifiers(
...modifiers
) as unknown as ValueProperty<T, F>
) as unknown as ValueProperty<T>
case PropertyFunction.Constant:
return new ConstantProperty(...(fieldValues as [number] | Vector)).withModifiers(
...modifiers
) as unknown as ValueProperty<T, F>
) as unknown as ValueProperty<T>
default:
throw new Error('Incompatible or unknown function in property: ' + func)
}
Expand Down Expand Up @@ -13556,6 +13556,7 @@ class ValueProperty<T extends ValueType, F extends ValuePropertyFunction>
}

scale(factor: number) {
this.function = PropertyFunction.Constant
if (this.valueType === ValueType.Scalar) {
(this.value as number) *= factor
} else {
Expand All @@ -13564,6 +13565,7 @@ class ValueProperty<T extends ValueType, F extends ValuePropertyFunction>
}

power(exponent: number) {
this.function = PropertyFunction.Constant
if (this.valueType === ValueType.Scalar) {
(this.value as number) **= exponent
} else {
Expand All @@ -13572,14 +13574,15 @@ class ValueProperty<T extends ValueType, F extends ValuePropertyFunction>
}

add(summand: number) {
this.function = PropertyFunction.Constant
if (this.valueType === ValueType.Scalar) {
(this.value as number) += summand
} else {
this.value = (this.value as Vector).map(e => e + summand) as ValueTypeMap[T]
}
}

minify(): ValueProperty<T, any> {
minify(): ValueProperty<T> {
switch (this.function) {
case PropertyFunction.Zero:
case PropertyFunction.One:
Expand Down Expand Up @@ -13607,7 +13610,7 @@ class ValueProperty<T extends ValueType, F extends ValuePropertyFunction>
return this.value
}

clone(): ValueProperty<T, F> {
clone(): ValueProperty<T> {
return new ValueProperty(this.valueType, this.function, this.value, this.modifiers.map(e => Modifier.copy(e)))
}

Expand Down Expand Up @@ -14001,7 +14004,7 @@ class ComponentKeyframeProperty<T extends ValueType>

}

class ZeroProperty extends ValueProperty<any, PropertyFunction.Zero> {
class ZeroProperty extends ValueProperty<any> {
constructor(valueType: ValueType = ValueType.Scalar, modifiers: Modifier[] = []) {
super(
valueType,
Expand All @@ -14012,7 +14015,7 @@ class ZeroProperty extends ValueProperty<any, PropertyFunction.Zero> {
}
}

class OneProperty extends ValueProperty<any, PropertyFunction.One> {
class OneProperty extends ValueProperty<any> {
constructor(valueType: ValueType = ValueType.Scalar, modifiers: Modifier[] = []) {
super(
valueType,
Expand All @@ -14023,7 +14026,7 @@ class OneProperty extends ValueProperty<any, PropertyFunction.One> {
}
}

class ConstantProperty<T extends ValueType> extends ValueProperty<T, PropertyFunction.Constant> {
class ConstantProperty<T extends ValueType> extends ValueProperty<T> {

constructor(
...args:
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": "5.0.0",
"version": "5.0.1",
"description": "JavaScript library for editing FXR files from Dark Souls 3, Sekiro, Elden Ring, and Armored Core 6.",
"author": "CCCode",
"type": "module",
Expand Down

0 comments on commit b96d06b

Please sign in to comment.