Serializer

Serializer

Abstract base class for piece serializers.

For each piece type there is a serializer that can convert the piece back and forth to a key, and that also provides metadata about the type for the map editor. Mirrors the Java Serializer interface exactly.

Subclasses must override all five methods.

Constructor

new Serializer()

Source:

Methods

create(args) → {Piece}

Description:
  • Reconstruct a piece from its resolved args array. String args are plain values; Piece args are already-resolved nested registry lookups (the Registry resolves "^"-escaped sub-keys before calling create, exactly as it does today).

Source:
Parameters:
Name Type Description
args Array.<(string|Piece)>
Returns:
Type
Piece

example() → {Piece}

Description:
  • Return a representative instance of this type for display in the map editor.

Source:
Returns:
Type
Piece

store(piece) → {string}

Description:
  • Return the canonical serialized key for this piece, e.g. "Door|Blue|off". The key must be parseable back via create().

Source:
Parameters:
Name Type Description
piece Piece
Returns:
Type
string

tag() → {string}

Description:
  • Return the editor category for this type, e.g. "Terrain", "Room Features".

Source:
Returns:
Type
string

template(typeId) → {string}

Description:
  • Given the typeId, return a human-readable template showing the key format, e.g. "Door|{color}|{state}". Used by the editor to guide authoring.

Source:
Parameters:
Name Type Description
typeId string
Returns:
Type
string