mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-04 08:50:33 +08:00
27 lines
937 B
JavaScript
27 lines
937 B
JavaScript
import P from "parsernostrum"
|
|
import Grammar from "../serialization/Grammar.js"
|
|
import Vector2DEntity from "./Vector2DEntity.js"
|
|
|
|
export default class RBSerializationVector2DEntity extends Vector2DEntity {
|
|
|
|
static grammar = this.createGrammar()
|
|
|
|
/** @returns {P<RBSerializationVector2DEntity>} */
|
|
static createGrammar() {
|
|
return P.alt(
|
|
P.regArray(new RegExp(
|
|
/X\s*=\s*/.source + "(?<x>" + Grammar.numberRegexSource + ")"
|
|
+ "\\s+"
|
|
+ /Y\s*=\s*/.source + "(?<y>" + Grammar.numberRegexSource + ")"
|
|
)).map(({ groups: { x, y } }) => new this({
|
|
X: new (Vector2DEntity.attributes.X)(x),
|
|
Y: new (Vector2DEntity.attributes.Y)(y),
|
|
})),
|
|
Vector2DEntity.grammar.map(v => new this({
|
|
X: v.X,
|
|
Y: v.Y,
|
|
}))
|
|
).label("RBSerializationVector2DEntity")
|
|
}
|
|
}
|