// automatically generated by the FlatBuffers compiler, do not modify

/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */

import { CommandFleetMerge, CommandFleetMergeT } from '../order/command-fleet-merge.js';
import { CommandFleetSend, CommandFleetSendT } from '../order/command-fleet-send.js';
import { CommandPlanetProduce, CommandPlanetProduceT } from '../order/command-planet-produce.js';
import { CommandPlanetRename, CommandPlanetRenameT } from '../order/command-planet-rename.js';
import { CommandPlanetRouteRemove, CommandPlanetRouteRemoveT } from '../order/command-planet-route-remove.js';
import { CommandPlanetRouteSet, CommandPlanetRouteSetT } from '../order/command-planet-route-set.js';
import { CommandRaceQuit, CommandRaceQuitT } from '../order/command-race-quit.js';
import { CommandRaceRelation, CommandRaceRelationT } from '../order/command-race-relation.js';
import { CommandRaceVote, CommandRaceVoteT } from '../order/command-race-vote.js';
import { CommandScienceCreate, CommandScienceCreateT } from '../order/command-science-create.js';
import { CommandScienceRemove, CommandScienceRemoveT } from '../order/command-science-remove.js';
import { CommandShipClassCreate, CommandShipClassCreateT } from '../order/command-ship-class-create.js';
import { CommandShipClassMerge, CommandShipClassMergeT } from '../order/command-ship-class-merge.js';
import { CommandShipClassRemove, CommandShipClassRemoveT } from '../order/command-ship-class-remove.js';
import { CommandShipGroupBreak, CommandShipGroupBreakT } from '../order/command-ship-group-break.js';
import { CommandShipGroupDismantle, CommandShipGroupDismantleT } from '../order/command-ship-group-dismantle.js';
import { CommandShipGroupJoinFleet, CommandShipGroupJoinFleetT } from '../order/command-ship-group-join-fleet.js';
import { CommandShipGroupLoad, CommandShipGroupLoadT } from '../order/command-ship-group-load.js';
import { CommandShipGroupMerge, CommandShipGroupMergeT } from '../order/command-ship-group-merge.js';
import { CommandShipGroupSend, CommandShipGroupSendT } from '../order/command-ship-group-send.js';
import { CommandShipGroupTransfer, CommandShipGroupTransferT } from '../order/command-ship-group-transfer.js';
import { CommandShipGroupUnload, CommandShipGroupUnloadT } from '../order/command-ship-group-unload.js';
import { CommandShipGroupUpgrade, CommandShipGroupUpgradeT } from '../order/command-ship-group-upgrade.js';


export enum CommandPayload {
  NONE = 0,
  CommandRaceQuit = 1,
  CommandRaceVote = 2,
  CommandRaceRelation = 3,
  CommandShipClassCreate = 4,
  CommandShipClassMerge = 5,
  CommandShipClassRemove = 6,
  CommandShipGroupBreak = 7,
  CommandShipGroupLoad = 8,
  CommandShipGroupUnload = 9,
  CommandShipGroupSend = 10,
  CommandShipGroupUpgrade = 11,
  CommandShipGroupMerge = 12,
  CommandShipGroupDismantle = 13,
  CommandShipGroupTransfer = 14,
  CommandShipGroupJoinFleet = 15,
  CommandFleetMerge = 16,
  CommandFleetSend = 17,
  CommandScienceCreate = 18,
  CommandScienceRemove = 19,
  CommandPlanetRename = 20,
  CommandPlanetProduce = 21,
  CommandPlanetRouteSet = 22,
  CommandPlanetRouteRemove = 23
}

