@abextm/cache2
Version:
Utilities for reading OSRS "caches"
38 lines (37 loc) • 996 B
JavaScript
import { PerFileLoadable } from "../Loadable.js";
import { Typed } from "../reflect.js";
export class Param extends PerFileLoadable {
id;
constructor(id) {
super();
this.id = id;
}
static index = 2;
static archive = 11;
type = 0;
isMembers = true;
defaultInt = 0;
defaultString = null;
static decode(r, id) {
const v = new Param(id);
for (let opcode; (opcode = r.u8()) != 0;) {
switch (opcode) {
case 1:
v.type = r.u8();
break;
case 2:
v.defaultInt = r.i32();
break;
case 4:
v.isMembers = false;
break;
case 5:
v.defaultString = r.string();
break;
default:
throw new Error(`unknown opcode ${opcode}`);
}
}
return v;
}
}