public static Variant FromStream(IStarboundStream stream) { var variant = new Variant(); byte type = stream.ReadUInt8(); switch (type) { case 1: variant.Value = null; break; case 2: variant.Value = stream.ReadDouble(); break; case 3: variant.Value = stream.ReadBoolean(); break; case 4: variant.Value = stream.ReadVLQ(); break; case 5: variant.Value = stream.ReadString(); break; case 6: var array = new Variant[stream.ReadVLQ()]; for (int i = 0; i < array.Length; i++) { array[i] = FromStream(stream); } variant.Value = array; break; case 7: var dict = new VariantDict(); var length = stream.ReadVLQ(); while (length-- > 0) { dict[stream.ReadString()] = FromStream(stream); } variant.Value = dict; break; default: throw new InvalidOperationException(string.Format("Unknown Variant type: 0x{0:X2}", type)); } return(variant); }
public override void Read(IStarboundStream stream) { Success = stream.ReadBoolean(); ClientId = stream.ReadVLQ(); RejectionReason = stream.ReadString(); CelestialInfos = new List <CelestialInfo>(); ulong length = stream.ReadVLQ(); for (ulong i = 0; i < length; i++) { CelestialInfos.Add(CelestialInfo.FromStream(stream)); } }
public static ItemDescriptor FromStream(IStarboundStream stream) { ItemDescriptor idescr = new ItemDescriptor(); idescr.name = stream.ReadString(); idescr.count = stream.ReadVLQ(); // SharpStarLogger.DefaultLogger.Info("name:"+idescr.name+",count"+idescr.count); idescr.parameters = Json.FromStream(stream); return(idescr); }
public override void Read(IStarboundStream stream) { ulong vlq = stream.ReadVLQ(); Position = new List <Vec2I>(); for (int i = 0; i < (int)vlq; i++) { Vec2I vec = Vec2I.FromStream(stream); Position.Add(vec); } Layer = (TileLayer)stream.ReadUInt8(); SourcePos = Vec2F.FromStream(stream); TileDamage = TileDamage.FromStream(stream); }
public override void Read(IStarboundStream stream) { CurrentStep = stream.ReadVLQ(); }
public override void Read(IStarboundStream stream) { EntityId = stream.ReadInt32(); item = ItemDescriptor.FromStream(stream); slot = stream.ReadVLQ(); }
public static Json FromStream(IStarboundStream stream) { var json = new Json(); var type = stream.ReadUInt8(); switch (type) { case 0: json.Value = null; break; case 1: json.Value = stream.ReadSingle(); break; case 2: json.Value = stream.ReadBoolean(); break; case 3: json.Value = stream.ReadInt32(); break; case 4: json.Value = stream.ReadString(); break; case 5: var array = new Json[stream.ReadVLQ()]; for (int i = 0; i < array.Length; i++) { array[i] = FromStream(stream); } json.Value = array; break; case 6: var dict = new JsonDict(); var length = stream.ReadVLQ(); while (length-- > 0) { dict[stream.ReadString()] = FromStream(stream); } json.Value = dict; break; case 7: var dict1 = new JsonDict(); var length2 = stream.ReadVLQ(); while (length2-- > 0) { dict1[stream.ReadString()] = FromStream(stream); } json.Value = dict1; break; default: throw new InvalidOperationException(string.Format("Unknown Json type: 0x{0:X2}", type)); } return(json); }