public void Write(NWriter wtr) { wtr.Write(Id); Position.Write(wtr); wtr.Write((short)Stats.Length); foreach (var i in Stats) { wtr.Write((byte)i.Key); if (i.Value is string) { wtr.WriteUTF(i.Value as string); } else { wtr.Write((int)i.Value); } } }
public void Write(Client psr, NWriter wtr) { try { wtr.Write(Id); Position.Write(psr, wtr); wtr.Write((ushort)Stats.Length); foreach (KeyValuePair <StatsType, object> i in Stats) { wtr.Write((byte)i.Key); if (i.Key.IsUTF() && i.Value != null) { wtr.WriteUTF(i.Value.ToString()); } else { wtr.Write((int)i.Value); } } } catch (Exception) { } }
public void Write(NWriter wtr) { wtr.Write(Id); Position.Write(wtr); wtr.Write((short)Stats.Length); foreach (var i in Stats) { wtr.Write((byte)i.Key); if (i.Value is int) { wtr.Write((int)i.Value); continue; } if (i.Value is string) { //Console.WriteLine(i.Key); wtr.WriteUTF(i.Value as string); continue; } if (i.Value is bool) { wtr.Write((bool)i.Value ? 1 : 0); continue; } if (i.Value is ushort) { wtr.Write((int)(ushort)i.Value); continue; } throw new InvalidOperationException( $"Stat '{i.Key}' of type '{i.Value?.GetType().ToString() ?? "null"}' not supported."); } }
public void Write(NWriter wtr) { try { wtr.Write(Id); Position.Write(wtr); wtr.Write((ushort)Stats.Length); foreach (var i in Stats) { wtr.Write((byte)i.Key); if (i.Value is int) { wtr.Write((int)i.Value); continue; } if (i.Value is string) { wtr.WriteUTF(i.Value.ToString()); continue; } if (i.Value is bool) { wtr.Write(i.Value.GetHashCode()); continue; } if (!(i.Value is ushort)) { throw new InvalidOperationException($"Stat '{i.Key}' of type '{i.Value?.GetType().ToString() ?? "null"}' not supported."); } wtr.Write((int)(ushort)i.Value); } } catch (Exception ex) { log.Error(ex); } }
public void Write(Client psr, NWriter wtr) { wtr.Write(Time); Position.Write(psr, wtr); }
public void Write(NWriter wtr) { wtr.Write(Time); Position.Write(wtr); }