export function unionToCommandPayload(
  type: CommandPayload,
  accessor: (obj:CommandFleetMerge|CommandFleetSend|CommandPlanetProduce|CommandPlanetRename|CommandPlanetRouteRemove|CommandPlanetRouteSet|CommandRaceQuit|CommandRaceRelation|CommandRaceVote|CommandScienceCreate|CommandScienceRemove|CommandShipClassCreate|CommandShipClassMerge|CommandShipClassRemove|CommandShipGroupBreak|CommandShipGroupDismantle|CommandShipGroupJoinFleet|CommandShipGroupLoad|CommandShipGroupMerge|CommandShipGroupSend|CommandShipGroupTransfer|CommandShipGroupUnload|CommandShipGroupUpgrade) => CommandFleetMerge|CommandFleetSend|CommandPlanetProduce|CommandPlanetRename|CommandPlanetRouteRemove|CommandPlanetRouteSet|CommandRaceQuit|CommandRaceRelation|CommandRaceVote|CommandScienceCreate|CommandScienceRemove|CommandShipClassCreate|CommandShipClassMerge|CommandShipClassRemove|CommandShipGroupBreak|CommandShipGroupDismantle|CommandShipGroupJoinFleet|CommandShipGroupLoad|CommandShipGroupMerge|CommandShipGroupSend|CommandShipGroupTransfer|CommandShipGroupUnload|CommandShipGroupUpgrade|null
): CommandFleetMerge|CommandFleetSend|CommandPlanetProduce|CommandPlanetRename|CommandPlanetRouteRemove|CommandPlanetRouteSet|CommandRaceQuit|CommandRaceRelation|CommandRaceVote|CommandScienceCreate|CommandScienceRemove|CommandShipClassCreate|CommandShipClassMerge|CommandShipClassRemove|CommandShipGroupBreak|CommandShipGroupDismantle|CommandShipGroupJoinFleet|CommandShipGroupLoad|CommandShipGroupMerge|CommandShipGroupSend|CommandShipGroupTransfer|CommandShipGroupUnload|CommandShipGroupUpgrade|null {
  switch(CommandPayload[type]) {
    case 'NONE': return null; 
    case 'CommandRaceQuit': return accessor(new CommandRaceQuit())! as CommandRaceQuit;
    case 'CommandRaceVote': return accessor(new CommandRaceVote())! as CommandRaceVote;
    case 'CommandRaceRelation': return accessor(new CommandRaceRelation())! as CommandRaceRelation;
    case 'CommandShipClassCreate': return accessor(new CommandShipClassCreate())! as CommandShipClassCreate;
    case 'CommandShipClassMerge': return accessor(new CommandShipClassMerge())! as CommandShipClassMerge;
    case 'CommandShipClassRemove': return accessor(new CommandShipClassRemove())! as CommandShipClassRemove;
    case 'CommandShipGroupBreak': return accessor(new CommandShipGroupBreak())! as CommandShipGroupBreak;
    case 'CommandShipGroupLoad': return accessor(new CommandShipGroupLoad())! as CommandShipGroupLoad;
    case 'CommandShipGroupUnload': return accessor(new CommandShipGroupUnload())! as CommandShipGroupUnload;
    case 'CommandShipGroupSend': return accessor(new CommandShipGroupSend())! as CommandShipGroupSend;
    case 'CommandShipGroupUpgrade': return accessor(new CommandShipGroupUpgrade())! as CommandShipGroupUpgrade;
    case 'CommandShipGroupMerge': return accessor(new CommandShipGroupMerge())! as CommandShipGroupMerge;
    case 'CommandShipGroupDismantle': return accessor(new CommandShipGroupDismantle())! as CommandShipGroupDismantle;
    case 'CommandShipGroupTransfer': return accessor(new CommandShipGroupTransfer())! as CommandShipGroupTransfer;
    case 'CommandShipGroupJoinFleet': return accessor(new CommandShipGroupJoinFleet())! as CommandShipGroupJoinFleet;
    case 'CommandFleetMerge': return accessor(new CommandFleetMerge())! as CommandFleetMerge;
    case 'CommandFleetSend': return accessor(new CommandFleetSend())! as CommandFleetSend;
    case 'CommandScienceCreate': return accessor(new CommandScienceCreate())! as CommandScienceCreate;
    case 'CommandScienceRemove': return accessor(new CommandScienceRemove())! as CommandScienceRemove;
    case 'CommandPlanetRename': return accessor(new CommandPlanetRename())! as CommandPlanetRename;
    case 'CommandPlanetProduce': return accessor(new CommandPlanetProduce())! as CommandPlanetProduce;
    case 'CommandPlanetRouteSet': return accessor(new CommandPlanetRouteSet())! as CommandPlanetRouteSet;
    case 'CommandPlanetRouteRemove': return accessor(new CommandPlanetRouteRemove())! as CommandPlanetRouteRemove;
    default: return null;
  }
}

