23 lines
618 B
JavaScript
23 lines
618 B
JavaScript
import { Random } from "./Random";
|
|
import { setRangeValue } from "../../Utils/NumberUtils";
|
|
export class ValueWithRandom {
|
|
constructor() {
|
|
this.random = new Random();
|
|
this.value = 0;
|
|
}
|
|
load(data) {
|
|
if (!data) {
|
|
return;
|
|
}
|
|
if (typeof data.random === "boolean") {
|
|
this.random.enable = data.random;
|
|
}
|
|
else {
|
|
this.random.load(data.random);
|
|
}
|
|
if (data.value !== undefined) {
|
|
this.value = setRangeValue(data.value, this.random.enable ? this.random.minimumValue : undefined);
|
|
}
|
|
}
|
|
}
|