You've already forked Nitro_Render_V3
mirror of
https://github.com/duckietm/Nitro_Render_V3.git
synced 2026-06-20 07:26:18 +00:00
53 lines
1.1 KiB
TypeScript
53 lines
1.1 KiB
TypeScript
import { IAdvancedMap, IMessageDataWrapper, IMessageParser } from '@nitrots/api';
|
|
import { AdvancedMap } from '@nitrots/utils';
|
|
|
|
export class UnseenItemsParser implements IMessageParser
|
|
{
|
|
private _items: IAdvancedMap<number, number[]>;
|
|
|
|
public flush(): boolean
|
|
{
|
|
this._items = new AdvancedMap();
|
|
|
|
return true;
|
|
}
|
|
|
|
public parse(wrapper: IMessageDataWrapper): boolean
|
|
{
|
|
if(!wrapper) return false;
|
|
|
|
let totalUnseen = wrapper.readInt();
|
|
|
|
while(totalUnseen > 0)
|
|
{
|
|
const category = wrapper.readInt();
|
|
|
|
let totalItems = wrapper.readInt();
|
|
const itemIds: number[] = [];
|
|
|
|
while(totalItems > 0)
|
|
{
|
|
itemIds.push(wrapper.readInt());
|
|
|
|
totalItems--;
|
|
}
|
|
|
|
this._items.add(category, itemIds);
|
|
|
|
totalUnseen--;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public getItemsByCategory(category: number): number[]
|
|
{
|
|
return this._items.getValue(category);
|
|
}
|
|
|
|
public get categories(): number[]
|
|
{
|
|
return this._items.getKeys();
|
|
}
|
|
}
|