import { OutPacketBase } from 'packets/out/packet' ; import { UserLoadout } from 'user/userloadout' ; class export class OutFavoritePresetLoadout { public static build ( loadouts , outPacket ) { outPacket . writeUInt8 ( loadouts . length * 16 ) ; for ( const loadout of loadouts ) { this . writeLoadout ( outPacket , loadout ) ; } } private static writeItem ( outPacket , item , curIndex , loadoutNum ) { outPacket . writeUInt8 ( loadoutNum ) ; outPacket . writeUInt8 ( curIndex ) ; outPacket . writeUInt32 ( item ) ; } private static writeLoadout ( outPacket , loadout ) { let curItem = 0 ; this . writeItem ( outPacket , loadout . primary_weapon , curItem ++ , loadout . loadout_num ) ; this . writeItem ( outPacket , loadout . secondary_weapon , curItem ++ , loadout . loadout_num ) ; this . writeItem ( outPacket , loadout . melee , curItem ++ , loadout . loadout_num ) ; this . writeItem ( outPacket , loadout . hegrenade , curItem ++ , loadout . loadout_num ) ; this . writeItem ( outPacket , loadout . smoke , curItem ++ , loadout . loadout_num ) ; this . writeItem ( outPacket , loadout . flash , curItem ++ , loadout . loadout_num ) ; for ( ; curItem < 16 ; curItem ++ ) { outPacket . writeUInt8 ( loadout . loadout_num ) ; outPacket . writeUInt8 ( curItem ) ; outPacket . writeUInt32 ( 0 ) ; } } }