public static Packet Parse(KaitaiStream input, IParameterManager manager) { // get command var command = (RcpTypes.Command)input.ReadU1(); if (!Enum.IsDefined(typeof(RcpTypes.Command), command)) { throw new RCPDataErrorException("Packed parsing: Unknown command: " + command.ToString()); } var packet = new Packet(command); // read packet options while (!input.IsEof) { var code = input.ReadU1(); if (code == 0) // terminator { break; } var option = (RcpTypes.PacketOptions)code; if (!Enum.IsDefined(typeof(RcpTypes.PacketOptions), option)) { throw new RCPDataErrorException("Packet parsing: Unknown option: " + option.ToString()); } switch (option) { case RcpTypes.PacketOptions.Data: switch (command) { // case RcpTypes.Command.Initialize: // // init - should not happen // throw new RCPDataErrorException(); case RcpTypes.Command.Remove: case RcpTypes.Command.Update: // expect parameter packet.Data = Parameter.Parse(input, manager); break; case RcpTypes.Command.Version: packet.Data = new RcpTypes.TinyString(input); break; } break; case RcpTypes.PacketOptions.Timestamp: packet.Timestamp = input.ReadU8be(); break; default: throw new RCPUnsupportedFeatureException(); } } return(packet); }
public override Color ReadValue(KaitaiStream input) { var b = input.ReadU1(); var g = input.ReadU1(); var r = input.ReadU1(); var a = input.ReadU1(); // Server send alpha? return(new Color(r, g, b, 255)); }
public override Color ReadValue(KaitaiStream input) { var a = input.ReadU1(); var b = input.ReadU1(); var g = input.ReadU1(); var r = input.ReadU1(); return(new Color(r, g, b, a)); }
public override void ParseOptions(KaitaiStream input) { //read terminator input.ReadU1(); //execute bang OnBang?.Invoke(); }
public virtual void ParseOptions(KaitaiStream input) { while (true) { var code = input.ReadU1(); if (code == 0) // terminator { break; } // handle option in specific implementation if (!HandleOption(input, code)) { throw new RCPUnsupportedFeatureException(); } } }
public override bool ReadValue(KaitaiStream input) { return(input.ReadU1() > 0); }
public override byte ReadValue(KaitaiStream input) { return(input.ReadU1()); }