UNPKG

prendy

Version:

Make games with prerendered backdrops using babylonjs and repond

37 lines (36 loc) 1.47 kB
import { forEach } from "chootils/dist/loops"; export default function characters(prendyAssets) { const { characterNames, dollNames, characterOptions } = prendyAssets; const getDefaultState = (_characterName, dollName) => { return { dollName: (dollName ?? dollNames[0]), // Colliders atTriggers: {}, atCamCubes: {}, hasLeftFirstTrigger: true, // when going to a new place, it waits to leave the first trigger before triggers work again }; }; const getDefaultRefs = (_characterName) => ({ testRef: null, }); // hacky way to get return type from generic function // from Colin at https://stackoverflow.com/questions/50321419/typescript-returntype-of-generic-function class StateReturnType_Generic_Helper { // wrapped has no explicit return type so we can infer it wrapped(a, b) { return getDefaultState(a, b); } } function makeAutmaticCharacterStartStates() { const partialModelStates = {}; forEach(characterNames, (characterName) => { partialModelStates[characterName] = getDefaultState(characterName, characterOptions[characterName].doll); }); return partialModelStates; } const startStates = { ...makeAutmaticCharacterStartStates(), // friend: state("friend", "friend"), }; return { startStates, getDefaultState, getDefaultRefs }; }