import { BinaryClassSerializationAdapter } from "../../../storage/binary/BinaryClassSerializationAdapter.js";
import ClingToTerrain from "./ClingToTerrain.js";

export class ClingToTerrainSerializationAdapter extends BinaryClassSerializationAdapter {

    klass = ClingToTerrain;
    version = 1;

    /**
     *
     * @param {BinaryBuffer} buffer
     * @param {ClingToTerrain} value
     */
    serialize(buffer, value) {
        buffer.writeUint8(value.normalAlign ? 1 : 0);
        buffer.writeFloat32(value.rotationSpeed);
    }

    /**
     *
     * @param {BinaryBuffer} buffer
     * @param {ClingToTerrain} value
     */
    deserialize(buffer, value) {
        value.normalAlign = buffer.readUint8() !== 0;
        value.rotationSpeed = buffer.readFloat32();
    }
}
