UNPKG

novaparse

Version:
37 lines 1.36 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); // The general design pattern for these resource parsers is for all properties to be getters. // This makes parsing happen just in time so that you don't, say, parse ALL of the pictures // before you actually need them (thus delaying the game's startup time). // This class is an exception, however, since none of its properties could easily // be replaced with getters. class BaseResource { constructor(resource, idSpace) { this.idSpace = idSpace; this.name = resource.name; this.id = resource.id; this.data = resource.data; this._globalID = null; // This is set by IDSpaceHandler in getIDSpaceUnsafe this._prefix = null; // Same for this } get globalID() { if (this._globalID == null) { throw new Error("globalID of " + this.name + " was requested before it was set"); } return this._globalID; } set globalID(id) { this._globalID = id; } get prefix() { if (this._prefix == null) { throw new Error("prefix of " + this.name + " was requested before it was set"); } return this._prefix; } set prefix(id) { this._prefix = id; } } exports.BaseResource = BaseResource; //# sourceMappingURL=NovaResourceBase.js.map