2020-05-09 14:45:23 +00:00
|
|
|
import { BasicSerializableObject } from "../savegame/serialization";
|
|
|
|
|
|
|
|
export class Component extends BasicSerializableObject {
|
|
|
|
/**
|
|
|
|
* Returns the components unique id
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
static getId() {
|
|
|
|
abstract;
|
|
|
|
return "unknown-component";
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Should return the schema used for serialization
|
|
|
|
*/
|
|
|
|
static getSchema() {
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
2020-05-27 12:30:59 +00:00
|
|
|
/**
|
2020-09-19 19:41:48 +00:00
|
|
|
* Copy the current state to another component
|
|
|
|
* @param {Component} otherComponent
|
2020-05-27 12:30:59 +00:00
|
|
|
*/
|
2020-09-19 19:41:48 +00:00
|
|
|
copyAdditionalStateTo(otherComponent) {}
|
2020-05-27 12:30:59 +00:00
|
|
|
|
2020-05-09 14:45:23 +00:00
|
|
|
/* dev:start */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fixes typeof DerivedComponent is not assignable to typeof Component, compiled out
|
|
|
|
* in non-dev builds
|
|
|
|
*/
|
|
|
|
constructor(...args) {
|
|
|
|
super();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a string representing the components data, only in dev builds
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
getDebugString() {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
/* dev:end */
|
|
|
|
}
|
2020-08-06 09:28:28 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* TypeScript does not support Abstract Static methods (https://github.com/microsoft/TypeScript/issues/34516)
|
|
|
|
* One workaround is to declare the type of the component and reference that for static methods
|
|
|
|
* @typedef {typeof Component} StaticComponent
|
|
|
|
*/
|