export function unionListToCommandPayload(
  type: CommandPayload, 
  accessor: (index: number, obj:CommandFleetMerge|CommandFleetSend|CommandPlanetProduce|CommandPlanetRename|CommandPlanetRouteRemove|CommandPlanetRouteSet|CommandRaceQuit|CommandRaceRelation|CommandRaceVote|CommandScienceCreate|CommandScienceRemove|CommandShipClassCreate|CommandShipClassMerge|CommandShipClassRemove|CommandShipGroupBreak|CommandShipGroupDismantle|CommandShipGroupJoinFleet|CommandShipGroupLoad|CommandShipGroupMerge|CommandShipGroupSend|CommandShipGroupTransfer|CommandShipGroupUnload|CommandShipGroupUpgrade) => CommandFleetMerge|CommandFleetSend|CommandPlanetProduce|CommandPlanetRename|CommandPlanetRouteRemove|CommandPlanetRouteSet|CommandRaceQuit|CommandRaceRelation|CommandRaceVote|CommandScienceCreate|CommandScienceRemove|CommandShipClassCreate|CommandShipClassMerge|CommandShipClassRemove|CommandShipGroupBreak|CommandShipGroupDismantle|CommandShipGroupJoinFleet|CommandShipGroupLoad|CommandShipGroupMerge|CommandShipGroupSend|CommandShipGroupTransfer|CommandShipGroupUnload|CommandShipGroupUpgrade|null, 
  index: number
): CommandFleetMerge|CommandFleetSend|CommandPlanetProduce|CommandPlanetRename|CommandPlanetRouteRemove|CommandPlanetRouteSet|CommandRaceQuit|CommandRaceRelation|CommandRaceVote|CommandScienceCreate|CommandScienceRemove|CommandShipClassCreate|CommandShipClassMerge|CommandShipClassRemove|CommandShipGroupBreak|CommandShipGroupDismantle|CommandShipGroupJoinFleet|CommandShipGroupLoad|CommandShipGroupMerge|CommandShipGroupSend|CommandShipGroupTransfer|CommandShipGroupUnload|CommandShipGroupUpgrade|null {
  switch(CommandPayload[type]) {
    case 'NONE': return null; 
    case 'CommandRaceQuit': return accessor(index, new CommandRaceQuit())! as CommandRaceQuit;
    case 'CommandRaceVote': return accessor(index, new CommandRaceVote())! as CommandRaceVote;
    case 'CommandRaceRelation': return accessor(index, new CommandRaceRelation())! as CommandRaceRelation;
    case 'CommandShipClassCreate': return accessor(index, new CommandShipClassCreate())! as CommandShipClassCreate;
    case 'CommandShipClassMerge': return accessor(index, new CommandShipClassMerge())! as CommandShipClassMerge;
    case 'CommandShipClassRemove': return accessor(index, new CommandShipClassRemove())! as CommandShipClassRemove;
    case 'CommandShipGroupBreak': return accessor(index, new CommandShipGroupBreak())! as CommandShipGroupBreak;
    case 'CommandShipGroupLoad': return accessor(index, new CommandShipGroupLoad())! as CommandShipGroupLoad;
    case 'CommandShipGroupUnload': return accessor(index, new CommandShipGroupUnload())! as CommandShipGroupUnload;
    case 'CommandShipGroupSend': return accessor(index, new CommandShipGroupSend())! as CommandShipGroupSend;
    case 'CommandShipGroupUpgrade': return accessor(index, new CommandShipGroupUpgrade())! as CommandShipGroupUpgrade;
    case 'CommandShipGroupMerge': return accessor(index, new CommandShipGroupMerge())! as CommandShipGroupMerge;
    case 'CommandShipGroupDismantle': return accessor(index, new CommandShipGroupDismantle())! as CommandShipGroupDismantle;
    case 'CommandShipGroupTransfer': return accessor(index, new CommandShipGroupTransfer())! as CommandShipGroupTransfer;
    case 'CommandShipGroupJoinFleet': return accessor(index, new CommandShipGroupJoinFleet())! as CommandShipGroupJoinFleet;
    case 'CommandFleetMerge': return accessor(index, new CommandFleetMerge())! as CommandFleetMerge;
    case 'CommandFleetSend': return accessor(index, new CommandFleetSend())! as CommandFleetSend;
    case 'CommandScienceCreate': return accessor(index, new CommandScienceCreate())! as CommandScienceCreate;
    case 'CommandScienceRemove': return accessor(index, new CommandScienceRemove())! as CommandScienceRemove;
    case 'CommandPlanetRename': return accessor(index, new CommandPlanetRename())! as CommandPlanetRename;
    case 'CommandPlanetProduce': return accessor(index, new CommandPlanetProduce())! as CommandPlanetProduce;
    case 'CommandPlanetRouteSet': return accessor(index, new CommandPlanetRouteSet())! as CommandPlanetRouteSet;
    case 'CommandPlanetRouteRemove': return accessor(index, new CommandPlanetRouteRemove())! as CommandPlanetRouteRemove;
    default: return null;
  }
}
