// @generated by protobuf-ts 2.11.1
// @generated from protobuf file "cell.proto" (package "aegis", syntax proto3)
// tslint:disable
import type { BinaryWriteOptions } from "@protobuf-ts/runtime";
import type { IBinaryWriter } 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 { WireType } from "@protobuf-ts/runtime";
import type { PartialMessage } from "@protobuf-ts/runtime";
import { reflectionMergePartial } from "@protobuf-ts/runtime";
import { MessageType } from "@protobuf-ts/runtime";
import { WorldObject } from "./world_object";
import { Location } from "./location";
/**
 * @generated from protobuf message aegis.Cell
 */
export interface Cell {
    /**
     * @generated from protobuf field: aegis.Location loc = 1
     */
    loc?: Location;
    /**
     * @generated from protobuf field: int32 moveCost = 2
     */
    moveCost: number;
    /**
     * @generated from protobuf field: aegis.CellType type = 3
     */
    type: CellType;
    /**
     * @generated from protobuf field: repeated int32 agents = 4
     */
    agents: number[];
    /**
     * @generated from protobuf field: repeated aegis.WorldObject layers = 5
     */
    layers: WorldObject[];
}
/**
 * @generated from protobuf enum aegis.CellType
 */
export enum CellType {
    /**
     * @generated from protobuf enum value: NORMAL = 0;
     */
    NORMAL = 0,
    /**
     * @generated from protobuf enum value: SPAWN = 1;
     */
    SPAWN = 1,
    /**
     * @generated from protobuf enum value: KILLER = 2;
     */
    KILLER = 2,
    /**
     * @generated from protobuf enum value: CHARGING = 3;
     */
    CHARGING = 3
}
// @generated message type with reflection information, may provide speed optimized methods
class Cell$Type extends MessageType<Cell> {
    constructor() {
        super("aegis.Cell", [
            { no: 1, name: "loc", kind: "message", T: () => Location },
            { no: 2, name: "moveCost", kind: "scalar", T: 5 /*ScalarType.INT32*/ },
            { no: 3, name: "type", kind: "enum", T: () => ["aegis.CellType", CellType] },
            { no: 4, name: "agents", kind: "scalar", repeat: 1 /*RepeatType.PACKED*/, T: 5 /*ScalarType.INT32*/ },
            { no: 5, name: "layers", kind: "message", repeat: 2 /*RepeatType.UNPACKED*/, T: () => WorldObject }
        ]);
    }
    create(value?: PartialMessage<Cell>): Cell {
        const message = globalThis.Object.create((this.messagePrototype!));
        message.moveCost = 0;
        message.type = 0;
        message.agents = [];
        message.layers = [];
        if (value !== undefined)
            reflectionMergePartial<Cell>(this, message, value);
        return message;
    }
    internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Cell): Cell {
        let message = target ?? this.create(), end = reader.pos + length;
        while (reader.pos < end) {
            let [fieldNo, wireType] = reader.tag();
            switch (fieldNo) {
                case /* aegis.Location loc */ 1:
                    message.loc = Location.internalBinaryRead(reader, reader.uint32(), options, message.loc);
                    break;
                case /* int32 moveCost */ 2:
                    message.moveCost = reader.int32();
                    break;
                case /* aegis.CellType type */ 3:
                    message.type = reader.int32();
                    break;
                case /* repeated int32 agents */ 4:
                    if (wireType === WireType.LengthDelimited)
                        for (let e = reader.int32() + reader.pos; reader.pos < e;)
                            message.agents.push(reader.int32());
                    else
                        message.agents.push(reader.int32());
                    break;
                case /* repeated aegis.WorldObject layers */ 5:
                    message.layers.push(WorldObject.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: Cell, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
        /* aegis.Location loc = 1; */
        if (message.loc)
            Location.internalBinaryWrite(message.loc, writer.tag(1, WireType.LengthDelimited).fork(), options).join();
        /* int32 moveCost = 2; */
        if (message.moveCost !== 0)
            writer.tag(2, WireType.Varint).int32(message.moveCost);
        /* aegis.CellType type = 3; */
        if (message.type !== 0)
            writer.tag(3, WireType.Varint).int32(message.type);
        /* repeated int32 agents = 4; */
        if (message.agents.length) {
            writer.tag(4, WireType.LengthDelimited).fork();
            for (let i = 0; i < message.agents.length; i++)
                writer.int32(message.agents[i]);
            writer.join();
        }
        /* repeated aegis.WorldObject layers = 5; */
        for (let i = 0; i < message.layers.length; i++)
            WorldObject.internalBinaryWrite(message.layers[i], writer.tag(5, 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.Cell
 */
export const Cell = new Cell$Type();
