mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-04 08:41:34 +08:00
Vector2D support
This commit is contained in:
@@ -24,7 +24,9 @@ import UnionType from "../entity/UnionType"
|
||||
import UnknownKeysEntity from "../entity/UnknownKeysEntity"
|
||||
import Utility from "../Utility"
|
||||
import VariableReferenceEntity from "../entity/VariableReferenceEntity"
|
||||
import Vector2DEntity from "../entity/Vector2DEntity"
|
||||
import VectorEntity from "../entity/VectorEntity"
|
||||
import SimpleSerializationVector2DEntity from "../entity/SimpleSerializationVector2DEntity"
|
||||
|
||||
let P = Parsimmon
|
||||
|
||||
@@ -89,6 +91,8 @@ export default class Grammar {
|
||||
return r.Rotator
|
||||
case SimpleSerializationRotatorEntity:
|
||||
return r.SimpleSerializationRotator
|
||||
case SimpleSerializationVector2DEntity:
|
||||
return r.SimpleSerializationVector2D
|
||||
case SimpleSerializationVectorEntity:
|
||||
return r.SimpleSerializationVector
|
||||
case String:
|
||||
@@ -103,6 +107,8 @@ export default class Grammar {
|
||||
: accum.or(cur))
|
||||
case VariableReferenceEntity:
|
||||
return r.VariableReference
|
||||
case Vector2DEntity:
|
||||
return r.Vector2D
|
||||
case VectorEntity:
|
||||
return r.Vector
|
||||
default:
|
||||
@@ -308,6 +314,7 @@ export default class Grammar {
|
||||
r.LocalizedText,
|
||||
r.InvariantText,
|
||||
r.PinReference,
|
||||
Grammar.createEntityGrammar(r, Vector2DEntity, true),
|
||||
Grammar.createEntityGrammar(r, VectorEntity, true),
|
||||
Grammar.createEntityGrammar(r, LinearColorEntity, true),
|
||||
r.UnknownKeys,
|
||||
@@ -326,6 +333,9 @@ export default class Grammar {
|
||||
})
|
||||
)
|
||||
|
||||
/** @param {Grammar} r */
|
||||
Vector2D = r => Grammar.createEntityGrammar(r, Vector2DEntity)
|
||||
|
||||
/** @param {Grammar} r */
|
||||
Vector = r => Grammar.createEntityGrammar(r, VectorEntity)
|
||||
|
||||
@@ -346,6 +356,17 @@ export default class Grammar {
|
||||
})
|
||||
)
|
||||
|
||||
/** @param {Grammar} r */
|
||||
SimpleSerializationVector2D = r => P.seqMap(
|
||||
r.Number,
|
||||
P.string(",").trim(P.optWhitespace),
|
||||
r.Number,
|
||||
(x, _1, y) => new SimpleSerializationVector2DEntity({
|
||||
X: x,
|
||||
Y: y,
|
||||
})
|
||||
)
|
||||
|
||||
/** @param {Grammar} r */
|
||||
SimpleSerializationVector = r => P.seqMap(
|
||||
r.Number,
|
||||
|
||||
@@ -25,7 +25,9 @@ import ToStringSerializer from "./ToStringSerializer"
|
||||
import UnknownKeysEntity from "../entity/UnknownKeysEntity"
|
||||
import Utility from "../Utility"
|
||||
import VariableReferenceEntity from "../entity/VariableReferenceEntity"
|
||||
import Vector2DEntity from "../entity/Vector2DEntity"
|
||||
import VectorEntity from "../entity/VectorEntity"
|
||||
import SimpleSerializationVector2DEntity from "../entity/SimpleSerializationVector2DEntity"
|
||||
|
||||
export default function initializeSerializerFactory() {
|
||||
|
||||
@@ -186,6 +188,14 @@ export default function initializeSerializerFactory() {
|
||||
)
|
||||
)
|
||||
|
||||
SerializerFactory.registerSerializer(
|
||||
SimpleSerializationVector2DEntity,
|
||||
new CustomSerializer(
|
||||
(value, insideString) => `${value.X}, ${value.Y}`,
|
||||
SimpleSerializationVector2DEntity
|
||||
)
|
||||
)
|
||||
|
||||
SerializerFactory.registerSerializer(
|
||||
SimpleSerializationVectorEntity,
|
||||
new CustomSerializer(
|
||||
@@ -209,6 +219,11 @@ export default function initializeSerializerFactory() {
|
||||
new GeneralSerializer(bracketsWrapped, VariableReferenceEntity)
|
||||
)
|
||||
|
||||
SerializerFactory.registerSerializer(
|
||||
Vector2DEntity,
|
||||
new GeneralSerializer(bracketsWrapped, Vector2DEntity)
|
||||
)
|
||||
|
||||
SerializerFactory.registerSerializer(
|
||||
VectorEntity,
|
||||
new GeneralSerializer(bracketsWrapped, VectorEntity)
|
||||
|
||||
Reference in New Issue
Block a user