UNPKG

novaparse

Version:
74 lines 3.52 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const BaseParse_1 = require("./BaseParse"); const Animation_1 = require("novadatainterface/Animation"); const NovaDataInterface_1 = require("novadatainterface/NovaDataInterface"); function ShanParse(shan, notFoundFunction) { return __awaiter(this, void 0, void 0, function* () { var base = yield BaseParse_1.BaseParse(shan, notFoundFunction); var images = { baseImage: Animation_1.DefaultAnimationImage }; var imageNames = ['baseImage', 'altImage', 'glowImage', 'lightImage', 'weapImage']; for (var index in imageNames) { var imageName = imageNames[index]; var imageInfo = shan.images[imageName]; if (imageInfo === null) { continue; // That image does not exist for this Shan } var imagePurposes = { normal: { start: 0, length: shan.framesPer } }; switch (shan.flags.extraFramePurpose) { case ('banking'): imagePurposes.left = { start: shan.framesPer, length: shan.framesPer, }; imagePurposes.right = { start: shan.framesPer * 2, length: shan.framesPer }; break; case ('animation'): imagePurposes.animation = { start: shan.framesPer, // The rest of the frames are for the animation length: shan.framesPer * ((imageInfo.setCount || shan.images.baseImage.setCount) - 1) }; break; } // get the rled from novadata // The rled contains the ID of the image that is used. var rled = shan.idSpace.rlëD[imageInfo.ID]; if (!rled) { notFoundFunction("shän id " + base.id + " has no corresponding rlëD for " + imageName + ", which expects rlëD id " + imageInfo.ID + " to be available."); if (imageName == "baseImage") { // Everything must have a baseImage. throw new NovaDataInterface_1.NovaIDNotFoundError("Base image not found for rlëD id " + imageInfo.ID); } continue; // Don't add this as an image since it wasn't found. } // Store the image in images images[imageName] = { id: rled.globalID, imagePurposes }; } return Object.assign({}, base, { images, exitPoints: shan.exitPoints }); }); } exports.ShanParse = ShanParse; //# sourceMappingURL=ShanParse.js.map