UNPKG

marga

Version:
55 lines (54 loc) 1.28 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const InnerError_1 = require("../../error/InnerError"); /** * Entiy for road. It implements the interface IEntity. */ class Entity { _prev; _next; _index = -1; _tagArray = []; _gameId; constructor(gameId) { this._gameId = gameId; } getGameId() { return this._gameId; } setNextEntity(entity) { const converted = entity; this._next = converted; } getNextEntity() { const converted = this._next; return converted; } setIndex(index) { this._index = index; } setPreviousEntity(entity) { if (!(entity instanceof Entity)) { throw new InnerError_1.default('[Entity][setPreviousEntity]: parameter entity should a instance of Entity!'); } this._prev = entity; // entity.setNextEntity(this) entity._next = this; } getIndex() { return this._index; } getPreviousEntity() { if (!this._prev) { return undefined; } return this._prev; } getTagArray() { return [...this._tagArray]; } addTag(tag) { this._tagArray.push(tag); } } exports.default = Entity;