mirror of
https://git.srhtnin.garden/sarah/srhtnin.github.io.git
synced 2026-10-15 03:03:17 +02:00
Fixed bug where the previews for mutations with lists in their plots
could get a repeat permutation.
This commit is contained in:
1 parent
c723177564
commit
ea50b76e26
1 file changed
+41
-4
@@ -4,6 +4,7 @@ let MutationRecipePreviewFrame = 0;
|
|||||||
let MutationRecipePreviewTimer = null;
|
let MutationRecipePreviewTimer = null;
|
||||||
|
|
||||||
const MutationRecipePreviewCells = new Set();
|
const MutationRecipePreviewCells = new Set();
|
||||||
|
const MutationRecipePreviewPermutations = new Map();
|
||||||
|
|
||||||
|
|
||||||
function GetMutationRecipePreviewListReference(
|
function GetMutationRecipePreviewListReference(
|
||||||
@@ -419,16 +420,25 @@ function CreateMutationRecipePreviewPermutation(
|
|||||||
ListNumber,
|
ListNumber,
|
||||||
Frame
|
Frame
|
||||||
) {
|
) {
|
||||||
|
const CacheKey =
|
||||||
|
ListNumber + ":" + ItemCount;
|
||||||
|
|
||||||
|
const Cached =
|
||||||
|
MutationRecipePreviewPermutations.get(
|
||||||
|
CacheKey
|
||||||
|
);
|
||||||
|
|
||||||
|
if (Cached?.Frame === Frame) {
|
||||||
|
return Cached.Permutation;
|
||||||
|
}
|
||||||
|
|
||||||
const Permutation =
|
const Permutation =
|
||||||
Array.from(
|
Array.from(
|
||||||
{ length: ItemCount },
|
{ length: ItemCount },
|
||||||
(_, Index) => Index
|
(_, Index) => Index
|
||||||
);
|
);
|
||||||
|
|
||||||
if (ItemCount < 2 || Frame === 0) {
|
if (ItemCount >= 2 && Frame !== 0) {
|
||||||
return Permutation;
|
|
||||||
}
|
|
||||||
|
|
||||||
let State =
|
let State =
|
||||||
(
|
(
|
||||||
Math.imul(
|
Math.imul(
|
||||||
@@ -470,6 +480,33 @@ function CreateMutationRecipePreviewPermutation(
|
|||||||
Permutation[Index]
|
Permutation[Index]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
ItemCount >= 2 &&
|
||||||
|
Cached?.Frame === Frame - 1 &&
|
||||||
|
Permutation.every(
|
||||||
|
(Value, Index) =>
|
||||||
|
Value ===
|
||||||
|
Cached.Permutation[Index]
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
[
|
||||||
|
Permutation[0],
|
||||||
|
Permutation[1]
|
||||||
|
] = [
|
||||||
|
Permutation[1],
|
||||||
|
Permutation[0]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
MutationRecipePreviewPermutations.set(
|
||||||
|
CacheKey,
|
||||||
|
{
|
||||||
|
Frame: Frame,
|
||||||
|
Permutation: Permutation
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
return Permutation;
|
return Permutation;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user