// @generated by protobuf-ts 2.11.1
// @generated from protobuf file "world.proto" (package "aegis", syntax proto3)
// tslint:disable
import type { BinaryWriteOptions } from "@protobuf-ts/runtime";
import type { IBinaryWriter } from "@protobuf-ts/runtime";
import { WireType } from "@protobuf-ts/runtime";
import type { BinaryReadOptions } from "@protobuf-ts/runtime";
import type { IBinaryReader } from "@protobuf-ts/runtime";
import { UnknownFieldHandler } from "@protobuf-ts/runtime";
import type { PartialMessage } from "@protobuf-ts/runtime";
import { reflectionMergePartial } from "@protobuf-ts/runtime";
import { MessageType } from "@protobuf-ts/runtime";
import { InitSpawn } from "./spawn";
import { Cell } from "./cell";
/**
 * @generated from protobuf message aegis.World
 */
export interface World {
    /**
     * @generated from protobuf field: int32 width = 1
     */
    width: number;
    /**
     * @generated from protobuf field: int32 height = 2
     */
    height: number;
    /**
     * @generated from protobuf field: int32 seed = 3
     */
    seed: number;
    /**
     * @generated from protobuf field: int32 start_energy = 4
     */
    startEnergy: number;
    /**
     * @generated from protobuf field: repeated aegis.Cell cells = 5
     */
    cells: Cell[];
    /**
     * @generated from protobuf field: int32 total_survivors = 6
     */
    totalSurvivors: number;
    /**
     * @generated from protobuf field: repeated aegis.InitSpawn init_spawns = 7
     */
    initSpawns: InitSpawn[];
}
// @generated message type with reflection information, may provide speed optimized methods
class World$Type extends MessageType<World> {
    constructor() {
        super("aegis.World", [
            { no: 1, name: "width", kind: "scalar", T: 5 /*ScalarType.INT32*/ },
            { no: 2, name: "height", kind: "scalar", T: 5 /*ScalarType.INT32*/ },
            { no: 3, name: "seed", kind: "scalar", T: 5 /*ScalarType.INT32*/ },
            { no: 4, name: "start_energy", kind: "scalar", T: 5 /*ScalarType.INT32*/ },
            { no: 5, name: "cells", kind: "message", repeat: 2 /*RepeatType.UNPACKED*/, T: () => Cell },
            { no: 6, name: "total_survivors", kind: "scalar", T: 5 /*ScalarType.INT32*/ },
            { no: 7, name: "init_spawns", kind: "message", repeat: 2 /*RepeatType.UNPACKED*/, T: () => InitSpawn }
        ]);
    }
    create(value?: PartialMessage<World>): World {
        const message = globalThis.Object.create((this.messagePrototype!));
        message.width = 0;
        message.height = 0;
        message.seed = 0;
        message.startEnergy = 0;
        message.cells = [];
        message.totalSurvivors = 0;
        message.initSpawns = [];
        if (value !== undefined)
            reflectionMergePartial<World>(this, message, value);
        return message;
    }
    internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: World): World {
        let message = target ?? this.create(), end = reader.pos + length;
        while (reader.pos < end) {
            let [fieldNo, wireType] = reader.tag();
            switch (fieldNo) {
                case /* int32 width */ 1:
                    message.width = reader.int32();
                    break;
                case /* int32 height */ 2:
                    message.height = reader.int32();
                    break;
                case /* int32 seed */ 3:
                    message.seed = reader.int32();
                    break;
                case /* int32 start_energy */ 4:
                    message.startEnergy = reader.int32();
                    break;
                case /* repeated aegis.Cell cells */ 5:
                    message.cells.push(Cell.internalBinaryRead(reader, reader.uint32(), options));
                    break;
                case /* int32 total_survivors */ 6:
                    message.totalSurvivors = reader.int32();
                    break;
                case /* repeated aegis.InitSpawn init_spawns */ 7:
                    message.initSpawns.push(InitSpawn.internalBinaryRead(reader, reader.uint32(), options));
                    break;
                default:
                    let u = options.readUnknownField;
                    if (u === "throw")
                        throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
                    let d = reader.skip(wireType);
                    if (u !== false)
                        (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
            }
        }
        return message;
    }
    internalBinaryWrite(message: World, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
        /* int32 width = 1; */
        if (message.width !== 0)
            writer.tag(1, WireType.Varint).int32(message.width);
        /* int32 height = 2; */
        if (message.height !== 0)
            writer.tag(2, WireType.Varint).int32(message.height);
        /* int32 seed = 3; */
        if (message.seed !== 0)
            writer.tag(3, WireType.Varint).int32(message.seed);
        /* int32 start_energy = 4; */
        if (message.startEnergy !== 0)
            writer.tag(4, WireType.Varint).int32(message.startEnergy);
        /* repeated aegis.Cell cells = 5; */
        for (let i = 0; i < message.cells.length; i++)
            Cell.internalBinaryWrite(message.cells[i], writer.tag(5, WireType.LengthDelimited).fork(), options).join();
        /* int32 total_survivors = 6; */
        if (message.totalSurvivors !== 0)
            writer.tag(6, WireType.Varint).int32(message.totalSurvivors);
        /* repeated aegis.InitSpawn init_spawns = 7; */
        for (let i = 0; i < message.initSpawns.length; i++)
            InitSpawn.internalBinaryWrite(message.initSpawns[i], writer.tag(7, WireType.LengthDelimited).fork(), options).join();
        let u = options.writeUnknownFields;
        if (u !== false)
            (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
        return writer;
    }
}
/**
 * @generated MessageType for protobuf message aegis.World
 */
export const World = new World$Type();
