mirror of
https://github.com/ad044/lainTSX.git
synced 2024-10-22 23:19:06 +00:00
added unknown node handling and proper titles for every entry in json files
This commit is contained in:
parent
2abaeea1f7
commit
bc018e964d
6 changed files with 191 additions and 4413 deletions
|
@ -153,19 +153,20 @@ export const LainRipMiddleRing = () => (
|
|||
export const LainKnock = () => (
|
||||
<LainConstructor
|
||||
sprite={knockSpriteSheet}
|
||||
frameCount={32}
|
||||
frameCount={30}
|
||||
framesHorizontal={6}
|
||||
framesVertical={6}
|
||||
framesVertical={5}
|
||||
fps={30 * 0.35}
|
||||
/>
|
||||
);
|
||||
|
||||
export const LainKnockAndFall = () => (
|
||||
<LainConstructor
|
||||
sprite={knockAndFallSpriteSheet}
|
||||
frameCount={64}
|
||||
frameCount={62}
|
||||
framesHorizontal={8}
|
||||
framesVertical={8}
|
||||
fps={64 * 0.17}
|
||||
fps={62 * 0.17}
|
||||
/>
|
||||
);
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ export type NodeDataType = {
|
|||
title: string;
|
||||
unlocked_by: string;
|
||||
upgrade_requirement: number;
|
||||
protocol_lines: { 1: string; 2: string; 3: string; 4: string };
|
||||
words: { 1: string; 2: string; 3: string };
|
||||
matrixIndices?: {
|
||||
matrixIdx: number;
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
import { findNode, getNodeById } from "../../utils/node-utils";
|
||||
import {
|
||||
findNode,
|
||||
getNodeById,
|
||||
isNodeVisible,
|
||||
unknownNodeTemplate,
|
||||
} from "../../utils/node-utils";
|
||||
|
||||
const handleMainSceneEvent = (mainSceneContext: any) => {
|
||||
const {
|
||||
|
@ -23,11 +28,13 @@ const handleMainSceneEvent = (mainSceneContext: any) => {
|
|||
const keyPressToLower = keyPress.toLowerCase();
|
||||
|
||||
const nodeData = findNode(
|
||||
activeNode.id,
|
||||
keyPressToLower,
|
||||
activeNode.matrixIndices!,
|
||||
level,
|
||||
currentSite,
|
||||
gameProgress
|
||||
gameProgress,
|
||||
true
|
||||
);
|
||||
|
||||
if (!nodeData) return;
|
||||
|
@ -40,7 +47,9 @@ const handleMainSceneEvent = (mainSceneContext: any) => {
|
|||
? siteRotY + Math.PI / 4
|
||||
: siteRotY - Math.PI / 4,
|
||||
node: {
|
||||
...getNodeById(nodeData.node, currentSite),
|
||||
...(nodeData.node !== "unknown"
|
||||
? getNodeById(nodeData.node, currentSite)
|
||||
: unknownNodeTemplate),
|
||||
matrixIndices: nodeData.matrixIndices,
|
||||
},
|
||||
};
|
||||
|
@ -59,11 +68,13 @@ const handleMainSceneEvent = (mainSceneContext: any) => {
|
|||
case "DOWN": {
|
||||
const keyPressToLower = keyPress.toLowerCase();
|
||||
const nodeData = findNode(
|
||||
activeNode.id,
|
||||
keyPressToLower,
|
||||
activeNode.matrixIndices!,
|
||||
level,
|
||||
currentSite,
|
||||
gameProgress
|
||||
gameProgress,
|
||||
true
|
||||
);
|
||||
|
||||
if (!nodeData) return;
|
||||
|
@ -75,7 +86,9 @@ const handleMainSceneEvent = (mainSceneContext: any) => {
|
|||
.toString()
|
||||
.padStart(2, "0"),
|
||||
node: {
|
||||
...getNodeById(nodeData.node, currentSite),
|
||||
...(nodeData.node !== "unknown"
|
||||
? getNodeById(nodeData.node, currentSite)
|
||||
: unknownNodeTemplate),
|
||||
matrixIndices: nodeData.matrixIndices,
|
||||
},
|
||||
};
|
||||
|
@ -95,6 +108,9 @@ const handleMainSceneEvent = (mainSceneContext: any) => {
|
|||
|
||||
const nodeType = activeNode.type;
|
||||
|
||||
if (activeNode.id === "" || !isNodeVisible(activeNode, gameProgress))
|
||||
return;
|
||||
|
||||
if (activeNode.upgrade_requirement > ssknLvl) {
|
||||
const rejectAnimations = [
|
||||
"touch_and_scare",
|
||||
|
@ -222,12 +238,15 @@ const handleMainSceneEvent = (mainSceneContext: any) => {
|
|||
|
||||
const direction = selectedLevel > level ? "up" : "down";
|
||||
|
||||
const rowIdx = direction === "up" ? 2 : 0;
|
||||
const nodeData = findNode(
|
||||
activeNode.id,
|
||||
direction,
|
||||
activeNode.matrixIndices!,
|
||||
{ ...activeNode.matrixIndices!, rowIdx: rowIdx },
|
||||
selectedLevel,
|
||||
currentSite,
|
||||
gameProgress
|
||||
gameProgress,
|
||||
false
|
||||
);
|
||||
|
||||
if (nodeData) {
|
||||
|
@ -236,7 +255,9 @@ const handleMainSceneEvent = (mainSceneContext: any) => {
|
|||
return {
|
||||
event: event,
|
||||
node: {
|
||||
...getNodeById(nodeData.node, currentSite),
|
||||
...(nodeData.node !== "unknown"
|
||||
? getNodeById(nodeData.node, currentSite)
|
||||
: unknownNodeTemplate),
|
||||
matrixIndices: nodeData.matrixIndices,
|
||||
},
|
||||
level: selectedLevel.toString().padStart(2, "0"),
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -92,7 +92,7 @@ export const getVisibleNodesMatrix = (
|
|||
);
|
||||
};
|
||||
|
||||
function RowPrecedence(rowIdx: number): number[] {
|
||||
const RowPrecedence = (rowIdx: number): number[] => {
|
||||
switch (rowIdx) {
|
||||
default:
|
||||
case 0:
|
||||
|
@ -102,9 +102,9 @@ function RowPrecedence(rowIdx: number): number[] {
|
|||
case 2:
|
||||
return [2, 1, 0];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function ColPrecedence(colIdx: number): number[] {
|
||||
const ColPrecedence = (colIdx: number): number[] => {
|
||||
switch (colIdx) {
|
||||
default:
|
||||
case 0:
|
||||
|
@ -116,7 +116,7 @@ function ColPrecedence(colIdx: number): number[] {
|
|||
case 3:
|
||||
return [3, 2, 1, 0];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function* nextPos_left([row, col]: [number, number]) {
|
||||
const p = RowPrecedence(row);
|
||||
|
@ -144,7 +144,7 @@ function* nextPos_down([row, col]: [number, number]) {
|
|||
for (let r = row + 1; r < 3; r++) for (let c = 0; c < 4; c++) yield [r, p[c]];
|
||||
}
|
||||
|
||||
function move(direction: string, [matrix, level]: [number, number]) {
|
||||
const move = (direction: string, [matrix, level]: [number, number]) => {
|
||||
switch (direction) {
|
||||
case "left":
|
||||
matrix = matrix + 1 > 8 ? 1 : matrix + 1;
|
||||
|
@ -161,9 +161,11 @@ function move(direction: string, [matrix, level]: [number, number]) {
|
|||
}
|
||||
|
||||
return [matrix, level];
|
||||
}
|
||||
};
|
||||
|
||||
export const findNode = (
|
||||
nodeId: string,
|
||||
|
||||
export function findNode(
|
||||
direction: string,
|
||||
|
||||
{
|
||||
|
@ -174,18 +176,26 @@ export function findNode(
|
|||
|
||||
level: number,
|
||||
currentSite: string,
|
||||
gameProgress: any
|
||||
): any | undefined {
|
||||
const funcs: any = {
|
||||
gameProgress: typeof game_progress,
|
||||
shouldSearchNext: boolean
|
||||
) => {
|
||||
const funcs: {
|
||||
[key: string]: (([row, col]: [number, number]) => Generator<
|
||||
number[],
|
||||
void
|
||||
>)[];
|
||||
} = {
|
||||
left: [nextPos_left, ([r]: [number, number]) => nextPos_right([r, -1])],
|
||||
right: [nextPos_right, ([r]: [number, number]) => nextPos_left([r, 4])],
|
||||
up: [nextPos_up, ([, c]: [number, number]) => nextPos_up([3, c])],
|
||||
down: [nextPos_down, ([, c]: [number, number]) => nextPos_down([-1, c])],
|
||||
};
|
||||
|
||||
const initialMatrixIdx = matrixIdx;
|
||||
|
||||
const nextPos = funcs[direction];
|
||||
|
||||
for (let i = 0; i < 2; i++) {
|
||||
for (let i = 0; i < (shouldSearchNext ? 2 : 1); i++) {
|
||||
const nodes = getVisibleNodesMatrix(
|
||||
matrixIdx,
|
||||
level,
|
||||
|
@ -212,7 +222,21 @@ export function findNode(
|
|||
|
||||
[matrixIdx, level] = move(direction, [matrixIdx, level]);
|
||||
}
|
||||
}
|
||||
|
||||
if (nodeId === "") [matrixIdx] = move(direction, [initialMatrixIdx, level]);
|
||||
|
||||
if (direction === "up" || direction === "down" || nodeId === "") {
|
||||
return {
|
||||
node: "unknown",
|
||||
matrixIndices: {
|
||||
matrixIdx,
|
||||
rowIdx: rowIdx,
|
||||
colIdx: colIdx,
|
||||
},
|
||||
didMove: true,
|
||||
};
|
||||
}
|
||||
};
|
||||
export const filterInvisibleNodes = (
|
||||
siteData: SiteType,
|
||||
gameProgress: typeof game_progress
|
||||
|
@ -234,3 +258,26 @@ export const filterInvisibleNodes = (
|
|||
|
||||
return visibleNodes;
|
||||
};
|
||||
|
||||
export const unknownNodeTemplate = {
|
||||
id: "",
|
||||
image_table_indices: {
|
||||
"1": "",
|
||||
"2": "",
|
||||
"3": "",
|
||||
},
|
||||
media_file: "",
|
||||
node_name: "Unknown",
|
||||
required_final_video_viewcount: 0,
|
||||
site: "",
|
||||
title: "",
|
||||
triggers_final_video: 0,
|
||||
type: 0,
|
||||
unlocked_by: "",
|
||||
upgrade_requirement: 0,
|
||||
words: {
|
||||
"1": "",
|
||||
"2": "",
|
||||
"3": "",
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue